Date: Tue, 14 Aug 2001 13:18:59 +0200 (CEST) From: Michael Reifenberger <root@nihil.plaut.de> To: FreeBSD-gnats-submit@freebsd.org Subject: kern/29698: linux ipcs doesn'work <synopsis of the problem (one line)> Message-ID: <200108141118.f7EBIxV07015@nihil.plaut.de>
next in thread | raw e-mail | index | archive | help
>Number: 29698 >Category: kern >Synopsis: linux ipcs doesn'work >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Aug 14 02:20:01 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Michael Reifenberger >Release: FreeBSD 5.0-CURRENT i386 >Organization: >Environment: System: FreeBSD nihil 5.0-CURRENT FreeBSD 5.0-CURRENT #1: Sun Aug 12 15:01:29 CEST 2001 root@nihil:/usr/src/sys/i386/compile/nihil i386 >Description: /compat/linux/usr/bin/ipcs [-s|-a] doesn't work >How-To-Repeat: /compat/linux/usr/bin/ipcs [-s|-a] >Fix: It is the needed step in getting "/compat/linux/usr/bin/ipcs -s" working. Furthermore it enhances the sysv[sem|shm] sysctl's into tunables so they can preset to usable values on modload. --- ./i386/linux/linux.h.orig Wed Aug 8 00:09:28 2001 +++ ./i386/linux/linux.h Mon Aug 13 00:41:50 2001 @@ -457,4 +457,6 @@ #define LINUX_SETVAL 16 #define LINUX_SETALL 17 +#define LINUX_SEM_STAT 18 +#define LINUX_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.orig Sun 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 <compat/linux/linux_util.h> +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; + unsigned long swap_successes; +}; + struct linux_ipc_perm { linux_key_t key; @@ -183,4 +213,5 @@ { struct linux_semid_ds linux_semid; + struct linux_seminfo linux_seminfo; struct semid_ds bsd_semid; struct __semctl_args /* { @@ -238,5 +269,9 @@ return __semctl(p, &bsd_args); case LINUX_IPC_STAT: - bsd_args.cmd = IPC_STAT; + case LINUX_SEM_STAT: + if( args->arg3 == IPC_STAT ) + bsd_args.cmd = IPC_STAT; + else + bsd_args.cmd = SEM_STAT; unptr = stackgap_alloc(&sg, sizeof(union semun *)); dsp = stackgap_alloc(&sg, sizeof(struct semid_ds)); @@ -255,5 +290,24 @@ if (error) return error; + p->p_retval[0] = IXSEQ_TO_IPCID(bsd_args.semid, bsd_semid.sem_perm); return copyout((caddr_t)&linux_semid, ldsp, sizeof(linux_semid)); + case LINUX_IPC_INFO: + case LINUX_SEM_INFO: + error = copyin(args->ptr, &ldsp, sizeof(ldsp)); + if (error) + return error; + bcopy(&seminfo, &linux_seminfo, sizeof(linux_seminfo) ); +/* XXX +#define used_semids 10 +#define used_sems 10 + linux_seminfo.semusz = used_semids; + linux_seminfo.semaem = used_sems; + } */ + error = copyout((caddr_t)&linux_seminfo, ldsp, + sizeof(linux_seminfo) ); + if (error) + return error; + p->p_retval[0] = seminfo.semmni; + return(0); case LINUX_GETALL: /* FALLTHROUGH */ >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200108141118.f7EBIxV07015>