diff options
Diffstat (limited to 'sys/posix4')
-rw-r--r-- | sys/posix4/aio.h | 23 | ||||
-rw-r--r-- | sys/posix4/ksched.c | 52 | ||||
-rw-r--r-- | sys/posix4/mqueue.h | 6 | ||||
-rw-r--r-- | sys/posix4/p1003_1b.c | 239 | ||||
-rw-r--r-- | sys/posix4/posix4.h | 256 | ||||
-rw-r--r-- | sys/posix4/posix4_mib.c | 83 | ||||
-rw-r--r-- | sys/posix4/sched.h | 3 | ||||
-rw-r--r-- | sys/posix4/semaphore.h | 6 |
8 files changed, 380 insertions, 288 deletions
diff --git a/sys/posix4/aio.h b/sys/posix4/aio.h index 25e7d1c4cfe9..73319ece7920 100644 --- a/sys/posix4/aio.h +++ b/sys/posix4/aio.h @@ -31,26 +31,29 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: aio.h,v 1.2 1998/03/08 17:25:11 dufault Exp $ + * $Id: aio.h,v 1.3 1998/03/23 14:05:25 bde Exp $ */ /* aio.h: P1003.1B-1993 Asynchronous I/O */ -#ifndef _AIO_H_ -#define _AIO_H_ +#ifndef _P1003_1B_AIO_H_ +#define _P1003_1B_AIO_H_ -#ifdef _POSIX4_INCLUDE_MAYBES +#include <sys/_posix.h> #include <sys/types.h> + +/* For struct sigevent: + */ +#ifdef KERNEL +#include <sys/signal.h> +#else #include <signal.h> + +#ifdef _P1003_1B_INCLUDE_MAYBES #include <time.h> #include <fcntl.h> #else struct timespec; -#include <sys/types.h> -#ifdef KERNEL -#include <sys/signal.h> -#else -#include <signal.h> #endif #endif @@ -104,4 +107,4 @@ __END_DECLS #endif /* KERNEL */ -#endif /* _POSIX4_AIO_H_ */ +#endif /* _P1003_1B_AIO_H_ */ diff --git a/sys/posix4/ksched.c b/sys/posix4/ksched.c index 7ff85d622010..90c029ac311b 100644 --- a/sys/posix4/ksched.c +++ b/sys/posix4/ksched.c @@ -39,34 +39,38 @@ #include <sys/proc.h> #include <sys/kernel.h> #include <machine/cpu.h> /* For need_resched */ -#include <fcntl.h> -#include <sys/posix4.h> +#include <posix4/posix4.h> /* ksched: Real-time extension to support POSIX priority scheduling. */ -static struct timespec rr_interval; +struct ksched { + struct timespec rr_interval; +}; -int ksched_attach(int p4_instance, int fac_code, void **p) +int ksched_attach(struct ksched **p) { - rr_interval.tv_sec = 0; - rr_interval.tv_nsec = 1000000000L / roundrobin_interval(); + struct ksched *ksched= p31b_malloc(sizeof(*ksched)); - *p = 0; + ksched->rr_interval.tv_sec = 0; + ksched->rr_interval.tv_nsec = 1000000000L / roundrobin_interval(); + *p = ksched; return 0; } -int ksched_detach(void *p) +int ksched_detach(struct ksched *p) { + p31b_free(p); + return 0; } /* * XXX About priorities * - * POSIX4 requires that numerically higher priorities be of + * POSIX 1003.1b requires that numerically higher priorities be of * higher priority. It also permits sched_setparam to be * implementation defined for SCHED_OTHER. I don't like * the notion of inverted priorites for normal processes when @@ -76,14 +80,14 @@ int ksched_detach(void *p) */ /* Macros to convert between the unix (lower numerically is higher priority) - * and POSIX4 (higher numerically is higher priority) + * and POSIX 1003.1b (higher numerically is higher priority) */ #define p4prio_to_rtpprio(P) (RTP_PRIO_MAX - (P)) #define rtpprio_to_p4prio(P) (RTP_PRIO_MAX - (P)) static inline int -getscheduler(int *ret, void *hook, struct proc *p) +getscheduler(int *ret, struct ksched *ksched, struct proc *p) { int e = 0; @@ -105,25 +109,25 @@ getscheduler(int *ret, void *hook, struct proc *p) return e; } -int ksched_setparam(int *ret, void *hook, +int ksched_setparam(int *ret, struct ksched *ksched, struct proc *p, const struct sched_param *param) { int e, policy; - e = getscheduler(&policy, hook, p); + e = getscheduler(&policy, ksched, p); if (e == 0) { if (policy == SCHED_OTHER) e = EINVAL; else - e = ksched_setscheduler(ret, hook, p, policy, param); + e = ksched_setscheduler(ret, ksched, p, policy, param); } return e; } -int ksched_getparam(int *ret, void *hook, +int ksched_getparam(int *ret, struct ksched *ksched, struct proc *p, struct sched_param *param) { if (RTP_PRIO_IS_REALTIME(p->p_rtprio.type)) @@ -136,10 +140,10 @@ int ksched_getparam(int *ret, void *hook, * XXX The priority and scheduler modifications should * be moved into published interfaces in kern/kern_sync. * - * The permissions to modify process p were checked in "posix4proc()". + * The permissions to modify process p were checked in "p31b_proc()". * */ -int ksched_setscheduler(int *ret, void *hook, +int ksched_setscheduler(int *ret, struct ksched *ksched, struct proc *p, int policy, const struct sched_param *param) { int e = 0; @@ -186,20 +190,20 @@ int ksched_setscheduler(int *ret, void *hook, return e; } -int ksched_getscheduler(int *ret, void *hook, struct proc *p) +int ksched_getscheduler(int *ret, struct ksched *ksched, struct proc *p) { - return getscheduler(ret, hook, p); + return getscheduler(ret, ksched, p); } /* ksched_yield: Yield the CPU. */ -int ksched_yield(int *ret, void *hook) +int ksched_yield(int *ret, struct ksched *ksched) { need_resched(); return 0; } -int ksched_get_priority_max(int *ret, void *hook, int policy) +int ksched_get_priority_max(int *ret, struct ksched *ksched, int policy) { int e = 0; @@ -221,7 +225,7 @@ int ksched_get_priority_max(int *ret, void *hook, int policy) return e; } -int ksched_get_priority_min(int *ret, void *hook, int policy) +int ksched_get_priority_min(int *ret, struct ksched *ksched, int policy) { int e = 0; @@ -243,10 +247,10 @@ int ksched_get_priority_min(int *ret, void *hook, int policy) return e; } -int ksched_rr_get_interval(int *ret, void *hook, +int ksched_rr_get_interval(int *ret, struct ksched *ksched, struct proc *p, struct timespec *timespec) { - *timespec = rr_interval; + *timespec = ksched->rr_interval; return 0; } diff --git a/sys/posix4/mqueue.h b/sys/posix4/mqueue.h index 6fcf4409ed33..c59a4aa84f06 100644 --- a/sys/posix4/mqueue.h +++ b/sys/posix4/mqueue.h @@ -1,7 +1,7 @@ #ifndef _MQUEUE_H_ #define _MQUEUE_H_ -/* mqueue.h: POSIX.4 Message Queues */ +/* mqueue.h: POSIX 1003.1b Message Queues */ /*- * Copyright (c) 1996, 1997 @@ -36,7 +36,9 @@ * */ -#ifdef _POSIX4_INCLUDE_MAYBES +#include <sys/_posix.h> + +#ifdef _P1003_1B_INCLUDE_MAYBES #include <sys/types.h> #include <fcntl.h> #include <time.h> diff --git a/sys/posix4/p1003_1b.c b/sys/posix4/p1003_1b.c new file mode 100644 index 000000000000..ccbee6b80283 --- /dev/null +++ b/sys/posix4/p1003_1b.c @@ -0,0 +1,239 @@ +/* + * Copyright (c) 1996, 1997, 1998 + * HD Associates, Inc. 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. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by HD Associates, Inc + * 4. Neither the name of the author nor the names of any co-contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES 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 HD ASSOCIATES 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. + * + */ + +/* p1003_1b: Real Time common code. + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/kernel.h> +#include <sys/sysent.h> +#include <sys/proc.h> +#include <sys/syslog.h> +#include <sys/module.h> +#include <sys/sysproto.h> +#include <sys/sysctl.h> + +#include <posix4/posix4.h> + +MALLOC_DEFINE(M_P31B, "p1003.1b", "Posix 1003.1B"); + +/* p31b_proc: Return a proc struct corresponding to a pid to operate on. + * + * Enforce permission policy. + * + * The policy is the same as for sending signals except there + * is no notion of process groups. + * + * pid == 0 means my process. + * + * This is disabled until I've got a permission gate in again: + * only root can do this. + */ + +#if 0 +/* + * This is stolen from CANSIGNAL in kern_sig: + * + * Can process p, with pcred pc, do "write flavor" operations to process q? + */ +#define CAN_AFFECT(p, pc, q) \ + ((pc)->pc_ucred->cr_uid == 0 || \ + (pc)->p_ruid == (q)->p_cred->p_ruid || \ + (pc)->pc_ucred->cr_uid == (q)->p_cred->p_ruid || \ + (pc)->p_ruid == (q)->p_ucred->cr_uid || \ + (pc)->pc_ucred->cr_uid == (q)->p_ucred->cr_uid) +#else +#define CAN_AFFECT(p, pc, q) ((pc)->pc_ucred->cr_uid == 0) +#endif + +/* + * p31b_proc: Look up a proc from a PID. If proc is 0 it is + * my own proc. + */ +int p31b_proc(struct proc *p, pid_t pid, struct proc **pp) +{ + int ret = 0; + struct proc *other_proc = 0; + + if (pid == 0) + other_proc = p; + else + other_proc = pfind(pid); + + if (other_proc) + { + /* Enforce permission policy. + */ + if (CAN_AFFECT(p, p->p_cred, other_proc)) + *pp = other_proc; + else + ret = EPERM; + } + else + ret = ESRCH; + + return ret; +} + +int +syscall_not_present(struct proc *p, const char *s, struct nosys_args *uap) +{ + log(LOG_ERR, "cmd %s pid %d tried to use non-present %s\n", + p->p_comm, p->p_pid, s); + return nosys(p, uap); +} + +#if !defined(_KPOSIX_PRIORITY_SCHEDULING) + +/* Not configured but loadable via an LKM: + */ + +static int sched_attach(void) +{ + return 0; +} + +SYSCALL_NOT_PRESENT_GEN(sched_setparam) +SYSCALL_NOT_PRESENT_GEN(sched_getparam) +SYSCALL_NOT_PRESENT_GEN(sched_setscheduler) +SYSCALL_NOT_PRESENT_GEN(sched_getscheduler) +SYSCALL_NOT_PRESENT_GEN(sched_yield) +SYSCALL_NOT_PRESENT_GEN(sched_get_priority_max) +SYSCALL_NOT_PRESENT_GEN(sched_get_priority_min) +SYSCALL_NOT_PRESENT_GEN(sched_rr_get_interval) + +#else + +/* Configured in kernel version: + */ +static struct ksched *ksched; + +static int sched_attach(void) +{ + int ret = ksched_attach(&ksched); + + if (ret == 0) + p31b_setcfg(CTL_P1003_1B_PRIORITY_SCHEDULING, 1); + + return ret; +} + +int sched_setparam(struct proc *p, + struct sched_setparam_args *uap) +{ + int e; + + (void) (0 + || (e = p31b_proc(p, uap->pid, &p)) + || (e = ksched_setparam(&p->p_retval[0], ksched, p, + (const struct sched_param *) &uap->param)) + ); + + return e; +} + +int sched_getparam(struct proc *p, + struct sched_getparam_args *uap) +{ + int e; + + (void) (0 + || (e = p31b_proc(p, uap->pid, &p)) + || (e = ksched_getparam(&p->p_retval[0], ksched, p, uap->param)) + ); + + return e; +} +int sched_setscheduler(struct proc *p, + struct sched_setscheduler_args *uap) +{ + int e; + (void) (0 + || (e = p31b_proc(p, uap->pid, &p)) + || (e = ksched_setscheduler(&p->p_retval[0], + ksched, p, uap->policy, uap->param)) + ); + + return e; +} +int sched_getscheduler(struct proc *p, + struct sched_getscheduler_args *uap) +{ + int e; + (void) (0 + || (e = p31b_proc(p, uap->pid, &p)) + || (e = ksched_getscheduler(&p->p_retval[0], ksched, p)) + ); + + return e; +} +int sched_yield(struct proc *p, + struct sched_yield_args *uap) +{ + return ksched_yield(&p->p_retval[0], ksched); +} +int sched_get_priority_max(struct proc *p, + struct sched_get_priority_max_args *uap) +{ + return ksched_get_priority_max(&p->p_retval[0], + ksched, uap->policy); +} +int sched_get_priority_min(struct proc *p, + struct sched_get_priority_min_args *uap) +{ + return ksched_get_priority_min(&p->p_retval[0], + ksched, uap->policy); +} +int sched_rr_get_interval(struct proc *p, + struct sched_rr_get_interval_args *uap) +{ + int e; + + (void) (0 + || (e = p31b_proc(p, uap->pid, &p)) + || (e = ksched_rr_get_interval(&p->p_retval[0], ksched, + p, uap->interval)) + ); + + return e; +} + +#endif + +static void p31binit(void *notused) +{ + (void) sched_attach(); +} + +SYSINIT(p31b, SI_SUB_P1003_1B, SI_ORDER_FIRST, p31binit, NULL); diff --git a/sys/posix4/posix4.h b/sys/posix4/posix4.h index 99ba8822a2b0..dd3418cb8f89 100644 --- a/sys/posix4/posix4.h +++ b/sys/posix4/posix4.h @@ -1,5 +1,5 @@ -#ifndef _POSIX4_POSIX4_H_ -#define _POSIX4_POSIX4_H_ +#ifndef _P1003_1B_P1003_1B_H_ +#define _P1003_1B_P1003_1B_H_ /*- * Copyright (c) 1996, 1997, 1998 * HD Associates, Inc. All rights reserved. @@ -33,56 +33,40 @@ * */ -#include <sys/_posix.h> +#include "opt_posix.h" -#ifdef _POSIX4_VISIBLE +#ifdef P1003_1B #include <sys/param.h> #include <sys/ioccom.h> -#include <sched.h> +#include <sys/malloc.h> +#include <posix4/sched.h> -/* - * - * March 1, 1998: Details from here on change and this header file - * is volatile. - * - * Locally I've got PRIORITY SCHEDULING - * set as a system call available only to root - * and I'm still using a pseudo device to gate everything else. - * - * This interface vectors us into the kernel through a - * POSIX4 pseudo device with some user privilege authorization along - * the way. - * - * XXX I'm going with option 3. - * - * This has drawbacks from the point of view of ktrace. There - * are (at least) three ways to do this: - * - * 1. As it is being done, which is bad for ktrace and is hokey - * but is easy to extend during development; - * 2. Add a system call for every POSIX4 entry point, which - * will result in many more system calls (on the order of 64) - * 3. Add a system call for each POSIX4 option, which is a bit more - * useful for ktrace and will add only about 14 new system calls. - * +/* Generate syscall stubs for when something is optionally + * LKM'd. References "syscall_not_present". + * XXX Good candidate for sys/syscall.h */ +struct proc; +struct nosys_args; +extern int syscall_not_present(struct proc *, const char *, struct nosys_args *); -#define POSIX4_FACILITIES 16 -#define POSIX4_ONE_ONLY +#define SYSCALL_NOT_PRESENT_GEN(SC) \ +int SC (struct proc *p, struct SC##_args *uap) \ +{ \ + return syscall_not_present(p, #SC , (struct nosys_args *)uap); \ +} -/* - * All facility request structures have a posix4_dispatch header - * at the front. Return values are always an indication of - * success or failure and are automatically converted into an errno - * by the kernel. "Non-errno" return codes are handled via ret. - */ -struct posix4_dispatch { - int op; - int ret; -}; -#if defined(_POSIX_PRIORITY_SCHEDULING) +MALLOC_DECLARE(M_P31B); + +#define p31b_malloc(SIZE) malloc((SIZE), M_P31B, M_WAITOK) +#define p31b_free(P) free((P), M_P31B) + +int p31b_proc __P((struct proc *, pid_t, struct proc **)); + +void p31b_setcfg __P((int, int)); + +#ifdef _KPOSIX_PRIORITY_SCHEDULING /* * KSCHED_OP_RW is a vector of read/write flags for each entry indexed @@ -106,187 +90,29 @@ enum ksched_op { SCHED_OP_MAX }; -struct ksched -{ - struct posix4_dispatch dispatch; - pid_t pid; - int policy; - struct sched_param param; - struct timespec interval; -}; - -#endif /* _POSIX_PRIORITY_SCHEDULING */ - -#if defined(_POSIX_MEMLOCK) ^ defined(_POSIX_MEMLOCK_RANGE) -/* This implementation expects these two options to always be together. - * If one isn't handled it should be disabled at - * run time. - */ -#error _POSIX_MEMLOCK and _POSIX_MEMLOCK_RANGE should always be together -#endif - -#if defined(_POSIX_MEMLOCK) && defined(_POSIX_MEMLOCK_RANGE) - -enum kmemlock_op { - -#define KMEMLOCK_OP_RW { 1, 1, 1, 1 } - - MEMLOCK_MLOCKALL, - MEMLOCK_MUNLOCKALL, - MEMLOCK_MLOCK, - MEMLOCK_MUNLOCK, - MEMLOCK_OP_MAX -}; - -struct kmemlock -{ - struct posix4_dispatch dispatch; - int flags; - void *addr; - size_t len; -}; - -#endif /* _POSIX_MEMLOCK && _POSIX_MEMLOCK_RANGE */ - -#if defined(KERNEL) - -struct proc; - -void *posix4malloc __P((int *, size_t)); -void posix4free __P((int *, void *)); -int posix4proc __P((struct proc *, pid_t, struct proc **)); -int posix4ioctl __P((dev_t, int, caddr_t, int, struct proc *)); -void posix4attach __P((int)); -void posix4_facility __P((int, int)); - -struct lkm_table; -int posix4_init __P((struct lkm_table *, int , int )); +struct ksched; -#ifdef _POSIX_PRIORITY_SCHEDULING +int ksched_attach(struct ksched **); +int ksched_detach(struct ksched *); -int ksched_attach(int, int, void **); -int ksched_detach(void *); - -int ksched_setparam(int *, void *, +int ksched_setparam(int *, struct ksched *, struct proc *, const struct sched_param *); -int ksched_getparam(int *, void *, +int ksched_getparam(int *, struct ksched *, struct proc *, struct sched_param *); -int ksched_setscheduler(int *, void *, +int ksched_setscheduler(int *, struct ksched *, struct proc *, int, const struct sched_param *); -int ksched_getscheduler(int *, void *, struct proc *); - -int ksched_yield(int *, void *); - -int ksched_get_priority_max(int *, void *, int); -int ksched_get_priority_min(int *, void *, int); - -int ksched_rr_get_interval(int *, void *, struct proc *, struct timespec *); - -#endif /* _POSIX_PRIORITY_SCHEDULING */ - -#if defined(_POSIX_MEMLOCK) && defined(_POSIX_MEMLOCK_RANGE) +int ksched_getscheduler(int *, struct ksched *, struct proc *); -int kmemlock_attach(int, int, void **); -int kmemlock_detach(void *); -int kmlockall(int *, void *, int); -int kmunlockall(int *, void *); -int kmlock(int *, void *, const void *, size_t); -int kmunlock(int *, void *, const void *, size_t ); +int ksched_yield(int *, struct ksched *); -#endif /* _POSIX_MEMLOCK && _POSIX_MEMLOCK_RANGE */ +int ksched_get_priority_max(int *, struct ksched *, int); +int ksched_get_priority_min(int *, struct ksched *, int); -#endif /* KERNEL */ +int ksched_rr_get_interval(int *, struct ksched *, struct proc *, struct timespec *); -/* A facility is an implementation of one of the optional portions of - * POSIX4 as selected by the feature test macros, such as the fixed - * priority scheduler or the realtime signals. - */ - -/* Each facility has a facility code, an opcode, and r-w attributes. - * To exercise the operation associated with an opcode you need the - * appropriate privileges on the POSIX4 device with the facility - * bit set in the minor number. This means that every facility has - * a protection bit: Probably more than we need, but it may have - * advantages. - * - */ - -#define posix4encode(FACILITY, RW) (FACILITY) -#define posix4decode(X, FACILITY_P) \ - do { \ - *(FACILITY_P) = ((X) & 0xff); \ - } while (0) - -/* - * The dispatch codes: - */ -#define IO_POSIX4_PRIORITY_SCHEDULING _IOWR('r', \ - CTL_POSIX4_PRIORITY_SCHEDULING, struct ksched) +#endif /* _KPOSIX_PRIORITY_SCHEDULING */ -#define IO_POSIX4_MEMLOCK _IOWR('r', \ - CTL_POSIX4_MEMLOCK, struct ksched) - -/* - * CTL_POSIX4 definitions for syscfg - */ - -#define CTL_POSIX4_ASYNCHRONOUS_IO 1 /* boolean */ -#define CTL_POSIX4_MAPPED_FILES 2 /* boolean */ -#define CTL_POSIX4_MEMLOCK 3 /* boolean */ -#define CTL_POSIX4_MEMLOCK_RANGE 4 /* boolean */ -#define CTL_POSIX4_MEMORY_PROTECTION 5 /* boolean */ -#define CTL_POSIX4_MESSAGE_PASSING 6 /* boolean */ -#define CTL_POSIX4_PRIORITIZED_IO 7 /* boolean */ -#define CTL_POSIX4_PRIORITY_SCHEDULING 8 /* boolean */ -#define CTL_POSIX4_REALTIME_SIGNALS 9 /* boolean */ -#define CTL_POSIX4_SEMAPHORES 10 /* boolean */ -#define CTL_POSIX4_FSYNC 11 /* boolean */ -#define CTL_POSIX4_SHARED_MEMORY_OBJECTS 12 /* boolean */ -#define CTL_POSIX4_SYNCHRONIZED_IO 13 /* boolean */ -#define CTL_POSIX4_TIMERS 14 /* boolean */ -#define CTL_POSIX4_AIO_LISTIO_MAX 15 /* int */ -#define CTL_POSIX4_AIO_MAX 16 /* int */ -#define CTL_POSIX4_AIO_PRIO_DELTA_MAX 17 /* int */ -#define CTL_POSIX4_DELAYTIMER_MAX 18 /* int */ -#define CTL_POSIX4_MQ_OPEN_MAX 19 /* int */ -#define CTL_POSIX4_PAGESIZE 20 /* int */ -#define CTL_POSIX4_RTSIG_MAX 21 /* int */ -#define CTL_POSIX4_SEM_NSEMS_MAX 22 /* int */ -#define CTL_POSIX4_SEM_VALUE_MAX 23 /* int */ -#define CTL_POSIX4_SIGQUEUE_MAX 24 /* int */ -#define CTL_POSIX4_TIMER_MAX 25 /* int */ - -#define CTL_POSIX4_N_CTLS 25 - -#define CTL_POSIX4_NAMES { \ - { 0, 0 }, \ - { "asynchronous_io", CTLTYPE_INT }, \ - { "mapped_files", CTLTYPE_INT }, \ - { "memlock", CTLTYPE_INT }, \ - { "memlock_range", CTLTYPE_INT }, \ - { "memory_protection", CTLTYPE_INT }, \ - { "message_passing", CTLTYPE_INT }, \ - { "prioritized_io", CTLTYPE_INT }, \ - { "priority_scheduling", CTLTYPE_INT }, \ - { "realtime_signals", CTLTYPE_INT }, \ - { "semaphores", CTLTYPE_INT }, \ - { "fsync", CTLTYPE_INT }, \ - { "shared_memory_objects", CTLTYPE_INT }, \ - { "synchronized_io", CTLTYPE_INT }, \ - { "timers", CTLTYPE_INT }, \ - { "aio_listio_max", CTLTYPE_INT }, \ - { "aio_max", CTLTYPE_INT }, \ - { "aio_prio_delta_max", CTLTYPE_INT }, \ - { "delaytimer_max", CTLTYPE_INT }, \ - { "mq_open_max", CTLTYPE_INT }, \ - { "pagesize", CTLTYPE_INT }, \ - { "rtsig_max", CTLTYPE_INT }, \ - { "nsems_max", CTLTYPE_INT }, \ - { "sem_value_max", CTLTYPE_INT }, \ - { "sigqueue_max", CTLTYPE_INT }, \ - { "timer_max", CTLTYPE_INT }, \ -} -#endif /* _POSIX4_VISIBLE */ -#endif /* _POSIX4_POSIX4_H_ */ +#endif /* P1003_1B */ +#endif /* _P1003_1B_P1003_1B_H_ */ diff --git a/sys/posix4/posix4_mib.c b/sys/posix4/posix4_mib.c index 84532b8ef74f..523f76b87ca0 100644 --- a/sys/posix4/posix4_mib.c +++ b/sys/posix4/posix4_mib.c @@ -34,44 +34,61 @@ #include <sys/param.h> #include <sys/kernel.h> #include <sys/sysctl.h> -#include <sys/unistd.h> +#include <posix4/posix4.h> -static int facility[CTL_POSIX4_N_CTLS]; +static int facility[CTL_P1003_1B_MAXID - 1]; + +/* OID_AUTO isn't working with sysconf(3). I guess I'd have to + * modify it to do a lookup by name from the index. + * For now I've left it a top-level sysctl. + */ + +#if 1 + +#define P1B_SYSCTL(num, name) \ +SYSCTL_INT(_p1003_1b, num, \ + name, CTLFLAG_RD, facility + num - 1, 0, ""); + +#else + +#define P1B_SYSCTL(num, name) \ +SYSCTL_INT(_kern_p1003_1b, OID_AUTO, \ + name, CTLFLAG_RD, facility + num - 1, 0, ""); +SYSCTL_NODE(_kern, OID_AUTO, p1003_1b, CTLFLAG_RW, 0, "P1003.1B"); + +#endif -#define P4_SYSCTL(num, name) \ - SYSCTL_INT(_posix4, num, name, CTLFLAG_RD, facility + num - 1, 0, ""); -P4_SYSCTL(CTL_POSIX4_ASYNCHRONOUS_IO, asynchronous_io); -P4_SYSCTL(CTL_POSIX4_MAPPED_FILES, mapped_files); -P4_SYSCTL(CTL_POSIX4_MEMLOCK, memlock); -P4_SYSCTL(CTL_POSIX4_MEMLOCK_RANGE, memlock_range); -P4_SYSCTL(CTL_POSIX4_MEMORY_PROTECTION, memory_protection); -P4_SYSCTL(CTL_POSIX4_MESSAGE_PASSING, message_passing); -P4_SYSCTL(CTL_POSIX4_PRIORITIZED_IO, prioritized_io); -P4_SYSCTL(CTL_POSIX4_PRIORITY_SCHEDULING, priority_scheduling); -P4_SYSCTL(CTL_POSIX4_REALTIME_SIGNALS, realtime_signals); -P4_SYSCTL(CTL_POSIX4_SEMAPHORES, semaphores); -P4_SYSCTL(CTL_POSIX4_FSYNC, fsync); -P4_SYSCTL(CTL_POSIX4_SHARED_MEMORY_OBJECTS, shared_memory_objects); -P4_SYSCTL(CTL_POSIX4_SYNCHRONIZED_IO, synchronized_io); -P4_SYSCTL(CTL_POSIX4_TIMERS, timers); -P4_SYSCTL(CTL_POSIX4_AIO_LISTIO_MAX, aio_listio_max); -P4_SYSCTL(CTL_POSIX4_AIO_MAX, aio_max); -P4_SYSCTL(CTL_POSIX4_AIO_PRIO_DELTA_MAX, aio_prio_delta_max); -P4_SYSCTL(CTL_POSIX4_DELAYTIMER_MAX, delaytimer_max); -P4_SYSCTL(CTL_POSIX4_MQ_OPEN_MAX, mq_open_max); -P4_SYSCTL(CTL_POSIX4_PAGESIZE, pagesize); -P4_SYSCTL(CTL_POSIX4_RTSIG_MAX, rtsig_max); -P4_SYSCTL(CTL_POSIX4_SEM_NSEMS_MAX, sem_nsems_max); -P4_SYSCTL(CTL_POSIX4_SEM_VALUE_MAX, sem_value_max); -P4_SYSCTL(CTL_POSIX4_SIGQUEUE_MAX, sigqueue_max); -P4_SYSCTL(CTL_POSIX4_TIMER_MAX, timer_max); +P1B_SYSCTL(CTL_P1003_1B_ASYNCHRONOUS_IO, asynchronous_io); +P1B_SYSCTL(CTL_P1003_1B_MAPPED_FILES, mapped_files); +P1B_SYSCTL(CTL_P1003_1B_MEMLOCK, memlock); +P1B_SYSCTL(CTL_P1003_1B_MEMLOCK_RANGE, memlock_range); +P1B_SYSCTL(CTL_P1003_1B_MEMORY_PROTECTION, memory_protection); +P1B_SYSCTL(CTL_P1003_1B_MESSAGE_PASSING, message_passing); +P1B_SYSCTL(CTL_P1003_1B_PRIORITIZED_IO, prioritized_io); +P1B_SYSCTL(CTL_P1003_1B_PRIORITY_SCHEDULING, priority_scheduling); +P1B_SYSCTL(CTL_P1003_1B_REALTIME_SIGNALS, realtime_signals); +P1B_SYSCTL(CTL_P1003_1B_SEMAPHORES, semaphores); +P1B_SYSCTL(CTL_P1003_1B_FSYNC, fsync); +P1B_SYSCTL(CTL_P1003_1B_SHARED_MEMORY_OBJECTS, shared_memory_objects); +P1B_SYSCTL(CTL_P1003_1B_SYNCHRONIZED_IO, synchronized_io); +P1B_SYSCTL(CTL_P1003_1B_TIMERS, timers); +P1B_SYSCTL(CTL_P1003_1B_AIO_LISTIO_MAX, aio_listio_max); +P1B_SYSCTL(CTL_P1003_1B_AIO_MAX, aio_max); +P1B_SYSCTL(CTL_P1003_1B_AIO_PRIO_DELTA_MAX, aio_prio_delta_max); +P1B_SYSCTL(CTL_P1003_1B_DELAYTIMER_MAX, delaytimer_max); +P1B_SYSCTL(CTL_P1003_1B_MQ_OPEN_MAX, mq_open_max); +P1B_SYSCTL(CTL_P1003_1B_PAGESIZE, pagesize); +P1B_SYSCTL(CTL_P1003_1B_RTSIG_MAX, rtsig_max); +P1B_SYSCTL(CTL_P1003_1B_SEM_NSEMS_MAX, sem_nsems_max); +P1B_SYSCTL(CTL_P1003_1B_SEM_VALUE_MAX, sem_value_max); +P1B_SYSCTL(CTL_P1003_1B_SIGQUEUE_MAX, sigqueue_max); +P1B_SYSCTL(CTL_P1003_1B_TIMER_MAX, timer_max); -/* posix4_facility: Set a facility to a value. This is - * probably a temporary measure until the LKM code is combined with this. +/* p31b_setcfg: Set the configuration */ -void posix4_facility(int num, int value) +void p31b_setcfg(int num, int value) { - if (num >= 1 && num <= CTL_POSIX4_N_CTLS) + if (num >= 1 && num < CTL_P1003_1B_MAXID) facility[num - 1] = value; } diff --git a/sys/posix4/sched.h b/sys/posix4/sched.h index 50bc3c65b1dd..bd049339f921 100644 --- a/sys/posix4/sched.h +++ b/sys/posix4/sched.h @@ -1,7 +1,7 @@ #ifndef _SCHED_H_ #define _SCHED_H_ -/* sched.h: POSIX.4 Process Scheduling header */ +/* sched.h: POSIX 1003.1b Process Scheduling header */ /*- * Copyright (c) 1996, 1997 @@ -37,7 +37,6 @@ * */ -#include <unistd.h> #include <sys/types.h> /* For pid_t */ #ifndef KERNEL diff --git a/sys/posix4/semaphore.h b/sys/posix4/semaphore.h index 02cde3ee7821..f57a96f7e3f4 100644 --- a/sys/posix4/semaphore.h +++ b/sys/posix4/semaphore.h @@ -1,7 +1,7 @@ #ifndef _SEMAPHORE_H_ #define _SEMAPHORE_H_ -/* semaphore.h: POSIX.4 semaphores */ +/* semaphore.h: POSIX 1003.1b semaphores */ /*- * Copyright (c) 1996, 1997 @@ -36,7 +36,9 @@ * */ -#ifdef _POSIX4_INCLUDE_MAYBES +#include <sys/_posix.h> + +#ifdef _P1003_1B_INCLUDE_MAYBES #include <sys/types.h> #include <fcntl.h> #endif |