summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormr <mr@FreeBSD.org>2001-09-15 09:50:38 +0000
committermr <mr@FreeBSD.org>2001-09-15 09:50:38 +0000
commit99ae75a097ca7f2e4fabca5b0c137987e421bd91 (patch)
tree404d7be16ab6c9ab5b9122b39a5b306417b35272
parent57403f5f90e0bf91957389f03a1d9ad47746a5c7 (diff)
downloadFreeBSD-src-99ae75a097ca7f2e4fabca5b0c137987e421bd91.zip
FreeBSD-src-99ae75a097ca7f2e4fabca5b0c137987e421bd91.tar.gz
Implement LINUX_[SEM|IPC]_[STAT|INFO]
to make /compat/linux/usr/bin/ipcs -s happy. PR: kern/29698 (part) Reviewed by: audit
-rw-r--r--sys/alpha/linux/linux.h2
-rw-r--r--sys/compat/linux/linux_ipc.c60
-rw-r--r--sys/i386/linux/linux.h2
3 files changed, 62 insertions, 2 deletions
diff --git a/sys/alpha/linux/linux.h b/sys/alpha/linux/linux.h
index 6ea22e6..f1f31fd 100644
--- a/sys/alpha/linux/linux.h
+++ b/sys/alpha/linux/linux.h
@@ -383,6 +383,8 @@ int linux_ioctl_unregister_handler(struct linux_ioctl_handler *h);
#define LINUX_GETZCNT 15
#define LINUX_SETVAL 16
#define LINUX_SETALL 17
+#define LINUX_SEM_STAT 18
+#define LINUX_SEM_INFO 19
union l_semun {
l_int val;
diff --git a/sys/compat/linux/linux_ipc.c b/sys/compat/linux/linux_ipc.c
index 9053efc..300c67a 100644
--- a/sys/compat/linux/linux_ipc.c
+++ b/sys/compat/linux/linux_ipc.c
@@ -40,6 +40,36 @@
#include <compat/linux/linux_ipc.h>
#include <compat/linux/linux_util.h>
+struct l_seminfo {
+ l_int semmap;
+ l_int semmni;
+ l_int semmns;
+ l_int semmnu;
+ l_int semmsl;
+ l_int semopm;
+ l_int semume;
+ l_int semusz;
+ l_int semvmx;
+ l_int semaem;
+};
+
+struct l_shminfo {
+ l_int shmmax;
+ l_int shmmin;
+ l_int shmmni;
+ l_int shmseg;
+ l_int shmall;
+};
+
+struct l_shm_info {
+ l_int used_ids;
+ l_ulong shm_tot; /* total allocated shm */
+ l_ulong shm_rss; /* total resident shm */
+ l_ulong shm_swp; /* total swapped shm */
+ l_ulong swap_attempts;
+ l_ulong swap_successes;
+};
+
struct l_ipc_perm {
l_key_t key;
l_uid16_t uid;
@@ -188,6 +218,7 @@ linux_semctl(struct thread *td, struct linux_semctl_args *args)
int cmd;
union semun *arg;
} */ bsd_args;
+ struct l_seminfo linux_seminfo;
int error;
union semun *unptr;
caddr_t sg;
@@ -228,16 +259,41 @@ linux_semctl(struct thread *td, struct linux_semctl_args *args)
bsd_args.arg = unptr;
return __semctl(td, &bsd_args);
case LINUX_IPC_STAT:
- bsd_args.cmd = IPC_STAT;
+ case LINUX_SEM_STAT:
+ if( args->cmd == LINUX_IPC_STAT )
+ bsd_args.cmd = IPC_STAT;
+ else
+ bsd_args.cmd = SEM_STAT;
unptr = stackgap_alloc(&sg, sizeof(union semun));
unptr->buf = stackgap_alloc(&sg, sizeof(struct semid_ds));
bsd_args.arg = unptr;
error = __semctl(td, &bsd_args);
if (error)
return error;
+ td->td_retval[0] = IXSEQ_TO_IPCID(bsd_args.semid,
+ unptr->buf->sem_perm);
bsd_to_linux_semid_ds(unptr->buf, &linux_semid);
return copyout(&linux_semid, (caddr_t)args->arg.buf,
- sizeof(linux_semid));
+ sizeof(linux_semid));
+ case LINUX_IPC_INFO:
+ case LINUX_SEM_INFO:
+ error = copyin((caddr_t)args->arg.buf, &linux_seminfo,
+ sizeof(linux_seminfo) );
+ if (error)
+ return error;
+ bcopy(&seminfo, &linux_seminfo, sizeof(linux_seminfo) );
+/* XXX BSD equivalent?
+#define used_semids 10
+#define used_sems 10
+ linux_seminfo.semusz = used_semids;
+ linux_seminfo.semaem = used_sems;
+*/
+ error = copyout((caddr_t)&linux_seminfo, (caddr_t)args->arg.buf,
+ sizeof(linux_seminfo) );
+ if (error)
+ return error;
+ td->td_retval[0] = seminfo.semmni;
+ return 0; /* No need for __semctl call */
case LINUX_GETALL:
/* FALLTHROUGH */
case LINUX_SETALL:
diff --git a/sys/i386/linux/linux.h b/sys/i386/linux/linux.h
index 2b2a916..26fc4c0 100644
--- a/sys/i386/linux/linux.h
+++ b/sys/i386/linux/linux.h
@@ -542,6 +542,8 @@ int linux_ioctl_unregister_handler(struct linux_ioctl_handler *h);
#define LINUX_GETZCNT 15
#define LINUX_SETVAL 16
#define LINUX_SETALL 17
+#define LINUX_SEM_STAT 18
+#define LINUX_SEM_INFO 19
union l_semun {
l_int val;
OpenPOWER on IntegriCloud