Module Name:    src
Committed By:   pgoyette
Date:           Wed May 13 02:06:25 UTC 2015

Modified Files:
        src/sys/conf: param.c
        src/sys/kern: sysv_ipc.c
Added Files:
        src/sys/modules/sysv_ipc: Makefile

Log Message:
Create a new sysv_ipc module to contain the SYSVSHM, SYSVSEM, and
SYSVMSG options.  Move associated variables out of param.c and into
the module's source file.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sys/conf/param.c
cvs rdiff -u -r1.27 -r1.28 src/sys/kern/sysv_ipc.c
cvs rdiff -u -r0 -r1.1 src/sys/modules/sysv_ipc/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/conf/param.c
diff -u src/sys/conf/param.c:1.64 src/sys/conf/param.c:1.65
--- src/sys/conf/param.c:1.64	Sat Jun  9 02:31:14 2012
+++ src/sys/conf/param.c	Wed May 13 02:06:25 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.c,v 1.64 2012/06/09 02:31:14 christos Exp $	*/
+/*	$NetBSD: param.c,v 1.65 2015/05/13 02:06:25 pgoyette Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1989 Regents of the University of California.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: param.c,v 1.64 2012/06/09 02:31:14 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: param.c,v 1.65 2015/05/13 02:06:25 pgoyette Exp $");
 
 #include "opt_hz.h"
 #include "opt_rtc_offset.h"
@@ -148,6 +148,7 @@ int	mblowat = MBLOWAT;
 #endif
 int	mcllowat = MCLLOWAT;
 
+#if XXX_PRG
 /*
  * Values in support of System V compatible shared memory.	XXX
  */
@@ -208,6 +209,7 @@ struct	msginfo msginfo = {
 	MSGSEG		/* number of message segments */
 };
 #endif
+#endif /* XXX_PRG */
 
 /*
  * Actual network mbuf sizes (read-only), for netstat.

Index: src/sys/kern/sysv_ipc.c
diff -u src/sys/kern/sysv_ipc.c:1.27 src/sys/kern/sysv_ipc.c:1.28
--- src/sys/kern/sysv_ipc.c:1.27	Wed May 13 01:23:10 2015
+++ src/sys/kern/sysv_ipc.c	Wed May 13 02:06:25 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: sysv_ipc.c,v 1.27 2015/05/13 01:23:10 pgoyette Exp $	*/
+/*	$NetBSD: sysv_ipc.c,v 1.28 2015/05/13 02:06:25 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2007 The NetBSD Foundation, Inc.
@@ -30,10 +30,15 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sysv_ipc.c,v 1.27 2015/05/13 01:23:10 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysv_ipc.c,v 1.28 2015/05/13 02:06:25 pgoyette Exp $");
 
+#ifdef _KERNEL_OPT
 #include "opt_sysv.h"
-#include "opt_compat_netbsd.h"
+#endif
+
+#include <sys/syscall.h>
+#include <sys/syscallargs.h>
+#include <sys/syscallvar.h>
 #include <sys/param.h>
 #include <sys/kernel.h>
 #include <sys/proc.h>
@@ -49,22 +54,193 @@ __KERNEL_RCSID(0, "$NetBSD: sysv_ipc.c,v
 #endif
 #include <sys/systm.h>
 #include <sys/kmem.h>
+#include <sys/module.h>
 #include <sys/mount.h>
 #include <sys/vnode.h>
 #include <sys/stat.h>
 #include <sys/sysctl.h>
 #include <sys/kauth.h>
 
-#ifdef COMPAT_50
-#include <compat/sys/ipc.h>
+static int (*kern_sysvipc50_sysctl_p)(SYSCTLFN_ARGS);
+
+/*
+ * Values in support of System V compatible shared memory.	XXX
+ * (originally located in sys/conf/param.c)
+ */
+#ifdef SYSVSHM
+#if !defined(SHMMAX) && defined(SHMMAXPGS)
+#define	SHMMAX	SHMMAXPGS	/* shminit() performs a `*= PAGE_SIZE' */
+#elif !defined(SHMMAX)
+#define SHMMAX 0
+#endif
+#ifndef	SHMMIN
+#define	SHMMIN	1
+#endif
+#ifndef	SHMMNI
+#define	SHMMNI	128		/* <64k, see IPCID_TO_IX in ipc.h */
+#endif
+#ifndef	SHMSEG
+#define	SHMSEG	128
+#endif
+
+struct	shminfo shminfo = {
+	SHMMAX,
+	SHMMIN,
+	SHMMNI,
+	SHMSEG,
+	0
+};
 #endif
 
