From 55c2faba7515b9c365715818477694224e7cc217 Mon Sep 17 00:00:00 2001 From: "William F. Jolitz" Date: Tue, 30 Apr 1991 16:55:55 -0800 Subject: [PATCH] 386BSD 0.1 development Work on file usr/src/lib/libc/sys/accept.2 Work on file usr/src/lib/libc/sys/acct.2 Work on file usr/src/lib/libc/sys/access.2 Work on file usr/src/lib/libc/sys/adjtime.2 Work on file usr/src/lib/libc/sys/bind.2 Work on file usr/src/lib/libc/sys/brk.2 Work on file usr/src/lib/libc/sys/chdir.2 Work on file usr/src/lib/libc/sys/chroot.2 Work on file usr/src/lib/libc/sys/chown.2 Work on file usr/src/lib/libc/sys/close.2 Work on file usr/src/lib/libc/sys/chmod.2 Work on file usr/src/lib/libc/sys/connect.2 Work on file usr/src/lib/libc/sys/fcntl.2 Work on file usr/src/lib/libc/sys/execve.2 Work on file usr/src/lib/libc/sys/dup.2 Work on file usr/src/lib/libc/sys/flock.2 Work on file usr/src/lib/libc/sys/fsync.2 Work on file usr/src/lib/libc/sys/fork.2 Work on file usr/src/lib/libc/sys/getgroups.2 Work on file usr/src/lib/libc/sys/getgid.2 Work on file usr/src/lib/libc/sys/getdtablesize.2 Work on file usr/src/lib/libc/sys/gethostid.2 Work on file usr/src/lib/libc/sys/gethostname.2 Work on file usr/src/lib/libc/sys/getitimer.2 Work on file usr/src/lib/libc/sys/getpriority.2 Work on file usr/src/lib/libc/sys/getpgrp.2 Work on file usr/src/lib/libc/sys/getpagesize.2 Work on file usr/src/lib/libc/sys/getpeername.2 Work on file usr/src/lib/libc/sys/getpid.2 Work on file usr/src/lib/libc/sys/getrlimit.2 Work on file usr/src/lib/libc/sys/getsockname.2 Work on file usr/src/lib/libc/sys/getrusage.2 Work on file usr/src/lib/libc/sys/gettimeofday.2 Work on file usr/src/lib/libc/sys/getuid.2 Work on file usr/src/lib/libc/sys/kill.2 Work on file usr/src/lib/libc/sys/ioctl.2 Work on file usr/src/lib/libc/sys/link.2 Work on file usr/src/lib/libc/sys/listen.2 Work on file usr/src/lib/libc/sys/mknod.2 Work on file usr/src/lib/libc/sys/mkdir.2 Work on file usr/src/lib/libc/sys/lseek.2 Work on file usr/src/lib/libc/sys/mount.2 Work on file usr/src/lib/libc/sys/pipe.2 Work on file usr/src/lib/libc/sys/read.2 Work on file usr/src/lib/libc/sys/rename.2 Work on file usr/src/lib/libc/sys/readlink.2 Work on file usr/src/lib/libc/sys/reboot.2 Work on file usr/src/lib/libc/sys/select.2 Work on file usr/src/lib/libc/sys/rmdir.2 Work on file usr/src/lib/libc/sys/setgroups.2 Work on file usr/src/lib/libc/sys/setregid.2 Work on file usr/src/lib/libc/sys/shutdown.2 Work on file usr/src/lib/libc/sys/setreuid.2 Work on file usr/src/lib/libc/sys/setpgid.2 Work on file usr/src/lib/libc/sys/sigstack.2 Work on file usr/src/lib/libc/sys/sigreturn.2 Work on file usr/src/lib/libc/sys/stat.2 Work on file usr/src/lib/libc/sys/socketpair.2 Work on file usr/src/lib/libc/sys/socket.2 Work on file usr/src/lib/libc/sys/symlink.2 Work on file usr/src/lib/libc/sys/swapon.2 Work on file usr/src/lib/libc/sys/syscall.2 Work on file usr/src/lib/libc/sys/sync.2 Work on file usr/src/lib/libc/sys/umask.2 Work on file usr/src/lib/libc/sys/vfork.2 Work on file usr/src/lib/libc/sys/utimes.2 Work on file usr/src/lib/libc/sys/unlink.2 Work on file usr/src/lib/libc/sys/truncate.2 Work on file usr/src/lib/libc/sys/wait.2 Work on file usr/src/lib/libc/sys/write.2 Co-Authored-By: Lynne Greer Jolitz Synthesized-from: 386BSD-0.1 --- usr/src/lib/libc/sys/accept.2 | 166 ++++++++++++++ usr/src/lib/libc/sys/access.2 | 132 +++++++++++ usr/src/lib/libc/sys/acct.2 | 115 ++++++++++ usr/src/lib/libc/sys/adjtime.2 | 111 ++++++++++ usr/src/lib/libc/sys/bind.2 | 126 +++++++++++ usr/src/lib/libc/sys/brk.2 | 144 ++++++++++++ usr/src/lib/libc/sys/chdir.2 | 129 +++++++++++ usr/src/lib/libc/sys/chmod.2 | 182 +++++++++++++++ usr/src/lib/libc/sys/chown.2 | 147 +++++++++++++ usr/src/lib/libc/sys/chroot.2 | 97 ++++++++ usr/src/lib/libc/sys/close.2 | 120 ++++++++++ usr/src/lib/libc/sys/connect.2 | 147 +++++++++++++ usr/src/lib/libc/sys/dup.2 | 132 +++++++++++ usr/src/lib/libc/sys/execve.2 | 255 +++++++++++++++++++++ usr/src/lib/libc/sys/fcntl.2 | 215 ++++++++++++++++++ usr/src/lib/libc/sys/flock.2 | 145 ++++++++++++ usr/src/lib/libc/sys/fork.2 | 107 +++++++++ usr/src/lib/libc/sys/fsync.2 | 81 +++++++ usr/src/lib/libc/sys/getdtablesize.2 | 60 +++++ usr/src/lib/libc/sys/getgid.2 | 79 +++++++ usr/src/lib/libc/sys/getgroups.2 | 96 ++++++++ usr/src/lib/libc/sys/gethostid.2 | 66 ++++++ usr/src/lib/libc/sys/gethostname.2 | 96 ++++++++ usr/src/lib/libc/sys/getitimer.2 | 166 ++++++++++++++ usr/src/lib/libc/sys/getpagesize.2 | 61 ++++++ usr/src/lib/libc/sys/getpeername.2 | 89 ++++++++ usr/src/lib/libc/sys/getpgrp.2 | 77 +++++++ usr/src/lib/libc/sys/getpid.2 | 72 ++++++ usr/src/lib/libc/sys/getpriority.2 | 142 ++++++++++++ usr/src/lib/libc/sys/getrlimit.2 | 181 +++++++++++++++ usr/src/lib/libc/sys/getrusage.2 | 164 ++++++++++++++ usr/src/lib/libc/sys/getsockname.2 | 87 ++++++++ usr/src/lib/libc/sys/gettimeofday.2 | 119 ++++++++++ usr/src/lib/libc/sys/getuid.2 | 80 +++++++ usr/src/lib/libc/sys/ioctl.2 | 106 +++++++++ usr/src/lib/libc/sys/kill.2 | 131 +++++++++++ usr/src/lib/libc/sys/link.2 | 151 +++++++++++++ usr/src/lib/libc/sys/listen.2 | 100 +++++++++ usr/src/lib/libc/sys/lseek.2 | 135 ++++++++++++ usr/src/lib/libc/sys/mkdir.2 | 123 +++++++++++ usr/src/lib/libc/sys/mknod.2 | 127 +++++++++++ usr/src/lib/libc/sys/mount.2 | 317 +++++++++++++++++++++++++++ usr/src/lib/libc/sys/pipe.2 | 115 ++++++++++ usr/src/lib/libc/sys/read.2 | 188 ++++++++++++++++ usr/src/lib/libc/sys/readlink.2 | 95 ++++++++ usr/src/lib/libc/sys/reboot.2 | 158 +++++++++++++ usr/src/lib/libc/sys/rename.2 | 198 +++++++++++++++++ usr/src/lib/libc/sys/rmdir.2 | 106 +++++++++ usr/src/lib/libc/sys/select.2 | 182 +++++++++++++++ usr/src/lib/libc/sys/setgroups.2 | 89 ++++++++ usr/src/lib/libc/sys/setpgid.2 | 89 ++++++++ usr/src/lib/libc/sys/setregid.2 | 74 +++++++ usr/src/lib/libc/sys/setreuid.2 | 75 +++++++ usr/src/lib/libc/sys/shutdown.2 | 81 +++++++ usr/src/lib/libc/sys/sigreturn.2 | 97 ++++++++ usr/src/lib/libc/sys/sigstack.2 | 100 +++++++++ usr/src/lib/libc/sys/socket.2 | 257 ++++++++++++++++++++++ usr/src/lib/libc/sys/socketpair.2 | 91 ++++++++ usr/src/lib/libc/sys/stat.2 | 247 +++++++++++++++++++++ usr/src/lib/libc/sys/swapon.2 | 113 ++++++++++ usr/src/lib/libc/sys/symlink.2 | 139 ++++++++++++ usr/src/lib/libc/sys/sync.2 | 73 ++++++ usr/src/lib/libc/sys/syscall.2 | 71 ++++++ usr/src/lib/libc/sys/truncate.2 | 122 +++++++++++ usr/src/lib/libc/sys/umask.2 | 82 +++++++ usr/src/lib/libc/sys/unlink.2 | 111 ++++++++++ usr/src/lib/libc/sys/utimes.2 | 118 ++++++++++ usr/src/lib/libc/sys/vfork.2 | 126 +++++++++++ usr/src/lib/libc/sys/wait.2 | 295 +++++++++++++++++++++++++ usr/src/lib/libc/sys/write.2 | 203 +++++++++++++++++ 70 files changed, 9071 insertions(+) create mode 100644 usr/src/lib/libc/sys/accept.2 create mode 100644 usr/src/lib/libc/sys/access.2 create mode 100644 usr/src/lib/libc/sys/acct.2 create mode 100644 usr/src/lib/libc/sys/adjtime.2 create mode 100644 usr/src/lib/libc/sys/bind.2 create mode 100644 usr/src/lib/libc/sys/brk.2 create mode 100644 usr/src/lib/libc/sys/chdir.2 create mode 100644 usr/src/lib/libc/sys/chmod.2 create mode 100644 usr/src/lib/libc/sys/chown.2 create mode 100644 usr/src/lib/libc/sys/chroot.2 create mode 100644 usr/src/lib/libc/sys/close.2 create mode 100644 usr/src/lib/libc/sys/connect.2 create mode 100644 usr/src/lib/libc/sys/dup.2 create mode 100644 usr/src/lib/libc/sys/execve.2 create mode 100644 usr/src/lib/libc/sys/fcntl.2 create mode 100644 usr/src/lib/libc/sys/flock.2 create mode 100644 usr/src/lib/libc/sys/fork.2 create mode 100644 usr/src/lib/libc/sys/fsync.2 create mode 100644 usr/src/lib/libc/sys/getdtablesize.2 create mode 100644 usr/src/lib/libc/sys/getgid.2 create mode 100644 usr/src/lib/libc/sys/getgroups.2 create mode 100644 usr/src/lib/libc/sys/gethostid.2 create mode 100644 usr/src/lib/libc/sys/gethostname.2 create mode 100644 usr/src/lib/libc/sys/getitimer.2 create mode 100644 usr/src/lib/libc/sys/getpagesize.2 create mode 100644 usr/src/lib/libc/sys/getpeername.2 create mode 100644 usr/src/lib/libc/sys/getpgrp.2 create mode 100644 usr/src/lib/libc/sys/getpid.2 create mode 100644 usr/src/lib/libc/sys/getpriority.2 create mode 100644 usr/src/lib/libc/sys/getrlimit.2 create mode 100644 usr/src/lib/libc/sys/getrusage.2 create mode 100644 usr/src/lib/libc/sys/getsockname.2 create mode 100644 usr/src/lib/libc/sys/gettimeofday.2 create mode 100644 usr/src/lib/libc/sys/getuid.2 create mode 100644 usr/src/lib/libc/sys/ioctl.2 create mode 100644 usr/src/lib/libc/sys/kill.2 create mode 100644 usr/src/lib/libc/sys/link.2 create mode 100644 usr/src/lib/libc/sys/listen.2 create mode 100644 usr/src/lib/libc/sys/lseek.2 create mode 100644 usr/src/lib/libc/sys/mkdir.2 create mode 100644 usr/src/lib/libc/sys/mknod.2 create mode 100644 usr/src/lib/libc/sys/mount.2 create mode 100644 usr/src/lib/libc/sys/pipe.2 create mode 100644 usr/src/lib/libc/sys/read.2 create mode 100644 usr/src/lib/libc/sys/readlink.2 create mode 100644 usr/src/lib/libc/sys/reboot.2 create mode 100644 usr/src/lib/libc/sys/rename.2 create mode 100644 usr/src/lib/libc/sys/rmdir.2 create mode 100644 usr/src/lib/libc/sys/select.2 create mode 100644 usr/src/lib/libc/sys/setgroups.2 create mode 100644 usr/src/lib/libc/sys/setpgid.2 create mode 100644 usr/src/lib/libc/sys/setregid.2 create mode 100644 usr/src/lib/libc/sys/setreuid.2 create mode 100644 usr/src/lib/libc/sys/shutdown.2 create mode 100644 usr/src/lib/libc/sys/sigreturn.2 create mode 100644 usr/src/lib/libc/sys/sigstack.2 create mode 100644 usr/src/lib/libc/sys/socket.2 create mode 100644 usr/src/lib/libc/sys/socketpair.2 create mode 100644 usr/src/lib/libc/sys/stat.2 create mode 100644 usr/src/lib/libc/sys/swapon.2 create mode 100644 usr/src/lib/libc/sys/symlink.2 create mode 100644 usr/src/lib/libc/sys/sync.2 create mode 100644 usr/src/lib/libc/sys/syscall.2 create mode 100644 usr/src/lib/libc/sys/truncate.2 create mode 100644 usr/src/lib/libc/sys/umask.2 create mode 100644 usr/src/lib/libc/sys/unlink.2 create mode 100644 usr/src/lib/libc/sys/utimes.2 create mode 100644 usr/src/lib/libc/sys/vfork.2 create mode 100644 usr/src/lib/libc/sys/wait.2 create mode 100644 usr/src/lib/libc/sys/write.2 diff --git a/usr/src/lib/libc/sys/accept.2 b/usr/src/lib/libc/sys/accept.2 new file mode 100644 index 0000000000..6a0feb3560 --- /dev/null +++ b/usr/src/lib/libc/sys/accept.2 @@ -0,0 +1,166 @@ +.\" Copyright (c) 1983, 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)accept.2 6.6 (Berkeley) 4/29/91 +.\" +.Dd April 29, 1991 +.Dt ACCEPT 2 +.Os BSD 4.2 +.Sh NAME +.Nm accept +.Nd accept a connection on a socket +.Sh SYNOPSIS +.Fd #include +.Fd #include +.Ft int +.Fn accept "int s" "struct sockaddr *addr" "int *addrlen" +.Sh DESCRIPTION +The argument +.Fa s +is a socket that has been created with +.Xr socket 2 , +bound to an address with +.Xr bind 2 , +and is listening for connections after a +.Xr listen 2 . +The +.Fn accept +argument +extracts the first connection request +on the queue of pending connections, creates +a new socket with the same properties of +.Fa s +and allocates a new file descriptor +for the socket. If no pending connections are +present on the queue, and the socket is not marked +as non-blocking, +.Fn accept +blocks the caller until a connection is present. +If the socket is marked non-blocking and no pending +connections are present on the queue, +.Fn accept +returns an error as described below. +The accepted socket +may not be used +to accept more connections. The original socket +.Fa s +remains open. +.Pp +The argument +.Fa addr +is a result parameter that is filled in with +the address of the connecting entity, +as known to the communications layer. +The exact format of the +.Fa addr +parameter is determined by the domain in which the communication +is occurring. +The +.Fa addrlen +is a value-result parameter; it should initially contain the +amount of space pointed to by +.Fa addr ; +on return it will contain the actual length (in bytes) of the +address returned. +This call +is used with connection-based socket types, currently with +.Dv SOCK_STREAM . +.Pp +It is possible to +.Xr select 2 +a socket for the purposes of doing an +.Fn accept +by selecting it for read. +.Pp +For certain protocols which require an explicit confirmation, +such as +.Tn ISO +or +.Tn DATAKIT , +.Fn accept +can be thought of +as merely dequeueing the next connection +request and not implying confirmation. +Confirmation can be implied by a normal read or write on the new +file desciptor, and rejection can be implied by closing the +new socket. +.Pp +One can obtain user connection request data without confirming +the connection by issuing a +.Xr recvmsg 2 +call with an +.Fa msg_iovlen +of 0 and a non-zero +.Fa msg_controllen , +or by issuing a +.Xr getsockopt 2 +request. +Similarly, one can provide user connection rejection information +by issuing a +.Xr sendmsg 2 +call with providing only the control information, +or by calling +.Xr setsockopt 2 . +.Sh RETURN VALUES +The call returns \-1 on error. If it succeeds, it returns a non-negative +integer that is a descriptor for the accepted socket. +.Sh ERRORS +The +.Fn accept +will fail if: +.Bl -tag -width EWOULDBLOCK +.It Bq Er EBADF +The descriptor is invalid. +.It Bq Er ENOTSOCK +The descriptor references a file, not a socket. +.It Bq Er EOPNOTSUPP +The referenced socket is not of type +.Dv SOCK_STREAM . +.It Bq Er EFAULT +The +.Fa addr +parameter is not in a writable part of the +user address space. +.It Bq Er EWOULDBLOCK +The socket is marked non-blocking and no connections +are present to be accepted. +.El +.Sh SEE ALSO +.Xr bind 2 , +.Xr connect 2 , +.Xr listen 2 , +.Xr select 2 , +.Xr socket 2 +.Sh HISTORY +The +.Nm +function appeared in +.Bx 4.2 . diff --git a/usr/src/lib/libc/sys/access.2 b/usr/src/lib/libc/sys/access.2 new file mode 100644 index 0000000000..9a0f180b64 --- /dev/null +++ b/usr/src/lib/libc/sys/access.2 @@ -0,0 +1,132 @@ +.\" Copyright (c) 1980, 1991 Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)access.2 6.7 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt ACCESS 2 +.Os BSD 4 +.Sh NAME +.Nm access +.Nd check access permissions of a file or pathname +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn access "const char *path" "int mode" +.Sh DESCRIPTION +The +.Fn access +function checks the accessibility of the +file named by +.Fa path +for the access permissions indicated by +.Fa mode . +The value of +.Fa mode +is the bitwise inclusive OR of the access permissions to be +checked +.Pf ( Dv R_OK +for read permission, +.Dv W_OK +for write permission and +.Dv X_OK +for execute/search permission) or the existence test, +.Dv F_OK . +All components of the pathname +.Fa path +are checked for access permissions (including +.Dv F_OK ) . +.Pp +The real user ID is used in place of the effective user ID +and the real group access list +(including the real group ID) are +used in place of the effective ID for verifying permission. +.Pp +Even if a process has appropriate privileges and indicates success for +.Dv X_OK , +the file may not actually have execute permission bits set. +Likewise for +.Dv R_OK +and +.Dv W_OK . +.Sh RETURN VALUES +If +.Fa path +cannot be found or if any of the desired access modes would +not be granted, then a -1 value is returned; otherwise +a 0 value is returned. +.Sh ERRORS +Access to the file is denied if: +.Bl -tag -width Er +.It Bq Er ENOTDIR +A component of the path prefix is not a directory. +.It Bq Er EINVAL +The pathname contains a character with the high-order bit set. +.It Bq Er ENAMETOOLONG +A component of a pathname exceeded 255 characters, +or an entire path name exceeded 1023 characters. +.It Bq Er ENOENT +The named file does not exist. +.It Bq Er EACCES +Search permission is denied for a component of the path prefix. +.It Bq Er ELOOP +Too many symbolic links were encountered in translating the pathname. +.It Bq Er EROFS +Write access is requested for a file on a read-only file system. +.It Bq Er ETXTBSY +Write access is requested for a pure procedure (shared text) +file presently being executed. +.It Bq Er EACCES +Permission bits of the file mode do not permit the requested +access, or search permission is denied on a component of the +path prefix. The owner of a file has permission checked with +respect to the ``owner'' read, write, and execute mode bits, +members of the file's group other than the owner have permission +checked with respect to the ``group'' mode bits, and all +others have permissions checked with respect to the ``other'' +mode bits. +.It Bq Er EFAULT +.Fa Path +points outside the process's allocated address space. +.It Bq Er EIO +An I/O error occurred while reading from or writing to the file system. +.El +.Sh SEE ALSO +.Xr chmod 2 , +.Xr stat 2 +.Sh STANDARDS +.Fn Access +conforms to IEEE Std 1003.1-1988 +.Pq Dq Tn POSIX . +.Sh CAVEAT +.Fn Access +is a potential security hole and +should never be used. diff --git a/usr/src/lib/libc/sys/acct.2 b/usr/src/lib/libc/sys/acct.2 new file mode 100644 index 0000000000..0a36e7be14 --- /dev/null +++ b/usr/src/lib/libc/sys/acct.2 @@ -0,0 +1,115 @@ +.\" Copyright (c) 1980, 1991 Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)acct.2 6.5 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt ACCT 2 +.Os BSD 4 +.Sh NAME +.Nm acct +.Nd enable or disable process accounting +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn acct "const char *file" +.Sh DESCRIPTION +The +.Fn acct +call enables or disables the collection of system accounting +records. +If the argument +.Fa file +is a nil pointer, accounting is disabled. +If +.Fa file +is an +.Em existing +pathname (null-terminated), record collection is enabled and for +every process initiated which terminates under normal +conditions an accounting record is appended to +.Fa file . +Abnormal conditions of termination are reboots +or other fatal system problems. +Records for processes which never terminate can not be +produced by +.Fn acct . +.Pp +For more information on the record structure used by +.Fn acct , +see +.Pa /usr/include/sys/acct.h +and +.Xr acct 5 . +.Pp +This call is permitted only to the super-user. +.Sh NOTES +Accounting is automatically disabled when the file system the +accounting file resides on runs out of space; it is enabled when +space once again becomes available. +.Sh RETURN VALUES +On error -1 is returned. +The file must exist and the call may be exercised only by the super-user. +.Sh ERRORS +.Fn Acct +will fail if one of the following is true: +.Bl -tag -width Er +.It Bq Er EPERM +The caller is not the super-user. +.It Bq Er ENOTDIR +A component of the path prefix is not a directory. +.It Bq Er EINVAL +The pathname contains a character with the high-order bit set. +.It Bq Er ENAMETOOLONG +A component of a pathname exceeded 255 characters, +or an entire path name exceeded 1023 characters. +.It Bq Er ENOENT +The named file does not exist. +.It Bq Er EACCES +Search permission is denied for a component of the path prefix, +or the path name is not a regular file. +.It Bq Er ELOOP +Too many symbolic links were encountered in translating the pathname. +.It Bq Er EROFS +The named file resides on a read-only file system. +.It Bq Er EFAULT +.Fa File +points outside the process's allocated address space. +.It Bq Er EIO +An I/O error occurred while reading from or writing to the file system. +.El +.Sh SEE ALSO +.Xr acct 5 , +.Xr sa 8 +.Sh HISTORY +An +.Nm +function call appeared in Version 7 AT&T UNIX. diff --git a/usr/src/lib/libc/sys/adjtime.2 b/usr/src/lib/libc/sys/adjtime.2 new file mode 100644 index 0000000000..2eae90533b --- /dev/null +++ b/usr/src/lib/libc/sys/adjtime.2 @@ -0,0 +1,111 @@ +.\" Copyright (c) 1980, 1991 Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)adjtime.2 1.7 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt ADJTIME 2 +.Os BSD 4.3 +.Sh NAME +.Nm adjtime +.Nd "correct the time to allow synchronization of the system clock" +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn adjtime "struct timeval *delta" "struct timeval *olddelta" +.Sh DESCRIPTION +.Fn Adjtime +makes small adjustments to the system time, as returned by +.Xr gettimeofday 2 , +advancing or retarding it +by the time specified by the timeval +.Fa delta . +If +.Fa delta +is negative, the clock is +slowed down by incrementing it more slowly than normal until +the correction is complete. +If +.Fa delta +is positive, a larger increment than normal +is used. +The skew used to perform the correction is generally a fraction of one percent. +Thus, the time is always +a monotonically increasing function. +A time correction from an earlier call to +.Fn adjtime +may not be finished when +.Fn adjtime +is called again. +If +.Fa olddelta +is non-nil, +the structure pointed to will contain, upon return, the +number of microseconds still to be corrected +from the earlier call. +.Pp +This call may be used by time servers that synchronize the clocks +of computers in a local area network. +Such time servers would slow down the clocks of some machines +and speed up the clocks of others to bring them to the average network time. +.Pp +The call +.Fn adjtime +is restricted to the super-user. +.Sh RETURN VALUES +A return value of 0 indicates that the call succeeded. +A return value of -1 indicates that an error occurred, and in this +case an error code is stored in the global variable +.Va errno . +.Sh ERRORS +.Fn Adjtime +will fail if: +.Bl -tag -width Er +.It Bq Er EFAULT +An argument points outside the process's allocated address space. +.It Bq Er EPERM +The process's effective user ID is not that of the super-user. +.El +.Sh SEE ALSO +.Xr date 1 , +.Xr gettimeofday 2 , +.Xr timed 8 , +.Xr timedc 8 , +.Rs +.%T "TSP: The Time Synchronization Protocol for UNIX 4.3BSD" +.%A R. Gusella +.%A S. Zatti +.Re +.Sh HISTORY +The +.Nm +function call appeared in +.Bx 4.3 . diff --git a/usr/src/lib/libc/sys/bind.2 b/usr/src/lib/libc/sys/bind.2 new file mode 100644 index 0000000000..031f45e184 --- /dev/null +++ b/usr/src/lib/libc/sys/bind.2 @@ -0,0 +1,126 @@ +.\" Copyright (c) 1983 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)bind.2 6.9 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt BIND 2 +.Os BSD 4.2 +.Sh NAME +.Nm bind +.Nd bind a name to a socket +.Sh SYNOPSIS +.Fd #include +.Fd #include +.Ft int +.Fn bind "int s" "struct sockaddr *name" "int namelen" +.Sh DESCRIPTION +.Fn Bind +assigns a name to an unnamed socket. +When a socket is created +with +.Xr socket 2 +it exists in a name space (address family) +but has no name assigned. +.Fn Bind +requests that +.Fa name +be assigned to the socket. +.Sh NOTES +Binding a name in the UNIX domain creates a socket in the file +system that must be deleted by the caller when it is no longer +needed (using +.Xr unlink 2 ) . +.Pp +The rules used in name binding vary between communication domains. +Consult the manual entries in section 4 for detailed information. +.Sh RETURN VALUES +If the bind is successful, a 0 value is returned. +A return value of -1 indicates an error, which is +further specified in the global +.Va errno . +.Sh ERRORS +The +.Fn bind +call will fail if: +.Bl -tag -width EADDRNOTAVA +.It Bq Er EBADF +.Fa S +is not a valid descriptor. +.It Bq Er ENOTSOCK +.Fa S +is not a socket. +.It Bq Er EADDRNOTAVAIL +The specified address is not available from the local machine. +.It Bq Er EADDRINUSE +The specified address is already in use. +.It Bq Er EINVAL +The socket is already bound to an address. +.It Bq Er EACCES +The requested address is protected, and the current user +has inadequate permission to access it. +.It Bq Er EFAULT +The +.Fa name +parameter is not in a valid part of the user +address space. +.El +.Pp +The following errors are specific to binding names in the UNIX domain. +.Bl -tag -width EADDRNOTAVA +.It Bq Er ENOTDIR +A component of the path prefix is not a directory. +.It Bq Er EINVAL +The pathname contains a character with the high-order bit set. +.It Bq Er ENAMETOOLONG +A component of a pathname exceeded 255 characters, +or an entire path name exceeded 1023 characters. +.It Bq Er ENOENT +A prefix component of the path name does not exist. +.It Bq Er ELOOP +Too many symbolic links were encountered in translating the pathname. +.It Bq Er EIO +An I/O error occurred while making the directory entry or allocating the inode. +.It Bq Er EROFS +The name would reside on a read-only file system. +.It Bq Er EISDIR +An empty pathname was specified. +.El +.Sh SEE ALSO +.Xr connect 2 , +.Xr listen 2 , +.Xr socket 2 , +.Xr getsockname 2 +.Sh HISTORY +The +.Nm +function call appeared in +.Bx 4.2 . diff --git a/usr/src/lib/libc/sys/brk.2 b/usr/src/lib/libc/sys/brk.2 new file mode 100644 index 0000000000..79cf8cd74c --- /dev/null +++ b/usr/src/lib/libc/sys/brk.2 @@ -0,0 +1,144 @@ +.\" Copyright (c) 1980, 1991 Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)brk.2 6.5 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt BRK 2 +.Os BSD 4 +.Sh NAME +.Nm brk , +.Nm sbrk +.Nd change data segment size +.Sh SYNOPSIS +.Fd #include +.Ft char +.Fn *brk "const char *addr" +.Ft char * +.Fn *sbrk "int incr" +.Sh DESCRIPTION +.Bf -symbolic +The brk and sbrk functions are historical curiosities +left over from earlier days before the advent of virtual memory management. +.Ef +The +.Fn brk +function +sets the break or lowest address +of a process's data segment (unilitialized data) to +.Fa addr +(immediately above bss). +Data addressing is restricted between +.Fa addr +and the lowest stack pointer to the stack segment. +Memory is allocated by +.Fa brk +in page size pieces; +if +.Fa addr +is not evenly divisible by the system page size, it is +increased to the next page boundary. +.Pp +.\" The +.\" .Nm sbrk +.\" function +.\" allocates chunks of +.\" .Fa incr +.\" bytes +.\" to the process's data space +.\" and returns an address pointer. +.\" The +.\" .Xr malloc 3 +.\" function utilizes +.\" .Nm sbrk . +.\" .Pp +The current value of the program break is reliably returned by +.Dq Li sbrk(0) +(see also +.Xr end 3 ) . +The +.Xr getrlimit 2 +system call may be used to determine +the maximum permissible size of the +.Em data +segment; +it will not be possible to set the break +beyond the +.Em rlim_max +value returned from a call to +.Xr getrlimit , +e.g. +.Dq qetext + rlp\(->rlim_max. +(see +.Xr end 3 +for the definition of +.Em etext ) . +.Sh RETURN VALUES +.Nm Brk +returns 0 if successful; -1 if the process requests more memory than +than allowed by the system limit. +The +.Nm sbrk +function returns 0 if successful, otherwise the error +.Er EOPNOTSUPP +is returned. +.\" .Sh ERRORS +.\" .Xr Sbrk +.\" returns -1 if the break could not be set. +.\" will fail and no additional memory will be allocated if +.\" one of the following are true: +.\" .Bl -tag -width [ENOMEM] +.\" .It Bq Er ENOMEM +.\" The limit, as set by +.\" .Xr setrlimit 2 , +.\" was exceeded. +.\" .It Bq Er ENOMEM +.\" The maximum possible size of a data segment (compiled into the +.\" system) was exceeded. +.\" .It Bq Er ENOMEM +.\" Insufficient space existed in the swap area +.\" to support the expansion. +.\" .El +.Sh SEE ALSO +.Xr execve 2 , +.Xr getrlimit 2 , +.Xr malloc 3 , +.Xr end 3 +.Sh BUGS +Setting the break may fail due to a temporary lack of +swap space. It is not possible to distinguish this +from a failure caused by exceeding the maximum size of +the data segment without consulting +.Xr getrlimit . +.Sh HISTORY +A +.Nm +function call appeared in Version 7 AT&T UNIX. diff --git a/usr/src/lib/libc/sys/chdir.2 b/usr/src/lib/libc/sys/chdir.2 new file mode 100644 index 0000000000..244ab59ae7 --- /dev/null +++ b/usr/src/lib/libc/sys/chdir.2 @@ -0,0 +1,129 @@ +.\" Copyright (c) 1980, 1991 Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)chdir.2 6.7 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt CHDIR 2 +.Os BSD 4 +.Sh NAME +.Nm chdir , +.Nm fchdir +.Nd change current working directory +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn chdir "const char *path" +.Ft int +.Fn fchdir "int fd" +.Sh DESCRIPTION +The +.Fa path +arument points to the pathname of a directory. +The +.Fn chdir +function +causes the named directory +to become the current working directory, that is, +the starting point for path searches of pathnames not beginning with +a slash, +.Ql / . +.Pp +The +.Fn fchdir +function +causes the directory referenced by +.Fa fd +to become the current working directory, +the starting point for path searches of pathnames not beginning with +a slash, +.Ql / . +.Pp +In order for a directory to become the current directory, +a process must have execute (search) access to the directory. +.Sh RETURN VALUES +Upon successful completion, a value of 0 is returned. +Otherwise, a value of -1 is returned and +.Va errno +is set to indicate +the error. +.Sh ERRORS +.Fn Chdir +will fail and the current working directory will be unchanged if +one or more of the following are true: +.Bl -tag -width Er +.It Bq Er ENOTDIR +A component of the path prefix is not a directory. +.It Bq Er EINVAL +The pathname contains a character with the high-order bit set. +.It Bq Er ENAMETOOLONG +A component of a pathname exceeded 255 characters, +or an entire path name exceeded 1023 characters. +.It Bq Er ENOENT +The named directory does not exist. +.It Bq Er ELOOP +Too many symbolic links were encountered in translating the pathname. +.It Bq Er EACCES +Search permission is denied for any component of +the path name. +.It Bq Er EFAULT +.Fa Path +points outside the process's allocated address space. +.It Bq Er EIO +An I/O error occurred while reading from or writing to the file system. +.El +.Pp +.Fn Fchdir +will fail and the current working directory will be unchanged if +one or more of the following are true: +.Bl -tag -width Er +.It Bq Er EACCES +Search permission is denied for the directory referenced by the +file descriptor. +.It Bq Er ENOTDIR +The file descriptor does not reference a directory. +.It Bq Er EBADF +The argument +.Fa fd +is not a valid file descriptor. +.El +.Sh SEE ALSO +.Xr chroot 2 +.Sh STANDARDS +.Fn Chdir +is expected to conform to IEEE Std 1003.1-1988 +.Pq Dq Tn POSIX . +.Sh HISTORY +The +.Fn fchdir +function call +appeared in +.Bx 4.2 . diff --git a/usr/src/lib/libc/sys/chmod.2 b/usr/src/lib/libc/sys/chmod.2 new file mode 100644 index 0000000000..10e1e3ef83 --- /dev/null +++ b/usr/src/lib/libc/sys/chmod.2 @@ -0,0 +1,182 @@ +.\" Copyright (c) 1980, 1991 Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)chmod.2 6.6 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt CHMOD 2 +.Os BSD 4 +.Sh NAME +.Nm chmod , +.Nm fchmod +.Nd change mode of file +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn chmod "const char *path" "mode_t mode" +.Ft int +.Fn fchmod "int fd" "mode_t mode" +.Sh DESCRIPTION +The function +.Fn chmod +sets the file permission bits +of the file +specified by the pathname +.Fa path +to +.Fa mode . +.Fn Fchmod +sets the permission bits of the specified +file descriptor +.Fa fd . +.Fn Chmod +verifies that the process owner (user) either owns +the file specified by +.Fa path +(or +.Fa fd ) , +or +is the super-user. +A mode is created from +.Em or Ap d +permission bit masks +defined in +.Aq Pa sys/stat.h : +.Bd -literal -offset indent -compact +#define S_IRWXU 0000700 /* RWX mask for owner */ +#define S_IRUSR 0000400 /* R for owner */ +#define S_IWUSR 0000200 /* W for owner */ +#define S_IXUSR 0000100 /* X for owner */ + +#define S_IRWXG 0000070 /* RWX mask for group */ +#define S_IRGRP 0000040 /* R for group */ +#define S_IWGRP 0000020 /* W for group */ +#define S_IXGRP 0000010 /* X for group */ + +#define S_IRWXO 0000007 /* RWX mask for other */ +#define S_IROTH 0000004 /* R for other */ +#define S_IWOTH 0000002 /* W for other */ +#define S_IXOTH 0000001 /* X for other */ + +#define S_ISUID 0004000 /* set user id on execution */ +#define S_ISGID 0002000 /* set group id on execution */ +#define S_ISVTX 0001000 /* save swapped text even after use */ +.Ed +.Pp +The +.Dv ISVTX +(the +.Em sticky bit ) +indicates to the system which executable files are shareable (the +default) and the system maintains the program text of the files +in the swap area. The sticky bit may only be set by the super user +on shareable executable files. +.Pp +If mode +.Dv ISVTX +(the `sticky bit') is set on a directory, +an unprivileged user may not delete or rename +files of other users in that directory. The sticky bit may be +set by any user on a directory which the user owns or has appropriate +permissions. +For more details of the properties of the sticky bit, see +.Xr sticky 8 . +.Pp +Writing or changing the owner of a file +turns off the set-user-id and set-group-id bits +unless the user is the super-user. +This makes the system somewhat more secure +by protecting set-user-id (set-group-id) files +from remaining set-user-id (set-group-id) if they are modified, +at the expense of a degree of compatibility. +.Sh RETURN VALUES +Upon successful completion, a value of 0 is returned. +Otherwise, a value of -1 is returned and +.Va errno +is set to indicate the error. +.Sh ERRORS +.Fn Chmod +will fail and the file mode will be unchanged if: +.Bl -tag -width Er +.It Bq Er ENOTDIR +A component of the path prefix is not a directory. +.It Bq Er EINVAL +The pathname contains a character with the high-order bit set. +.It Bq Er ENAMETOOLONG +A component of a pathname exceeded 255 characters, +or an entire path name exceeded 1023 characters. +.It Bq Er ENOENT +The named file does not exist. +.It Bq Er EACCES +Search permission is denied for a component of the path prefix. +.It Bq Er ELOOP +Too many symbolic links were encountered in translating the pathname. +.It Bq Er EPERM +The effective user ID does not match the owner of the file and +the effective user ID is not the super-user. +.It Bq Er EROFS +The named file resides on a read-only file system. +.It Bq Er EFAULT +.Fa Path +points outside the process's allocated address space. +.It Bq Er EIO +An I/O error occurred while reading from or writing to the file system. +.El +.Pp +.Fn Fchmod +will fail if: +.Bl -tag -width Er +.It Bq Er EBADF +The descriptor is not valid. +.It Bq Er EINVAL +.Fa Fd +refers to a socket, not to a file. +.It Bq Er EROFS +The file resides on a read-only file system. +.It Bq Er EIO +An I/O error occurred while reading from or writing to the file system. +.El +.Sh SEE ALSO +.Xr chmod 1 , +.Xr open 2 , +.Xr chown 2 , +.Xr stat 2 , +.Xr sticky 8 +.Sh STANDARDS +.Fn Chmod +is expected to conform to IEEE Std 1003.1-1988 +.Pq Dq Tn POSIX . +.Sh HISTORY +The +.Fn fchmod +function call +appeared in +.Bx 4.2 . diff --git a/usr/src/lib/libc/sys/chown.2 b/usr/src/lib/libc/sys/chown.2 new file mode 100644 index 0000000000..257e1d09b2 --- /dev/null +++ b/usr/src/lib/libc/sys/chown.2 @@ -0,0 +1,147 @@ +.\" Copyright (c) 1980, 1991 Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)chown.2 6.7 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt CHOWN 2 +.Os BSD 4 +.Sh NAME +.Nm chown , +.Nm fchown +.Nd change owner and group of a file +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn chown "const char *path" "uid_t owner" "gid_t group" +.Ft int +.Fn fchown "int fd" "int owner" "int group" +.Sh DESCRIPTION +The owner ID and group ID of the file +named by +.Fa path +or referenced by +.Fa fd +is changed as specified by the arguments +.Fa owner +and +.Fa group . +The owner of a file may change the +.Fa group +to a group of which +he or she is a member, +but the change +.Fa owner +capability is restricted to the super-user. +.Pp +.Fn Chown +clears the set-user-id and set-group-id bits +on the file +to prevent accidental or mischievious creation of +set-user-id and set-group-id programs. +.Pp +.Fn Fchown +is particularly useful when used in conjunction +with the file locking primitives (see +.Xr flock 2 ) . +.Pp +One of the owner or group id's +may be left unchanged by specifying it as -1. +.Pp +If the final component of +.Fa path +is a symbolic link, +the ownership and group of the symbolic link is changed, +not the ownership and group of the file or directory to which it points. +.Sh RETURN VALUES +Zero is returned if the operation was successful; +-1 is returned if an error occurs, with a more specific +error code being placed in the global variable +.Va errno . +.Sh ERRORS +.Fn Chown +will fail and the file will be unchanged if: +.Bl -tag -width Er +.It Bq Er ENOTDIR +A component of the path prefix is not a directory. +.It Bq Er EINVAL +The pathname contains a character with the high-order bit set. +.It Bq Er ENAMETOOLONG +A component of a pathname exceeded 255 characters, +or an entire path name exceeded 1023 characters. +.It Bq Er ENOENT +The named file does not exist. +.It Bq Er EACCES +Search permission is denied for a component of the path prefix. +.It Bq Er ELOOP +Too many symbolic links were encountered in translating the pathname. +.It Bq Er EPERM +The effective user ID is not the super-user. +.It Bq Er EROFS +The named file resides on a read-only file system. +.It Bq Er EFAULT +.Fa Path +points outside the process's allocated address space. +.It Bq Er EIO +An I/O error occurred while reading from or writing to the file system. +.El +.Pp +.Fn Fchown +will fail if: +.Bl -tag -width Er +.It Bq Er EBADF +.Fa Fd +does not refer to a valid descriptor. +.It Bq Er EINVAL +.Fa Fd +refers to a socket, not a file. +.It Bq Er EPERM +The effective user ID is not the super-user. +.It Bq Er EROFS +The named file resides on a read-only file system. +.It Bq Er EIO +An I/O error occurred while reading from or writing to the file system. +.El +.Sh SEE ALSO +.Xr chown 8 , +.Xr chgrp 1 , +.Xr chmod 2 , +.Xr flock 2 +.Sh STANDARDS +.Fn Chown +is expected to conform to IEEE Std 1003.1-1988 +.Pq Dq Tn POSIX . +.Sh HISTORY +The +.Fn fchown +function call +appeared in +.Bx 4.2 . diff --git a/usr/src/lib/libc/sys/chroot.2 b/usr/src/lib/libc/sys/chroot.2 new file mode 100644 index 0000000000..529f00bb7b --- /dev/null +++ b/usr/src/lib/libc/sys/chroot.2 @@ -0,0 +1,97 @@ +.\" Copyright (c) 1983, 1991 Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)chroot.2 6.5 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt CHROOT 2 +.Os BSD 4.2 +.Sh NAME +.Nm chroot +.Nd change root directory +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn chroot "const char *dirname" +.Sh DESCRIPTION +.Fa Dirname +is the address of the pathname of a directory, terminated by an ASCII NUL. +.Fn Chroot +causes +.Fa dirname +to become the root directory, +that is, the starting point for path searches of pathnames +beginning with +.Ql / . +.Pp +In order for a directory to become the root directory +a process must have execute (search) access for that directory. +.Pp +It should be noted that +.Fn chroot +has no effect on the process's current directory. +.Pp +This call is restricted to the super-user. +.Sh RETURN VALUES +Upon successful completion, a value of 0 is returned. Otherwise, +a value of -1 is returned and +.Va errno +is set to indicate an error. +.Sh ERRORS +.Fn Chroot +will fail and the root directory will be unchanged if: +.Bl -tag -width [ENOTDIR] +.It Bq Er ENOTDIR +A component of the path name is not a directory. +.It Bq Er EINVAL +The pathname contains a character with the high-order bit set. +.It Bq Er ENAMETOOLONG +A component of a pathname exceeded 255 characters, +or an entire path name exceeded 1023 characters. +.It Bq Er ENOENT +The named directory does not exist. +.It Bq Er EACCES +Search permission is denied for any component of the path name. +.It Bq Er ELOOP +Too many symbolic links were encountered in translating the pathname. +.It Bq Er EFAULT +.Fa Path +points outside the process's allocated address space. +.It Bq Er EIO +An I/O error occurred while reading from or writing to the file system. +.El +.Sh SEE ALSO +.Xr chdir 2 +.Sh HISTORY +The +.Nm +function call appeared in +.Bx 4.2 . diff --git a/usr/src/lib/libc/sys/close.2 b/usr/src/lib/libc/sys/close.2 new file mode 100644 index 0000000000..8400214dba --- /dev/null +++ b/usr/src/lib/libc/sys/close.2 @@ -0,0 +1,120 @@ +.\" Copyright (c) 1980, 1991 Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)close.2 6.4 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt CLOSE 2 +.Os BSD 4 +.Sh NAME +.Nm close +.Nd delete a descriptor +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn close "int d" +.Sh DESCRIPTION +The +.Fn close +call deletes a descriptor from the per-process object +reference table. +If this is the last reference to the underlying object, the +object will be deactivated. +For example, on the last close of a file +the current +.Em seek +pointer associated with the file is lost; +on the last close of a +.Xr socket 2 +associated naming information and queued data are discarded; +on the last close of a file holding an advisory lock +the lock is released (see further +.Xr flock 2 ) . +.Pp +When a process exits, +all associated file descriptors are freed, but since there is +a limit on active descriptors per processes, the +.Fn close +function call +is useful when a large quanitity of file descriptors are being handled. +.Pp +When a process forks (see +.Xr fork 2 ) , +all descriptors for the new child process reference the same +objects as they did in the parent before the fork. +If a new process is then to be run using +.Xr execve 2 , +the process would normally inherit these descriptors. Most +of the descriptors can be rearranged with +.Xr dup2 2 +or deleted with +.Fn close +before the +.Xr execve +is attempted, but if some of these descriptors will still +be needed if the execve fails, it is necessary to arrange for them +to be closed if the execve succeeds. +For this reason, the call +.Dq Li fcntl(d, F_SETFD, 1) +is provided, +which arranges that a descriptor will be closed after a successful +execve; the call +.Dq Li fcntl(d, F_SETFD, 0) +restores the default, +which is to not close the descriptor. +.Sh RETURN VALUES +Upon successful completion, a value of 0 is returned. +Otherwise, a value of -1 is returned and the global integer variable +.Va errno +is set to indicate the error. +.Sh ERRORS +.Fn Close +will fail if: +.Bl -tag -width Er +.It Bq Er EBADF +.Fa D +is not an active descriptor. +.It Bq Er EINTR +An interupt was received. +.El +.Sh SEE ALSO +.Xr accept 2 , +.Xr flock 2 , +.Xr open 2 , +.Xr pipe 2 , +.Xr socket 2 , +.Xr socketpair 2 , +.Xr execve 2 , +.Xr fcntl 2 +.Sh STANDARDS +.Fn Close +conforms to IEEE Std 1003.1-1988 +.Pq Dq Tn POSIX . diff --git a/usr/src/lib/libc/sys/connect.2 b/usr/src/lib/libc/sys/connect.2 new file mode 100644 index 0000000000..db2738b05a --- /dev/null +++ b/usr/src/lib/libc/sys/connect.2 @@ -0,0 +1,147 @@ +.\" Copyright (c) 1983 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)connect.2 6.9 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt CONNECT 2 +.Os BSD 4.2 +.Sh NAME +.Nm connect +.Nd initiate a connection on a socket +.Sh SYNOPSIS +.Fd #include +.Fd #include +.Ft int +.Fn connect "int s" "struct sockaddr *name" "int namelen" +.Sh DESCRIPTION +The parameter +.Fa s +is a socket. +If it is of type +.Dv SOCK_DGRAM , +this call specifies the peer with which the socket is to be associated; +this address is that to which datagrams are to be sent, +and the only address from which datagrams are to be received. +If the socket is of type +.Dv SOCK_STREAM , +this call attempts to make a connection to +another socket. +The other socket is specified by +.Fa name , +which is an address in the communications space of the socket. +Each communications space interprets the +.Fa name +parameter in its own way. +Generally, stream sockets may successfully +.Fn connect +only once; datagram sockets may use +.Fn connect +multiple times to change their association. +Datagram sockets may dissolve the association +by connecting to an invalid address, such as a null address. +.Sh RETURN VALUES +If the connection or binding succeeds, 0 is returned. +Otherwise a -1 is returned, and a more specific error +code is stored in +.Va errno . +.Sh ERRORS +The +.Fn connect +call fails if: +.Bl -tag -width EADDRNOTAVAILABB +.It Bq Er EBADF +.Fa S +is not a valid descriptor. +.It Bq Er ENOTSOCK +.Fa S +is a descriptor for a file, not a socket. +.It Bq Er EADDRNOTAVAIL +The specified address is not available on this machine. +.It Bq Er EAFNOSUPPORT +Addresses in the specified address family cannot be used with this socket. +.It Bq Er EISCONN +The socket is already connected. +.It Bq Er ETIMEDOUT +Connection establishment timed out without establishing a connection. +.It Bq Er ECONNREFUSED +The attempt to connect was forcefully rejected. +.It Bq Er ENETUNREACH +The network isn't reachable from this host. +.It Bq Er EADDRINUSE +The address is already in use. +.It Bq Er EFAULT +The +.Fa name +parameter specifies an area outside +the process address space. +.It Bq Er EINPROGRESS +The socket is non-blocking +and the connection cannot +be completed immediately. +It is possible to +.Xr select 2 +for completion by selecting the socket for writing. +.It Bq Er EALREADY +The socket is non-blocking +and a previous connection attempt +has not yet been completed. +.El +.Pp +The following errors are specific to connecting names in the UNIX domain. +These errors may not apply in future versions of the UNIX IPC domain. +.Bl -tag -width EADDRNOTAVAILABB +.It Bq Er ENOTDIR +A component of the path prefix is not a directory. +.It Bq Er EINVAL +The pathname contains a character with the high-order bit set. +.It Bq Er ENAMETOOLONG +A component of a pathname exceeded 255 characters, +or an entire path name exceeded 1023 characters. +.It Bq Er ENOENT +The named socket does not exist. +.It Bq Er EACCES +Search permission is denied for a component of the path prefix. +.It Bq Er EACCES +Write access to the named socket is denied. +.It Bq Er ELOOP +Too many symbolic links were encountered in translating the pathname. +.El +.Sh SEE ALSO +.Xr accept 2 , +.Xr select 2 , +.Xr socket 2 , +.Xr getsockname 2 +.Sh HISTORY +The +.Nm +function call appeared in +.Bx 4.2 . diff --git a/usr/src/lib/libc/sys/dup.2 b/usr/src/lib/libc/sys/dup.2 new file mode 100644 index 0000000000..d79373d981 --- /dev/null +++ b/usr/src/lib/libc/sys/dup.2 @@ -0,0 +1,132 @@ +.\" Copyright (c) 1980, 1991 Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)dup.2 6.4 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt DUP 2 +.Os BSD 4 +.Sh NAME +.Nm dup , +.Nm dup2 +.Nd duplicate an existing file descriptor +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn dup "int oldd" +.Ft int +.Fn dup2 "int oldd" "int newd" +.Sh DESCRIPTION +.Fn Dup +duplicates an existing object descriptor and returns its value to +the calling process +.Fa ( newd += +.Fn dup oldd ) . +The argument +.Fa oldd +is a small non-negative integer index in +the per-process descriptor table. The value must be less +than the size of the table, which is returned by +.Xr getdtablesize 2 . +The new descriptor returned by the call +is the lowest numbered descriptor +currently not in use by the process. +.Pp +The object referenced by the descriptor does not distinguish +between +.Fa oldd +and +.Fa newd +in any way. +Thus if +.Fa newd +and +.Fa oldd +are duplicate references to an open +file, +.Xr read 2 , +.Xr write 2 +and +.Xr lseek 2 +calls all move a single pointer into the file, +and append mode, non-blocking I/O and asynchronous I/O options +are shared between the references. +If a separate pointer into the file is desired, a different +object reference to the file must be obtained by issuing an +additional +.Xr open 2 +call. +The close-on-exec flag on the new file descriptor is unset. +.Pp +In +.Fn dup2 , +the value of the new descriptor +.Fa newd +is specified. If this descriptor is already +in use, the descriptor is first deallocated as if a +.Xr close 2 +call had been done first. +.Sh RETURN VALUES +The value -1 is returned if an error occurs in either call. +The external variable +.Va errno +indicates the cause of the error. +.Sh ERRORS +.Fn Dup +and +.Fn dup2 +fail if: +.Bl -tag -width Er +.It Bq Er EBADF +.Fa Oldd +or +.Fa newd +is not a valid active descriptor +.It Bq Er EMFILE +Too many descriptors are active. +.El +.Sh SEE ALSO +.Xr accept 2 , +.Xr open 2 , +.Xr close 2 , +.Xr fcntl 2 , +.Xr pipe 2 , +.Xr socket 2 , +.Xr socketpair 2 , +.Xr getdtablesize 2 +.Sh STANDARDS +.Fn Dup +and +.Fn dup2 +are expected to conform +to IEEE Std 1003.1-1988 +.Pq Dq Tn POSIX . diff --git a/usr/src/lib/libc/sys/execve.2 b/usr/src/lib/libc/sys/execve.2 new file mode 100644 index 0000000000..23f5348708 --- /dev/null +++ b/usr/src/lib/libc/sys/execve.2 @@ -0,0 +1,255 @@ +.\" Copyright (c) 1980, 1991 Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)execve.2 6.9 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt EXECVE 2 +.Os BSD 4 +.Sh NAME +.Nm execve +.Nd execute a file +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn execve "const char *path" "const * char *argv" "const * char *envp" +.Sh DESCRIPTION +.Fn Execve +transforms the calling process into a new process. +The new process is constructed from an ordinary file, +whose name is pointed to by +.Fa path , +called the +.Em new process file . +This file is either an executable object file, +or a file of data for an interpreter. +An executable object file consists of an identifying header, +followed by pages of data representing the initial program (text) +and initialized data pages. Additional pages may be specified +by the header to be initialized with zero data; see +.Xr a.out 5 . +.Pp +An interpreter file begins with a line of the form: +.Pp +.Bd -filled -offset indent -compact +.Sy \&#! +.Em interpreter +.Bq Em arg +.Ed +.Pp +When an interpreter file is +.Fn execve Ap d , +the system +.Fn execve Ap s +the specified +.Em interpreter . +If the optional +.Em arg +is specified, it becomes the first argument to the +.Em interpreter , +and the name of the originally +.Fn execve Ap d +file becomes the second argument; +otherwise, the name of the originally +.Fn execve Ap d +file becomes the first argument. The original arguments are shifted over to +become the subsequent arguments. The zeroth argument, normally the name of the +.Fn execve Ap d +file, is left unchanged. +.Pp +The argument +.Fa argv +is a pointer to a null-terminated array of +character pointers to null-terminated character strings. +These strings construct the argument list to be made available to the new +process. At least one argument must be present in +the array; by custom, the first element should be +the name of the executed program (for example, the last component of +.Fa path ) . +.Pp +The argument +.Fa envp +is also a pointer to a null-terminated array of +character pointers to null-terminated strings. +A pointer to this array is normally stored in the global variable +.Va environ. +These strings pass information to the +new process that is not directly an argument to the command (see +.Xr environ 7 ) . +.Pp +File descriptors open in the calling process image remain open in +the new process image, except for those for which the close-on-exec +flag is set (see +.Xr close 2 +and +.Xr fcntl 2 ) . +Descriptors that remain open are unaffected by +.Fn execve . +.Pp +Signals set to be ignored in the calling process are set to be ignored in +the +new process. Signals which are set to be caught in the calling process image +are set to default action in the new process image. +Blocked signals remain blocked regardless of changes to the signal action. +The signal stack is reset to be undefined (see +.Xr sigaction 2 +for more information). +.Pp +If the set-user-ID mode bit of the new process image file is set +(see +.Xr chmod 2 ) , +the effective user ID of the new process image is set to the owner ID +of the new process image file. +If the set-group-ID mode bit of the new process image file is set, +the effective group ID of the new process image is set to the group ID +of the new process image file. +The real user ID, real group ID and +supplementary group IDs of the new process image remain the same as the calling +process image. +.Pp +The new process also inherits the following attributes from +the calling process: +.Pp +.Bl -column parent_process_ID -offset indent -compact +.It process ID Ta see Xr getpid 2 +.It parent process ID Ta see Xr getppid 2 +.It process group ID Ta see Xr getpgrp 2 +.It access groups Ta see Xr getgroups 2 +.It working directory Ta see Xr chdir 2 +.It root directory Ta see Xr chroot 2 +.It control terminal Ta see Xr termios 4 +.It resource usages Ta see Xr getrusage 2 +.It interval timers Ta see Xr getitimer 2 +.It resource limits Ta see Xr getrlimit 2 +.It file mode mask Ta see Xr umask 2 +.It signal mask Ta see Xr sigvec 2 , +.Xr sigsetmask 2 +.El +.Pp +When a program is executed as a result of an +.Fn execve +call, it is entered as follows: +.Bd -literal -offset indent +main(argc, argv, envp) +int argc; +char **argv, **envp; +.Ed +.Pp +where +.Fa argc +is the number of elements in +.Fa argv +(the ``arg count'') +and +.Fa argv +points to the array of character pointers +to the arguments themselves. +.Sh RETURN VALUES +As the +.Fn execve +function overlays the current process image +with a new process image the successful call +has no process to return to. +If +.Fn execve +does return to the calling process an error has occurred; the +return value will be -1 and the global variable +.Va errno +is set to indicate the error. +.Sh ERRORS +.Fn Execve +will fail and return to the calling process if: +.Bl -tag -width [ENAMETOOLONG] +.It Bq Er ENOTDIR +A component of the path prefix is not a directory. +.It Bq Er EINVAL +The pathname contains a character with the high-order bit set. +.It Bq Er ENAMETOOLONG +A component of a pathname exceeded 255 characters, +or an entire path name exceeded 1023 characters. +.It Bq Er ENOENT +The new process file does not exist. +.It Bq Er ELOOP +Too many symbolic links were encountered in translating the pathname. +.It Bq Er EACCES +Search permission is denied for a component of the path prefix. +.It Bq Er EACCES +The new process file is not an ordinary file. +.It Bq Er EACCES +The new process file mode denies execute permission. +.It Bq Er ENOEXEC +The new process file has the appropriate access +permission, but has an invalid magic number in its header. +.It Bq Er ETXTBSY +The new process file is a pure procedure (shared text) +file that is currently open for writing or reading by some process. +.It Bq Er ENOMEM +The new process requires more virtual memory than +is allowed by the imposed maximum +.Pq Xr getrlimit 2 . +.It Bq Er E2BIG +The number of bytes in the new process's argument list +is larger than the system-imposed limit. +The limit in the system as released is 20480 bytes +.Pf ( Dv NCARGS +in +.Ao Pa sys/param.h Ac . +.It Bq Er EFAULT +The new process file is not as long as indicated by +the size values in its header. +.It Bq Er EFAULT +.Fa Path , +.Fa argv , +or +.Fa envp +point +to an illegal address. +.It Bq Er EIO +An I/O error occurred while reading from the file system. +.El +.Sh CAVEAT +If a program is +.Em setuid +to a non-super-user, but is executed when +the real +.Em uid +is ``root'', then the program has some of the powers +of a super-user as well. +.Sh SEE ALSO +.Xr exit 2 , +.Xr fork 2 , +.Xr execl 3 , +.Xr environ 7 +.Sh HISTORY +The +.Nm +function call appeared in +.Bx 4.2 . diff --git a/usr/src/lib/libc/sys/fcntl.2 b/usr/src/lib/libc/sys/fcntl.2 new file mode 100644 index 0000000000..9161383a16 --- /dev/null +++ b/usr/src/lib/libc/sys/fcntl.2 @@ -0,0 +1,215 @@ +.\" Copyright (c) 1983 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)fcntl.2 6.7 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt FCNTL 2 +.Os BSD 4.2 +.Sh NAME +.Nm fcntl +.Nd file control +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn fcntl "int fd" "int cmd" "int arg" +.Sh DESCRIPTION +.Fn Fcntl +provides for control over descriptors. +The argument +.Fa fd +is a descriptor to be operated on by +.Fa cmd +as follows: +.Bl -tag -width F_GETOWNX +.It Dv F_DUPFD +Return a new descriptor as follows: +.Pp +.Bl -bullet -compact -offset 4n +.It +Lowest numbered available descriptor greater than or equal to +.Fa arg . +.It +Same object references as the original descriptor. +.It +New descriptor shares the same file offset if the object +was a file. +.It +Same access mode (read, write or read/write). +.It +Same file status flags (i.e., both file descriptors +share the same file status flags). +.It +The close-on-exec flag associated with the new file descriptor +is set to remain open across +.Xr execv 2 +system calls. +.El +.It Dv F_GETFD +Get the close-on-exec flag associated with the file descriptor +.Fa fd . +If the low-order bit of the returned value is 0, +the file will remain open across +.Fn exec , +otherwise the file will be closed upon execution of +.Fn exec +.Fa ( arg +is ignored). +.It Dv F_SETFD +Set the close-on-exec flag associated with +.Fa fd +to the low order bit of +.Fa arg +(0 or 1 as above). +.It Dv F_GETFL +Get descriptor status flags, as described below +.Fa ( arg +is ignored). +.It Dv F_SETFL +Set descriptor status flags to +.Fa arg . +.It Dv F_GETOWN +Get the process ID or process group +currently receiving +.Dv SIGIO +and +.Dv SIGURG +signals; process groups are returned +as negative values +.Fa ( arg +is ignored). +.It Dv F_SETOWN +Set the process or process group +to receive +.Dv SIGIO +and +.Dv SIGURG +signals; +process groups are specified by supplying +.Fa arg +as negative, otherwise +.Fa arg +is interpreted as a process ID. +.El +.Pp +The flags for the +.Dv F_GETFL +and +.Dv F_SETFL +flags are as follows: +.Bl -tag -width F_GETOWNX +.It Dv O_NDELAY +Non-blocking I/O; if no data is available to a +.Xr read +call, or if a +.Xr write +operation would block, +the read or write call returns -1 with the error +.Er EWOULDBLOCK . +.It Dv O_APPEND +Force each write to append at the end of file; +corresponds to the +.Dv O_APPEND +flag of +.Xr open 2 . +.It Dv O_ASYNC +Enable the +.Dv SIGIO +signal to be sent to the process group +when I/O is possible, e.g., +upon availability of data to be read. +.El +.Sh RETURN VALUES +Upon successful completion, the value returned depends on +.Fa cmd +as follows: +.Bl -tag -width F_GETOWNX -offset indent +.It Dv F_DUPFD +A new file descriptor. +.It Dv F_GETFD +Value of flag (only the low-order bit is defined). +.It Dv F_GETFL +Value of flags. +.It Dv F_GETOWN +Value of file descriptor owner. +.It other +Value other than -1. +.El +.Pp +Otherwise, a value of -1 is returned and +.Va errno +is set to indicate the error. +.Sh ERRORS +.Fn Fcntl +will fail if: +.Bl -tag -width Er +.It Bq Er EBADF +.Fa Fildes +is not a valid open file descriptor. +.It Bq Er EMFILE +.Fa Cmd +is +.Dv F_DUPFD +and the maximum allowed number of file descriptors are currently +open. +.It Bq Er EINVAL +.Fa Cmd +is +.Dv F_DUPFD +and +.Fa arg +is negative or greater than the maximum allowable number +(see +.Xr getdtablesize 2 ) . +.It Bq Er ESRCH +.Fa Cmd +is +.Dv F_SETOWN +and +the process ID given as argument is not in use. +.El +.Sh SEE ALSO +.Xr close 2 , +.Xr execve 2 , +.Xr getdtablesize 2 , +.Xr open 2 , +.Xr sigvec 2 +.Sh BUGS +The asynchronous I/O facilities of +.Dv FNDELAY +and +.Dv FASYNC +are currently available only for tty and socket operations. +.Sh HISTORY +The +.Nm +function call appeared in +.Bx 4.2 . diff --git a/usr/src/lib/libc/sys/flock.2 b/usr/src/lib/libc/sys/flock.2 new file mode 100644 index 0000000000..7e1fef78e9 --- /dev/null +++ b/usr/src/lib/libc/sys/flock.2 @@ -0,0 +1,145 @@ +.\" Copyright (c) 1983, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)flock.2 6.7 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt FLOCK 2 +.Os BSD 4.2 +.Sh NAME +.Nm flock +.Nd "apply or remove an advisory lock on an open file" +.Sh SYNOPSIS +.Fd #include +.Fd #define LOCK_SH 1 /* shared lock */ +.Fd #define LOCK_EX 2 /* exclusive lock */ +.Fd #define LOCK_NB 4 /* don't block when locking */ +.Fd #define LOCK_UN 8 /* unlock */ +.Ft int +.Fn flock "int fd" "int operation" +.Sh DESCRIPTION +.Fn Flock +applies or removes an +.Em advisory +lock on the file associated with the file descriptor +.Fa fd . +A lock is applied by specifying an +.Fa operation +parameter that is the inclusive or of +.Dv LOCK_SH +or +.Dv LOCK_EX +and, possibly, +.Dv LOCK_NB . +To unlock +an existing lock +.Dv operation +should be +.Dv LOCK_UN . +.Pp +Advisory locks allow cooperating processes to perform +consistent operations on files, but do not guarantee +consistency (i.e., processes may still access files +without using advisory locks possibly resulting in +inconsistencies). +.Pp +The locking mechanism allows two types of locks: +.Em shared +locks and +.Em exclusive +locks. +At any time multiple shared locks may be applied to a file, +but at no time are multiple exclusive, or both shared and exclusive, +locks allowed simultaneously on a file. +.Pp +A shared lock may be +.Em upgraded +to an exclusive lock, and vice versa, simply by specifying +the appropriate lock type; this results in the previous +lock being released and the new lock applied (possibly +after other processes have gained and released the lock). +.Pp +Requesting a lock on an object that is already locked +normally causes the caller to be blocked until the lock may be +acquired. If +.Dv LOCK_NB +is included in +.Fa operation , +then this will not happen; instead the call will fail and +the error +.Er EWOULDBLOCK +will be returned. +.Sh NOTES +Locks are on files, not file descriptors. That is, file descriptors +duplicated through +.Xr dup 2 +or +.Xr fork 2 +do not result in multiple instances of a lock, but rather multiple +references to a single lock. If a process holding a lock on a file +forks and the child explicitly unlocks the file, the parent will +lose its lock. +.Pp +Processes blocked awaiting a lock may be awakened by signals. +.Sh RETURN VALUES +Zero is returned if the operation was successful; +on an error a -1 is returned and an error code is left in +the global location +.Va errno . +.Sh ERRORS +The +.Fn flock +call fails if: +.Bl -tag -width EWOULDBLOCKAA +.It Bq Er EWOULDBLOCK +The file is locked and the +.Dv LOCK_NB +option was specified. +.It Bq Er EBADF +The argument +.Fa fd +is an invalid descriptor. +.It Bq Er EINVAL +The argument +.Fa fd +refers to an object other than a file. +.El +.Sh SEE ALSO +.Xr open 2 , +.Xr close 2 , +.Xr dup 2 , +.Xr execve 2 , +.Xr fork 2 +.Sh HISTORY +The +.Nm +function call appeared in +.Bx 4.2 . diff --git a/usr/src/lib/libc/sys/fork.2 b/usr/src/lib/libc/sys/fork.2 new file mode 100644 index 0000000000..8c16ae7eda --- /dev/null +++ b/usr/src/lib/libc/sys/fork.2 @@ -0,0 +1,107 @@ +.\" Copyright (c) 1980, 1991 Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)fork.2 6.5 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt FORK 2 +.Os BSD 4.0 +.Sh NAME +.Nm fork +.Nd create a new process +.Sh SYNOPSIS +.Fd #include +.Ft pid_t +.Fn fork void +.Sh DESCRIPTION +.Fn Fork +causes creation of a new process. +The new process (child process) is an exact copy of the +calling process (parent process) except for the following: +.Bl -bullet -offset indent +.It +The child process has a unique process ID. +.It +The child process has a different parent +process ID (i.e., the process ID of the parent process). +.It +The child process has its own copy of the parent's descriptors. +These descriptors reference the same underlying objects, so that, +for instance, file pointers in file objects are shared between +the child and the parent, so that an +.Xr lseek 2 +on a descriptor in the child process can affect a subsequent +.Xr read +or +.Xr write +by the parent. +This descriptor copying is also used by the shell to +establish standard input and output for newly created processes +as well as to set up pipes. +.It +The child processes resource utilizations +are set to 0; see +.Xr setrlimit 2 . +.El +.Sh RETURN VALUES +Upon successful completion, +.Fn fork +returns a value +of 0 to the child process and returns the process ID of the child +process to the parent process. Otherwise, a value of -1 is returned +to the parent process, no child process is created, and the global +variable +.Va errno +is set to indicate the error. +.Sh ERRORS +.Fn Fork +will fail and no child process will be created if: +.Bl -tag -width [EAGAIN] +.It Bq Er EAGAIN +The system-imposed limit on the total +number of processes under execution would be exceeded. +This limit is configuration-dependent. +.It Bq Er EAGAIN +The system-imposed limit +.Dv MAXUPRC +.Pq Aq Pa sys/param.h +on the total number of +processes under execution by a single user would be exceeded. +.It Bq Er ENOMEM +There is insufficient swap space for the new process. +.El +.Sh SEE ALSO +.Xr execve 2 , +.Xr wait 2 +.Sh HISTORY +A +.Nm +function call appeared in Version 6 AT&T UNIX. diff --git a/usr/src/lib/libc/sys/fsync.2 b/usr/src/lib/libc/sys/fsync.2 new file mode 100644 index 0000000000..ef832da99f --- /dev/null +++ b/usr/src/lib/libc/sys/fsync.2 @@ -0,0 +1,81 @@ +.\" Copyright (c) 1983 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)fsync.2 6.7 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt FSYNC 2 +.Os BSD 4.2 +.Sh NAME +.Nm fsync +.Nd "synchronize a file's in-core state with that on disk" +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn fsync "int fd" +.Sh DESCRIPTION +.Fn Fsync +causes all modified data and attributes of +.Fa fd +to be moved to a permanent storage device. +This normally results in all in-core modified copies +of buffers for the associated file to be written to a disk. +.Pp +.Fn Fsync +should be used by programs that require a file to be +in a known state, for example, in building a simple transaction +facility. +.Sh RETURN VALUES +A 0 value is returned on success. A -1 value indicates +an error. +.Sh ERRORS +The +.Fn fsync +fails if: +.Bl -tag -width Er +.It Bq Er EBADF +.Fa Fd +is not a valid descriptor. +.It Bq Er EINVAL +.Fa Fd +refers to a socket, not to a file. +.It Bq Er EIO +An I/O error occurred while reading from or writing to the file system. +.El +.Sh SEE ALSO +.Xr sync 2 , +.Xr sync 8 , +.Xr update 8 +.Sh HISTORY +The +.Nm +function call appeared in +.Bx 4.2 . diff --git a/usr/src/lib/libc/sys/getdtablesize.2 b/usr/src/lib/libc/sys/getdtablesize.2 new file mode 100644 index 0000000000..7b68f8f4eb --- /dev/null +++ b/usr/src/lib/libc/sys/getdtablesize.2 @@ -0,0 +1,60 @@ +.\" Copyright (c) 1983, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)getdtablesize.2 6.5 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt GETDTABLESIZE 2 +.Os BSD 4.2 +.Sh NAME +.Nm getdtablesize +.Nd get descriptor table size +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn getdtablesize void +.Sh DESCRIPTION +Each process has a fixed size descriptor table, +which is guaranteed to have at least 20 slots. The entries in +the descriptor table are numbered with small integers starting at 0. +The call +.Fn getdtablesize +returns the size of this table. +.Sh SEE ALSO +.Xr close 2 , +.Xr dup 2 , +.Xr open 2 , +.Xr select 2 +.Sh HISTORY +The +.Nm +function call appeared in +.Bx 4.2 . diff --git a/usr/src/lib/libc/sys/getgid.2 b/usr/src/lib/libc/sys/getgid.2 new file mode 100644 index 0000000000..373b494009 --- /dev/null +++ b/usr/src/lib/libc/sys/getgid.2 @@ -0,0 +1,79 @@ +.\" Copyright (c) 1983, 1991 Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)getgid.2 6.3 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt GETGID 2 +.Os BSD 4.2 +.Sh NAME +.Nm getgid , +.Nm getegid +.Nd get group process identification +.Sh SYNOPSIS +.Fd #include +.Ft gid_t +.Fn getgid void +.Ft gid_t +.Fn getegid void +.Sh DESCRIPTION +The +.Fn getgid +function returns the real group ID of the calling process, +.Fn getegid +returns the effective group ID of the calling process. +.Pp +The real group ID is specified at login time. +.Pp +The real group ID is the group of the user who invoked the program. +As the effective group ID gives the process additional permissions +during the execution of +.Dq Em set-group-ID +mode processes, +.Fn getgid +is used to determine the real-user-id of the calling process. +.Sh ERRORS +The +.Fn getgid +and +.Fn getegid +functions are always successful, and no return value is reserved to +indicate an error. +.Sh SEE ALSO +.Xr getuid 2 , +.Xr setregid 2 , +.Xr setgid 3 +.Sh STANDARDS +.Fn Getgid +and +.Fn getegid +conform to IEEE Std 1003.1-1988 +.Pq Dq Tn POSIX . diff --git a/usr/src/lib/libc/sys/getgroups.2 b/usr/src/lib/libc/sys/getgroups.2 new file mode 100644 index 0000000000..741fa05327 --- /dev/null +++ b/usr/src/lib/libc/sys/getgroups.2 @@ -0,0 +1,96 @@ +.\" Copyright (c) 1983, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)getgroups.2 6.7 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt GETGROUPS 2 +.Os BSD 4.2 +.Sh NAME +.Nm getgroups +.Nd get group access list +.Sh SYNOPSIS +.Fd #include +.Fd #include +.Ft int +.Fn getgroups "int gidsetlen" "int *gidset" +.Sh DESCRIPTION +.Fn Getgroups +gets the current group access list of the user process +and stores it in the array +.Fa gidset . +The parameter +.Fa gidsetlen +indicates the number of entries that may be placed in +.Fa gidset . +.Fn Getgroups +returns the actual number of groups returned in +.Fa gidset . +No more than +.Dv NGROUPS , +as defined in +.Aq Pa sys/param.h , +will ever +be returned. +.Sh RETURN VALUES +A successful call returns the number of groups in the group set. +A value of -1 indicates that an error occurred, and the error +code is stored in the global variable +.Va errno . +.Sh ERRORS +The possible errors for +.Fn getgroups +are: +.Bl -tag -width Er +.It Bq Er EINVAL +The argument +.Fa gidsetlen +is smaller than the number of groups in the group set. +.It Bq Er EFAULT +The argument +.Fa gidset +specifies +an invalid address. +.El +.Sh SEE ALSO +.Xr setgroups 2 , +.Xr initgroups 3 +.Sh BUGS +The +.Fa gidset +array should be of type +.Vt gid_t , +but remains integer for compatibility with earlier systems. +.Sh HISTORY +The +.Nm +function call appeared in +.Bx 4.2 . diff --git a/usr/src/lib/libc/sys/gethostid.2 b/usr/src/lib/libc/sys/gethostid.2 new file mode 100644 index 0000000000..4c334aaaeb --- /dev/null +++ b/usr/src/lib/libc/sys/gethostid.2 @@ -0,0 +1,66 @@ +.\" Copyright (c) 1983, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)gethostid.2 6.6 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt GETHOSTID 2 +.Os BSD 4.2 +.Sh NAME +.Nm gethostid , +.Nm sethostid +.Nd get/set unique identifier of current host +.Sh SYNOPSIS +.Fd #include +.Ft long +.Fn gethostid void +.Ft int +.Fn sethostid "long hostid" +.Sh DESCRIPTION +.Fn Sethostid +establishes a 32-bit identifier for the +current processor that is intended to be unique among all +UNIX systems in existence. This is normally a DARPA Internet +address for the local machine. This call is allowed only to the +super-user and is normally performed at boot time. +.Pp +.Fn Gethostid +returns the 32-bit identifier for the current processor. +.Sh SEE ALSO +.Xr hostid 1 , +.Xr gethostname 2 +.Sh BUGS +32 bits for the identifier is too small. +.Sh HISTORY +The +.Nm +function call appeared in +.Bx 4.2 . diff --git a/usr/src/lib/libc/sys/gethostname.2 b/usr/src/lib/libc/sys/gethostname.2 new file mode 100644 index 0000000000..19b5e2cf99 --- /dev/null +++ b/usr/src/lib/libc/sys/gethostname.2 @@ -0,0 +1,96 @@ +.\" Copyright (c) 1983, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)gethostname.2 6.7 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt GETHOSTNAME 2 +.Os BSD 4.2 +.Sh NAME +.Nm gethostname , +.Nm sethostname +.Nd get/set name of current host +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn gethostname "char *name" "int namelen" +.Ft int +.Fn sethostname "const char *name" "int namelen" +.Sh DESCRIPTION +.Fn Gethostname +returns the standard host name for the current processor, as +previously set by +.Fn sethostname . +The parameter +.Fa namelen +specifies the size of the +.Fa name +array. The returned name is null-terminated unless insufficient +space is provided. +.Pp +.Fn Sethostname +sets the name of the host machine to be +.Fa name , +which has length +.Fa namelen . +This call is restricted to the super-user and +is normally used only when the system is bootstrapped. +.Sh RETURN VALUES +If the call succeeds a value of 0 is returned. If the call +fails, a value of -1 is returned and an error code is +placed in the global location +.Va errno . +.Sh ERRORS +The following errors may be returned by these calls: +.Bl -tag -width Er +.It Bq Er EFAULT +The +.Fa name +or +.Fa namelen +parameter gave an +invalid address. +.It Bq Er EPERM +The caller tried to set the hostname and was not the super-user. +.El +.Sh SEE ALSO +.Xr gethostid 2 +.Sh BUGS +Host names are limited to +.Dv MAXHOSTNAMELEN +(from +.Ao Pa sys/param.h Ac ) +characters, currently 64. +.Sh HISTORY +The +.Nm +function call appeared in +.Bx 4.2 . diff --git a/usr/src/lib/libc/sys/getitimer.2 b/usr/src/lib/libc/sys/getitimer.2 new file mode 100644 index 0000000000..e194ed910a --- /dev/null +++ b/usr/src/lib/libc/sys/getitimer.2 @@ -0,0 +1,166 @@ +.\" Copyright (c) 1983, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)getitimer.2 6.6 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt GETITIMER 2 +.Os BSD 4.2 +.Sh NAME +.Nm getitimer , +.Nm setitimer +.Nd get/set value of interval timer +.Sh SYNOPSIS +.Fd #include +.Fd #define ITIMER_REAL 0 +.Fd #define ITIMER_VIRTUAL 1 +.Fd #define ITIMER_PROF 2 +.Ft int +.Fn getitimer "int which" "struct itimerval *value" +.Ft int +.Fn setitimer "int which" "struct itimerval *value" "struct itimerval *ovalue" +.Sh DESCRIPTION +The system provides each process with three interval timers, +defined in +.Ao Pa sys/time.h Ac . +The +.Fn getitimer +call returns the current value for the timer specified in +.Fa which +in the structure at +.Fa value . +The +.Fn setitimer +call sets a timer to the specified +.Fa value +(returning the previous value of the timer if +.Fa ovalue +is non-nil). +.Pp +A timer value is defined by the +.Fa itimerval +structure: +.Bd -literal -offset indent +struct itimerval { + struct timeval it_interval; /* timer interval */ + struct timeval it_value; /* current value */ +}; +.Ed +.Pp +If +.Fa it_value +is non-zero, it indicates the time to the next timer expiration. +If +.Fa it_interval +is non-zero, it specifies a value to be used in reloading +.Fa it_value +when the timer expires. +Setting +.Fa it_value +to 0 disables a timer. Setting +.Fa it_interval +to 0 causes a timer to be disabled after its next expiration (assuming +.Fa it_value +is non-zero). +.Pp +Time values smaller than the resolution of the +system clock are rounded up to this resolution +(typically 10 milliseconds). +.Pp +The +.Dv ITIMER_REAL +timer decrements in real time. A +.Dv SIGALRM +signal is +delivered when this timer expires. +.Pp +The +.Dv ITIMER_VIRTUAL +timer decrements in process virtual time. +It runs only when the process is executing. A +.Dv SIGVTALRM +signal +is delivered when it expires. +.Pp +The +.Dv ITIMER_PROF +timer decrements both in process virtual time and +when the system is running on behalf of the process. It is designed +to be used by interpreters in statistically profiling the execution +of interpreted programs. +Each time the +.Dv ITIMER_PROF +timer expires, the +.Dv SIGPROF +signal is +delivered. Because this signal may interrupt in-progress +system calls, programs using this timer must be prepared to +restart interrupted system calls. +.Sh NOTES +Three macros for manipulating time values are defined in +.Ao Pa sys/time.h Ac . +.Fa Timerclear +sets a time value to zero, +.Fa timerisset +tests if a time value is non-zero, and +.Fa timercmp +compares two time values (beware that >= and <= do not +work with this macro). +.Sh RETURN VALUES +If the calls succeed, a value of 0 is returned. If an error occurs, +the value -1 is returned, and a more precise error code is placed +in the global variable +.Va errno . +.Sh ERRORS +.Fn Getitimer +and +.Fn setitimer +will fail if: +.Bl -tag -width Er +.It Bq Er EFAULT +The +.Fa value +parameter specified a bad address. +.It Bq Er EINVAL +A +.Fa value +parameter specified a time was too large +to be handled. +.El +.Sh SEE ALSO +.Xr select 2 , +.Xr sigvec 2 , +.Xr gettimeofday 2 +.Sh HISTORY +The +.Nm +function call appeared in +.Bx 4.2 . diff --git a/usr/src/lib/libc/sys/getpagesize.2 b/usr/src/lib/libc/sys/getpagesize.2 new file mode 100644 index 0000000000..824b9ea2b2 --- /dev/null +++ b/usr/src/lib/libc/sys/getpagesize.2 @@ -0,0 +1,61 @@ +.\" Copyright (c) 1983, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)getpagesize.2 6.4 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt GETPAGESIZE 2 +.Os BSD 4.2 +.Sh NAME +.Nm getpagesize +.Nd get system page size +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn getpagesize void +.Sh DESCRIPTION +.Fn Getpagesize +returns the number of bytes in a page. +Page granularity is the granularity of many of the memory +management calls. +.Pp +The page size is a +.Xr system +page size and may not be the same as the underlying +hardware page size. +.Sh SEE ALSO +.Xr sbrk 2 , +.Xr pagesize 1 +.Sh HISTORY +The +.Nm +function call appeared in +.Bx 4.2 . diff --git a/usr/src/lib/libc/sys/getpeername.2 b/usr/src/lib/libc/sys/getpeername.2 new file mode 100644 index 0000000000..c7b036adab --- /dev/null +++ b/usr/src/lib/libc/sys/getpeername.2 @@ -0,0 +1,89 @@ +.\" Copyright (c) 1983, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)getpeername.2 6.5 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt GETPEERNAME 2 +.Os BSD 4.2 +.Sh NAME +.Nm getpeername +.Nd get name of connected peer +.Sh SYNOPSIS +.Ft int +.Fn getpeername "int s" "struct sockaddr *name" "int *namelen" +.Sh DESCRIPTION +.Fn Getpeername +returns the name of the peer connected to +socket +.Fa s . +The +.Fa namelen +parameter should be initialized to indicate +the amount of space pointed to by +.Fa name . +On return it contains the actual size of the name +returned (in bytes). +The name is truncated if the buffer provided is too small. +.Sh DIAGNOSTICS +A 0 is returned if the call succeeds, -1 if it fails. +.Sh ERRORS +The call succeeds unless: +.Bl -tag -width ENOTSOCKAA +.It Bq Er EBADF +The argument +.Fa s +is not a valid descriptor. +.It Bq Er ENOTSOCK +The argument +.Fa s +is a file, not a socket. +.It Bq Er ENOTCONN +The socket is not connected. +.It Bq Er ENOBUFS +Insufficient resources were available in the system +to perform the operation. +.It Bq Er EFAULT +The +.Fa name +parameter points to memory not in a valid part of the +process address space. +.El +.Sh SEE ALSO +.Xr accept 2 , +.Xr bind 2 , +.Xr socket 2 , +.Xr getsockname 2 +.Sh HISTORY +The +.Nm +function call appeared in +.Bx 4.2 . diff --git a/usr/src/lib/libc/sys/getpgrp.2 b/usr/src/lib/libc/sys/getpgrp.2 new file mode 100644 index 0000000000..fe04ee2a83 --- /dev/null +++ b/usr/src/lib/libc/sys/getpgrp.2 @@ -0,0 +1,77 @@ +.\" Copyright (c) 1983, 1991 Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)getpgrp.2 6.4 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt GETPGRP 2 +.Os BSD 4.2 +.Sh NAME +.Nm getpgrp +.Nd get process group +.Sh SYNOPSIS +.Ft pid_t +.Fn getpgrp "int pid" +.Sh DESCRIPTION +The process group of the specified process is returned by +.Fn getpgrp . +If +.Fa pid +is zero, the call applies to the current process. +.Pp +Process groups are used for distribution of signals, and +by terminals to arbitrate requests for their input: processes +that have the same process group as the terminal are foreground +and may read, while others will block with a signal if they attempt +to read. +.Pp +This call is thus used by programs such as +.Xr csh 1 +to create +process groups +in implementing job control. +The +.Dv TIOCGPGRP +and +.Dv TIOCSPGRP +calls +described in +.Xr termios 4 +are used to get/set the process group of the control terminal. +.Sh SEE ALSO +.Xr setpgrp 2 , +.Xr getuid 2 , +.Xr termios 4 +.Sh HISTORY +The +.Nm +function call appeared in +.Bx 4.0 . diff --git a/usr/src/lib/libc/sys/getpid.2 b/usr/src/lib/libc/sys/getpid.2 new file mode 100644 index 0000000000..7d4ad17abf --- /dev/null +++ b/usr/src/lib/libc/sys/getpid.2 @@ -0,0 +1,72 @@ +.\" Copyright (c) 1980, 1991 Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)getpid.2 6.4 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt GETPID 2 +.Os BSD 4 +.Sh NAME +.Nm getpid , +.Nm getppid +.Nd get parent or calling process identification +.Sh SYNOPSIS +.Fd #include +.Ft pid_t +.Fn getpid void +.Ft pid_t +.Fn getppid void +.Sh DESCRIPTION +.Fn Getpid +returns +the process ID of +the calling process. +The ID is guaranteed to be unique and is +useful for constructing temporary file names. +.Pp +.Fn Getppid +returns the process ID of the parent +of the calling process. +.Sh ERRORS +The +.Fn getpid +and +.Fn getppid +functions are always successful, and no return value is reserved to +indicate an error. +.Sh SEE ALSO +.Xr gethostid 2 +.Sh STANDARDS +.Fn Getpid +and +.Fn getppid +conform to IEEE Std 1003.1-1988 +.Pq Dq Tn POSIX . diff --git a/usr/src/lib/libc/sys/getpriority.2 b/usr/src/lib/libc/sys/getpriority.2 new file mode 100644 index 0000000000..6369800c63 --- /dev/null +++ b/usr/src/lib/libc/sys/getpriority.2 @@ -0,0 +1,142 @@ +.\" Copyright (c) 1980, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)getpriority.2 6.9 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt GETPRIORITY 2 +.Os BSD 4 +.Sh NAME +.Nm getpriority , +.Nm setpriority +.Nd get/set program scheduling priority +.Sh SYNOPSIS +.Fd #include +.Fd #include +.Ft int +.Fn getpriority "int which" "int who" +.Ft int +.Fn setpriority "int which" "int who" "int prio" +.Sh DESCRIPTION +The scheduling +priority of the process, process group, or user, as indicated by +.Fa which +and +.Fa who +is obtained with the +.Fn getpriority +call and set with the +.Fn setpriority +call. +.Fa Which +is one of +.Dv PRIO_PROCESS , +.Dv PRIO_PGRP , +or +.Dv PRIO_USER , +and +.Fa who +is interpreted relative to +.Fa which +(a process identifier for +.Dv PRIO_PROCESS , +process group +identifier for +.Dv PRIO_PGRP , +and a user ID for +.Dv PRIO_USER ) . +A zero value of +.Fa who +denotes the current process, process group, or user. +.Fa Prio +is a value in the range -20 to 20. The default priority is 0; +lower priorities cause more favorable scheduling. +.Pp +The +.Fn getpriority +call returns the highest priority (lowest numerical value) +enjoyed by any of the specified processes. The +.Fn setpriority +call sets the priorities of all of the specified processes +to the specified value. Only the super-user may lower priorities. +.Sh RETURN VALUES +Since +.Fn getpriority +can legitimately return the value -1, it is necessary +to clear the external variable +.Va errno +prior to the +call, then check it afterward to determine +if a -1 is an error or a legitimate value. +The +.Fn setpriority +call returns 0 if there is no error, or +-1 if there is. +.Sh ERRORS +.Fn Getpriority +and +.Fn setpriority +will fail if: +.Bl -tag -width Er +.It Bq Er ESRCH +No process was located using the +.Fa which +and +.Fa who +values specified. +.It Bq Er EINVAL +.Fa Which +was not one of +.Dv PRIO_PROCESS , +.Dv PRIO_PGRP , +or +.Dv PRIO_USER . +.El +.Pp +.Bl -tag -width Er +In addition to the errors indicated above, +.Fn setpriority +will fail if: +.It Bq Er EPERM +A process was located, but neither its effective nor real user +ID matched the effective user ID of the caller. +.It Bq Er EACCES +A non super-user attempted to lower a process priority. +.El +.Sh SEE ALSO +.Xr nice 1 , +.Xr fork 2 , +.Xr renice 8 +.Sh HISTORY +The +.Nm +function call appeared in +.Bx 4.2 . diff --git a/usr/src/lib/libc/sys/getrlimit.2 b/usr/src/lib/libc/sys/getrlimit.2 new file mode 100644 index 0000000000..75fd6cd3c3 --- /dev/null +++ b/usr/src/lib/libc/sys/getrlimit.2 @@ -0,0 +1,181 @@ +.\" Copyright (c) 1980, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)getrlimit.2 6.7 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt GETRLIMIT 2 +.Os BSD 4 +.Sh NAME +.Nm getrlimit , +.Nm setrlimit +.Nd control maximum system resource consumption +.Sh SYNOPSIS +.Fd #include +.Fd #include +.Ft int +.Fn getrlimit "int resource" "struct rlimit *rlp" +.Ft int +.Fn setrlimit "int resource" "struct rlimit *rlp" +.Sh DESCRIPTION +Limits on the consumption of system resources by the current process +and each process it creates may be obtained with the +.Fn getrlimit +call, and set with the +.Fn setrlimit +call. +.Pp +The +.Fa resource +parameter is one of the following: +.Bl -tag -width RLIMIT_FSIZEAA +.It Dv RLIMIT_CPU +the maximum amount of cpu time (in seconds) to be used by +each process. +.It Dv RLIMIT_FSIZE +the largest size, in bytes, of any single file that may be created. +.It Dv RLIMIT_DATA +the maximum size, in bytes, of the data segment for a process; +this defines how far a program may extend its break with the +.Xr sbrk 2 +system call. +.It Dv RLIMIT_STACK +the maximum size, in bytes, of the stack segment for a process; +this defines how far a program's stack segment may be extended. +Stack extension is performed automatically by the system. +.It Dv RLIMIT_CORE +the largest size, in bytes, of a +.Xr core +file that may be created. +.It Dv RLIMIT_RSS +the maximum size, in bytes, to which a process's resident set size may +grow. This imposes a limit on the amount of physical memory +to be given to a process; if memory is tight, the system will +prefer to take memory from processes that are exceeding their +declared resident set size. +.El +.Pp +A resource limit is specified as a soft limit and a hard limit. When a +soft limit is exceeded a process may receive a signal (for example, if +the cpu time or file size is exceeded), but it will be allowed to +continue execution until it reaches the hard limit (or modifies +its resource limit). The +.Em rlimit +structure is used to specify the hard and soft limits on a resource, +.Bd -literal -offset indent +struct rlimit { + int rlim_cur; /* current (soft) limit */ + int rlim_max; /* hard limit */ +}; +.Ed +.Pp +Only the super-user may raise the maximum limits. Other users +may only alter +.Fa rlim_cur +within the range from 0 to +.Fa rlim_max +or (irreversibly) lower +.Fa rlim_max . +.Pp +An +.Dq infinite +value for a limit is defined as +.Dv RLIM_INFINITY +(0x7\&f\&f\&f\&f\&f\&f\&f). +.Pp +Because this information is stored in the per-process information, +this system call must be executed directly by the shell if it +is to affect all future processes created by the shell; +.Ic limit +is thus a built-in command to +.Xr csh 1 . +.Pp +The system refuses to extend the data or stack space when the limits +would be exceeded in the normal way: a +.Xr break +call fails if the data space limit is reached. +When the stack limit is reached, the process receives +a segmentation fault +.Pq Dv SIGSEGV ; +if this signal is not +caught by a handler using the signal stack, this signal +will kill the process. +.Pp +A file I/O operation that would create a file larger that the process' +soft limit will cause the write to fail and a signal +.Dv SIGXFSZ +to be +generated; this normally terminates the process, but may be caught. When +the soft cpu time limit is exceeded, a signal +.Dv SIGXCPU +is sent to the +offending process. +.Sh RETURN VALUES +A 0 return value indicates that the call succeeded, changing +or returning the resource limit. A return value of -1 indicates +that an error occurred, and an error code is stored in the global +location +.Va errno . +.Sh ERRORS +.Fn Getrlimit +and +.Fn setrlimit +will fail if: +.Bl -tag -width Er +.It Bq Er EFAULT +The address specified for +.Fa rlp +is invalid. +.It Bq Er EPERM +The limit specified to +.Fn setrlimit +would have +raised the maximum limit value, and the caller is not the super-user. +.El +.Sh SEE ALSO +.Xr csh 1 , +.Xr quota 2 , +.Xr sigvec 2 , +.Xr sigstack 2 +.Sh BUGS +There should be +.Ic limit +and +.Ic unlimit +commands in +.Xr sh 1 +as well as in +.Xr csh . +.Sh HISTORY +The +.Nm +function call appeared in +.Bx 4.2 . diff --git a/usr/src/lib/libc/sys/getrusage.2 b/usr/src/lib/libc/sys/getrusage.2 new file mode 100644 index 0000000000..7b917ed44c --- /dev/null +++ b/usr/src/lib/libc/sys/getrusage.2 @@ -0,0 +1,164 @@ +.\" Copyright (c) 1985, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)getrusage.2 6.9 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt GETRUSAGE 2 +.Os BSD 4 +.Sh NAME +.Nm getrusage +.Nd get information about resource utilization +.Sh SYNOPSIS +.Fd #include +.Fd #include +.Fd #define RUSAGE_SELF 0 +.Fd #define RUSAGE_CHILDREN -1 +.Ft int +.Fn getrusage "int who" "struct rusage *rusage" +.Sh DESCRIPTION +.Fn Getrusage +returns information describing the resources utilized by the current +process, or all its terminated child processes. +The +.Fa who +parameter is either +.Dv RUSAGE_SELF +or +.Dv RUSAGE_CHILDREN . +The buffer to which +.Fa rusage +points will be filled in with +the following structure: +.Bd -literal +struct rusage { + struct timeval ru_utime; /* user time used */ + struct timeval ru_stime; /* system time used */ + long ru_maxrss; /* integral max resident set size */ + long ru_ixrss; /* integral shared text memory size */ + long ru_idrss; /* integral unshared data size */ + long ru_isrss; /* integral unshared stack size */ + long ru_minflt; /* page reclaims */ + long ru_majflt; /* page faults */ + long ru_nswap; /* swaps */ + long ru_inblock; /* block input operations */ + long ru_oublock; /* block output operations */ + long ru_msgsnd; /* messages sent */ + long ru_msgrcv; /* messages received */ + long ru_nsignals; /* signals received */ + long ru_nvcsw; /* voluntary context switches */ + long ru_nivcsw; /* involuntary context switches */ +}; +.Ed +.Pp +The fields are interpreted as follows: +.Bl -tag -width ru_minfltaa +.It Fa ru_utime +the total amount of time spent executing in user mode. +.It Fa ru_stime +the total amount of time spent in the system executing on behalf +of the process(es). +.It Fa ru_maxrss +the maximum resident set size utilized (in kilobytes). +.It Fa ru_ixrss +an \*(lqintegral\*(rq value indicating the amount of memory used +by the text segment +that was also shared among other processes. This value is expressed +in units of kilobytes * ticks-of-execution. +.It Fa ru_idrss +an integral value of the amount of unshared memory residing in the +data segment of a process (expressed in units of +kilobytes * ticks-of-execution). +.It Fa ru_isrss +an integral value of the amount of unshared memory residing in the +stack segment of a process (expressed in units of +kilobytes * ticks-of-execution). +.It Fa ru_minflt +the number of page faults serviced without any I/O activity; here +I/O activity is avoided by \*(lqreclaiming\*(rq a page frame from +the list of pages awaiting reallocation. +.It Fa ru_majflt +the number of page faults serviced that required I/O activity. +.It Fa ru_nswap +the number of times a process was \*(lqswapped\*(rq out of main +memory. +.It Fa ru_inblock +the number of times the file system had to perform input. +.It Fa ru_oublock +the number of times the file system had to perform output. +.It Fa ru_msgsnd +the number of IPC messages sent. +.It Fa ru_msgrcv +the number of IPC messages received. +.It Fa ru_nsignals +the number of signals delivered. +.It Fa ru_nvcsw +the number of times a context switch resulted due to a process +voluntarily giving up the processor before its time slice was +completed (usually to await availability of a resource). +.It Fa ru_nivcsw +the number of times a context switch resulted due to a higher +priority process becoming runnable or because the current process +exceeded its time slice. +.El +.Sh NOTES +The numbers +.Fa ru_inblock +and +.Fa ru_oublock +account only for real +I/O; data supplied by the caching mechanism is charged only +to the first process to read or write the data. +.Sh ERRORS +.Fn Getrusage +returns -1 on error. +The possible errors are: +.Bl -tag -width Er +.It Bq Er EINVAL +The +.Fa who +parameter is not a valid value. +.It Bq Er EFAULT +The address specified by the +.Fa rusage +parameter is not in a valid part of the process address space. +.El +.Sh SEE ALSO +.Xr gettimeofday 2 , +.Xr wait 2 +.Sh BUGS +There is no way to obtain information about a child process +that has not yet terminated. +.Sh HISTORY +The +.Nm +function call appeared in +.Bx 4.2 . diff --git a/usr/src/lib/libc/sys/getsockname.2 b/usr/src/lib/libc/sys/getsockname.2 new file mode 100644 index 0000000000..12a7ec8600 --- /dev/null +++ b/usr/src/lib/libc/sys/getsockname.2 @@ -0,0 +1,87 @@ +.\" Copyright (c) 1983, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)getsockname.2 6.4 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt GETSOCKNAME 2 +.Os BSD 4.2 +.Sh NAME +.Nm getsockname +.Nd get socket name +.Sh SYNOPSIS +.Ft int +.Fn getsockname "int s" "struct sockaddr *name" "int *namelen" +.Sh DESCRIPTION +.Fn Getsockname +returns the current +.Fa name +for the specified socket. The +.Fa namelen +parameter should be initialized to indicate +the amount of space pointed to by +.Fa name . +On return it contains the actual size of the name +returned (in bytes). +.Sh DIAGNOSTICS +A 0 is returned if the call succeeds, -1 if it fails. +.Sh ERRORS +The call succeeds unless: +.Bl -tag -width ENOTSOCKAA +.It Bq Er EBADF +The argument +.Fa s +is not a valid descriptor. +.It Bq Er ENOTSOCK +The argument +.Fa s +is a file, not a socket. +.It Bq Er ENOBUFS +Insufficient resources were available in the system +to perform the operation. +.It Bq Er EFAULT +The +.Fa name +parameter points to memory not in a valid part of the +process address space. +.El +.Sh SEE ALSO +.Xr bind 2 , +.Xr socket 2 +.Sh BUGS +Names bound to sockets in the UNIX domain are inaccessible; +.Xr getsockname +returns a zero length name. +.Sh HISTORY +The +.Nm +function call appeared in +.Bx 4.2 . diff --git a/usr/src/lib/libc/sys/gettimeofday.2 b/usr/src/lib/libc/sys/gettimeofday.2 new file mode 100644 index 0000000000..3588f06af6 --- /dev/null +++ b/usr/src/lib/libc/sys/gettimeofday.2 @@ -0,0 +1,119 @@ +.\" Copyright (c) 1980, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)gettimeofday.2 6.11 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt GETTIMEOFDAY 2 +.Os BSD 4 +.Sh NAME +.Nm gettimeofday , +.Nm settimeofday +.Nd get/set date and time +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn gettimeofday "struct timeval *tp" "struct timezone *tzp" +.Ft int +.Fn settimeofday "struct timeval *tp" "struct timezone *tzp" +.Sh DESCRIPTION +.Bf -symbolic +Note: timezone is no longer used; this information is kept outside +the kernel. +.Ef +The system's notion of the current Greenwich time and the current time +zone is obtained with the +.Fn gettimeofday +call, and set with the +.Fn settimeofday +call. The time is expressed in seconds and microseconds +since midnight (0 hour), January 1, 1970. The resolution of the system +clock is hardware dependent, and the time may be updated continuously or +in ``ticks.'' If +.Fa tp +or +.Fa tzp +is NULL, the associated time +information will not be returned or set. +.Pp +The structures pointed to by +.Fa tp +and +.Fa tzp +are defined in +.Ao Pa sys/time.h Ac +as: +.Pp +.Bd -literal +struct timeval { + long tv_sec; /* seconds since Jan. 1, 1970 */ + long tv_usec; /* and microseconds */ +}; + +struct timezone { + int tz_minuteswest; /* of Greenwich */ + int tz_dsttime; /* type of dst correction to apply */ +}; +.Ed +.Pp +The +.Fa timezone +structure indicates the local time zone +(measured in minutes of time westward from Greenwich), +and a flag that, if nonzero, indicates that +Daylight Saving time applies locally during +the appropriate part of the year. +.Pp +Only the super-user may set the time of day or time zone. +.Sh RETURN +A 0 return value indicates that the call succeeded. +A -1 return value indicates an error occurred, and in this +case an error code is stored into the global variable +.Va errno . +.Sh ERRORS +The following error codes may be set in +.Va errno : +.Bl -tag -width [EFAULT] +.It Bq Er EFAULT +An argument address referenced invalid memory. +.It Bq Er EPERM +A user other than the super-user attempted to set the time. +.El +.Sh SEE ALSO +.Xr date 1 , +.Xr adjtime 2 , +.Xr ctime 3 , +.Xr timed 8 +.Sh HISTORY +The +.Nm +function call appeared in +.Bx 4.2 . diff --git a/usr/src/lib/libc/sys/getuid.2 b/usr/src/lib/libc/sys/getuid.2 new file mode 100644 index 0000000000..83045810de --- /dev/null +++ b/usr/src/lib/libc/sys/getuid.2 @@ -0,0 +1,80 @@ +.\" Copyright (c) 1980, 1991 Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)getuid.2 6.4 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt GETUID 2 +.Os BSD 4 +.Sh NAME +.Nm getuid , +.Nm geteuid +.Nd get user identification +.Sh SYNOPSIS +.Fd #include +.Fd #include +.Ft uid_t +.Fn getuid void +.Ft uid_t +.Fn geteuid void +.Sh DESCRIPTION +The +.Fn getuid +function returns the real user ID of the calling process. +The +.Fn geteuid +function +returns the effective user ID of the calling process. +.Pp +The real user ID is that of the user who has invoked the program. +As the effective user ID +gives the process additional permissions during +execution of +.Dq Em set-user-ID +mode processes, +.Fn getuid +is used to determine the real-user-id of the calling process. +.Sh ERRORS +The +.Fn getuid +and +.Fn geteuid +functions are always successful, and no return value is reserved to +indicate an error. +.Sh SEE ALSO +.Xr getgid 2 , +.Xr setreuid 2 +.Sh STANDARDS +.Fn Geteuid +and +.Fn getuid +conform to IEEE Std 1003.1-1988 +.Pq Dq Tn POSIX . diff --git a/usr/src/lib/libc/sys/ioctl.2 b/usr/src/lib/libc/sys/ioctl.2 new file mode 100644 index 0000000000..a90d0b8e93 --- /dev/null +++ b/usr/src/lib/libc/sys/ioctl.2 @@ -0,0 +1,106 @@ +.\" Copyright (c) 1980, 1991 Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)ioctl.2 6.4 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt IOCTL 2 +.Os BSD 4 +.Sh NAME +.Nm ioctl +.Nd control device +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn ioctl "int d" "unsigned long request" "char *argp" +.Sh DESCRIPTION +The +.Fn ioctl +function manipulates the underlying device parameters of special files. +In particular, many operating +characteristics of character special files (e.g. terminals) +may be controlled with +.Fn ioctl +requests. +The argument +.Fa d +must be an open file descriptor. +.Pp +An ioctl +.Fa request +has encoded in it whether the argument is an +.Dq in +parameter +or +.Dq out +parameter, and the size of the argument +.Fa argp +in bytes. +Macros and defines used in specifying an ioctl +.Fa request +are located in the file +.Ao Pa sys/ioctl.h Ac . +.Sh RETURN VALUES +If an error has occurred, a value of -1 is returned and +.Va errno +is set to indicate the error. +.Sh ERRORS +.Fn Ioctl +will fail: +.Bl -tag -width [ENOTTY] +.It Bq Er EBADF +.Fa d +is not a valid descriptor. +.It Bq Er ENOTTY +.Fa d +is not associated with a character +special device. +.It Bq Er ENOTTY +The specified request does not apply to the kind +of object that the descriptor +.Fa d +references. +.It Bq Er EINVAL +.Fa Request +or +.Fa argp +is not valid. +.El +.Sh SEE ALSO +.Xr execve 2 , +.Xr fcntl 2 , +.Xr mt 4 , +.Xr tty 4 , +.Xr intro 4 +.Sh HISTORY +An +.Nm +function call appeared in Version 7 AT&T UNIX. diff --git a/usr/src/lib/libc/sys/kill.2 b/usr/src/lib/libc/sys/kill.2 new file mode 100644 index 0000000000..bdb553d96e --- /dev/null +++ b/usr/src/lib/libc/sys/kill.2 @@ -0,0 +1,131 @@ +.\" Copyright (c) 1980, 1991 Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)kill.2 6.6 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt KILL 2 +.Os BSD 4 +.Sh NAME +.Nm kill +.Nd send signal to a process +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn kill "pid_t pid" "int sig" +.Sh DESCRIPTION +The +.Fn kill +function sends the signal given by +.Fa sig +to +.Fa pid , +a +process or a group of processes. +.Fa Sig +may be one of the signals specified in +.Xr sigaction 2 +or it may be 0, in which case +error checking is performed but no +signal is actually sent. +This can be used to check the validity of +.Fa pid . +.Pp +For a process to have permission to send a signal to a process designated +by +.Fa pid , +the real or effective user ID of the receving process must match +that of the sending process or the user must have appropriate privileges +(such as given by a set-user-ID program or the user is the super-user). +A single exception is the signal SIGCONT, which may always be sent +to any descendant of the current process. +.Bl -tag -width Ds +.It \&If Fa pid No \&is greater than zero : +.Fa Sig +is sent to the process whose ID is equal to +.Fa pid. +.It \&If Fa pid No \&is zero : +.Fa Sig +is sent to all processes whose group ID is equal +to the process group ID of the sender, and for which the +process has permission; +this is a variant of +.Xr killpg 2 . +.It \&If Fa pid No \&is -1 : +If the user has super user privileges, +the signal is sent to all processes excluding +system processes. If the user is not the super user, +the signal is sent to all processes with the same uid as the user +except the process sending the signal. +No error is returned if any process could be signaled. +.El +.Pp +For compatibility with System V, +if the process number is negative but not -1, +the signal is sent to all processes whose process group ID +is equal to the absolute value of the process number. +This is a variant of +.Xr killpg 2 . +.Sh RETURN VALUES +Upon successful completion, a value of 0 is returned. +Otherwise, a value of -1 is returned and +.Va errno +is set to indicate the error. +.Sh ERRORS +.Fn Kill +will fail and no signal will be sent if: +.Bl -tag -width [EINVAL] +.It Bq Er EINVAL +.Fa Sig +is not a valid signal number. +.It Bq Er ESRCH +No process can be found corresponding to that specified by +.Fa pid . +.It Bq Er ESRCH +The process id was given as 0 +but the sending process does not have a process group. +.It Bq Er EPERM +The sending process is not the super-user and its effective +user id does not match the effective user-id of the receiving process. +When signaling a process group, this error is returned if any members +of the group could not be signaled. +.El +.Sh SEE ALSO +.Xr getpid 2 , +.Xr getpgrp 2 , +.Xr killpg 2 , +.Xr sigaction 2 +.Sh STANDARDS +The +.Fn kill +function is expected to +conform to IEEE Std 1003.1-1988 +.Pq Dq Tn POSIX . diff --git a/usr/src/lib/libc/sys/link.2 b/usr/src/lib/libc/sys/link.2 new file mode 100644 index 0000000000..5b6a03de31 --- /dev/null +++ b/usr/src/lib/libc/sys/link.2 @@ -0,0 +1,151 @@ +.\" Copyright (c) 1980, 1991 Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)link.2 6.4 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt LINK 2 +.Os BSD 4 +.Sh NAME +.Nm link +.Nd make a hard file link +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn link "const char *name1" "const char *name2" +.Sh DESCRIPTION +The +.Fn link +function call +atomically creates the specified directory entry (hard link) +.Fa name2 +with the attributes of the underlying object pointed at by +.Fa name1 +If the link is successful: the link count of the underlying object +is incremented; +.Fa name1 +and +.Fa name2 +share equal access and rights +to the +underlying object. +.Pp +If +.Fa name1 +is removed, the file +.Fa name2 +is not deleted and the link count of the +underlying object is +decremented. +.Pp +.Fa Name1 +must exist for the hard link to +succeed and +both +.Fa name1 +and +.Fa name2 +must be in the same file system. +Unless the caller is the super-user, +.Fa name1 +may not be a directory. +.Sh RETURN VALUES +Upon successful completion, a value of 0 is returned. Otherwise, +a value of -1 is returned and +.Va errno +is set to indicate the error. +.Sh ERRORS +.Fn Link +will fail and no link will be created if: +are true: +.Bl -tag -width Ar +.It Bq Er ENOTDIR +A component of either path prefix is not a directory. +.It Bq Er EINVAL +Either pathname contains a character with the high-order bit set. +.It Bq Er ENAMETOOLONG +A component of either pathname exceeded 255 characters, +or entire length of either path name exceeded 1023 characters. +.It Bq Er ENOENT +A component of either path prefix does not exist. +.It Bq Er EACCES +A component of either path prefix denies search permission. +.It Bq Er EACCES +The requested link requires writing in a directory with a mode +that denies write permission. +.It Bq Er ELOOP +Too many symbolic links were encountered in translating one of the pathnames. +.It Bq Er ENOENT +The file named by +.Fa name1 +does not exist. +.It Bq Er EEXIST +The link named by +.Fa name2 +does exist. +.It Bq Er EPERM +The file named by +.Fa name1 +is a directory and the effective +user ID is not super-user. +.It Bq Er EXDEV +The link named by +.Fa name2 +and the file named by +.Fa name1 +are on different file systems. +.It Bq Er ENOSPC +The directory in which the entry for the new link is being placed +cannot be extended because there is no space left on the file +system containing the directory. +.It Bq Er EDQUOT +The directory in which the entry for the new link +is being placed cannot be extended because the +user's quota of disk blocks on the file system +containing the directory has been exhausted. +.It Bq Er EIO +An I/O error occurred while reading from or writing to +the file system to make the directory entry. +.It Bq Er EROFS +The requested link requires writing in a directory on a read-only file +system. +.It Bq Er EFAULT +One of the pathnames specified +is outside the process's allocated address space. +.El +.Sh SEE ALSO +.Xr symlink 2 , +.Xr unlink 2 +.Sh STANDARDS +.Fn Link +is expected to +conform to IEEE Std 1003.1-1988 +.Pq Dq Tn POSIX . diff --git a/usr/src/lib/libc/sys/listen.2 b/usr/src/lib/libc/sys/listen.2 new file mode 100644 index 0000000000..dd126b4b96 --- /dev/null +++ b/usr/src/lib/libc/sys/listen.2 @@ -0,0 +1,100 @@ +.\" Copyright (c) 1983, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)listen.2 6.5 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt LISTEN 2 +.Os BSD 4.2 +.Sh NAME +.Nm listen +.Nd listen for connections on a socket +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn listen "int s" "int backlog" +.Sh DESCRIPTION +To accept connections, a socket +is first created with +.Xr socket 2 , +a willingness to accept incoming connections and +a queue limit for incoming connections are specified with +.Fn listen , +and then the connections are +accepted with +.Xr accept 2 . +The +.Fn listen +call applies only to sockets of type +.Dv SOCK_STREAM +or +.Dv SOCK_SEQPACKET. +.Pp +The +.Fa backlog +parameter defines the maximum length the queue of +pending connections may grow to. +If a connection +request arrives with the queue full the client may +receive an error with an indication of +.Er ECONNREFUSED , +or, if the underlying protocol supports retransmission, +the request may be ignored so that retries may succeed. +.Sh RETURN VALUES +A 0 return value indicates success; -1 indicates an error. +.Sh ERRORS +.Fn Listen will fail if: +.Bl -tag -width [EOPNOTSUPP] +.It Bq Er EBADF +The argument +.Fa s +is not a valid descriptor. +.It Bq Er ENOTSOCK +The argument +.Fa s +is not a socket. +.It Bq Er EOPNOTSUPP +The socket is not of a type that supports the operation +.Fn listen . +.El +.Sh SEE ALSO +.Xr accept 2 , +.Xr connect 2 , +.Xr socket 2 +.Sh BUGS +The +.Fa backlog +is currently limited (silently) to 5. +.Sh HISTORY +The +.Nm +function call appeared in +.Bx 4.2 . diff --git a/usr/src/lib/libc/sys/lseek.2 b/usr/src/lib/libc/sys/lseek.2 new file mode 100644 index 0000000000..f6d8e88425 --- /dev/null +++ b/usr/src/lib/libc/sys/lseek.2 @@ -0,0 +1,135 @@ +.\" Copyright (c) 1980, 1991 Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)lseek.2 6.5 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt LSEEK 2 +.Os BSD 4 +.Sh NAME +.Nm lseek +.Nd reposition read/write file offset +.Sh SYNOPSIS +.Fd #include +.Ft off_t +.Fn lseek "int fildes" "off_t offset" "int whence" +.Sh DESCRIPTION +The +.Fn lseek +function repositions the offset of the file descriptor +.Fa fildes +to the +argument +.Fa offset +according to the directive +.Fa whence. +The argument +.Fa fildes +must be an open +file descriptor. +.Fn Lseek +repositions the file pointer +.Fa fildes +as follows: +.Bl -item -offset indent +.It +If +.Fa whence +is +.Dv SEEK_SET , +the offset is set to +.Fa offset +bytes. +.It +If +.Fa whence +is +.Dv SEEK_CUR , +the offset is set to its current location plus +.Fa offset +bytes. +.It +If +.Fa whence +is +.Dv SEEK_END , +the offset is set to the size of the +file plus +.Fa offset +bytes. +.El +.Pp +The +.Fn lseek +function allows the file offset to be set beyond the end +of the existing end-of-file of the file. If data is later written +at this point, subsequent reads of the data in the gap return +bytes of zeros (until data is actualy written into the gap). +.Pp +Some devices are incapable of seeking. The value of the pointer +associated with such a device is undefined. +.Sh RETURN VALUES +Upon successful completion, +.Fn lseek +returns the resulting offset location as measured in bytes from the +begining of the file. +Otherwise, +a value of -1 is returned and +.Va errno +is set to indicate +the error. +.Sh ERRORS +.Fn Lseek +will fail and the file pointer will remain unchanged if: +.Bl -tag -width [EINVAL] +.It Bq Er EBADF +.Em Fildes +is not an open file descriptor. +.It Bq Er ESPIPE +.Em Fildes +is associated with a pipe, socket, or FIFO. +.It Bq Er EINVAL +.Fa Whence +is not a proper value. +.El +.Sh SEE ALSO +.Xr dup 2 , +.Xr open 2 +.Sh BUGS +This document's use of +.Fa whence +is incorrect English, but maintained for historical reasons. +.Sh STANDARDS +The +.Fn lseek +function +conforms to IEEE Std 1003.1-1988 +.Pq Dq Tn POSIX . diff --git a/usr/src/lib/libc/sys/mkdir.2 b/usr/src/lib/libc/sys/mkdir.2 new file mode 100644 index 0000000000..fd03ac0224 --- /dev/null +++ b/usr/src/lib/libc/sys/mkdir.2 @@ -0,0 +1,123 @@ +.\" Copyright (c) 1983, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)mkdir.2 6.7 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt MKDIR 2 +.Os BSD 4.2 +.Sh NAME +.Nm mkdir +.Nd make a directory file +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn mkdir "const char *path" "mode_t mode" +.Sh DESCRIPTION +The directory +.Fa path +is created with the access permissions specified by +.Fa mode +and restricted by the the +.Xr umask 2 +of the calling process. +.Pp +The directory's owner ID is set to the process's effective user ID. +The directory's group ID is set to that of the parent directory in +which it is created. +.Sh RETURN VALUES +A 0 return value indicates success. A -1 return value +indicates an error, and an error code is stored in +.Va errno . +.Sh ERRORS +.Fn Mkdir +will fail and no directory will be created if: +.Bl -tag -width ENAMETOOLO +.It Bq Er ENOTDIR +A component of the path prefix is not a directory. +.It Bq Er EINVAL +The pathname contains a character with the high-order bit set. +.It Bq Er ENAMETOOLONG +A component of a pathname exceeded 255 characters, +or an entire path name exceeded 1023 characters. +.It Bq Er ENOENT +A component of the path prefix does not exist. +.It Bq Er EACCES +Search permission is denied for a component of the path prefix. +.It Bq Er ELOOP +Too many symbolic links were encountered in translating the pathname. +.It Bq Er EPERM +The +.Fa path +argument contains a byte with the high-order bit set. +.It Bq Er EROFS +The named file resides on a read-only file system. +.It Bq Er EEXIST +The named file exists. +.It Bq Er ENOSPC +The directory in which the entry for the new directory is being placed +cannot be extended because there is no space left on the file +system containing the directory. +.It Bq Er ENOSPC +The new directory cannot be created because there +there is no space left on the file +system that will contain the directory. +.It Bq Er ENOSPC +There are no free inodes on the file system on which the +directory is being created. +.It Bq Er EDQUOT +The directory in which the entry for the new directory +is being placed cannot be extended because the +user's quota of disk blocks on the file system +containing the directory has been exhausted. +.It Bq Er EDQUOT +The new directory cannot be created because the user's +quota of disk blocks on the file system that will +contain the directory has been exhausted. +.It Bq Er EDQUOT +The user's quota of inodes on the file system on +which the directory is being created has been exhausted. +.It Bq Er EIO +An I/O error occurred while making the directory entry or allocating the inode. +.It Bq Er EIO +An I/O error occurred while reading from or writing to the file system. +.It Bq Er EFAULT +.Fa Path +points outside the process's allocated address space. +.El +.Sh SEE ALSO +.Xr chmod 2 , +.Xr stat 2 , +.Xr umask 2 +.Sh STANDARDS +.Fn Mkdir +conforms to IEEE Std 1003.1-1988 +.Pq Dq Tn POSIX . diff --git a/usr/src/lib/libc/sys/mknod.2 b/usr/src/lib/libc/sys/mknod.2 new file mode 100644 index 0000000000..edd5926863 --- /dev/null +++ b/usr/src/lib/libc/sys/mknod.2 @@ -0,0 +1,127 @@ +.\" Copyright (c) 1980, 1991 Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)mknod.2 6.5 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt MKNOD 2 +.Os BSD 4 +.Sh NAME +.Nm mknod +.Nd make a special file node +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn mknod "const char *path" "mode_t mode" "dev_t dev" +.Sh DESCRIPTION +The device special file +.Fa path +is created with the major and minor +device numbers extracted from +.Fa mode. +The access permissions of +.Fa path +are descendant from the +.Xr umask 2 +of the parent process. +.Pp +If +.Fa mode +indicates a block or character special file, +.Fa dev +is a configuration dependent specification of a character or block +I/O device and the superblock of the device. If +.Fa mode +does not indicate a block special or character special device, +.Fa dev +is ignored. +.Pp +.Fn Mknod +requires super-user privileges. +.Sh RETURN VALUES +Upon successful completion a value of 0 is returned. +Otherwise, a value of -1 is returned and +.Va errno +is set to indicate the error. +.Sh ERRORS +.Fn Mknod +will fail and the file will be not created if: +.Bl -tag -width Er +.It Bq Er ENOTDIR +A component of the path prefix is not a directory. +.It Bq Er EINVAL +The pathname contains a character with the high-order bit set. +.It Bq Er ENAMETOOLONG +A component of a pathname exceeded 255 characters, +or an entire path name exceeded 1023 characters. +.It Bq Er ENOENT +A component of the path prefix does not exist. +.It Bq Er EACCES +Search permission is denied for a component of the path prefix. +.It Bq Er ELOOP +Too many symbolic links were encountered in translating the pathname. +.It Bq Er EPERM +The process's effective user ID is not super-user. +.It Bq Er EPERM +The pathname contains a character with the high-order bit set. +.It Bq Er EIO +An I/O error occurred while making the directory entry or allocating the inode. +.It Bq Er ENOSPC +The directory in which the entry for the new node is being placed +cannot be extended because there is no space left on the file +system containing the directory. +.It Bq Er ENOSPC +There are no free inodes on the file system on which the +node is being created. +.It Bq Er EDQUOT +The directory in which the entry for the new node +is being placed cannot be extended because the +user's quota of disk blocks on the file system +containing the directory has been exhausted. +.It Bq Er EDQUOT +The user's quota of inodes on the file system on +which the node is being created has been exhausted. +.It Bq Er EROFS +The named file resides on a read-only file system. +.It Bq Er EEXIST +The named file exists. +.It Bq Er EFAULT +.Fa Path +points outside the process's allocated address space. +.El +.Sh SEE ALSO +.Xr chmod 2 , +.Xr stat 2 , +.Xr umask 2 +.Sh HISTORY +A +.Nm +function call appeared in Version 6 AT&T UNIX. diff --git a/usr/src/lib/libc/sys/mount.2 b/usr/src/lib/libc/sys/mount.2 new file mode 100644 index 0000000000..d830f5f8b9 --- /dev/null +++ b/usr/src/lib/libc/sys/mount.2 @@ -0,0 +1,317 @@ +.\" Copyright (c) 1980, 1989 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)mount.2 6.12 (Berkeley) 3/15/91 +.\" +.Dd March 15, 1991 +.Dt MOUNT 2 +.Os BSD 4 +.Sh NAME +.Nm mount , +.Nm unmount +.Nd mount or dismount a filesystem +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn mount "int type" "const char *dir" "int flags" "caddr_t data" +.Ft int +.Fn unmount "const char *dir" "int flags" +.Sh DESCRIPTION +The +.Fn mount +function grafts +a filesystem object onto the system file tree +at the point +.Ar dir . +The argument +.Ar data +describes the filesystem object to be mounted. +The argument +.Ar type +tells the kernel how to interpret +.Ar data +(See +.Ar type +below). +The contents of the filesystem +become available through the new mount point +.Ar dir . +Any files in +.Ar dir +at the time +of a successful mount are swept under the carpet so to speak, and +are unavailable until the filesystem is unmounted. +.Pp +The following +.Ar flags +may be specified to +suppress default semantics which affect filesystem access. +.Bl -tag -width M_SYNCHRONOUS +.It Dv M_RDONLY +The file system should be treated as read-only; +Even the super-user may not write on it. +.It Dv M_NOEXEC +Do not allow files to be executed from the file system. +.It Dv M_NOSUID +Do not honor setuid or setgid bits on files when executing them. +.It Dv M_NODEV +Do not interpret special files on the file system. +.It Dv M_SYNCHRONOUS +All I/O to the file system should be done synchronously. +.El +.Pp +The flag +.Dv M_UPDATE +indicates that the mount command is being applied +to an already mounted file system. +This allows the mount flags to be changed without requiring +that the file system be unmounted and remounted. +Some file systems may not allow all flags to be changed. +For example, +most file systems will not allow a change from read-write to read-only. +.Pp +The +.Fa type +argument defines the type of the file system. +The types of file systems known to the system are defined in +.Aq Pa sys/mount.h . +.Fa Data +is a pointer to a structure that contains the type +specific arguments to mount. +The currently supported types of file systems and +their type specific data are: +.Pp +.Dv MOUNT_UFS +.Bd -literal -offset indent -compact +struct ufs_args { + char *fspec; /* Block special file to mount */ + int exflags; /* export related flags */ + uid_t exroot; /* mapping for root uid */ +}; +.Ed +.Pp +.Dv MOUNT_NFS +.Bd -literal -offset indent -compact +struct nfs_args { + struct sockaddr_in *addr; /* file server address */ + nfsv2fh_t *fh; /* File handle to be mounted */ + int flags; /* flags */ + int wsize; /* write size in bytes */ + int rsize; /* read size in bytes */ + int timeo; /* initial timeout 0.1 secs */ + int retrans; /* times to retry send */ + char *hostname; /* server's name */ +}; +.Ed +.Pp +.Dv MOUNT_MFS +.Bd -literal -offset indent -compact +struct mfs_args { + char *name; /* name of backing process */ + caddr_t base; /* base address of the file system */ + u_long size; /* size of the file system */ +}; +.Ed +.Pp +The +.Fn umount +function call disassociates the filesystem from the specified +mount point +.Fa dir . +.Pp +The +.Fa flags +argument may have one of the following values: +.Bl -tag -width M_SYNCHRONOUS +.It Dv MNT_NOFORCE +The unmount should fail if any files are active on the file system. +.It Dv MNT_FORCE +The file system should be forcibly unmounted even if files are +still active. +Active special devices continue to work, +but any further accesses to any other active files result in errors +even if the file system is later remounted. +.El +.Sh RETURN VALUES +The +.Fn mount +returns the value 0 if the mount was successful, otherwise -1 is returned +and the variable +.Va errno +is set to indicate the error. +.Pp +.Nm Umount +returns the value 0 if the umount succeeded; otherwise -1 is returned +and the variable +.Va errno +is set to indicate the error. +.Sh ERRORS +.Fn Mount +will fail when one of the following occurs: +.Bl -tag -width [ENOTBLK] +.It Bq Er EPERM +The caller is not the super-user. +.It Bq Er ENAMETOOLONG +A component of a pathname exceeded 255 characters, +or the entire length of a path name exceeded 1023 characters. +.It Bq Er ELOOP +Too many symbolic links were encountered in translating a pathname. +.It Bq Er ENOENT +A component of +.Fa dir +does not exist. +.It Bq Er ENOTDIR +A component of +.Ar name +is not a directory, +or a path prefix of +.Ar special +is not a directory. +.It Bq Er EINVAL +A pathname contains a character with the high-order bit set. +.It Bq Er EBUSY +Another process currently holds a reference to +.Fa dir . +.It Bq Er EFAULT +.Fa Dir +points outside the process's allocated address space. +.El +.Pp +The following errors can occur for a +.Em ufs +file system mount: +.Bl -tag -width [ENOTBLK] +.It Bq Er ENODEV +A component of ufs_args +.Ar fspec +does not exist. +.It Bq Er ENOTBLK +.Ar Fspec +is not a block device. +.It Bq Er ENXIO +The major device number of +.Ar fspec +is out of range (this indicates no device driver exists +for the associated hardware). +.It Bq Er EBUSY +.Ar Fspec +is already mounted. +.It Bq Er EMFILE +No space remains in the mount table. +.It Bq Er EINVAL +The super block for the file system had a bad magic +number or an out of range block size. +.It Bq Er ENOMEM +Not enough memory was available to read the cylinder +group information for the file system. +.It Bq Er EIO +An I/O error occurred while reading the super block or +cylinder group information. +.It Bq Er EFAULT +.Ar Fspec +points outside the process's allocated address space. +.El +.Pp +The following errors can occur for a +.Em nfs +file system mount: +.Bl -tag -width [ENOTBLK] +.It Bq Er ETIMEDOUT +.Em Nfs +timed out trying to contact the server. +.It Bq Er EFAULT +Some part of the information described by nfs_args +points outside the process's allocated address space. +.El +.Pp +The following errors can occur for a +.Em mfs +file system mount: +.Bl -tag -width [ENOTBLK] +.It Bq Er EMFILE +No space remains in the mount table. +.It Bq Er EINVAL +The super block for the file system had a bad magic +number or an out of range block size. +.It Bq Er ENOMEM +Not enough memory was available to read the cylinder +group information for the file system. +.It Bq Er EIO +An paging error occurred while reading the super block or +cylinder group information. +.It Bq Er EFAULT +.Em Name +points outside the process's allocated address space. +.El +.Pp +.Nm Umount +may fail with one of the following errors: +.Bl -tag -width [ENOTBLK] +.It Bq Er EPERM +The caller is not the super-user. +.It Bq Er ENOTDIR +A component of the path is not a directory. +.It Bq Er EINVAL +The pathname contains a character with the high-order bit set. +.It Bq Er ENAMETOOLONG +A component of a pathname exceeded 255 characters, +or an entire path name exceeded 1023 characters. +.It Bq Er ELOOP +Too many symbolic links were encountered in translating the pathname. +.It Bq Er EINVAL +The requested directory is not in the mount table. +.It Bq Er EBUSY +A process is holding a reference to a file located +on the file system. +.It Bq Er EIO +An I/O error occurred while writing cached file system information. +.It Bq Er EFAULT +.Fa Dir +points outside the process's allocated address space. +.El +.Pp +A +.Em ufs +or +.Em mfs +mount can also fail if the maximum number of filesystems are currently +mounted. +.Sh SEE ALSO +.Xr mount 8 , +.Xr umount 8 , +.Xr mfs 8 +.Sh BUGS +Some of the error codes need translation to more obvious messages. +.Sh HISTORY +.Fn Mount +and +.Fn umount +function calls appeared in Version 6 AT&T UNIX. diff --git a/usr/src/lib/libc/sys/pipe.2 b/usr/src/lib/libc/sys/pipe.2 new file mode 100644 index 0000000000..a34cd34ee8 --- /dev/null +++ b/usr/src/lib/libc/sys/pipe.2 @@ -0,0 +1,115 @@ +.\" Copyright (c) 1980, 1991 Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)pipe.2 6.3 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt PIPE 2 +.Os BSD 4 +.Sh NAME +.Nm pipe +.Nd create descriptor pair for interprocess communication +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn pipe "int *fildes" +.Sh DESCRIPTION +The +.Fn pipe +function +creates a +.Em pipe , +which is an object allowing +unidirectional data flow, +and allocates a pair of file descriptors. +The first descriptor connects to the +.Em read end +of the pipe, +and the second connects to the +.Em write end , +so that data written to +.Fa fildes[1] +appears on (i.e., can be read from) +.Fa fildes[0] . +This allows the output of one program to be +sent +to another program: +the source's standard output is set up to be +the write end of the pipe, +and the sink's standard input is set up to be +the read end of the pipe. +The pipe itself persists until all its associated descriptors are +closed. +.Pp +A pipe whose read or write end has been closed is considered +.Em widowed . +Writing on such a pipe causes the writing process to receive +a +.Dv SIGPIPE +signal. +Widowing a pipe is the only way to deliver end-of-file to a reader: +after the reader consumes any buffered data, reading a widowed pipe +returns a zero count. +.Pp +Pipes are really a special case of the +.Xr socketpair 2 +call and, in fact, are implemented as such in the system. +.Sh RETURN VALUES +On successful creation of the pipe, zero is returned. Otherwise, +a value of -1 is returned and the variable +.Va errno +set to indicate the +error. +.Sh ERRORS +The +.Fn pipe +call will fail if: +.Bl -tag -width [EMFILE] +.It Bq Er EMFILE +Too many descriptors are active. +.It Bq Er ENFILE +The system file table is full. +.It Bq Er EFAULT +The +.Fa fildes +buffer is in an invalid area of the process's address +space. +.El +.Sh SEE ALSO +.Xr sh 1 , +.Xr read 2 , +.Xr write 2 , +.Xr fork 2 , +.Xr socketpair 2 +.Sh HISTORY +A +.Nm +function call appeared in Version 6 AT&T UNIX. diff --git a/usr/src/lib/libc/sys/read.2 b/usr/src/lib/libc/sys/read.2 new file mode 100644 index 0000000000..e96a273292 --- /dev/null +++ b/usr/src/lib/libc/sys/read.2 @@ -0,0 +1,188 @@ +.\" Copyright (c) 1980, 1991 Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)read.2 6.7 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt READ 2 +.Os BSD 4 +.Sh NAME +.Nm read , +.Nm readv +.Nd read input +.Sh SYNOPSIS +.Fd #include +.Fd #include +.Fd #include +.Ft ssize_t +.Fn read "int d" "char *buf" "size_t nbytes" +.Ft int +.Fn readv "int d" "struct iovec *iov" "int iovcnt" +.Sh DESCRIPTION +.Fn Read +attempts to read +.Fa nbytes +of data from the object referenced by the descriptor +.Fa d +into the buffer pointed to by +.Fa buf . +.Fn Readv +performs the same action, but scatters the input data +into the +.Fa iovcnt +buffers specified by the members of the +.Fa iov +array: iov[0], iov[1], ..., iov[iovcnt\|\-\|1]. +.Pp +For +.Fn readv , +the +.Fa iovec +structure is defined as +.Bd -literal -offset indent -compact +struct iovec { + caddr_t iov_base; + int iov_len; +}; +.Ed +.Pp +Each +.Fa iovec +entry specifies the base address and length of an area +in memory where data should be placed. +.Fn Readv +will always fill an area completely before proceeding +to the next. +.Pp +On objects capable of seeking, the +.Fn read +starts at a position +given by the pointer associated with +.Fa d +(see +.Xr lseek 2 ) . +Upon return from +.Fn read , +the pointer is incremented by the number of bytes actually read. +.Pp +Objects that are not capable of seeking always read from the current +position. The value of the pointer associated with such an +object is undefined. +.Pp +Upon successful completion, +.Fn read +and +.Fn readv +return the number of bytes actually read and placed in the buffer. +The system guarantees to read the number of bytes requested if +the descriptor references a normal file that has that many bytes left +before the end-of-file, but in no other case. +.Pp +.Sh RETURN VALUES +If successful, the +number of bytes actually read is returned. Upon reading end-of-file, +zero is returned. +Otherwise, a -1 is returned and the global variable +.Va errno +is set to indicate the error. +.Sh ERRORS +.Fn Read +and +.Fn readv +will succeed unless: +.Bl -tag -width Er +.It Bq Er EBADF +.Fa D +is not a valid file or socket descriptor open for reading. +.It Bq Er EFAULT +.Fa Buf +points outside the allocated address space. +.It Bq Er EIO +An I/O error occurred while reading from the file system. +.It Bq Er EINTR +A read from a slow device was interrupted before +any data arrived by the delivery of a signal. +.It Bq Er EINVAL +The pointer associated with +.Fa d +was negative. +.It Bq Er EWOULDBLOCK +The file was marked for non-blocking I/O, +and no data were ready to be read. +.El +.Pp +In addition, +.Fn readv +may return one of the following errors: +.Bl -tag -width Er +.It Bq Er EINVAL +.Fa Iovcnt +was less than or equal to 0, or greater than 16. +.It Bq Er EINVAL +One of the +.Fa iov_len +values in the +.Fa iov +array was negative. +.It Bq Er EINVAL +The sum of the +.Fa iov_len +values in the +.Fa iov +array overflowed a 32-bit integer. +.It Bq Er EFAULT +Part of the +.Fa iov +points outside the process's allocated address space. +.El +.Sh SEE ALSO +.Xr dup 2 , +.Xr fcntl 2 , +.Xr open 2 , +.Xr pipe 2 , +.Xr select 2 , +.Xr socket 2 , +.Xr socketpair 2 +.Sh STANDARDS +.Fn Read +is expected to conform to IEEE Std 1003.1-1988 +.Pq Dq Tn POSIX . +.Sh HISTORY +The +.Fn readv +function call +appeared in +.Bx 4.2 . +A +.Nm read +function call +appeared in +Version 6 AT&T UNIX. diff --git a/usr/src/lib/libc/sys/readlink.2 b/usr/src/lib/libc/sys/readlink.2 new file mode 100644 index 0000000000..09906b656e --- /dev/null +++ b/usr/src/lib/libc/sys/readlink.2 @@ -0,0 +1,95 @@ +.\" Copyright (c) 1983, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)readlink.2 6.8 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt READLINK 2 +.Os BSD 4.2 +.Sh NAME +.Nm readlink +.Nd read value of a symbolic link +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn readlink "const char *path" "char *buf" "int bufsiz" +.Sh DESCRIPTION +.Fn Readlink +places the contents of the symbolic link +.Fa path +in the buffer +.Fa buf , +which has size +.Fa bufsiz . +.Nm Readlink +does not append a +.Dv NUL +character to +.Fa buf . +.Sh RETURN VALUES +The call returns the count of characters placed in the buffer +if it succeeds, or a -1 if an error occurs, placing the error +code in the global variable +.Va errno . +.Sh ERRORS +.Fn Readlink +will fail if: +.Bl -tag -width ENAMETOOLONG +.It Bq Er ENOTDIR +A component of the path prefix is not a directory. +.It Bq Er EINVAL +The pathname contains a character with the high-order bit set. +.It Bq Er ENAMETOOLONG +A component of a pathname exceeded 255 characters, +or an entire path name exceeded 1023 characters. +.It Bq Er ENOENT +The named file does not exist. +.It Bq Er EACCES +Search permission is denied for a component of the path prefix. +.It Bq Er ELOOP +Too many symbolic links were encountered in translating the pathname. +.It Bq Er EINVAL +The named file is not a symbolic link. +.It Bq Er EIO +An I/O error occurred while reading from the file system. +.It Bq Er EFAULT +.Fa Buf +extends outside the process's allocated address space. +.El +.Sh SEE ALSO +.Xr stat 2 , +.Xr lstat 2 , +.Xr symlink 2 +.Sh HISTORY +The +.Nm +function call appeared in +.Bx 4.2 . diff --git a/usr/src/lib/libc/sys/reboot.2 b/usr/src/lib/libc/sys/reboot.2 new file mode 100644 index 0000000000..5eff0adfd5 --- /dev/null +++ b/usr/src/lib/libc/sys/reboot.2 @@ -0,0 +1,158 @@ +.\" Copyright (c) 1980, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)reboot.2 6.5 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt REBOOT 2 +.Os BSD 4 +.Sh NAME +.Nm reboot +.Nd reboot system or halt processor +.Sh SYNOPSIS +.Fd #include +.Fd #include +.Ft int +.Fn reboot "int howto" +.Sh DESCRIPTION +.Fn Reboot +reboots the system. +Only the super-user may reboot a machine on demand. +However, a reboot is invoked +automatically in the event of unrecoverable system failures. +.Pp +.Fa Howto +is a mask of options; the system call interface allows the following +options, defined in the include file +.Aq Pa sys/reboot.h , +to be passed +to the new kernel or the new bootstrap and init programs. +.Bl -tag -width RB_INITNAMEA +.It Dv RB_AUTOBOOT +The default, causing the system to reboot in its usual fashion. +.It Dv RB_ASKNAME +Interpreted by the bootstrap program itself, causing it to +prompt on the console as to what file should be booted. +Normally, the system is booted from the file +.Dq Em xx Ns No (0,0)vmunix , +where +.Em xx +is the default disk name, +without prompting for the file name. +.It Dv RB_DFLTROOT +Use the compiled in root device. +Normally, the system uses the device from which it was booted +as the root device if possible. +(The default behavior is dependent on the ability of the bootstrap program +to determine the drive from which it was loaded, which is not possible +on all systems.) +.It Dv RB_DUMP +Dump kernel memory before rebooting; see +.Xr savecore 8 +for more information. +.It Dv RB_HALT +the processor is simply halted; no reboot takes place. +This option should be used with caution. +.It Dv RB_INITNAME +An option allowing the specification of an init program (see +.Xr init 8 ) +other than +.Pa /sbin/init +to be run when the system reboots. +This switch is not currently available. +.It Dv RB_KDB +Load the symbol table and enable a built-in debugger in the system. +This option will have no useful function if the kernel is not configured +for debugging. +Several other options have different meaning if combined +with this option, although their use may not be possible +via the +.Fn reboot +call. +See +.Xr kadb 4 +for more information. +.It Dv RB_NOSYNC +Normally, the disks are sync'd (see +.Xr sync 8 ) +before the processor is halted or rebooted. +This option may be useful if file system changes have been made manually +or if the processor is on fire. +.It Dv RB_RDONLY +Initially mount the root file system read-only. +This is currently the default, and this option has been deprecated. +.It Dv RB_SINGLE +Normally, the reboot procedure involves an automatic disk consistency +check and then multi-user operations. +.Dv RB_SINGLE +prevents this, booting the system with a single-user shell +on the console. +.Dv RB_SINGLE +is actually interpreted by the +.Xr init 8 +program in the newly booted system. +.Pp +When no options are given (i.e., +.Dv RB_AUTOBOOT +is used), the system is +rebooted from file ``vmunix'' in the root file system of unit 0 +of a disk chosen in a processor specific way. +An automatic consistency check of the disks is normally performed +(see +.Xr fsck 8 ) . +.El +.Sh RETURN VALUES +If successful, this call never returns. +Otherwise, a -1 is returned and an error is returned in the global +variable +.Va errno . +.Sh ERRORS +.Bl -tag -width Er +.It Bq Er EPERM +The caller is not the super-user. +.El +.Sh SEE ALSO +.Xr kadb 4 , +.Xr crash 8 , +.Xr halt 8 , +.Xr init 8 , +.Xr reboot 8 , +.Xr savecore 8 +.Sh BUGS +The HP300 implementation supports neither +.Dv RB_DFLTROOT +nor +.Dv RB_KDB . +.Sh HISTORY +The +.Nm +function call appeared in +.Bx 4.0 . diff --git a/usr/src/lib/libc/sys/rename.2 b/usr/src/lib/libc/sys/rename.2 new file mode 100644 index 0000000000..07a168c0f1 --- /dev/null +++ b/usr/src/lib/libc/sys/rename.2 @@ -0,0 +1,198 @@ +.\" Copyright (c) 1983, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)rename.2 6.7 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt RENAME 2 +.Os BSD 4.2 +.Sh NAME +.Nm rename +.Nd change the name of a file +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn rename "const char *from" "const char *to" +.Sh DESCRIPTION +.Fn Rename +causes the link named +.Fa from +to be renamed as +.Fa to . +If +.Fa to +exists, it is first removed. +Both +.Fa from +and +.Fa to +must be of the same type (that is, both directories or both +non-directories), and must reside on the same file system. +.Pp +.Fn Rename +guarantees that an instance of +.Fa to +will always exist, even if the system should crash in +the middle of the operation. +.Pp +If the final component of +.Fa from +is a symbolic link, +the symbolic link is renamed, +not the file or directory to which it points. +.Sh CAVEAT +The system can deadlock if a loop in the file system graph is present. +This loop takes the form of an entry in directory +.Ql Pa a , +say +.Ql Pa a/foo , +being a hard link to directory +.Ql Pa b , +and an entry in +directory +.Ql Pa b , +say +.Ql Pa b/bar , +being a hard link +to directory +.Ql Pa a . +When such a loop exists and two separate processes attempt to +perform +.Ql rename a/foo b/bar +and +.Ql rename b/bar a/foo , +respectively, +the system may deadlock attempting to lock +both directories for modification. +Hard links to directories should be +replaced by symbolic links by the system administrator. +.Sh RETURN VALUES +A 0 value is returned if the operation succeeds, otherwise +.Fn rename +returns -1 and the global variable +.Va errno +indicates the reason for the failure. +.Sh ERRORS +.Fn Rename +will fail and neither of the argument files will be +affected if: +.Bl -tag -width ENAMETOOLONG +.It Bq Er EINVAL +Either pathname contains a character with the high-order bit set. +.It Bq Er ENAMETOOLONG +A component of either pathname exceeded 255 characters, +or the entire length of either path name exceeded 1023 characters. +.It Bq Er ENOENT +A component of the +.Fa from +path does not exist, +or a path prefix of +.Fa to +does not exist. +.It Bq Er EACCES +A component of either path prefix denies search permission. +.It Bq Er EACCES +The requested link requires writing in a directory with a mode +that denies write permission. +.It Bq Er EPERM +The directory containing +.Fa from +is marked sticky, +and neither the containing directory nor +.Fa from +are owned by the effective user ID. +.It Bq Er EPERM +The +.Fa to +file exists, +the directory containing +.Fa to +is marked sticky, +and neither the containing directory nor +.Fa to +are owned by the effective user ID. +.It Bq Er ELOOP +Too many symbolic links were encountered in translating either pathname. +.It Bq Er ENOTDIR +A component of either path prefix is not a directory. +.It Bq Er ENOTDIR +.Fa from +is a directory, but +.Fa to +is not a directory. +.It Bq Er EISDIR +.Fa to +is a directory, but +.Fa from +is not a directory. +.It Bq Er EXDEV +The link named by +.Fa to +and the file named by +.Fa from +are on different logical devices (file systems). Note that this error +code will not be returned if the implementation permits cross-device +links. +.It Bq Er ENOSPC +The directory in which the entry for the new name is being placed +cannot be extended because there is no space left on the file +system containing the directory. +.It Bq Er EDQUOT +The directory in which the entry for the new name +is being placed cannot be extended because the +user's quota of disk blocks on the file system +containing the directory has been exhausted. +.It Bq Er EIO +An I/O error occurred while making or updating a directory entry. +.It Bq Er EROFS +The requested link requires writing in a directory on a read-only file +system. +.It Bq Er EFAULT +.Em Path +points outside the process's allocated address space. +.It Bq Er EINVAL +.Fa From +is a parent directory of +.Fa to , +or an attempt is made to rename +.Ql \&. +or +.Ql \&.. . +.It Bq Er ENOTEMPTY +.Fa To +is a directory and is not empty. +.El +.Sh SEE ALSO +.Xr open 2 +.Sh STANDARDS +.Fn Rename +conforms to IEEE Std 1003.1-1988 +.Pq Dq Tn POSIX . diff --git a/usr/src/lib/libc/sys/rmdir.2 b/usr/src/lib/libc/sys/rmdir.2 new file mode 100644 index 0000000000..9c05d9c928 --- /dev/null +++ b/usr/src/lib/libc/sys/rmdir.2 @@ -0,0 +1,106 @@ +.\" Copyright (c) 1983, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)rmdir.2 6.6 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt RMDIR 2 +.Os BSD 4.2 +.Sh NAME +.Nm rmdir +.Nd remove a directory file +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn rmdir "const char *path" +.Sh DESCRIPTION +.Fn Rmdir +removes a directory file +whose name is given by +.Fa path . +The directory must not have any entries other +than +.Ql \&. +and +.Ql \&.. . +.Sh RETURN VALUES +A 0 is returned if the remove succeeds; otherwise a -1 is +returned and an error code is stored in the global location +.Va errno . +.Sh ERRORS +The named file is removed unless: +.Bl -tag -width [ENAMETOOLONG] +.It Bq Er ENOTDIR +A component of the path is not a directory. +.It Bq Er EINVAL +The pathname contains a character with the high-order bit set. +.It Bq Er ENAMETOOLONG +A component of a pathname exceeded 255 characters, +or an entire path name exceeded 1023 characters. +.It Bq Er ENOENT +The named directory does not exist. +.It Bq Er ELOOP +Too many symbolic links were encountered in translating the pathname. +.It Bq Er ENOTEMPTY +The named directory contains files other than +.Ql \&. +and +.Ql \&.. +in it. +.It Bq Er EACCES +Search permission is denied for a component of the path prefix. +.It Bq Er EACCES +Write permission is denied on the directory containing the link +to be removed. +.It Bq Er EPERM +The directory containing the directory to be removed is marked sticky, +and neither the containing directory nor the directory to be removed +are owned by the effective user ID. +.It Bq Er EBUSY +The directory to be removed is the mount point +for a mounted file system. +.It Bq Er EIO +An I/O error occurred while deleting the directory entry +or deallocating the inode. +.It Bq Er EROFS +The directory entry to be removed resides on a read-only file system. +.It Bq Er EFAULT +.Fa Path +points outside the process's allocated address space. +.El +.Sh SEE ALSO +.Xr mkdir 2 , +.Xr unlink 2 +.Sh HISTORY +The +.Nm +function call appeared in +.Bx 4.2 . diff --git a/usr/src/lib/libc/sys/select.2 b/usr/src/lib/libc/sys/select.2 new file mode 100644 index 0000000000..68b610dd88 --- /dev/null +++ b/usr/src/lib/libc/sys/select.2 @@ -0,0 +1,182 @@ +.\" Copyright (c) 1983, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)select.2 6.8 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt SELECT 2 +.Os BSD 4.2 +.Sh NAME +.Nm select +.Nd synchronous I/O multiplexing +.Sh SYNOPSIS +.Fd #include +.Fd #include +.Fd #include +.Ft int +.Fn select "int nfds" "fd_set *readfds" "fd_set *writefds" "fd_set *exceptfds" "struct timeval *timeout" +.Fn FD_SET fd &fdset +.Fn FD_CLR fd &fdset +.Fn FD_ISSET fd &fdset +.Fn FD_ZERO &fdset +.Sh DESCRIPTION +.Fn Select +examines the I/O descriptor sets whose addresses are passed in +.Fa readfds , +.Fa writefds , +and +.Fa exceptfds +to see if some of their descriptors +are ready for reading, are ready for writing, or have an exceptional +condition pending, respectively. +The first +.Fa nfds +descriptors are checked in each set; +i.e., the descriptors from 0 through +.Fa nfds Ns No -1 +in the descriptor sets are examined. +On return, +.Fn select +replaces the given descriptor sets +with subsets consisting of those descriptors that are ready +for the requested operation. +.Fn Select +returns the total number of ready descriptors in all the sets. +.Pp +The descriptor sets are stored as bit fields in arrays of integers. +The following macros are provided for manipulating such descriptor sets: +.Fn FD_ZERO &fdsetx +initializes a descriptor set +.Fa fdset +to the null set. +.Fn FD_SET fd &fdset +includes a particular descriptor +.Fa fd +in +.Fa fdset . +.Fn FD_CLR fd &fdset +removes +.Fa fd +from +.Fa fdset . +.Fn FD_ISSET fd &fdset +is non-zero if +.Fa fd +is a member of +.Fa fdset , +zero otherwise. +The behavior of these macros is undefined if +a descriptor value is less than zero or greater than or equal to +.Dv FD_SETSIZE , +which is normally at least equal +to the maximum number of descriptors supported by the system. +.Pp +If +.Fa timeout +is a non-nil pointer, it specifies a maximum interval to wait for the +selection to complete. If +.Fa timeout +is a nil pointer, the select blocks indefinitely. To affect a poll, the +.Fa timeout +argument should be non-nil, pointing to a zero-valued timeval structure. +.Pp +Any of +.Fa readfds , +.Fa writefds , +and +.Fa exceptfds +may be given as nil pointers if no descriptors are of interest. +.Sh RETURN VALUES +.Fn Select +returns the number of ready descriptors that are contained in +the descriptor sets, +or -1 if an error occurred. +If the time limit expires, +.Fn select +returns 0. +If +.Fn select +returns with an error, +including one due to an interrupted call, +the descriptor sets will be unmodified. +.Sh ERRORS +An error return from +.Fn select +indicates: +.Bl -tag -width Er +.It Bq Er EBADF +One of the descriptor sets specified an invalid descriptor. +.It Bq Er EINTR +A signal was delivered before the time limit expired and +before any of the selected events occurred. +.It Bq Er EINVAL +The specified time limit is invalid. One of its components is +negative or too large. +.El +.Sh SEE ALSO +.Xr accept 2 , +.Xr connect 2 , +.Xr read 2 , +.Xr write 2 , +.Xr recv 2 , +.Xr send 2 , +.Xr getdtablesize 2 +.Sh BUGS +Although the provision of +.Xr getdtablesize 2 +was intended to allow user programs to be written independent +of the kernel limit on the number of open files, the dimension +of a sufficiently large bit field for select remains a problem. +The default size +.Dv FD_SETSIZE +(currently 256) is somewhat larger than +the current kernel limit to the number of open files. +However, in order to accommodate programs which might potentially +use a larger number of open files with select, it is possible +to increase this size within a program by providing +a larger definition of +.Dv FD_SETSIZE +before the inclusion of +.Aq Pa sys/types.h . +.Pp +.Fn Select +should probably return the time remaining from the original timeout, +if any, by modifying the time value in place. +This may be implemented in future versions of the system. +Thus, it is unwise to assume that the timeout value will be unmodified +by the +.Fn select +call. +.Sh HISTORY +The +.Nm +function call appeared in +.Bx 4.2 . diff --git a/usr/src/lib/libc/sys/setgroups.2 b/usr/src/lib/libc/sys/setgroups.2 new file mode 100644 index 0000000000..e29041bff5 --- /dev/null +++ b/usr/src/lib/libc/sys/setgroups.2 @@ -0,0 +1,89 @@ +.\" Copyright (c) 1983, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)setgroups.2 6.7 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt SETGROUPS 2 +.Os BSD 4.2 +.Sh NAME +.Nm setgroups +.Nd set group access list +.Sh SYNOPSIS +.Fd #include +.Fd #include +.Ft int +.Fn setgroups "int ngroups" "const int *gidset" +.Sh DESCRIPTION +.Fn Setgroups +sets the group access list of the current user process +according to the array +.Fa gidset . +The parameter +.Fa ngroups +indicates the number of entries in the array and must be no +more than +.Dv NGROUPS , +as defined in +.Ao Pa sys/param.h Ac . +.Pp +Only the super-user may set new groups. +.Sh RETURN VALUES +A 0 value is returned on success, -1 on error, with +an error code stored in +.Va errno . +.Sh ERRORS +The +.Fn setgroups +call will fail if: +.Bl -tag -width Er +.It Bq Er EPERM +The caller is not the super-user. +.It Bq Er EFAULT +The address specified for +.Fa gidset +is outside the process +address space. +.El +.Sh SEE ALSO +.Xr getgroups 2 , +.Xr initgroups 3 +.Sh BUGS +The +.Fa gidset +array should be of type +.Em gid_t , +but remains integer for compatibility with earlier systems. +.Sh HISTORY +The +.Nm +function call appeared in +.Bx 4.2 . diff --git a/usr/src/lib/libc/sys/setpgid.2 b/usr/src/lib/libc/sys/setpgid.2 new file mode 100644 index 0000000000..cdf4fcca41 --- /dev/null +++ b/usr/src/lib/libc/sys/setpgid.2 @@ -0,0 +1,89 @@ +.\" Copyright (c) 1980, 1991 Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)setpgid.2 6.3 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt SETPGRP 2 +.Os BSD 4 +.Sh NAME +.Nm setpgid , +.Nm setpgrp +.Nd set process group +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn setpgid pid_tpid pid_tpgrp +.Ft int +.Fn setpgrp pid_tpid pid_tpgrp +.Sh DESCRIPTION +.Fn Setpgid +sets the process group of the specified process +.Ar pid +to the specified +.Ar pgrp . +If +.Ar pid +is zero, then the call applies to the current process. +.Pp +If the invoker is not the super-user, then the affected process +must have the same effective user-id as the invoker or be a descendant +of the invoking process. +.Sh RETURN VALUES +.Fn Setpgid +returns 0 when the operation was successful. +If the request failed, -1 is returned and the global variable +.Va errno +indicates the reason. +.Sh ERRORS +.Fn Setpgid +will fail and the process group will not be altered if: +.Bl -tag -width indent +.It Bq Er ESRCH +The requested process does not exist. +.It Bq Er EPERM +The effective user ID of the requested process is different +from that of the caller and the process is not a descendent +of the calling process. +.El +.Sh SEE ALSO +.Xr getpgrp 2 +.Sh STANDARDS +.Fn Setpgid +conforms to IEEE Std 1003.1-1988 +.Pq Dq Tn POSIX . +.Sh COMPATIBILITY +.Fn Setpgrp +is identical to +.Fn setpgid , +and is retained for calling convention compatibility with historical +versions of +.Bx . diff --git a/usr/src/lib/libc/sys/setregid.2 b/usr/src/lib/libc/sys/setregid.2 new file mode 100644 index 0000000000..70a368ee51 --- /dev/null +++ b/usr/src/lib/libc/sys/setregid.2 @@ -0,0 +1,74 @@ +.\" Copyright (c) 1983, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)setregid.2 6.4 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt SETREGID 2 +.Os BSD 4.2 +.Sh NAME +.Nm setregid +.Nd set real and effective group ID +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn setregid "int rgid" "int egid" +.Sh DESCRIPTION +The real and effective group ID's of the current process +are set to the arguments. +Unprivileged users may change the real group +ID to the effective group ID and vice-versa; only the super-user may +make other changes. +.Pp +Supplying a value of -1 for either the real or effective +group ID forces the system to substitute the current +ID in place of the -1 parameter. +.Sh RETURN VALUES +Upon successful completion, a value of 0 is returned. Otherwise, +a value of -1 is returned and +.Va errno +is set to indicate the error. +.Sh ERRORS +.Bl -tag -width [EPERM] +.It Bq Er EPERM +The current process is not the super-user and a change +other than changing the effective group-id to the real group-id +was specified. +.El +.Sh SEE ALSO +.Xr getgid 2 , +.Xr setreuid 2 , +.Xr setgid 3 +.Sh HISTORY +The +.Nm +function call appeared in +.Bx 4.2 . diff --git a/usr/src/lib/libc/sys/setreuid.2 b/usr/src/lib/libc/sys/setreuid.2 new file mode 100644 index 0000000000..061141ef27 --- /dev/null +++ b/usr/src/lib/libc/sys/setreuid.2 @@ -0,0 +1,75 @@ +.\" Copyright (c) 1980, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)setreuid.2 6.4 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt SETREUID 2 +.Os BSD 4 +.Sh NAME +.Nm setreuid +.Nd set real and effective user ID's +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn setreuid "int ruid" "int euid" +.Sh DESCRIPTION +The real and effective user ID's of the +current process are set according to the arguments. +If +.Fa ruid +or +.Fa euid +is -1, the current uid is filled in by the system. +Unprivileged users may change the real user +ID to the effective user ID and vice-versa; only the super-user may +make other changes. +.Sh RETURN VALUES +Upon successful completion, a value of 0 is returned. Otherwise, +a value of -1 is returned and +.Va errno +is set to indicate the error. +.Sh ERRORS +.Bl -tag -width [EPERM] +.It Bq Er EPERM +The current process is not the super-user and a change +other than changing the effective user-id to the real user-id +was specified. +.El +.Sh SEE ALSO +.Xr getuid 2 , +.Xr setregid 2 , +.Xr setuid 3 +.Sh HISTORY +The +.Nm +function call appeared in +.Bx 4.2 . diff --git a/usr/src/lib/libc/sys/shutdown.2 b/usr/src/lib/libc/sys/shutdown.2 new file mode 100644 index 0000000000..6b7f800b69 --- /dev/null +++ b/usr/src/lib/libc/sys/shutdown.2 @@ -0,0 +1,81 @@ +.\" Copyright (c) 1983, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)shutdown.2 6.4 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt SHUTDOWN 2 +.Os BSD 4.2 +.Sh NAME +.Nm shutdown +.Nd shut down part of a full-duplex connection +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn shutdown "int s" "int how" +.Sh DESCRIPTION +The +.Fn shutdown +call causes all or part of a full-duplex connection on +the socket associated with +.Fa s +to be shut down. +If +.Fa how +is 0, further receives will be disallowed. +If +.Fa how +is 1, further sends will be disallowed. +If +.Fa how +is 2, further sends and receives will be disallowed. +.Sh DIAGNOSTICS +A 0 is returned if the call succeeds, -1 if it fails. +.Sh ERRORS +The call succeeds unless: +.Bl -tag -width ENOTCONNAA +.It Bq Er EBADF +.Fa S +is not a valid descriptor. +.It Bq Er ENOTSOCK +.Fa S +is a file, not a socket. +.It Bq Er ENOTCONN +The specified socket is not connected. +.El +.Sh SEE ALSO +.Xr connect 2 , +.Xr socket 2 +.Sh HISTORY +The +.Nm +function call appeared in +.Bx 4.2 . diff --git a/usr/src/lib/libc/sys/sigreturn.2 b/usr/src/lib/libc/sys/sigreturn.2 new file mode 100644 index 0000000000..8221d4e614 --- /dev/null +++ b/usr/src/lib/libc/sys/sigreturn.2 @@ -0,0 +1,97 @@ +.\" Copyright (c) 1985, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)sigreturn.2 6.5 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt SIGRETURN 2 +.Os BSD 4.3 +.Sh NAME +.Nm sigreturn +.Nd return from signal +.Sh SYNOPSIS +.Fd #include +.Bd -literal +struct sigcontext { + int sc_onstack; + int sc_mask; + int sc_sp; + int sc_fp; + int sc_ap; + int sc_pc; + int sc_ps; +}; +.Ed +.Ft int +.Fn sigreturn "struct sigcontext *scp" +.Sh DESCRIPTION +.Fn Sigreturn +allows users to atomically unmask, switch stacks, +and return from a signal context. +The processes signal mask and stack status are +restored from the context. +The system call does not return; +the users stack pointer, frame pointer, argument pointer, +and processor status longword are restored from the context. +Execution resumes at the specified pc. +This system call is used by the trampoline code and +.Xr longjmp 3 +when returning from a signal to the previously executing program. +.Sh NOTES +This system call is not available in 4.2 +.Tn BSD +hence it should not be used if backward compatibility is needed. +.Sh RETURN VALUES +If successful, the system call does not return. +Otherwise, a value of -1 is returned and +.Va errno +is set to indicate the error. +.Sh ERRORS +.Fn Sigreturn +will fail and the process context will remain unchanged +if one of the following occurs. +.Bl -tag -width [EINVAL] +.It Bq Er EFAULT +.Fa Scp +points to memory that is not a valid part of the process +address space. +.It Bq Er EINVAL +The process status longword is invalid or would improperly +raise the privilege level of the process. +.El +.Sh SEE ALSO +.Xr sigvec 2 , +.Xr setjmp 3 +.Sh HISTORY +The +.Nm +function call appeared in +.Bx 4.3 . diff --git a/usr/src/lib/libc/sys/sigstack.2 b/usr/src/lib/libc/sys/sigstack.2 new file mode 100644 index 0000000000..b8bc8ee787 --- /dev/null +++ b/usr/src/lib/libc/sys/sigstack.2 @@ -0,0 +1,100 @@ +.\" Copyright (c) 1983, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)sigstack.2 6.5 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt SIGSTACK 2 +.Os BSD 4.2 +.Sh NAME +.Nm sigstack +.Nd set and/or get signal stack context +.Sh SYNOPSIS +.Fd #include +.Bd -literal +struct sigstack { + caddr_t ss_sp; + int ss_onstack; +}; +.Ed +.Ft int +.Fn sigstack "const struct sigstack *ss" "struct sigstack *oss" +.Sh DESCRIPTION +.Fn Sigstack +allows users to define an alternate stack on which signals +are to be processed. If +.Fa ss +is non-zero, +it specifies a +.Em "signal stack" +on which to deliver signals +and tells the system if the process is currently executing +on that stack. When a signal's action indicates its handler +should execute on the signal stack (specified with a +.Xr sigvec 2 +call), the system checks to see +if the process is currently executing on that stack. If the +process is not currently executing on the signal stack, +the system arranges a switch to the signal stack for the +duration of the signal handler's execution. +If +.Fa oss +is non-zero, the current signal stack state is returned. +.Sh NOTES +Signal stacks are not ``grown'' automatically, as is +done for the normal stack. If the stack overflows +unpredictable results may occur. +.Sh RETURN VALUES +Upon successful completion, a value of 0 is returned. +Otherwise, a value of -1 is returned and +.Va errno +is set to indicate the error. +.Sh ERRORS +.Fn Sigstack +will fail and the signal stack context will remain unchanged +if one of the following occurs. +.Bl -tag -width [EFAULT] +.It Bq Er EFAULT +Either +.Fa ss +or +.Fa oss +points to memory that is not a valid part of the process +address space. +.El +.Sh SEE ALSO +.Xr sigvec 2 , +.Xr setjmp 3 +.Sh HISTORY +The +.Nm +function call appeared in +.Bx 4.2 . diff --git a/usr/src/lib/libc/sys/socket.2 b/usr/src/lib/libc/sys/socket.2 new file mode 100644 index 0000000000..48427b4a94 --- /dev/null +++ b/usr/src/lib/libc/sys/socket.2 @@ -0,0 +1,257 @@ +.\" Copyright (c) 1983, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)socket.2 6.8 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt SOCKET 2 +.Os BSD 4.2 +.Sh NAME +.Nm socket +.Nd create an endpoint for communication +.Sh SYNOPSIS +.Fd #include +.Fd #include +.Ft int +.Fn socket "int domain" "int type" "int protocol" +.Sh DESCRIPTION +.Fn Socket +creates an endpoint for communication and returns a descriptor. +.Pp +The +.Fa domain +parameter specifies a communications domain within which +communication will take place; this selects the protocol family +which should be used. +These families are defined in the include file +.Ao Pa sys/socket.h Ac . +The currently understood formats are +.Pp +.Bd -literal -offset indent -compact +AF_UNIX (UNIX internal protocols), +AF_INET (ARPA Internet protocols), +AF_ISO (ISO protocols), +AF_NS (Xerox Network Systems protocols), and +AF_IMPLINK (IMP \*(lqhost at IMP\*(rq link layer). +.Ed +.Pp +The socket has the indicated +.Fa type , +which specifies the semantics of communication. Currently +defined types are: +.Pp +.Bd -literal -offset indent -compact +SOCK_STREAM +SOCK_DGRAM +SOCK_RAW +SOCK_SEQPACKET +SOCK_RDM +.Ed +.Pp +A +.Dv SOCK_STREAM +type provides sequenced, reliable, +two-way connection based byte streams. +An out-of-band data transmission mechanism may be supported. +A +.Dv SOCK_DGRAM +socket supports +datagrams (connectionless, unreliable messages of +a fixed (typically small) maximum length). +A +.Dv SOCK_SEQPACKET +socket may provide a sequenced, reliable, +two-way connection-based data transmission path for datagrams +of fixed maximum length; a consumer may be required to read +an entire packet with each read system call. +This facility is protocol specific, and presently implemented +only for +.Dv PF_NS . +.Dv SOCK_RAW +sockets provide access to internal network protocols and interfaces. +The types +.Dv SOCK_RAW , +which is available only to the super-user, and +.Dv SOCK_RDM , +which is planned, +but not yet implemented, are not described here. +.Pp +The +.Fa protocol +specifies a particular protocol to be used with the socket. +Normally only a single protocol exists to support a particular +socket type within a given protocol family. However, it is possible +that many protocols may exist, in which case a particular protocol +must be specified in this manner. The protocol number to use is +particular to the \*(lqcommunication domain\*(rq in which communication +is to take place; see +.Xr protocols 5 . +.Pp +Sockets of type +.Dv SOCK_STREAM +are full-duplex byte streams, similar +to pipes. A stream socket must be in a +.Em connected +state before any data may be sent or received +on it. A connection to another socket is created with a +.Xr connect 2 +call. Once connected, data may be transferred using +.Xr read 2 +and +.Xr write 2 +calls or some variant of the +.Xr send 2 +and +.Xr recv 2 +calls. When a session has been completed a +.Xr close 2 +may be performed. +Out-of-band data may also be transmitted as described in +.Xr send 2 +and received as described in +.Xr recv 2 . +.Pp +The communications protocols used to implement a +.Dv SOCK_STREAM +insure that data +is not lost or duplicated. If a piece of data for which the +peer protocol has buffer space cannot be successfully transmitted +within a reasonable length of time, then +the connection is considered broken and calls +will indicate an error with +-1 returns and with +.Dv ETIMEDOUT +as the specific code +in the global variable +.Va errno . +The protocols optionally keep sockets +.Dq warm +by forcing transmissions +roughly every minute in the absence of other activity. +An error is then indicated if no response can be +elicited on an otherwise +idle connection for a extended period (e.g. 5 minutes). +A +.Dv SIGPIPE +signal is raised if a process sends +on a broken stream; this causes naive processes, +which do not handle the signal, to exit. +.Pp +.Dv SOCK_SEQPACKET +sockets employ the same system calls +as +.Dv SOCK_STREAM +sockets. The only difference +is that +.Xr read 2 +calls will return only the amount of data requested, +and any remaining in the arriving packet will be discarded. +.Pp +.Dv SOCK_DGRAM +and +.Dv SOCK_RAW +sockets allow sending of datagrams to correspondents +named in +.Xr send 2 +calls. Datagrams are generally received with +.Xr recvfrom 2 , +which returns the next datagram with its return address. +.Pp +An +.Xr fcntl 2 +call can be used to specify a process group to receive +a +.Dv SIGURG +signal when the out-of-band data arrives. +It may also enable non-blocking I/O +and asynchronous notification of I/O events +via +.Dv SIGIO . +.Pp +The operation of sockets is controlled by socket level +.Em options . +These options are defined in the file +.Ao Pa sys/socket.h Ac . +.Xr Setsockopt 2 +and +.Xr getsockopt 2 +are used to set and get options, respectively. +.Sh RETURN VALUES +A -1 is returned if an error occurs, otherwise the return +value is a descriptor referencing the socket. +.Sh ERRORS +The +.Fn socket +call fails if: +.Bl -tag -width EPROTONOPSUPPORTA +.It Bq Er EPROTONOSUPPORT +The protocol type or the specified protocol is not supported +within this domain. +.It Bq Er EMFILE +The per-process descriptor table is full. +.It Bq Er ENFILE +The system file table is full. +.It Bq Er EACCESS +Permission to create a socket of the specified type and/or protocol +is denied. +.It Bq Er ENOBUFS +Insufficient buffer space is available. +The socket cannot be created until sufficient resources are freed. +.El +.Sh SEE ALSO +.Xr accept 2 , +.Xr bind 2 , +.Xr connect 2 , +.Xr getprotoent 3 , +.Xr getsockname 2 , +.Xr getsockopt 2 , +.Xr ioctl 2 , +.Xr listen 2 , +.Xr read 2 , +.Xr recv 2 , +.Xr select 2 , +.Xr send 2 , +.Xr shutdown 2 , +.Xr socketpair 2 , +.Xr write 2 +.Rs +.%T "An Introductory 4.3 BSD Interprocess Communication Tutorial" +.%O "reprinted in UNIX Programmer's Supplementary Documents Volume 1" +.Re +.Rs +.%T "BSD Interprocess Communication Tutorial" +.%O "reprinted in UNIX Programmer's Supplementary Documents Volume 1" +.Re +.Sh HISTORY +The +.Nm +function call appeared in +.Bx 4.2 . diff --git a/usr/src/lib/libc/sys/socketpair.2 b/usr/src/lib/libc/sys/socketpair.2 new file mode 100644 index 0000000000..780151fce8 --- /dev/null +++ b/usr/src/lib/libc/sys/socketpair.2 @@ -0,0 +1,91 @@ +.\" Copyright (c) 1983, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)socketpair.2 6.4 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt SOCKETPAIR 2 +.Os BSD 4.2 +.Sh NAME +.Nm socketpair +.Nd create a pair of connected sockets +.Sh SYNOPSIS +.Fd #include +.Fd #include +.Ft int +.Fn socketpair "int d" "int type" "int protocol" "int *sv" +.Sh DESCRIPTION +The +.Fn socketpair +call creates an unnamed pair of connected sockets in +the specified domain +.Fa d , +of the specified +.Fa type , +and using the optionally specified +.Fa protocol . +The descriptors used in referencing the new sockets +are returned in +.Fa sv Ns [0] +and +.Fa sv Ns [1] . +The two sockets are indistinguishable. +.Sh DIAGNOSTICS +A 0 is returned if the call succeeds, -1 if it fails. +.Sh ERRORS +The call succeeds unless: +.Bl -tag -width EPROTONOSUPPORTA +.It Bq Er EMFILE +Too many descriptors are in use by this process. +.It Bq Er EAFNOSUPPORT +The specified address family is not supported on this machine. +.It Bq Er EPROTONOSUPPORT +The specified protocol is not supported on this machine. +.It Bq Er EOPNOSUPPORT +The specified protocol does not support creation of socket pairs. +.It Bq Er EFAULT +The address +.Fa sv +does not specify a valid part of the +process address space. +.Sh SEE ALSO +.Xr read 2 , +.Xr write 2 , +.Xr pipe 2 +.Sh BUGS +This call is currently implemented only for the +.Tn UNIX +domain. +.Sh HISTORY +The +.Nm +function call appeared in +.Bx 4.2 . diff --git a/usr/src/lib/libc/sys/stat.2 b/usr/src/lib/libc/sys/stat.2 new file mode 100644 index 0000000000..8509716aef --- /dev/null +++ b/usr/src/lib/libc/sys/stat.2 @@ -0,0 +1,247 @@ +.\" Copyright (c) 1980, 1991 Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)stat.2 6.9 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt STAT 2 +.Os BSD 4 +.Sh NAME +.Nm stat , +.Nm lstat , +.Nm fstat +.Nd get file status +.Sh SYNOPSIS +.Fd #include +.Fd #include +.Ft int +.Fn stat "const char *path" "struct stat *buf" +.Ft int +.Fn lstat "const char *path" "struct stat *buf" +.Ft int +.Fn fstat "int fd" "struct stat *buf" +.Sh DESCRIPTION +The +.Fn stat +function obtains information about the file pointed to by +.Fa path . +Read, write or execute +permission of the named file is not required, but all directories +listed in the path name leading to the file must be seachable. +.Pp +.Fn Lstat +is like +.Fn stat +except in the case where the named file is a symbolic link, +in which case +.Fn lstat +returns information about the link, +while +.Fn stat +returns information about the file the link references. +.Pp +The +.Fn fstat +obtains the same information about an open file +known by the file descriptor +.Fa fd , +such as would +be obtained by an +.Xr open +call. +.Pp +.Fa Buf +is a pointer to a +.Fn stat +structure +as defined by +.Aq Pa sys/stat.h +(shown below) +and into which information is placed concerning the file. +.Bd -literal +struct stat { + dev_t st_dev; /* device inode resides on */ + ino_t st_ino; /* inode's number */ + mode_t st_mode; /* inode protection mode */ + nlink_t st_nlink; /* number or hard links to the file */ + uid_t st_uid; /* user-id of owner */ + gid_t st_gid; /* group-id of owner */ + dev_t st_rdev; /* device type, for special file inode */ + off_t st_size; /* file size, in bytes */ + time_t st_atime; /* time of last access */ + long st_spare1; + time_t st_mtime; /* time of last data modification */ + long st_spare2; + time_t st_ctime; /* time of last file status change */ + long st_spare3; + long st_blksize;/* optimal file sys I/O ops blocksize */ + long st_blocks; /* blocks allocated for file */ + u_long st_flags; /* user defined flags for file */ + u_long st_gen; /* file generation number */ +}; +.Ed +.Pp +The time-related fields of +.Fa struct stat +are as follows: +.Bl -tag -width st_blocks +.It st_atime +Time when file data last accessed. Changed by the following system +calls: +.Xr mknod 2 , +.Xr utimes 2 , +and +.Xr read 2 . +.It st_mtime +Time when file data last modified. +Changed by the following system calls: +.Xr mknod 2 , +.Xr utimes 2 , +.Xr write 2 . +.It st_ctime +Time when file status was last changed (inode data modification). +Changed by the following system calls: +.Xr chmod 2 +.Xr chown 2 , +.Xr link 2 , +.Xr mknod 2 , +.Xr rename 2 , +.Xr unlink 2 , +.Xr utimes 2 , +.Xr write 2 . +.It st_blocks +The actual number of blocks allocated for the file in 512-byte units. +.El +.Pp +The status information word +.Fa st_mode +has bits: +.Bd -literal +#define S_IFMT 0170000 /* type of file */ +#define S_IFIFO 0010000 /* named pipe (fifo) */ +#define S_IFCHR 0020000 /* character special */ +#define S_IFDIR 0040000 /* directory */ +#define S_IFBLK 0060000 /* block special */ +#define S_IFREG 0100000 /* regular */ +#define S_IFLNK 0120000 /* symbolic link */ +#define S_IFSOCK 0140000 /* socket */ +#define S_ISUID 0004000 /* set user id on execution */ +#define S_ISGID 0002000 /* set group id on execution */ +#define S_ISVTX 0001000 /* save swapped text even after use */ +#define S_IRUSR 0000400 /* read permission, owner */ +#define S_IWUSR 0000200 /* write permission, owner */ +#define S_IXUSR 0000100 /* execute/search permission, owner */ +.Ed +.Pp +For a list of access modes, see +.Aq Pa sys/stat.h , +.Xr access 2 +and +.Xr chmod 2 . +.Sh RETURN VALUES +Upon successful completion a value of 0 is returned. +Otherwise, a value of -1 is returned and +.Va errno +is set to indicate the error. +.Sh ERRORS +.Fn Stat +and +.Fn lstat +will fail if: +.Bl -tag -width ENAMETOOLONGAA +.It Bq Er ENOTDIR +A component of the path prefix is not a directory. +.It Bq Er EINVAL +The pathname contains a character with the high-order bit set. +.It Bq Er ENAMETOOLONG +A component of a pathname exceeded 255 characters, +or an entire path name exceeded 1023 characters. +.It Bq Er ENOENT +The named file does not exist. +.It Bq Er EACCES +Search permission is denied for a component of the path prefix. +.It Bq Er ELOOP +Too many symbolic links were encountered in translating the pathname. +.It Bq Er EFAULT +.Fa Buf +or +.Em name +points to an invalid address. +.It Bq Er EIO +An I/O error occurred while reading from or writing to the file system. +.El +.Pp +.Bl -tag -width [EFAULT] +.Fn Fstat +will fail if: +.It Bq Er EBADF +.Fa fd +is not a valid open file descriptor. +.It Bq Er EFAULT +.Fa Buf +points to an invalid address. +.It Bq Er EIO +An I/O error occurred while reading from or writing to the file system. +.El +.Sh CAVEAT +The fields in the stat structure currently marked +.Fa st_spare1 , +.Fa st_spare2 , +and +.Fa st_spare3 +are present in preparation for inode time stamps expanding +to 64 bits. This, however, can break certain programs that +depend on the time stamps being contiguous (in calls to +.Xr utimes 2 ) . +.Sh SEE ALSO +.Xr chmod 2 , +.Xr chown 2 , +.Xr utimes 2 +.Sh BUGS +Applying +.Xr fstat +to a socket (and thus to a pipe) +returns a zero'd buffer, +except for the blocksize field, +and a unique device and inode number. +.Sh STANDARDS +The +.Fn stat +and +.Fn fstat +function calls are expected to +conform to IEEE Std 1003.1-1988 +.Pq Dq Tn POSIX . +.Sh HISTORY +A +.Nm lstat +function call appeared in +.Bx 4.2 . diff --git a/usr/src/lib/libc/sys/swapon.2 b/usr/src/lib/libc/sys/swapon.2 new file mode 100644 index 0000000000..a4523c3ccc --- /dev/null +++ b/usr/src/lib/libc/sys/swapon.2 @@ -0,0 +1,113 @@ +.\" Copyright (c) 1980, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)swapon.2 6.7 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt SWAPON 2 +.Os BSD 4 +.Sh NAME +.Nm swapon +.Nd add a swap device for interleaved paging/swapping +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn swapon "const char *special" +.Sh DESCRIPTION +.Fn Swapon +makes the block device +.Fa special +available to the system for +allocation for paging and swapping. The names of potentially +available devices are known to the system and defined at system +configuration time. The size of the swap area on +.Fa special +is calculated at the time the device is first made available +for swapping. +.Sh RETURN VALUES +If an error has occurred, a value of -1 is returned and +.Va errno +is set to indicate the error. +.Sh ERRORS +.Fn Swapon +succeeds unless: +.Bl -tag -width ENAMETOOLONG +.It Bq Er ENOTDIR +A component of the path prefix is not a directory. +.It Bq Er EINVAL +The pathname contains a character with the high-order bit set. +.It Bq Er ENAMETOOLONG +A component of a pathname exceeded 255 characters, +or an entire path name exceeded 1023 characters. +.It Bq Er ENOENT +The named device does not exist. +.It Bq Er EACCES +Search permission is denied for a component of the path prefix. +.It Bq Er ELOOP +Too many symbolic links were encountered in translating the pathname. +.It Bq Er EPERM +The caller is not the super-user. +.It Bq Er ENOTBLK +.Fa Special +is not a block device. +.It Bq Er EBUSY +The device specified by +.Fa special +has already +been made available for swapping +.It Bq Er EINVAL +The device configured by +.Fa special +was not +configured into the system as a swap device. +.It Bq Er ENXIO +The major device number of +.Fa special +is out of range (this indicates no device driver exists +for the associated hardware). +.It Bq Er EIO +An I/O error occurred while opening the swap device. +.It Bq Er EFAULT +.Fa Special +points outside the process's allocated address space. +.Sh SEE ALSO +.Xr swapon 8 , +.Xr config 8 +.Sh BUGS +There is no way to stop swapping on a disk so that the pack may be +dismounted. +.Pp +This call will be upgraded in future versions of the system. +.Sh HISTORY +The +.Nm +function call appeared in +.Bx 4.0 . diff --git a/usr/src/lib/libc/sys/symlink.2 b/usr/src/lib/libc/sys/symlink.2 new file mode 100644 index 0000000000..4ab58b7386 --- /dev/null +++ b/usr/src/lib/libc/sys/symlink.2 @@ -0,0 +1,139 @@ +.\" Copyright (c) 1983, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)symlink.2 6.6 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt SYMLINK 2 +.Os BSD 4.2 +.Sh NAME +.Nm symlink +.Nd make symbolic link to a file +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn symlink "const char *name1" "const char *name2" +.Sh DESCRIPTION +A symbolic link +.Fa name2 +is created to +.Fa name1 +.Pf ( Fa name2 +is the name of the +file created, +.Fa name1 +is the string +used in creating the symbolic link). +Either name may be an arbitrary path name; the files need not +be on the same file system. +.Sh RETURN VALUES +Upon successful completion, a zero value is returned. +If an error occurs, the error code is stored in +.Va errno +and a -1 value is returned. +.Sh ERRORS +The symbolic link succeeds unless: +.Bl -tag -width ENAMETOO +.It Bq Er ENOTDIR +A component of the +.Fa name2 +prefix is not a directory. +.It Bq Er EINVAL +Either +.Fa name1 +or +.Fa name2 +contains a character with the high-order bit set. +.It Bq Er ENAMETOOLONG +A component of either pathname exceeded 255 characters, +or the entire length of either path name exceeded 1023 characters. +.It Bq Er ENOENT +The named file does not exist. +.It Bq Er EACCES +A component of the +.Fa name2 +path prefix denies search permission. +.It Bq Er ELOOP +Too many symbolic links were encountered in translating the pathname. +.It Bq Er EEXIST +.Fa Name2 +already exists. +.It Bq Er EIO +An I/O error occurred while making the directory entry for +.Fa name2 , +or allocating the inode for +.Fa name2 , +or writing out the link contents of +.Fa name2 . +.It Bq Er EROFS +The file +.Fa name2 +would reside on a read-only file system. +.It Bq Er ENOSPC +The directory in which the entry for the new symbolic link is being placed +cannot be extended because there is no space left on the file +system containing the directory. +.It Bq Er ENOSPC +The new symbolic link cannot be created because there +there is no space left on the file +system that will contain the symbolic link. +.It Bq Er ENOSPC +There are no free inodes on the file system on which the +symbolic link is being created. +.It Bq Er EDQUOT +The directory in which the entry for the new symbolic link +is being placed cannot be extended because the +user's quota of disk blocks on the file system +containing the directory has been exhausted. +.It Bq Er EDQUOT +The new symbolic link cannot be created because the user's +quota of disk blocks on the file system that will +contain the symbolic link has been exhausted. +.It Bq Er EDQUOT +The user's quota of inodes on the file system on +which the symbolic link is being created has been exhausted. +.It Bq Er EIO +An I/O error occurred while making the directory entry or allocating the inode. +.It Bq Er EFAULT +.Fa Name1 +or +.Fa name2 +points outside the process's allocated address space. +.El +.Sh SEE ALSO +.Xr link 2 , +.Xr ln 1 , +.Xr unlink 2 +.Sh HISTORY +The +.Nm +function call appeared in +.Bx 4.2 . diff --git a/usr/src/lib/libc/sys/sync.2 b/usr/src/lib/libc/sys/sync.2 new file mode 100644 index 0000000000..dd945e5284 --- /dev/null +++ b/usr/src/lib/libc/sys/sync.2 @@ -0,0 +1,73 @@ +.\" Copyright (c) 1980, 1991 Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)sync.2 6.3 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt SYNC 2 +.Os BSD 4 +.Sh NAME +.Nm sync +.Nd "synchronize disk block in-core status with that on disk" +.Sh SYNOPSIS +.Fd #include +.Ft void +.Fn sync void +.Sh DESCRIPTION +The +.Fn sync +function forces a write of dirty (modified) buffers +in the block buffer cache out +to disk. The kernel keeps this information in core to reduce +the number of disk I/O transfers required by the system. +As information in the cache is lost after a system crash a +.Fn sync +call is issued +frequently +by the user process +.Xr update 8 +(about every 30 seconds). +.Pp +The function +.Xr fsync 2 +may be used to synchronize individual file descriptor +attributes. +.Sh SEE ALSO +.Xr fsync 2 , +.Xr sync 8 , +.Xr update 8 +.Sh BUGS +.Fn Sync +may return before the buffers are completely flushed. +.Sh HISTORY +A +.Nm +function call appeared in Version 6 AT&T UNIX. diff --git a/usr/src/lib/libc/sys/syscall.2 b/usr/src/lib/libc/sys/syscall.2 new file mode 100644 index 0000000000..146e3aa006 --- /dev/null +++ b/usr/src/lib/libc/sys/syscall.2 @@ -0,0 +1,71 @@ +.\" Copyright (c) 1980, 1991 Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)syscall.2 6.3 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt SYSCALL 2 +.Os BSD 4 +.Sh NAME +.Nm syscall +.Nd indirect system call +.Sh SYNOPSIS +.Fd #include +.Fd #include +.Ft int +.Fn syscall "int number" "..." +.Sh DESCRIPTION +.Fn Syscall +performs the system call whose assembly language +interface has the specified +.Fa number +with the specified arguments. +Symbolic constants for system calls can be found in the header file +.Ao Pa syscall.h Ac . +.Pp +.Sh RETURN VALUES +The r0 value of the system call is returned. +When the C-bit is set, +.Fn syscall +returns -1 and sets the +external variable +.Va errno +(see +.Xr intro 2 ) . +.Sh BUGS +There is no way to simulate system calls +such as +.Xr pipe 2 . +.Sh HISTORY +The +.Nm +function call appeared in +.Bx 4.0 . diff --git a/usr/src/lib/libc/sys/truncate.2 b/usr/src/lib/libc/sys/truncate.2 new file mode 100644 index 0000000000..4edcdeda04 --- /dev/null +++ b/usr/src/lib/libc/sys/truncate.2 @@ -0,0 +1,122 @@ +.\" Copyright (c) 1983, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)truncate.2 6.9 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt TRUNCATE 2 +.Os BSD 4.2 +.Sh NAME +.Nm truncate +.Nd truncate a file to a specified length +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn truncate "const char *path" "off_t length" +.Ft int +.Fn ftruncate "int fd" "off_t length" +.Sh DESCRIPTION +.Fn Truncate +causes the file named by +.Fa path +or referenced by +.Fa fd +to be truncated to at most +.Fa length +bytes in size. If the file previously +was larger than this size, the extra data +is lost. +With +.Fn ftruncate , +the file must be open for writing. +.Sh RETURN VALUES +A value of 0 is returned if the call succeeds. If the call +fails a -1 is returned, and the global variable +.Va errno +specifies the error. +.Sh ERRORS +.Fn Truncate +succeeds unless: +.Bl -tag -width [ENOTDIR] +.It Bq Er ENOTDIR +A component of the path prefix is not a directory. +.It Bq Er EINVAL +The pathname contains a character with the high-order bit set. +.It Bq Er ENAMETOOLONG +A component of a pathname exceeded 255 characters, +or an entire path name exceeded 1023 characters. +.It Bq Er ENOENT +The named file does not exist. +.It Bq Er EACCES +Search permission is denied for a component of the path prefix. +.It Bq Er EACCES +The named file is not writable by the user. +.It Bq Er ELOOP +Too many symbolic links were encountered in translating the pathname. +.It Bq Er EISDIR +The named file is a directory. +.It Bq Er EROFS +The named file resides on a read-only file system. +.It Bq Er ETXTBSY +The file is a pure procedure (shared text) file that is being executed. +.It Bq Er EIO +An I/O error occurred updating the inode. +.It Bq Er EFAULT +.Fa Path +points outside the process's allocated address space. +.El +.Pp +.Fn Ftruncate +succeeds unless: +.Bl -tag -width [ENOTDIR] +.It Bq Er EBADF +The +.Fa fd +is not a valid descriptor. +.It Bq Er EINVAL +The +.Fa fd +references a socket, not a file. +.It Bq Er EINVAL +The +.Fa fd +is not open for writing. +.El +.Sh SEE ALSO +.Xr open 2 +.Sh BUGS +These calls should be generalized to allow ranges +of bytes in a file to be discarded. +.Sh HISTORY +The +.Nm +function call appeared in +.Bx 4.2 . diff --git a/usr/src/lib/libc/sys/umask.2 b/usr/src/lib/libc/sys/umask.2 new file mode 100644 index 0000000000..b88835148d --- /dev/null +++ b/usr/src/lib/libc/sys/umask.2 @@ -0,0 +1,82 @@ +.\" Copyright (c) 1980, 1991 Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)umask.2 6.2 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt UMASK 2 +.Os BSD 4 +.Sh NAME +.Nm umask +.Nd set file creation mode mask +.Sh SYNOPSIS +.Fd #include +.Ft mode_t +.Fn umask "mode_t numask" +.Sh DESCRIPTION +The +.Fn umask +routine sets the process's file mode creation mask to +.Fa numask +and returns the previous value of the mask. The 9 low-order +access permission +bits of +.Fa numask +are used by system calls, including +.Xr open 2 , +.Xr mkdir 2 , +and +.Xr mkfifo 2 , +to turn off corresponding bits +requested in file mode. +(see +.Xr chmod 2 ) . +This clearing allows each user to restrict the default access +to his files. +.Pp +The default mask value is 022 (write access for owner only). +Child processes inherit the mask of the calling process. +.Sh RETURN VALUES +The previous value of the file mode mask is returned by the call. +.Sh ERRORS +The +.Fn umask +function is always successful. +.Sh SEE ALSO +.Xr chmod 2 , +.Xr mknod 2 , +.Xr open 2 +.Sh STANDARDS +The +.Fn umask +function call is expected to +conform to IEEE Std 1003.1-1988 +.Pq Dq Tn POSIX . diff --git a/usr/src/lib/libc/sys/unlink.2 b/usr/src/lib/libc/sys/unlink.2 new file mode 100644 index 0000000000..304b284c19 --- /dev/null +++ b/usr/src/lib/libc/sys/unlink.2 @@ -0,0 +1,111 @@ +.\" Copyright (c) 1980, 1991 Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)unlink.2 6.3 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt UNLINK 2 +.Os BSD 4 +.Sh NAME +.Nm unlink +.Nd remove directory entry +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn unlink "const char *path" +.Sh DESCRIPTION +The +.Fn unlink +function +removes the link named by +.Fa path +from its directory and decrements the link count of the +file which was referenced by the link. +If that decrement reduces the link count of the file +to zero, +and no process has the file open, then +all resources associated with the file are reclaimed. +If one or more process have the file open when the last link is removed, +the link is removed, but the removal of the file is delayed until +all references to it have been closed. +.Sh RETURN VALUES +Upon successful completion, a value of 0 is returned. +Otherwise, a value of -1 is returned and +.Va errno +is set to indicate the error. +.Sh ERRORS +The +.Fn unlink +succeeds unless: +.Bl -tag -width ENAMETOOLONGAA +.It Bq Er ENOTDIR +A component of the path prefix is not a directory. +.It Bq Er EINVAL +The pathname contains a character with the high-order bit set. +.It Bq Er ENAMETOOLONG +A component of a pathname exceeded 255 characters, +or an entire path name exceeded 1023 characters. +.It Bq Er ENOENT +The named file does not exist. +.It Bq Er EACCES +Search permission is denied for a component of the path prefix. +.It Bq Er EACCES +Write permission is denied on the directory containing the link +to be removed. +.It Bq Er ELOOP +Too many symbolic links were encountered in translating the pathname. +.It Bq Er EPERM +The named file is a directory and the effective user ID +of the process is not the super-user. +.It Bq Er EPERM +The directory containing the file is marked sticky, +and neither the containing directory nor the file to be removed +are owned by the effective user ID. +.It Bq Er EBUSY +The entry to be unlinked is the mount point for a +mounted file system. +.It Bq Er EIO +An I/O error occurred while deleting the directory entry +or deallocating the inode. +.It Bq Er EROFS +The named file resides on a read-only file system. +.It Bq Er EFAULT +.Fa Path +points outside the process's allocated address space. +.El +.Sh SEE ALSO +.Xr close 2 , +.Xr link 2 , +.Xr rmdir 2 +.Sh HISTORY +An +.Nm +function call appeared in Version 6 AT&T UNIX. diff --git a/usr/src/lib/libc/sys/utimes.2 b/usr/src/lib/libc/sys/utimes.2 new file mode 100644 index 0000000000..c3e8bbc50c --- /dev/null +++ b/usr/src/lib/libc/sys/utimes.2 @@ -0,0 +1,118 @@ +.\" Copyright (c) 1990 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)utimes.2 6.7 (Berkeley) 4/19/91 +.\" +.Dd April 19, 1991 +.Dt UTIMES 2 +.Os BSD 4 +.Sh NAME +.Nm utimes +.Nd set file access and modification times +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn utimes "const char *file" "const struct timeval *times" +.Sh DESCRIPTION +The +.Fn utimes +function sets the access and modification times of the named file from +the structures in the argument array +.Fa times . +.Pp +The first structure is the access time, and the second is the modification +time. +.Pp +If the times are specified (the +.Fa times +argument is +.Pf non- Dv NULL ) +the caller must be the owner of the file or be the super-user. +.Pp +If the times are not specified (the +.Fa times +argument is +.Dv NULL ) +the caller must be the owner of the file, have permission to +write the file, or be the super-user. +.Sh RETURN VALUES +Upon successful completion, a value of 0 is returned. +Otherwise, a value of -1 is returned and +.Va errno +is set to indicate the error. +.Sh ERRORS +.Fn Utimes +will fail if: +.Bl -tag -width Er +.It Bq Er EACCES +Search permission is denied for a component of the path prefix; +or the +.Fa times +argument is +.Dv NULL +and the effective user ID of the process does not +match the owner of the file, and is not the super-user, and write +access is denied. +.It Bq Er EFAULT +.Xr File +or +.Fa times +points outside the process's allocated address space. +.It Bq Er EINVAL +The pathname contains a character with the high-order bit set. +.It Bq Er EIO +An I/O error occurred while reading or writing the affected inode. +.It Bq Er ELOOP +Too many symbolic links were encountered in translating the pathname. +.It Bq Er ENAMETOOLONG +A component of a pathname exceeded 255 characters, +or an entire path name exceeded 1023 characters. +.It Bq Er ENOENT +The named file does not exist. +.It Bq Er ENOTDIR +A component of the path prefix is not a directory. +.It Bq Er EPERM +The +.Fa times +argument is not +.Dv NULL +and the calling process's effective user ID +does not match the owner of the file and is not the super-user. +.It Bq Er EROFS +The file system containing the file is mounted read-only. +.El +.Sh SEE ALSO +.Xr stat 2 +.Sh HISTORY +The +.Nm +function call appeared in +.Bx 4.2 . diff --git a/usr/src/lib/libc/sys/vfork.2 b/usr/src/lib/libc/sys/vfork.2 new file mode 100644 index 0000000000..af05d05de8 --- /dev/null +++ b/usr/src/lib/libc/sys/vfork.2 @@ -0,0 +1,126 @@ +.\" Copyright (c) 1980, 1991 Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)vfork.2 6.3 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt VFORK 2 +.Os BSD 4 +.Sh NAME +.Nm vfork +.Nd spawn new process in a virtual memory efficient way +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn vfork void +.Sh DESCRIPTION +.Fn Vfork +can be used to create new processes without fully copying the address +space of the old process, which is horrendously inefficient in a paged +environment. It is useful when the purpose of +.Xr fork 2 +would have been to create a new system context for an +.Xr execve . +.Fn Vfork +differs from +.Xr fork +in that the child borrows the parent's memory and thread of +control until a call to +.Xr execve 2 +or an exit (either by a call to +.Xr exit 2 +or abnormally.) +The parent process is suspended while the child is using its resources. +.Pp +.Fn Vfork +returns 0 in the child's context and (later) the pid of the child in +the parent's context. +.Pp +.Fn Vfork +can normally be used just like +.Xr fork . +It does not work, however, to return while running in the childs context +from the procedure that called +.Fn vfork +since the eventual return from +.Fn vfork +would then return to a no longer existent stack frame. +Be careful, also, to call +.Xr _exit +rather than +.Xr exit +if you can't +.Xr execve , +since +.Xr exit +will flush and close standard I/O channels, and thereby mess up the +parent processes standard I/O data structures. +(Even with +.Xr fork +it is wrong to call +.Xr exit +since buffered data would then be flushed twice.) +.Sh SEE ALSO +.Xr fork 2 , +.Xr execve 2 , +.Xr sigvec 2 , +.Xr wait 2 , +.Sh DIAGNOSTICS +Same as for +.Xr fork . +.Sh BUGS +This system call will be eliminated when proper system sharing +mechanisms are implemented. +Users should not depend on the memory +sharing semantics of +.Xr vfork +as it will, in that case, be made synonymous to +.Xr fork . +.Pp +To avoid a possible deadlock situation, +processes that are children in the middle +of a +.Fn vfork +are never sent +.Dv SIGTTOU +or +.Dv SIGTTIN +signals; rather, +output or +.Xr ioctl 2 +calls +are allowed +and input attempts result in an end-of-file indication. +.Sh HISTORY +The +.Nm +function call appeared in +.Bx 3.0 . diff --git a/usr/src/lib/libc/sys/wait.2 b/usr/src/lib/libc/sys/wait.2 new file mode 100644 index 0000000000..b5a2a7cd11 --- /dev/null +++ b/usr/src/lib/libc/sys/wait.2 @@ -0,0 +1,295 @@ +.\" Copyright (c) 1980, 1991 Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)wait.2 6.5 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt WAIT 2 +.Os BSD 4 +.Sh NAME +.Nm wait , +.Nm waitpid , +.Nm wait4 , +.Nm wait3 +.Nd wait for process terminatation +.Sh SYNOPSIS +.Fd #include +.Fd #include +.Ft pid_t +.Fn wait "int *status" +.Fd #include +.Fd #include +.Ft pid_t +.Fn waitpid "pid_t wpid" "int *status" "int options" +.Ft pid_t +.Fn wait3 "int *status" "int options" "struct rusage *rusage" +.Ft pid_t +.Fn wait4 "pid_t wpid" "int *status" "int options" "struct rusage *rusage" +.Sh DESCRIPTION +The +.Fn wait +function suspends execution of its calling process until +.Fa status +information is available for a terminated child process, +or a signal is received. +On return from a successful +.Fn wait +call, +the +.Fa status +area contains termination information about the process that exited +as defined below. +.Pp +The +.Fn wait4 +call provides a more general interface for programs +that need to wait for certain child processes, +that need resource utilization statistics accummulated by child processes, +or that require options. +The other wait functions are implemented using +.Fn wait4 . +.Pp +The +.Fa wpid +parameter specifies the set of child processes for which to wait. +If +.Fa wpid +is -1, the call waits for any child process. +If +.Fa wpid +is 0, +the call waits for any child process in the process group of the caller. +If +.Fa wpid +is greater than zero, the call waits for the process with process id +.Fa wpid . +If +.Fa wpid +is less than -1, the call waits for any process whose process group id +equals the absolute value of +.Fa wpid . +.Pp +The +.Fa status +parameter is defined below. The +.Fa options +parameter contains the bitwise OR of any of the following options. +The +.Dv WNOHANG +option +is used to indicate that the call should not block if +there are no processes that wish to report status. +If the +.Dv WUNTRACED +option is set, +children of the current process that are stopped +due to a +.Dv SIGTTIN , SIGTTOU , SIGTSTP , +or +.Dv SIGSTOP +signal also have +their status reported. +.Pp +If +.Fa rusage +is non-zero, a summary of the resources used by the terminated +process and all its +children is returned (this information is currently not available +for stopped processes). +.Pp +When the +.Dv WNOHANG +option is specified and no processes +wish to report status, +.Fn wait4 +returns a +process id +of 0. +.Pp +The +.Fn waitpid +call is identical to +.Fn wait4 +with an +.Fa rusage +value of zero. +The older +.Fn wait3 +call is the same as +.Fn wait4 +with a +.Fa wpid +value of -1. +.Pp +The following macros may be used to test the manner of exit of the process. +One of the first three macros will evaluate to a non-zero (true) value: +.Bl -tag -width Ds +.It Fn WIFEXITED status +True if the process terminated normally by a call to +.Xr _exit 2 +or +.Xr exit 2 . +.It Fn WIFSIGNALED status +True if the process terminated due to receipt of a signal. +.It Fn WIFSTOPPED status +True if the process has not terminated, but has stopped and can be restarted. +This macro can be true only if the wait call specified the +.Dv WUNTRACED +option +or if the child process is being traced (see +.Xr ptrace 2 ) . +.El +.Pp +Depending on the values of those macros, the following macros +produce the remaining status information about the child process: +.Bl -tag -width Ds +.It Fn WEXITSTATUS status +If +.Fn WIFEXITED status +is true, evaluates to the low-order 8 bits +of the argument passed to +.Xr _exit 2 +or +.Xr exit 2 +by the child. +.It Fn WTERMSIG status +If +.Fn WIFSIGNALED status +is true, evaluates to the number of the signal +that caused the termination of the process. +.It Fn WCOREDUMP status +If +.Fn WIFSIGNALED status +is true, evaluates as true if the termination +of the process was accompanied by the creation of a core file +containing an image of the process when the signal was received. +.It Fn WSTOPSIG status +If +.Fn WIFSTOPPED status +is true, evaluates to the number of the signal +that caused the process to stop. +.El +.Sh NOTES +See +.Xr sigaction 2 +for a list of termination signals. +A status of 0 indicates normal termination. +.Pp +If a parent process terminates without +waiting for all of its child processes to terminate, +the remaining child processes are assigned the parent +process 1 ID (the init process ID). +.Pp +If a signal is caught while any of the +.Fn wait +calls is pending, +the call may be interrupted or restarted when the signal-catching routine +returns, +depending on the options in effect for the signal; +see +.Xr intro 2 , +System call restart. +.Sh RETURN VALUES +If +.Fn wait +returns due to a stopped +or terminated child process, the process ID of the child +is returned to the calling process. Otherwise, a value of -1 +is returned and +.Va errno +is set to indicate the error. +.Pp +If +.Fn wait4 , +.Fn wait3 +or +.Fn waitpid +returns due to a stopped +or terminated child process, the process ID of the child +is returned to the calling process. +If there are no children not previously awaited, +-1 is returned with +.Va errno +set to +.Bq Er ECHILD . +Otherwise, if +.Dv WNOHANG +is specified and there are +no stopped or exited children, +0 is returned. +If an error is detected or a caught signal aborts the call, +a value of -1 +is returned and +.Va errno +is set to indicate the error. +.Sh ERRORS +.Fn Wait +will fail and return immediately if: +.Bl -tag -width Er +.It Bq Er ECHILD +The calling process has no existing unwaited-for +child processes. +.It Bq Er EFAULT +The +.Fa status +or +.Fa rusage +arguments point to an illegal address. +(May not be detected before exit of a child process.) +.It Bq Er EINTR +The call was interrupted by a caught signal, +or the signal did not have the +.Dv SA_RESTART +flag set. +.El +.Sh STANDARDS +The +.Fn wait +and +.Fn waitpid +functions are defined by POSIX; +.Fn wait4 +and +.Fn wait3 +are not specified by POSIX. +The +.Fn WCOREDUMP +macro +and the ability to restart a pending +.Fn wait +call are extensions to the POSIX interface. +.Sh SEE ALSO +.Xr exit 2 , +.Xr sigaction 2 +.Sh HISTORY +A +.Nm +function call appeared in Version 6 AT&T UNIX. diff --git a/usr/src/lib/libc/sys/write.2 b/usr/src/lib/libc/sys/write.2 new file mode 100644 index 0000000000..f7d1f05339 --- /dev/null +++ b/usr/src/lib/libc/sys/write.2 @@ -0,0 +1,203 @@ +.\" Copyright (c) 1980, 1991 Regents of the University of California. +.\" All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)write.2 6.6 (Berkeley) 3/10/91 +.\" +.Dd March 10, 1991 +.Dt WRITE 2 +.Os BSD 4 +.Sh NAME +.Nm write , +.Nm writev +.Nd write output +.Sh SYNOPSIS +.Fd #include +.Fd #include +.Fd #include +.Ft ssize_t +.Fn write "int d" "const char *buf" "size_t nbytes" +.Ft int +.Fn writev "int d" "struct iovec *iov" "int iovcnt" +.Sh DESCRIPTION +.Fn Write +attempts to write +.Fa nbytes +of data to the object referenced by the descriptor +.Fa d +from the buffer pointed to by +.Fa buf . +.Fn Writev +performs the same action, but gathers the output data +from the +.Fa iovcnt +buffers specified by the members of the +.Fa iov +array: iov[0], iov[1], ..., iov[iovcnt\|-\|1]. +.Pp +For +.Fn writev , +the +.Fa iovec +structure is defined as: +.Bd -literal -offset indent -compact +struct iovec { + caddr_t iov_base; + int iov_len; +}; +.Ed +.Pp +Each +.Fa iovec +entry specifies the base address and length of an area +in memory from which data should be written. +.Fn Writev +will always write a complete area before proceeding +to the next. +.Pp +On objects capable of seeking, the +.Fn write +starts at a position +given by the pointer associated with +.Fa d , +see +.Xr lseek 2 . +Upon return from +.Fn write , +the pointer is incremented by the number of bytes which were written. +.Pp +Objects that are not capable of seeking always write from the current +position. The value of the pointer associated with such an object +is undefined. +.Pp +If the real user is not the super-user, then +.Fn write +clears the set-user-id bit on a file. +This prevents penetration of system security +by a user who +.Dq captures +a writable set-user-id file +owned by the super-user. +.Pp +When using non-blocking I/O on objects such as sockets that are subject +to flow control, +.Fn write +and +.Fn writev +may write fewer bytes than requested; +the return value must be noted, +and the remainder of the operation should be retried when possible. +.Sh RETURN VALUES +Upon successful completion the number of bytes which were written +is returned. Otherwise a -1 is returned and the global variable +.Va errno +is set to indicate the error. +.Sh ERRORS +.Fn Write +and +.Fn writev +will fail and the file pointer will remain unchanged if: +.Bl -tag -width Er +.It Bq Er EBADF +.Fa D +is not a valid descriptor open for writing. +.It Bq Er EPIPE +An attempt is made to write to a pipe that is not open +for reading by any process. +.It Bq Er EPIPE +An attempt is made to write to a socket of type +.DV SOCK_STREAM +that is not connected to a peer socket. +.It Bq Er EFBIG +An attempt was made to write a file that exceeds the process's +file size limit or the maximum file size. +.It Bq Er EFAULT +Part of +.Fa iov +or data to be written to the file +points outside the process's allocated address space. +.It Bq Er EINVAL +The pointer associated with +.Fa d +was negative. +.It Bq Er ENOSPC +There is no free space remaining on the file system +containing the file. +.It Bq Er EDQUOT +The user's quota of disk blocks on the file system +containing the file has been exhausted. +.It Bq Er EIO +An I/O error occurred while reading from or writing to the file system. +.It Bq Er EWOULDBLOCK +The file was marked for non-blocking I/O, +and no data could be written immediately. +.El +.Pp +In addition, +.Fn writev +may return one of the following errors: +.Bl -tag -width Er +.It Bq Er EINVAL +.Fa Iovcnt +was less than or equal to 0, or greater than 16. +.It Bq Er EINVAL +One of the +.Fa iov_len +values in the +.Fa iov +array was negative. +.It Bq Er EINVAL +The sum of the +.Fa iov_len +values in the +.Fa iov +array overflowed a 32-bit integer. +.El +.Sh SEE ALSO +.Xr fcntl 2 , +.Xr lseek 2 , +.Xr open 2 , +.Xr pipe 2 , +.Xr select 2 +.Sh STANDARDS +.Fn Write +is expected to conform to IEEE Std 1003.1-1988 +.Pq Dq Tn POSIX . +.Sh HISTORY +The +.Fn writev +function call +appeared in +.Bx 4.2 . +A +.Nm write +function call +appeared in +Version 6 AT&T UNIX. -- 2.20.1