Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/stdlib unix/98 pty functions and manual pages.



details:   https://anonhg.NetBSD.org/src/rev/fb3ae9fcfb98
branches:  trunk
changeset: 566986:fb3ae9fcfb98
user:      christos <christos%NetBSD.org@localhost>
date:      Thu May 27 02:58:48 2004 +0000

description:
unix/98 pty functions and manual pages.

diffstat:

 lib/libc/stdlib/Makefile.inc   |   11 ++-
 lib/libc/stdlib/grantpt.3      |  104 +++++++++++++++++++++++++++++++++++++++
 lib/libc/stdlib/posix_openpt.3 |   87 +++++++++++++++++++++++++++++++++
 lib/libc/stdlib/posix_openpt.c |   53 ++++++++++++++++++++
 lib/libc/stdlib/ptsname.3      |  107 +++++++++++++++++++++++++++++++++++++++++
 lib/libc/stdlib/pty.c          |   73 +++++++++++++++++++++++++++
 lib/libc/stdlib/unlockpt.3     |   93 +++++++++++++++++++++++++++++++++++
 7 files changed, 523 insertions(+), 5 deletions(-)

diffs (truncated from 574 to 300 lines):

diff -r ad91b3772a7a -r fb3ae9fcfb98 lib/libc/stdlib/Makefile.inc
--- a/lib/libc/stdlib/Makefile.inc      Thu May 27 02:58:14 2004 +0000
+++ b/lib/libc/stdlib/Makefile.inc      Thu May 27 02:58:48 2004 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.inc,v 1.55 2003/04/07 17:18:20 kleink Exp $
+#      $NetBSD: Makefile.inc,v 1.56 2004/05/27 02:58:48 christos Exp $
 #      from: @(#)Makefile.inc  8.3 (Berkeley) 2/4/95
 
 # stdlib sources
@@ -10,8 +10,8 @@
        getenv.c getopt.c getopt_long.c getsubopt.c \
        hcreate.c heapsort.c jrand48.c \
        l64a.c lldiv.c lcong48.c lrand48.c malloc.c merge.c mrand48.c \
-       nrand48.c putenv.c qabs.c qdiv.c qsort.c radixsort.c \
-       rand.c rand_r.c random.c seed48.c setenv.c srand48.c \
+       nrand48.c putenv.c qabs.c qdiv.c qsort.c posix_openpt.c pty.c \
+       radixsort.c rand.c rand_r.c random.c seed48.c setenv.c srand48.c \
        strsuftoll.c strtod.c \
        strtoimax.c strtol.c strtoll.c strtoq.c strtoul.c strtoull.c \
        strtoumax.c strtouq.c system.c tdelete.c tfind.c tsearch.c twalk.c \
@@ -25,9 +25,10 @@
 
 MAN+=  a64l.3 abort.3 abs.3 alloca.3 atexit.3 atof.3 atoi.3 atol.3 atoll.3 \
        bsearch.3 div.3 exit.3 getenv.3 getopt.3 getopt_long.3 getsubopt.3 \
-       hcreate.3 labs.3 ldiv.3 llabs.3 lldiv.3 malloc.3 memory.3 qabs.3 \
+       grantpt.3 hcreate.3 labs.3 ldiv.3 llabs.3 lldiv.3 malloc.3 memory.3 \
+       posix_openpt.3 ptsname.3 qabs.3 \
        qdiv.3 qsort.3 radixsort.3 rand48.3 rand.3 random.3 \
-       strsuftoll.3 strtod.3 strtol.3 strtoul.3 system.3 tsearch.3
+       strsuftoll.3 strtod.3 strtol.3 strtoul.3 system.3 tsearch.3 unlockpt.3
 
 MLINKS+=a64l.3 l64a.3
 MLINKS+=a64l.3 l64a_r.3
