summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwollman <wollman@FreeBSD.org>2001-06-18 20:24:54 +0000
committerwollman <wollman@FreeBSD.org>2001-06-18 20:24:54 +0000
commit204b9a8a22df17a404244eec0f26fdffc366afa6 (patch)
tree8a3a4e95b557ac68b83a0b75cedcd574f6a3f82c
parente55cc77a7fb5bb22f0913e7cbe6f06d0e309db68 (diff)
downloadFreeBSD-src-204b9a8a22df17a404244eec0f26fdffc366afa6.zip
FreeBSD-src-204b9a8a22df17a404244eec0f26fdffc366afa6.tar.gz
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
-rw-r--r--include/limits.h1
-rw-r--r--lib/libc/gen/sysconf.c12
-rw-r--r--sys/kern/kern_subr.c4
-rw-r--r--sys/sys/sysctl.h4
-rw-r--r--sys/sys/syslimits.h1
-rw-r--r--sys/sys/uio.h8
-rw-r--r--sys/sys/unistd.h2
7 files changed, 31 insertions, 1 deletions
diff --git a/include/limits.h b/include/limits.h
index 7436432..4174234 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 2298bb1..5be1f3b 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 <sys/_posix.h>
#include <sys/param.h>
#include <sys/time.h>
@@ -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 8fb2499..95c34a5 100644
--- a/sys/kern/kern_subr.c
+++ b/sys/kern/kern_subr.c
@@ -48,6 +48,7 @@
#include <sys/proc.h>
#include <sys/malloc.h>
#include <sys/resourcevar.h>
+#include <sys/sysctl.h>
#include <sys/vnode.h>
#include <vm/vm.h>
@@ -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 1b6657b..b5e3277 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 634db8f..9a05b2c 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 547dbad..fcf1570 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 <sys/syslimits.h>
+ * which in turn must be no less than _XOPEN_IOV_MAX from <limits.h>. If
+ * we ever make this tunable (probably pointless), then IOV_MAX should be
+ * removed from <sys/syslimits.h> 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 e3b562f..d78db34 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.
OpenPOWER on IntegriCloud