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/kern_descrip.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/kern_descrip.c')
-rw-r--r-- | sys/kern/kern_descrip.c | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 987ccda..81fead1 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -1030,20 +1030,15 @@ struct ofstat_args { int ofstat(struct thread *td, struct ofstat_args *uap) { - struct file *fp; - struct stat ub; struct ostat oub; + struct stat ub; int error; - if ((error = fget(td, uap->fd, &fp)) != 0) - goto done2; - error = fo_stat(fp, &ub, td->td_ucred, td); + error = kern_fstat(td, uap->fd, &ub); if (error == 0) { cvtstat(&ub, &oub); error = copyout(&oub, uap->sb, sizeof(oub)); } - fdrop(fp, td); -done2: return (error); } #endif /* COMPAT_43 */ @@ -1064,17 +1059,25 @@ struct fstat_args { int fstat(struct thread *td, struct fstat_args *uap) { - struct file *fp; struct stat ub; int error; - if ((error = fget(td, uap->fd, &fp)) != 0) - goto done2; - error = fo_stat(fp, &ub, td->td_ucred, td); + error = kern_fstat(td, uap->fd, &ub); if (error == 0) error = copyout(&ub, uap->sb, sizeof(ub)); + return (error); +} + +int +kern_fstat(struct thread *td, int fd, struct stat *sbp) +{ + struct file *fp; + int error; + + if ((error = fget(td, fd, &fp)) != 0) + return (error); + error = fo_stat(fp, sbp, td->td_ucred, td); fdrop(fp, td); -done2: return (error); } @@ -1094,20 +1097,15 @@ struct nfstat_args { int nfstat(struct thread *td, struct nfstat_args *uap) { - struct file *fp; - struct stat ub; struct nstat nub; + struct stat ub; int error; - if ((error = fget(td, uap->fd, &fp)) != 0) - goto done2; - error = fo_stat(fp, &ub, td->td_ucred, td); + error = kern_fstat(td, uap->fd, &ub); if (error == 0) { cvtnstat(&ub, &nub); error = copyout(&nub, uap->sb, sizeof(nub)); } - fdrop(fp, td); -done2: return (error); } |