Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Add new sysctl node "KERN_SYSVIPC_INFO" with "KERN_SYSVI...



details:   https://anonhg.NetBSD.org/src/rev/29be58f84b84
branches:  trunk
changeset: 487059:29be58f84b84
user:      simonb <simonb%NetBSD.org@localhost>
date:      Fri Jun 02 15:53:03 2000 +0000

description:
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().

diffstat:

 sys/compat/common/sysv_msg_14.c |    9 +-
 sys/compat/common/sysv_sem_14.c |    9 +-
 sys/compat/common/sysv_shm_14.c |    9 +-
 sys/kern/kern_clock.c           |    4 +-
 sys/kern/kern_ntptime.c         |    4 +-
 sys/kern/kern_sysctl.c          |  213 +++++++++++++++++++++++++++++++++++++--
 sys/kern/sysv_msg.c             |   14 +-
 sys/kern/sysv_sem.c             |   14 +-
 sys/kern/sysv_shm.c             |   13 +-
 sys/sys/ipc.h                   |   26 ++++-
 sys/sys/msg.h                   |   50 ++++++--
 sys/sys/sem.h                   |   61 +++++++---
 sys/sys/shm.h                   |   37 +++++-
 sys/sys/sysctl.h                |   33 +++--
 14 files changed, 390 insertions(+), 106 deletions(-)

diffs (truncated from 893 to 300 lines):

diff -r 156952c460fb -r 29be58f84b84 sys/compat/common/sysv_msg_14.c
--- a/sys/compat/common/sysv_msg_14.c   Fri Jun 02 15:38:32 2000 +0000
+++ b/sys/compat/common/sysv_msg_14.c   Fri Jun 02 15:53:03 2000 +0000
@@ -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 @@
 #undef CVT
 }
 
-void
+static void
 native_to_msqid_ds14(msqbuf, omsqbuf)
        struct msqid_ds *msqbuf;
        struct msqid_ds14 *omsqbuf;
diff -r 156952c460fb -r 29be58f84b84 sys/compat/common/sysv_sem_14.c
--- a/sys/compat/common/sysv_sem_14.c   Fri Jun 02 15:38:32 2000 +0000
+++ b/sys/compat/common/sysv_sem_14.c   Fri Jun 02 15:53:03 2000 +0000
@@ -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 @@
 #undef CVT
 }
 
-void
+static void
 native_to_semid_ds14(sembuf, osembuf)
        struct semid_ds *sembuf;
        struct semid_ds14 *osembuf;
diff -r 156952c460fb -r 29be58f84b84 sys/compat/common/sysv_shm_14.c
--- a/sys/compat/common/sysv_shm_14.c   Fri Jun 02 15:38:32 2000 +0000
+++ b/sys/compat/common/sysv_shm_14.c   Fri Jun 02 15:53:03 2000 +0000
@@ -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 @@
 #undef CVT
 }
 
-void
+static void
 native_to_shmid_ds14(shmbuf, oshmbuf)
        struct shmid_ds *shmbuf;
        struct shmid_ds14 *oshmbuf;
diff -r 156952c460fb -r 29be58f84b84 sys/kern/kern_clock.c
--- a/sys/kern/kern_clock.c     Fri Jun 02 15:38:32 2000 +0000
+++ b/sys/kern/kern_clock.c     Fri Jun 02 15:53:03 2000 +0000
@@ -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 @@
  */
 int
 sysctl_clockrate(where, sizep)
-       char *where;
+       void *where;
        size_t *sizep;
 {
        struct clockinfo clkinfo;
diff -r 156952c460fb -r 29be58f84b84 sys/kern/kern_ntptime.c
--- a/sys/kern/kern_ntptime.c   Fri Jun 02 15:38:32 2000 +0000
+++ b/sys/kern/kern_ntptime.c   Fri Jun 02 15:53:03 2000 +0000
@@ -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 @@
  */
 int
 sysctl_ntptime(where, sizep)
-       char *where;
+       void *where;
        size_t *sizep;
 {
        struct timeval atv;
diff -r 156952c460fb -r 29be58f84b84 sys/kern/kern_sysctl.c
--- a/sys/kern/kern_sysctl.c    Fri Jun 02 15:38:32 2000 +0000
+++ b/sys/kern/kern_sysctl.c    Fri Jun 02 15:53:03 2000 +0000
@@ -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 @@
        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 @@
        case KERN_PROF:
        case KERN_MBUF:
        case KERN_PROC_ARGS:
+       case KERN_SYSVIPC_INFO:
                /* Not terminal. */
                break;
        default:
@@ -442,6 +460,10 @@
        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 @@
 /*
  * 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 @@
        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



Home | Main Index | Thread Index | Old Index