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/wait.h>
11 #include <linux/shm.h>
12 #include <linux/sem.h>
13 #include <linux/msg.h>
14 #include <linux/ipc.h>
16 #include <asm/uaccess.h>
17 #include <asm/string.h>
21 struct solaris_ipc_perm
{
32 struct solaris_shmid_ds
{
33 struct solaris_ipc_perm shm_perm
;
36 unsigned short shm_lkcnt
;
48 unsigned short shm_cv
;
54 asmlinkage
long solaris_shmsys(int cmd
, u32 arg1
, u32 arg2
, u32 arg3
)
56 int (*sys_ipc
)(unsigned,int,int,unsigned long,void __user
*,long) =
57 (int (*)(unsigned,int,int,unsigned long,void __user
*,long))SYS(ipc
);
66 ret
= sys_ipc(SHMAT
, arg1
, arg3
& ~0x4000, (unsigned long)&raddr
, A(arg2
), 0);
68 if (ret
>= 0) return (u32
)raddr
;
72 case 3: /* SHM_LOCK */
73 case 4: /* SHM_UNLOCK */
74 return sys_ipc(SHMCTL
, arg1
, (arg2
== 3) ? SHM_LOCK
: SHM_UNLOCK
, 0, NULL
, 0);
75 case 10: /* IPC_RMID */
76 return sys_ipc(SHMCTL
, arg1
, IPC_RMID
, 0, NULL
, 0);
77 case 11: /* IPC_SET */
80 struct solaris_shmid_ds __user
*p
= A(arg3
);
82 if (get_user (s
.shm_perm
.uid
, &p
->shm_perm
.uid
) ||
83 __get_user (s
.shm_perm
.gid
, &p
->shm_perm
.gid
) ||
84 __get_user (s
.shm_perm
.mode
, &p
->shm_perm
.mode
))
88 ret
= sys_ipc(SHMCTL
, arg1
, IPC_SET
, 0, &s
, 0);
92 case 12: /* IPC_STAT */
95 struct solaris_shmid_ds __user
*p
= A(arg3
);
99 ret
= sys_ipc(SHMCTL
, arg1
, IPC_SET
, 0, &s
, 0);
101 if (put_user (s
.shm_perm
.uid
, &(p
->shm_perm
.uid
)) ||
102 __put_user (s
.shm_perm
.gid
, &(p
->shm_perm
.gid
)) ||
103 __put_user (s
.shm_perm
.cuid
, &(p
->shm_perm
.cuid
)) ||
104 __put_user (s
.shm_perm
.cgid
, &(p
->shm_perm
.cgid
)) ||
105 __put_user (s
.shm_perm
.mode
, &(p
->shm_perm
.mode
)) ||
106 __put_user (s
.shm_perm
.seq
, &(p
->shm_perm
.seq
)) ||
107 __put_user (s
.shm_perm
.key
, &(p
->shm_perm
.key
)) ||
108 __put_user (s
.shm_segsz
, &(p
->shm_segsz
)) ||
109 __put_user (s
.shm_lpid
, &(p
->shm_lpid
)) ||
110 __put_user (s
.shm_cpid
, &(p
->shm_cpid
)) ||
111 __put_user (s
.shm_nattch
, &(p
->shm_nattch
)) ||
112 __put_user (s
.shm_atime
, &(p
->shm_atime
)) ||
113 __put_user (s
.shm_dtime
, &(p
->shm_dtime
)) ||
114 __put_user (s
.shm_ctime
, &(p
->shm_ctime
)))
118 default: return -EINVAL
;
121 return sys_ipc(SHMDT
, 0, 0, 0, A(arg1
), 0);
123 return sys_ipc(SHMGET
, arg1
, arg2
, arg3
, NULL
, 0);