diff -r ad91b3772a7a -r fb3ae9fcfb98 lib/libc/stdlib/grantpt.3
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/stdlib/grantpt.3 Thu May 27 02:58:48 2004 +0000
@@ -0,0 +1,104 @@
+.\" $NetBSD: grantpt.3,v 1.1 2004/05/27 02:58:48 christos Exp $
+.\"
+.\" Copyright (c) 2004 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Christos Zoulas.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\"    must display the following acknowledgement:
+.\"        This product includes software developed by the NetBSD
+.\"        Foundation, Inc. and its contributors.
+.\" 4. Neither the name of The NetBSD Foundation nor the names of its
+.\"    contributors may be used to endorse or promote products derived
+.\"    from this software without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
+.\"
+.Dd May 25, 2004
+.Dt grantpt 3
+.Os
+.Sh NAME
+.Nm grantpt
+.Nd grant access to a slave pseudo-terminal device
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In stdlib.h
+.Ft int
+.Fn grantpt "int fildes"
+.Sh DESCRIPTION
+The
+.Fn grantpt
+function changes the mode and ownership of the slave pseudo-terminal device
+that corresponds to the master pseudo-terminal device associated with
+.Fa fildes
+to be owned by the real user id of the calling process, group id of
+.Dv tty .
+The permissions are set to readable and writable by owner, and writable by
+group.
+If the slave pseudo-terminal device was being accessed by other file
+descriptors at the time, all such access will be revoked.
+.Sh RETURN VALUES
+If successful, 
+.Fn grantpt
+returns 0; otherwise a value of -1 is returned and
+.Va errno
+is set to indicate the error.
+.Sh ERRORS
+The
+.Fn grantpt
+function will fail if:
+.Bl -tag -width Er
+.It Bq Er EACCESS
+the corresponding pseudo-terminal device could not be accessed.
+.It Bq Er EBADF
+.Fa fildes
+is not a valid descriptor.
+.It Bq Er EINVAL
+.Fa fildes
+is not associated with a master pseudo-terminal device.
+.El
+.Sh NOTES
+Setting the group to
+.Dv tty
+and revoking accesses by other file descriptors are
+.Nx
+extensions.
+Calling
+.Fn grantpt
+is equivalent to:
+.Bd -literal
+       ioctl(fildes, TIOCGRANTPT, 0);
+.Ed
+.Sh SEE ALSO
+.Xr ioctl 2 ,
+.Xr posix_openpt 3 ,
+.Xr ptsname 3 ,
+.Xr unlockpt 3
+.Sh STANDARDS
+The
+.Fn grantpt
+function conforms to
+.St -p1003.1-2001 .
+Its first release was in
+.St -xpg4.2 .
diff -r ad91b3772a7a -r fb3ae9fcfb98 lib/libc/stdlib/posix_openpt.3
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/stdlib/posix_openpt.3    Thu May 27 02:58:48 2004 +0000
@@ -0,0 +1,87 @@
+.\" $NetBSD: posix_openpt.3,v 1.1 2004/05/27 02:58:48 christos Exp $
+.\"
+.\" Copyright (c) 2004 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Christos Zoulas.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\"    must display the following acknowledgement:
+.\"        This product includes software developed by the NetBSD
+.\"        Foundation, Inc. and its contributors.
+.\" 4. Neither the name of The NetBSD Foundation nor the names of its
+.\"    contributors may be used to endorse or promote products derived
+.\"    from this software without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
+.\"
+.Dd May 25, 2004
+.Dt posix_openpt 3
+.Os
+.Sh NAME
+.Nm posix_openpt
+.Nd open a pseudo-terminal device
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In stdlib.h
+.In fcntl.h
+.Ft int
+.Fn posix_openpt "int oflag"
+.Sh DESCRIPTION
+.Fn posix_openpt
+Searches for an unused master pseudo-terminal device, opens it, and returns
+a file descriptor associated the now used pseudo-terminal device.
+The
+.Fa oflag
+argument has the same meaning as in the
+.Xr open 2
+call.
+.Sh RETURN VALUES
+If successful, 
+.Fn posix_openpt
+returns a non-negative integer, which corresponds to a file descriptor
+pointing to the master pseudo-terminal device.  Otherwise, a value of -1
+is returned and
+.Va errno
+is set to indicate the error.
+.Sh SEE ALSO
+.Xr grantpt 3 ,
+.Xr unlockpt 3 ,
+.Xr ptsname 3 ,
+.Xr ioctl 2 ,
+.Xr open 2
+.Sh RATIONALE
+The standards committee did not want to directly expose the cloning device,
+thus decided to wrap the functionality in this function. The equivalent
+code would be:
+.Bd -literal
+       int
+       posix_openpt(int oflag) {
+               return open("/dev/ptmx", oflag);
+       }
+.Ed
+.Sh STANDARDS
+The
+.Fn posix_openpt
+function conforms to
+.St -p1003.1-2001 .
diff -r ad91b3772a7a -r fb3ae9fcfb98 lib/libc/stdlib/posix_openpt.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/stdlib/posix_openpt.c    Thu May 27 02:58:48 2004 +0000
@@ -0,0 +1,53 @@
+/*     $NetBSD: posix_openpt.c,v 1.1 2004/05/27 02:58:48 christos Exp $        */
+
+/*-
+ * Copyright (c) 2004 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *        This product includes software developed by the NetBSD
+ *        Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: posix_openpt.c,v 1.1 2004/05/27 02:58:48 christos Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#include "namespace.h"
+#include <fcntl.h>
+#include <stdlib.h>
+
+int
+posix_openpt(int oflag)
+{
+
+       return open("/dev/ptmx", oflag);
+}
diff -r ad91b3772a7a -r fb3ae9fcfb98 lib/libc/stdlib/ptsname.3
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/stdlib/ptsname.3 Thu May 27 02:58:48 2004 +0000
@@ -0,0 +1,107 @@
+.\" $NetBSD: ptsname.3,v 1.1 2004/05/27 02:58:48 christos Exp $
+.\"
+.\" Copyright (c) 2004 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Christos Zoulas.



Home | Main Index | Thread Index | Old Index