diff options
Diffstat (limited to 'lib/libc/sys')
112 files changed, 3750 insertions, 762 deletions
diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc index 8677f7d..81d8621 100644 --- a/lib/libc/sys/Makefile.inc +++ b/lib/libc/sys/Makefile.inc @@ -1,12 +1,13 @@ # @(#)Makefile.inc 8.1 (Berkeley) 6/17/93 +# $Id$ # sys sources .PATH: ${.CURDIR}/${MACHINE}/sys ${.CURDIR}/sys # modules with non-default implementations on at least one architecture: -SRCS+= Ovfork.s brk.s cerror.s exect.s fork.s pipe.s ptrace.s reboot.s \ - sbrk.s setlogin.s sigpending.s sigprocmask.s sigreturn.s \ - sigsuspend.s syscall.s +SRCS+= Ovfork.S brk.S cerror.S exect.S fork.S pipe.S ptrace.S reboot.S \ + rfork.S sbrk.S setlogin.S sigpending.S sigprocmask.S sigreturn.S \ + sigsuspend.S syscall.S # glue to provide compatibility between GCC 1.X and 2.X SRCS+= ftruncate.c lseek.c mmap.c truncate.c @@ -21,62 +22,90 @@ ASM= accept.o access.o acct.o adjtime.o bind.o chdir.o chflags.o chmod.o \ getrlimit.o getrusage.o getsockname.o getsockopt.o gettimeofday.o \ getuid.o ioctl.o kill.o ktrace.o lfs_bmapv.o lfs_markv.o \ lfs_segclean.o lfs_segwait.o link.o listen.o lstat.o \ - madvise.o mincore.o mkdir.o mkfifo.o mknod.o mlock.o mount.o \ - mprotect.o msync.o munlock.o munmap.o nfssvc.o open.o \ - pathconf.o profil.o quotactl.o read.o \ + madvise.o mincore.o minherit.o mkdir.o mkfifo.o mknod.o mlock.o \ + mount.o \ + mprotect.o msgsys.o msync.o munlock.o munmap.o nfssvc.o \ + ntp_adjtime.o open.o pathconf.o profil.o quotactl.o read.o \ readlink.o readv.o recvfrom.o recvmsg.o rename.o revoke.o rmdir.o \ - select.o sendmsg.o sendto.o setegid.o seteuid.o setgid.o \ - setgroups.o setitimer.o setpgid.o setpriority.o setrlimit.o \ - setsid.o setsockopt.o settimeofday.o setuid.o shutdown.o \ + rtprio.o select.o semsys.o sendmsg.o sendto.o setegid.o seteuid.o \ + setgid.o \ + setgroups.o setitimer.o setpgid.o setpriority.o \ + setregid.o setreuid.o setrlimit.o \ + setsid.o setsockopt.o settimeofday.o setuid.o shmsys.o shutdown.o \ sigaction.o sigaltstack.o socket.o socketpair.o stat.o statfs.o \ - swapon.o symlink.o sync.o umask.o unlink.o unmount.o \ - utimes.o vadvise.o wait4.o write.o writev.o __syscall.o __sysctl.o + swapon.o symlink.o sync.o sysarch.o \ + umask.o unlink.o unmount.o utimes.o utrace.o \ + vadvise.o wait4.o write.o writev.o __syscall.o __sysctl.o PSEUDO= _exit.o _getlogin.o OBJS+= ${ASM} ${PSEUDO} -POBJS+= ${ASM:.o=.po} ${PSEUDO:.o=.po} -CLEANFILES+=${ASM} ${PSEUDO} ${POBJS} ${ASM}: ${.CURDIR}/${MACHINE}/SYS.h /usr/include/sys/syscall.h - @echo creating ${.PREFIX}.o ${.PREFIX}.po + @${ECHO} creating ${.PREFIX}.o @printf '#include "SYS.h"\nRSYSCALL(${.PREFIX})\n' | \ ${CPP} ${CFLAGS:M-[ID]*} ${AINC} | ${AS} -o ${.PREFIX}.o - @${LD} -x -r ${.PREFIX}.o - @mv a.out ${.PREFIX}.o + @${LD} -O ${.PREFIX}.o -x -r ${.PREFIX}.o + +PASM= ${ASM:.o=.po} +${PASM}: ${.CURDIR}/${MACHINE}/SYS.h /usr/include/sys/syscall.h + @${ECHO} creating ${.PREFIX}.po @printf '#include "SYS.h"\nRSYSCALL(${.PREFIX})\n' | \ ${CPP} -DPROF ${CFLAGS:M-[ID]*} ${AINC} | ${AS} -o ${.PREFIX}.po - @${LD} -x -r ${.PREFIX}.po - @mv a.out ${.PREFIX}.po + @${LD} -O ${.PREFIX}.po -x -r ${.PREFIX}.po + +SASM= ${ASM:.o=.so} +${SASM}: ${.CURDIR}/${MACHINE}/SYS.h /usr/include/sys/syscall.h + @${ECHO} creating ${.PREFIX}.so + @printf '#include "SYS.h"\nRSYSCALL(${.PREFIX})\n' | \ + ${CPP} -DPIC ${CFLAGS:M-[ID]*} ${AINC} | ${AS} -k -o ${.PREFIX}.so ${PSEUDO}: ${.CURDIR}/${MACHINE}/SYS.h /usr/include/sys/syscall.h - @echo creating ${.PREFIX}.o ${.PREFIX}.po + @${ECHO} creating ${.PREFIX}.o @printf '#include "SYS.h"\nPSEUDO(${.PREFIX},${.PREFIX:S/_//})\n' | \ ${CPP} ${CFLAGS:M-[ID]*} ${AINC} | ${AS} -o ${.PREFIX}.o - @${LD} -x -r ${.PREFIX}.o - @mv a.out ${.PREFIX}.o + @${LD} -O ${.PREFIX}.o -x -r ${.PREFIX}.o + +PPSEUDO=${PSEUDO:.o=.po} +${PPSEUDO}: ${.CURDIR}/${MACHINE}/SYS.h /usr/include/sys/syscall.h + @${ECHO} creating ${.PREFIX}.po @printf '#include "SYS.h"\nPSEUDO(${.PREFIX},${.PREFIX:S/_//})\n' | \ ${CPP} -DPROF ${CFLAGS:M-[ID]*} ${AINC} | ${AS} -o ${.PREFIX}.po - @${LD} -x -r ${.PREFIX}.po - @mv a.out ${.PREFIX}.po + @${LD} -O ${.PREFIX}.po -x -r ${.PREFIX}.po + +SPSEUDO=${PSEUDO:.o=.so} +${SPSEUDO}: ${.CURDIR}/${MACHINE}/SYS.h /usr/include/sys/syscall.h + @${ECHO} creating ${.PREFIX}.so + @printf '#include "SYS.h"\nPSEUDO(${.PREFIX},${.PREFIX:S/_//})\n' | \ + ${CPP} -DPIC ${CFLAGS:M-[ID]*} ${AINC} | ${AS} -k -o ${.PREFIX}.so -MAN2+= accept.0 access.0 acct.0 adjtime.0 bind.0 brk.0 chdir.0 chflags.0 \ - chmod.0 chown.0 chroot.0 close.0 connect.0 dup.0 execve.0 _exit.0 \ - fcntl.0 flock.0 fork.0 fsync.0 getdirentries.0 getdtablesize.0 \ - getfh.0 getfsstat.0 getgid.0 getgroups.0 getitimer.0 getlogin.0 \ - getpeername.0 getpgrp.0 getpid.0 getpriority.0 getrlimit.0 \ - getrusage.0 getsockname.0 getsockopt.0 gettimeofday.0 getuid.0 \ - intro.0 ioctl.0 kill.0 ktrace.0 link.0 listen.0 lseek.0 \ - mkdir.0 mkfifo.0 mknod.0 madvise.0 mincore.0 mlock.0 mmap.0 \ - mount.0 mprotect.0 msync.0 munmap.0 \ - nfssvc.0 open.0 pathconf.0 pipe.0 profil.0 ptrace.0 quotactl.0 \ - munmap.0 nfssvc.0 open.0 pipe.0 profil.0 ptrace.0 quotactl.0 \ - read.0 readlink.0 reboot.0 recv.0 rename.0 revoke.0 rmdir.0 \ - select.0 send.0 setgroups.0 setpgid.0 setsid.0 setuid.0 shutdown.0 \ - sigaction.0 sigpending.0 sigprocmask.0 sigreturn.0 sigaltstack.0 \ - sigstack.0 sigsuspend.0 socket.0 socketpair.0 stat.0 statfs.0 \ - swapon.0 symlink.0 sync.0 syscall.0 truncate.0 umask.0 unlink.0 \ - utimes.0 vfork.0 wait.0 write.0 +MAN2+= sys/accept.2 sys/access.2 sys/acct.2 sys/adjtime.2 sys/bind.2 \ + sys/brk.2 sys/chdir.2 sys/chflags.2 sys/chmod.2 sys/chown.2 \ + sys/chroot.2 sys/close.2 sys/connect.2 sys/dup.2 sys/execve.2 \ + sys/_exit.2 sys/fcntl.2 sys/flock.2 sys/fork.2 sys/fsync.2 \ + sys/getdirentries.2 sys/getdtablesize.2 sys/getfh.2 sys/getfsstat.2 \ + sys/getgid.2 sys/getgroups.2 sys/getitimer.2 sys/getlogin.2 \ + sys/getpeername.2 sys/getpgrp.2 sys/getpid.2 sys/getpriority.2 \ + sys/getrlimit.2 sys/getrusage.2 sys/getsockname.2 sys/getsockopt.2 \ + sys/gettimeofday.2 sys/getuid.2 sys/intro.2 sys/ioctl.2 sys/kill.2 \ + sys/ktrace.2 sys/link.2 sys/listen.2 sys/lseek.2 sys/mkdir.2 \ + sys/mkfifo.2 sys/mknod.2 sys/madvise.2 sys/mincore.2 sys/minherit.2 \ + sys/mlock.2 \ + sys/mmap.2 sys/mount.2 sys/mprotect.2 sys/msync.2 sys/munmap.2 \ + sys/ptrace.2 sys/nfssvc.2 sys/open.2 sys/pathconf.2 sys/pipe.2 \ + sys/profil.2 sys/quotactl.2 sys/read.2 sys/readlink.2 sys/reboot.2 \ + sys/recv.2 sys/rename.2 sys/revoke.2 sys/rfork.2 sys/rmdir.2 \ + sys/rtprio.2 sys/select.2 \ + sys/semctl.2 sys/semget.2 sys/semop.2 \ + sys/send.2 sys/setgroups.2 \ + sys/setpgid.2 sys/setregid.2 sys/setreuid.2 \ + sys/setsid.2 sys/setuid.2 sys/shmat.2 sys/shmctl.2 sys/shmget.2 \ + sys/shutdown.2 \ + sys/sigaction.2 sys/sigpending.2 sys/sigprocmask.2 sys/sigreturn.2 \ + sys/sigaltstack.2 sys/sigstack.2 sys/sigsuspend.2 sys/socket.2 \ + sys/socketpair.2 sys/stat.2 sys/statfs.2 sys/swapon.2 sys/symlink.2 \ + sys/sync.2 sys/syscall.2 sys/truncate.2 sys/umask.2 sys/unlink.2 \ + sys/utimes.2 sys/vfork.2 sys/wait.2 sys/write.2 MLINKS+=brk.2 sbrk.2 MLINKS+=dup.2 dup2.2 @@ -101,7 +130,9 @@ MLINKS+=pathconf.2 fpathconf.2 MLINKS+=read.2 readv.2 MLINKS+=recv.2 recvfrom.2 recv.2 recvmsg.2 MLINKS+=send.2 sendmsg.2 send.2 sendto.2 +MLINKS+=setpgid.2 setpgrp.2 MLINKS+=setuid.2 setegid.2 setuid.2 seteuid.2 setuid.2 setgid.2 +MLINKS+=shmat.2 shmdt.2 MLINKS+=stat.2 fstat.2 stat.2 lstat.2 MLINKS+=statfs.2 fstatfs.2 MLINKS+=syscall.2 __syscall.2 diff --git a/lib/libc/sys/_exit.2 b/lib/libc/sys/_exit.2 index 73e6062..4f6a1c5 100644 --- a/lib/libc/sys/_exit.2 +++ b/lib/libc/sys/_exit.2 @@ -30,6 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)_exit.2 8.1 (Berkeley) 6/4/93 +.\" $Id$ .\" .Dd June 4, 1993 .Dt EXIT 2 @@ -53,7 +54,7 @@ This may entail delays, for example, waiting for output to drain; a process in this state may not be killed, as it is already dying. .It If the parent process of the calling process has an outstanding -.Xr wait +.Xr wait 2 call or catches the .Dv SIGCHLD @@ -107,6 +108,11 @@ can never return. .Xr exit 3 .Sh STANDARDS The -.Nm _exit -function is defined by -.St -p1003.1-88 . +.Fn _exit +function call is expected to conform to +.St -p1003.1-90 . +.Sh HISTORY +An +.Fn _exit +function call appeared in +.At v7 . diff --git a/lib/libc/sys/accept.2 b/lib/libc/sys/accept.2 index d475e36..4c49c31 100644 --- a/lib/libc/sys/accept.2 +++ b/lib/libc/sys/accept.2 @@ -129,6 +129,31 @@ by issuing a call with providing only the control information, or by calling .Xr setsockopt 2 . +.Sh IMPLEMENTATION NOTES +.Pp +In the non-threaded library +.Fn accept +is implemented as the +.Va accept +syscall. +.Pp +In the threaded library, the +.Va accept +syscall is assembled to +.Fn _thread_sys_accept +and +.Fn accept +is implemented as a function which locks +.Va s +for read and write, then calls +.Fn _thread_sys_accept . +If the call to +.Fn _thread_sys_accept +would block, a context switch is performed. Before returning, +.Fn accept +unlocks +.Va s . +.Pp .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. @@ -161,6 +186,6 @@ are present to be accepted. .Xr socket 2 .Sh HISTORY The -.Nm +.Fn accept function appeared in .Bx 4.2 . diff --git a/lib/libc/sys/access.2 b/lib/libc/sys/access.2 index 0dc9d2e..cf1fe90 100644 --- a/lib/libc/sys/access.2 +++ b/lib/libc/sys/access.2 @@ -30,6 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)access.2 8.2 (Berkeley) 4/1/94 +.\" $Id$ .\" .Dd April 1, 1994 .Dt ACCESS 2 @@ -88,8 +89,6 @@ 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. @@ -121,10 +120,16 @@ An I/O error occurred while reading from or writing to the file system. .Xr chmod 2 , .Xr stat 2 .Sh STANDARDS -.Fn Access -conforms to IEEE Std 1003.1-1988 -.Pq Dq Tn POSIX . +The +.Fn access +function call is expected to conform to +.St -p1003.1-90 . .Sh CAVEAT .Fn Access is a potential security hole and should never be used. +.Sh HISTORY +An +.Fn access +function call appeared in +.At v7 . diff --git a/lib/libc/sys/acct.2 b/lib/libc/sys/acct.2 index bcd45ca..879a06f 100644 --- a/lib/libc/sys/acct.2 +++ b/lib/libc/sys/acct.2 @@ -86,8 +86,6 @@ will fail if one of the following is true: 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. @@ -111,5 +109,6 @@ An I/O error occurred while reading from or writing to the file system. .Xr sa 8 .Sh HISTORY An -.Nm -function call appeared in Version 7 AT&T UNIX. +.Fn acct +function call appeared in +.At v7 . diff --git a/lib/libc/sys/adjtime.2 b/lib/libc/sys/adjtime.2 index 84b9ad8..ddb8137 100644 --- a/lib/libc/sys/adjtime.2 +++ b/lib/libc/sys/adjtime.2 @@ -98,7 +98,7 @@ The process's effective user ID is not that of the super-user. .Xr date 1 , .Xr gettimeofday 2 , .Xr timed 8 , -.Xr timedc 8 , +.Xr timedc 8 .Rs .%T "TSP: The Time Synchronization Protocol for UNIX 4.3BSD" .%A R. Gusella @@ -106,6 +106,6 @@ The process's effective user ID is not that of the super-user. .Re .Sh HISTORY The -.Nm +.Fn adjtime function call appeared in .Bx 4.3 . diff --git a/lib/libc/sys/bind.2 b/lib/libc/sys/bind.2 index 18512e2..2094852 100644 --- a/lib/libc/sys/bind.2 +++ b/lib/libc/sys/bind.2 @@ -62,6 +62,28 @@ needed (using .Pp The rules used in name binding vary between communication domains. Consult the manual entries in section 4 for detailed information. +.Sh IMPLEMENTATION NOTES +.Pp +In the non-threaded library +.Fn bind +is implemented as the +.Va bind +syscall. +.Pp +In the threaded library, the +.Va bind +syscall is assembled to +.Fn _thread_sys_bind +and +.Fn bind +is implemented as a function which locks +.Va s +for read and write, then calls +.Fn _thread_sys_bind . +Before returning, +.Fn bind +unlocks +.Va s . .Sh RETURN VALUES If the bind is successful, a 0 value is returned. A return value of -1 indicates an error, which is @@ -82,8 +104,6 @@ is not a socket. 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. @@ -116,11 +136,11 @@ An empty pathname was specified. .El .Sh SEE ALSO .Xr connect 2 , +.Xr getsockname 2 , .Xr listen 2 , -.Xr socket 2 , -.Xr getsockname 2 +.Xr socket 2 .Sh HISTORY The -.Nm +.Fn bind function call appeared in .Bx 4.2 . diff --git a/lib/libc/sys/brk.2 b/lib/libc/sys/brk.2 index c84393d..6867fcb 100644 --- a/lib/libc/sys/brk.2 +++ b/lib/libc/sys/brk.2 @@ -39,9 +39,9 @@ .Nm sbrk .Nd change data segment size .Sh SYNOPSIS -.Fd #include <sys/types.h> -.Ft char -.Fn *brk "const char *addr" +.Fd #include <sys/unistd.h> +.Ft int +.Fn brk "const char *addr" .Ft char * .Fn *sbrk "int incr" .Sh DESCRIPTION @@ -94,7 +94,7 @@ it will not be possible to set the break beyond the .Em rlim_max value returned from a call to -.Xr getrlimit , +.Xr getrlimit 2 , e.g. .Dq qetext + rlp\(->rlim_max. (see @@ -102,19 +102,19 @@ e.g. for the definition of .Em etext ) . .Sh RETURN VALUES -.Nm Brk -returns a pointer to the new end of memory if successful; +.Fn Brk +returns 0 if successful; otherwise -1 with .Va errno set to indicate why the allocation failed. The -.Nm sbrk -returns a pointer to the base of the new storage if successful; +.Fn sbrk +function returns a pointer to the base of the new storage if successful; otherwise -1 with .Va errno set to indicate why the allocation failed. .Sh ERRORS -.Xr Sbrk +.Fn Sbrk will fail and no additional memory will be allocated if one of the following are true: .Bl -tag -width [ENOMEM] @@ -132,15 +132,16 @@ to support the expansion. .Sh SEE ALSO .Xr execve 2 , .Xr getrlimit 2 , -.Xr malloc 3 , -.Xr end 3 +.Xr end 3 , +.Xr malloc 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 . +.Xr getrlimit 2 . .Sh HISTORY A -.Nm -function call appeared in Version 7 AT&T UNIX. +.Fn brk +function call appeared in +.At v7 . diff --git a/lib/libc/sys/chdir.2 b/lib/libc/sys/chdir.2 index 0b06fa8..215d759 100644 --- a/lib/libc/sys/chdir.2 +++ b/lib/libc/sys/chdir.2 @@ -30,6 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)chdir.2 8.2 (Berkeley) 12/11/93 +.\" $Id$ .\" .Dd December 11, 1993 .Dt CHDIR 2 @@ -82,8 +83,6 @@ 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. @@ -118,10 +117,15 @@ is not a valid file descriptor. .Sh SEE ALSO .Xr chroot 2 .Sh STANDARDS -.Fn Chdir -is expected to conform to IEEE Std 1003.1-1988 -.Pq Dq Tn POSIX . +The +.Fn chdir +function call is expected to conform to +.St -p1003.1-90 . .Sh HISTORY +A +.Fn chdir +function call appeared in +.At v7 . The .Fn fchdir function call diff --git a/lib/libc/sys/chflags.2 b/lib/libc/sys/chflags.2 index 8481851..da3b285 100644 --- a/lib/libc/sys/chflags.2 +++ b/lib/libc/sys/chflags.2 @@ -96,12 +96,10 @@ Otherwise, -1 is returned and the global variable is set to indicate the error. .Sh ERRORS .Fn Chflags -will fail it: +will fail 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. @@ -144,11 +142,12 @@ An error occurred while reading from or writing to the file system. .El .Sh SEE ALSO -.Xr chflags 1, +.Xr chflags 1 , .Xr init 8 .Sh HISTORY The .Nm chflags and .Nm fchflags -functions first appeared in 4.4BSD. +functions first appeared in +.Bx 4.4 . diff --git a/lib/libc/sys/chmod.2 b/lib/libc/sys/chmod.2 index 1075158..2179e16 100644 --- a/lib/libc/sys/chmod.2 +++ b/lib/libc/sys/chmod.2 @@ -30,6 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)chmod.2 8.1 (Berkeley) 6/4/93 +.\" $Id$ .\" .Dd June 4, 1993 .Dt CHMOD 2 @@ -88,17 +89,12 @@ defined in #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_ISVTX 0001000 /* sticky bit */ .Ed .Pp -The +The FreeBSD VM system totally ignores the sticky bit ( .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. +) for executables. .Pp If mode .Dv ISVTX @@ -128,8 +124,6 @@ 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. @@ -166,15 +160,20 @@ 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 open 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 . +The +.Fn chmod +function call is expected to conform to +.St -p1003.1-90 . .Sh HISTORY +A +.Fn chmod +function call appeared in +.At v7 . The .Fn fchmod function call diff --git a/lib/libc/sys/chown.2 b/lib/libc/sys/chown.2 index 8b851e2..8cf5422 100644 --- a/lib/libc/sys/chown.2 +++ b/lib/libc/sys/chown.2 @@ -30,6 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)chown.2 8.4 (Berkeley) 4/19/94 +.\" $Id$ .\" .Dd April 19, 1994 .Dt CHOWN 2 @@ -43,7 +44,7 @@ .Ft int .Fn chown "const char *path" "uid_t owner" "gid_t group" .Ft int -.Fn fchown "int fd" "uid_t owner" "uid_t group" +.Fn fchown "int fd" "uid_t owner" "gid_t group" .Sh DESCRIPTION The owner ID and group ID of the file named by @@ -66,7 +67,8 @@ capability is restricted to the super-user. clears the set-user-id and set-group-id bits on the file to prevent accidental or mischievous creation of -set-user-id and set-group-id programs. +set-user-id and set-group-id programs if not executed +by the super-user. .Pp .Fn Fchown is particularly useful when used in conjunction @@ -86,8 +88,6 @@ 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. @@ -125,15 +125,20 @@ The named file resides on a read-only file system. 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 +.Xr flock 2 , +.Xr chown 8 .Sh STANDARDS -.Fn Chown -is expected to conform to IEEE Std 1003.1-1988 -.Pq Dq Tn POSIX . +The +.Fn chown +function call is expected to conform to +.St -p1003.1-90 . .Sh HISTORY +A +.Fn chown +function call appeared in +.At v7 . The .Fn fchown function call diff --git a/lib/libc/sys/chroot.2 b/lib/libc/sys/chroot.2 index d8763fe..10a9b5e 100644 --- a/lib/libc/sys/chroot.2 +++ b/lib/libc/sys/chroot.2 @@ -71,8 +71,8 @@ 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 EPERM +The effective user ID is not the super-user. .It Bq Er ENAMETOOLONG A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. @@ -92,6 +92,6 @@ An I/O error occurred while reading from or writing to the file system. .Xr chdir 2 .Sh HISTORY The -.Nm +.Fn chroot function call appeared in .Bx 4.2 . diff --git a/lib/libc/sys/close.2 b/lib/libc/sys/close.2 index 885ac80..1a66e39 100644 --- a/lib/libc/sys/close.2 +++ b/lib/libc/sys/close.2 @@ -30,6 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)close.2 8.2 (Berkeley) 4/19/94 +.\" $Id$ .\" .Dd April 19, 1994 .Dt CLOSE 2 @@ -78,7 +79,7 @@ of the descriptors can be rearranged with or deleted with .Fn close before the -.Xr execve +.Xr execve 2 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. @@ -90,6 +91,28 @@ execve; the call .Dq Li fcntl(d, F_SETFD, 0) restores the default, which is to not close the descriptor. +.Sh IMPLEMENTATION NOTES +.Pp +In the non-threaded library +.Fn close +is implemented as the +.Va close +syscall. +.Pp +In the threaded library, the +.Va close +syscall is assembled to +.Fn _thread_sys_close +and +.Fn close +is implemented as a function which locks +.Va d +for read and write, then calls +.Fn _thread_sys_close . +Before returning, +.Fn close +unlocks +.Va d . .Sh RETURN VALUES Upon successful completion, a value of 0 is returned. Otherwise, a value of -1 is returned and the global integer variable @@ -107,14 +130,20 @@ An interrupt was received. .El .Sh SEE ALSO .Xr accept 2 , +.Xr execve 2 , +.Xr fcntl 2 , .Xr flock 2 , .Xr open 2 , .Xr pipe 2 , .Xr socket 2 , -.Xr socketpair 2 , -.Xr execve 2 , -.Xr fcntl 2 +.Xr socketpair 2 .Sh STANDARDS -.Fn Close -conforms to IEEE Std 1003.1-1988 -.Pq Dq Tn POSIX . +The +.Fn close +function call is expected to conform to +.St -p1003.1-90 . +.Sh HISTORY +A +.Fn close +function call appeared in +.At v7 . diff --git a/lib/libc/sys/connect.2 b/lib/libc/sys/connect.2 index eb38ab3..446fab5 100644 --- a/lib/libc/sys/connect.2 +++ b/lib/libc/sys/connect.2 @@ -68,6 +68,30 @@ only once; datagram sockets may use multiple times to change their association. Datagram sockets may dissolve the association by connecting to an invalid address, such as a null address. +.Sh IMPLEMENTATION NOTES +.Pp +In the non-threaded library +.Fn connect +is implemented as the +.Va connect +syscall. +.Pp +In the threaded library, the +.Va connect +syscall is assembled to +.Fn _thread_sys_connect +and +.Fn connect +is implemented as a function which locks +.Va s +for read and write, then calls +.Fn _thread_sys_connect . +If the call to +.Fn _thread_sys_connect +would block, a context switch is performed. Before returning, +.Fn connect +unlocks +.Va s . .Sh RETURN VALUES If the connection or binding succeeds, 0 is returned. Otherwise a -1 is returned, and a more specific error @@ -79,10 +103,10 @@ The call fails if: .Bl -tag -width EADDRNOTAVAILABB .It Bq Er EBADF -.Fa S +.Fa s is not a valid descriptor. .It Bq Er ENOTSOCK -.Fa S +.Fa s is a descriptor for a file, not a socket. .It Bq Er EADDRNOTAVAIL The specified address is not available on this machine. @@ -121,8 +145,6 @@ 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. @@ -137,11 +159,11 @@ Too many symbolic links were encountered in translating the pathname. .El .Sh SEE ALSO .Xr accept 2 , +.Xr getsockname 2 , .Xr select 2 , -.Xr socket 2 , -.Xr getsockname 2 +.Xr socket 2 .Sh HISTORY The -.Nm +.Fn connect function call appeared in .Bx 4.2 . diff --git a/lib/libc/sys/dup.2 b/lib/libc/sys/dup.2 index 8989639..58a967d 100644 --- a/lib/libc/sys/dup.2 +++ b/lib/libc/sys/dup.2 @@ -30,6 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)dup.2 8.1 (Berkeley) 6/4/93 +.\" $Id: dup.2,v 1.7 1997/02/22 15:03:49 peter Exp $ .\" .Dd June 4, 1993 .Dt DUP 2 @@ -91,10 +92,74 @@ 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 +is specified. If this descriptor is already in use and +.Fa oldd +!= +.Fa newd , +the descriptor is first deallocated as if a .Xr close 2 -call had been done first. +call had been used. +If +.Fa oldd +is not a valid descriptor, then +.Fa newd +is not closed. +If +.Fa oldd +== +.Fa newd +and +.Fa oldd +is a valid descriptor, then +.Fn dup2 +is successful, and does nothing. +.Sh IMPLEMENTATION NOTES +.Pp +In the non-threaded library +.Fn dup +is implemented as the +.Va dup +syscall. +.Pp +In the threaded library, the +.Va dup +syscall is assembled to +.Fn _thread_sys_dup +and +.Fn dup +is implemented as a function which locks +.Va oldd +for read and write, then calls +.Fn _thread_sys_dup . +Before returning, +.Fn dup +unlocks +.Va oldd . +.Pp +In the non-threaded library +.Fn dup2 +is implemented as the +.Va dup2 +syscall. +.Pp +In the threaded library, the +.Va dup2 +syscall is assembled to +.Fn _thread_sys_dup2 +and +.Fn dup2 +is implemented as a function which locks both +.Va oldd +and +.Va newd +for read and write, then calls +.Fn _thread_sys_dup2 . +Before returning, +.Fn dup2 +unlocks +.Va oldd . +and +.Va newd . .Sh RETURN VALUES The value -1 is returned if an error occurs in either call. The external variable @@ -116,17 +181,24 @@ Too many descriptors are active. .El .Sh SEE ALSO .Xr accept 2 , -.Xr open 2 , .Xr close 2 , .Xr fcntl 2 , +.Xr getdtablesize 2 , +.Xr open 2 , .Xr pipe 2 , .Xr socket 2 , -.Xr socketpair 2 , -.Xr getdtablesize 2 +.Xr socketpair 2 .Sh STANDARDS -.Fn Dup +The +.Fn dup and .Fn dup2 -are expected to conform -to IEEE Std 1003.1-1988 -.Pq Dq Tn POSIX . +function calls are expected to conform to +.St -p1003.1-90 . +.Sh HISTORY +A +.Fn dup +and a +.Fn dup2 +function call appeared in +.At v7 . diff --git a/lib/libc/sys/execve.2 b/lib/libc/sys/execve.2 index ba47e6d..b9fb131 100644 --- a/lib/libc/sys/execve.2 +++ b/lib/libc/sys/execve.2 @@ -178,6 +178,23 @@ and .Fa argv points to the array of character pointers to the arguments themselves. +.Sh IMPLEMENTATION NOTES +.Pp +In the non-threaded library +.Fn execve +is implemented as the +.Va execve +syscall. +.Pp +In the threaded library, the +.Va execve +syscall is assembled to +.Fn _thread_sys_execve +and +.Fn execve +is implemented as a function which performs user-thread +library re-initialization and then calls +.Fn _thread_sys_execve . .Sh RETURN VALUES As the .Fn execve @@ -196,8 +213,6 @@ 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. @@ -224,10 +239,10 @@ is allowed by the imposed maximum .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 +The limit in the system as released is 65536 bytes .Pf ( Dv NCARGS in -.Ao Pa sys/param.h Ac . +.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. @@ -250,12 +265,13 @@ the real is ``root'', then the program has some of the powers of a super-user as well. .Sh SEE ALSO -.Xr exit 2 , +.Xr _exit 2 , .Xr fork 2 , .Xr execl 3 , +.Xr exit 3 , .Xr environ 7 .Sh HISTORY The -.Nm +.Fn execve function call appeared in .Bx 4.2 . diff --git a/lib/libc/sys/fcntl.2 b/lib/libc/sys/fcntl.2 index f53c02f..877e830 100644 --- a/lib/libc/sys/fcntl.2 +++ b/lib/libc/sys/fcntl.2 @@ -70,7 +70,7 @@ 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 +.Xr execve 2 system calls. .El .It Dv F_GETFD @@ -128,9 +128,9 @@ flags are as follows: .Bl -tag -width O_NONBLOCKX .It Dv O_NONBLOCK Non-blocking I/O; if no data is available to a -.Xr read +.Xr read 2 call, or if a -.Xr write +.Xr write 2 operation would block, the read or write call returns -1 with the error .Er EAGAIN . @@ -170,7 +170,7 @@ taken as a pointer to a .Fa "struct flock" (see above). The information retrieved overwrites the information passed to -.Nm fcntl +.Fn fcntl in the .Fa flock structure. @@ -193,18 +193,18 @@ or exclusive (or write) locks, as well as remove either type of lock .Dv (F_UNLCK) . If a shared or exclusive lock cannot be set, -.Nm fcntl +.Fn fcntl returns immediately with -.Er EACCES . +.Er EAGAIN . .It Dv F_SETLKW This command is the same as .Dv F_SETLK except that if a shared or exclusive lock is blocked by other locks, the process waits until the request can be satisfied. If a signal that is to be caught is received while -.Nm fcntl +.Fn fcntl is waiting for a region, the -.Nm fcntl +.Fn fcntl will be interrupted if the signal handler has not specified the .Dv SA_RESTART (see @@ -290,15 +290,17 @@ locks conflicts with the type specified in the request. This interface follows the completely stupid semantics of System V and .St -p1003.1-88 that require that all locks associated with a file for a given process are -removed when \fIany\fP file descriptor for that file is closed by that process. +removed when +.Em any +file descriptor for that file is closed by that process. This semantic means that applications must be aware of any files that a subroutine library may access. For example if an application for updating the password file locks the password file database while making the update, and then calls -.Xr getpwname 3 +.Xr getpwnam 3 to retrieve a record, the lock will be lost because -.Xr getpwname 3 +.Xr getpwnam 3 opens, reads, and closes the password database. The database close will release all locks that the process has associated with the database, even if the library routine never @@ -330,6 +332,29 @@ This implementation detects that sleeping until a locked region is unlocked would cause a deadlock and fails with an .Er EDEADLK error. +.Sh IMPLEMENTATION NOTES +.Pp +In the non-threaded library +.Fn fcntl +is implemented as the +.Va fcntl +syscall. +.Pp +In the threaded library, the +.Va fcntl +syscall is assembled to +.Fn _thread_sys_fcntl +and +.Fn fcntl +is implemented as a function which disables thread rescheduling, locks +.Va fd +for read and write, then calls +.Fn _thread_sys_fcntl . +Before returning, +.Fn fcntl +unlocks +.Va fd +and enables thread rescheduling. .Sh RETURN VALUES Upon successful completion, the value returned depends on .Fa cmd @@ -354,9 +379,9 @@ is set to indicate the error. .Fn Fcntl will fail if: .Bl -tag -width Er -.It Bq Er EACCES +.It Bq Er EAGAIN The argument -.Fa arg +.Fa cmd is .Dv F_SETLK , the type of lock @@ -401,12 +426,6 @@ is an exclusive lock and .Fa fildes is not a valid file descriptor open for writing. -.It Bq Er EMFILE -.Fa Cmd -is -.Dv F_DUPFD -and the maximum allowed number of file descriptors are currently -open. .It Bq Er EDEADLK The argument .Fa cmd @@ -445,7 +464,7 @@ refers to a file that does not support locking. The argument .Fa cmd is -.Dv F_DUPED +.Dv F_DUPFD and the maximum number of file descriptors permitted for the process are already in use, or no file descriptors greater than or equal to @@ -467,15 +486,33 @@ is and the process ID given as argument is not in use. .El +.Pp +In addition, if +.Fa fd +refers to a descriptor open on a terminal device (as opposed to a +descriptor open on a socket), a +.Fa cmd +of +.Dv F_SETOWN +can fail for the same reasons as in +.Xr tcsetpgrp 3 , +and a +.Fa cmd +of +.Dv F_GETOWN +for the reasons as stated in +.Xr tcgetpgrp 3 . .Sh SEE ALSO .Xr close 2 , .Xr execve 2 , .Xr flock 2 , .Xr getdtablesize 2 , .Xr open 2 , -.Xr sigvec 2 +.Xr sigvec 2 , +.Xr tcgetpgrp 3 , +.Xr tcsetpgrp 3 .Sh HISTORY The -.Nm +.Fn fcntl function call appeared in .Bx 4.2 . diff --git a/lib/libc/sys/flock.2 b/lib/libc/sys/flock.2 index bb6abb7..966f7a9 100644 --- a/lib/libc/sys/flock.2 +++ b/lib/libc/sys/flock.2 @@ -109,6 +109,28 @@ 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 IMPLEMENTATION NOTES +.Pp +In the non-threaded library +.Fn flock +is implemented as the +.Va flock +syscall. +.Pp +In the threaded library, the +.Va flock +syscall is assembled to +.Fn _thread_sys_flock +and +.Fn flock +is implemented as a function which locks +.Va fd +for read and write, then calls +.Fn _thread_sys_flock . +Before returning, +.Fn flock +unlocks +.Va fd . .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 @@ -131,15 +153,19 @@ is an invalid descriptor. The argument .Fa fd refers to an object other than a file. +.It Bq Er EOPNOTSUPP +The argument +.Fa fd +refers to an object that does not support file locking. .El .Sh SEE ALSO -.Xr open 2 , .Xr close 2 , .Xr dup 2 , .Xr execve 2 , -.Xr fork 2 +.Xr fork 2 , +.Xr open 2 .Sh HISTORY The -.Nm +.Fn flock function call appeared in .Bx 4.2 . diff --git a/lib/libc/sys/fork.2 b/lib/libc/sys/fork.2 index 0c290f6..e4bb7ef 100644 --- a/lib/libc/sys/fork.2 +++ b/lib/libc/sys/fork.2 @@ -59,9 +59,9 @@ 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 +.Xr read 2 or -.Xr write +.Xr write 2 by the parent. This descriptor copying is also used by the shell to establish standard input and output for newly created processes @@ -88,13 +88,27 @@ will fail and no child process will be created if: .It Bq Er EAGAIN The system-imposed limit on the total number of processes under execution would be exceeded. -This limit is configuration-dependent. +The limit is given by the +.Xr sysctl 3 +MIB variable +.Dv KERN_MAXPROC . +(The limit is actually one less than this +except for the super user). .It Bq Er EAGAIN -The system-imposed limit -.Dv MAXUPRC -.Pq Aq Pa sys/param.h +The user is not the super user, and +the system-imposed limit on the total number of processes under execution by a single user would be exceeded. +The limit is given by the +.Xr sysctl 3 +MIB variable +.Dv KERN_MAXPROCPERUID . +.It Bq Er EAGAIN +The user is not the super user, and +the soft resource limit corresponding to the resource parameter +.Dv RLIMIT_NOFILE +would be exceeded (see +.Xr getrlimit 2 ) . .It Bq Er ENOMEM There is insufficient swap space for the new process. .El diff --git a/lib/libc/sys/fsync.2 b/lib/libc/sys/fsync.2 index 234ea6e..74105ec 100644 --- a/lib/libc/sys/fsync.2 +++ b/lib/libc/sys/fsync.2 @@ -53,6 +53,28 @@ of buffers for the associated file to be written to a disk. should be used by programs that require a file to be in a known state, for example, in building a simple transaction facility. +.Sh IMPLEMENTATION NOTES +.Pp +In the non-threaded library +.Fn fsync +is implemented as the +.Va fsync +syscall. +.Pp +In the threaded library, the +.Va fsync +syscall is assembled to +.Fn _thread_sys_fsync +and +.Fn fsync +is implemented as a function which locks +.Va fd +for read and write, then calls +.Fn _thread_sys_fsync . +Before returning, +.Fn fsync +unlocks +.Va fd . .Sh RETURN VALUES A 0 value is returned on success. A -1 value indicates an error. @@ -72,10 +94,10 @@ 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 +.Xr update 4 , +.Xr sync 8 .Sh HISTORY The -.Nm +.Fn fsync function call appeared in .Bx 4.2 . diff --git a/lib/libc/sys/ftruncate.c b/lib/libc/sys/ftruncate.c index 2f3ae6d..72a6a91 100644 --- a/lib/libc/sys/ftruncate.c +++ b/lib/libc/sys/ftruncate.c @@ -37,6 +37,11 @@ static char sccsid[] = "@(#)ftruncate.c 8.1 (Berkeley) 6/17/93"; #include <sys/types.h> #include <sys/syscall.h> +#include <unistd.h> +#ifdef _THREAD_SAFE +#include <pthread.h> +#include "pthread_private.h" +#endif /* * This function provides 64-bit offset padding that @@ -48,5 +53,16 @@ ftruncate(fd, length) off_t length; { +#ifdef _THREAD_SAFE + int retval; + if (_thread_fd_lock(fd, FD_RDWR, NULL,__FILE__,__LINE__) != 0) { + retval = -1; + } else { + retval = __syscall((quad_t)SYS_ftruncate, fd, 0, length); + _thread_fd_unlock(fd, FD_RDWR); + } + return(retval); +#else return(__syscall((quad_t)SYS_ftruncate, fd, 0, length)); +#endif } diff --git a/lib/libc/sys/getdirentries.2 b/lib/libc/sys/getdirentries.2 index 6df9444..42857bb 100644 --- a/lib/libc/sys/getdirentries.2 +++ b/lib/libc/sys/getdirentries.2 @@ -120,6 +120,28 @@ The current position pointer should only be set to a value returned by a value returned in the location pointed to by .Fa basep , or zero. +.Sh IMPLEMENTATION NOTES +.Pp +In the non-threaded library +.Fn getdirentries +is implemented as the +.Va getdirentries +syscall. +.Pp +In the threaded library, the +.Va getdirentries +syscall is assembled to +.Fn _thread_sys_getdirentries +and +.Fn getdirentries +is implemented as a function which locks +.Va fd +for read and write, then calls +.Fn _thread_sys_getdirentries . +Before returning, +.Fn getdirentries +unlocks +.Va fd . .Sh RETURN VALUES If successful, the number of bytes actually transferred is returned. Otherwise, -1 is returned and the global variable @@ -129,24 +151,25 @@ is set to indicate the error. .Fn Getdirentries will fail if: .Bl -tag -width [EFAULT] -.It EBADF +.It Bq Er EBADF .Fa fd is not a valid file descriptor open for reading. -.It EFAULT +.It Bq Er EFAULT Either .Fa buf or .Fa basep point outside the allocated address space. -.It EIO +.It Bq Er EIO An .Tn I/O error occurred while reading from or writing to the file system. .El .Sh SEE ALSO -.Xr open 2 , -.Xr lseek 2 +.Xr lseek 2 , +.Xr open 2 .Sh HISTORY The -.Nm getdirentries -function first appeared in 4.4BSD. +.Fn getdirentries +function first appeared in +.Bx 4.4 . diff --git a/lib/libc/sys/getfh.2 b/lib/libc/sys/getfh.2 index ab73d5a..04f19cd 100644 --- a/lib/libc/sys/getfh.2 +++ b/lib/libc/sys/getfh.2 @@ -38,7 +38,7 @@ .Nm getfh .Nd get file handle .Sh SYNOPSIS -.Fd #include <sys/types.h> +.Fd #include <sys/param.h> .Fd #include <sys/mount.h> .Ft int .Fn getfh "char *path" "fhandle_t *fhp" @@ -61,9 +61,6 @@ fails if one or more of the following are true: A component of the path prefix of .Fa path is not a directory. -.It Bq EINVAL -.Fa path -contains a character with the high-order bit set. .It Bq ENAMETOOLONG The length of a component of .Fa path @@ -91,6 +88,7 @@ error occurred while reading from or writing to the file system. .El .Sh HISTORY The -.Nm getfh +.Fn getfh function -first appeared in 4.4BSD. +first appeared in +.Bx 4.4 . diff --git a/lib/libc/sys/getfsstat.2 b/lib/libc/sys/getfsstat.2 index 9d2a0d7..26363fa 100644 --- a/lib/libc/sys/getfsstat.2 +++ b/lib/libc/sys/getfsstat.2 @@ -51,31 +51,57 @@ is a pointer to .Xr statfs structures defined as follows: .Bd -literal -typedef quad fsid_t; +typedef struct fsid { int32_t val[2]; } fsid_t; /* file system id type */ -#define MNAMELEN 32 /* length of buffer for returned name */ +/* + * file system statistics + */ + +#define MFSNAMELEN 16 /* length of fs type name, including null */ +#define MNAMELEN 90 /* length of buffer for returned name */ struct statfs { - short f_type; /* type of filesystem (see below) */ - short f_flags; /* copy of mount flags */ - long f_bsize; /* fundamental filesystem block size */ - long f_iosize; /* optimal transfer block size */ - long f_blocks; /* total data blocks in filesystem */ - long f_bfree; /* free blocks in fs */ - long f_bavail; /* free blocks avail to non-superuser */ - long f_files; /* total file nodes in filesystem */ - long f_ffree; /* free file nodes in fs */ - fsid_t f_fsid; /* filesystem id */ - long f_spare[6]; /* spare for later */ - char f_mntonname[MNAMELEN]; /* directory on which mounted */ - char f_mntfromname[MNAMELEN]; /* mounted filesystem */ + long f_spare2; /* placeholder */ + long f_bsize; /* fundamental file system block size */ + long f_iosize; /* optimal transfer block size */ + long f_blocks; /* total data blocks in file system */ + long f_bfree; /* free blocks in fs */ + long f_bavail; /* free blocks avail to non-superuser */ + long f_files; /* total file nodes in file system */ + long f_ffree; /* free file nodes in fs */ + fsid_t f_fsid; /* file system id */ + uid_t f_owner; /* user that mounted the filesystem */ + int f_type; /* type of filesystem (see below) */ + int f_flags; /* copy of mount flags */ + long f_spare[2]; /* spare for later */ + char f_fstypename[MFSNAMELEN];/* fs type name */ + char f_mntonname[MNAMELEN];/* directory on which mounted */ + char f_mntfromname[MNAMELEN];/* mounted filesystem */ }; + /* * File system types. */ -#define MOUNT_UFS 1 -#define MOUNT_NFS 2 -#define MOUNT_PC 3 +#define MOUNT_NONE 0 +#define MOUNT_UFS 1 /* Fast Filesystem */ +#define MOUNT_NFS 2 /* Sun-compatible Network Filesystem */ +#define MOUNT_MFS 3 /* Memory-based Filesystem */ +#define MOUNT_MSDOS 4 /* MS/DOS Filesystem */ +#define MOUNT_LFS 5 /* Log-based Filesystem */ +#define MOUNT_LOFS 6 /* Loopback Filesystem */ +#define MOUNT_FDESC 7 /* File Descriptor Filesystem */ +#define MOUNT_PORTAL 8 /* Portal Filesystem */ +#define MOUNT_NULL 9 /* Minimal Filesystem Layer */ +#define MOUNT_UMAP 10 /* User/Group Identifier Remapping Filesystem */ +#define MOUNT_KERNFS 11 /* Kernel Information Filesystem */ +#define MOUNT_PROCFS 12 /* /proc Filesystem */ +#define MOUNT_AFS 13 /* Andrew Filesystem */ +#define MOUNT_CD9660 14 /* ISO9660 (aka CDROM) Filesystem */ +#define MOUNT_UNION 15 /* Union (translucent) Filesystem */ +#define MOUNT_DEVFS 16 /* existing device Filesystem */ +#define MOUNT_EXT2FS 17 /* Linux EXT2FS */ +#define MOUNT_TFS 18 /* Netcon Novell filesystem */ +#define MOUNT_MAXTYPE 18 .Ed .Pp Fields that are undefined for a particular filesystem are set to -1. @@ -131,5 +157,6 @@ error occurred while reading from or writing to the filesystem. .Xr mount 8 .Sh HISTORY The -.Nm getfsstat -function first appeared in 4.4BSD. +.Fn getfsstat +function first appeared in +.Bx 4.4 . diff --git a/lib/libc/sys/getgid.2 b/lib/libc/sys/getgid.2 index 52519d7..987f2a3 100644 --- a/lib/libc/sys/getgid.2 +++ b/lib/libc/sys/getgid.2 @@ -69,11 +69,12 @@ 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 +.Xr setgid 2 , +.Xr setregid 2 .Sh STANDARDS -.Fn Getgid +The +.Fn getgid and .Fn getegid -conform to IEEE Std 1003.1-1988 -.Pq Dq Tn POSIX . +function calls are expected to conform to +.St -p1003.1-90 . diff --git a/lib/libc/sys/getgroups.2 b/lib/libc/sys/getgroups.2 index 1428d83..ea73890 100644 --- a/lib/libc/sys/getgroups.2 +++ b/lib/libc/sys/getgroups.2 @@ -85,6 +85,6 @@ an invalid address. .Xr initgroups 3 .Sh HISTORY The -.Nm +.Fn getgroups function call appeared in .Bx 4.2 . diff --git a/lib/libc/sys/getitimer.2 b/lib/libc/sys/getitimer.2 index ac2e59a..d4534af 100644 --- a/lib/libc/sys/getitimer.2 +++ b/lib/libc/sys/getitimer.2 @@ -156,11 +156,12 @@ parameter specified a time that was too large to be handled. .El .Sh SEE ALSO +.Xr gettimeofday 2 , .Xr select 2 , .Xr sigvec 2 , -.Xr gettimeofday 2 +.Xr clocks 7 .Sh HISTORY The -.Nm +.Fn getitimer function call appeared in .Bx 4.2 . diff --git a/lib/libc/sys/getlogin.2 b/lib/libc/sys/getlogin.2 index 5b351ca..a087bda5 100644 --- a/lib/libc/sys/getlogin.2 +++ b/lib/libc/sys/getlogin.2 @@ -66,6 +66,50 @@ This call is restricted to the super-user, and is normally used only when a new session is being created on behalf of the named user (for example, at login time, or when a remote shell is invoked). +.Pp +.Em NOTE: +There is only one `login name' per `session . +.Pp +It is +.Em CRITICALLY +important to ensure that +.Fn setlogin +is only ever called after the process has taken adequate steps to ensure +that it is detached from it's parent's session. +Making a +.Fn setsid +system call is the +.Em ONLY +way to do this. The +.Fn daemon +library call calls +.Fn setsid +which is an ideal way of detaching from a controlling terminal and +forking into the background. +.Pp +In particular, doing a +.Fn "ioctl" "ttyfd" "TIOCNOTTY" "..." +or +.Fn "setpgrp" "..." +is +.Em NOT +sufficient. +.Pp +Once a parent process does a +.Fn setsid +call, it is acceptable for some child of that process to then do a +.Fn setlogin +even though it is not the session leader, but beware that ALL processes +in the session will change their login name at the same time, even the +parent. +.Pp +This is not the same as the traditional UNIX behavior of inheriting privilege. +.Pp +Since the +.Fn setlogin +system call is restricted to the super-user, it is assumed that (like +all other privileged programs) the programmer has taken adequate +precautions to prevent security violations. .Sh RETURN VALUES If a call to .Fn getlogin @@ -96,20 +140,14 @@ Login names are limited to .Dv MAXLOGNAME (from .Ao Pa sys/param.h Ac ) -characters, currently 12. +characters, currently 17 including null. .It Bq Er EPERM The caller tried to set the login name and was not the super-user. .El .Sh SEE ALSO -.Xr setsid 2 +.Xr setsid 2 , +.Xr daemon 3 .Sh BUGS -Login names are limited in length by -.Fn setlogin . -However, lower limits are placed on login names elsewhere in the system -.Pf ( Dv UT_NAMESIZE -in -.Ao Pa utmp.h Ac ) . -.Pp In earlier versions of the system, .Fn getlogin failed unless the process was associated with a login terminal. @@ -123,4 +161,5 @@ Portable programs should probably still make this check. .Sh HISTORY The .Fn getlogin -function first appeared in 4.4BSD. +function first appeared in +.Bx 4.4 . diff --git a/lib/libc/sys/getpeername.2 b/lib/libc/sys/getpeername.2 index d89488c..b9b6a03 100644 --- a/lib/libc/sys/getpeername.2 +++ b/lib/libc/sys/getpeername.2 @@ -38,6 +38,8 @@ .Nm getpeername .Nd get name of connected peer .Sh SYNOPSIS +.Fd #include <sys/types.h> +.Fd #include <sys/socket.h> .Ft int .Fn getpeername "int s" "struct sockaddr *name" "int *namelen" .Sh DESCRIPTION @@ -53,7 +55,29 @@ the amount of space pointed to by 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 +.Sh IMPLEMENTATION NOTES +.Pp +In the non-threaded library +.Fn getpeername +is implemented as the +.Va getpeername +syscall. +.Pp +In the threaded library, the +.Va getpeername +syscall is assembled to +.Fn _thread_sys_getpeername +and +.Fn getpeername +is implemented as a function which locks +.Va s +for read and write, then calls +.Fn _thread_sys_getpeername . +Before returning, +.Fn getpeername +unlocks +.Va s . +.Sh RETURN VALUES A 0 is returned if the call succeeds, -1 if it fails. .Sh ERRORS The call succeeds unless: @@ -80,10 +104,10 @@ process address space. .Sh SEE ALSO .Xr accept 2 , .Xr bind 2 , -.Xr socket 2 , -.Xr getsockname 2 +.Xr getsockname 2 , +.Xr socket 2 .Sh HISTORY The -.Nm +.Fn getpeername function call appeared in .Bx 4.2 . diff --git a/lib/libc/sys/getpgrp.2 b/lib/libc/sys/getpgrp.2 index 88812b7..9780b19 100644 --- a/lib/libc/sys/getpgrp.2 +++ b/lib/libc/sys/getpgrp.2 @@ -67,15 +67,15 @@ are used to get/set the process group of the control terminal. .Xr termios 4 .Sh HISTORY The -.Nm +.Fn getpgrp function call appeared in .Bx 4.0 . .Sh STANDARDS The .Fn getpgrp -function conforms to IEEE Std 1003.1-1988 -.Pq Dq Tn POSIX . -.Sh COMPATABILITY +function call is expected to conform to +.St -p1003.1-90 . +.Sh COMPATIBILITY This version of .Fn getpgrp differs from past Berkeley versions by not taking a @@ -87,15 +87,18 @@ This incompatibility is required by From the .St -p1003.1-88 Rationale: -.sp -4.3BSD provides a +.Pp +.Bx 4.3 +provides a .Fn getpgrp function that returns the process group ID for a specified process. Although this function is used to support job control, all known job-control shells always specify the calling process with this function. -Thus, the simpler System V +Thus, the simpler +.At V .Fn getpgrp -suffices, and the added complexity of the 4.3BSD +suffices, and the added complexity of the +.Bx 4.3 .Fn getpgrp has been omitted from POSIX.1. diff --git a/lib/libc/sys/getpid.2 b/lib/libc/sys/getpid.2 index 5f77706..b57fd60 100644 --- a/lib/libc/sys/getpid.2 +++ b/lib/libc/sys/getpid.2 @@ -30,6 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)getpid.2 8.1 (Berkeley) 6/4/93 +.\" $Id$ .\" .Dd June 4, 1993 .Dt GETPID 2 @@ -63,10 +64,16 @@ and functions are always successful, and no return value is reserved to indicate an error. .Sh SEE ALSO -.Xr gethostid 2 +.Xr gethostid 3 .Sh STANDARDS -.Fn Getpid +The +.Fn getpid and .Fn getppid -conform to IEEE Std 1003.1-1988 -.Pq Dq Tn POSIX . +function calls are expected to conform to +.St -p1003.1-90 . +.Sh HISTORY +A +.Fn getpid +function call appeared in +.At v7 . diff --git a/lib/libc/sys/getpriority.2 b/lib/libc/sys/getpriority.2 index aa151a0..fdb0a1e 100644 --- a/lib/libc/sys/getpriority.2 +++ b/lib/libc/sys/getpriority.2 @@ -137,6 +137,6 @@ A non super-user attempted to lower a process priority. .Xr renice 8 .Sh HISTORY The -.Nm +.Fn getpriority function call appeared in .Bx 4.2 . diff --git a/lib/libc/sys/getrlimit.2 b/lib/libc/sys/getrlimit.2 index 9aa3c8e..651223f 100644 --- a/lib/libc/sys/getrlimit.2 +++ b/lib/libc/sys/getrlimit.2 @@ -60,7 +60,7 @@ parameter is one of the following: .Bl -tag -width RLIMIT_FSIZEAA .It Li RLIMIT_CORE The largest size (in bytes) -.Xr core +.Xr core 5 file that may be created. .It Li RLIMIT_CPU The maximum amount of cpu time (in seconds) to be used by @@ -102,8 +102,8 @@ its resource limit). The structure is used to specify the hard and soft limits on a resource, .Bd -literal -offset indent struct rlimit { - quad_t rlim_cur; /* current (soft) limit */ - quad_t rlim_max; /* hard limit */ + rlim_t rlim_cur; /* current (soft) limit */ + rlim_t rlim_max; /* maximum value for rlim_cur */ }; .Ed .Pp @@ -171,21 +171,13 @@ raised the maximum limit value, and the caller is not the super-user. .El .Sh SEE ALSO .Xr csh 1 , -.Xr quota 2 , +.Xr quota 1 , +.Xr quotactl 2 , .Xr sigaltstack 2 , .Xr sigvec 2 , .Xr sysctl 3 -.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 +.Fn getrlimit function call appeared in .Bx 4.2 . diff --git a/lib/libc/sys/getrusage.2 b/lib/libc/sys/getrusage.2 index 9d1657c..0f92569 100644 --- a/lib/libc/sys/getrusage.2 +++ b/lib/libc/sys/getrusage.2 @@ -38,6 +38,7 @@ .Nm getrusage .Nd get information about resource utilization .Sh SYNOPSIS +.Fd #include <sys/types.h> .Fd #include <sys/time.h> .Fd #include <sys/resource.h> .Fd #define RUSAGE_SELF 0 @@ -62,7 +63,7 @@ the following structure: 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_maxrss; /* 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 */ @@ -93,6 +94,9 @@ 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. +Ticks are statistics clock ticks. +The statistics clock has a frequency of +sysconf(_SC_CLOCK_TCK) ticks per second. .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 @@ -137,10 +141,16 @@ and 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 RETURN VALUES +Uponsuccessful completion, +.Fn getrusage +returns 0. Otherwise, a value of -1 is returned and +.Va errno +is set to indicate the error. .Sh ERRORS -.Fn Getrusage -returns -1 on error. -The possible errors are: +The +.Fn getrusage +function will fail if: .Bl -tag -width Er .It Bq Er EINVAL The @@ -153,12 +163,13 @@ parameter is not in a valid part of the process address space. .El .Sh SEE ALSO .Xr gettimeofday 2 , -.Xr wait 2 +.Xr wait 2 , +.Xr clocks 7 .Sh BUGS There is no way to obtain information about a child process that has not yet terminated. .Sh HISTORY The -.Nm +.Fn getrusage function call appeared in .Bx 4.2 . diff --git a/lib/libc/sys/getsockname.2 b/lib/libc/sys/getsockname.2 index d56e404..df650cb 100644 --- a/lib/libc/sys/getsockname.2 +++ b/lib/libc/sys/getsockname.2 @@ -38,6 +38,8 @@ .Nm getsockname .Nd get socket name .Sh SYNOPSIS +.Fd #include <sys/types.h> +.Fd #include <sys/socket.h> .Ft int .Fn getsockname "int s" "struct sockaddr *name" "int *namelen" .Sh DESCRIPTION @@ -51,7 +53,29 @@ the amount of space pointed to by .Fa name . On return it contains the actual size of the name returned (in bytes). -.Sh DIAGNOSTICS +.Sh IMPLEMENTATION NOTES +.Pp +In the non-threaded library +.Fn getsockname +is implemented as the +.Va getsockname +syscall. +.Pp +In the threaded library, the +.Va getsockname +syscall is assembled to +.Fn _thread_sys_getsockname +and +.Fn getsockname +is implemented as a function which locks +.Va fd +for read and write, then calls +.Fn _thread_sys_getsockname . +Before returning, +.Fn getsockname +unlocks +.Va fd . +.Sh RETURN VALUES A 0 is returned if the call succeeds, -1 if it fails. .Sh ERRORS The call succeeds unless: @@ -82,6 +106,6 @@ Names bound to sockets in the UNIX domain are inaccessible; returns a zero length name. .Sh HISTORY The -.Nm +.Fn getsockname function call appeared in .Bx 4.2 . diff --git a/lib/libc/sys/getsockopt.2 b/lib/libc/sys/getsockopt.2 index 46d3d8a..ba5e6f8 100644 --- a/lib/libc/sys/getsockopt.2 +++ b/lib/libc/sys/getsockopt.2 @@ -29,9 +29,10 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)getsockopt.2 8.3 (Berkeley) 4/19/94 +.\" @(#)getsockopt.2 8.3 (Berkeley) 4/19/94 +.\" $Id$ .\" -.Dd April 19, 1994 +.Dd November 3, 1995 .Dt GETSOCKOPT 2 .Os BSD 4.3r .Sh NAME @@ -189,7 +190,7 @@ is performed. If the socket promises reliable delivery of data and .Dv SO_LINGER is set, the system will block the process on the -.Xr close +.Xr close 2 attempt until it is able to transmit the data or until it decides it is unable to deliver the information (a timeout period, termed the linger interval, is specified in the @@ -200,7 +201,7 @@ is requested). If .Dv SO_LINGER is disabled and a -.Xr close +.Xr close 2 is issued, the system will process the close in a manner that allows the process to continue as quickly as possible. .Pp @@ -214,9 +215,9 @@ With protocols that support out-of-band data, the option requests that out-of-band data be placed in the normal data input queue as received; it will then be accessible with -.Xr recv +.Xr recv 2 or -.Xr read +.Xr read 2 calls without the .Dv MSG_OOB flag. @@ -228,7 +229,11 @@ are options to adjust the normal buffer sizes allocated for output and input buffers, respectively. The buffer size may be increased for high-volume connections, or may be decreased to limit the possible backlog of incoming data. -The system places an absolute limit on these values. +The system places an absolute maximum on these values, which is accessible +through the +.Xr sysctl 3 +MIB variable +.Dq Li kern.maxsockbuf . .Pp .Dv SO_SNDLOWAT is an option to set the minimum count for output operations. @@ -261,7 +266,7 @@ wait until they have received the smaller of the low water mark value or the requested amount. Receive calls may still return less than the low water mark if an error occurs, a signal is caught, or the type of data next in the receive queue -is different than that returned. +is different from that which was returned. .Pp .Dv SO_SNDTIMEO is an option to set a timeout value for output operations. @@ -308,6 +313,49 @@ returns any pending error on the socket and clears the error status. It may be used to check for asynchronous errors on connected datagram sockets or for other asynchronous errors. +.Sh IMPLEMENTATION NOTES +.Pp +In the non-threaded library +.Fn getsockopt +is implemented as the +.Va getsockopt +syscall. +.Pp +In the threaded library, the +.Va getsockopt +syscall is assembled to +.Fn _thread_sys_getsockopt +and +.Fn getsockopt +is implemented as a function which locks +.Va s +for read and write, then calls +.Fn _thread_sys_getsockopt . +Before returning, +.Fn getsockopt +unlocks +.Va s . +.Pp +In the non-threaded library +.Fn setsockopt +is implemented as the +.Va setsockopt +syscall. +.Pp +In the threaded library, the +.Va setsockopt +syscall is assembled to +.Fn _thread_sys_setsockopt +and +.Fn setsockopt +is implemented as a function which locks +.Va s +for read and write, then calls +.Fn _thread_sys_setsockopt . +Before returning, +.Fn setsockopt +unlocks +.Va s . .Sh RETURN VALUES A 0 is returned if the call succeeds, -1 if it fails. .Sh ERRORS @@ -336,12 +384,14 @@ is not in a valid part of the process address space. .Sh SEE ALSO .Xr ioctl 2 , .Xr socket 2 , -.Xr getprotoent 3 -.Xr protocols 5 +.Xr getprotoent 3 , +.Xr sysctl 3 , +.Xr protocols 5 , +.Xr sysctl 8 .Sh BUGS Several of the socket options should be handled at lower levels of the system. .Sh HISTORY The -.Nm +.Fn getsockopt system call appeared in .Bx 4.2 . diff --git a/lib/libc/sys/gettimeofday.2 b/lib/libc/sys/gettimeofday.2 index 9426de6..bc3fa0b 100644 --- a/lib/libc/sys/gettimeofday.2 +++ b/lib/libc/sys/gettimeofday.2 @@ -74,13 +74,13 @@ as: .Pp .Bd -literal struct timeval { - long tv_sec; /* seconds since Jan. 1, 1970 */ + long tv_sec; /* seconds */ long tv_usec; /* and microseconds */ }; struct timezone { - int tz_minuteswest; /* of Greenwich */ - int tz_dsttime; /* type of dst correction to apply */ + int tz_minuteswest; /* minutes west of Greenwich */ + int tz_dsttime; /* type of dst correction */ }; .Ed .Pp @@ -111,9 +111,10 @@ A user other than the super-user attempted to set the time. .Xr date 1 , .Xr adjtime 2 , .Xr ctime 3 , +.Xr clocks 7 , .Xr timed 8 .Sh HISTORY The -.Nm +.Fn gettimeofday function call appeared in .Bx 4.2 . diff --git a/lib/libc/sys/getuid.2 b/lib/libc/sys/getuid.2 index 23b1763..330a3d6 100644 --- a/lib/libc/sys/getuid.2 +++ b/lib/libc/sys/getuid.2 @@ -30,6 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)getuid.2 8.1 (Berkeley) 6/4/93 +.\" $Id$ .\" .Dd June 4, 1993 .Dt GETUID 2 @@ -73,8 +74,16 @@ indicate an error. .Xr getgid 2 , .Xr setreuid 2 .Sh STANDARDS -.Fn Geteuid +The +.Fn geteuid and .Fn getuid -conform to IEEE Std 1003.1-1988 -.Pq Dq Tn POSIX . +function calls are expected to conform to +.St -p1003.1-90 . +.Sh HISTORY +A +.Fn getuid +and a +.Fn geteuid +function call appeared in +.At v7 . diff --git a/lib/libc/sys/intro.2 b/lib/libc/sys/intro.2 index bf43809..665bca6 100644 --- a/lib/libc/sys/intro.2 +++ b/lib/libc/sys/intro.2 @@ -46,13 +46,49 @@ their error returns, and other common definitions and concepts. .\".Sy System call restart .\".Pp .\"<more later...> -.Sh DIAGNOSTICS -Nearly all of the system calls provide an error number in the external -variable -.Va errno , -which is defined as: +.Sh RETURN VALUES +Nearly all of the system calls provide an error number referenced via +the external identifier errno. This identifier is defined in +.Aq Pa sys/errno.h +for non-threaded programs as: .Pp -.Dl extern int errno +.Dl extern int errno; +.Pp +and for threaded programs as: +.Pp +.Dl extern int * __error(); +.Dl #define errno (* __error()) +.Pp +A threaded program must be compiled with +.Va _THREAD_SAFE +defined so that the preprocessor will output the appropriate errno +definition to the compiler. Failure to do so will mean that error +variables will not be thread specific. +.Pp +The threaded library implementation of +.Va __error() +returns a pointer to a field in the thread specific structure for +threads other than the initial thread. For the initial thread, +.Va __error() +returns a pointer to a global +.Va errno +variable that is compatible with that used by non-threaded programs. +This allows the initial thread to call functions in libraries which have +not been compiled with +.Va _THREAD_SAFE . +Programmers should ensure that threads other than the initial thread only +call functions in libraries that have been compiled with +.Va _THREAD_SAFE . +.Pp +Programmers should include +.Aq Pa sys/errno.h to obtain the definition of +.Va errno +rather than coding the definition as an external reference directly. It is +planned that the +.Va extern int errno +definition will eventually be replaced by the threaded definition so that +all libraries will have a thread-aware treatment of +.Va errno . .Pp When a system call detects an error, it returns an integer value @@ -108,7 +144,7 @@ loaded on a drive. .It Er 7 E2BIG Em "Arg list too long" . The number of bytes used for the argument and environment list of the new process exceeded the current limit -of 20480 bytes +of 65536 bytes .Pf ( Dv NCARGS in .Aq Pa sys/param.h ) . @@ -123,9 +159,9 @@ or a read (write) request was made to a file that was only open for writing (reading). .It Er 10 ECHILD Em "\&No child processes" . A -.Xr wait +.Xr wait 2 or -.Xr waitpid +.Xr waitpid 2 function was executed by a process that had no existing or unwaited-for child processes. .It Er 11 EDEADLK Em "Resource deadlock avoided" . @@ -151,7 +187,7 @@ in a manner which would have conflicted with the request. .It Er 17 EEXIST Em "File exists" . An existing file was mentioned in an inappropriate context, for instance, as the new link name in a -.Xr link +.Xr link 2 function. .It Er 18 EXDEV Em "Improper link" . A hard link to a file on another file system @@ -169,9 +205,9 @@ An attempt was made to open a directory with write mode specified. .It Er 22 EINVAL Em "Invalid argument" . Some invalid argument was supplied. (For example, specifying an undefined signal to a -.Xr signal +.Xr signal 3 or -.Xr kill +.Xr kill 2 function). .It Er 23 ENFILE Em "Too many open files in system" . Maximum number of file descriptors allowable on the system @@ -191,7 +227,7 @@ special device for which the operation was inappropriate. The new process was a pure procedure (shared text) file which was open for writing by another process, or while the pure procedure file was being executed an -.Xr open +.Xr open 2 call requested write access. .It Er 27 EFBIG Em "File too large" . The size of a file exceeded the maximum (about @@ -200,7 +236,7 @@ The size of a file exceeded the maximum (about bytes). .It Er 28 ENOSPC Em "Device out of space" . A -.Xr write +.Xr write 2 to an ordinary file, the creation of a directory or symbolic link, or the creation of a directory entry failed because no more disk blocks were available @@ -209,7 +245,7 @@ created file failed because no more inodes were available on the file system. .It Er 29 ESPIPE Em "Illegal seek" . An -.Xr lseek +.Xr lseek 2 function was issued on a socket, pipe or .Tn FIFO . .It Er 30 EROFS Em "Read-only file system" . @@ -308,12 +344,12 @@ An operation on a socket or pipe was not performed because the system lacked sufficient buffer space or because a queue was full. .It Er 56 EISCONN Em "Socket is already connected" . A -.Xr connect +.Xr connect 2 request was made on an already connected socket; or, a -.Xr sendto +.Xr sendto 2 or -.Xr sendmsg +.Xr sendmsg 2 request on a connected socket specified a destination when already connected. .It Er 57 ENOTCONN Em "Socket is not connected" . @@ -327,9 +363,9 @@ had already been shut down with a previous call. .It Er 60 ETIMEDOUT Em "Operation timed out" . A -.Xr connect +.Xr connect 2 or -.Xr send +.Xr send 2 request failed because the connected party did not properly respond after a period of time. (The timeout period is dependent on the communication protocol.) @@ -361,7 +397,7 @@ was supplied to a remove directory or rename call. The quota system ran out of table entries. .It Er 69 EDQUOT Em "Disc quota exceeded" . A -.Xr write +.Xr write 2 to an ordinary file, the creation of a directory or symbolic link, or the creation of a directory entry failed because the user's quota of disk blocks was @@ -414,7 +450,7 @@ A new process is created by a currently active process; (see The parent process ID of a process is initially the process ID of its creator. If the creating process exits, the parent process ID of each child is set to the ID of a system process, -.Xr init . +.Xr init 8 . .It Process Group Each active process is a member of a process group that is identified by a non-negative integer called the process group ID. This is the process @@ -461,7 +497,7 @@ as the group, but is in a different process group. Note that when a process exits, the parent process for its children is changed to be -.Xr init , +.Nm init , which is in a separate session. Not all members of an orphaned process group are necessarily orphaned processes (those whose creating process has exited). @@ -550,8 +586,7 @@ excluding 0 (NUL) and the .Tn ASCII code for .Ql \&/ -(slash). (The parity bit, -bit 7, must be 0.) +(slash). .Pp Note that it is generally unwise to use .Ql \&* , @@ -665,4 +700,5 @@ of a certain format. An Address Family is the set of addresses for a specific group of protocols. Each socket has an address chosen from the address family in which the socket was created. .Sh SEE ALSO -intro(3), perror(3) +.Xr intro 3 , +.Xr perror 3 diff --git a/lib/libc/sys/ioctl.2 b/lib/libc/sys/ioctl.2 index 36ce6ff..a1d5f79 100644 --- a/lib/libc/sys/ioctl.2 +++ b/lib/libc/sys/ioctl.2 @@ -68,6 +68,28 @@ Macros and defines used in specifying an ioctl .Fa request are located in the file .Ao Pa sys/ioctl.h Ac . +.Sh IMPLEMENTATION NOTES +.Pp +In the non-threaded library +.Fn ioctl +is implemented as the +.Va ioctl +syscall. +.Pp +In the threaded library, the +.Va ioctl +syscall is assembled to +.Fn _thread_sys_ioctl +and +.Fn ioctl +is implemented as a function which locks +.Va d +for read and write, then calls +.Fn _thread_sys_ioctl . +Before returning, +.Fn ioctl +unlocks +.Va d . .Sh RETURN VALUES If an error has occurred, a value of -1 is returned and .Va errno @@ -98,9 +120,10 @@ is not valid. .Xr mt 1 , .Xr execve 2 , .Xr fcntl 2 , -.Xr tty 4 , -.Xr intro 4 +.Xr intro 4 , +.Xr tty 4 .Sh HISTORY An -.Nm -function call appeared in Version 7 AT&T UNIX. +.Fn ioctl +function call appeared in +.At v7 . diff --git a/lib/libc/sys/kill.2 b/lib/libc/sys/kill.2 index a20afd3..bb6defc 100644 --- a/lib/libc/sys/kill.2 +++ b/lib/libc/sys/kill.2 @@ -30,6 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)kill.2 8.3 (Berkeley) 4/19/94 +.\" $Id$ .\" .Dd April 19, 1994 .Dt KILL 2 @@ -119,13 +120,17 @@ 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 getpid 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 . +function call is expected to conform to +.St -p1003.1-90 . +.Sh HISTORY +A +.Fn kill +function call appeared in +.At v7 . diff --git a/lib/libc/sys/ktrace.2 b/lib/libc/sys/ktrace.2 index 9fe61f8..8f41a52 100644 --- a/lib/libc/sys/ktrace.2 +++ b/lib/libc/sys/ktrace.2 @@ -30,6 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)ktrace.2 8.1 (Berkeley) 6/4/93 +.\" $Id$ .\" .Dd June 4, 1993 .Dt KTRACE 2 @@ -38,7 +39,9 @@ .Nm ktrace .Nd process tracing .Sh SYNOPSIS -.Fd #include <sys/types.h> +.Fd #include <sys/param.h> +.Fd #include <sys/time.h> +.Fd #include <sys/uio.h> .Fd #include <sys/ktrace.h> .Ft int .Fn ktrace "const char *tracefile" "int ops" "int trpoints" "int pid" @@ -52,7 +55,7 @@ Only the super-user can trace setuid or setgid programs. The .Ar tracefile gives the pathname of the file to be used for tracing. -The file must exist and be writable by the calling process. +The file must exist and be a regular file writable by the calling process. All trace records are always appended to the file, so the file must be truncated to zero length to discard previous trace data. @@ -138,8 +141,6 @@ 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. @@ -153,8 +154,8 @@ Too many symbolic links were encountered in translating the pathname. An I/O error occurred while reading from or writing to the file system. .El .Sh SEE ALSO -.Xr ktrace 1 , -.Xr kdump 1 +.Xr kdump 1 , +.Xr ktrace 1 .Sh HISTORY A .Nm ktrace diff --git a/lib/libc/sys/link.2 b/lib/libc/sys/link.2 index d160786..e0bc45e 100644 --- a/lib/libc/sys/link.2 +++ b/lib/libc/sys/link.2 @@ -30,6 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)link.2 8.3 (Berkeley) 1/12/94 +.\" $Id$ .\" .Dd January 12, 1994 .Dt LINK 2 @@ -74,7 +75,6 @@ both 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 @@ -88,8 +88,6 @@ will fail and no link will be created if: .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. @@ -113,8 +111,7 @@ does exist. .It Bq Er EPERM The file named by .Fa name1 -is a directory and the effective -user ID is not super-user. +is a directory. .It Bq Er EXDEV The link named by .Fa name2 @@ -145,7 +142,18 @@ is outside the process's allocated address space. .Xr symlink 2 , .Xr unlink 2 .Sh STANDARDS -.Fn Link -is expected to -conform to IEEE Std 1003.1-1988 -.Pq Dq Tn POSIX . +The +.Fn link +function call is expected to conform to +.St -p1003.1-90 . +.Sh HISTORY +A +.Fn link +function call appeared in +.At v7 . +.Pp +The +.Fn link +system call traditionally allows the super-user to link directories which +corrupts the filesystem coherency. This implementation no longer permits +it. diff --git a/lib/libc/sys/listen.2 b/lib/libc/sys/listen.2 index 0dd2060..2319031 100644 --- a/lib/libc/sys/listen.2 +++ b/lib/libc/sys/listen.2 @@ -29,9 +29,10 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)listen.2 8.2 (Berkeley) 12/11/93 +.\" From: @(#)listen.2 8.2 (Berkeley) 12/11/93 +.\" $Id$ .\" -.Dd December 11, 1993 +.Dd November 3, 1995 .Dt LISTEN 2 .Os BSD 4.2 .Sh NAME @@ -68,6 +69,41 @@ 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. +.Pp +The +.Xr sysctl 3 +MIB variable +.Dq Li kern.somaxconn +specifies a hard limit on +.Fa backlog ; +if a value greater than +.Li kern.somaxconn +or less than zero is specified, +.Fa backlog +is silently forced to +.Li kern.somaxconn . +.Sh IMPLEMENTATION NOTES +.Pp +In the non-threaded library +.Fn listen +is implemented as the +.Va listen +syscall. +.Pp +In the threaded library, the +.Va listen +syscall is assembled to +.Fn _thread_sys_listen +and +.Fn listen +is implemented as a function which locks +.Va s +for read and write, then calls +.Fn _thread_sys_listen . +Before returning, +.Fn listen +unlocks +.Va s . .Sh RETURN VALUES A 0 return value indicates success; -1 indicates an error. .Sh ERRORS @@ -89,13 +125,17 @@ The socket is not of a type that supports the operation .Sh SEE ALSO .Xr accept 2 , .Xr connect 2 , -.Xr socket 2 -.Sh BUGS -The -.Fa backlog -is currently limited (silently) to 5. +.Xr socket 2 , +.Xr sysctl 3 , +.Xr sysctl 8 .Sh HISTORY The -.Nm +.Fn listen function call appeared in .Bx 4.2 . +The ability to configure the maximum +.Fa backlog +at run-time, and to use a negative +.Fa backlog +to request the maximum allowable value, was introduced in +.Fx 2.2 . diff --git a/lib/libc/sys/lseek.2 b/lib/libc/sys/lseek.2 index ef38451..39a37fa 100644 --- a/lib/libc/sys/lseek.2 +++ b/lib/libc/sys/lseek.2 @@ -30,6 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)lseek.2 8.3 (Berkeley) 4/19/94 +.\" $Id$ .\" .Dd April 19, 1994 .Dt LSEEK 2 @@ -56,7 +57,8 @@ The argument must be an open file descriptor. .Fn Lseek -repositions the file pointer +repositions the file position pointer associated with the file +descriptor .Fa fildes as follows: .Bl -item -offset indent @@ -108,7 +110,7 @@ is set to indicate the error. .Sh ERRORS .Fn Lseek -will fail and the file pointer will remain unchanged if: +will fail and the file position pointer will remain unchanged if: .Bl -tag -width [EINVAL] .It Bq Er EBADF .Em Fildes @@ -130,6 +132,10 @@ is incorrect English, but is maintained for historical reasons. .Sh STANDARDS The .Fn lseek -function -conforms to IEEE Std 1003.1-1988 -.Pq Dq Tn POSIX . +function call is expected to conform to +.St -p1003.1-90 . +.Sh HISTORY +A +.Fn lseek +function call appeared in +.At v7 . diff --git a/lib/libc/sys/lseek.c b/lib/libc/sys/lseek.c index 52208d1..8896ad8 100644 --- a/lib/libc/sys/lseek.c +++ b/lib/libc/sys/lseek.c @@ -37,6 +37,11 @@ static char sccsid[] = "@(#)lseek.c 8.1 (Berkeley) 6/17/93"; #include <sys/types.h> #include <sys/syscall.h> +#include <unistd.h> +#ifdef _THREAD_SAFE +#include <pthread.h> +#include "pthread_private.h" +#endif /* * This function provides 64-bit offset padding that @@ -48,7 +53,17 @@ lseek(fd, offset, whence) off_t offset; int whence; { - extern off_t __syscall(); +#ifdef _THREAD_SAFE + off_t offs; + if (_thread_fd_lock(fd, FD_RDWR, NULL,__FILE__,__LINE__) != 0) { + offs = -1; + } else { + offs = __syscall((quad_t) SYS_lseek,fd, 0, offset, whence); + _thread_fd_unlock(fd, FD_RDWR); + } + return(offs); +#else return(__syscall((quad_t)SYS_lseek, fd, 0, offset, whence)); +#endif } diff --git a/lib/libc/sys/madvise.2 b/lib/libc/sys/madvise.2 index d0676ab..fc71765 100644 --- a/lib/libc/sys/madvise.2 +++ b/lib/libc/sys/madvise.2 @@ -30,15 +30,19 @@ .\" SUCH DAMAGE. .\" .\" @(#)madvise.2 8.1 (Berkeley) 6/9/93 +.\" $Id$ .\" -.Dd June 9, 1993 +.Dd Jul 19, 1996 .Dt MADVISE 2 .Os .Sh NAME .Nm madvise .Nd give advise about use of memory .Sh SYNOPSIS -.Fn madvise "caddr_t addr" "int len" "int behav" +.Fd #include <sys/types.h> +.Fd #include <sys/mman.h> +.Ft int +.Fn madvise "caddr_t addr" "size_t len" "int behav" .Sh DESCRIPTION The .Fn madvise @@ -46,21 +50,78 @@ system call allows a process that has knowledge of its memory behavior to describe it to the system. The known behaviors are given in -.Pa <sys/mman.h> : +.Aq Pa sys/mman.h : .Bd -literal -#define MADV_NORMAL 0 /* no further special treatment */ -#define MADV_RANDOM 1 /* expect random page references */ -#define MADV_SEQUENTIAL 2 /* expect sequential references */ -#define MADV_WILLNEED 3 /* will need these pages */ -#define MADV_DONTNEED 4 /* don't need these pages */ -#define MADV_SPACEAVAIL 5 /* insure that resources are reserved */ +#define MADV_NORMAL 0 /* no further special treatment */ +#define MADV_RANDOM 1 /* expect random page references */ +#define MADV_SEQUENTIAL 2 /* expect sequential references */ +#define MADV_WILLNEED 3 /* will need these pages */ +#define MADV_DONTNEED 4 /* don't need these pages */ +#define MADV_FREE 5 /* data is now unimportant */ .Ed +.Pp +.Bl -tag -width MADV_SEQUENTIAL +.It Dv MADV_NORMAL +Tells the system to revert to the default paging +behavior. +.It Dv MADV_RANDOM +Is a hint that pages will be accessed randomly, and prefetching +is likely not advantageous. +.It Dv MADV_SEQUENTIAL +Causes the VM system to depress the priority of +pages immediately preceeding a given page when it is faulted in. +.It Dv MADV_WILLNEED +Causes pages that are in a given virtual address range +to temporarily have higher priority, and if they are in +memory, decrease the likelihood of them being freed. Additionally, +the pages that are already in memory will be immediately mapped into +the process, thereby eliminating unnecessary overhead of going through +the entire process of faulting the pages in. This WILL NOT fault +pages in from backing store, but quickly map the pages already in memory +into the calling process. +.It Dv MADV_DONTNEED +Allows the VM system to decrease the in-memory priority +of pages in the specified range. Additionally future references to +this address range will incur a page fault. +.Dv MADV_FREE +gives the VM system the freedom to free pages, +and tells the system that information in the specified page range +is no longer important. This is an efficient way of allowing +.Xr malloc 3 +to free pages anywhere in the address space, while keeping the address space +valid. The next time that the page is referenced, the page might be demand +zeroed, or might contain the data that was there before the +.Dv MADV_FREE +call. +References made to that address space range will not make the VM system +page the information back in from backing store until the page is +modified again. +.El +.Sh RETURN VALUES +Upon successful completion, +.Fn madvise +returns 0. Otherwise a value of -1 is returned and +.Va errno +is set to indicate the error. +.Sh ERRORS +The +.Fn madvise +function will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +The virtual address range specified by the +.Fa addr +and +.Fa len +arguments is not valid. +.El .Sh SEE ALSO -.Xr msync 2 , -.Xr munmap 2 , +.Xr mincore 2 , .Xr mprotect 2 , -.Xr mincore 2 +.Xr msync 2 , +.Xr munmap 2 . .Sh HISTORY The -.Nm madvise -function first appeared in 4.4BSD. +.Fn madvise +function first appeared in +.Bx 4.4 . diff --git a/lib/libc/sys/mincore.2 b/lib/libc/sys/mincore.2 index 4e73c2a..9c694f4 100644 --- a/lib/libc/sys/mincore.2 +++ b/lib/libc/sys/mincore.2 @@ -30,6 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)mincore.2 8.1 (Berkeley) 6/9/93 +.\" $Id$ .\" .Dd June 9, 1993 .Dt MINCORE 2 @@ -38,7 +39,10 @@ .Nm mincore .Nd get advise about use of memory .Sh SYNOPSIS -.Fn mincore "caddr_t addr" "int len" "char *vec" +.Fd #include <sys/types.h> +.Fd #include <sys/mman.h> +.Ft int +.Fn mincore "caddr_t addr" "size_t len" "char *vec" .Sh DESCRIPTION The .Fn mincore @@ -50,12 +54,35 @@ in the character array .Fa vec , with a value of 1 meaning that the page is in-core. +.Sh RETURN VALUES +Upson successful completion, +.Fn mincore +returns 0 and +.Fa vec +is updated to relect the page status. Otherwise a value of -1 +is returned and +.Va error +is set to indicate the error. +.Sh ERRORS +.Bl -tag -width Er +.It Bq Er EINVAL +The virtial address range specified by the +.Fa addr +and +.Fa len +arguments is not valid. +.It Bq Er EFAULT +The +.Fa vec +argument points to an illegal address. +.El .Sh SEE ALSO -.Xr msync 2 , -.Xr munmap 2 , -.Xr mprotect 2 , .Xr madvise 2 , +.Xr mprotect 2 , +.Xr msync 2 , +.Xr munmap 2 .Sh HISTORY The .Fn mincore -function first appeared in 4.4BSD. +function first appeared in +.Bx 4.4 . diff --git a/lib/libc/sys/minherit.2 b/lib/libc/sys/minherit.2 new file mode 100644 index 0000000..a8ebed3 --- /dev/null +++ b/lib/libc/sys/minherit.2 @@ -0,0 +1,94 @@ +.\" $Id$ +.\" +.\" Copyright (c) 1991, 1993 +.\" 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. +.\" +.\" @(#)minherit.2 8.1 (Berkeley) 6/9/93 +.\" +.Dd Feb 17, 1996 +.Dt MINHERIT 2 +.Os +.Sh NAME +.Nm minherit +.Nd control the inheritance of pages +.Sh SYNOPSIS +.Fd #include <sys/types.h> +.Fd #include <sys/mman.h> +.Ft int +.Fn minherit "caddr_t addr" "size_t len" "int inherit" +.Sh DESCRIPTION +The +.Fn minherit +system call +changes the specified pages to have the inheritance characteristic +.Fa inherit . +Not all implementations will guarantee that the inheritance characteristic +can be set on a page basis; +the granularity of changes may be as large as an entire region. +.Sh RETURN VALUES +Upon successful completion, +.Fn minherit +returns 0. Otherwise, a value of -1 is returned and +.Va errno +is set to indicate the error. +.Sh ERRORS +The +.Fn minherit +function will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +The virtual address range specified by the +.Fa addr +and +.Fa len +arguments is not valid. +.It Bq Er EACESS +The flags specified by the +.Fa inherit +argument were not valid for the pages specified +by the +.Fa addr +and +.Fa len +arguments. +.El +.Sh SEE ALSO +.Xr fork 2 , +.Xr madvise 2 , +.Xr mincore 2 , +.Xr mprotect 2 , +.Xr msync 2 , +.Xr munmap 2 , +.Xr rfork 2 +.Sh HISTORY +The +.Fn minherit +function first appeared in OpenBSD. diff --git a/lib/libc/sys/mkdir.2 b/lib/libc/sys/mkdir.2 index 4bf11be..1dc6ef5 100644 --- a/lib/libc/sys/mkdir.2 +++ b/lib/libc/sys/mkdir.2 @@ -30,6 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)mkdir.2 8.2 (Berkeley) 12/11/93 +.\" $Id$ .\" .Dd December 11, 1993 .Dt MKDIR 2 @@ -46,7 +47,7 @@ The directory .Fa path is created with the access permissions specified by .Fa mode -and restricted by the the +and restricted by the .Xr umask 2 of the calling process. .Pp @@ -63,8 +64,6 @@ 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. @@ -108,6 +107,7 @@ points outside the process's allocated address space. .Xr stat 2 , .Xr umask 2 .Sh STANDARDS -.Fn Mkdir -conforms to IEEE Std 1003.1-1988 -.Pq Dq Tn POSIX . +The +.Fn mkdir +function call is expected to conform to +.St -p1003.1-90 . diff --git a/lib/libc/sys/mkfifo.2 b/lib/libc/sys/mkfifo.2 index 6f7686e..b39bf9c 100644 --- a/lib/libc/sys/mkfifo.2 +++ b/lib/libc/sys/mkfifo.2 @@ -67,8 +67,6 @@ will fail and no fifo will be created if: The kernel has not been configured to support fifo's. .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. @@ -115,10 +113,11 @@ points outside the process's allocated address space. .El .Sh SEE ALSO .Xr chmod 2 , +.Xr mknod 2, .Xr stat 2 , .Xr umask 2 .Sh STANDARDS The -.Nm mkfifo -function call conforms to -.St -p1003.1-88 . +.Fn mkfifo +function call is expected to conform to +.St -p1003.1-90 . diff --git a/lib/libc/sys/mknod.2 b/lib/libc/sys/mknod.2 index d77ccbc..2db4f45 100644 --- a/lib/libc/sys/mknod.2 +++ b/lib/libc/sys/mknod.2 @@ -77,8 +77,6 @@ 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. @@ -119,9 +117,11 @@ points outside the process's allocated address space. .El .Sh SEE ALSO .Xr chmod 2 , +.Xr mkfifo 2 , .Xr stat 2 , .Xr umask 2 .Sh HISTORY A -.Nm -function call appeared in Version 6 AT&T UNIX. +.Fn mknod +function call appeared in +.At v6 . diff --git a/lib/libc/sys/mlock.2 b/lib/libc/sys/mlock.2 index 90bb7c7..15ce741 100644 --- a/lib/libc/sys/mlock.2 +++ b/lib/libc/sys/mlock.2 @@ -47,7 +47,7 @@ .Fn munlock "caddr_t addr" "size_t len" .Sh DESCRIPTION The -.Nm mlock +.Fn mlock system call locks into memory the physical pages associated with the virtual address range starting at @@ -56,9 +56,9 @@ for .Fa len bytes. The -.Nm munlock +.Fn munlock call unlocks pages previously locked by one or more -.Nm mlock +.Fn mlock calls. For both, the .Fa addr @@ -70,7 +70,7 @@ to be so. The entire range must be allocated. .Pp After an -.Nm mlock +.Fn mlock call, the indicated pages will cause neither a non-resident page nor address-translation fault until they are unlocked. They may still cause protection-violation faults or TLB-miss faults on @@ -81,12 +81,12 @@ Multiple processes may have the same physical pages locked via their own virtual address mappings. A single process may likewise have pages multiply-locked via different virtual mappings of the same pages or via nested -.Nm mlock +.Fn mlock calls on the same address range. Unlocking is performed explicitly by -.Nm munlock +.Fn munlock or implicitly by a call to -.Nm munmap +.Fn munmap which deallocates the unmapped address range. Locked mappings are not inherited by the child process after a .Xr fork 2 . @@ -94,7 +94,7 @@ Locked mappings are not inherited by the child process after a Since physical memory is a potentially scarce resource, processes are limited in how much they can lock down. A single process can -.Nm mlock +.Fn mlock the minimum of a system-wide ``wired pages'' limit and the per-process @@ -138,11 +138,11 @@ Some portion of the indicated address range is not locked. .Xr getpagesize 3 .Sh BUGS Unlike The Sun implementation, multiple -.Nm mlock +.Fn mlock calls on the same address range require the corresponding number of -.Nm munlock +.Fn munlock calls to actually unlock the pages, i.e. -.Nm mlock +.Fn mlock nests. This should be considered a consequence of the implementation and not a feature. @@ -158,4 +158,5 @@ The .Fn mlock and .Fn munlock -functions first appeared in 4.4BSD. +functions first appeared in +.Bx 4.4 . diff --git a/lib/libc/sys/mmap.2 b/lib/libc/sys/mmap.2 index 1c0d84a..855a032 100644 --- a/lib/libc/sys/mmap.2 +++ b/lib/libc/sys/mmap.2 @@ -44,7 +44,7 @@ .Fn mmap "caddr_t addr" "size_t len" "int prot" "int flags" "int fd" "off_t offset" .Sh DESCRIPTION The -.Nm mmap +.Fn mmap function causes the pages starting at .Fa addr and continuing for at most @@ -113,7 +113,7 @@ region. Do not permit the system to select a different address than the one specified. If the specified address cannot be used, -.Nm mmap +.Fn mmap will fail. If MAP_FIXED is specified, .Fa addr @@ -124,7 +124,7 @@ Notify the kernel that the region may contain semaphores and that special handling may be necessary. .It Dv MAP_INHERIT Permit regions to be inherited across -.Xr exec 2 +.Xr execve 2 system calls. .It Dv MAP_PRIVATE Modifications are private. @@ -147,9 +147,9 @@ the file descriptor argument specifies a file or device to which swapping should be done. .Sh RETURN VALUES Upon successful completion, -.Nm mmap +.Fn mmap returns a pointer to the mapped region. -Otherwise, a value of -1 is returned and +Otherwise, a value of MAP_FAILED is returned and .Va errno is set to indicate the error. .Sh ERRORS @@ -180,20 +180,28 @@ was not open for writing. .It Bq Er EBADF .Fa Fd is not a valid open file descriptor. -.\".It Bq Er EINVAL -.\"One of -.\".Dv MAP_ANON -.\"or -.\".Dv MAP_FILE -.\"was not specified as part of the -.\".Fa flags -.\"parameter. +.It Bq Er EINVAL .Dv MAP_FIXED was specified and the -.I addr -parameter was not page aligned. -.Fa Fd +.Fa addr +parameter was not page aligned, or part of the desired address space +resides out of the valid address space for a user process. +.It Bq Er EINVAL +.Fa Len +was negative. +.It Bq Er EINVAL +.Dv MAP_ANON +was specified and the +.Fa fd +parameter was not -1. +.It Bq Er EINVAL +.Dv MAP_ANON +has not been specified and +.Fa fd did not reference a regular or character special file. +.It Bq Er EINVAL +.Fa Offset +was not page-aligned. (See BUGS below.) .It Bq Er ENOMEM .Dv MAP_FIXED was specified and the @@ -202,9 +210,29 @@ parameter wasn't available. .Dv MAP_ANON was specified and insufficient memory was available. .Sh "SEE ALSO" -.Xr getpagesize 2 , +.Xr madvise 2 , +.Xr mincore 2 , +.Xr mlock 2 , +.Xr mprotect 2 , .Xr msync 2 , +.Xr munlock 2 , .Xr munmap 2 , -.Xr mprotect 2 , -.Xr madvise 2 , -.Xr mincore 2 +.Xr getpagesize 3 + +.Sh BUGS +.Ar len +is limited to 2GB. Mmapping slightly more than 2GB doesn't work, but +it is possible to map a window of size (filesize % 2GB) for file sizes +of slightly less than 2G, 4GB, 6GB and 8GB. + +The limit is imposed for a variety of reasons. Most of them have to do +with FreeBSD not wanting to use 64 bit offsets in the VM system due to +the extreme performance penalty. So FreeBSD uses 32bit page indexes and +this gives FreeBSD a maximum of 8TB filesizes. It's actually bugs in +the filesystem code that causes the limit to be further restricted to +1TB (loss of precision when doing blockno calculations). + +Another reason for the 2GB limit is that filesystem metadata can +reside at negative offsets. + +We currently can only deal with page aligned file offsets. diff --git a/lib/libc/sys/mount.2 b/lib/libc/sys/mount.2 index 6829a3e..4ee86a6 100644 --- a/lib/libc/sys/mount.2 +++ b/lib/libc/sys/mount.2 @@ -83,10 +83,20 @@ Even the super-user may not write on it. Do not allow files to be executed from the filesystem. .It Dv MNT_NOSUID Do not honor setuid or setgid bits on files when executing them. +.It Dv MNT_NOATIME +Disable update of file access times. .It Dv MNT_NODEV Do not interpret special files on the filesystem. .It Dv MNT_SYNCHRONOUS All I/O to the filesystem should be done synchronously. +.It Dv MNT_ASYNC +All I/O to the filesystem should be done asynchronously. +.It Dv MNT_WANTRDWR +Upgrade a mounted read-only filesystem to read-write if MNT_UPDATE +is also specified. +.It Dv MNT_FORCE +Fore a read-write mount even if the filesystem appears to be unclean. +Dangerous. .El .Pp The flag @@ -97,7 +107,12 @@ This allows the mount flags to be changed without requiring that the filesystem be unmounted and remounted. Some filesystems may not allow all flags to be changed. For example, -most filesystems will not allow a change from read-write to read-only. +many filesystems will not allow a change from read-write to read-only. +.Pp +The flag +.Dv MNT_RELOAD +causes the vfs subsystem to update its data structures pertaining to +the specified already mounted filesystem. .Pp The .Fa type @@ -110,36 +125,150 @@ specific arguments to mount. The currently supported types of filesystems and their type specific data are: .Pp +.Bd -literal -compact +/* + * Export arguments for local filesystem mount calls. + */ +struct export_args { + int ex_flags; /* export related flags */ + uid_t ex_root; /* mapping for root uid */ + struct ucred ex_anon; /* mapping for anonymous user */ + struct sockaddr *ex_addr; /* net address to which exported */ + int ex_addrlen; /* and the net address length */ + struct sockaddr *ex_mask; /* mask of valid bits in saddr */ + int ex_masklen; /* and the smask length */ +}; +.Ed +.Pp .Dv MOUNT_UFS -.Bd -literal -offset indent -compact +.Pp +.Bd -literal -compact +/* + * Arguments to mount UFS-bases filesystems + */ struct ufs_args { - char *fspec; /* Block special file to mount */ - int exflags; /* export related flags */ - uid_t exroot; /* mapping for root uid */ + char *fspec; /* Block special file to mount */ + struct export_args export; /* network export information */ }; .Ed .Pp .Dv MOUNT_NFS -.Bd -literal -offset indent -compact +.Pp +.Bd -literal -compact +#ifdef NFS +/* + * Arguments to mount NFS + */ + +#define NFS_ARGSVERSION 3 /* change when nfs_args changes */ 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 */ + int version; /* args structure version number */ + struct sockaddr *addr; /* file server address */ + int addrlen; /* length of address */ + int sotype; /* Socket type */ + int proto; /* and Protocol */ + u_char *fh; /* File handle to be mounted */ + int fhsize; /* Size, in bytes, of fh */ + int flags; /* flags */ + int wsize; /* write size in bytes */ + int rsize; /* read size in bytes */ + int readdirsize; /* readdir size in bytes */ + int timeo; /* initial timeout in .1 secs */ + int retrans; /* times to retry send */ + int maxgrouplist; /* Max. size of group list */ + int readahead; /* # of blocks to readahead */ + int leaseterm; /* Term (sec) of lease */ + int deadthresh; /* Retrans threshold */ + char *hostname; /* server's name */ }; + +/* + * NFS mount option flags + */ +#define NFSMNT_SOFT 0x00000001 /* soft mount (hard is default) */ +#define NFSMNT_WSIZE 0x00000002 /* set write size */ +#define NFSMNT_RSIZE 0x00000004 /* set read size */ +#define NFSMNT_TIMEO 0x00000008 /* set initial timeout */ +#define NFSMNT_RETRANS 0x00000010 /* set number of request retries */ +#define NFSMNT_MAXGRPS 0x00000020 /* set maximum grouplist size */ +#define NFSMNT_INT 0x00000040 /* allow interrupts on hard mount */ +#define NFSMNT_NOCONN 0x00000080 /* Don't Connect the socket */ +#define NFSMNT_NQNFS 0x00000100 /* Use Nqnfs protocol */ +#define NFSMNT_NFSV3 0x00000200 /* Use NFS Version 3 protocol */ +#define NFSMNT_KERB 0x00000400 /* Use Kerberos authentication */ +#define NFSMNT_DUMBTIMR 0x00000800 /* Don't estimate rtt dynamically */ +#define NFSMNT_LEASETERM 0x00001000 /* set lease term (nqnfs) */ +#define NFSMNT_READAHEAD 0x00002000 /* set read ahead */ +#define NFSMNT_DEADTHRESH 0x00004000 /* set dead server retry thresh */ +#define NFSMNT_RESVPORT 0x00008000 /* Allocate a reserved port */ +#define NFSMNT_RDIRPLUS 0x00010000 /* Use Readdirplus for V3 */ +#define NFSMNT_READDIRSIZE 0x00020000 /* Set readdir size */ +#define NFSMNT_INTERNAL 0xfffc0000 /* Bits set internally */ +#define NFSMNT_HASWRITEVERF 0x00040000 /* Has write verifier for V3 */ +#define NFSMNT_GOTPATHCONF 0x00080000 /* Got the V3 pathconf info */ +#define NFSMNT_GOTFSINFO 0x00100000 /* Got the V3 fsinfo */ +#define NFSMNT_MNTD 0x00200000 /* Mnt server for mnt point */ +#define NFSMNT_DISMINPROG 0x00400000 /* Dismount in progress */ +#define NFSMNT_DISMNT 0x00800000 /* Dismounted */ +#define NFSMNT_SNDLOCK 0x01000000 /* Send socket lock */ +#define NFSMNT_WANTSND 0x02000000 /* Want above */ +#define NFSMNT_RCVLOCK 0x04000000 /* Rcv socket lock */ +#define NFSMNT_WANTRCV 0x08000000 /* Want above */ +#define NFSMNT_WAITAUTH 0x10000000 /* Wait for authentication */ +#define NFSMNT_HASAUTH 0x20000000 /* Has authenticator */ +#define NFSMNT_WANTAUTH 0x40000000 /* Wants an authenticator */ +#define NFSMNT_AUTHERR 0x80000000 /* Authentication error */ +#endif /* NFS */ .Ed .Pp .Dv MOUNT_MFS -.Bd -literal -offset indent -compact +.Pp +.Bd -literal -compact +/* + * Arguments to mount MFS + */ struct mfs_args { - char *name; /* name of backing process */ - caddr_t base; /* base address of the filesystem */ - u_long size; /* size of the filesystem */ + char *fspec; /* name to export for statfs */ + struct export_args export; /* if exported MFSes are supported */ + caddr_t base; /* base of file system in memory */ + u_long size; /* size of file system */ +}; +.Ed +.Pp +.Dv MOUNT_MSDOSFS +.Pp +.Bd -literal -compact +#ifdef MSDOSFS +/* + * Arguments to mount MSDOS filesystems. + */ +struct msdosfs_args { + char *fspec; /* blocks special holding the fs to mount */ + struct export_args export; /* network export information */ + uid_t uid; /* uid that owns msdosfs files */ + gid_t gid; /* gid that owns msdosfs files */ + mode_t mask; /* mask to be applied for msdosfs perms */ }; +#endif +.Ed +.Pp +.Dv MOUNT_CD9660 +.Pp +.Bd -literal -compact +#ifdef CD9660 +/* + * Arguments to mount ISO 9660 filesystems. + */ +struct iso_args { + char *fspec; /* block special device to mount */ + struct export_args export; /* network export info */ + int flags; /* mounting flags, see below */ + +}; +#define ISOFSMNT_NORRIP 0x00000001 /* disable Rock Ridge Ext.*/ +#define ISOFSMNT_GENS 0x00000002 /* enable generation numbers */ +#define ISOFSMNT_EXTATT 0x00000004 /* enable extended attributes */ +#endif /* CD9660 */ .Ed .Pp The @@ -152,8 +281,9 @@ The .Fa flags argument may specify .Dv MNT_FORCE -to specify that the filesystem should be forcibly unmounted even if files are -still active. +to specify that the filesystem should be forcibly unmounted or made read-only +(if MNT_UPDATE and MNT_RDONLY are also specified) +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 filesystem is later remounted. @@ -165,14 +295,16 @@ 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 +The +.Fn umount +function 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: +The +.Fn mount +function will fail when one of the following occurs: .Bl -tag -width [ENOTBLK] .It Bq Er EPERM The caller is not the super-user. @@ -192,8 +324,6 @@ 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 . @@ -269,8 +399,9 @@ cylinder group information. points outside the process's allocated address space. .El .Pp -.Nm Umount -may fail with one of the following errors: +The +.Fn umount +function may fail with one of the following errors: .Bl -tag -width [ENOTBLK] .It Bq Er EPERM The caller is not the super-user. @@ -302,13 +433,14 @@ or mount can also fail if the maximum number of filesystems are currently mounted. .Sh SEE ALSO +.Xr mfs 8 , .Xr mount 8 , -.Xr umount 8 , -.Xr mfs 8 +.Xr umount 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. +function calls appeared in +.At v6 . diff --git a/lib/libc/sys/mprotect.2 b/lib/libc/sys/mprotect.2 index bb2b9ad..d4e28d7 100644 --- a/lib/libc/sys/mprotect.2 +++ b/lib/libc/sys/mprotect.2 @@ -38,7 +38,10 @@ .Nm mprotect .Nd control the protection of pages .Sh SYNOPSIS -.Fn mprotect "caddr_t addr" "int len" "int prot" +.Fd #include <sys/types.h> +.Fd #include <sys/mman.h> +.Ft int +.Fn mprotect "caddr_t addr" "size_t len" "int prot" .Sh DESCRIPTION The .Fn mprotect @@ -47,12 +50,38 @@ changes the specified pages to have protection .Fa prot . Not all implementations will guarantee protection on a page basis; the granularity of protection changes may be as large as an entire region. +.Sh RETURN VALUES +Upon successful completion, +.Fn mprotect +returns 0. Otherwise a value of -1 is returned +and +.Va errno +is set to indicate the error. +.Sh ERRORS +The +.Fn mprotect +function will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +The virtual address range specified by the +.Fa addr +and +.Fa len +arguments is not valid. +.It Bq Er EACCES +The calling process was not allowed to change +the protection to the value specified by +the +.Fa prot +argument. +.El .Sh SEE ALSO -.Xr msync 2 , -.Xr munmap 2 , .Xr madvise 2 , -.Xr mincore 2 +.Xr mincore 2 , +.Xr msync 2 , +.Xr munmap 2 .Sh HISTORY The .Fn mprotect -function first appeared in 4.4BSD. +function first appeared in +.Bx 4.4 . diff --git a/lib/libc/sys/msync.2 b/lib/libc/sys/msync.2 index 2583c15..f21ff29 100644 --- a/lib/libc/sys/msync.2 +++ b/lib/libc/sys/msync.2 @@ -38,7 +38,10 @@ .Nm msync .Nd synchronize a mapped region .Sh SYNOPSIS -.Fn msync "caddr_t addr" "int len" +.Fd #include <sys/types.h> +.Fd #include <sys/mman.h> +.Ft int +.Fn msync "caddr_t addr" "size_t len" "int flags" .Sh DESCRIPTION The .Fn msync @@ -57,17 +60,36 @@ is non-zero, only the pages containing and .Fa len succeeding locations will be examined. -Any required synchronization of memory caches -will also take place at this time. -Filesystem operations on a file that is mapped for shared modifications -are unpredictable except after an -.Fn msync . +The +.Fa flags +argument may be specified as follows: +.Bd -literal +MS_ASYNC Return immediately (not currently implemented) +MS_INVALIDATE Invalidate all cached data +.Ed +.Sh RETURN VALUES +If any errors occur, -1 is returned and errno is set to indicate the +error. Otherwise, a 0 value is returned. +.Sh ERRORS +.Fn msync +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +.Fa addr +is not a multiple of the hardware page size. +.It Bq Er EINVAL +.Fa len +is too large or negative. +.It Bq Er EINVAL +.Fa flags +was both MS_ASYNC and MS_INVALIDATE. Only one of these flags is allowed. .Sh SEE ALSO .Xr madvise 2 , -.Xr munmap 2 , +.Xr mincore 2 , .Xr mprotect 2 , -.Xr mincore 2 +.Xr munmap 2 .Sh HISTORY The .Fn msync -function first appeared in 4.4BSD. +function first appeared in +.Bx 4.4 . diff --git a/lib/libc/sys/munmap.2 b/lib/libc/sys/munmap.2 index b9e8a1b..208dc0b 100644 --- a/lib/libc/sys/munmap.2 +++ b/lib/libc/sys/munmap.2 @@ -38,6 +38,9 @@ .Nm munmap .Nd remove a mapping .Sh SYNOPSIS +.Fd #include <sys/types.h> +.Fd #include <sys/mman.h> +.Ft int .Fn munmap "caddr_t addr" "size_t len" .Sh DESCRIPTION The @@ -48,7 +51,7 @@ and causes further references to addresses within the range to generate invalid memory references. .Sh RETURN VALUES Upon successful completion, -.Nm munmap +.Fn munmap returns zero. Otherwise, a value of -1 is returned and .Va errno @@ -66,13 +69,14 @@ parameter was negative, or some part of the region being unmapped is not part of the currently valid address space. .Sh "SEE ALSO" -.Xr getpagesize 2 , +.Xr madvise 2 , +.Xr mincore 2 , +.Xr mprotect 2 , .Xr msync 2 , .Xr munmap 2 , -.Xr mprotect 2 , -.Xr madvise 2 , -.Xr mincore 2 +.Xr getpagesize 3 .Sh HISTORY The .Fn munmap -function first appeared in 4.4BSD. +function first appeared in +.Bx 4.4 . diff --git a/lib/libc/sys/nfssvc.2 b/lib/libc/sys/nfssvc.2 index 0c8038f..c789aee 100644 --- a/lib/libc/sys/nfssvc.2 +++ b/lib/libc/sys/nfssvc.2 @@ -86,10 +86,13 @@ struct nfsd_cargs { uid_t ncd_authuid; /* Effective uid */ int ncd_authtype; /* Type of authenticator */ int ncd_authlen; /* Length of authenticator string */ - char *ncd_authstr; /* Authenticator string */ + u_char *ncd_authstr; /* Authenticator string */ + int ncd_verflen; /* and the verifier */ + u_char *ncd_verfstr; + NFSKERBKEY_T ncd_key; /* Session key */ }; .Ed -.sp +.Pp structure. The initial call has only the .Dv NFSSVC_MNTD @@ -135,10 +138,15 @@ struct nfsd_srvargs { u_long nsd_haddr; /* Ip address of client */ struct ucred nsd_cr; /* Cred. uid maps to */ int nsd_authlen; /* Length of auth string (ret) */ - char *nsd_authstr; /* Auth string (ret) */ + u_char *nsd_authstr; /* Auth string (ret) */ + int nsd_verflen; /* and the verfier */ + u_char *nsd_verfstr; + struct timeval nsd_timestamp; /* timestamp from verifier */ + u_long nsd_ttl; /* credential ttl (sec) */ + NFSKERBKEY_T nsd_key; /* Session key */ }; .Ed -.sp +.Pp to enter the kernel as an .Xr nfsd 8 daemon. @@ -186,12 +194,12 @@ with the flag and a pointer to a .Bd -literal struct nfsd_args { - int sock; /* Socket to serve */ - caddr_t name; /* Client address for connection based sockets */ - int namelen; /* Length of name */ + int sock; /* Socket to serve */ + caddr_t name; /* Client address for connection based sockets */ + int namelen;/* Length of name */ }; .Ed -.sp +.Pp to pass a server side .Tn NFS socket into the kernel for servicing by the @@ -199,7 +207,7 @@ socket into the kernel for servicing by the daemons. .Sh RETURN VALUES Normally -.Nm nfssvc +.Fn nfssvc does not return unless the server is terminated by a signal when a value of 0 is returned. Otherwise, -1 is returned and the global variable @@ -215,16 +223,17 @@ as explained above. The caller is not the super-user. .El .Sh SEE ALSO -.Xr nfsd 8 , .Xr mount_nfs 8 , +.Xr nfsd 8 , .Xr nfsiod 8 .Sh HISTORY The -.Nm nfssvc -function first appeared in 4.4BSD. +.Fn nfssvc +function first appeared in +.Bx 4.4 . .Sh BUGS The -.Nm nfssvc +.Fn nfssvc system call is designed specifically for the .Tn NFS support daemons and as such is specific to their requirements. @@ -234,5 +243,5 @@ support, since is not really an error. Several fields of the argument structures are assumed to be valid and sometimes to be unchanged from a previous call, such that -.Nm nfssvc +.Fn nfssvc must be used with extreme care. diff --git a/lib/libc/sys/open.2 b/lib/libc/sys/open.2 index dea59fc..11d2906 100644 --- a/lib/libc/sys/open.2 +++ b/lib/libc/sys/open.2 @@ -136,7 +136,7 @@ When a new file is created it is given the group of the directory which contains it. .Pp The new descriptor is set to remain open across -.Xr execve +.Xr execve 2 system calls; see .Xr close 2 and @@ -146,6 +146,33 @@ The system imposes a limit on the number of file descriptors open simultaneously by one process. .Xr Getdtablesize 2 returns the current system limit. +.Pp +.Sh IMPLEMENTATION NOTES +In the non-threaded library +.Fn open +is implemented as the +.Va open +syscall. +.Pp +In the threaded library, the +.Va open +syscall is assembled to +.Fn _thread_sys_open +and +.Fn open +is implemented as a function which disables thread rescheduling +and calls +.Fn _thread_sys_open . +Before returning, +.Fn open +enables thread rescheduling. +.Sh RETURN VALUES +If successful, +.Fn open +returns a non-negative integer, termed a file descriptor. +It returns -1 on failure, and sets +.Va errno +to indicate the error. .Sh ERRORS The named file is opened unless: .Bl -tag -width Er @@ -188,7 +215,7 @@ special file, and the device associated with this special file does not exist. .It Bq Er EINTR The -.Nm +.Fn open operation was interrupted by a signal. .It Bq Er EOPNOTSUPP .Dv O_SHLOCK @@ -249,9 +276,10 @@ An attempt was made to open a socket (not currently implemented). .Xr getdtablesize 2 , .Xr lseek 2 , .Xr read 2 , -.Xr write 2 , -.Xr umask 2 +.Xr umask 2 , +.Xr write 2 .Sh HISTORY An -.Nm -function call appeared in Version 6 AT&T UNIX. +.Fn open +function call appeared in +.At v6 . diff --git a/lib/libc/sys/pathconf.2 b/lib/libc/sys/pathconf.2 index 1b4fbc4..f8500e3 100644 --- a/lib/libc/sys/pathconf.2 +++ b/lib/libc/sys/pathconf.2 @@ -55,12 +55,12 @@ value of a configurable system limit or option variable associated with a pathname or file descriptor. .Pp For -.Nm pathconf , +.Fn pathconf , the .Fa path argument is the name of a file or directory. For -.Nm fpathconf , +.Fn fpathconf , the .Fa fd argument is an open file descriptor. @@ -98,9 +98,9 @@ Returns the terminal character disabling value. .El .Sh RETURN VALUES If the call to -.Nm pathconf +.Fn pathconf or -.Nm fpathconf +.Fn fpathconf is not successful, \-1 is returned and .Va errno is set appropriately. @@ -111,9 +111,9 @@ is not modified. Otherwise, the current variable value is returned. .Sh ERRORS If any of the following conditions occur, the -.Nm pathconf +.Fn pathconf and -.Nm fpathconf +.Fn fpathconf functions shall return -1 and set .Va errno to the corresponding value. @@ -157,7 +157,8 @@ An I/O error occurred while reading from or writing to the file system. .Xr sysctl 3 .Sh HISTORY The -.Nm pathconf +.Fn pathconf and -.Nm fpathconf -functions first appeared in 4.4BSD. +.Fn fpathconf +functions first appeared in +.Bx 4.4 . diff --git a/lib/libc/sys/pipe.2 b/lib/libc/sys/pipe.2 index 51b7364..d50c94f 100644 --- a/lib/libc/sys/pipe.2 +++ b/lib/libc/sys/pipe.2 @@ -48,12 +48,13 @@ function creates a .Em pipe , which is an object allowing -unidirectional data flow, +bidirectional data flow, and allocates a pair of file descriptors. -The first descriptor connects to the +.Pp +By convention, the first descriptor is normally used as the .Em read end of the pipe, -and the second connects to the +and the second is normally the .Em write end , so that data written to .Fa fildes[1] @@ -69,7 +70,7 @@ 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 +A pipe that has had an end closed is considered .Em widowed . Writing on such a pipe causes the writing process to receive a @@ -79,9 +80,10 @@ 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. +The bidirectional nature of this implementation of pipes is not +portable to older systems, so it is recommended to use the convention +for using the endpoints in the traditional manner when using a +pipe in one direction. .Sh RETURN VALUES On successful creation of the pipe, zero is returned. Otherwise, a value of -1 is returned and the variable @@ -105,11 +107,13 @@ space. .El .Sh SEE ALSO .Xr sh 1 , -.Xr read 2 , -.Xr write 2 , .Xr fork 2 , -.Xr socketpair 2 +.Xr read 2 , +.Xr socketpair 2 , +.Xr write 2 .Sh HISTORY A -.Nm -function call appeared in Version 6 AT&T UNIX. +.Fn pipe +function call appeared in Version 3 AT&T UNIX. +.Pp +Bidirectional pipes were first used on Unix System V release 4. diff --git a/lib/libc/sys/profil.2 b/lib/libc/sys/profil.2 index 670e343..8db74ba 100644 --- a/lib/libc/sys/profil.2 +++ b/lib/libc/sys/profil.2 @@ -33,6 +33,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)profil.2 8.1 (Berkeley) 6/4/93 +.\" $Id$ .\" .Dd "June 4, 1993" .Dt PROFIL 2 @@ -49,10 +50,12 @@ The function enables or disables program counter profiling of the current process. If profiling is enabled, -then at every clock tick, +then at every profiling clock tick, the kernel updates an appropriate count in the .Fa samples buffer. +The frequency of the profiling clock is recorded +in the header in the profiling output file. .Pp The buffer .Fa samples @@ -62,7 +65,7 @@ bytes and is divided into a series of 16-bit bins. Each bin counts the number of times the program counter was in a particular address range in the process -when a clock tick occurred while profiling was enabled. +when a profiling clock tick occurred while profiling was enabled. For a given program counter address, the number of the corresponding bin is given by the relation: @@ -115,8 +118,11 @@ contains an invalid address. .El .Sh SEE ALSO .Xr gprof 1 -.\" .Sh HISTORY -.\" wish I knew... probably v7. +.Sh HISTORY +A +.Fn profil +function call appeared in +.At v7 . .Sh BUGS This routine should be named .Fn profile . diff --git a/lib/libc/sys/ptrace.2 b/lib/libc/sys/ptrace.2 new file mode 100644 index 0000000..80bb513 --- /dev/null +++ b/lib/libc/sys/ptrace.2 @@ -0,0 +1,291 @@ +.\" $Id$ +.\" $NetBSD: ptrace.2,v 1.2 1995/02/27 12:35:37 cgd Exp $ +.\" +.\" This file is in the public domain. +.Dd January 20, 1996 +.Dt PTRACE 2 +.Os FreeBSD 2 +.Sh NAME +.Nm ptrace +.Nd process tracing and debugging +.Sh SYNOPSIS +.Fd #include <sys/types.h> +.Fd #include <sys/ptrace.h> +.Ft int +.Fn ptrace "int request" "pid_t pid" "caddr_t addr" "int data" +.Sh DESCRIPTION +.Fn ptrace +provides tracing and debugging facilities. It allows one process (the +.Em tracing +process) to control another (the +.Em traced +process). Most of the time, the traced process runs normally, but when +it receives a signal +.Po +see +.Xr sigaction 2 +.Pc , +it stops. The tracing process is expected to notice this via +.Xr wait 2 +or the delivery of a +.Dv SIGCHLD +signal, examine the state of the stopped process, and cause it to +terminate or continue as appropriate. +.Fn ptrace +is the mechanism by which all this happens. +.Pp +The +.Fa request +argument specifies what operation is being performed; the meaning of +the rest of the arguments depends on the operation, but except for one +special case noted below, all +.Fn ptrace +calls are made by the tracing process, and the +.Fa pid +argument specifies the process ID of the traced process. +.Fa request +can be: +.Bl -tag -width 12n +.It Dv PT_TRACE_ME +This request is the only one used by the traced process; it declares +that the process expects to be traced by its parent. All the other +arguments are ignored. (If the parent process does not expect to trace +the child, it will probably be rather confused by the results; once the +traced process stops, it cannot be made to continue except via +.Eo \& +.Fn ptrace +.Ec \&.) +When a process has used this request and calls +.Xr execve 2 +or any of the routines built on it +.Po +such as +.Xr execv 3 +.Pc , +it will stop before executing the first instruction of the new image. +Also, any setuid or setgid bits on the executable being executed will +be ignored. +.It Dv PT_READ_I , Dv PT_READ_D +These requests read a single +.Li int +of data from the traced process' address space. Traditionally, +.Fn ptrace +has allowed for machines with distinct address spaces for instruction +and data, which is why there are two requests: conceptually, +.Dv PT_READ_I +reads from the instruction space and +.Dv PT_READ_D +reads from the data space. In the current FreeBSD implementation, these +two requests are completely identical. The +.Fa addr +argument specifies the address (in the traced process' virtual address +space) at which the read is to be done. This address does not have to +meet any alignment constraints. The value read is returned as the +return value from +.Eo \& +.Fn ptrace +.Ec . +.It Dv PT_WRITE_I , Dv PT_WRITE_D +These requests parallel +.Dv PT_READ_I +and +.Dv PT_READ_D , +except that they write rather than read. The +.Fa data +argument supplies the value to be written. +.It Dv PT_READ_U +This request reads an +.Li int +from the traced process' user structure. The +.Fa addr +argument specifies the location of the int relative to the base of the +user structure; it will usually be an integer value cast to +.Li caddr_t +either explicitly or via the presence of a prototype for +.Eo \& +.Fn ptrace +.Ec . +Unlike +.Dv PT_READ_I +and +.Dv PT_READ_D , +.Fa addr +must be aligned on an +.Li int +boundary. The value read is returned as the return value from +.Eo \& +.Fn ptrace +.Ec . +.It Dv PT_WRITE_U +This request writes an +.Li int +into the traced process' user structure. +.Fa addr +specifies the offset, just as for +.Dv PT_READ_U , +and +.Fa data +specifies the value to be written, just as for +.Dv PT_WRITE_I +and +.Dv PT_WRITE_D . +.It Dv PT_CONTINUE +The traced process continues execution. +.Fa addr +is an address specifying the place where execution is to be resumed (a +new value for the program counter), or +.Li (caddr_t)1 +to indicate that execution is to pick up where it left off. +.Fa data +provides a signal number to be delivered to the traced process as it +resumes execution, or 0 if no signal is to be sent. +.It Dv PT_KILL +The traced process terminates, as if +.Dv PT_CONTINUE +had been used with +.Dv SIGKILL +given as the signal to be delivered. +.It Dv PT_ATTACH +This request allows a process to gain control of an otherwise unrelated +process and begin tracing it. It does not need any cooperation from +the to-be-traced process. In this case, +.Fa pid +specifies the process ID of the to-be-traced process, and the other two +arguments are ignored. This request requires that the target process +must have the same real UID as the tracing process, and that it must +not be executing a setuid or setgid executable. (If the tracing +process is running as root, these restrictions do not apply.) The +tracing process will see the newly-traced process stop and may then +control it as if it had been traced all along. +.It Dv PT_DETACH +This request is like PT_CONTINUE, except that it does not allow +specifying an alternate place to continue execution, and after it +succeeds, the traced process is no longer traced and continues +execution normally. +.El +.Pp +Additionally, machine-specific requests can exist. On the i386, these +are: +.Bl -tag -width 12n +.It Dv PT_GETREGS +This request reads the traced process' machine registers into the +.Dq Li "struct reg" +(defined in +.Aq Pa machine/reg.h ) +pointed to by +.Fa addr . +.It Dv PT_SETREGS +This request is the converse of +.Dv PT_GETREGS ; +it loads the traced process' machine registers from the +.Dq Li "struct reg" +(defined in +.Aq Pa machine/reg.h ) +pointed to by +.Fa addr . +.It Dv PT_GETFPREGS +This request reads the traced process' floating-point registers into +the +.Dq Li "struct fpreg" +(defined in +.Aq Pa machine/reg.h ) +pointed to by +.Fa addr . +.It Dv PT_SETFPREGS +This request is the converse of +.Dv PT_GETFPREGS ; +it loads the traced process' floating-point registers from the +.Dq Li "struct fpreg" +(defined in +.Aq Pa machine/reg.h ) +pointed to by +.Fa addr . +.El +.Sh RETURN VALUES +Some requests can cause +.Fn ptrace +to return +.Li -1 +as a non-error value; to disambiguate, +.Va errno +can be set to 0 before the call and checked afterwards. +.Sh ERRORS +The +.Fn ptrace +function may fail if: +.Bl -tag -width 4n +.It Bq Er ESRCH +.Bl -bullet -compact +.It +No process having the specified process ID exists. +.El +.It Bq Er EINVAL +.Bl -bullet -compact +.It +A process attempted to use +.Dv PT_ATTACH +on itself. +.It +The +.Fa request +was not one of the legal requests. +.It +The +.Fa addr +to +.Dv PT_READ_U +or +.Dv PT_WRITE_U +was not +.Li int Ns \&-aligned. +.It +The signal number (in +.Fa data ) +to +.Dv PT_CONTINUE +was neither 0 nor a legal signal number. +.It +.Dv PT_GETREGS , +.Dv PT_SETREGS , +.Dv PT_GETFPREGS , +or +.Dv PT_SETFPREGS +was attempted on a process with no valid register set. (This is +normally true only of system processes.) +.El +.It Bq Er EBUSY +.Bl -bullet -compact +.It +.Dv PT_ATTACH +was attempted on a process that was already being traced. +.It +A request attempted to manipulate a process that was being traced by +some process other than the one making the request. +.It +A request (other than +.Dv PT_ATTACH ) +specified a process that wasn't stopped. +.El +.It Bq Er EPERM +.Bl -bullet -compact +.It +A request (other than +.Dv PT_ATTACH ) +attempted to manipulate a process that wasn't being traced at all. +.It +An attempt was made to use +.Dv PT_ATTACH +on a process in violation of the requirements listed under +.Dv PT_ATTACH +above. +.El +.Sh SEE ALSO +.Xr execve 2 , +.Xr sigaction 2 , +.Xr wait 2 , +.Xr execv 3 +.Sh HISTORY +A +.Fn ptrace +function call appeared in +.At v7 . diff --git a/lib/libc/sys/quotactl.2 b/lib/libc/sys/quotactl.2 index acf9127..f09e2d23 100644 --- a/lib/libc/sys/quotactl.2 +++ b/lib/libc/sys/quotactl.2 @@ -41,7 +41,7 @@ .Nm quotactl .Nd manipulate filesystem quotas .Sh SYNOPSIS -.Ft #include <ufs/quota.h> /* for ufs quotas */ +.Fd #include <ufs/ufs/quota.h> /* for ufs quotas */ .Ft int .Fn quotactl "const char *path" "int cmd" "int id" "char *addr" .Sh DESCRIPTION @@ -156,8 +156,6 @@ The quota table cannot be expanded. .It Bq Er EINVAL .Fa Cmd or the command type is invalid. -.It Bq Er EINVAL -A pathname contains a character with the high-order bit set. .It Bq Er EACCES In .Dv Q_QUOTAON , @@ -208,6 +206,6 @@ and .Xr getrlimit 2 . .Sh HISTORY The -.Nm quotactl +.Fn quotactl function call appeared in .Bx 4.3 Reno . diff --git a/lib/libc/sys/read.2 b/lib/libc/sys/read.2 index b94341a..723c1bd 100644 --- a/lib/libc/sys/read.2 +++ b/lib/libc/sys/read.2 @@ -70,8 +70,8 @@ structure is defined as: .Pp .Bd -literal -offset indent -compact struct iovec { - void *iov_base; - size_t iov_len; + char *iov_base; /* Base address. */ + size_t iov_len; /* Length. */ }; .Ed .Pp @@ -107,6 +107,53 @@ 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 IMPLEMENTATION NOTES +.Pp +In the non-threaded library +.Fn read +is implemented as the +.Va read +syscall. +.Pp +In the threaded library, the +.Va read +syscall is assembled to +.Fn _thread_sys_read +and +.Fn read +is implemented as a function which locks +.Va d +for read, then calls +.Fn _thread_sys_read . +If the call to +.Fn _thread_sys_read +would block, a context switch is performed. Before returning, +.Fn read +unlocks +.Va d . +.Pp +In the non-threaded library +.Fn readv +is implemented as the +.Va readv +syscall. +.Pp +In the threaded library, the +.Va readv +syscall is assembled to +.Fn _thread_sys_readv +and +.Fn readv +is implemented as a function which locks +.Va d +for read, then calls +.Fn _thread_sys_readv . +If the call to +.Fn _thread_sys_readv +would block, a context switch is performed. Before returning, +.Fn readv +unlocks +.Va d . .Sh RETURN VALUES If successful, the number of bytes actually read is returned. Upon reading end-of-file, @@ -173,9 +220,10 @@ points outside the process's allocated address space. .Xr socket 2 , .Xr socketpair 2 .Sh STANDARDS -.Fn Read -is expected to conform to IEEE Std 1003.1-1988 -.Pq Dq Tn POSIX . +The +.Fn read +function call is expected to conform to +.St -p1003.1-90 . .Sh HISTORY The .Fn readv @@ -183,7 +231,6 @@ function call appeared in .Bx 4.2 . A -.Nm read -function call -appeared in -Version 6 AT&T UNIX. +.Fn read +function call appeared in +.At v6 . diff --git a/lib/libc/sys/readlink.2 b/lib/libc/sys/readlink.2 index 4827110..8443de2 100644 --- a/lib/libc/sys/readlink.2 +++ b/lib/libc/sys/readlink.2 @@ -30,6 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)readlink.2 8.1 (Berkeley) 6/4/93 +.\" $Id$ .\" .Dd June 4, 1993 .Dt READLINK 2 @@ -49,8 +50,9 @@ in the buffer .Fa buf , which has size .Fa bufsiz . -.Nm Readlink -does not append a +The +.Fn readlink +function does not append a .Dv NUL character to .Fa buf . @@ -65,8 +67,6 @@ 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. @@ -85,12 +85,12 @@ An I/O error occurred while reading from the file system. extends outside the process's allocated address space. .El .Sh SEE ALSO -.Xr stat 2 , .Xr lstat 2 , -.Xr symlink 2 -.Xr symlink 7 , +.Xr stat 2 , +.Xr symlink 2 , +.Xr symlink 7 .Sh HISTORY The -.Nm +.Fn readlink function call appeared in .Bx 4.2 . diff --git a/lib/libc/sys/reboot.2 b/lib/libc/sys/reboot.2 index 317c139..1eda9b3 100644 --- a/lib/libc/sys/reboot.2 +++ b/lib/libc/sys/reboot.2 @@ -62,7 +62,7 @@ The default, causing the system to reboot in its usual fashion. 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 , +.Dq Em xx Ns No (0,0)kernel , where .Em xx is the default disk name, @@ -81,6 +81,9 @@ 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_POWEROFF +After halting, the shutdown code will do what it can to turn +of the power. This requires hardware support. .It Dv RB_INITNAME An option allowing the specification of an init program (see .Xr init 8 ) @@ -123,7 +126,7 @@ program in the newly booted system. 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 +rebooted from file ``kernel'' 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 @@ -140,7 +143,6 @@ variable The caller is not the super-user. .El .Sh SEE ALSO -.Xr kadb 4 , .Xr crash 8 , .Xr halt 8 , .Xr init 8 , @@ -153,6 +155,6 @@ nor .Dv RB_KDB . .Sh HISTORY The -.Nm +.Fn reboot function call appeared in .Bx 4.0 . diff --git a/lib/libc/sys/recv.2 b/lib/libc/sys/recv.2 index 9ed24a3..5751022 100644 --- a/lib/libc/sys/recv.2 +++ b/lib/libc/sys/recv.2 @@ -252,12 +252,12 @@ address space. .El .Sh SEE ALSO .Xr fcntl 2 , +.Xr getsockopt 2 , .Xr read 2 , .Xr select 2 , -.Xr getsockopt 2 , .Xr socket 2 .Sh HISTORY The -.Nm +.Fn recv function call appeared in .Bx 4.2 . diff --git a/lib/libc/sys/rename.2 b/lib/libc/sys/rename.2 index be47d58..d9e1b83 100644 --- a/lib/libc/sys/rename.2 +++ b/lib/libc/sys/rename.2 @@ -30,6 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)rename.2 8.1 (Berkeley) 6/4/93 +.\" $Id$ .\" .Dd June 4, 1993 .Dt RENAME 2 @@ -105,8 +106,6 @@ indicates the reason for the failure. 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. @@ -191,9 +190,10 @@ or is a directory and is not empty. .El .Sh SEE ALSO -.Xr open 2 +.Xr open 2 , .Xr symlink 7 .Sh STANDARDS -.Fn Rename -conforms to IEEE Std 1003.1-1988 -.Pq Dq Tn POSIX . +The +.Fn rename +function call is expected to conform to +.St -p1003.1-90 . diff --git a/lib/libc/sys/revoke.2 b/lib/libc/sys/revoke.2 index e782874..93dfdee 100644 --- a/lib/libc/sys/revoke.2 +++ b/lib/libc/sys/revoke.2 @@ -45,7 +45,7 @@ .Fn revoke "char *path" .Sh DESCRIPTION The -.Nm revoke +.Fn revoke function invalidates all current open file descriptors in the system for the file named by .Fa path . @@ -63,7 +63,7 @@ is called as if all open references to the file had been closed. .Pp Access to a file may be revoked only by its owner or the super user. The -.Nm revoke +.Fn revoke function is currently supported only for block and character special device files. It is normally used to prepare a terminal device for a new login session, @@ -100,6 +100,6 @@ The caller is neither the owner of the file nor the super user. .Xr close 2 .Sh HISTORY The -.Nm revoke +.Fn revoke function was introduced in .Bx 4.3 Reno . diff --git a/lib/libc/sys/rfork.2 b/lib/libc/sys/rfork.2 new file mode 100644 index 0000000..4a54149 --- /dev/null +++ b/lib/libc/sys/rfork.2 @@ -0,0 +1,137 @@ +.\" +.\" This manual page is taken directly from Plan9, and modified to +.\" describe the actual BSD implementation. Permission for +.\" use of this page comes from Rob Pike <rob@plan9.att.com>. +.\" +.Dd Jan 12, 1996 +.Dt RFORK 2 +.Os +.Sh NAME +.Nm rfork +.Nd manipulate process resources +.Sh SYNOPSIS +.Fd #include <unistd.h> +.Ft int +.Fn rfork "int flags" +.Sh DESCRIPTION +Forking, vforking or rforking are the only ways new processes are created. +The +.Fa flags +argument to +.Fn rfork +selects which resources of the +invoking process (parent) are shared +by the new process (child) or initialized to +their default values. +The resources include +the open file descriptor table (which, when shared, permits processes +to open and close files for other processes), +and open files. +.Fa Flags +is the logical OR of some subset of: +.Bl -tag -width "RFCNAMEG" -compact -offset indent +.It RFPROC +If set a new process is created; otherwise changes affect the +current process. +The current implementation requires this flag to always be set. +.It RFNOWAIT +If set, the child process will be dissociated from the parent. Upon +exit the child will not leave a status for the parent to collect. +See +.Xr wait 2 . +.It RFFDG +If set, the invoker's file descriptor table (see +.Xr intro 2 +) is copied; otherwise the two processes share a +single table. +.It RFCFDG +If set, the new process starts with a clean file descriptor table. +Is mutually exclusive with +.Dv RFFDG . +.It RFMEM +If set, the kernel will force sharing of the entire address space. +The child +will then inherit all the shared segments the parent process owns. Other segment +types will be unaffected. Subsequent forks by the parent will then +propagate the shared data and bss between children. The stack segment +is always split. May be set only with +.Dv RFPROC . +.El +.Pp +File descriptors in a shared file descriptor table are kept +open until either they are explicitly closed +or all processes sharing the table exit. +.Pp +If +.Dv RFPROC +is set, the +value returned in the parent process +is the process id +of the child process; the value returned in the child is zero. +Without +.Dv RFPROC , +the return value is zero. +Process id's range from 1 to the maximum integer +.Ft ( int ) +value. +.Fn Rfork +will sleep, if necessary, until required process resources are available. +.Pp +.Fn Fork +can be implemented as a call to +.Fn rfork "RFFDG|RFPROC" +but isn't for backwards compatibility. +.Sh RETURN VALUES +Upon successful completion, +.Fn rfork +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 Rfork +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. +The limit is given by the +.Xr sysctl 3 +MIB variable +.Dv KERN_MAXPROC . +(The limit is actually one less than this +except for the super user). +.It Bq Er EAGAIN +The user is not the super user, and +the system-imposed limit +on the total number of +processes under execution by a single user would be exceeded. +The limit is given by the +.Xr sysctl 3 +MIB variable +.Dv KERN_MAXPROCPERUID . +.It Bq Er EAGAIN +The user is not the super user, and +the soft resource limit corresponding to the resource parameter +.Dv RLIMIT_NOFILE +would be exceeded (see +.Xr getrlimit 2 ) . +.It Bq Er EINVAL +The RFPROC flag was not specified. +.It Bq Er EINVAL +Both the RFFDG and the RFCFDG flags were specified. +.It Bq Er ENOMEM +There is insufficient swap space for the new process. +.El +.Sh SEE ALSO +.Xr fork 2 , +.Xr intro 2 , +.Xr minherit 2 , +.Xr vfork 2 +.Sh HISTORY +The +.Fn rfork +function call first appeared in Plan9. diff --git a/lib/libc/sys/rmdir.2 b/lib/libc/sys/rmdir.2 index 29f8833..51235f6 100644 --- a/lib/libc/sys/rmdir.2 +++ b/lib/libc/sys/rmdir.2 @@ -60,8 +60,6 @@ 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. @@ -101,6 +99,6 @@ points outside the process's allocated address space. .Xr unlink 2 .Sh HISTORY The -.Nm +.Fn rmdir function call appeared in .Bx 4.2 . diff --git a/lib/libc/sys/rtprio.2 b/lib/libc/sys/rtprio.2 new file mode 100644 index 0000000..e27311f --- /dev/null +++ b/lib/libc/sys/rtprio.2 @@ -0,0 +1,106 @@ +.\" Copyright (c) 1994, Henrik Vestergaard Draboel +.\" 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 Henrik Vestergaard Draboel. +.\" 4. The name of the author may not be used to endorse or promote products +.\" derived from this software without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. +.\" +.\" $Id$ +.\" +.Dd July 23, 1994 +.Dt RTPRIO 2 +.Sh NAME +.Nm rtprio +.Nd examine or modify a process realtime or idle priority +.Sh SYNOPSIS +.Fd #include <sys/types.h> +.Fd #include <sys/rtprio.h> +.Ft int +.Fn rtprio "int function" "pid_t pid" "struct rtprio *rtp" +.Sh DESCRIPTION +.Fn rtprio +is used to lookup or change the realtime or idle priority of a process. + +.Fa function +specifies the operation to be performed. RTP_LOOKUP to lookup the current priority, +and RTP_SET to set the priority. +.Fa pid +specifies the process to be used, 0 for the current process. + +.Fa *rtp +is a pointer to a struct rtprio which is used to specify the priority and priority type. +This structure has the following form: +.Bd -literal +struct rtprio { + u_short type; + u_short prio; +}; +.Ed +.Pp +The value of the +.Nm type +field may be RTP_PRIO_REALTIME for realtime priorities, +RTP_PRIO_NORMAL for normal priorities, and RTP_PRIO_IDLE for idle priorities. +The priority specified by the +.Nm prio +field ranges between 0 and +.Dv RTP_PRIO_MAX (usually 31) . +0 is the highest possible priority. + +Realtime and idle priority is inherited through fork() and exec(). + +A realtime process can only be preempted by a process of equal or +higher priority, or by an interrupt; idle priority processes will run only +when no other real/normal priority process is runnable. Higher real/idle priority processes +preempt lower real/idle priority processes. Processes of equal real/idle priority are run round-robin. +.Sh RETURN VALUES +.Fn rtprio +will return 0 for success and -1 for all errors. The global variable +.Va errno +will be set to indicate the error. +.Sh ERRORS +.Fn rtprio +will fail if +.Bl -tag -width Er +.It Bq Er EINVAL +The specified +.Fa prio +was out of range. +.It Bq Er EPERM +The calling process is not allowed to set the realtime priority. Only +root is allowed to change the realtime priority of any process, and non-root +may only change the idle priority of the current process. +.It Bq Er ESRCH +The specified process was not found. +.Sh AUTHOR +The original author was Henrik Vestergaard Draboel - hvd@terry.ping.dk. This +implementation in FreeBSD was substantially rewritten by David Greenman. +.Sh SEE ALSO +.Xr nice 1 , +.Xr ps 1 , +.Xr rtprio 1 , +.Xr setpriority 2 , +.Xr nice 3 , +.Xr renice 8 diff --git a/lib/libc/sys/select.2 b/lib/libc/sys/select.2 index 3de5b5e..c9a332dc 100644 --- a/lib/libc/sys/select.2 +++ b/lib/libc/sys/select.2 @@ -104,7 +104,7 @@ If 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 +is a nil pointer, the select blocks indefinitely. To effect a poll, the .Fa timeout argument should be non-nil, pointing to a zero-valued timeval structure. .Pp @@ -140,6 +140,9 @@ 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. +.It Bq Er EINVAL +.Fa nfds +was invalid. .El .Sh SEE ALSO .Xr accept 2 , @@ -149,26 +152,31 @@ negative or too large. .Xr read 2 , .Xr recv 2 , .Xr send 2 , -.Xr write 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 +.Xr write 2 , +.Xr clocks 7 +.Sh NOTES +The default size of .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 +is currently 256. +In order to accomodate programs which might potentially +use a larger number of open files with +.Fn select +, it is possible +to increase this size by having the program define .Dv FD_SETSIZE -before the inclusion of +before the inclusion of any header which includes .Aq Pa sys/types.h . .Pp -.Fn Select +If +.Fa nfds +is greater than the number of open files, +.Fn select +is not guaranteed to examine the unused file descriptors. For historical +reasons, +.Fn select +will always examine the first 256 descriptors. +.Sh BUGS +.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. @@ -178,6 +186,6 @@ by the call. .Sh HISTORY The -.Nm +.Fn select function call appeared in .Bx 4.2 . diff --git a/lib/libc/sys/semctl.2 b/lib/libc/sys/semctl.2 new file mode 100644 index 0000000..3ebbeee --- /dev/null +++ b/lib/libc/sys/semctl.2 @@ -0,0 +1,173 @@ +.\" +.\" Copyright (c) 1995 David Hovemeyer <daveho@infocom.com> +.\" +.\" 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. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``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 DEVELOPERS 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. +.\" +.\" $Id$ +.\" +.Dd September 12, 1995 +.Dt SEMCTL 2 +.Os FreeBSD +.Sh NAME +.Nm semctl +.Nd control operations on a semaphore set +.Sh SYNOPSIS +.Fd #include <sys/types.h> +.Fd #include <sys/ipc.h> +.Fd #include <sys/sem.h> +.Ft int +.Fn "semctl" "int semid" "int semnum" "int cmd" "union semun arg" +.Sh DESCRIPTION +.Fn Semctl +performs the operation indicated by +.Fa cmd +on the semaphore set indicated by +.Fa semid . +For the commands that use the +.Fa arg +parameter, +.Fa "union semun" +is defined as follows: +.Bd -literal +.\" +.\" From <sys/sem.h>: +.\" +union semun { + int val; /* value for SETVAL */ + struct semid_ds *buf; /* buffer for IPC_STAT & IPC_SET */ + u_short *array; /* array for GETALL & SETALL */ +}; +.Ed +.Pp +Commands are performed as follows: +.\" +.\" This section based on Stevens, _Advanced Programming in the UNIX +.\" Environment_. +.\" +.Bl -tag -width IPC_RMIDXXX +.It Dv IPC_STAT +Fetch the semaphore set's +.Fa "struct semid_ds" , +storing it in the memory pointed to by +.Fa arg.buf . +.It Dv IPC_SET +Changes the +.Fa sem_perm.uid , +.Fa sem_perm.gid , +and +.Fa sem_perm.mode +members of the semaphore set's +.Fa "struct semid_ds" +to match those of the struct pointed to by +.Fa arg.buf . +The calling process's effective uid must +match either +.Fa sem_perm.uid +or +.Fa sem_perm.cuid , +or it must have superuser privileges. +.It IPC_RMID +Immediately removes the semaphore set from the system. The calling +process's effective uid must equal the semaphore set's +.Fa sem_perm.uid +or +.Fa sem_perm.cuid , +or the process must have superuser privileges. +.It Dv GETVAL +Return the value of semaphore number +.Fa semnum . +.It Dv SETVAL +Set the value of semaphore number +.Fa semnum +to +.Fa arg.val . +.It Dv GETPID +Return the pid of the last process to perform an operation on +semaphore number +.Fa semnum . +.It Dv GETNCNT +Return the number of processes waiting for semaphore number +.Fa semnum Ns 's +value to become greater than its current value. +.It Dv GETZCNT +Return the number of processes waiting for semaphore number +.Fa semnum Ns 's +value to become 0. +.It Dv GETALL +Fetch the value of all of the semaphores in the set into the +array pointed to by +.Fa arg.array . +.It Dv SETALL +Set the values of all of the semaphores in the set to the values +in the array pointed to by +.Fa arg.array . +.El +.Pp +The +.Fa "struct semid_ds" +is defined as follows: +.Bd -literal +.\" +.\" Taken straight from <sys/sem.h>. +.\" +struct semid_ds { + struct ipc_perm sem_perm; /* operation permission struct */ + struct sem *sem_base; /* pointer to first semaphore in set */ + u_short sem_nsems; /* number of sems in set */ + time_t sem_otime; /* last operation time */ + long sem_pad1; /* SVABI/386 says I need this here */ + time_t sem_ctime; /* last change time */ + /* Times measured in secs since */ + /* 00:00:00 GMT, Jan. 1, 1970 */ + long sem_pad2; /* SVABI/386 says I need this here */ + long sem_pad3[4]; /* SVABI/386 says I need this here */ +}; +.Ed +.Sh RETURN VALUES +On success, when +.Fa cmd +is one of GETVAL, GETNCNT, or GETZCNT, +.Fn semctl +returns the corresponding value; otherwise, 0 is returned. +On failure, -1 is returned, and +.Va errno +is set to indicate the error. +.Sh ERRORS +.Fn Semctl +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +No semaphore set corresponds to +.Fa semid . +.It Bq Er EINVAL +.Fa semnum +is not in the range of valid semaphores for given semaphore set. +.It Bq Er EPERM +The calling process's effective uid does not match the uid of +the semaphore set's owner or creator. +.It Bq Er EACCES +Permission denied due to mismatch between operation and mode of +semaphore set. +.Sh SEE ALSO +.Xr semget 2 , +.Xr semop 2 diff --git a/lib/libc/sys/semget.2 b/lib/libc/sys/semget.2 new file mode 100644 index 0000000..45a25d5 --- /dev/null +++ b/lib/libc/sys/semget.2 @@ -0,0 +1,137 @@ +.\" +.\" Copyright (c) 1995 David Hovemeyer <daveho@infocom.com> +.\" +.\" 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. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``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 DEVELOPERS 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. +.\" +.\" $Id$ +.\" +.Dd September 12, 1995 +.Dt SEMGET 2 +.Os FreeBSD +.Sh NAME +.Nm semget +.Nd obtain a semaphore id +.Sh SYNOPSIS +.Fd #include <sys/types.h> +.Fd #include <sys/ipc.h> +.Fd #include <sys/sem.h> +.Ft int +.Fn "semget" "key_t key" "int nsems" "int flag" +.Sh DESCRIPTION +Based on the values of +.Fa key +and +.Fa flag , +.Fn semget +returns the identifier of a newly created or previously existing +set of semaphores. +.\" +.\" This is copied verbatim from the shmget manpage. Perhaps +.\" it should go in a common manpage, such as .Xr ipc 2 +.\" +The key +is analogous to a filename: it provides a handle that names an +IPC object. There are three ways to specify a key: +.Bl -bullet +.It +IPC_PRIVATE may be specified, in which case a new IPC object +will be created. +.It +An integer constant may be specified. If no IPC object corresponding +to +.Fa key +is specified and the IPC_CREAT bit is set in +.Fa flag , +a new one will be created. +.It +.Fn ftok +may be used to generate a key from a pathname. See +.Xr ftok 3 . +.El +.\" +.\" Likewise for this section, except SHM_* becomes SEM_*. +.\" +.Pp +The mode of a newly created IPC object is determined by +.Em OR Ns 'ing +the following constants into the +.Fa flag +parameter: +.Bl -tag -width XSEM_WXX6XXX +.It Dv SEM_R +Read access for user. +.It Dv SEM_A +Alter access for user. +.It Dv (SEM_R>>3) +Read access for group. +.It Dv (SEM_A>>3) +Alter access for group. +.It Dv (SEM_R>>6) +Read access for other. +.It Dv (SEM_A>>6) +Alter access for other. +.El +.Pp +If a new set of semaphores is being created, +.Fa nsems +is used to indicate the number of semaphores the set should contain. +Otherwise, +.Fa nsems +may be specified as 0. +.Sh RETURN VALUES +.Fn Semget +returns the id of a semaphore set if successful; otherwise, -1 +is returned and +.Va errno +is set to indicate the error. +.Sh ERRORS +.Fn Semget +will fail if: +.Bl -tag -width Er +.\" ipcperm could fail (we're opening to read and write, as it were) +.It Bq Er EACCES +Access permission failure. +.\" +.\" sysv_sem.c is quite explicit about these, so I'm pretty sure +.\" this is accurate +.\" +.It Bq Er EEXIST +IPC_CREAT and IPC_EXCL were specified, and a semaphore set +corresponding to +.Fa key +already exists. +.It Bq Er EINVAL +The number of semaphores requested exceeds the system imposed maximum +per set. +.It Bq Er ENOSPC +Insufficiently many semaphores are available. +.It Bq Er ENOSPC +The kernel could not allocate a +.Fa "struct semid_ds" . +.It Bq Er ENOENT +No semaphore set was found corresponding to +.Fa key , +and IPC_CREAT was not specified. +.Sh SEE ALSO +.Xr semctl 2 , +.Xr semop 2 diff --git a/lib/libc/sys/semop.2 b/lib/libc/sys/semop.2 new file mode 100644 index 0000000..9d07893 --- /dev/null +++ b/lib/libc/sys/semop.2 @@ -0,0 +1,192 @@ +.\" +.\" Copyright (c) 1995 David Hovemeyer <daveho@infocom.com> +.\" +.\" 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. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``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 DEVELOPERS 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. +.\" +.\" $Id$ +.\" +.Dd September 22, 1995 +.Dt SEMOP 2 +.Os FreeBSD +.Sh NAME +.Nm semop +.Nd atomic array of operations on a semaphore set +.Sh SYNOPSIS +.Fd #include <sys/types.h> +.Fd #include <sys/ipc.h> +.Fd #include <sys/sem.h> +.Ft int +.Fn "semop" "int semid" "struct sembuf array[]" "unsigned nops" +.Sh DESCRIPTION +.Fn Semop +atomically performs the array of operations indicated by +.Fa array +on the semaphore set indicated by +.Fa semid . +The length of +.Fa array +is indicated by +.Fa nops . +Each operation is encoded in a +.Fa "struct sembuf" , +which is defined as follows: +.Bd -literal +.\" +.\" From <sys/sem.h> +.\" +struct sembuf { + u_short sem_num; /* semaphore # */ + short sem_op; /* semaphore operation */ + short sem_flg; /* operation flags */ +}; +.Ed +.Pp +For each element in +.Fa array , +.Fa sem_op +and +.Fa sem_flg +determine an operation to be performed on semaphore number +.Fa sem_num +in the set. The values SEM_UNDO and IPC_NOWAIT may be +.Em OR Ns 'ed +into the +.Fa sem_flg +member in order to modify the behavior of the given operation. +.Pp +The operation performed depends as follows on the value of +.Fa sem_op : +.\" +.\" This section is based on the description of semop() in +.\" Stevens, _Advanced Programming in the UNIX Environment_. +.\" +.Bl -bullet +.It +When +.Fa sem_op +is positive, the semaphore's value is incremented by +.Fa sem_op Ns 's +value. If SEM_UNDO is specified, the semaphore's adjust on exit +value is decremented by +.Fa sem_op Ns 's +value. A positive value for +.Fa sem_op +generally corresponds to a process releasing a resource +associated with the semaphore. +.It +The behavior when +.Fa sem_op +is negative depends on the current value of the semaphore: +.Bl -bullet +.It +If the current value of the semaphore is greater than or equal to +the absolute value of +.Fa sem_op , +then the value is decremented by the absolute value of +.Fa sem_op . +If SEM_UNDO is specified, the semaphore's adjust on exit +value is incremented by the absolute value of +.Fa sem_op . +.It +If the current value of the semaphore is less than +.Fa sem_op Ns 's +value, one of the following happens: +.\" XXX a *second* sublist? +.Bl -bullet +.It +If IPC_NOWAIT was specified, then +.Fn semop +returns immediately with a return value of EAGAIN. +.It +If some other process has removed the semaphore with the IPC_RMID +option of +.Fn semctl , +then +.Fn semop +returns immediately with a return value of EINVAL. +.It +Otherwise, the calling process is put to sleep until the semaphore's +value is greater than or equal to the absolute value of +.Fa sem_op . +When this condition becomes true, the semaphore's value is decremented +by the absolute value of +.Fa sem_op , +and the semaphore's adjust on exit value is incremented by the +absolute value of +.Fa sem_op . +.El +.Pp +A negative value for +.Fa sem_op +generally means that a process is waiting for a resource to become +available. +.El +.Pp +.It +When +.Fa sem_op +is zero, the process waits for the semaphore's value to become zero. +If it is already zero, the call to +.Fn semop +can return immediately. Otherwise, the calling process is put to +sleep until the semaphore's value becomes zero. +.El +.Pp +For each semaphore a process has in use, the kernel maintains an +`adjust on exit' value, as alluded to earlier. When a process +exits, either voluntarily or involuntarily, the adjust on exit value +for each semaphore is added to the semaphore's value. This can +be used to insure that a resource is released if a process terminates +unexpectedly. +.Sh RETURN VALUES +On success, +.Fn semop +returns 0; otherwise, -1 is returned and +.Va errno +is set to indicate the error. +.Sh ERRORS +.Fn Semop +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +No semaphore set corresponds to +.Fa semid . +.It Bq Er EACCES +Permission denied due to mismatch between operation and mode of +semaphore set. +.It Bq Er EAGAIN +The semaphore's value was less than +.Fa sem_op , +and IPC_NOWAIT was specified. +.It Bq Er E2BIG +Too many operations were specified. +.It Bq Er EFBIG +.\" +.\" I'd have thought this would be EINVAL, but the source says +.\" EFBIG. +.\" +.Fa sem_num +was not in the range of valid semaphores for the set. +.Sh SEE ALSO +.Xr semctl 2 , +.Xr semget 2 diff --git a/lib/libc/sys/send.2 b/lib/libc/sys/send.2 index 9dc285b..57fcfb3 100644 --- a/lib/libc/sys/send.2 +++ b/lib/libc/sys/send.2 @@ -29,9 +29,10 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)send.2 8.2 (Berkeley) 2/21/94 +.\" From: @(#)send.2 8.2 (Berkeley) 2/21/94 +.\" $Id$ .\" -.Dd February 21, 1994 +.Dd February 15, 1995 .Dt SEND 2 .Os BSD 4.2 .Sh NAME @@ -94,8 +95,11 @@ The .Fa flags parameter may include one or more of the following: .Bd -literal -#define MSG_OOB 0x1 /* process out-of-band data */ -#define MSG_DONTROUTE 0x4 /* bypass routing, use direct interface */ +#define MSG_OOB 0x1 /* process out-of-band data */ +#define MSG_PEEK 0x2 /* peek at incoming message */ +#define MSG_DONTROUTE 0x4 /* bypass routing, use direct interface */ +#define MSG_EOR 0x8 /* data completes record */ +#define MSG_EOF 0x100 /* data completes transaction */ .Ed .Pp The flag @@ -107,6 +111,20 @@ data on sockets that support this notion (e.g. the underlying protocol must also support .Dq out-of-band data. +.Dv MSG_EOR +is used to indicate a record mark for protocols which support the +concept. +.Dv MSG_EOF +requests that the sender side of a socket be shut down, and that an +appropriate indication be sent at the end of the specified data; +this flag is only implemented for +.Dv SOCK_STREAM +sockets in the +.Dv PF_INET +protocol family, and is used to implement Transaction +.Tn TCP +(see +.Xr ttcp 4 ) . .Dv MSG_DONTROUTE is usually used only by diagnostic or routing programs. .Pp @@ -124,9 +142,13 @@ if an error occurred. and .Fn sendmsg fail if: -.Bl -tag -width [EMSGSIZE] +.Bl -tag -width Er .It Bq Er EBADF An invalid descriptor was specified. +.It Bq Er EACCES +The destination address is a broadcast address, and +.Dv SO_BROADCAST +has not been set on the socket. .It Bq Er ENOTSOCK The argument .Fa s @@ -146,16 +168,18 @@ The operation may succeed when buffers become available. The output queue for a network interface was full. This generally indicates that the interface has stopped sending, but may be caused by transient congestion. +.It Bq Er EHOSTUNREACH +The remote host was unreachable. .El .Sh SEE ALSO .Xr fcntl 2 , +.Xr getsockopt 2 , .Xr recv 2 , .Xr select 2 , -.Xr getsockopt 2 , .Xr socket 2 , .Xr write 2 .Sh HISTORY The -.Nm +.Fn send function call appeared in .Bx 4.2 . diff --git a/lib/libc/sys/setgroups.2 b/lib/libc/sys/setgroups.2 index e20b47e..bce9e1a 100644 --- a/lib/libc/sys/setgroups.2 +++ b/lib/libc/sys/setgroups.2 @@ -78,6 +78,6 @@ address space. .Xr initgroups 3 .Sh HISTORY The -.Nm +.Fn setgroups function call appeared in .Bx 4.2 . diff --git a/lib/libc/sys/setpgid.2 b/lib/libc/sys/setpgid.2 index 141c203..4490edf 100644 --- a/lib/libc/sys/setpgid.2 +++ b/lib/libc/sys/setpgid.2 @@ -77,9 +77,10 @@ of the calling process. .Sh SEE ALSO .Xr getpgrp 2 .Sh STANDARDS -.Fn Setpgid -conforms to IEEE Std 1003.1-1988 -.Pq Dq Tn POSIX . +The +.Fn setpgid +function call is expected to conform to +.St -p1003.1-90 . .Sh COMPATIBILITY .Fn Setpgrp is identical to diff --git a/lib/libc/sys/setregid.2 b/lib/libc/sys/setregid.2 new file mode 100644 index 0000000..787dd11 --- /dev/null +++ b/lib/libc/sys/setregid.2 @@ -0,0 +1,91 @@ +.\" Copyright (c) 1980, 1991, 1993, 1994 +.\" 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 8.2 (Berkeley) 4/16/94 +.\" +.Dd April 16, 1994 +.Dt SETREGID 2 +.Os BSD 4.2 +.Sh NAME +.Nm setregid +.Nd set real and effective group ID +.Sh SYNOPSIS +.Fd #include <unistd.h> +.Ft int +.Fn setregid "gid_t rgid" "gid_t 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. +.Pp +The +.Fn setregid +function was intended to allow swapping +the real and effective group IDs +in set-group-ID programs to temporarily relinquish the set-group-ID value. +This function did not work correctly, +and its purpose is now better served by the use of the +.Fn setegid +function (see +.Xr setuid 2 ) . +.Pp +When setting the real and effective group IDs to the same value, +the standard +.Fn setgid +function is preferred. +.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 setegid 2 , +.Xr setgid 2 , +.Xr setuid 2 +.Sh HISTORY +The +.Fn setregid +system call appeared in +.Bx 4.2 . diff --git a/lib/libc/sys/setreuid.2 b/lib/libc/sys/setreuid.2 new file mode 100644 index 0000000..9d9402c --- /dev/null +++ b/lib/libc/sys/setreuid.2 @@ -0,0 +1,89 @@ +.\" Copyright (c) 1980, 1991, 1993, 1994 +.\" 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 8.2 (Berkeley) 4/16/94 +.\" +.Dd April 16, 1994 +.Dt SETREUID 2 +.Os BSD 4 +.Sh NAME +.Nm setreuid +.Nd set real and effective user ID's +.Sh SYNOPSIS +.Fd #include <unistd.h> +.Ft int +.Fn setreuid "uid_t ruid" "uid_t euid" +.Sh DESCRIPTION +The real and effective user IDs 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. +.Pp +The +.Fn setreuid +function has been used to swap the real and effective user IDs +in set-user-ID programs to temporarily relinquish the set-user-ID value. +This purpose is now better served by the use of the +.Fn seteuid +function (see +.Xr setuid 2 ) . +.Pp +When setting the real and effective user IDs to the same value, +the standard +.Fn setuid +function is preferred. +.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 seteuid 2 , +.Xr setuid 2 +.Sh HISTORY +The +.Fn setreuid +system call appeared in +.Bx 4.2 . diff --git a/lib/libc/sys/setsid.2 b/lib/libc/sys/setsid.2 index 48ac6a0..27e5f42 100644 --- a/lib/libc/sys/setsid.2 +++ b/lib/libc/sys/setsid.2 @@ -43,24 +43,27 @@ .Fn setsid "void" .Sh DESCRIPTION The -.Nm setsid +.Fn setsid function creates a new session. The calling process is the session leader of the new session, is the process group leader of a new process group and has no controlling terminal. The calling process is the only process in either the session or the process group. -.Pp +.Sh RETURN VALUES Upon successful completion, the -.Nm setsid +.Fn setsid function returns the value of the process group ID of the new process group, which is the same as the process ID of the calling process. -.Sh ERRORS If an error occurs, -.Nm setsid +.Fn setsid returns -1 and the global variable .Va errno -is set to indicate the error, as follows: +is set to indicate the error. +.Sh ERRORS +The +.Fn setsid +function will fail if: .Bl -tag -width Er .It Bq Er EPERM The calling process is already a process group leader, or the process @@ -68,12 +71,12 @@ group ID of a process other than the calling process matches the process ID of the calling process. .El .Sh SEE ALSO -.Xr setpgid 3 , +.Xr setpgid 2 , .Xr tcgetpgrp 3 , .Xr tcsetpgrp 3 .Sh STANDARDS The -.Nm setsid +.Fn setsid function is expected to be compliant with the -.St -p1003.1-88 +.St -p1003.1-90 specification. diff --git a/lib/libc/sys/setuid.2 b/lib/libc/sys/setuid.2 index 383a8f5..0944874 100644 --- a/lib/libc/sys/setuid.2 +++ b/lib/libc/sys/setuid.2 @@ -30,6 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)setuid.2 8.1 (Berkeley) 6/4/93 +.\" $Id$ .\" .Dd June 4, 1993 .Dt SETUID 2 @@ -58,9 +59,20 @@ function sets the real and effective user IDs and the saved set-user-ID of the current process to the specified value. +.\" Comment out next block for !_POSIX_SAVED_IDS +.\" The real user ID and the saved set-user-ID are changed only if the +.\" effective user ID is that of the super user. +.\" I.e. +.\" .Fn setuid +.\" function is equal to +.\" .Fn seteuid +.\" function if the effective user ID is not that of the super user. +.\" End of block The .Fn setuid function is permitted if the specified ID is equal to the real user ID +.\" Comment out next line for !_POSIX_SAVED_IDS +.\" or the saved set-user-ID of the process, or if the effective user ID is that of the super user. .Pp The @@ -69,9 +81,20 @@ function sets the real and effective group IDs and the saved set-group-ID of the current process to the specified value. +.\" Comment out next block for !_POSIX_SAVED_IDS +.\" The real group ID and the saved set-group-ID are changed only if the +.\" effective user ID is that of the super user. +.\" I.e. +.\" .Fn setgid +.\" function is equal to +.\" .Fn setegid +.\" function if the effective user ID is not that of the super user. +.\" End of block The .Fn setgid function is permitted if the specified ID is equal to the real group ID +.\" Comment out next line for !_POSIX_SAVED_IDS +.\" or the saved set-groupd-ID of the process, or if the effective user ID is that of the super user. .Pp The @@ -99,18 +122,20 @@ If the user is not the super user, or the uid specified is not the real, effective ID, or saved ID, these functions return \-1. .Sh SEE ALSO -.Xr getuid 2 , -.Xr getgid 2 +.Xr getgid 2 , +.Xr getuid 2 .Sh STANDARDS The .Fn setuid and .Fn setgid functions are compliant with the -.St -p1003.1-88 +.St -p1003.1-90 specification with .Li _POSIX_SAVED_IDS -not defined. +.\" Uncomment next line for !_POSIX_SAVED_IDS +not +defined. The .Fn seteuid and @@ -120,3 +145,10 @@ functions are extensions based on the concept of .Li _POSIX_SAVED_IDS , and have been proposed for a future revision of the standard. +.Sh HISTORY +A +.Fn setuid +and a +.Fn setgid +function calls appeared in +.At v7 . diff --git a/lib/libc/sys/shmat.2 b/lib/libc/sys/shmat.2 new file mode 100644 index 0000000..e43554e --- /dev/null +++ b/lib/libc/sys/shmat.2 @@ -0,0 +1,110 @@ +.\" +.\" Copyright (c) 1995 David Hovemeyer <daveho@infocom.com> +.\" +.\" 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. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``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 DEVELOPERS 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. +.\" +.\" $Id$ +.\" +.Dd August 2, 1995 +.Dt SHMAT 2 +.Os FreeBSD +.Sh NAME +.Nm shmat , +.Nm shmdt +.Nd attach or detach shared memory +.Sh SYNOPSIS +.Fd #include <sys/types.h> +.Fd #include <sys/ipc.h> +.Fd #include <sys/shm.h> +.Ft void * +.Fn "shmat" "int shmid" "void *addr" "int flag" +.Ft int +.Fn "shmdt" "void *addr" +.Sh DESCRIPTION +.Fn Shmat +attaches the shared memory segment identified by +.Fa shmid +to the calling process's address space. The address where the segment +is attached is determined as follows: +.\" +.\" These are cribbed almost exactly from Stevens, _Advanced Programming in +.\" the UNIX Environment_. +.\" +.Bl -bullet +.It +If +.Fa addr +is 0, the segment is attached at an address selected by the +kernel. +.It +If +.Fa addr +is nonzero and SHM_RND is not specified in +.Fa flag , +the segment is attached the specified address. +.It +If +.Fa addr +is specified and SHM_RND is specified, +.Fa addr +is rounded down to the nearest multiple of SHMLBA. +.El +.Pp +.Fn Shmdt +detaches the shared memory segment at the address specified by +.Fa addr +from the calling process's address space. +.Sh RETURN VALUES +Upon success, +.Fn shmat +returns the address where the segment is attached; otherwise, -1 +is returned and +.Va errno +is set to indicate the error. +.Pp +Upon success, +.Fn shmdt +returns 0; otherwise, -1 is returned and +.Va errno +is set to indicate the error. +.Sh ERRORS +.Fn Shmat +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +No shared memory segment was found corresponding to +.Fa shmid . +.It Bq Er EINVAL +.Fa addr +was not an acceptable address. +.El +.Pp +.Fn Shmdt +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +.Fa addr +does not point to a shared memory segment. +.Sh "SEE ALSO" +.Xr shmctl 2 , +.Xr shmget 2 diff --git a/lib/libc/sys/shmctl.2 b/lib/libc/sys/shmctl.2 new file mode 100644 index 0000000..ae78ebc --- /dev/null +++ b/lib/libc/sys/shmctl.2 @@ -0,0 +1,136 @@ +.\" +.\" Copyright (c) 1995 David Hovemeyer <daveho@infocom.com> +.\" +.\" 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. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``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 DEVELOPERS 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. +.\" +.\" $Id$ +.\" +.Dd July 17, 1995 +.Dt SHMCTL 2 +.Os FreeBSD +.Sh NAME +.Nm shmctl +.Nd shared memory control +.Sh SYNOPSIS +.Fd #include <sys/types.h> +.Fd #include <sys/ipc.h> +.Fd #include <sys/shm.h> +.Ft int +.Fn "shmctl" "int shmid" "int cmd" "struct shmid_ds *buf" +.Sh DESCRIPTION +Performs the action specified by +.Fa cmd +on the shared memory segment identified by +.Fa shmid : +.Bl -tag -width SHM_UNLOCKX +.It Dv IPC_STAT +Fetch the segment's +.Fa "struct shmid_ds" , +storing it in the memory pointed to by +.Fa buf . +.\" +.\" XXX need to make sure that this is correct for FreeBSD +.\" +.It Dv IPC_SET +Changes the +.Fa shm_perm.uid , +.Fa shm_perm.gid , +and +.Fa shm_perm.mode +members of the segment's +.Fa "struct shmid_ds" +to match those of the struct pointed to by +.Fa buf . +The calling process's effective uid must +match either +.Fa shm_perm.uid +or +.Fa shm_perm.cuid , +or it must have superuser privileges. +.It Dv IPC_RMID +Removes the segment from the system. The removal will not take +effect until all processes having attached the segment have exited; +however, once the IPC_RMID operation has taken place, no further +processes will be allowed to attach the segment. For the operation +to succeed, the calling process's effective uid must match +.Fa shm_perm.uid +or +.Fa shm_perm.cuid , +or the process must have superuser privileges. +.\" .It Dv SHM_LOCK +.\" Locks the segment in memory. The calling process must have +.\" superuser privileges. Not implemented in FreeBSD. +.\" .It Dv SHM_UNLOCK +.\" Unlocks the segment from memory. The calling process must +.\" have superuser privileges. Not implemented in FreeBSD. +.El +.Pp +The +.Fa "shmid_ds" +struct is defined as follows: +.\" +.\" I fiddled with the spaces a bit to make it fit well when viewed +.\" with nroff, but otherwise it's straight from sys/shm.h +.\" +.Bd -literal +struct shmid_ds { + struct ipc_perm shm_perm; /* operation permission structure */ + int shm_segsz; /* size of segment in bytes */ + pid_t shm_lpid; /* process ID of last shared memory op */ + pid_t shm_cpid; /* process ID of creator */ + short shm_nattch; /* number of current attaches */ + time_t shm_atime; /* time of last shmat() */ + time_t shm_dtime; /* time of last shmdt() */ + time_t shm_ctime; /* time of last change by shmctl() */ + void *shm_internal; /* sysv stupidity */ +}; +.Ed +.Sh RETURN VALUES +Upon successful completion, +.Fn shmctl +returns 0. Otherwise, it returns -1 and +.Va errno +is set to indicate the error. +.Sh ERRORS +.Fn Shmctl +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +Invalid operation, or +no shared memory segment was found corresponding to +.Fa shmid . +.\" +.\" XXX I think the following is right: ipcperm() only returns EPERM +.\" when an attempt is made to modify (IPC_M) by a non-creator +.\" non-owner +.It Bq Er EPERM +The calling process's effective uid does not match the uid of +the shared memory segment's owner or creator. +.It Bq Er EACCES +Permission denied due to mismatch between operation and mode of +shared memory segment. +.Sh "SEE ALSO" +.Xr shmat 2 , +.Xr shmdt 2 , +.Xr shmget 2 , +.Xr ftok 3 diff --git a/lib/libc/sys/shmget.2 b/lib/libc/sys/shmget.2 new file mode 100644 index 0000000..64eee64 --- /dev/null +++ b/lib/libc/sys/shmget.2 @@ -0,0 +1,138 @@ +.\" +.\" Copyright (c) 1995 David Hovemeyer <daveho@infocom.com> +.\" +.\" 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. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``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 DEVELOPERS 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. +.\" +.\" $Id$ +.\" +.Dd July 3, 1995 +.Dt SHMGET 2 +.Os FreeBSD +.Sh NAME +.Nm shmget +.Nd obtain a shared memory identifier +.Sh SYNOPSIS +.Fd #include <sys/types.h> +.Fd #include <sys/ipc.h> +.Fd #include <sys/shm.h> +.Ft int +.Fn "shmget" "key_t key" "int size" "int flag" +.Sh DESCRIPTION +Based on the values of +.Fa key +and +.Fa flag , +.Fn shmget +returns the identifier of a newly created or previously existing shared +memory segment. +.\" +.\" The following bit about keys and modes also applies to semaphores +.\" and message queues. +.\" +The key +is analogous to a filename: it provides a handle that names an +IPC object. There are three ways to specify a key: +.Bl -bullet +.It +IPC_PRIVATE may be specified, in which case a new IPC object +will be created. +.It +An integer constant may be specified. If no IPC object corresponding +to +.Fa key +is specified and the IPC_CREAT bit is set in +.Fa flag , +a new one will be created. +.It +.Fn ftok +may be used to generate a key from a pathname. See +.Xr ftok 3 . +.El +.Pp +The mode of a newly created IPC object is determined by +.Em OR Ns 'ing +the following constants into the +.Fa flag +parameter: +.Bl -tag -width XSHM_WXX6XXX +.It Dv SHM_R +Read access for user. +.It Dv SHM_W +Write access for user. +.It Dv (SHM_R>>3) +Read access for group. +.It Dv (SHM_W>>3) +Write access for group. +.It Dv (SHM_R>>6) +Read access for other. +.It Dv (SHM_W>>6) +Write access for other. +.El +.\" +.\" XXX - we should also mention how uid, euid, and gid affect ownership +.\" and use +.\" +.\" end section about keys and modes +.\" +.Pp +When creating a new shared memory segment, +.Fa size +indicates the desired size of the new segment in bytes. The size +of the segment may be rounded up to a multiple convenient to the +kernel (i.e., the page size). +.Sh RETURN VALUES +Upon successful completion, +.Fn shmget +returns the positive integer identifier of a shared memory segment. +Otherwise, -1 is returned and +.Va errno +set to indicate the error. +.Sh ERRORS +.Fn Shmget +will fail if: +.Bl -tag -width Er +.\" +.\" XXX What about ipcperm failing? +.\" +.It Bq Er EINVAL +Size specified is greater than the size of the previously existing segment. +Size specified is less than the system imposed minimum, or greater than +the system imposed maximum. +.It Bq Er ENOENT +No shared memory segment was found matching +.Fa key , +and IPC_CREAT was not specified. +.It Bq Er ENOSPC +The kernel was unable to allocate enough memory to +satisfy the request. +.It Bq Er EEXIST +IPC_CREAT and IPC_EXCL were specified, and a shared memory segment +corresponding to +.Fa key +already exists. +.Pp +.Sh "SEE ALSO" +.Xr shmat 2 , +.Xr shmctl 2 , +.Xr shmdt 2 , +.Xr ftok 3 diff --git a/lib/libc/sys/shutdown.2 b/lib/libc/sys/shutdown.2 index 976f958..3059793 100644 --- a/lib/libc/sys/shutdown.2 +++ b/lib/libc/sys/shutdown.2 @@ -57,7 +57,7 @@ is 1, further sends will be disallowed. If .Fa how is 2, further sends and receives will be disallowed. -.Sh DIAGNOSTICS +.Sh RETURN VALUES A 0 is returned if the call succeeds, -1 if it fails. .Sh ERRORS The call succeeds unless: @@ -76,6 +76,6 @@ The specified socket is not connected. .Xr socket 2 .Sh HISTORY The -.Nm +.Fn shutdown function call appeared in .Bx 4.2 . diff --git a/lib/libc/sys/sigaction.2 b/lib/libc/sys/sigaction.2 index d48b640..3fd68ca 100644 --- a/lib/libc/sys/sigaction.2 +++ b/lib/libc/sys/sigaction.2 @@ -41,16 +41,16 @@ .Fd #include <signal.h> .Bd -literal struct sigaction { - void (*sa_handler)(); - sigset_t sa_mask; - int sa_flags; + void (*sa_handler)(); /* signal handler */ + sigset_t sa_mask; /* signal mask to apply */ + int sa_flags; /* see signal options below */ }; .Ed -.Fn sigaction "int sig" "struct sigaction *act" "struct sigaction *oact" +.Fn sigaction "int sig" "const struct sigaction *act" "struct sigaction *oact" .Sh DESCRIPTION The system defines a set of signals that may be delivered to a process. Signal delivery resembles the occurrence of a hardware interrupt: -the signal is blocked from further occurrence, the current process +the signal is normally blocked from further occurrence, the current process context is saved, and a new one is built. A process may specify a .Em handler to which a signal is delivered, or specify that a signal is to be @@ -68,7 +68,7 @@ of the process. This may be changed, on a per-handler basis, so that signals are taken on a special .Em "signal stack" . .Pp -Signal routines execute with the signal that caused their +Signal routines normally execute with the signal that caused their invocation .Em blocked , but other signals may yet occur. @@ -117,7 +117,8 @@ the signal to be delivered, and the signal mask associated with the handler to be invoked. .Pp .Fn Sigaction -assigns an action for a specific signal. +assigns an action for a signal specified by +.Fa sig . If .Fa act is non-zero, it @@ -131,7 +132,7 @@ If is non-zero, the previous handling information for the signal is returned to the user. .Pp -Once a signal handler is installed, it remains installed +Once a signal handler is installed, it normally remains installed until another .Fn sigaction call is made, or an @@ -178,7 +179,16 @@ bit is set in the system will deliver the signal to the process on a .Em "signal stack" , specified with -.Xr sigstack 2 . +.Xr sigaltstack 2 . +If the +.Dv SA_NODEFER +bit is set, further occurrences of the delivered signal are not +masked during the execution of the handler. +If the +.Dv SA_RESETHAND +bit is set, the handler is reset back to +.Dv SIG_DFL +at the moment the signal is delivered. .Pp If a signal is caught during the system calls listed below, the call may be forced to terminate @@ -234,7 +244,7 @@ with names as in the include file .It Dv SIGQUIT No " create core image" " quit program" .It Dv SIGILL No " create core image" " illegal instruction" .It Dv SIGTRAP No " create core image" " trace trap" -.It Dv SIGABRT No " create core image" Xr abort 2 +.It Dv SIGABRT No " create core image" Xr abort 3 call (formerly .Dv SIGIOT ) .It Dv SIGEMT No " create core image" " emulate instruction executed" @@ -242,7 +252,7 @@ call (formerly .It Dv SIGKILL No " terminate process" " kill program" .It Dv SIGBUS No " create core image" " bus error" .It Dv SIGSEGV No " create core image" " segmentation violation" -.It Dv SIGSYS No " create core image" " system call given invalid argument" +.It Dv SIGSYS No " create core image" " non-existent system call invoked" .It Dv SIGPIPE No " terminate process" " write on a pipe with no reader" .It Dv SIGALRM No " terminate process" " real-time timer expired" .It Dv SIGTERM No " terminate process" " software termination signal" @@ -327,9 +337,9 @@ or .El .Sh STANDARDS The -.Nm sigaction -function is defined by -.St -p1003.1-88 . +.Fn sigaction +function call is expected to conform to +.St -p1003.1-90 . The .Dv SA_ONSTACK and @@ -352,17 +362,22 @@ and Those signals are available on most .Tn BSD Ns \-derived systems. +The +.Dv SA_NODEFER +and +.Dv SA_RESETHAND +are intended for backwards compatability with other operating systems. .Sh SEE ALSO .Xr kill 1 , -.Xr ptrace 2 , .Xr kill 2 , +.Xr ptrace 2 , .Xr sigaction 2 , -.Xr sigprocmask 2 , -.Xr sigsuspend 2 , +.Xr sigaltstack 2 , .Xr sigblock 2 , -.Xr sigsetmask 2 , .Xr sigpause 2 , -.Xr sigstack 2 , +.Xr sigprocmask 2 , +.Xr sigsetmask 2 , +.Xr sigsuspend 2 , .Xr sigvec 2 , .Xr setjmp 3 , .Xr siginterrupt 3 , diff --git a/lib/libc/sys/sigaltstack.2 b/lib/libc/sys/sigaltstack.2 index f1ed718..5e8815d 100644 --- a/lib/libc/sys/sigaltstack.2 +++ b/lib/libc/sys/sigaltstack.2 @@ -71,7 +71,7 @@ the system arranges a switch to the signal stack for the duration of the signal handler's execution. .Pp If -.Dv SA_DISABLE +.Dv SS_DISABLE is set in .Fa ss_flags , .Fa ss_sp @@ -79,7 +79,7 @@ and .Fa ss_size are ignored and the signal stack will be disabled. Trying to disable an active stack will cause -.Nm +.Fn sigaltstack to return -1 with .Va errno set to @@ -95,9 +95,9 @@ is non-zero, the current signal stack state is returned. The .Fa ss_flags field will contain the value -.Dv SA_ONSTACK +.Dv SS_ONSTACK if the process is currently on a signal stack and -.Dv SA_DISABLE +.Dv SS_DISABLE if the signal stack is currently disabled. .Sh NOTES The value @@ -158,7 +158,7 @@ Size of alternate stack area is less than or equal to .Xr setjmp 3 .Sh HISTORY The predecessor to -.Nm sigaltstack , +.Fn sigaltstack , the .Fn sigstack system call, appeared in diff --git a/lib/libc/sys/sigpending.2 b/lib/libc/sys/sigpending.2 index 0c87d4f..e8c6b8d 100644 --- a/lib/libc/sys/sigpending.2 +++ b/lib/libc/sys/sigpending.2 @@ -46,7 +46,7 @@ .Fn sigpending "sigset_t *set" .Sh DESCRIPTION The -.Nm sigpending +.Fn sigpending function returns a mask of the signals pending for delivery to the calling process in the location indicated by .Fa set . @@ -60,13 +60,13 @@ indicates an error occurred and is set to indicated the reason. .Sh ERRORS The -.Nm sigpending +.Fn sigpending function does not currently detect any errors. .Sh SEE ALSO .Xr sigaction 2 , .Xr sigprocmask 2 .Sh STANDARDS The -.Nm sigpending -function is defined by -.St -p1003.1-88 . +.Fn sigpending +function call is expected to conform to +.St -p1003.1-90 . diff --git a/lib/libc/sys/sigprocmask.2 b/lib/libc/sys/sigprocmask.2 index 73b014d..af1b574 100644 --- a/lib/libc/sys/sigprocmask.2 +++ b/lib/libc/sys/sigprocmask.2 @@ -110,11 +110,11 @@ has a value other than those listed here. .Sh SEE ALSO .Xr kill 2 , .Xr sigaction 2 , -.Xr sigsetops 3 , -.Xr sigsuspend 2 +.Xr sigsuspend 2 , +.Xr sigsetops 3 .Sh STANDARDS The -.Nm sigprocmask +.Fn sigprocmask function call is expected to conform to -.St -p1003.1-88 . +.St -p1003.1-90 . diff --git a/lib/libc/sys/sigreturn.2 b/lib/libc/sys/sigreturn.2 index f995d11..0e848c3 100644 --- a/lib/libc/sys/sigreturn.2 +++ b/lib/libc/sys/sigreturn.2 @@ -40,14 +40,28 @@ .Sh SYNOPSIS .Fd #include <signal.h> .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; +struct sigcontext { + int sc_onstack; /* sigstack state to restore */ + int sc_mask; /* signal mask to restore */ + int sc_esp; /* machine state */ + int sc_ebp; + int sc_isp; + int sc_eip; + int sc_efl; + int sc_es; + int sc_ds; + int sc_cs; + int sc_ss; + int sc_edi; + int sc_esi; + int sc_ebx; + int sc_edx; + int sc_ecx; + int sc_eax; +# define sc_sp sc_esp +# define sc_fp sc_ebp +# define sc_pc sc_eip +# define sc_ps sc_efl }; .Ed .Ft int @@ -92,6 +106,6 @@ raise the privilege level of the process. .Xr setjmp 3 .Sh HISTORY The -.Nm +.Fn sigreturn function call appeared in .Bx 4.3 . diff --git a/lib/libc/sys/sigstack.2 b/lib/libc/sys/sigstack.2 index 54d1c14..3fbe6e6 100644 --- a/lib/libc/sys/sigstack.2 +++ b/lib/libc/sys/sigstack.2 @@ -46,6 +46,6 @@ function has been deprecated in favor of the interface described in .Xr sigaltstack 2 .Sh HISTORY The -.Nm +.Fn sigstack function call appeared in .Bx 4.2 . diff --git a/lib/libc/sys/sigsuspend.2 b/lib/libc/sys/sigsuspend.2 index a234454..0c77bcb 100644 --- a/lib/libc/sys/sigsuspend.2 +++ b/lib/libc/sys/sigsuspend.2 @@ -69,12 +69,11 @@ always terminates by being interrupted, returning -1 with set to .Dv EINTR . .Sh SEE ALSO -.Xr sigprocmask 2 , .Xr sigaction 2 , +.Xr sigprocmask 2 , .Xr sigsetops 3 .Sh STANDARDS The -.Nm sigsupend -function call -conforms to -.St -p1003.1-88 . +.Fn sigsupend +function call is expected to conform to +.St -p1003.1-90 . diff --git a/lib/libc/sys/socket.2 b/lib/libc/sys/socket.2 index a16e3fb..b069b57 100644 --- a/lib/libc/sys/socket.2 +++ b/lib/libc/sys/socket.2 @@ -29,9 +29,10 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)socket.2 8.1 (Berkeley) 6/4/93 +.\" From: @(#)socket.2 8.1 (Berkeley) 6/4/93 +.\" $Id$ .\" -.Dd June 4, 1993 +.Dd February 15, 1995 .Dt SOCKET 2 .Os BSD 4.2 .Sh NAME @@ -56,11 +57,12 @@ These families are defined in the include file 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). +PF_LOCAL (Host-internal protocols, formerly called PF_UNIX), +PF_INET (ARPA Internet protocols), +PF_ISO (ISO protocols), +PF_CCITT (ITU-T protocols, like X.25), +PF_NS (Xerox Network Systems protocols), and +.\"PF_IMPLINK (IMP \*(lqhost at IMP\*(rq link layer). .Ed .Pp The socket has the indicated @@ -123,7 +125,8 @@ to pipes. A stream socket must be in a 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 +call. +Once connected, data may be transferred using .Xr read 2 and .Xr write 2 @@ -131,7 +134,15 @@ calls or some variant of the .Xr send 2 and .Xr recv 2 -calls. When a session has been completed a +calls. +(Some protocol families, such as the Internet family, +support the notion of an +.Dq implied connect, +which permits data to be sent piggybacked onto a connect operation by +using the +.Xr sendto 2 +call.) +When a session has been completed a .Xr close 2 may be performed. Out-of-band data may also be transmitted as described in @@ -230,7 +241,6 @@ The socket cannot be created until sufficient resources are freed. .Xr accept 2 , .Xr bind 2 , .Xr connect 2 , -.Xr getprotoent 3 , .Xr getsockname 2 , .Xr getsockopt 2 , .Xr ioctl 2 , @@ -241,17 +251,20 @@ The socket cannot be created until sufficient resources are freed. .Xr send 2 , .Xr shutdown 2 , .Xr socketpair 2 , -.Xr write 2 +.Xr write 2 , +.Xr getprotoent 3 .Rs .%T "An Introductory 4.3 BSD Interprocess Communication Tutorial" -.%O "reprinted in UNIX Programmer's Supplementary Documents Volume 1" +.%B PS1 +.%N 7 .Re .Rs .%T "BSD Interprocess Communication Tutorial" -.%O "reprinted in UNIX Programmer's Supplementary Documents Volume 1" +.%B PS1 +.%N 8 .Re .Sh HISTORY The -.Nm +.Fn socket function call appeared in .Bx 4.2 . diff --git a/lib/libc/sys/socketpair.2 b/lib/libc/sys/socketpair.2 index 1e8ba24..62aef76 100644 --- a/lib/libc/sys/socketpair.2 +++ b/lib/libc/sys/socketpair.2 @@ -58,7 +58,7 @@ are returned in and .Fa sv Ns [1] . The two sockets are indistinguishable. -.Sh DIAGNOSTICS +.Sh RETURN VALUES A 0 is returned if the call succeeds, -1 if it fails. .Sh ERRORS The call succeeds unless: @@ -77,15 +77,15 @@ The address does not specify a valid part of the process address space. .Sh SEE ALSO +.Xr pipe 2 , .Xr read 2 , -.Xr write 2 , -.Xr pipe 2 +.Xr write 2 .Sh BUGS This call is currently implemented only for the .Tn UNIX domain. .Sh HISTORY The -.Nm +.Fn socketpair function call appeared in .Bx 4.2 . diff --git a/lib/libc/sys/stat.2 b/lib/libc/sys/stat.2 index 8f78621..24fc4e4 100644 --- a/lib/libc/sys/stat.2 +++ b/lib/libc/sys/stat.2 @@ -30,6 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)stat.2 8.3 (Berkeley) 4/19/94 +.\" $Id$ .\" .Dd April 19, 1994 .Dt STAT 2 @@ -93,21 +94,30 @@ as defined by 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 */ + dev_t st_dev; /* inode's device */ + ino_t st_ino; /* inode's number */ + mode_t st_mode; /* inode protection mode */ + nlink_t st_nlink; /* number of hard links */ + uid_t st_uid; /* user ID of the file's owner */ + gid_t st_gid; /* group ID of the file's group */ + dev_t st_rdev; /* device type */ +#ifndef _POSIX_SOURCE struct timespec st_atimespec; /* time of last access */ struct timespec st_mtimespec; /* time of last data modification */ struct timespec st_ctimespec; /* time of last file status change */ - off_t st_size; /* file size, in bytes */ - quad_t st_blocks; /* blocks allocated for file */ - u_long st_blksize;/* optimal file sys I/O ops blocksize */ - u_long st_flags; /* user defined flags for file */ - u_long st_gen; /* file generation number */ +#else + time_t st_atime; /* time of last access */ + long st_atimensec; /* nsec of last access */ + time_t st_mtime; /* time of last data modification */ + long st_mtimensec; /* nsec of last data modification */ + time_t st_ctime; /* time of last file status change */ + long st_ctimensec; /* nsec of last file status change */ +#endif + off_t st_size; /* file size, in bytes */ + quad_t st_blocks; /* blocks allocated for file */ + u_long st_blksize; /* optimal blocksize for I/O */ + u_long st_flags; /* user defined flags for file */ + u_long st_gen; /* file generation number */ }; .Ed .Pp @@ -146,6 +156,17 @@ and system calls. .El .Pp +If +.Dv _POSIX_SOURCE +is not defined, the time-related fields are defined as: +.Bd -literal +#ifndef _POSIX_SOURCE +#define st_atime st_atimespec.tv_sec +#define st_mtime st_mtimespec.tv_sec +#define st_ctime st_ctimespec.tv_sec +#endif +.Ed +.Pp The size-related fields of the .Fa struct stat are as follows: @@ -170,6 +191,7 @@ has the following bits: #define S_IFREG 0100000 /* regular */ #define S_IFLNK 0120000 /* symbolic link */ #define S_IFSOCK 0140000 /* socket */ +#define S_IFWHT 0160000 /* whiteout */ #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 */ @@ -207,8 +229,6 @@ 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. @@ -252,13 +272,13 @@ depend on the time stamps being contiguous (in calls to .Sh SEE ALSO .Xr chmod 2 , .Xr chown 2 , -.Xr utimes 2 +.Xr utimes 2 , .Xr symlink 7 .Sh BUGS Applying -.Xr fstat +.Fn fstat to a socket (and thus to a pipe) -returns a zero'd buffer, +returns a zeroed buffer, except for the blocksize field, and a unique device and inode number. .Sh STANDARDS @@ -266,11 +286,16 @@ The .Fn stat and .Fn fstat -function calls are expected to -conform to IEEE Std 1003.1-1988 -.Pq Dq Tn POSIX . +function calls are expected to conform to +.St -p1003.1-90 . .Sh HISTORY A -.Nm lstat +.Fn stat +and a +.Fn fstat +function call appeared in +.At v7 . +A +.Fn lstat function call appeared in .Bx 4.2 . diff --git a/lib/libc/sys/statfs.2 b/lib/libc/sys/statfs.2 index a7a1da2..f5641a59 100644 --- a/lib/libc/sys/statfs.2 +++ b/lib/libc/sys/statfs.2 @@ -54,13 +54,17 @@ is a pointer to a .Fn statfs structure defined as follows: .Bd -literal -typedef quad fsid_t; +typedef struct fsid { int32_t val[2]; } fsid_t; /* file system id type */ -#define MNAMELEN 90 /* length of buffer for returned name */ +/* + * file system statistics + */ + +#define MFSNAMELEN 16 /* length of fs type name, including null */ +#define MNAMELEN 90 /* length of buffer for returned name */ struct statfs { -short f_type; /* type of filesystem (see below) */ -short f_flags; /* copy of mount flags */ +long f_spare2; /* placeholder */ long f_bsize; /* fundamental file system block size */ long f_iosize; /* optimal transfer block size */ long f_blocks; /* total data blocks in file system */ @@ -69,7 +73,11 @@ long f_bavail; /* free blocks avail to non-superuser */ long f_files; /* total file nodes in file system */ long f_ffree; /* free file nodes in fs */ fsid_t f_fsid; /* file system id */ -long f_spare[9]; /* spare for later */ +uid_t f_owner; /* user that mounted the filesystem */ +int f_type; /* type of filesystem (see below) */ +int f_flags; /* copy of mount flags */ +long f_spare[2]; /* spare for later */ +char f_fstypename[MFSNAMELEN];/* fs type name */ char f_mntonname[MNAMELEN]; /* mount point */ char f_mntfromname[MNAMELEN]; /* mounted filesystem */ }; @@ -91,6 +99,10 @@ char f_mntfromname[MNAMELEN]; /* mounted filesystem */ #define MOUNT_AFS 13 /* Andrew Filesystem */ #define MOUNT_CD9660 14 /* ISO9660 (aka CDROM) Filesystem */ #define MOUNT_UNION 15 /* Union (translucent) Filesystem */ +#define MOUNT_DEVFS 16 /* existing device Filesystem */ +#define MOUNT_EXT2FS 17 /* Linux EXT2FS */ +#define MOUNT_TFS 18 /* Netcon Novell filesystem */ +#define MOUNT_MAXTYPE 18 .Ed .Pp Fields that are undefined for a particular file system are set to -1. @@ -110,9 +122,6 @@ fails if one or more of the following are true: A component of the path prefix of .Fa Path is not a directory. -.It Bq Er EINVAL -.Fa path -contains a character with the high-order bit set. .It Bq Er ENAMETOOLONG The length of a component of .Fa path @@ -157,5 +166,6 @@ error occurred while reading from or writing to the file system. .El .Sh HISTORY The -.Nm statfs -function first appeared in 4.4BSD. +.Fn statfs +function first appeared in +.Bx 4.4 . diff --git a/lib/libc/sys/swapon.2 b/lib/libc/sys/swapon.2 index 5f152cc..b684da1 100644 --- a/lib/libc/sys/swapon.2 +++ b/lib/libc/sys/swapon.2 @@ -62,8 +62,6 @@ 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. @@ -99,8 +97,8 @@ An I/O error occurred while opening the swap device. .Fa Special points outside the process's allocated address space. .Sh SEE ALSO -.Xr swapon 8 , -.Xr config 8 +.Xr config 8 , +.Xr swapon 8 .Sh BUGS There is no way to stop swapping on a disk so that the pack may be dismounted. @@ -108,6 +106,6 @@ dismounted. This call will be upgraded in future versions of the system. .Sh HISTORY The -.Nm +.Fn swapon function call appeared in .Bx 4.0 . diff --git a/lib/libc/sys/symlink.2 b/lib/libc/sys/symlink.2 index c404a3d..ce1fa7e 100644 --- a/lib/libc/sys/symlink.2 +++ b/lib/libc/sys/symlink.2 @@ -66,12 +66,6 @@ The symbolic link succeeds unless: 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. @@ -129,11 +123,14 @@ or points outside the process's allocated address space. .El .Sh SEE ALSO -.Xr link 2 , .Xr ln 1 , -.Xr unlink 2 +.Xr link 2 , +.Xr lstat 2 , +.Xr readlink 2 , +.Xr unlink 2 , +.Xr symlink 7 .Sh HISTORY The -.Nm +.Fn symlink function call appeared in .Bx 4.2 . diff --git a/lib/libc/sys/sync.2 b/lib/libc/sys/sync.2 index 5e79fef..2b2b664 100644 --- a/lib/libc/sys/sync.2 +++ b/lib/libc/sys/sync.2 @@ -53,7 +53,7 @@ As information in the cache is lost after a system crash a call is issued frequently by the user process -.Xr update 8 +.Xr update 4 (about every 30 seconds). .Pp The function @@ -62,12 +62,13 @@ may be used to synchronize individual file descriptor attributes. .Sh SEE ALSO .Xr fsync 2 , -.Xr sync 8 , -.Xr update 8 +.Xr update 4 , +.Xr sync 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. +.Fn sync +function call appeared in +.At v6 . diff --git a/lib/libc/sys/syscall.2 b/lib/libc/sys/syscall.2 index 2e020ad..f357366 100644 --- a/lib/libc/sys/syscall.2 +++ b/lib/libc/sys/syscall.2 @@ -54,7 +54,7 @@ with the specified arguments. Symbolic constants for system calls can be found in the header file .Ao Pa sys/syscall.h Ac . The -.Nm __syscall +.Fn __syscall form should be used when one or more of the parameters is a 64-bit argument to ensure that argument alignment is correct. This system call is useful for testing new system calls that @@ -71,6 +71,6 @@ such as .Xr pipe 2 . .Sh HISTORY The -.Nm syscall +.Fn syscall function call appeared in .Bx 4.0 . diff --git a/lib/libc/sys/truncate.2 b/lib/libc/sys/truncate.2 index 2a5f3a6..678dcf6 100644 --- a/lib/libc/sys/truncate.2 +++ b/lib/libc/sys/truncate.2 @@ -37,7 +37,7 @@ .Sh NAME .Nm truncate , .Nm ftruncate -.Nd truncate a file to a specified length +.Nd truncate or extend a file to a specified length .Sh SYNOPSIS .Fd #include <unistd.h> .Ft int @@ -50,11 +50,14 @@ causes the file named by .Fa path or referenced by .Fa fd -to be truncated to at most +to be truncated or extended to .Fa length -bytes in size. If the file previously +bytes in size. If the file was larger than this size, the extra data is lost. +If the file was smaller than this size, +it will be extended as if by writing bytes +with the value zero. With .Fn ftruncate , the file must be open for writing. @@ -69,8 +72,6 @@ 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. @@ -116,8 +117,12 @@ is not open for writing. .Sh BUGS These calls should be generalized to allow ranges of bytes in a file to be discarded. +.Pp +Use of +.Fn truncate +to extend a file is not portable. .Sh HISTORY The -.Nm +.Fn truncate function call appeared in .Bx 4.2 . diff --git a/lib/libc/sys/umask.2 b/lib/libc/sys/umask.2 index cec3f1d..4ac1db8 100644 --- a/lib/libc/sys/umask.2 +++ b/lib/libc/sys/umask.2 @@ -30,6 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)umask.2 8.1 (Berkeley) 6/4/93 +.\" $Id$ .\" .Dd June 4, 1993 .Dt UMASK 2 @@ -78,5 +79,10 @@ function is always successful. .Sh STANDARDS The .Fn umask -function call is expected to conform to IEEE Std 1003.1-1988 -.Pq Dq Tn POSIX . +function call is expected to conform to +.St -p1003.1-90 . +.Sh HISTORY +An +.Fn umask +function call appeared in +.At v7 . diff --git a/lib/libc/sys/unlink.2 b/lib/libc/sys/unlink.2 index 78221bc..8693f95 100644 --- a/lib/libc/sys/unlink.2 +++ b/lib/libc/sys/unlink.2 @@ -30,6 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)unlink.2 8.1 (Berkeley) 6/4/93 +.\" $Id$ .\" .Dd June 4, 1993 .Dt UNLINK 2 @@ -56,6 +57,8 @@ 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. +.Fa path +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 @@ -68,8 +71,6 @@ 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. @@ -83,8 +84,7 @@ 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. +The named file is a directory. .It Bq Er EPERM The directory containing the file is marked sticky, and neither the containing directory nor the file to be removed @@ -104,9 +104,16 @@ points outside the process's allocated address space. .Sh SEE ALSO .Xr close 2 , .Xr link 2 , -.Xr rmdir 2 +.Xr rmdir 2 , .Xr symlink 7 .Sh HISTORY An -.Nm -function call appeared in Version 6 AT&T UNIX. +.Fn unlink +function call appeared in +.At v6 . +.Pp +The +.Fn unlink +system call traditionally allows the super-user to unlink directories which +can damage the filesystem integrity. This implementation no longer permits +it. diff --git a/lib/libc/sys/utimes.2 b/lib/libc/sys/utimes.2 index 1ebeb37..531d236 100644 --- a/lib/libc/sys/utimes.2 +++ b/lib/libc/sys/utimes.2 @@ -82,12 +82,10 @@ 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 +.Fa 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 @@ -113,6 +111,6 @@ The file system containing the file is mounted read-only. .Xr stat 2 .Sh HISTORY The -.Nm utimes +.Fn utimes function call appeared in .Bx 4.2 . diff --git a/lib/libc/sys/vfork.2 b/lib/libc/sys/vfork.2 index 8b6e077..a780cbf 100644 --- a/lib/libc/sys/vfork.2 +++ b/lib/libc/sys/vfork.2 @@ -30,6 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)vfork.2 8.1 (Berkeley) 6/4/93 +.\" $Id$ .\" .Dd June 4, 1993 .Dt VFORK 2 @@ -48,16 +49,16 @@ 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 . +.Xr execve 2 . .Fn Vfork differs from -.Xr fork +.Xr fork 2 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.) +.Xr exit 3 +or abnormally). The parent process is suspended while the child is using its resources. .Pp .Fn Vfork @@ -66,7 +67,7 @@ the parent's context. .Pp .Fn Vfork can normally be used just like -.Xr fork . +.Xr fork 2 . It does not work, however, to return while running in the childs context from the procedure that called .Fn vfork @@ -74,36 +75,36 @@ since the eventual return from .Fn vfork would then return to a no longer existent stack frame. Be careful, also, to call -.Xr _exit +.Xr _exit 2 rather than -.Xr exit +.Xr exit 3 if you can't -.Xr execve , +.Xr execve 2 , since -.Xr exit +.Xr exit 3 will flush and close standard I/O channels, and thereby mess up the parent processes standard I/O data structures. (Even with -.Xr fork +.Xr fork 2 it is wrong to call -.Xr exit +.Xr exit 3 since buffered data would then be flushed twice.) .Sh SEE ALSO -.Xr fork 2 , .Xr execve 2 , +.Xr fork 2 , .Xr sigvec 2 , -.Xr wait 2 , -.Sh DIAGNOSTICS +.Xr wait 2 +.Sh RETURN VALUES Same as for -.Xr fork . +.Xr fork 2 . .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 +.Xr vfork 2 as it will, in that case, be made synonymous to -.Xr fork . +.Xr fork 2 . .Pp To avoid a possible deadlock situation, processes that are children in the middle @@ -121,6 +122,6 @@ are allowed and input attempts result in an end-of-file indication. .Sh HISTORY The -.Nm +.Fn vfork function call appeared in .Bx 3.0 . diff --git a/lib/libc/sys/wait.2 b/lib/libc/sys/wait.2 index c0077b1..d348361 100644 --- a/lib/libc/sys/wait.2 +++ b/lib/libc/sys/wait.2 @@ -156,7 +156,7 @@ One of the first three macros will evaluate to a non-zero (true) value: True if the process terminated normally by a call to .Xr _exit 2 or -.Xr exit 2 . +.Xr exit 3 . .It Fn WIFSIGNALED status True if the process terminated due to receipt of a signal. .It Fn WIFSTOPPED status @@ -178,7 +178,7 @@ is true, evaluates to the low-order 8 bits of the argument passed to .Xr _exit 2 or -.Xr exit 2 +.Xr exit 3 by the child. .It Fn WTERMSIG status If @@ -287,9 +287,11 @@ 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 +.Xr _exit 2 , +.Xr sigaction 2 , +.Xr exit 3 .Sh HISTORY A -.Nm -function call appeared in Version 6 AT&T UNIX. +.Fn wait +function call appeared in +.At v6 . diff --git a/lib/libc/sys/write.2 b/lib/libc/sys/write.2 index de2d3ae..f8d8063 100644 --- a/lib/libc/sys/write.2 +++ b/lib/libc/sys/write.2 @@ -70,8 +70,8 @@ structure is defined as: .Pp .Bd -literal -offset indent -compact struct iovec { - void *iov_base; - size_t iov_len; + char *iov_base; /* Base address. */ + size_t iov_len; /* Length. */ }; .Ed .Pp @@ -115,6 +115,53 @@ and may write fewer bytes than requested; the return value must be noted, and the remainder of the operation should be retried when possible. +.Sh IMPLEMENTATION NOTES +.Pp +In the non-threaded library +.Fn write +is implemented as the +.Va write +syscall. +.Pp +In the threaded library, the +.Va write +syscall is assembled to +.Fn _thread_sys_write +and +.Fn write +is implemented as a function which locks +.Va d +for read and write, then calls +.Fn _thread_sys_write . +If the call to +.Fn _thread_sys_write +would block, a context switch is performed. Before returning, +.Fn write +unlocks +.Va d . +.Pp +In the non-threaded library +.Fn writev +is implemented as the +.Va writev +syscall. +.Pp +In the threaded library, the +.Va writev +syscall is assembled to +.Fn _thread_sys_writev +and +.Fn writev +is implemented as a function which locks +.Va d +for read and write, then calls +.Fn _thread_sys_writev . +If the call to +.Fn _thread_sys_writev +would block, a context switch is performed. Before returning, +.Fn writev +unlocks +.Va d . .Sh RETURN VALUES Upon successful completion the number of bytes which were written is returned. Otherwise a -1 is returned and the global variable @@ -134,7 +181,7 @@ 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 +.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 @@ -189,9 +236,10 @@ array overflowed a 32-bit integer. .Xr pipe 2 , .Xr select 2 .Sh STANDARDS -.Fn Write -is expected to conform to IEEE Std 1003.1-1988 -.Pq Dq Tn POSIX . +The +.Fn write +function call is expected to conform to +.St -p1003.1-90 . .Sh HISTORY The .Fn writev @@ -199,7 +247,6 @@ function call appeared in .Bx 4.2 . A -.Nm write -function call -appeared in -Version 6 AT&T UNIX. +.Fn write +function call appeared in +.At v6 . |