1 /* $Id: ipc.c,v 1.5 1999/12/09 00:41:00 davem Exp $
2 * ipc.c: Solaris IPC emulation
4 * Copyright (C) 1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
7 #include <linux/kernel.h>
8 #include <linux/types.h>
9 #include <linux/smp_lock.h>
10 #include <linux/wait.h>
12 #include <linux/shm.h>
13 #include <linux/sem.h>
14 #include <linux/msg.h>
16 #include <asm/uaccess.h>
17 #include <asm/string.h>
22 struct solaris_ipc_perm {
33 struct solaris_shmid_ds {
34 struct solaris_ipc_perm shm_perm;
37 unsigned short shm_lkcnt;
49 unsigned short shm_cv;
55 asmlinkage long solaris_shmsys(int cmd, u32 arg1, u32 arg2, u32 arg3)
57 int (*sys_ipc)(unsigned,int,int,unsigned long,void __user *,long) =
58 (int (*)(unsigned,int,int,unsigned long,void __user *,long))SYS(ipc);
67 ret = sys_ipc(SHMAT, arg1, arg3 & ~0x4000, (unsigned long)&raddr, A(arg2), 0);
69 if (ret >= 0) return (u32)raddr;
73 case 3: /* SHM_LOCK */
74 case 4: /* SHM_UNLOCK */
75 return sys_ipc(SHMCTL, arg1, (arg2 == 3) ? SHM_LOCK : SHM_UNLOCK, 0, NULL, 0);
76 case 10: /* IPC_RMID */
77 return sys_ipc(SHMCTL, arg1, IPC_RMID, 0, NULL, 0);
78 case 11: /* IPC_SET */
81 struct solaris_shmid_ds __user *p = A(arg3);
83 if (get_user (s.shm_perm.uid, &p->shm_perm.uid) ||
84 __get_user (s.shm_perm.gid, &p->shm_perm.gid) ||
85 __get_user (s.shm_perm.mode, &p->shm_perm.mode))
89 ret = sys_ipc(SHMCTL, arg1, IPC_SET, 0, &s, 0);
93 case 12: /* IPC_STAT */
96 struct solaris_shmid_ds __user *p = A(arg3);
100 ret = sys_ipc(SHMCTL, arg1, IPC_SET, 0, &s, 0);
102 if (put_user (s.shm_perm.uid, &(p->shm_perm.uid)) ||
103 __put_user (s.shm_perm.gid, &(p->shm_perm.gid)) ||
104 __put_user (s.shm_perm.cuid, &(p->shm_perm.cuid)) ||
105 __put_user (s.shm_perm.cgid, &(p->shm_perm.cgid)) ||
106 __put_user (s.shm_perm.mode, &(p->shm_perm.mode)) ||
107 __put_user (s.shm_perm.seq, &(p->shm_perm.seq)) ||
108 __put_user (s.shm_perm.key, &(p->shm_perm.key)) ||
109 __put_user (s.shm_segsz, &(p->shm_segsz)) ||
110 __put_user (s.shm_lpid, &(p->shm_lpid)) ||
111 __put_user (s.shm_cpid, &(p->shm_cpid)) ||
112 __put_user (s.shm_nattch, &(p->shm_nattch)) ||
113 __put_user (s.shm_atime, &(p->shm_atime)) ||
114 __put_user (s.shm_dtime, &(p->shm_dtime)) ||
115 __put_user (s.shm_ctime, &(p->shm_ctime)))
119 default: return -EINVAL;
122 return sys_ipc(SHMDT, 0, 0, 0, A(arg1), 0);
124 return sys_ipc(SHMGET, arg1, arg2, arg3, NULL, 0);