Add new sysctl node "KERN_SYSVIPC_INFO" with "KERN_SYSVIPC_MSG_INFO",

"KERN_SYSVIPC_SEM_INFO" and "KERN_SYSVIPC_SHM_INFO" to return the
info and data structures for the relevent SysV IPC types.  The return
structures use fixed-size types and should be compat32 safe.  All
user-visible changes are protected with
	#if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)

Make all variable declarations extern in msg.h, sem.h and shm.h and
add relevent variable declarations to sysv_*.c and remove unneeded
header files from those .c files.

Make compat14 SysV IPC conversion functions and sysctl_file() static.

Change the data pointer to "void *" in sysctl_clockrate(),
sysctl_ntptime(), sysctl_file() and sysctl_doeproc().
This commit is contained in:
simonb 2000-06-02 15:53:03 +00:00
parent f2ab1eb70c
commit 38cc1b3975
14 changed files with 390 additions and 106 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: sysv_msg_14.c,v 1.1 1999/08/25 04:47:12 thorpej Exp $ */
/* $NetBSD: sysv_msg_14.c,v 1.2 2000/06/02 15:53:03 simonb Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -48,7 +48,10 @@
#include <sys/syscallargs.h>
void
static void msqid_ds14_to_native __P((struct msqid_ds14 *, struct msqid_ds *));
static void native_to_msqid_ds14 __P((struct msqid_ds *, struct msqid_ds14 *));
static void
msqid_ds14_to_native(omsqbuf, msqbuf)
struct msqid_ds14 *omsqbuf;
struct msqid_ds *msqbuf;
@ -67,7 +70,7 @@ msqid_ds14_to_native(omsqbuf, msqbuf)
#undef CVT
}
void
static void
native_to_msqid_ds14(msqbuf, omsqbuf)
struct msqid_ds *msqbuf;
struct msqid_ds14 *omsqbuf;

View File

@ -1,4 +1,4 @@
/* $NetBSD: sysv_sem_14.c,v 1.1 1999/08/25 04:47:12 thorpej Exp $ */
/* $NetBSD: sysv_sem_14.c,v 1.2 2000/06/02 15:53:04 simonb Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -48,7 +48,10 @@
#include <sys/syscallargs.h>
void
static void semid_ds14_to_native __P((struct semid_ds14 *, struct semid_ds *));
static void native_to_semid_ds14 __P((struct semid_ds *, struct semid_ds14 *));
static void
semid_ds14_to_native(osembuf, sembuf)
struct semid_ds14 *osembuf;
struct semid_ds *sembuf;
@ -63,7 +66,7 @@ semid_ds14_to_native(osembuf, sembuf)
#undef CVT
}
void
static void
native_to_semid_ds14(sembuf, osembuf)
struct semid_ds *sembuf;
struct semid_ds14 *osembuf;

View File

@ -1,4 +1,4 @@
/* $NetBSD: sysv_shm_14.c,v 1.1 1999/08/25 04:47:12 thorpej Exp $ */
/* $NetBSD: sysv_shm_14.c,v 1.2 2000/06/02 15:53:04 simonb Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -48,7 +48,10 @@
#include <sys/syscallargs.h>
void
static void shmid_ds14_to_native __P((struct shmid_ds14 *, struct shmid_ds *));
static void native_to_shmid_ds14 __P((struct shmid_ds *, struct shmid_ds14 *));
static void
shmid_ds14_to_native(oshmbuf, shmbuf)
struct shmid_ds14 *oshmbuf;
struct shmid_ds *shmbuf;
@ -67,7 +70,7 @@ shmid_ds14_to_native(oshmbuf, shmbuf)
#undef CVT
}
void
static void
native_to_shmid_ds14(shmbuf, oshmbuf)
struct shmid_ds *shmbuf;
struct shmid_ds14 *oshmbuf;

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_clock.c,v 1.58 2000/05/29 23:48:33 mycroft Exp $ */
/* $NetBSD: kern_clock.c,v 1.59 2000/06/02 15:53:04 simonb Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -1596,7 +1596,7 @@ hardpps(tvp, usec)
*/
int
sysctl_clockrate(where, sizep)
char *where;
void *where;
size_t *sizep;
{
struct clockinfo clkinfo;

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_ntptime.c,v 1.9 2000/03/30 09:27:11 augustss Exp $ */
/* $NetBSD: kern_ntptime.c,v 1.10 2000/06/02 15:53:04 simonb Exp $ */
/******************************************************************************
* *
@ -295,7 +295,7 @@ sys_ntp_adjtime(p, v, retval)
*/
int
sysctl_ntptime(where, sizep)
char *where;
void *where;
size_t *sizep;
{
struct timeval atv;

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_sysctl.c,v 1.68 2000/06/01 18:30:03 pk Exp $ */
/* $NetBSD: kern_sysctl.c,v 1.69 2000/06/02 15:53:05 simonb Exp $ */
/*-
* Copyright (c) 1982, 1986, 1989, 1993
@ -70,6 +70,19 @@
#include <sys/vnode.h>
#include <sys/sysctl.h>
#if defined(SYSVMSG) || defined(SYSVSEM) || defined(SYSVSHM)
#include <sys/ipc.h>
#endif
#ifdef SYSVMSG
#include <sys/msg.h>
#endif
#ifdef SYSVSEM
#include <sys/sem.h>
#endif
#ifdef SYSVSHM
#include <sys/shm.h>
#endif
#if defined(DDB)
#include <ddb/ddbvar.h>
#endif
@ -85,7 +98,11 @@ static struct sysctl_lock {
int sl_locked;
} memlock;
static int sysctl_doeproc __P((int *, u_int, char *, size_t *));
static int sysctl_file __P((void *, size_t *));
#if defined(SYSVMSG) || defined(SYSVSEM) || defined(SYSVSHM)
static int sysctl_sysvipc __P((int *, u_int, void *, size_t *));
#endif
static int sysctl_doeproc __P((int *, u_int, void *, size_t *));
static void fill_kproc2 __P((struct proc *, struct kinfo_proc2 *));
static int sysctl_procargs __P((int *, u_int, void *, size_t *, struct proc *));
@ -263,6 +280,7 @@ kern_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
case KERN_PROF:
case KERN_MBUF:
case KERN_PROC_ARGS:
case KERN_SYSVIPC_INFO:
/* Not terminal. */
break;
default:
@ -442,6 +460,10 @@ kern_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
case KERN_CP_TIME:
return (sysctl_rdstruct(oldp, oldlenp, newp, cp_time,
sizeof(cp_time)));
#if defined(SYSVMSG) || defined(SYSVSEM) || defined(SYSVSHM)
case KERN_SYSVIPC_INFO:
return (sysctl_sysvipc(name + 1, namelen - 1, oldp, oldlenp));
#endif
default:
return (EOPNOTSUPP);
}
@ -911,15 +933,16 @@ sysctl_rdstruct(oldp, oldlenp, newp, sp, len)
/*
* Get file structures.
*/
int
sysctl_file(where, sizep)
char *where;
static int
sysctl_file(vwhere, sizep)
void *vwhere;
size_t *sizep;
{
int buflen, error;
struct file *fp;
char *start = where;
char *start, *where;
start = where = vwhere;
buflen = *sizep;
if (where == NULL) {
/*
@ -960,28 +983,194 @@ sysctl_file(where, sizep)
return (0);
}
#if defined(SYSVMSG) || defined(SYSVSEM) || defined(SYSVSHM)
#define FILL_PERM(src, dst) do { \
(dst)._key = (src)._key; \
(dst).uid = (src).uid; \
(dst).gid = (src).gid; \
(dst).cuid = (src).cuid; \
(dst).cgid = (src).cgid; \
(dst).mode = (src).mode; \
(dst)._seq = (src)._seq; \
} while (0);
#define FILL_MSG(src, dst) do { \
FILL_PERM((src).msg_perm, (dst).msg_perm); \
(dst).msg_qnum = (src).msg_qnum; \
(dst).msg_qbytes = (src).msg_qbytes; \
(dst)._msg_cbytes = (src)._msg_cbytes; \
(dst).msg_lspid = (src).msg_lspid; \
(dst).msg_lrpid = (src).msg_lrpid; \
(dst).msg_stime = (src).msg_stime; \
(dst).msg_rtime = (src).msg_rtime; \
(dst).msg_ctime = (src).msg_ctime; \
} while (0)
#define FILL_SEM(src, dst) do { \
FILL_PERM((src).sem_perm, (dst).sem_perm); \
(dst).sem_nsems = (src).sem_nsems; \
(dst).sem_otime = (src).sem_otime; \
(dst).sem_ctime = (src).sem_ctime; \
} while (0)
#define FILL_SHM(src, dst) do { \
FILL_PERM((src).shm_perm, (dst).shm_perm); \
(dst).shm_segsz = (src).shm_segsz; \
(dst).shm_lpid = (src).shm_lpid; \
(dst).shm_cpid = (src).shm_cpid; \
(dst).shm_atime = (src).shm_atime; \
(dst).shm_dtime = (src).shm_dtime; \
(dst).shm_ctime = (src).shm_ctime; \
(dst).shm_nattch = (src).shm_nattch; \
} while (0)
static int
sysctl_sysvipc(name, namelen, where, sizep)
int *name;
u_int namelen;
void *where;
size_t *sizep;
{
struct msg_sysctl_info *msgsi;
struct sem_sysctl_info *semsi;
struct shm_sysctl_info *shmsi;
size_t infosize, dssize, tsize, buflen;
void *buf = NULL, *buf2;
char *start;
int32_t nds;
int i, error, ret;
if (namelen != 1)
return (EINVAL);
start = where;
buflen = *sizep;
switch (*name) {
case KERN_SYSVIPC_MSG_INFO:
#ifdef SYSVMSG
infosize = sizeof(msgsi->msginfo);
nds = msginfo.msgmni;
dssize = sizeof(msgsi->msgids[0]);
break;
#else
return (EINVAL);
#endif
case KERN_SYSVIPC_SEM_INFO:
#ifdef SYSVSEM
infosize = sizeof(semsi->seminfo);
nds = seminfo.semmni;
dssize = sizeof(semsi->semids[0]);
break;
#else
return (EINVAL);
#endif
case KERN_SYSVIPC_SHM_INFO:
#ifdef SYSVSHM
infosize = sizeof(shmsi->shminfo);
nds = shminfo.shmmni;
dssize = sizeof(shmsi->shmids[0]);
break;
#else
return (EINVAL);
#endif
default:
return (EINVAL);
}
/*
* Round infosize to 64 bit boundary if requesting more than just
* the info structure or getting the total data size.
*/
if (where == NULL || *sizep > infosize)
infosize = ((infosize + 7) / 8) * 8;
tsize = infosize + nds * dssize;
/* Return just the total size required. */
if (where == NULL) {
*sizep = tsize;
return (0);
}
/* Not enough room for even the info struct. */
if (buflen < infosize) {
*sizep = 0;
return (ENOMEM);
}
buf = malloc(min(tsize, buflen), M_TEMP, M_WAITOK);
memset(buf, 0, min(tsize, buflen));
switch (*name) {
case KERN_SYSVIPC_MSG_INFO:
msgsi = (struct msg_sysctl_info *)buf;
buf2 = &msgsi->msgids[0];
msgsi->msginfo = msginfo;
break;
case KERN_SYSVIPC_SEM_INFO:
semsi = (struct sem_sysctl_info *)buf;
buf2 = &semsi->semids[0];
semsi->seminfo = seminfo;
break;
case KERN_SYSVIPC_SHM_INFO:
shmsi = (struct shm_sysctl_info *)buf;
buf2 = &shmsi->shmids[0];
shmsi->shminfo = shminfo;
break;
}
buflen -= infosize;
ret = 0;
if (buflen > 0) {
/* Fill in the IPC data structures. */
for (i = 0; i < nds; i++) {
if (buflen < dssize) {
ret = ENOMEM;
break;
}
switch (*name) {
case KERN_SYSVIPC_MSG_INFO:
FILL_MSG(msqids[i], msgsi->msgids[i]);
break;
case KERN_SYSVIPC_SEM_INFO:
FILL_SEM(sema[i], semsi->semids[i]);
break;
case KERN_SYSVIPC_SHM_INFO:
FILL_SHM(shmsegs[i], shmsi->shmids[i]);
break;
}
buflen -= dssize;
}
}
*sizep -= buflen;
error = copyout(buf, start, *sizep);
/* If copyout succeeded, use return code set earlier. */
if (error == 0)
error = ret;
if (buf)
free(buf, M_TEMP);
return (error);
}
#endif /* SYSVMSG || SYSVSEM || SYSVSHM */
/*
* try over estimating by 5 procs
*/
#define KERN_PROCSLOP (5 * sizeof(struct kinfo_proc))
int
sysctl_doeproc(name, namelen, where, sizep)
static int
sysctl_doeproc(name, namelen, vwhere, sizep)
int *name;
u_int namelen;
char *where;
void *vwhere;
size_t *sizep;
{
struct eproc eproc;
struct kinfo_proc2 kproc2;
struct kinfo_proc *dp = (struct kinfo_proc *)where;
struct kinfo_proc *dp;
struct proc *p;
const struct proclist_desc *pd;
char *dp2;
char *where, *dp2;
int type, op, arg, elem_size, elem_count;
int buflen, needed, error;
dp2 = where;
dp = vwhere;
dp2 = where = vwhere;
buflen = where != NULL ? *sizep : 0;
error = needed = 0;
type = name[0];

View File

@ -1,4 +1,4 @@
/* $NetBSD: sysv_msg.c,v 1.28 2000/04/12 13:08:26 simonb Exp $ */
/* $NetBSD: sysv_msg.c,v 1.29 2000/06/02 15:53:05 simonb Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -59,13 +59,11 @@
#define SYSVMSG
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/proc.h>
#include <sys/msg.h>
#include <sys/malloc.h>
#include <sys/mount.h>
#include <vm/vm.h> /* XXX for <sys/sysctl.h> */
#include <sys/sysctl.h>
#include <sys/mount.h> /* XXX for <sys/syscallargs.h> */
#include <sys/syscallargs.h>
#define MSG_DEBUG
@ -80,6 +78,10 @@
int nfree_msgmaps; /* # of free map entries */
short free_msgmaps; /* head of linked list of free map entries */
struct __msg *free_msghdrs; /* list of free msg headers */
char *msgpool; /* MSGMAX byte long msg buffer pool */
struct msgmap *msgmaps; /* MSGSEG msgmap structures */
struct __msg *msghdrs; /* MSGTQL msg headers */
struct msqid_ds *msqids; /* MSGMNI msqid_ds struct's */
static void msg_freehdr __P((struct __msg *));

View File

@ -1,4 +1,4 @@
/* $NetBSD: sysv_sem.c,v 1.37 2000/05/27 21:00:25 sommerfeld Exp $ */
/* $NetBSD: sysv_sem.c,v 1.38 2000/06/02 15:53:05 simonb Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -48,16 +48,18 @@
#define SYSVSEM
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/proc.h>
#include <sys/sem.h>
#include <sys/malloc.h>
#include <sys/mount.h>
#include <vm/vm.h> /* XXX for <sys/sysctl.h> */
#include <sys/sysctl.h>
#include <sys/mount.h> /* XXX for <sys/syscallargs.h> */
#include <sys/syscallargs.h>
int semtot = 0;
struct semid_ds *sema; /* semaphore id pool */
struct __sem *sem; /* semaphore pool */
struct sem_undo *semu_list; /* list of active undo structures */
int *semu; /* undo structure pool */
#ifdef SEM_DEBUG
#define SEM_PRINTF(a) printf a

View File

@ -1,4 +1,4 @@
/* $NetBSD: sysv_shm.c,v 1.55 2000/04/15 16:49:40 simonb Exp $ */
/* $NetBSD: sysv_shm.c,v 1.56 2000/06/02 15:53:05 simonb Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -73,20 +73,17 @@
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/shm.h>
#include <sys/proc.h>
#include <sys/uio.h>
#include <sys/time.h>
#include <sys/malloc.h>
#include <sys/mman.h>
#include <sys/systm.h>
#include <sys/stat.h>
#include <sys/mount.h>
#include <sys/syscallargs.h>
#include <vm/vm.h>
#include <uvm/uvm_extern.h>
#include <sys/sysctl.h>
#include <sys/mount.h> /* XXX for <sys/syscallargs.h> */
#include <sys/syscallargs.h>
struct shmid_ds *shm_find_segment_by_shmid __P((int));
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: ipc.h,v 1.22 1999/08/25 19:25:13 thorpej Exp $ */
/* $NetBSD: ipc.h,v 1.23 2000/06/02 15:53:05 simonb Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -70,6 +70,19 @@ struct ipc_perm {
key_t _key; /* user specified msg/sem/shm key */
};
#if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
/* Warning: 64-bit structure padding is needed here */
struct ipc_perm_sysctl {
u_int64_t _key;
uid_t uid;
gid_t gid;
uid_t cuid;
gid_t cgid;
mode_t mode;
int16_t _seq;
int16_t pad;
};
#endif /* !_POSIX_C_SOURCE && !_XOPEN_SOURCE */
#ifdef _KERNEL
/*
@ -98,11 +111,18 @@ struct ipc_perm14 {
#define IPC_SET 1 /* set options */
#define IPC_STAT 2 /* get options */
/*
* Macros to convert between ipc ids and array indices or sequence ids.
* The first of these is used by ipcs(1), and so is defined outside the
* kernel as well.
*/
#if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
#define IXSEQ_TO_IPCID(ix,perm) (((perm._seq) << 16) | (ix & 0xffff))
#endif
#ifdef _KERNEL
/* Macros to convert between ipc ids and array indices or sequence ids */
#define IPCID_TO_IX(id) ((id) & 0xffff)
#define IPCID_TO_SEQ(id) (((id) >> 16) & 0xffff)
#define IXSEQ_TO_IPCID(ix,perm) (((perm._seq) << 16) | (ix & 0xffff))
/* Common access type bits, used with ipcperm(). */
#define IPC_R 000400 /* read permission */

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.h,v 1.12 2000/03/28 05:14:04 simonb Exp $ */
/* $NetBSD: msg.h,v 1.13 2000/06/02 15:53:05 simonb Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -117,7 +117,9 @@ struct msqid_ds14 {
long msg_pad3;
long msg_pad4[4];
};
#endif
#if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
/*
* Based on the configuration parameters described in an SVR2 (yes, two)
* config(1m) man page.
@ -129,15 +131,35 @@ struct msqid_ds14 {
* two between 8 and 1024 inclusive (and panic's if it isn't).
*/
struct msginfo {
int msgmax, /* max chars in a message */
msgmni, /* max message queue identifiers */
msgmnb, /* max chars in a queue */
msgtql, /* max messages in system */
msgssz, /* size of a message segment
int32_t msgmax; /* max chars in a message */
int32_t msgmni; /* max message queue identifiers */
int32_t msgmnb; /* max chars in a queue */
int32_t msgtql; /* max messages in system */
int32_t msgssz; /* size of a message segment
(see notes above) */
msgseg; /* number of message segments */
int32_t msgseg; /* number of message segments */
};
extern struct msginfo msginfo;
/* Warning: 64-bit structure padding is needed here */
struct msgid_ds_sysctl {
struct ipc_perm_sysctl msg_perm;
u_int64_t msg_qnum;
u_int64_t msg_qbytes;
u_int64_t _msg_cbytes;
pid_t msg_lspid;
pid_t msg_lrpid;
time_t msg_stime;
time_t msg_rtime;
time_t msg_ctime;
int32_t pad;
};
struct msg_sysctl_info {
struct msginfo msginfo;
struct msgid_ds_sysctl msgids[1];
};
#endif /* !_POSIX_C_SOURCE && !_XOPEN_SOURCE */
#ifdef _KERNEL
#ifndef MSGSSZ
#define MSGSSZ 8 /* Each segment must be 2^N long */
@ -173,10 +195,11 @@ struct msgmap {
/* 0..(MSGSEG-1) -> index of next segment */
};
char *msgpool; /* MSGMAX byte long msg buffer pool */
struct msgmap *msgmaps; /* MSGSEG msgmap structures */
struct __msg *msghdrs; /* MSGTQL msg headers */
struct msqid_ds *msqids; /* MSGMNI msqid_ds struct's */
extern struct msginfo msginfo;
extern char *msgpool; /* MSGMAX byte long msg buffer pool */
extern struct msgmap *msgmaps; /* MSGSEG msgmap structures */
extern struct __msg *msghdrs; /* MSGTQL msg headers */
extern struct msqid_ds *msqids; /* MSGMNI msqid_ds struct's */
#define MSG_LOCKED 01000 /* Is this msqid_ds locked? */
@ -196,9 +219,6 @@ struct proc;
void msginit __P((void));
int msgctl1 __P((struct proc *, int, int, struct msqid_ds *));
void msqid_ds14_to_native __P((struct msqid_ds14 *, struct msqid_ds *));
void native_to_msqid_ds14 __P((struct msqid_ds *, struct msqid_ds14 *));
#endif /* !_KERNEL */
#endif /* !_SYS_MSG_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: sem.h,v 1.11 2000/03/28 05:14:04 simonb Exp $ */
/* $NetBSD: sem.h,v 1.12 2000/06/02 15:53:05 simonb Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -136,26 +136,47 @@ struct sem_undo {
int un_id; /* semid */
} un_ent[1]; /* undo entries */
};
#endif /* _KERNEL */
#if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
/*
* semaphore info struct
*/
struct seminfo {
int semmap, /* # of entries in semaphore map */
semmni, /* # of semaphore identifiers */
semmns, /* # of semaphores in system */
semmnu, /* # of undo structures in system */
semmsl, /* max # of semaphores per id */
semopm, /* max # of operations per semop call */
semume, /* max # of undo entries per process */
semusz, /* size in bytes of undo structure */
semvmx, /* semaphore maximum value */
semaem; /* adjust on exit max value */
int32_t semmap; /* # of entries in semaphore map */
int32_t semmni; /* # of semaphore identifiers */
int32_t semmns; /* # of semaphores in system */
int32_t semmnu; /* # of undo structures in system */
int32_t semmsl; /* max # of semaphores per id */
int32_t semopm; /* max # of operations per semop call */
int32_t semume; /* max # of undo entries per process */
int32_t semusz; /* size in bytes of undo structure */
int32_t semvmx; /* semaphore maximum value */
int32_t semaem; /* adjust on exit max value */
};
extern struct seminfo seminfo;
/* internal "mode" bits */
/* Warning: 64-bit structure padding is needed here */
struct semid_ds_sysctl {
struct ipc_perm_sysctl sem_perm;
int16_t sem_nsems;
int16_t pad2;
int32_t pad3;
time_t sem_otime;
time_t sem_ctime;
};
struct sem_sysctl_info {
struct seminfo seminfo;
struct semid_ds_sysctl semids[1];
};
/*
* Internal "mode" bits. The first of these is used by ipcs(1), and so
* is defined outside the kernel as well.
*/
#define SEM_ALLOC 01000 /* semaphore is allocated */
#endif /* !_POSIX_C_SOURCE && !_XOPEN_SOURCE */
#ifdef _KERNEL
#define SEM_DEST 02000 /* semaphore will be destroyed on last detach */
/*
@ -191,11 +212,12 @@ extern struct seminfo seminfo;
/*
* Structures allocated in machdep.c
*/
struct semid_ds *sema; /* semaphore id pool */
struct __sem *sem; /* semaphore pool */
struct map *semmap; /* semaphore allocation map */
struct sem_undo *semu_list; /* list of active undo structures */
int *semu; /* undo structure pool */
extern struct seminfo seminfo;
extern struct semid_ds *sema; /* semaphore id pool */
extern struct __sem *sem; /* semaphore pool */
extern struct map *semmap; /* semaphore allocation map */
extern struct sem_undo *semu_list; /* list of active undo structures */
extern int *semu; /* undo structure pool */
/*
* Macro to find a particular sem_undo vector
@ -231,9 +253,6 @@ void seminit __P((void));
void semexit __P((struct proc *));
int semctl1 __P((struct proc *, int, int, int, void *, register_t *));
void semid_ds14_to_native __P((struct semid_ds14 *, struct semid_ds *));
void native_to_semid_ds14 __P((struct semid_ds *, struct semid_ds14 *));
#endif /* !_KERNEL */
#endif /* !_SEM_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: shm.h,v 1.25 2000/03/28 05:14:04 simonb Exp $ */
/* $NetBSD: shm.h,v 1.26 2000/06/02 15:53:05 simonb Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -114,6 +114,7 @@ struct shmid_ds14 {
time_t shm_ctime; /* time of last change by shmctl() */
void *shm_internal; /* sysv stupidity */
};
#endif /* _KERNEL */
#if !defined(_XOPEN_SOURCE)
/*
@ -124,17 +125,38 @@ struct shmid_ds14 {
#define SHM_UNLOCK 4 /* Unlock a segment locked by SHM_LOCK. */
#endif /* _XOPEN_SOURCE */
#if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
/*
* System 5 style catch-all structure for shared memory constants that
* might be of interest to user programs. Do we really want/need this?
*/
struct shminfo {
int shmmax; /* max shared memory segment size (bytes) */
int shmmin; /* min shared memory segment size (bytes) */
int shmmni; /* max number of shared memory identifiers */
int shmseg; /* max shared memory segments per process */
int shmall; /* max amount of shared memory (pages) */
int32_t shmmax; /* max shared memory segment size (bytes) */
int32_t shmmin; /* min shared memory segment size (bytes) */
int32_t shmmni; /* max number of shared memory identifiers */
int32_t shmseg; /* max shared memory segments per process */
int32_t shmall; /* max amount of shared memory (pages) */
};
/* Warning: 64-bit structure padding is needed here */
struct shmid_ds_sysctl {
struct ipc_perm_sysctl shm_perm;
u_int64_t shm_segsz;
pid_t shm_lpid;
pid_t shm_cpid;
time_t shm_atime;
time_t shm_dtime;
time_t shm_ctime;
u_int32_t shm_nattch;
};
struct shm_sysctl_info {
struct shminfo shminfo;
int32_t pad; /* shminfo not a multiple of 64 bits */
struct shmid_ds_sysctl shmids[1];
};
#endif /* !_POSIX_C_SOURCE && !_XOPEN_SOURCE */
#ifdef _KERNEL
extern struct shminfo shminfo;
extern struct shmid_ds *shmsegs;
@ -144,9 +166,6 @@ void shminit __P((void));
void shmfork __P((struct vmspace *, struct vmspace *));
void shmexit __P((struct vmspace *));
int shmctl1 __P((struct proc *, int, int, struct shmid_ds *));
void shmid_ds14_to_native __P((struct shmid_ds14 *, struct shmid_ds *));
void native_to_shmid_ds14 __P((struct shmid_ds *, struct shmid_ds14 *));
#else /* !_KERNEL */
#include <sys/cdefs.h>