-static int (*kern_sysvipc50_sysctl_p)(SYSCTLFN_ARGS)
-#ifdef COMPAT_50
-		= sysctl_kern_sysvipc50;
-#else
-		= NULL;
+/*
+ * Values in support of System V compatible semaphores.
+ */
+#ifdef SYSVSEM
+struct	seminfo seminfo = {
+	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 */
+};
+#endif
+
+/*
+ * Values in support of System V compatible messages.
+ */
+#ifdef SYSVMSG
+struct	msginfo msginfo = {
+	MSGMAX,		/* max chars in a message */
+	MSGMNI,		/* # of message queue identifiers */
+	MSGMNB,		/* max chars in a queue */
+	MSGTQL,		/* max messages in system */
+	MSGSSZ,		/* size of a message segment */
+			/* (must be small power of 2 greater than 4) */
+	MSGSEG		/* number of message segments */
+};
+#endif
+
+MODULE(MODULE_CLASS_EXEC, sysv_ipc, NULL);
+ 
+#ifdef _MODULE
+SYSCTL_SETUP_PROTO(sysctl_ipc_setup);
+SYSCTL_SETUP_PROTO(sysctl_ipc_shm_setup);
+SYSCTL_SETUP_PROTO(sysctl_ipc_sem_setup);
+SYSCTL_SETUP_PROTO(sysctl_ipc_msg_setup);
+
+static struct sysctllog *sysctl_sysvipc_clog = NULL;
+#endif
+
+static const struct syscall_package sysvipc_syscalls[] = {
+	{ SYS___shmctl50, 0, (sy_call_t *)sys___shmctl50 },
+	{ SYS_shmat, 0, (sy_call_t *)sys_shmat },
+	{ SYS_shmdt, 0, (sy_call_t *)sys_shmdt },
+	{ SYS_shmget, 0, (sy_call_t *)sys_shmget },
+	{ SYS_____semctl50, 0, (sy_call_t *)sys_____semctl50 },
+	{ SYS_semget, 0, (sy_call_t *)sys_semget },
+	{ SYS_semop, 0, (sy_call_t *)sys_semop },
+	{ SYS_semconfig, 0, (sy_call_t *)sys_semconfig },
+	{ SYS___msgctl50, 0, (sy_call_t *)sys___msgctl50 },
+	{ SYS_msgget, 0, (sy_call_t *)sys_msgget },
+	{ SYS_msgsnd, 0, (sy_call_t *)sys_msgsnd },
+	{ SYS_msgrcv, 0, (sy_call_t *)sys_msgrcv },
+	{ 0, 0, NULL }
+};
+
+static int
+sysv_ipc_modcmd(modcmd_t cmd, void *arg)
+{
+	int error = 0;
+
+	switch (cmd) {
+	case MODULE_CMD_INIT:
+		/* Link the system calls */
+		error = syscall_establish(NULL, sysvipc_syscalls);
+
+		/* Initialize all sysctl sub-trees */
+#ifdef _MODULE
+		sysctl_ipc_setup(&sysctl_sysvipc_clog);
+#ifdef	SYSVMSG
+		sysctl_ipc_msg_setup(&sysctl_sysvipc_clog);
+#endif
+#ifdef	SYSVSHM
+		sysctl_ipc_shm_setup(&sysctl_sysvipc_clog);
+#endif
+#ifdef	SYSVSEM
+		sysctl_ipc_sem_setup(&sysctl_sysvipc_clog);
+#endif
+		/* Assume no compat sysctl routine for now */
+		kern_sysvipc50_sysctl_p = NULL;
+
+		/* Initialize each sub-component */
+#ifdef SYSVSHM
+		shminit();
+#endif
+#ifdef SYSVSEM
+		seminit();
 #endif
+#ifdef SYSVMSG
+		msginit();
+#endif
+#endif /* _MODULE */
+		break;
+	case MODULE_CMD_FINI:
+		/*
+		 * Make sure no subcomponents are active.  Each one
+		 * tells us if it is busy, and if it was _not_ busy,
+		 * we assume it has already done its own clean-up.
+		 * So we might need to re-init any components that
+		 * are successfully fini'd if we find one that is 
+		 * still busy.
+		 */
+#ifdef SYSVSHM
+		if (shmfini()) {
+			return EBUSY;
+		}
+#endif
+#ifdef SYSVSEM
+		if (semfini()) {
+#ifdef SYSVSHM
+			shminit();
+#endif
+			return EBUSY;
+		}
+#endif
+#ifdef SYSVMSG
+		if (msgfini()) {
+#ifdef SYSVSEM
+			seminit();
+#endif
+#ifdef SYSVSHM
+			shminit();
+#endif
+			return EBUSY;
+		}
+#endif
+
+		/* Unlink the system calls. */
+		error = syscall_disestablish(NULL, sysvipc_syscalls);
+		if (error)
+			return error;
+
+#ifdef _MODULE
+		/* Remove the sysctl sub-trees */
+		sysctl_teardown(&sysctl_sysvipc_clog);
+#endif  
+
+		/* Remove the kauth listener */
+		sysvipcfini();
+		break;
+	default:
+		return ENOTTY;
+	}
+	return error;
+}
 
 void
 sysvipc50_set_compat_sysctl(int (*compat_sysctl)(SYSCTLFN_PROTO))

Added files:

Index: src/sys/modules/sysv_ipc/Makefile
diff -u /dev/null src/sys/modules/sysv_ipc/Makefile:1.1
--- /dev/null	Wed May 13 02:06:25 2015
+++ src/sys/modules/sysv_ipc/Makefile	Wed May 13 02:06:25 2015
@@ -0,0 +1,13 @@
+# $NetBSD: Makefile,v 1.1 2015/05/13 02:06:25 pgoyette Exp $
+
+.include "../Makefile.inc"
+
+.PATH:	${S}/kern
+
+KMOD=	sysv_ipc
+
+CPPFLAGS+=	-DSYSVSEM -DSYSVSHM -DSYSVMSG
+
+SRCS=	sysv_ipc.c sysv_msg.c sysv_sem.c sysv_shm.c
+
+.include <bsd.kmodule.mk>

Reply via email to