On Sun, 12 Aug 2001, Julian Elischer wrote:
...
> my guess is that you are
Lets see...
Attached is a first shot to get /compat/linux/usr/bin/ipcs -s working.
I extended sem.h for SEM_STAT and gave it a special handling
in __semctl() to accept a index number.
Please review and commmit if acceptable.
BTW: In sysv_*.c the sysctls got extended to be tunables.
This left the question how (readonly)sysctl vars should get initialised in
modules.
FE: semmni is currently readonly and used on modload time to allocate a scruct.
Because the sysctl var doesn't exist before modload but is used during modload
there is no possibility to preset the value except on compile-time.
One sollution is to use tunables but can they be changed after startup?
BTW2: Is it possible that changing a sysctl(from userland) var calls a
kernel function (maybe for sanity checks)?
Or has the sysct to be of the type SYSCTL_PROC?
Bye!
Michael Reifenberger
^.*Plaut.*$, IT, R/3 Basis, GPS
--- ./i386/linux/linux.h.orig Wed Aug 8 00:09:28 2001
+++ ./i386/linux/linux.hMon Aug 13 00:41:50 2001
@@ -457,4 +457,6 @@
#defineLINUX_SETVAL16
#defineLINUX_SETALL17
+#defineLINUX_SEM_STAT 18
+#defineLINUX_SEM_INFO 19
/*
--- ./kern/sysv_sem.c.orig Sun Aug 12 13:18:34 2001
+++ ./kern/sysv_sem.c Sun Aug 12 23:31:10 2001
@@ -171,4 +171,14 @@
register int i;
+ TUNABLE_INT_FETCH("kern.ipc.semmap", &seminfo.semmap);
+ TUNABLE_INT_FETCH("kern.ipc.semmni", &seminfo.semmni);
+ TUNABLE_INT_FETCH("kern.ipc.semmns", &seminfo.semmns);
+ TUNABLE_INT_FETCH("kern.ipc.semmnu", &seminfo.semmnu);
+ TUNABLE_INT_FETCH("kern.ipc.semmsl", &seminfo.semmsl);
+ TUNABLE_INT_FETCH("kern.ipc.semopm", &seminfo.semopm);
+ TUNABLE_INT_FETCH("kern.ipc.semume", &seminfo.semume);
+ TUNABLE_INT_FETCH("kern.ipc.semusz", &seminfo.semusz);
+ TUNABLE_INT_FETCH("kern.ipc.semvmx", &seminfo.semvmx);
+ TUNABLE_INT_FETCH("kern.ipc.semaem", &seminfo.semaem);
sem = malloc(sizeof(struct sem) * seminfo.semmns, M_SEM, M_WAITOK);
if (sem == NULL)
@@ -471,4 +481,21 @@
return (ENOSYS);
+ switch(cmd) {
+ case SEM_STAT:
+ if (semid < 0 || semid >= seminfo.semmsl)
+ return(EINVAL);
+ semaptr = &sema[semid];
+ if ((semaptr->sem_perm.mode & SEM_ALLOC) == 0 )
+ return(EINVAL);
+ if ((eval = ipcperm(p, &semaptr->sem_perm, IPC_R)))
+ return(eval);
+ if ((eval = copyin(arg, &real_arg, sizeof(real_arg))) != 0)
+ return(eval);
+ eval = copyout((caddr_t)semaptr, real_arg.buf,
+ sizeof(struct semid_ds));
+ rval = IXSEQ_TO_IPCID(semid,semaptr->sem_perm);
+ goto out;
+ }
+
semid = IPCID_TO_IX(semid);
if (semid < 0 || semid >= seminfo.semmsl)
@@ -602,4 +629,6 @@
return(EINVAL);
}
+
+out:
if (eval == 0)
--- ./kern/sysv_shm.c.orig Sun Aug 12 13:18:43 2001
+++ ./kern/sysv_shm.c Sun Aug 12 21:11:36 2001
@@ -716,4 +716,10 @@
int i;
+TUNABLE_INT_FETCH("kern.ipc.shmmaxpgs", &shminfo.shmall);
+shminfo.shmmax = shminfo.shmall * PAGE_SIZE;
+TUNABLE_INT_FETCH("kern.ipc.shmmin", &shminfo.shmmin);
+TUNABLE_INT_FETCH("kern.ipc.shmmni", &shminfo.shmmni);
+TUNABLE_INT_FETCH("kern.ipc.shmseg", &shminfo.shmseg);
+TUNABLE_INT_FETCH("kern.ipc.shm_use_phys", &shm_use_phys);
shmalloced = shminfo.shmmni;
shmsegs = malloc(shmalloced * sizeof(shmsegs[0]), M_SHM, M_WAITOK);
--- ./sys/sem.h.origSun Aug 12 23:17:32 2001
+++ ./sys/sem.h Mon Aug 13 00:40:50 2001
@@ -59,4 +59,6 @@
#define SETVAL 8 /* Set the value of semval to arg.val {ALTER} */
#define SETALL 9 /* Set semvals from arg.array {ALTER} */
+#define SEM_STAT 10 /* Like IPC_STAT but treats semid as sema-index*/
+#define SEM_INFO 11 /* for future use */
/*
--- ./compat/linux/linux_ipc.c.orig Sat Aug 4 17:49:33 2001
+++ ./compat/linux/linux_ipc.c Mon Aug 13 00:45:27 2001
@@ -41,4 +41,34 @@
#include
+struct linux_seminfo {
+int semmap;
+int semmni;
+int semmns;
+int semmnu;
+int semmsl;
+int semopm;
+int semume;
+int semusz;
+int semvmx;
+int semaem;
+};
+
+struct linux_shminfo {
+int shmmax;
+int shmmin;
+int shmmni;
+int shmseg;
+int shmall;
+};
+
+struct linux_shm_info {
+int used_ids;
+unsigned long shm_tot; /* total allocated shm */
+unsigned long shm_rss; /* total resident shm */
+unsigned long shm_swp; /* total swapped shm */
+unsigned long swap_attempts;
+un