- Create sysctl nodes for AIO.
- Add POSIX defined system variables and constants of AIO_LISTIO_MAX and AIO_MAX values. Both with _POSIX_ASYNCHRONOUS_IO, provide them in sysconf(3) and getconf(1) interfaces. - Clean up sysconf(3) for handling sysctl nodes dynamically.
This commit is contained in:
parent
ab54f30196
commit
0994dd0691
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: limits.h,v 1.23 2004/11/10 04:02:52 lukem Exp $ */
|
||||
/* $NetBSD: limits.h,v 1.24 2007/05/01 01:01:25 rmind Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1993
|
||||
@ -38,6 +38,8 @@
|
||||
|
||||
#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
|
||||
defined(_NETBSD_SOURCE)
|
||||
#define _POSIX_AIO_LISTIO_MAX 2
|
||||
#define _POSIX_AIO_MAX 1
|
||||
#define _POSIX_ARG_MAX 4096
|
||||
#define _POSIX_CHILD_MAX 6
|
||||
#define _POSIX_LINK_MAX 8
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: sysconf.c,v 1.22 2006/11/25 21:40:04 christos Exp $ */
|
||||
/* $NetBSD: sysconf.c,v 1.23 2007/05/01 01:01:35 rmind Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
@ -37,7 +37,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)sysconf.c 8.2 (Berkeley) 3/20/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: sysconf.c,v 1.22 2006/11/25 21:40:04 christos Exp $");
|
||||
__RCSID("$NetBSD: sysconf.c,v 1.23 2007/05/01 01:01:35 rmind Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
@ -69,17 +69,20 @@ __weak_alias(sysconf,__sysconf)
|
||||
* less useful than returning up-to-date values, however.
|
||||
*/
|
||||
long
|
||||
sysconf(name)
|
||||
int name;
|
||||
sysconf(int name)
|
||||
{
|
||||
struct rlimit rl;
|
||||
size_t len;
|
||||
int mib[3], value;
|
||||
int mib[CTL_MAXNAME], value;
|
||||
unsigned int mib_len;
|
||||
struct clockinfo tmpclock;
|
||||
static int clk_tck;
|
||||
|
||||
len = sizeof(value);
|
||||
|
||||
/* Default length of the MIB */
|
||||
mib_len = 2;
|
||||
|
||||
switch (name) {
|
||||
|
||||
/* 1003.1 */
|
||||
@ -284,13 +287,25 @@ sysconf(name)
|
||||
mib[0] = CTL_KERN;
|
||||
mib[1] = KERN_SYSVIPC;
|
||||
mib[2] = KERN_SYSVIPC_SHM;
|
||||
if (sysctl(mib, 3, &value, &len, NULL, 0) == -1)
|
||||
return (-1);
|
||||
if (value == 0)
|
||||
return (-1);
|
||||
return (0);
|
||||
mib_len = 3;
|
||||
goto yesno;
|
||||
|
||||
/* 1003.1-2001, XSI Option Group */
|
||||
case _SC_AIO_LISTIO_MAX:
|
||||
if (sysctlgetmibinfo("kern.aio_listio_max", &mib[0], &mib_len,
|
||||
NULL, NULL, NULL, SYSCTL_VERSION))
|
||||
return -1;
|
||||
break;
|
||||
case _SC_AIO_MAX:
|
||||
if (sysctlgetmibinfo("kern.aio_max", &mib[0], &mib_len,
|
||||
NULL, NULL, NULL, SYSCTL_VERSION))
|
||||
return -1;
|
||||
break;
|
||||
case _SC_ASYNCHRONOUS_IO:
|
||||
if (sysctlgetmibinfo("kern.posix_aio", &mib[0], &mib_len,
|
||||
NULL, NULL, NULL, SYSCTL_VERSION))
|
||||
return -1;
|
||||
goto yesno;
|
||||
case _SC_ATEXIT_MAX:
|
||||
mib[0] = CTL_USER;
|
||||
mib[1] = USER_ATEXIT_MAX;
|
||||
@ -302,7 +317,7 @@ sysconf(name)
|
||||
case _SC_GETPW_R_SIZE_MAX:
|
||||
return _GETPW_R_SIZE_MAX;
|
||||
|
||||
yesno: if (sysctl(mib, 2, &value, &len, NULL, 0) == -1)
|
||||
yesno: if (sysctl(mib, mib_len, &value, &len, NULL, 0) == -1)
|
||||
return (-1);
|
||||
if (value == 0)
|
||||
return (-1);
|
||||
@ -313,5 +328,5 @@ yesno: if (sysctl(mib, 2, &value, &len, NULL, 0) == -1)
|
||||
errno = EINVAL;
|
||||
return (-1);
|
||||
}
|
||||
return (sysctl(mib, 2, &value, &len, NULL, 0) == -1 ? -1 : value);
|
||||
return (sysctl(mib, mib_len, &value, &len, NULL, 0) == -1 ? -1 : value);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: vfs_aio.c,v 1.1 2007/04/30 14:44:30 rmind Exp $ */
|
||||
/* $NetBSD: vfs_aio.c,v 1.2 2007/05/01 01:01:36 rmind Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007, Mindaugas Rasiukevicius <rmind at NetBSD org>
|
||||
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: vfs_aio.c,v 1.1 2007/04/30 14:44:30 rmind Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: vfs_aio.c,v 1.2 2007/05/01 01:01:36 rmind Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
@ -49,6 +49,7 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_aio.c,v 1.1 2007/04/30 14:44:30 rmind Exp $");
|
||||
#include <sys/signal.h>
|
||||
#include <sys/signalvar.h>
|
||||
#include <sys/syscallargs.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/vnode.h>
|
||||
@ -940,6 +941,42 @@ err:
|
||||
return error;
|
||||
}
|
||||
|
||||
/*
|
||||
* SysCtl
|
||||
*/
|
||||
|
||||
SYSCTL_SETUP(sysctl_aio_setup, "sysctl aio setup")
|
||||
{
|
||||
|
||||
sysctl_createv(clog, 0, NULL, NULL,
|
||||
CTLFLAG_PERMANENT,
|
||||
CTLTYPE_NODE, "kern", NULL,
|
||||
NULL, 0, NULL, 0,
|
||||
CTL_KERN, CTL_EOL);
|
||||
sysctl_createv(clog, 0, NULL, NULL,
|
||||
CTLFLAG_PERMANENT|CTLFLAG_IMMEDIATE,
|
||||
CTLTYPE_INT, "posix_aio",
|
||||
SYSCTL_DESCR("Version of IEEE Std 1003.1 and its "
|
||||
"Asynchronous I/O option to which the "
|
||||
"system attempts to conform"),
|
||||
NULL, _POSIX_ASYNCHRONOUS_IO, NULL, 0,
|
||||
CTL_KERN, CTL_CREATE, CTL_EOL);
|
||||
sysctl_createv(clog, 0, NULL, NULL,
|
||||
CTLFLAG_PERMANENT|CTLFLAG_IMMEDIATE,
|
||||
CTLTYPE_INT, "aio_listio_max",
|
||||
SYSCTL_DESCR("Maximum number of asynchronous I/O "
|
||||
"operations in a single list I/O call"),
|
||||
NULL, AIO_LISTIO_MAX, NULL, 0,
|
||||
CTL_KERN, CTL_CREATE, CTL_EOL);
|
||||
sysctl_createv(clog, 0, NULL, NULL,
|
||||
CTLFLAG_PERMANENT|CTLFLAG_IMMEDIATE,
|
||||
CTLTYPE_INT, "aio_max",
|
||||
SYSCTL_DESCR("Maximum number of asynchronous I/O "
|
||||
"operations"),
|
||||
NULL, AIO_MAX, NULL, 0,
|
||||
CTL_KERN, CTL_CREATE, CTL_EOL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Debugging
|
||||
*/
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: unistd.h,v 1.36 2007/04/30 14:44:31 rmind Exp $ */
|
||||
/* $NetBSD: unistd.h,v 1.37 2007/05/01 01:01:36 rmind Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
@ -66,7 +66,7 @@
|
||||
/* chown requires appropriate privileges */
|
||||
#define _POSIX_CHOWN_RESTRICTED 1
|
||||
/* clock selection */
|
||||
#define _POSIX_CLOCK_SELECTION -1
|
||||
#define _POSIX_CLOCK_SELECTION -1
|
||||
/* too-long path components generate errors */
|
||||
#define _POSIX_NO_TRUNC 1
|
||||
/* may disable terminal special characters */
|
||||
@ -197,7 +197,10 @@
|
||||
#define _SC_READER_WRITER_LOCKS 46
|
||||
#define _SC_GETGR_R_SIZE_MAX 47
|
||||
#define _SC_GETPW_R_SIZE_MAX 48
|
||||
#define _SC_CLOCK_SELECTION 49
|
||||
#define _SC_CLOCK_SELECTION 49
|
||||
#define _SC_ASYNCHRONOUS_IO 50
|
||||
#define _SC_AIO_LISTIO_MAX 51
|
||||
#define _SC_AIO_MAX 52
|
||||
|
||||
/* configurable system strings */
|
||||
#define _CS_PATH 1
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: getconf.c,v 1.26 2006/12/06 12:02:02 mjf Exp $ */
|
||||
/* $NetBSD: getconf.c,v 1.27 2007/05/01 01:01:37 rmind Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996, 1998 The NetBSD Foundation, Inc.
|
||||
@ -38,7 +38,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: getconf.c,v 1.26 2006/12/06 12:02:02 mjf Exp $");
|
||||
__RCSID("$NetBSD: getconf.c,v 1.27 2007/05/01 01:01:37 rmind Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <err.h>
|
||||
@ -78,6 +78,8 @@ static const struct conf_variable conf_table[] =
|
||||
{ "POSIX2_VERSION", CONSTANT, _POSIX2_VERSION },
|
||||
|
||||
/* POSIX.1 Minimum Values */
|
||||
{ "_POSIX_AIO_LISTIO_MAX", CONSTANT, _POSIX_AIO_LISTIO_MAX },
|
||||
{ "_POSIX_AIO_MAX", CONSTANT, _POSIX_AIO_MAX },
|
||||
{ "_POSIX_ARG_MAX", CONSTANT, _POSIX_ARG_MAX },
|
||||
{ "_POSIX_CHILD_MAX", CONSTANT, _POSIX_CHILD_MAX },
|
||||
{ "_POSIX_LINK_MAX", CONSTANT, _POSIX_LINK_MAX },
|
||||
@ -113,6 +115,8 @@ static const struct conf_variable conf_table[] =
|
||||
{ "POSIX2_UPE", SYSCONF, _SC_2_UPE },
|
||||
|
||||
/* POSIX.1 Configurable System Variables */
|
||||
{ "AIO_LISTIO_MAX", SYSCONF, _SC_AIO_LISTIO_MAX },
|
||||
{ "AIO_MAX", SYSCONF, _SC_AIO_MAX },
|
||||
{ "ARG_MAX", SYSCONF, _SC_ARG_MAX },
|
||||
{ "CHILD_MAX", SYSCONF, _SC_CHILD_MAX },
|
||||
{ "CLK_TCK", SYSCONF, _SC_CLK_TCK },
|
||||
@ -136,6 +140,7 @@ static const struct conf_variable conf_table[] =
|
||||
|
||||
/* POSIX.1b Configurable System Variables */
|
||||
{ "PAGESIZE", SYSCONF, _SC_PAGESIZE },
|
||||
{ "_POSIX_ASYNCHRONOUS_IO", SYSCONF, _SC_ASYNCHRONOUS_IO },
|
||||
{ "_POSIX_FSYNC", SYSCONF, _SC_FSYNC },
|
||||
{ "_POSIX_MAPPED_FILES", SYSCONF, _SC_MAPPED_FILES },
|
||||
{ "_POSIX_MEMLOCK", SYSCONF, _SC_MEMLOCK },
|
||||
|
Loading…
Reference in New Issue
Block a user