From 37336173d35a97285def1fbf91f77b7db95a2f1a Mon Sep 17 00:00:00 2001 From: Garrett Wollman Date: Mon, 18 Jun 2001 20:24:54 +0000 Subject: [PATCH] After one too many PRs on the subject, bite the bullet and define IOV_MAX and its associated constants. Implement _SC_IOV_MAX in the usual way. Be a bit sloppy about the namespace question; this should get cleared up in time for 5.0. MFC after: 1 month --- include/limits.h | 1 + lib/libc/gen/sysconf.c | 12 ++++++++++++ sys/kern/kern_subr.c | 4 ++++ sys/sys/sysctl.h | 4 +++- sys/sys/syslimits.h | 1 + sys/sys/uio.h | 8 ++++++++ sys/sys/unistd.h | 2 ++ 7 files changed, 31 insertions(+), 1 deletion(-) diff --git a/include/limits.h b/include/limits.h index 743643217805..4174234a5ac1 100644 --- a/include/limits.h +++ b/include/limits.h @@ -62,6 +62,7 @@ #define _POSIX2_LINE_MAX 2048 #define _POSIX2_RE_DUP_MAX 255 +#define _XOPEN_IOV_MAX 16 #ifdef _P1003_1B_VISIBLE diff --git a/lib/libc/gen/sysconf.c b/lib/libc/gen/sysconf.c index 2298bb1907a6..5be1f3bf59fd 100644 --- a/lib/libc/gen/sysconf.c +++ b/lib/libc/gen/sysconf.c @@ -38,6 +38,11 @@ static char sccsid[] = "@(#)sysconf.c 8.2 (Berkeley) 3/20/94"; #endif /* LIBC_SCCS and not lint */ +#if defined(LIBC_RCS) && !defined(lint) +static const char rcsid[] = + "$FreeBSD$"; +#endif /* LIBC_RCS and not lint */ + #include #include #include @@ -285,6 +290,13 @@ sysconf(name) goto yesno; #endif /* _P1003_1B_VISIBLE */ +#ifdef _SC_IOV_MAX + case _SC_IOV_MAX: + mib[0] = CTL_KERN; + mib[1] = KERN_IOV_MAX; + break; +#endif + yesno: if (sysctl(mib, 2, &value, &len, NULL, 0) == -1) return (-1); if (value == 0) diff --git a/sys/kern/kern_subr.c b/sys/kern/kern_subr.c index 8fb2499109b3..95c34a5c4b97 100644 --- a/sys/kern/kern_subr.c +++ b/sys/kern/kern_subr.c @@ -48,6 +48,7 @@ #include #include #include +#include #include #include @@ -56,6 +57,9 @@ static void uio_yield __P((void)); +SYSCTL_INT(_kern, KERN_IOV_MAX, iov_max, CTLFLAG_RD, NULL, UIO_MAXIOV, + "Maximum number of elements in an I/O vector; sysconf(_SC_IOV_MAX)"); + int uiomove(cp, n, uio) register caddr_t cp; diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h index 1b6657ba24cd..b5e3277669f6 100644 --- a/sys/sys/sysctl.h +++ b/sys/sys/sysctl.h @@ -328,7 +328,8 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); #define KERN_PS_STRINGS 32 /* int: address of PS_STRINGS */ #define KERN_USRSTACK 33 /* int: address of USRSTACK */ #define KERN_LOGSIGEXIT 34 /* int: do we log sigexit procs? */ -#define KERN_MAXID 35 /* number of valid kern ids */ +#define KERN_IOV_MAX 35 /* int: value of UIO_MAXIOV */ +#define KERN_MAXID 36 /* number of valid kern ids */ #define CTL_KERN_NAMES { \ { 0, 0 }, \ @@ -366,6 +367,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); { "ps_strings", CTLTYPE_INT }, \ { "usrstack", CTLTYPE_INT }, \ { "logsigexit", CTLTYPE_INT }, \ + { "iov_max", CTLTYPE_INT }, \ } /* diff --git a/sys/sys/syslimits.h b/sys/sys/syslimits.h index 634db8f3b3c2..9a05b2c3b921 100644 --- a/sys/sys/syslimits.h +++ b/sys/sys/syslimits.h @@ -51,6 +51,7 @@ #endif #define PATH_MAX 1024 /* max bytes in pathname */ #define PIPE_BUF 512 /* max bytes for atomic pipe writes */ +#define IOV_MAX 1024 /* max elements in i/o vector */ #define BC_BASE_MAX 99 /* max ibase/obase values in bc(1) */ #define BC_DIM_MAX 2048 /* max array elements in bc(1) */ diff --git a/sys/sys/uio.h b/sys/sys/uio.h index 547dbad6d703..fcf1570b3071 100644 --- a/sys/sys/uio.h +++ b/sys/sys/uio.h @@ -70,6 +70,14 @@ struct uio { /* * Limits + * + * N.B.: UIO_MAXIOV must be no less than IOV_MAX from + * which in turn must be no less than _XOPEN_IOV_MAX from . If + * we ever make this tunable (probably pointless), then IOV_MAX should be + * removed from and applications would be expected to use + * sysconf(3) to find out the correct value, or else assume the worst + * (_XOPEN_IOV_MAX). Perhaps UIO_MAXIOV should be simply defined as + * IOV_MAX. */ #define UIO_MAXIOV 1024 /* max 1K of iov's */ #define UIO_SMALLIOV 8 /* 8 on stack, else malloc */ diff --git a/sys/sys/unistd.h b/sys/sys/unistd.h index e3b562f14f3e..d78db34251a3 100644 --- a/sys/sys/unistd.h +++ b/sys/sys/unistd.h @@ -198,6 +198,8 @@ #endif /* _P1003_1B_VISIBLE */ +#define _SC_IOV_MAX 56 + #ifndef _POSIX_SOURCE /* * rfork() options.