diff options
author | sjg <sjg@FreeBSD.org> | 2013-10-13 02:35:19 +0000 |
---|---|---|
committer | sjg <sjg@FreeBSD.org> | 2013-10-13 02:35:19 +0000 |
commit | 7fcd33c1faf567506b5c0b4148c7a15a10788a5d (patch) | |
tree | 2c6f4d1ca5d1c643faea64e1f4c90105a1ab406a /lib/libc | |
parent | 2a59274eda20cc626e28052fff7aa8b7bf6a3683 (diff) | |
parent | 5cca672bb0892f1c5da630c34a1f98e2de4d7064 (diff) | |
download | FreeBSD-src-7fcd33c1faf567506b5c0b4148c7a15a10788a5d.zip FreeBSD-src-7fcd33c1faf567506b5c0b4148c7a15a10788a5d.tar.gz |
Merge head@256284
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/gen/lockf.3 | 12 | ||||
-rw-r--r-- | lib/libc/net/sctp_sys_calls.c | 7 | ||||
-rw-r--r-- | lib/libc/sys/Makefile.inc | 1 | ||||
-rw-r--r-- | lib/libc/sys/Symbol.map | 3 | ||||
-rw-r--r-- | lib/libc/sys/accept.2 | 13 | ||||
-rw-r--r-- | lib/libc/sys/close.2 | 6 | ||||
-rw-r--r-- | lib/libc/sys/ioctl.2 | 12 | ||||
-rw-r--r-- | lib/libc/sys/procctl.2 | 142 | ||||
-rw-r--r-- | lib/libc/sys/read.2 | 20 | ||||
-rw-r--r-- | lib/libc/sys/socketpair.2 | 6 | ||||
-rw-r--r-- | lib/libc/sys/write.2 | 18 |
11 files changed, 197 insertions, 43 deletions
diff --git a/lib/libc/gen/lockf.3 b/lib/libc/gen/lockf.3 index d9350d1..a4adcfa 100644 --- a/lib/libc/gen/lockf.3 +++ b/lib/libc/gen/lockf.3 @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 19, 1997 +.Dd September 11, 2013 .Dt LOCKF 3 .Os .Sh NAME @@ -40,7 +40,7 @@ .Sh SYNOPSIS .In unistd.h .Ft int -.Fn lockf "int filedes" "int function" "off_t size" +.Fn lockf "int fd" "int function" "off_t size" .Sh DESCRIPTION The .Fn lockf @@ -52,7 +52,7 @@ either return an error value or block until the section becomes unlocked. All the locks for a process are removed when the process terminates. .Pp The argument -.Fa filedes +.Fa fd is an open file descriptor. The file descriptor must have been opened either for write-only .Dv ( O_WRONLY ) @@ -207,7 +207,7 @@ or and the section is already locked by another process. .It Bq Er EBADF The argument -.Fa filedes +.Fa fd is not a valid open file descriptor. .Pp The argument @@ -217,7 +217,7 @@ is or .Dv F_TLOCK , and -.Fa filedes +.Fa fd is not a valid file descriptor open for writing. .It Bq Er EDEADLK The argument @@ -243,7 +243,7 @@ or .Dv F_TEST . .Pp The argument -.Fa filedes +.Fa fd refers to a file that does not support locking. .It Bq Er ENOLCK The argument diff --git a/lib/libc/net/sctp_sys_calls.c b/lib/libc/net/sctp_sys_calls.c index 1b65b07..fda9676 100644 --- a/lib/libc/net/sctp_sys_calls.c +++ b/lib/libc/net/sctp_sys_calls.c @@ -101,10 +101,10 @@ sctp_connectx(int sd, const struct sockaddr *addrs, int addrcnt, sctp_assoc_t * id) { char *buf; - int i, ret, cnt, *aa; + int i, ret, *aa; char *cpto; const struct sockaddr *at; - size_t len = sizeof(int); + size_t len; /* validate the address count and list */ if ((addrs == NULL) || (addrcnt <= 0)) { @@ -115,8 +115,8 @@ sctp_connectx(int sd, const struct sockaddr *addrs, int addrcnt, errno = E2BIG; return (-1); } + len = sizeof(int); at = addrs; - cnt = 0; cpto = buf + sizeof(int); /* validate all the addresses and get the size */ for (i = 0; i < addrcnt; i++) { @@ -161,6 +161,7 @@ sctp_connectx(int sd, const struct sockaddr *addrs, int addrcnt, if ((ret == 0) && (id != NULL)) { *id = *(sctp_assoc_t *) buf; } + free(buf); return (ret); } diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc index 4cc87ae..ac5907b 100644 --- a/lib/libc/sys/Makefile.inc +++ b/lib/libc/sys/Makefile.inc @@ -197,6 +197,7 @@ MAN+= abort2.2 \ posix_fadvise.2 \ posix_fallocate.2 \ posix_openpt.2 \ + procctl.2 \ profil.2 \ pselect.2 \ ptrace.2 \ diff --git a/lib/libc/sys/Symbol.map b/lib/libc/sys/Symbol.map index 222f5f0..fe887c3 100644 --- a/lib/libc/sys/Symbol.map +++ b/lib/libc/sys/Symbol.map @@ -395,6 +395,7 @@ FBSD_1.3 { ffclock_setestimate; pipe2; posix_fadvise; + procctl; wait6; }; @@ -822,6 +823,8 @@ FBSDprivate_1.0 { __sys_poll; _preadv; __sys_preadv; + _procctl; + __sys_procctl; _profil; __sys_profil; _pselect; diff --git a/lib/libc/sys/accept.2 b/lib/libc/sys/accept.2 index 76fb463..7b8422a 100644 --- a/lib/libc/sys/accept.2 +++ b/lib/libc/sys/accept.2 @@ -28,7 +28,7 @@ .\" @(#)accept.2 8.2 (Berkeley) 12/11/93 .\" $FreeBSD$ .\" -.Dd May 1, 2013 +.Dd October 1, 2013 .Dt ACCEPT 2 .Os .Sh NAME @@ -155,13 +155,20 @@ For some applications, performance may be enhanced by using an .Xr accept_filter 9 to pre-process incoming connections. .Pp -Portable programs should not rely on the +When using +.Fn accept , +portable programs should not rely on the .Dv O_NONBLOCK and .Dv O_ASYNC properties and the signal destination being inherited, but should set them explicitly using -.Xr fcntl 2 . +.Xr fcntl 2 ; +.Fn accept4 +sets these properties consistently, +but may not be fully portable across +.Ux +platforms. .Sh RETURN VALUES These calls return \-1 on error. If they succeed, they return a non-negative diff --git a/lib/libc/sys/close.2 b/lib/libc/sys/close.2 index c3a0972..6df4500 100644 --- a/lib/libc/sys/close.2 +++ b/lib/libc/sys/close.2 @@ -28,7 +28,7 @@ .\" @(#)close.2 8.2 (Berkeley) 4/19/94 .\" $FreeBSD$ .\" -.Dd January 22, 2012 +.Dd September 11, 2013 .Dt CLOSE 2 .Os .Sh NAME @@ -39,7 +39,7 @@ .Sh SYNOPSIS .In unistd.h .Ft int -.Fn close "int d" +.Fn close "int fd" .Sh DESCRIPTION The .Fn close @@ -107,7 +107,7 @@ system call will fail if: .Bl -tag -width Er .It Bq Er EBADF The -.Fa d +.Fa fd argument is not an active descriptor. .It Bq Er EINTR diff --git a/lib/libc/sys/ioctl.2 b/lib/libc/sys/ioctl.2 index bab7b47..81500a9 100644 --- a/lib/libc/sys/ioctl.2 +++ b/lib/libc/sys/ioctl.2 @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 11, 2010 +.Dd September 11, 2013 .Dt IOCTL 2 .Os .Sh NAME @@ -40,7 +40,7 @@ .Sh SYNOPSIS .In sys/ioctl.h .Ft int -.Fn ioctl "int d" "unsigned long request" ... +.Fn ioctl "int fd" "unsigned long request" ... .Sh DESCRIPTION The .Fn ioctl @@ -51,7 +51,7 @@ may be controlled with .Fn ioctl requests. The argument -.Fa d +.Fa fd must be an open file descriptor. .Pp The third argument to @@ -116,19 +116,19 @@ will fail if: .Bl -tag -width Er .It Bq Er EBADF The -.Fa d +.Fa fd argument is not a valid descriptor. .It Bq Er ENOTTY The -.Fa d +.Fa fd argument is not associated with a character special device. .It Bq Er ENOTTY The specified request does not apply to the kind of object that the descriptor -.Fa d +.Fa fd references. .It Bq Er EINVAL The diff --git a/lib/libc/sys/procctl.2 b/lib/libc/sys/procctl.2 new file mode 100644 index 0000000..32bf34d --- /dev/null +++ b/lib/libc/sys/procctl.2 @@ -0,0 +1,142 @@ +.\" Copyright (c) 2013 Advanced Computing Technologies LLC +.\" Written by: John H. Baldwin <jhb@FreeBSD.org> +.\" 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 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. +.\" +.\" $FreeBSD$ +.\" +.Dd September 19, 2013 +.Dt PROCCTL 2 +.Os +.Sh NAME +.Nm procctl +.Nd control processes +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/procctl.h +.Ft int +.Fn procctl "idtype_t idtype" "id_t id" "int cmd" "void *arg" +.Sh DESCRIPTION +The +.Fn procctl +system call provides for control over processes. +The +.Fa idtype +and +.Fa id +arguments specify the set of processes to control. +If multiple processes match the identifier, +.Nm +will make a +.Dq best effort +to control as many of the selected possibles as possible. +An error is only returned if no selected processes successfully complete +the request. +The following identifier types are supported: +.Bl -tag -width "Dv P_PGID" +.It Dv P_PID +Control the process with the process ID +.Fa id . +.It Dv P_PGID +Control processes belonging to the process group with the ID +.Fa id . +.El +.Pp +The control request to perform is specified by the +.Fa cmd +argument. +The following commands are supported: +.Bl -tag -width "Dv PROC_SPROTECT" +.It Dv PROC_SPROTECT +Set process protection state. +This is used to mark a process as protected from being killed if the system +exhausts available memory and swap. +The +.Fa arg +parameter must point to an integer containing an operation and zero or more +optional flags. +The following operations are supported: +.Bl -tag -width "Dv PPROT_CLEAR" +.It Dv PPROT_SET +Mark the selected processes as protected. +.It Dv PPROT_CLEAR +Clear the protected state of selected processes. +.El +.Pp +The following optional flags are supported: +.Bl -tag -width "Dv PPROT_DESCE" +.It Dv PPROT_DESCEND +Apply the requested operation to all child processes of each selected process +in addition to each selected process. +.It Dv PPROT_INHERIT +When used with +.Dv PPROT_SET , +mark all future child processes of each selected process as protected. +Future child processes will also mark all of their future child processes. +.El +.El +.Sh RETURN VALUES +If an error occurs, a value of -1 is returned and +.Va errno +is set to indicate the error. +.Sh ERRORS +The +.Fn procctl +system call +will fail if: +.Bl -tag -width Er +.It Bq Er EFAULT +The +.Fa arg +points outside the process's allocated address space. +.It Bq Er EINVAL +The +.Fa cmd +argument specifies an unsupported command. +.Pp +The +.Fa idtype +argument specifies an unsupported identifier type. +.It Bq Er EPERM +The calling process does not have permission to perform the requested +operation on any of the selected processes. +.It Bq Er ESRCH +No processes matched the requested +.Fa idtype +and +.Fa id . +.It Bq Er EINVAL +An invalid operation or flag was passed in +.Fa arg +for a +.Dv PROC_SPROTECT +command. +.El +.Sh SEE ALSO +.Xr ptrace 2 +.Sh HISTORY +The +.Fn procctl +function appeared in +.Fx 10 . diff --git a/lib/libc/sys/read.2 b/lib/libc/sys/read.2 index 2127eda..e99665f 100644 --- a/lib/libc/sys/read.2 +++ b/lib/libc/sys/read.2 @@ -28,7 +28,7 @@ .\" @(#)read.2 8.4 (Berkeley) 2/26/94 .\" $FreeBSD$ .\" -.Dd January 22, 2012 +.Dd September 11, 2013 .Dt READ 2 .Os .Sh NAME @@ -43,14 +43,14 @@ .In sys/types.h .In unistd.h .Ft ssize_t -.Fn read "int d" "void *buf" "size_t nbytes" +.Fn read "int fd" "void *buf" "size_t nbytes" .Ft ssize_t -.Fn pread "int d" "void *buf" "size_t nbytes" "off_t offset" +.Fn pread "int fd" "void *buf" "size_t nbytes" "off_t offset" .In sys/uio.h .Ft ssize_t -.Fn readv "int d" "const struct iovec *iov" "int iovcnt" +.Fn readv "int fd" "const struct iovec *iov" "int iovcnt" .Ft ssize_t -.Fn preadv "int d" "const struct iovec *iov" "int iovcnt" "off_t offset" +.Fn preadv "int fd" "const struct iovec *iov" "int iovcnt" "off_t offset" .Sh DESCRIPTION The .Fn read @@ -58,7 +58,7 @@ system call attempts to read .Fa nbytes of data from the object referenced by the descriptor -.Fa d +.Fa fd into the buffer pointed to by .Fa buf . The @@ -107,7 +107,7 @@ On objects capable of seeking, the .Fn read starts at a position given by the pointer associated with -.Fa d +.Fa fd (see .Xr lseek 2 ) . Upon return from @@ -149,12 +149,12 @@ will succeed unless: .Bl -tag -width Er .It Bq Er EBADF The -.Fa d +.Fa fd argument is not a valid file or socket descriptor open for reading. .It Bq Er ECONNRESET The -.Fa d +.Fa fd argument refers to a socket, and the remote socket end is forcibly closed. .It Bq Er EFAULT @@ -173,7 +173,7 @@ was interrupted by the delivery of a signal before any data arrived. .It Bq Er EINVAL The pointer associated with -.Fa d +.Fa fd was negative. .It Bq Er EAGAIN The file was marked for non-blocking I/O, diff --git a/lib/libc/sys/socketpair.2 b/lib/libc/sys/socketpair.2 index 08d00d3..d3a47eb 100644 --- a/lib/libc/sys/socketpair.2 +++ b/lib/libc/sys/socketpair.2 @@ -28,7 +28,7 @@ .\" @(#)socketpair.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd March 19, 2013 +.Dd September 11, 2013 .Dt SOCKETPAIR 2 .Os .Sh NAME @@ -40,13 +40,13 @@ .In sys/types.h .In sys/socket.h .Ft int -.Fn socketpair "int d" "int type" "int protocol" "int *sv" +.Fn socketpair "int fd" "int type" "int protocol" "int *sv" .Sh DESCRIPTION The .Fn socketpair system call creates an unnamed pair of connected sockets in the specified domain -.Fa d , +.Fa fd , of the specified .Fa type , and using the optionally specified diff --git a/lib/libc/sys/write.2 b/lib/libc/sys/write.2 index d22b985..a06e7c9 100644 --- a/lib/libc/sys/write.2 +++ b/lib/libc/sys/write.2 @@ -28,7 +28,7 @@ .\" @(#)write.2 8.5 (Berkeley) 4/2/94 .\" $FreeBSD$ .\" -.Dd January 22, 2012 +.Dd September 11, 2013 .Dt WRITE 2 .Os .Sh NAME @@ -43,14 +43,14 @@ .In sys/types.h .In unistd.h .Ft ssize_t -.Fn write "int d" "const void *buf" "size_t nbytes" +.Fn write "int fd" "const void *buf" "size_t nbytes" .Ft ssize_t -.Fn pwrite "int d" "const void *buf" "size_t nbytes" "off_t offset" +.Fn pwrite "int fd" "const void *buf" "size_t nbytes" "off_t offset" .In sys/uio.h .Ft ssize_t -.Fn writev "int d" "const struct iovec *iov" "int iovcnt" +.Fn writev "int fd" "const struct iovec *iov" "int iovcnt" .Ft ssize_t -.Fn pwritev "int d" "const struct iovec *iov" "int iovcnt" "off_t offset" +.Fn pwritev "int fd" "const struct iovec *iov" "int iovcnt" "off_t offset" .Sh DESCRIPTION The .Fn write @@ -58,7 +58,7 @@ system call attempts to write .Fa nbytes of data to the object referenced by the descriptor -.Fa d +.Fa fd from the buffer pointed to by .Fa buf . The @@ -107,7 +107,7 @@ On objects capable of seeking, the .Fn write starts at a position given by the pointer associated with -.Fa d , +.Fa fd , see .Xr lseek 2 . Upon return from @@ -154,7 +154,7 @@ will fail and the file pointer will remain unchanged if: .Bl -tag -width Er .It Bq Er EBADF The -.Fa d +.Fa fd argument is not a valid descriptor open for writing. .It Bq Er EPIPE @@ -174,7 +174,7 @@ or data to be written to the file points outside the process's allocated address space. .It Bq Er EINVAL The pointer associated with -.Fa d +.Fa fd was negative. .It Bq Er ENOSPC There is no free space remaining on the file system |