diff options
author | jhb <jhb@FreeBSD.org> | 2005-02-07 18:44:55 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2005-02-07 18:44:55 +0000 |
commit | 71c05d27c0fe7676964592e1791abed816be1a00 (patch) | |
tree | ff7cc7cc16c891dadf164e579f6845927917f2ef /sys/kern/sysv_msg.c | |
parent | 2cfc33f9b1a577677860ff7412307ff6ae91fa38 (diff) | |
download | FreeBSD-src-71c05d27c0fe7676964592e1791abed816be1a00.zip FreeBSD-src-71c05d27c0fe7676964592e1791abed816be1a00.tar.gz |
- Tweak kern_msgctl() to return a copy of the requested message queue id
structure in the struct pointed to by the 3rd argument for IPC_STAT and
get rid of the 4th argument. The old way returned a pointer into the
kernel array that the calling function would then access afterwards
without holding the appropriate locks and doing non-lock-safe things like
copyout() with the data anyways. This change removes that unsafeness and
resulting race conditions as well as simplifying the interface.
- Implement kern_foo wrappers for stat(), lstat(), fstat(), statfs(),
fstatfs(), and fhstatfs(). Use these wrappers to cut out a lot of
code duplication for freebsd4 and netbsd compatability system calls.
- Add a new lookup function kern_alternate_path() that looks up a filename
under an alternate prefix and determines which filename should be used.
This is basically a more general version of linux_emul_convpath() that
can be shared by all the ABIs thus allowing for further reduction of
code duplication.
Diffstat (limited to 'sys/kern/sysv_msg.c')
-rw-r--r-- | sys/kern/sysv_msg.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/sys/kern/sysv_msg.c b/sys/kern/sysv_msg.c index efd630e..f1a7122 100644 --- a/sys/kern/sysv_msg.c +++ b/sys/kern/sysv_msg.c @@ -397,26 +397,24 @@ msgctl(td, uap) int msqid = uap->msqid; int cmd = uap->cmd; struct msqid_ds msqbuf; - struct msqid_ds *msqptr; int error; DPRINTF(("call to msgctl(%d, %d, 0x%x)\n", msqid, cmd, uap->buf)); if (cmd == IPC_SET && (error = copyin(uap->buf, &msqbuf, sizeof(msqbuf))) != 0) return (error); - error = kern_msgctl(td, msqid, cmd, &msqbuf, &msqptr); + error = kern_msgctl(td, msqid, cmd, &msqbuf); if (cmd == IPC_STAT && error == 0) - error = copyout(msqptr, uap->buf, sizeof(struct msqid_ds)); + error = copyout(&msqbuf, uap->buf, sizeof(struct msqid_ds)); return (error); } int -kern_msgctl(td, msqid, cmd, msqbuf, msqptr) +kern_msgctl(td, msqid, cmd, msqbuf) struct thread *td; int msqid; int cmd; struct msqid_ds *msqbuf; - struct msqid_ds **msqptr; { int rval, error, msqix; register struct msqid_kernel *msqkptr; @@ -545,7 +543,7 @@ kern_msgctl(td, msqid, cmd, msqbuf, msqptr) DPRINTF(("requester doesn't have read access\n")); goto done2; } - *msqptr = &(msqkptr->u); + *msqbuf = msqkptr->u; break; default: @@ -558,7 +556,7 @@ kern_msgctl(td, msqid, cmd, msqbuf, msqptr) td->td_retval[0] = rval; done2: mtx_unlock(&msq_mtx); - return(error); + return (error); } #ifndef _SYS_SYSPROTO_H_ |