View File

@ -1,4 +1,4 @@
/* $NetBSD: sysctl.h,v 1.47 2000/05/27 15:28:58 simonb Exp $ */
/* $NetBSD: sysctl.h,v 1.48 2000/06/02 15:53:05 simonb Exp $ */
/*
* Copyright (c) 1989, 1993
@ -163,7 +163,8 @@ struct ctlname {
#define KERN_FSCALE 49 /* int: fixpt FSCALE */
#define KERN_CCPU 50 /* int: fixpt ccpu */
#define KERN_CP_TIME 51 /* struct: cpu time counters */
#define KERN_MAXID 52 /* number of valid kern ids */
#define KERN_SYSVIPC_INFO 52 /* number of valid kern ids */
#define KERN_MAXID 53 /* number of valid kern ids */
#define CTL_KERN_NAMES { \
{ 0, 0 }, \
@ -218,16 +219,9 @@ struct ctlname {
{ "fscale", CTLTYPE_INT }, \
{ "ccpu", CTLTYPE_INT }, \
{ "cp_time", CTLTYPE_STRUCT }, \
{ "sysvipc_info", CTLTYPE_STRUCT }, \
}
/*
* KERN_PROC_ARGS subtypes
*/
#define KERN_PROC_ARGV 1 /* argv */
#define KERN_PROC_NARGV 2 /* number of strings in above */
#define KERN_PROC_ENV 3 /* environ */
#define KERN_PROC_NENV 4 /* number of strings in above */
/*
* KERN_PROC subtypes
*/
@ -402,6 +396,20 @@ struct kinfo_proc2 {
u_int32_t p_uctime_usec; /* STRUCT TIMEVAL: child u+s time. */
};
/*
* KERN_PROC_ARGS subtypes
*/
#define KERN_PROC_ARGV 1 /* argv */
#define KERN_PROC_NARGV 2 /* number of strings in above */
#define KERN_PROC_ENV 3 /* environ */
#define KERN_PROC_NENV 4 /* number of strings in above */
/*
* KERN_SYSVIPC_INFO subtypes
*/
#define KERN_SYSVIPC_MSG_INFO 1 /* msginfo and msqid_ds */
#define KERN_SYSVIPC_SEM_INFO 2 /* seminfo and semid_ds */
#define KERN_SYSVIPC_SHM_INFO 3 /* shminfo and shmid_ds */
/*
* CTL_HW identifiers
@ -615,12 +623,11 @@ int sysctl_string __P((void *, size_t *, void *, size_t, char *, int));
int sysctl_rdstring __P((void *, size_t *, void *, char *));
int sysctl_struct __P((void *, size_t *, void *, size_t, void *, int));
int sysctl_rdstruct __P((void *, size_t *, void *, void *, int));
int sysctl_file __P((char *, size_t *));
struct radix_node;
struct walkarg;
int sysctl_clockrate __P((char *, size_t *));
int sysctl_clockrate __P((void *, size_t *));
int sysctl_vnode __P((char *, size_t *, struct proc *));
int sysctl_ntptime __P((char *, size_t *));
int sysctl_ntptime __P((void *, size_t *));
#ifdef GPROF
int sysctl_doprof __P((int *, u_int, void *, size_t *, void *, size_t));
#endif