diff options
Diffstat (limited to 'lib/libc/sys')
52 files changed, 146 insertions, 901 deletions
diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc index 431aa04ce782..dc65844af2ca 100644 --- a/lib/libc/sys/Makefile.inc +++ b/lib/libc/sys/Makefile.inc @@ -1,5 +1,4 @@ # @(#)Makefile.inc 8.1 (Berkeley) 6/17/93 -# $Id$ # sys sources .PATH: ${.CURDIR}/${MACHINE}/sys ${.CURDIR}/sys @@ -22,13 +21,11 @@ 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 minherit.o mkdir.o mkfifo.o mknod.o mlock.o \ - mount.o \ + madvise.o mincore.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 \ - rtprio.o select.o semsys.o sendmsg.o sendto.o setegid.o seteuid.o \ - setgid.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 \ @@ -92,13 +89,11 @@ MAN2+= sys/accept.2 sys/access.2 sys/acct.2 sys/adjtime.2 sys/bind.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/mkfifo.2 sys/mknod.2 sys/madvise.2 sys/mincore.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/rmdir.2 \ - sys/rtprio.2 sys/select.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/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 \ @@ -110,6 +105,8 @@ MAN2+= sys/accept.2 sys/access.2 sys/acct.2 sys/adjtime.2 sys/bind.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 +# missing: ptrace.2 + MLINKS+=brk.2 sbrk.2 MLINKS+=dup.2 dup2.2 MLINKS+=chdir.2 fchdir.2 diff --git a/lib/libc/sys/_exit.2 b/lib/libc/sys/_exit.2 index 12a5f7e0967d..73e60627453a 100644 --- a/lib/libc/sys/_exit.2 +++ b/lib/libc/sys/_exit.2 @@ -53,7 +53,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 2 +.Xr wait call or catches the .Dv SIGCHLD diff --git a/lib/libc/sys/accept.2 b/lib/libc/sys/accept.2 index 126000a2ecb6..d475e3685b43 100644 --- a/lib/libc/sys/accept.2 +++ b/lib/libc/sys/accept.2 @@ -129,31 +129,6 @@ 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. diff --git a/lib/libc/sys/bind.2 b/lib/libc/sys/bind.2 index f98631d7939b..18512e29e5c9 100644 --- a/lib/libc/sys/bind.2 +++ b/lib/libc/sys/bind.2 @@ -62,28 +62,6 @@ 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 diff --git a/lib/libc/sys/brk.2 b/lib/libc/sys/brk.2 index 0e34e4f7daa9..7580f3855dbf 100644 --- a/lib/libc/sys/brk.2 +++ b/lib/libc/sys/brk.2 @@ -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 2 , +.Xr getrlimit , e.g. .Dq qetext + rlp\(->rlim_max. (see @@ -109,12 +109,12 @@ otherwise -1 with set to indicate why the allocation failed. The .Nm sbrk -function returns a pointer to the base of the new storage if successful; +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 -.Fn Sbrk +.Xr Sbrk will fail and no additional memory will be allocated if one of the following are true: .Bl -tag -width [ENOMEM] @@ -139,7 +139,7 @@ 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 2 . +.Xr getrlimit . .Sh HISTORY A .Nm diff --git a/lib/libc/sys/chown.2 b/lib/libc/sys/chown.2 index 89656f3b2dca..11c3956898e8 100644 --- a/lib/libc/sys/chown.2 +++ b/lib/libc/sys/chown.2 @@ -66,8 +66,7 @@ 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 if not executed -by the super-user. +set-user-id and set-group-id programs. .Pp .Fn Fchown is particularly useful when used in conjunction diff --git a/lib/libc/sys/close.2 b/lib/libc/sys/close.2 index 3a64dac01887..885ac807b693 100644 --- a/lib/libc/sys/close.2 +++ b/lib/libc/sys/close.2 @@ -78,7 +78,7 @@ of the descriptors can be rearranged with or deleted with .Fn close before the -.Xr execve 2 +.Xr execve is attempted, but if some of these descriptors will still be needed if the execve fails, it is necessary to arrange for them to be closed if the execve succeeds. @@ -90,28 +90,6 @@ 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 diff --git a/lib/libc/sys/connect.2 b/lib/libc/sys/connect.2 index a6d7c7133165..eb38ab320b4b 100644 --- a/lib/libc/sys/connect.2 +++ b/lib/libc/sys/connect.2 @@ -68,30 +68,6 @@ 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 @@ -103,10 +79,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. diff --git a/lib/libc/sys/dup.2 b/lib/libc/sys/dup.2 index 29d1ada27b77..898963923e8c 100644 --- a/lib/libc/sys/dup.2 +++ b/lib/libc/sys/dup.2 @@ -95,53 +95,6 @@ is specified. If this descriptor is already in use, the descriptor is first deallocated as if a .Xr close 2 call had been done first. -.Sh 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 diff --git a/lib/libc/sys/execve.2 b/lib/libc/sys/execve.2 index 4db261896152..ba47e6d1833c 100644 --- a/lib/libc/sys/execve.2 +++ b/lib/libc/sys/execve.2 @@ -178,23 +178,6 @@ 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 @@ -244,7 +227,7 @@ is larger than the system-imposed limit. The limit in the system as released is 20480 bytes .Pf ( Dv NCARGS in -.Ao Pa sys/param.h Ac ) . +.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. @@ -267,10 +250,9 @@ 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 diff --git a/lib/libc/sys/flock.2 b/lib/libc/sys/flock.2 index 5ec080c5f5d1..bb6abb75fc5b 100644 --- a/lib/libc/sys/flock.2 +++ b/lib/libc/sys/flock.2 @@ -109,28 +109,6 @@ 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 diff --git a/lib/libc/sys/fork.2 b/lib/libc/sys/fork.2 index b8d465a0892d..0c290f69bd1c 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 2 +.Xr read or -.Xr write 2 +.Xr write by the parent. This descriptor copying is also used by the shell to establish standard input and output for newly created processes diff --git a/lib/libc/sys/fsync.2 b/lib/libc/sys/fsync.2 index 313b4c7a7116..234ea6e996ed 100644 --- a/lib/libc/sys/fsync.2 +++ b/lib/libc/sys/fsync.2 @@ -53,28 +53,6 @@ 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. @@ -94,8 +72,8 @@ An I/O error occurred while reading from or writing to the file system. .El .Sh SEE ALSO .Xr sync 2 , -.Xr update 4 , -.Xr sync 8 +.Xr sync 8 , +.Xr update 8 .Sh HISTORY The .Nm diff --git a/lib/libc/sys/ftruncate.c b/lib/libc/sys/ftruncate.c index 72a6a9158153..2f3ae6d5a024 100644 --- a/lib/libc/sys/ftruncate.c +++ b/lib/libc/sys/ftruncate.c @@ -37,11 +37,6 @@ 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 @@ -53,16 +48,5 @@ 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 b0ecd92287c7..6df944420db6 100644 --- a/lib/libc/sys/getdirentries.2 +++ b/lib/libc/sys/getdirentries.2 @@ -120,28 +120,6 @@ 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 @@ -151,16 +129,16 @@ is set to indicate the error. .Fn Getdirentries will fail if: .Bl -tag -width [EFAULT] -.It Bq Er EBADF +.It EBADF .Fa fd is not a valid file descriptor open for reading. -.It Bq Er EFAULT +.It EFAULT Either .Fa buf or .Fa basep point outside the allocated address space. -.It Bq Er EIO +.It EIO An .Tn I/O error occurred while reading from or writing to the file system. diff --git a/lib/libc/sys/getfh.2 b/lib/libc/sys/getfh.2 index e881066096b4..ab73d5a4b558 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/param.h> +.Fd #include <sys/types.h> .Fd #include <sys/mount.h> .Ft int .Fn getfh "char *path" "fhandle_t *fhp" diff --git a/lib/libc/sys/getgid.2 b/lib/libc/sys/getgid.2 index 574c15a11eb2..52519d767c68 100644 --- a/lib/libc/sys/getgid.2 +++ b/lib/libc/sys/getgid.2 @@ -70,7 +70,7 @@ indicate an error. .Sh SEE ALSO .Xr getuid 2 , .Xr setregid 2 , -.Xr setgid 2 +.Xr setgid 3 .Sh STANDARDS .Fn Getgid and diff --git a/lib/libc/sys/getlogin.2 b/lib/libc/sys/getlogin.2 index b0c6f1bb1483..5b351ca0fed2 100644 --- a/lib/libc/sys/getlogin.2 +++ b/lib/libc/sys/getlogin.2 @@ -66,50 +66,6 @@ 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 @@ -145,8 +101,7 @@ characters, currently 12. The caller tried to set the login name and was not the super-user. .El .Sh SEE ALSO -.Xr setsid 2 , -.Xr daemon 3 +.Xr setsid 2 .Sh BUGS Login names are limited in length by .Fn setlogin . diff --git a/lib/libc/sys/getpeername.2 b/lib/libc/sys/getpeername.2 index 5ca0a443c326..d89488c3aaf9 100644 --- a/lib/libc/sys/getpeername.2 +++ b/lib/libc/sys/getpeername.2 @@ -53,28 +53,6 @@ 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 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 DIAGNOSTICS A 0 is returned if the call succeeds, -1 if it fails. .Sh ERRORS diff --git a/lib/libc/sys/getpid.2 b/lib/libc/sys/getpid.2 index 22f9257b5198..5f77706f30f9 100644 --- a/lib/libc/sys/getpid.2 +++ b/lib/libc/sys/getpid.2 @@ -63,7 +63,7 @@ and functions are always successful, and no return value is reserved to indicate an error. .Sh SEE ALSO -.Xr gethostid 3 +.Xr gethostid 2 .Sh STANDARDS .Fn Getpid and diff --git a/lib/libc/sys/getrlimit.2 b/lib/libc/sys/getrlimit.2 index 42b9028dada9..9aa3c8edac37 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 5 +.Xr core file that may be created. .It Li RLIMIT_CPU The maximum amount of cpu time (in seconds) to be used by @@ -171,11 +171,19 @@ raised the maximum limit value, and the caller is not the super-user. .El .Sh SEE ALSO .Xr csh 1 , -.Xr quota 1 , -.Xr quotactl 2 , +.Xr quota 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 diff --git a/lib/libc/sys/getsockname.2 b/lib/libc/sys/getsockname.2 index e053b4768e7b..d56e40486646 100644 --- a/lib/libc/sys/getsockname.2 +++ b/lib/libc/sys/getsockname.2 @@ -51,28 +51,6 @@ the amount of space pointed to by .Fa name . On return it contains the actual size of the name returned (in bytes). -.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 DIAGNOSTICS A 0 is returned if the call succeeds, -1 if it fails. .Sh ERRORS diff --git a/lib/libc/sys/getsockopt.2 b/lib/libc/sys/getsockopt.2 index 5adfdec61c33..46d3d8a53fc9 100644 --- a/lib/libc/sys/getsockopt.2 +++ b/lib/libc/sys/getsockopt.2 @@ -29,10 +29,9 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)getsockopt.2 8.3 (Berkeley) 4/19/94 -.\" $Id$ +.\" @(#)getsockopt.2 8.3 (Berkeley) 4/19/94 .\" -.Dd November 3, 1995 +.Dd April 19, 1994 .Dt GETSOCKOPT 2 .Os BSD 4.3r .Sh NAME @@ -190,7 +189,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 2 +.Xr close 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 @@ -201,7 +200,7 @@ is requested). If .Dv SO_LINGER is disabled and a -.Xr close 2 +.Xr close is issued, the system will process the close in a manner that allows the process to continue as quickly as possible. .Pp @@ -215,9 +214,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 2 +.Xr recv or -.Xr read 2 +.Xr read calls without the .Dv MSG_OOB flag. @@ -229,11 +228,7 @@ 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 maximum on these values, which is accessible -through the -.Xr sysctl 3 -MIB variable -.Dq Li kern.maxsockbuf . +The system places an absolute limit on these values. .Pp .Dv SO_SNDLOWAT is an option to set the minimum count for output operations. @@ -266,7 +261,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 from that which was returned. +is different than that returned. .Pp .Dv SO_SNDTIMEO is an option to set a timeout value for output operations. @@ -313,49 +308,6 @@ 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 @@ -384,10 +336,8 @@ is not in a valid part of the process address space. .Sh SEE ALSO .Xr ioctl 2 , .Xr socket 2 , -.Xr getprotoent 3 , -.Xr sysctl 3 , -.Xr protocols 5 , -.Xr sysctl 8 +.Xr getprotoent 3 +.Xr protocols 5 .Sh BUGS Several of the socket options should be handled at lower levels of the system. .Sh HISTORY diff --git a/lib/libc/sys/intro.2 b/lib/libc/sys/intro.2 index 79aad8a8a6b6..bf4380917e39 100644 --- a/lib/libc/sys/intro.2 +++ b/lib/libc/sys/intro.2 @@ -47,49 +47,13 @@ their error returns, and other common definitions and concepts. .\".Pp .\"<more later...> .Sh DIAGNOSTICS -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: +Nearly all of the system calls provide an error number in the external +variable +.Va errno , +which is defined as: .Pp .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 indicating failure (usually -1) @@ -159,9 +123,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 2 +.Xr wait or -.Xr waitpid 2 +.Xr waitpid function was executed by a process that had no existing or unwaited-for child processes. .It Er 11 EDEADLK Em "Resource deadlock avoided" . @@ -187,7 +151,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 2 +.Xr link function. .It Er 18 EXDEV Em "Improper link" . A hard link to a file on another file system @@ -205,9 +169,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 3 +.Xr signal or -.Xr kill 2 +.Xr kill function). .It Er 23 ENFILE Em "Too many open files in system" . Maximum number of file descriptors allowable on the system @@ -227,7 +191,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 2 +.Xr open call requested write access. .It Er 27 EFBIG Em "File too large" . The size of a file exceeded the maximum (about @@ -236,7 +200,7 @@ The size of a file exceeded the maximum (about bytes). .It Er 28 ENOSPC Em "Device out of space" . A -.Xr write 2 +.Xr write 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 @@ -245,7 +209,7 @@ created file failed because no more inodes were available on the file system. .It Er 29 ESPIPE Em "Illegal seek" . An -.Xr lseek 2 +.Xr lseek function was issued on a socket, pipe or .Tn FIFO . .It Er 30 EROFS Em "Read-only file system" . @@ -344,12 +308,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 2 +.Xr connect request was made on an already connected socket; or, a -.Xr sendto 2 +.Xr sendto or -.Xr sendmsg 2 +.Xr sendmsg request on a connected socket specified a destination when already connected. .It Er 57 ENOTCONN Em "Socket is not connected" . @@ -363,9 +327,9 @@ had already been shut down with a previous call. .It Er 60 ETIMEDOUT Em "Operation timed out" . A -.Xr connect 2 +.Xr connect or -.Xr send 2 +.Xr send request failed because the connected party did not properly respond after a period of time. (The timeout period is dependent on the communication protocol.) @@ -397,7 +361,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 2 +.Xr write 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 @@ -450,7 +414,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 8 . +.Xr init . .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 @@ -497,7 +461,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 -.Nm init , +.Xr 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). @@ -701,5 +665,4 @@ 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 -.Xr intro 3 , -.Xr perror 3 +intro(3), perror(3) diff --git a/lib/libc/sys/ioctl.2 b/lib/libc/sys/ioctl.2 index 38c58b9dcf59..36ce6ff47f65 100644 --- a/lib/libc/sys/ioctl.2 +++ b/lib/libc/sys/ioctl.2 @@ -68,28 +68,6 @@ 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 diff --git a/lib/libc/sys/ktrace.2 b/lib/libc/sys/ktrace.2 index fd4515fc6082..9fe61f89570f 100644 --- a/lib/libc/sys/ktrace.2 +++ b/lib/libc/sys/ktrace.2 @@ -38,9 +38,7 @@ .Nm ktrace .Nd process tracing .Sh SYNOPSIS -.Fd #include <sys/param.h> -.Fd #include <sys/time.h> -.Fd #include <sys/uio.h> +.Fd #include <sys/types.h> .Fd #include <sys/ktrace.h> .Ft int .Fn ktrace "const char *tracefile" "int ops" "int trpoints" "int pid" diff --git a/lib/libc/sys/link.2 b/lib/libc/sys/link.2 index 4c27ab9765ac..d1607862d2c5 100644 --- a/lib/libc/sys/link.2 +++ b/lib/libc/sys/link.2 @@ -74,6 +74,7 @@ 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 @@ -112,7 +113,8 @@ does exist. .It Bq Er EPERM The file named by .Fa name1 -is a directory. +is a directory and the effective +user ID is not super-user. .It Bq Er EXDEV The link named by .Fa name2 @@ -147,10 +149,3 @@ is outside the process's allocated address space. is expected to conform to IEEE Std 1003.1-1988 .Pq Dq Tn POSIX . -.Sh HISTORY -.Pp -The -.Nm -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 b3271dd2d62c..0ab28bc2bd59 100644 --- a/lib/libc/sys/listen.2 +++ b/lib/libc/sys/listen.2 @@ -29,10 +29,9 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" From: @(#)listen.2 8.2 (Berkeley) 12/11/93 -.\" $Id$ +.\" @(#)listen.2 8.2 (Berkeley) 12/11/93 .\" -.Dd November 3, 1995 +.Dd December 11, 1993 .Dt LISTEN 2 .Os BSD 4.2 .Sh NAME @@ -69,41 +68,6 @@ 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 @@ -125,17 +89,13 @@ The socket is not of a type that supports the operation .Sh SEE ALSO .Xr accept 2 , .Xr connect 2 , -.Xr socket 2 , -.Xr sysctl 3 , -.Xr sysctl 8 +.Xr socket 2 +.Sh BUGS +The +.Fa backlog +is currently limited (silently) to 32. .Sh HISTORY The .Nm 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.c b/lib/libc/sys/lseek.c index 8896ad8d3567..52208d137a93 100644 --- a/lib/libc/sys/lseek.c +++ b/lib/libc/sys/lseek.c @@ -37,11 +37,6 @@ 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 @@ -53,17 +48,7 @@ lseek(fd, offset, whence) off_t offset; int whence; { -#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); + extern off_t __syscall(); -#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 4326389b1eb1..d0676ab18fce 100644 --- a/lib/libc/sys/madvise.2 +++ b/lib/libc/sys/madvise.2 @@ -38,9 +38,7 @@ .Nm madvise .Nd give advise about use of memory .Sh SYNOPSIS -.Fd #include <sys/types.h> -.Fd #include <sys/mman.h> -.Fn madvise "caddr_t addr" "size_t len" "int behav" +.Fn madvise "caddr_t addr" "int len" "int behav" .Sh DESCRIPTION The .Fn madvise @@ -61,12 +59,7 @@ The known behaviors are given in .Xr msync 2 , .Xr munmap 2 , .Xr mprotect 2 , -.Xr mincore 2 . - -.Sh BUGS -.Nm madvise -is not yet implemented. - +.Xr mincore 2 .Sh HISTORY The .Nm madvise diff --git a/lib/libc/sys/mincore.2 b/lib/libc/sys/mincore.2 index a51fcc9fc464..4e73c2ab90f8 100644 --- a/lib/libc/sys/mincore.2 +++ b/lib/libc/sys/mincore.2 @@ -38,9 +38,7 @@ .Nm mincore .Nd get advise about use of memory .Sh SYNOPSIS -.Fd #include <sys/types.h> -.Fd #include <sys/mman.h> -.Fn mincore "caddr_t addr" "size_t len" "char *vec" +.Fn mincore "caddr_t addr" "int len" "char *vec" .Sh DESCRIPTION The .Fn mincore diff --git a/lib/libc/sys/mmap.2 b/lib/libc/sys/mmap.2 index 2b87189dc723..1c0d84a85d0c 100644 --- a/lib/libc/sys/mmap.2 +++ b/lib/libc/sys/mmap.2 @@ -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 execve 2 +.Xr exec 2 system calls. .It Dv MAP_PRIVATE Modifications are private. @@ -202,27 +202,9 @@ parameter wasn't available. .Dv MAP_ANON was specified and insufficient memory was available. .Sh "SEE ALSO" +.Xr getpagesize 2 , .Xr msync 2 , .Xr munmap 2 , .Xr mprotect 2 , .Xr madvise 2 , -.Xr mincore 2 , -.Xr mlock 2 , -.Xr munlock 2 , -.Xr getpagesize 3 - -.Sh BUGS -.Ar len -is limit to 2GB. Mmapping slightly more than 2GB doesn't work, but -mapping 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 use 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. +.Xr mincore 2 diff --git a/lib/libc/sys/mprotect.2 b/lib/libc/sys/mprotect.2 index 4ddd65d5e8ac..bb2b9ad21e44 100644 --- a/lib/libc/sys/mprotect.2 +++ b/lib/libc/sys/mprotect.2 @@ -38,9 +38,7 @@ .Nm mprotect .Nd control the protection of pages .Sh SYNOPSIS -.Fd #include <sys/types.h> -.Fd #include <sys/mman.h> -.Fn mprotect "caddr_t addr" "size_t len" "int prot" +.Fn mprotect "caddr_t addr" "int len" "int prot" .Sh DESCRIPTION The .Fn mprotect diff --git a/lib/libc/sys/msync.2 b/lib/libc/sys/msync.2 index 409dd08b35a2..d976e304599e 100644 --- a/lib/libc/sys/msync.2 +++ b/lib/libc/sys/msync.2 @@ -38,9 +38,7 @@ .Nm msync .Nd synchronize a mapped region .Sh SYNOPSIS -.Fd #include <sys/types.h> -.Fd #include <sys/mman.h> -.Fn msync "caddr_t addr" "size_t len" "int flags" +.Fn msync "caddr_t addr" "int len" "int flags" .Sh DESCRIPTION The .Fn msync diff --git a/lib/libc/sys/munmap.2 b/lib/libc/sys/munmap.2 index 5d14016e887d..b9e8a1b0841c 100644 --- a/lib/libc/sys/munmap.2 +++ b/lib/libc/sys/munmap.2 @@ -38,8 +38,6 @@ .Nm munmap .Nd remove a mapping .Sh SYNOPSIS -.Fd #include <sys/types.h> -.Fd #include <sys/mman.h> .Fn munmap "caddr_t addr" "size_t len" .Sh DESCRIPTION The @@ -68,12 +66,12 @@ 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 msync 2 , .Xr munmap 2 , .Xr mprotect 2 , .Xr madvise 2 , -.Xr mincore 2 , -.Xr getpagesize 3 +.Xr mincore 2 .Sh HISTORY The .Fn munmap diff --git a/lib/libc/sys/open.2 b/lib/libc/sys/open.2 index bb7526250cb4..dea59fcce346 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 2 +.Xr execve system calls; see .Xr close 2 and @@ -146,26 +146,6 @@ 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 ERRORS The named file is opened unless: .Bl -tag -width Er diff --git a/lib/libc/sys/pipe.2 b/lib/libc/sys/pipe.2 index 763cc2fc7dfa..51b7364bf86c 100644 --- a/lib/libc/sys/pipe.2 +++ b/lib/libc/sys/pipe.2 @@ -48,13 +48,12 @@ function creates a .Em pipe , which is an object allowing -bidirectional data flow, +unidirectional data flow, and allocates a pair of file descriptors. -.Pp -By convention, the first descriptor is normally used as the +The first descriptor connects to the .Em read end of the pipe, -and the second is normally the +and the second connects to the .Em write end , so that data written to .Fa fildes[1] @@ -70,7 +69,7 @@ the read end of the pipe. The pipe itself persists until all its associated descriptors are closed. .Pp -A pipe that has had an end closed is considered +A pipe whose read or write end has been closed is considered .Em widowed . Writing on such a pipe causes the writing process to receive a @@ -80,10 +79,9 @@ 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 -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. +Pipes are really a special case of the +.Xr socketpair 2 +call and, in fact, are implemented as such in the system. .Sh RETURN VALUES On successful creation of the pipe, zero is returned. Otherwise, a value of -1 is returned and the variable @@ -115,5 +113,3 @@ space. A .Nm function call appeared in Version 6 AT&T UNIX. -.Pp -Bidirectional pipes were first used on Unix System V release 4. diff --git a/lib/libc/sys/ptrace.2 b/lib/libc/sys/ptrace.2 index dc66d1d77d44..f9cf5d106206 100644 --- a/lib/libc/sys/ptrace.2 +++ b/lib/libc/sys/ptrace.2 @@ -75,7 +75,7 @@ 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 +reads from the data space. In the current NetBSD implementation, these two requests are completely identical. The .Fa addr argument specifies the address (in the traced process' virtual address @@ -145,61 +145,6 @@ The traced process terminates, as if 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 ERRORS Some requests can cause @@ -219,10 +164,6 @@ No process having the specified process ID exists. .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. @@ -241,40 +182,12 @@ The signal number (in 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 ) +A request 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 sigaction 2 diff --git a/lib/libc/sys/quotactl.2 b/lib/libc/sys/quotactl.2 index f40a0dee2d0b..047d070d2be3 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 -.Fd #include <ufs/ufs/quota.h> /* for ufs quotas */ +.Ft #include <ufs/ufs/quota.h> /* for ufs quotas */ .Ft int .Fn quotactl "const char *path" "int cmd" "int id" "char *addr" .Sh DESCRIPTION diff --git a/lib/libc/sys/read.2 b/lib/libc/sys/read.2 index ea428fd47a12..b94341a043c0 100644 --- a/lib/libc/sys/read.2 +++ b/lib/libc/sys/read.2 @@ -107,53 +107,6 @@ 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, diff --git a/lib/libc/sys/reboot.2 b/lib/libc/sys/reboot.2 index ad66ee5646db..0db9ea2349cb 100644 --- a/lib/libc/sys/reboot.2 +++ b/lib/libc/sys/reboot.2 @@ -140,6 +140,7 @@ variable The caller is not the super-user. .El .Sh SEE ALSO +.Xr kadb 4 , .Xr crash 8 , .Xr halt 8 , .Xr init 8 , diff --git a/lib/libc/sys/rtprio.2 b/lib/libc/sys/rtprio.2 index 1fd18ee5f05d..8b74272999e1 100644 --- a/lib/libc/sys/rtprio.2 +++ b/lib/libc/sys/rtprio.2 @@ -35,10 +35,10 @@ .Nm rtprio .Nd examine or modify a process realtime or idle priority .Sh SYNOPSIS -.Fd #include <sys/types.h> +.Fd #include <sys/resource.h> .Fd #include <sys/rtprio.h> .Ft int -.Fn rtprio "int function" "pid_t pid" "struct rtprio *rtp" +.Fn rtprio "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. @@ -101,6 +101,6 @@ implementation in FreeBSD was substantially rewritten by David Greenman. .Xr rtprio 1 , .Xr nice 1 , .Xr ps 1 , -.Xr setpriority 2 , -.Xr nice 3 , +.Xr nice 2 , .Xr renice 8 + diff --git a/lib/libc/sys/setsid.2 b/lib/libc/sys/setsid.2 index 404b1b81a008..48ac6a071785 100644 --- a/lib/libc/sys/setsid.2 +++ b/lib/libc/sys/setsid.2 @@ -68,7 +68,7 @@ group ID of a process other than the calling process matches the process ID of the calling process. .El .Sh SEE ALSO -.Xr setpgid 2 , +.Xr setpgid 3 , .Xr tcgetpgrp 3 , .Xr tcsetpgrp 3 .Sh STANDARDS diff --git a/lib/libc/sys/sigaction.2 b/lib/libc/sys/sigaction.2 index b9fe5caca506..3f41266a9c81 100644 --- a/lib/libc/sys/sigaction.2 +++ b/lib/libc/sys/sigaction.2 @@ -50,7 +50,7 @@ struct sigaction { .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 normally blocked from further occurrence, the current process +the signal is 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 normally execute with the signal that caused their +Signal routines execute with the signal that caused their invocation .Em blocked , but other signals may yet occur. @@ -131,7 +131,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 normally remains installed +Once a signal handler is installed, it remains installed until another .Fn sigaction call is made, or an @@ -178,16 +178,7 @@ bit is set in the system will deliver the signal to the process on a .Em "signal stack" , specified with -.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. +.Xr sigstack 2 . .Pp If a signal is caught during the system calls listed below, the call may be forced to terminate @@ -243,7 +234,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 3 +.It Dv SIGABRT No " create core image" Xr abort 2 call (formerly .Dv SIGIOT ) .It Dv SIGEMT No " create core image" " emulate instruction executed" @@ -251,7 +242,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" " non-existent system call invoked" +.It Dv SIGSYS No " create core image" " system call given invalid argument" .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" @@ -361,11 +352,6 @@ 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 , @@ -376,7 +362,7 @@ are intended for backwards compatability with other operating systems. .Xr sigblock 2 , .Xr sigsetmask 2 , .Xr sigpause 2 , -.Xr sigaltstack 2 , +.Xr sigstack 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 4892a923fcbd..f1ed718eb966 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 SS_DISABLE +.Dv SA_DISABLE is set in .Fa ss_flags , .Fa ss_sp @@ -95,9 +95,9 @@ is non-zero, the current signal stack state is returned. The .Fa ss_flags field will contain the value -.Dv SS_ONSTACK +.Dv SA_ONSTACK if the process is currently on a signal stack and -.Dv SS_DISABLE +.Dv SA_DISABLE if the signal stack is currently disabled. .Sh NOTES The value diff --git a/lib/libc/sys/stat.2 b/lib/libc/sys/stat.2 index 51a5b2e5ff4b..27bc183ddeb0 100644 --- a/lib/libc/sys/stat.2 +++ b/lib/libc/sys/stat.2 @@ -256,7 +256,7 @@ depend on the time stamps being contiguous (in calls to .Xr symlink 7 .Sh BUGS Applying -.Fn fstat +.Xr fstat to a socket (and thus to a pipe) returns a zeroed buffer, except for the blocksize field, diff --git a/lib/libc/sys/sync.2 b/lib/libc/sys/sync.2 index 6309c18c7261..5e79feff2d28 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 4 +.Xr update 8 (about every 30 seconds). .Pp The function @@ -62,8 +62,8 @@ may be used to synchronize individual file descriptor attributes. .Sh SEE ALSO .Xr fsync 2 , -.Xr update 4 , -.Xr sync 8 +.Xr sync 8 , +.Xr update 8 .Sh BUGS .Fn Sync may return before the buffers are completely flushed. diff --git a/lib/libc/sys/unlink.2 b/lib/libc/sys/unlink.2 index 1f469453d5ad..78221bc505fc 100644 --- a/lib/libc/sys/unlink.2 +++ b/lib/libc/sys/unlink.2 @@ -56,8 +56,6 @@ 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 @@ -85,7 +83,8 @@ 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. +The named file is a directory and the effective user ID +of the process is not the super-user. .It Bq Er EPERM The directory containing the file is marked sticky, and neither the containing directory nor the file to be removed @@ -111,9 +110,3 @@ points outside the process's allocated address space. An .Nm function call appeared in Version 6 AT&T UNIX. -.Pp -The -.Nm -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 125b6193c637..1ebeb37eecd9 100644 --- a/lib/libc/sys/utimes.2 +++ b/lib/libc/sys/utimes.2 @@ -82,7 +82,7 @@ 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 -.Fa File +.Xr File or .Fa times points outside the process's allocated address space. diff --git a/lib/libc/sys/vfork.2 b/lib/libc/sys/vfork.2 index 0d0dbf02d3be..8b6e077a90ee 100644 --- a/lib/libc/sys/vfork.2 +++ b/lib/libc/sys/vfork.2 @@ -48,16 +48,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 2 . +.Xr execve . .Fn Vfork differs from -.Xr fork 2 +.Xr fork in that the child borrows the parent's memory and thread of control until a call to .Xr execve 2 or an exit (either by a call to -.Xr exit 3 -or abnormally). +.Xr exit 2 +or abnormally.) The parent process is suspended while the child is using its resources. .Pp .Fn Vfork @@ -66,7 +66,7 @@ the parent's context. .Pp .Fn Vfork can normally be used just like -.Xr fork 2 . +.Xr fork . It does not work, however, to return while running in the childs context from the procedure that called .Fn vfork @@ -74,19 +74,19 @@ since the eventual return from .Fn vfork would then return to a no longer existent stack frame. Be careful, also, to call -.Xr _exit 2 +.Xr _exit rather than -.Xr exit 3 +.Xr exit if you can't -.Xr execve 2 , +.Xr execve , since -.Xr exit 3 +.Xr exit will flush and close standard I/O channels, and thereby mess up the parent processes standard I/O data structures. (Even with -.Xr fork 2 +.Xr fork it is wrong to call -.Xr exit 3 +.Xr exit since buffered data would then be flushed twice.) .Sh SEE ALSO .Xr fork 2 , @@ -95,15 +95,15 @@ since buffered data would then be flushed twice.) .Xr wait 2 , .Sh DIAGNOSTICS Same as for -.Xr fork 2 . +.Xr fork . .Sh BUGS This system call will be eliminated when proper system sharing mechanisms are implemented. Users should not depend on the memory sharing semantics of -.Xr vfork 2 +.Xr vfork as it will, in that case, be made synonymous to -.Xr fork 2 . +.Xr fork . .Pp To avoid a possible deadlock situation, processes that are children in the middle diff --git a/lib/libc/sys/wait.2 b/lib/libc/sys/wait.2 index cd9ab62750e7..c0077b150ce8 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 3 . +.Xr exit 2 . .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 3 +.Xr exit 2 by the child. .It Fn WTERMSIG status If @@ -287,9 +287,8 @@ 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 3 +.Xr exit 2 , +.Xr sigaction 2 .Sh HISTORY A .Nm diff --git a/lib/libc/sys/write.2 b/lib/libc/sys/write.2 index a1e4a517cbe2..de2d3aef59ab 100644 --- a/lib/libc/sys/write.2 +++ b/lib/libc/sys/write.2 @@ -115,53 +115,6 @@ 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 |
