diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2001-05-16 17:14:40 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2001-05-16 17:14:40 +0000 |
commit | d081888ede32893d5dfa6a13f09405aa730c9092 (patch) | |
tree | df2c5452e4612103cc5e3b507980de79f926318b /sys/kern/sysv_msg.c | |
parent | a298e9ff9d4b9418b1b5b64c70a04ed9774e676d (diff) |
Create COMPAT_25 and move ogetfsstat, ostatfs and ostatfs into it.
Create COMPAT_23 and move __osemctl, omsgctl, oshmctl there.
Diffstat (limited to 'sys/kern/sysv_msg.c')
-rw-r--r-- | sys/kern/sysv_msg.c | 142 |
1 files changed, 3 insertions, 139 deletions
diff --git a/sys/kern/sysv_msg.c b/sys/kern/sysv_msg.c index 2a7f2097828..66d34143026 100644 --- a/sys/kern/sysv_msg.c +++ b/sys/kern/sysv_msg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sysv_msg.c,v 1.8 1999/08/09 21:44:24 deraadt Exp $ */ +/* $OpenBSD: sysv_msg.c,v 1.9 2001/05/16 17:14:35 millert Exp $ */ /* $NetBSD: sysv_msg.c,v 1.19 1996/02/09 19:00:18 christos Exp $ */ /* @@ -37,7 +37,7 @@ int nfree_msgmaps; /* # of free map entries */ short free_msgmaps; /* head of linked list of free map entries */ struct msg *free_msghdrs; /* list of free msg headers */ -static void msg_freehdr __P((struct msg *)); +void msg_freehdr __P((struct msg *)); void msginit() @@ -90,7 +90,7 @@ msginit() } } -static void +void msg_freehdr(msghdr) struct msg *msghdr; { @@ -142,142 +142,6 @@ msqid_n2o(n, o) } int -sys_omsgctl(p, v, retval) - struct proc *p; - void *v; - register_t *retval; -{ - register struct sys_msgctl_args /* { - syscallarg(int) msqid; - syscallarg(int) cmd; - syscallarg(struct msqid_ds *) buf; - } */ *uap = v; - int msqid = SCARG(uap, msqid); - int cmd = SCARG(uap, cmd); - struct msqid_ds *user_msqptr = SCARG(uap, buf); - struct ucred *cred = p->p_ucred; - int rval, eval; - struct omsqid_ds omsqbuf; - register struct msqid_ds *msqptr; - -#ifdef MSG_DEBUG_OK - printf("call to msgctl(%d, %d, %p)\n", msqid, cmd, user_msqptr); -#endif - - msqid = IPCID_TO_IX(msqid); - - if (msqid < 0 || msqid >= msginfo.msgmni) { -#ifdef MSG_DEBUG_OK - printf("msqid (%d) out of range (0<=msqid<%d)\n", msqid, - msginfo.msgmni); -#endif - return(EINVAL); - } - - msqptr = &msqids[msqid]; - - if (msqptr->msg_qbytes == 0) { -#ifdef MSG_DEBUG_OK - printf("no such msqid\n"); -#endif - return(EINVAL); - } - if (msqptr->msg_perm.seq != IPCID_TO_SEQ(SCARG(uap, msqid))) { -#ifdef MSG_DEBUG_OK - printf("wrong sequence number\n"); -#endif - return(EINVAL); - } - - eval = 0; - rval = 0; - - switch (cmd) { - - case IPC_RMID: - { - struct msg *msghdr; - if ((eval = ipcperm(cred, &msqptr->msg_perm, IPC_M)) != 0) - return(eval); - /* Free the message headers */ - msghdr = msqptr->msg_first; - while (msghdr != NULL) { - struct msg *msghdr_tmp; - - /* Free the segments of each message */ - msqptr->msg_cbytes -= msghdr->msg_ts; - msqptr->msg_qnum--; - msghdr_tmp = msghdr; - msghdr = msghdr->msg_next; - msg_freehdr(msghdr_tmp); - } - -#ifdef DIAGNOSTIC - if (msqptr->msg_cbytes != 0) - panic("sys_omsgctl: msg_cbytes is screwed up"); - if (msqptr->msg_qnum != 0) - panic("sys_omsgctl: msg_qnum is screwed up"); -#endif - - msqptr->msg_qbytes = 0; /* Mark it as free */ - - wakeup((caddr_t)msqptr); - } - - break; - - case IPC_SET: - if ((eval = ipcperm(cred, &msqptr->msg_perm, IPC_M))) - return(eval); - if ((eval = copyin(user_msqptr, &omsqbuf, sizeof(omsqbuf))) != 0) - return(eval); - if (omsqbuf.msg_qbytes > msqptr->msg_qbytes && cred->cr_uid != 0) - return(EPERM); - if (omsqbuf.msg_qbytes > msginfo.msgmnb) { -#ifdef MSG_DEBUG_OK - printf("can't increase msg_qbytes beyond %d (truncating)\n", - msginfo.msgmnb); -#endif - omsqbuf.msg_qbytes = msginfo.msgmnb; /* silently restrict qbytes to system limit */ - } - if (omsqbuf.msg_qbytes == 0) { -#ifdef MSG_DEBUG_OK - printf("can't reduce msg_qbytes to 0\n"); -#endif - return(EINVAL); /* non-standard errno! */ - } - msqptr->msg_perm.uid = omsqbuf.msg_perm.uid; /* change the owner */ - msqptr->msg_perm.gid = omsqbuf.msg_perm.gid; /* change the owner */ - msqptr->msg_perm.mode = (msqptr->msg_perm.mode & ~0777) | - (omsqbuf.msg_perm.mode & 0777); - msqptr->msg_qbytes = omsqbuf.msg_qbytes; - msqptr->msg_ctime = time.tv_sec; - break; - - case IPC_STAT: - if ((eval = ipcperm(cred, &msqptr->msg_perm, IPC_R))) { -#ifdef MSG_DEBUG_OK - printf("requester doesn't have read access\n"); -#endif - return(eval); - } - msqid_n2o(msqptr, &omsqbuf); - eval = copyout((caddr_t)&omsqbuf, user_msqptr, sizeof omsqbuf); - break; - - default: -#ifdef MSG_DEBUG_OK - printf("invalid command %d\n", cmd); -#endif - return(EINVAL); - } - - if (eval == 0) - *retval = rval; - return(eval); -} - -int sys_msgctl(p, v, retval) struct proc *p; void *v; |