Date: Mon, 26 Jun 2006 18:03:33 GMT From: John Baldwin <jhb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 100075 for review Message-ID: <200606261803.k5QI3XeQ003631@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=100075 Change 100075 by jhb@jhb_mutex on 2006/06/26 18:03:03 Use kern_shmctl() and mark svr4_sys_shmsys() MPSAFE. Affected files ... .. //depot/projects/smpng/sys/compat/svr4/svr4_ipc.c#13 edit .. //depot/projects/smpng/sys/compat/svr4/syscalls.master#12 edit Differences ... ==== //depot/projects/smpng/sys/compat/svr4/svr4_ipc.c#13 (text+ko) ==== @@ -650,76 +650,61 @@ void *v; { struct svr4_sys_shmctl_args *uap = v; - int error; - caddr_t sg = stackgap_init(); - struct shmctl_args ap; struct shmid_ds bs; struct svr4_shmid_ds ss; + size_t bufsize; + int cmd, error; - ap.shmid = uap->shmid; - if (uap->buf != NULL) { - ap.buf = stackgap_alloc(&sg, sizeof (struct shmid_ds)); switch (uap->cmd) { case SVR4_IPC_SET: case SVR4_IPC_RMID: case SVR4_SHM_LOCK: case SVR4_SHM_UNLOCK: - error = copyin(uap->buf, (caddr_t) &ss, - sizeof ss); + error = copyin(uap->buf, &ss, sizeof(ss)); if (error) - return error; + return (error); svr4_to_bsd_shmid_ds(&ss, &bs); - error = copyout(&bs, ap.buf, sizeof bs); - if (error) - return error; break; default: - break; + return (EINVAL); } } - else - ap.buf = NULL; - switch (uap->cmd) { case SVR4_IPC_STAT: - ap.cmd = IPC_STAT; - if ((error = shmctl(td, &ap)) != 0) - return error; - if (uap->buf == NULL) - return 0; - error = copyin(&bs, ap.buf, sizeof bs); - if (error) - return error; - bsd_to_svr4_shmid_ds(&bs, &ss); - return copyout(&ss, uap->buf, sizeof ss); - + cmd = IPC_STAT; + break; case SVR4_IPC_SET: - ap.cmd = IPC_SET; - return shmctl(td, &ap); - + cmd = IPC_SET; + break; case SVR4_IPC_RMID: + cmd = IPC_RMID; + break; case SVR4_SHM_LOCK: + cmd = SHM_LOCK; + break; case SVR4_SHM_UNLOCK: - switch (uap->cmd) { - case SVR4_IPC_RMID: - ap.cmd = IPC_RMID; - break; - case SVR4_SHM_LOCK: - ap.cmd = SHM_LOCK; - break; - case SVR4_SHM_UNLOCK: - ap.cmd = SHM_UNLOCK; - break; - default: - return EINVAL; + cmd = SHM_UNLOCK; + break; + default: + return (EINVAL); + } + + error = kern_shmctl(td, uap->shmid, cmd, &bs, &bufsize); + if (error) + return (error); + + switch (uap->cmd) { + case SVR4_IPC_STAT: + if (uap->buf != NULL) { + bsd_to_svr4_shmid_ds(&bs, &ss); + error = copyout(&ss, uap->buf, sizeof(ss)); } - return shmctl(td, &ap); + break; + } - default: - return EINVAL; - } + return (error); } int ==== //depot/projects/smpng/sys/compat/svr4/syscalls.master#12 (text+ko) ==== @@ -100,7 +100,7 @@ int a3, int a4, int a5); } 50 AUE_NULL MSTD { int svr4_sys_sysarch(int op, void *a1); } 51 AUE_NULL UNIMPL acct -52 AUE_NULL STD { int svr4_sys_shmsys(int what, int a2, \ +52 AUE_NULL MSTD { int svr4_sys_shmsys(int what, int a2, \ int a3, int a4, int a5); } 53 AUE_NULL STD { int svr4_sys_semsys(int what, int a2, \ int a3, int a4, int a5); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200606261803.k5QI3XeQ003631>