PERFORCE change 145760 for review
Ed Schouten
ed at FreeBSD.org
Wed Jul 23 23:11:51 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=145760
Change 145760 by ed at ed_dull on 2008/07/23 23:11:45
Cleanups to grantpt.c:
- Move the pseudo-terminal master device tests to a new
__isptmaster() routine.
- Use __strong_reference() to link them to grantpt() and
unlockpt().
- Use __isptmaster() inside ptsname(), instead of using
TIOCPTMASTER directly.
Affected files ...
.. //depot/projects/mpsafetty/lib/libc/stdlib/grantpt.c#2 edit
Differences ...
==== //depot/projects/mpsafetty/lib/libc/stdlib/grantpt.c#2 (text+ko) ====
@@ -41,23 +41,13 @@
#include "un-namespace.h"
/*
- * grantpt(): grant ownership of a slave pseudo-terminal device to the
- * current user.
- *
- * unlockpt(): unlock a pseudo-terminal device pair.
+ * __isptmaster(): return whether the file descriptor refers to a
+ * pseudo-terminal master device.
*/
+static int
+__isptmaster(int fildes)
+{
-int
-grantpt(int fildes)
-{
- /*
- * In our implementation, grantpt() and unlockpt() don't
- * actually have any use, because PTY's are created on the fly
- * and already have proper permissions.
- *
- * Just make sure `fildes' actually points to a real PTY master
- * device.
- */
if (_ioctl(fildes, TIOCPTMASTER) == 0)
return (0);
@@ -67,7 +57,15 @@
return (-1);
}
-__weak_reference(grantpt, unlockpt);
+/*
+ * In our implementation, grantpt() and unlockpt() don't actually have
+ * any use, because PTY's are created on the fly and already have proper
+ * permissions upon creation.
+ *
+ * Just make sure `fildes' actually points to a real PTY master device.
+ */
+__strong_reference(__isptmaster, grantpt);
+__strong_reference(__isptmaster, unlockpt);
/*
* ptsname(): return the pathname of the slave pseudo-terminal device
@@ -82,7 +80,7 @@
int sverrno = errno;
/* Make sure fildes points to a master device. */
- if (_ioctl(fildes, TIOCPTMASTER) != 0)
+ if (__isptmaster(fildes) != 0)
goto done;
/* Obtain the device name through FIODGNAME */
More information about the p4-projects
mailing list