This source file includes following definitions.
- msqid_copyin
- msqid_copyout
- compat_23_sys_msgctl
- semid_copyin
- semid_copyout
- compat_23_sys___semctl
- shmid_copyin
- shmid_copyout
- compat_23_sys_shmctl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #include <sys/param.h>
20 #include <sys/systm.h>
21 #include <sys/kernel.h>
22 #include <sys/proc.h>
23 #include <sys/msg.h>
24 #include <sys/sem.h>
25 #include <sys/shm.h>
26
27 #include <sys/mount.h>
28 #include <sys/syscallargs.h>
29
30
31
32
33 #if defined(SYSVMSG) || defined(SYSVSEM) || defined(SYSVSHM)
34 #define cvt_ds(to, from, type, base) do { \
35 (to)->type##_perm.cuid = (from)->type##_perm.cuid; \
36 (to)->type##_perm.cgid = (from)->type##_perm.cgid; \
37 (to)->type##_perm.uid = (from)->type##_perm.uid; \
38 (to)->type##_perm.gid = (from)->type##_perm.gid; \
39 (to)->type##_perm.mode = (from)->type##_perm.mode & 0xffffU; \
40 (to)->type##_perm.seq = (from)->type##_perm.seq; \
41 (to)->type##_perm.key = (from)->type##_perm.key; \
42 bcopy((caddr_t)&(from)->base, (caddr_t)&(to)->base, \
43 sizeof(*(to)) - ((caddr_t)&(to)->base - (caddr_t)to)); \
44 } while (0)
45 #endif
46
47 #ifdef SYSVMSG
48
49
50
51 static int
52 msqid_copyin(const void *uaddr, void *kaddr, size_t len)
53 {
54 struct msqid_ds *msqbuf = kaddr;
55 struct msqid_ds23 omsqbuf;
56 int error;
57
58 if (len != sizeof(struct msqid_ds))
59 return (EFAULT);
60 if ((error = copyin(uaddr, &omsqbuf, sizeof(omsqbuf))) == 0)
61 cvt_ds(msqbuf, &omsqbuf, msg, msg_first);
62 return (error);
63 }
64
65
66
67
68 static int
69 msqid_copyout(const void *kaddr, void *uaddr, size_t len)
70 {
71 const struct msqid_ds *msqbuf = kaddr;
72 struct msqid_ds23 omsqbuf;
73
74 if (len != sizeof(struct msqid_ds))
75 return (EFAULT);
76 cvt_ds(&omsqbuf, msqbuf, msg, msg_first);
77 return (copyout(&omsqbuf, uaddr, sizeof(omsqbuf)));
78 }
79
80
81
82
83 int
84 compat_23_sys_msgctl(struct proc *p, void *v, register_t *retval)
85 {
86 struct compat_23_sys_msgctl_args
87
88
89
90 *uap = v;
91
92 return (msgctl1(p, SCARG(uap, msqid), SCARG(uap, cmd),
93 (caddr_t)SCARG(uap, buf), msqid_copyin, msqid_copyout));
94 }
95 #endif
96
97 #ifdef SYSVSEM
98
99
100
101 static int
102 semid_copyin(const void *uaddr, void *kaddr, size_t len)
103 {
104 struct semid_ds *sembuf = kaddr;
105 struct semid_ds23 osembuf;
106 int error;
107
108 if (len != sizeof(struct semid_ds))
109 return (EFAULT);
110 if ((error = copyin(uaddr, &osembuf, sizeof(osembuf))) == 0)
111 cvt_ds(sembuf, &osembuf, sem, sem_base);
112 return (error);
113 }
114
115
116
117
118 static int
119 semid_copyout(const void *kaddr, void *uaddr, size_t len)
120 {
121 const struct semid_ds *sembuf = kaddr;
122 struct semid_ds23 osembuf;
123
124 if (len != sizeof(struct semid_ds))
125 return (EFAULT);
126 cvt_ds(&osembuf, sembuf, sem, sem_base);
127 return (copyout(&osembuf, uaddr, sizeof(osembuf)));
128 }
129
130
131
132
133 int
134 compat_23_sys___semctl(struct proc *p, void *v, register_t *retval)
135 {
136 struct compat_23_sys___semctl_args
137
138
139
140
141 *uap = v;
142 union semun arg;
143 int error = 0, cmd = SCARG(uap, cmd);
144
145 switch (cmd) {
146 case IPC_SET:
147 case IPC_STAT:
148 case GETALL:
149 case SETVAL:
150 case SETALL:
151 error = copyin(SCARG(uap, arg), &arg, sizeof(arg));
152 break;
153 }
154 if (error == 0) {
155 error = semctl1(p, SCARG(uap, semid), SCARG(uap, semnum),
156 cmd, &arg, retval, semid_copyin, semid_copyout);
157 }
158 return (error);
159 }
160 #endif
161
162 #ifdef SYSVSHM
163
164
165
166 static int
167 shmid_copyin(const void *uaddr, void *kaddr, size_t len)
168 {
169 struct shmid_ds *shmbuf = kaddr;
170 struct shmid_ds23 oshmbuf;
171 int error;
172
173 if (len != sizeof(struct shmid_ds))
174 return (EFAULT);
175 if ((error = copyin(uaddr, &oshmbuf, sizeof(oshmbuf))) == 0)
176 cvt_ds(shmbuf, &oshmbuf, shm, shm_segsz);
177 return (error);
178 }
179
180
181
182
183 static int
184 shmid_copyout(const void *kaddr, void *uaddr, size_t len)
185 {
186 const struct shmid_ds *shmbuf = kaddr;
187 struct shmid_ds23 oshmbuf;
188
189 if (len != sizeof(struct shmid_ds))
190 return (EFAULT);
191 cvt_ds(&oshmbuf, shmbuf, shm, shm_segsz);
192 return (copyout(&oshmbuf, uaddr, sizeof(oshmbuf)));
193 }
194
195
196
197
198 int
199 compat_23_sys_shmctl(struct proc *p, void *v, register_t *retval)
200 {
201 struct compat_23_sys_shmctl_args
202
203
204
205 *uap = v;
206
207 return (shmctl1(p, SCARG(uap, shmid), SCARG(uap, cmd),
208 (caddr_t)SCARG(uap, buf), shmid_copyin, shmid_copyout));
209 }
210 #endif