1/* 2 * Copyright (c) 1995 Scott Bartram 3 * Copyright (c) 1995 Steven Wallace 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 8 unchanged lines hidden (view full) --- 17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * |
25 * $FreeBSD: head/sys/i386/ibcs2/ibcs2_ipc.c 107849 2002-12-14 01:56:26Z alfred $ |
26 */ 27 28#include <sys/param.h> 29#include <sys/systm.h> 30#include <sys/msg.h> 31#include <sys/sem.h> 32#include <sys/shm.h> 33#include <sys/sysproto.h> --- 67 unchanged lines hidden (view full) --- 101 return; 102} 103 104int 105ibcs2_msgsys(td, uap) 106 struct thread *td; 107 struct ibcs2_msgsys_args *uap; 108{ |
109 switch (uap->which) { |
110 case 0: /* msgget */ |
111 uap->which = 1; |
112 return msgsys(td, (struct msgsys_args *)uap); 113 case 1: { /* msgctl */ 114 int error; 115 struct msgsys_args margs; 116 caddr_t sg = stackgap_init(); 117 |
118 margs.which = 0; 119 margs.a2 = uap->a2; 120 margs.a4 = |
121 (int)stackgap_alloc(&sg, sizeof(struct msqid_ds)); |
122 margs.a3 = uap->a3; 123 switch (margs.a3) { |
124 case IBCS2_IPC_STAT: 125 error = msgsys(td, &margs); 126 if (!error) 127 cvt_msqid2imsqid( |
128 (struct msqid_ds *)margs.a4, 129 (struct ibcs2_msqid_ds *)uap->a4); |
130 return error; 131 case IBCS2_IPC_SET: |
132 cvt_imsqid2msqid((struct ibcs2_msqid_ds *)uap->a4, 133 (struct msqid_ds *)margs.a4); |
134 return msgsys(td, &margs); 135 case IBCS2_IPC_RMID: 136 return msgsys(td, &margs); 137 } 138 return EINVAL; 139 } 140 case 2: /* msgrcv */ |
141 uap->which = 3; |
142 return msgsys(td, (struct msgsys_args *)uap); 143 case 3: /* msgsnd */ |
144 uap->which = 2; |
145 return msgsys(td, (struct msgsys_args *)uap); 146 default: 147 return EINVAL; 148 } 149} 150 151/* 152 * iBCS2 semsys call --- 80 unchanged lines hidden (view full) --- 233 234int 235ibcs2_semsys(td, uap) 236 struct thread *td; 237 struct ibcs2_semsys_args *uap; 238{ 239 int error; 240 |
241 switch (uap->which) { |
242 case 0: /* semctl */ |
243 switch(uap->a4) { |
244 case IBCS2_IPC_STAT: 245 { 246 struct ibcs2_semid_ds *isp; 247 struct semid_ds *sp; 248 union semun *sup, ssu; 249 caddr_t sg = stackgap_init(); 250 251 |
252 ssu = (union semun) uap->a5; |
253 sp = stackgap_alloc(&sg, sizeof(struct semid_ds)); 254 sup = stackgap_alloc(&sg, sizeof(union semun)); 255 sup->buf = sp; |
256 uap->a5 = (int)sup; |
257 error = semsys(td, (struct semsys_args *)uap); 258 if (!error) { |
259 uap->a5 = (int)ssu.buf; |
260 isp = stackgap_alloc(&sg, sizeof(*isp)); 261 cvt_semid2isemid(sp, isp); 262 error = copyout((caddr_t)isp, 263 (caddr_t)ssu.buf, 264 sizeof(*isp)); 265 } 266 return error; 267 } 268 case IBCS2_IPC_SET: 269 { 270 struct ibcs2_semid_ds *isp; 271 struct semid_ds *sp; 272 caddr_t sg = stackgap_init(); 273 274 isp = stackgap_alloc(&sg, sizeof(*isp)); 275 sp = stackgap_alloc(&sg, sizeof(*sp)); |
276 error = copyin((caddr_t)uap->a5, (caddr_t)isp, |
277 sizeof(*isp)); 278 if (error) 279 return error; 280 cvt_isemid2semid(isp, sp); |
281 uap->a5 = (int)sp; |
282 return semsys(td, (struct semsys_args *)uap); 283 } 284 case IBCS2_SETVAL: 285 { 286 union semun *sp; 287 caddr_t sg = stackgap_init(); 288 289 sp = stackgap_alloc(&sg, sizeof(*sp)); |
290 sp->val = (int) uap->a5; 291 uap->a5 = (int)sp; |
292 return semsys(td, (struct semsys_args *)uap); 293 } 294 } 295 296 return semsys(td, (struct semsys_args *)uap); 297 298 case 1: /* semget */ 299 return semsys(td, (struct semsys_args *)uap); --- 45 unchanged lines hidden (view full) --- 345 346int 347ibcs2_shmsys(td, uap) 348 struct thread *td; 349 struct ibcs2_shmsys_args *uap; 350{ 351 int error; 352 |
353 switch (uap->which) { |
354 case 0: /* shmat */ 355 return shmsys(td, (struct shmsys_args *)uap); 356 357 case 1: /* shmctl */ |
358 switch(uap->a3) { |
359 case IBCS2_IPC_STAT: 360 { 361 struct ibcs2_shmid_ds *isp; 362 struct shmid_ds *sp; 363 caddr_t sg = stackgap_init(); 364 |
365 isp = (struct ibcs2_shmid_ds *)uap->a4; |
366 sp = stackgap_alloc(&sg, sizeof(*sp)); |
367 uap->a4 = (int)sp; |
368 error = shmsys(td, (struct shmsys_args *)uap); 369 if (!error) { |
370 uap->a4 = (int)isp; |
371 isp = stackgap_alloc(&sg, sizeof(*isp)); 372 cvt_shmid2ishmid(sp, isp); 373 error = copyout((caddr_t)isp, |
374 (caddr_t)uap->a4, |
375 sizeof(*isp)); 376 } 377 return error; 378 } 379 case IBCS2_IPC_SET: 380 { 381 struct ibcs2_shmid_ds *isp; 382 struct shmid_ds *sp; 383 caddr_t sg = stackgap_init(); 384 385 isp = stackgap_alloc(&sg, sizeof(*isp)); 386 sp = stackgap_alloc(&sg, sizeof(*sp)); |
387 error = copyin((caddr_t)uap->a4, (caddr_t)isp, |
388 sizeof(*isp)); 389 if (error) 390 return error; 391 cvt_ishmid2shmid(isp, sp); |
392 uap->a4 = (int)sp; |
393 return shmsys(td, (struct shmsys_args *)uap); 394 } 395 } 396 397 return shmsys(td, (struct shmsys_args *)uap); 398 399 case 2: /* shmdt */ 400 return shmsys(td, (struct shmsys_args *)uap); 401 402 case 3: /* shmget */ 403 return shmsys(td, (struct shmsys_args *)uap); 404 } 405 return EINVAL; 406} |