From: mbuhl Date: Fri, 16 Sep 2022 15:57:23 +0000 (+0000) Subject: semctl1 and msgctl were introduced for binary compatibility for OpenBSD 3.5. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=08b61afc716124eac1757cf94d146c18f3650f58;p=openbsd semctl1 and msgctl were introduced for binary compatibility for OpenBSD 3.5. They are no longer needed. OK bluhm@ --- diff --git a/sys/kern/sysv_msg.c b/sys/kern/sysv_msg.c index 602c81feac4..9fb57c4dedf 100644 --- a/sys/kern/sysv_msg.c +++ b/sys/kern/sysv_msg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sysv_msg.c,v 1.39 2022/08/14 01:58:28 jsg Exp $ */ +/* $OpenBSD: sysv_msg.c,v 1.40 2022/09/16 15:57:23 mbuhl Exp $ */ /* $NetBSD: sysv_msg.c,v 1.19 1996/02/09 19:00:18 christos Exp $ */ /* * Copyright (c) 2009 Bret S. Lambert @@ -98,20 +98,12 @@ sys_msgctl(struct proc *p, void *v, register_t *retval) syscallarg(int) cmd; syscallarg(struct msqid_ds *) buf; } */ *uap = v; - - return (msgctl1(p, SCARG(uap, msqid), SCARG(uap, cmd), - (caddr_t)SCARG(uap, buf), copyin, copyout)); -} - -int -msgctl1(struct proc *p, int msqid, int cmd, caddr_t buf, - int (*ds_copyin)(const void *, void *, size_t), - int (*ds_copyout)(const void *, void *, size_t)) -{ - struct msqid_ds tmp; + struct msqid_ds tmp, *umsq = SCARG(uap, buf); struct ucred *cred = p->p_ucred; struct que *que; - int error = 0; + int msqid = SCARG(uap, msqid); + int cmd = SCARG(uap, cmd); + int error; if ((que = que_lookup(msqid)) == NULL) return (EINVAL); @@ -141,7 +133,7 @@ msgctl1(struct proc *p, int msqid, int cmd, caddr_t buf, case IPC_SET: if ((error = ipcperm(cred, &que->msqid_ds.msg_perm, IPC_M))) goto out; - if ((error = ds_copyin(buf, &tmp, sizeof(struct msqid_ds)))) + if ((error = copyin(umsq, &tmp, sizeof(struct msqid_ds)))) goto out; /* only superuser can bump max bytes in queue */ @@ -173,8 +165,7 @@ msgctl1(struct proc *p, int msqid, int cmd, caddr_t buf, case IPC_STAT: if ((error = ipcperm(cred, &que->msqid_ds.msg_perm, IPC_R))) goto out; - error = ds_copyout(&que->msqid_ds, buf, - sizeof(struct msqid_ds)); + error = copyout(&que->msqid_ds, umsq, sizeof(struct msqid_ds)); break; default: diff --git a/sys/kern/sysv_sem.c b/sys/kern/sysv_sem.c index 4ad2cf2a712..fcc0262b58f 100644 --- a/sys/kern/sysv_sem.c +++ b/sys/kern/sysv_sem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sysv_sem.c,v 1.61 2021/04/30 13:52:48 bluhm Exp $ */ +/* $OpenBSD: sysv_sem.c,v 1.62 2022/09/16 15:57:23 mbuhl Exp $ */ /* $NetBSD: sysv_sem.c,v 1.26 1996/02/09 19:00:25 christos Exp $ */ /* @@ -229,8 +229,15 @@ sys___semctl(struct proc *p, void *v, register_t *retval) syscallarg(int) cmd; syscallarg(union semun *) arg; } */ *uap = v; - union semun arg; - int error = 0, cmd = SCARG(uap, cmd); + struct ucred *cred = p->p_ucred; + int semid = SCARG(uap, semid); + int semnum = SCARG(uap, semnum); + int cmd = SCARG(uap, cmd); + union semun arg, *uarg = SCARG(uap, arg); + struct semid_ds sbuf; + struct semid_ds *semaptr; + unsigned short *semval = NULL; + int i, ix, error; switch (cmd) { case IPC_SET: @@ -238,28 +245,11 @@ sys___semctl(struct proc *p, void *v, register_t *retval) case GETALL: case SETVAL: case SETALL: - error = copyin(SCARG(uap, arg), &arg, sizeof(arg)); - break; - } - if (error == 0) { - error = semctl1(p, SCARG(uap, semid), SCARG(uap, semnum), - cmd, &arg, retval, copyin, copyout); + if ((error = copyin(uarg, &arg, sizeof(union semun)))) + return (error); } - return (error); -} - -int -semctl1(struct proc *p, int semid, int semnum, int cmd, union semun *arg, - register_t *retval, int (*ds_copyin)(const void *, void *, size_t), - int (*ds_copyout)(const void *, void *, size_t)) -{ - struct ucred *cred = p->p_ucred; - int i, ix, error = 0; - struct semid_ds sbuf; - struct semid_ds *semaptr; - unsigned short *semval = NULL; - DPRINTF(("call to semctl(%d, %d, %d, %p)\n", semid, semnum, cmd, arg)); + DPRINTF(("call to semctl(%d, %d, %d, %p)\n", semid, semnum, cmd, uarg)); ix = IPCID_TO_IX(semid); if (ix < 0 || ix >= seminfo.semmni) @@ -287,7 +277,7 @@ semctl1(struct proc *p, int semid, int semnum, int cmd, union semun *arg, case IPC_SET: if ((error = ipcperm(cred, &semaptr->sem_perm, IPC_M))) return (error); - if ((error = ds_copyin(arg->buf, &sbuf, sizeof(sbuf))) != 0) + if ((error = copyin(arg.buf, &sbuf, sizeof(sbuf))) != 0) return (error); semaptr->sem_perm.uid = sbuf.sem_perm.uid; semaptr->sem_perm.gid = sbuf.sem_perm.gid; @@ -301,7 +291,7 @@ semctl1(struct proc *p, int semid, int semnum, int cmd, union semun *arg, return (error); memcpy(&sbuf, semaptr, sizeof sbuf); sbuf.sem_base = NULL; - error = ds_copyout(&sbuf, arg->buf, sizeof(struct semid_ds)); + error = copyout(&sbuf, arg.buf, sizeof(struct semid_ds)); break; case GETNCNT: @@ -332,8 +322,8 @@ semctl1(struct proc *p, int semid, int semnum, int cmd, union semun *arg, if ((error = ipcperm(cred, &semaptr->sem_perm, IPC_R))) return (error); for (i = 0; i < semaptr->sem_nsems; i++) { - error = ds_copyout(&semaptr->sem_base[i].semval, - &arg->array[i], sizeof(arg->array[0])); + error = copyout(&semaptr->sem_base[i].semval, + &arg.array[i], sizeof(arg.array[0])); if (error != 0) break; } @@ -352,9 +342,9 @@ semctl1(struct proc *p, int semid, int semnum, int cmd, union semun *arg, return (error); if (semnum < 0 || semnum >= semaptr->sem_nsems) return (EINVAL); - if (arg->val > seminfo.semvmx) + if (arg.val > seminfo.semvmx) return (ERANGE); - semaptr->sem_base[semnum].semval = arg->val; + semaptr->sem_base[semnum].semval = arg.val; semundo_clear(ix, semnum); wakeup(&sema[ix]); break; @@ -362,11 +352,11 @@ semctl1(struct proc *p, int semid, int semnum, int cmd, union semun *arg, case SETALL: if ((error = ipcperm(cred, &semaptr->sem_perm, IPC_W))) return (error); - semval = mallocarray(semaptr->sem_nsems, sizeof(arg->array[0]), + semval = mallocarray(semaptr->sem_nsems, sizeof(arg.array[0]), M_TEMP, M_WAITOK); for (i = 0; i < semaptr->sem_nsems; i++) { - error = ds_copyin(&arg->array[i], &semval[i], - sizeof(arg->array[0])); + error = copyin(&arg.array[i], &semval[i], + sizeof(arg.array[0])); if (error != 0) goto error; if (semval[i] > seminfo.semvmx) { @@ -387,7 +377,7 @@ semctl1(struct proc *p, int semid, int semnum, int cmd, union semun *arg, error: if (semval) free(semval, M_TEMP, - semaptr->sem_nsems * sizeof(arg->array[0])); + semaptr->sem_nsems * sizeof(arg.array[0])); return (error); } diff --git a/sys/sys/msg.h b/sys/sys/msg.h index 96a4a0cb689..d7ebe4684b5 100644 --- a/sys/sys/msg.h +++ b/sys/sys/msg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: msg.h,v 1.19 2014/11/23 04:31:42 guenther Exp $ */ +/* $OpenBSD: msg.h,v 1.20 2022/09/16 15:57:23 mbuhl Exp $ */ /* $NetBSD: msg.h,v 1.9 1996/02/09 18:25:18 christos Exp $ */ /* @@ -169,9 +169,6 @@ __END_DECLS struct proc; void msginit(void); -int msgctl1(struct proc *, int, int, caddr_t, - int (*)(const void *, void *, size_t), - int (*)(const void *, void *, size_t)); #endif /* !_KERNEL */ #endif /* !_SYS_MSG_H_ */ diff --git a/sys/sys/sem.h b/sys/sys/sem.h index 184482d7810..9d09a95be77 100644 --- a/sys/sys/sem.h +++ b/sys/sys/sem.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sem.h,v 1.24 2016/09/01 08:33:40 tom Exp $ */ +/* $OpenBSD: sem.h,v 1.25 2022/09/16 15:57:23 mbuhl Exp $ */ /* $NetBSD: sem.h,v 1.8 1996/02/09 18:25:29 christos Exp $ */ /* @@ -180,10 +180,6 @@ struct proc; void seminit(void); void semexit(struct process *); int sysctl_sysvsem(int *, u_int, void *, size_t *, void *, size_t); -int semctl1(struct proc *, int, int, int, union semun *, register_t *, - int (*)(const void *, void *, size_t), - int (*)(const void *, void *, size_t)); - #endif /* _KERNEL */ #ifndef _KERNEL