diff options
author | jhb <jhb@FreeBSD.org> | 2004-08-24 20:21:21 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2004-08-24 20:21:21 +0000 |
commit | cc23ea84d0ad17e7d69a1539947fdc50a38c6af0 (patch) | |
tree | 2adb2b3e0072e186b55581dbf999abee2995639a /sys/alpha | |
parent | 1ec5d22c32622b609088a0218cc5e25ef0352c34 (diff) | |
download | FreeBSD-src-cc23ea84d0ad17e7d69a1539947fdc50a38c6af0.zip FreeBSD-src-cc23ea84d0ad17e7d69a1539947fdc50a38c6af0.tar.gz |
Fix the ABI wrappers to use kern_fcntl() rather than calling fcntl()
directly. This removes a few more users of the stackgap and also marks
the syscalls using these wrappers MP safe where appropriate.
Tested on: i386 with linux acroread5
Compiled on: i386, alpha LINT
Diffstat (limited to 'sys/alpha')
-rw-r--r-- | sys/alpha/linux/syscalls.master | 2 | ||||
-rw-r--r-- | sys/alpha/osf1/osf1_misc.c | 33 | ||||
-rw-r--r-- | sys/alpha/osf1/syscalls.master | 2 |
3 files changed, 15 insertions, 22 deletions
diff --git a/sys/alpha/linux/syscalls.master b/sys/alpha/linux/syscalls.master index 27df413..250ede3 100644 --- a/sys/alpha/linux/syscalls.master +++ b/sys/alpha/linux/syscalls.master @@ -133,7 +133,7 @@ 89 STD { int linux_getdtablesize(void); } 90 MNOPROTO { int dup2(u_int from, u_int to); } 91 STD { int linux_newfstat(l_uint fd, struct l_newstat *buf); } -92 STD { int linux_fcntl(l_uint fd, l_uint cmd, l_ulong arg); } +92 MSTD { int linux_fcntl(l_uint fd, l_uint cmd, l_ulong arg); } 93 STD { int osf1_select(u_int nd, fd_set *in, fd_set *ou, \ fd_set *ex, struct timeval *tv); } 94 NOPROTO { int poll(struct pollfd*, unsigned int nfds, long timeout); } diff --git a/sys/alpha/osf1/osf1_misc.c b/sys/alpha/osf1/osf1_misc.c index 2fbea57..9cebf52 100644 --- a/sys/alpha/osf1/osf1_misc.c +++ b/sys/alpha/osf1/osf1_misc.c @@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$"); #include <sys/socket.h> #include <sys/socketvar.h> #include <sys/stat.h> +#include <sys/syscallsubr.h> #include <sys/sysctl.h> #include <sys/sysent.h> #include <sys/sysproto.h> @@ -758,19 +759,14 @@ osf1_fcntl(td, uap) { int error; long tmp; - caddr_t oarg, sg; - struct fcntl_args a; struct osf1_flock osf_flock; struct flock bsd_flock; - struct flock *nflock; error = 0; switch (uap->cmd) { case F_SETFL: - a.fd = uap->fd; - a.cmd = F_SETFL; /* need to translate flags here */ tmp = 0; if ((long)uap->arg & OSF1_FNONBLOCK) @@ -791,8 +787,7 @@ osf1_fcntl(td, uap) tmp |= FNDELAY; if ((long)uap->arg & OSF1_FSYNC) tmp |= FFSYNC; - a.arg = tmp; - error = fcntl(td, &a); + error = kern_fcntl(td, uap->fd, F_SETFL, tmp); break; case F_SETLK: @@ -803,20 +798,15 @@ osf1_fcntl(td, uap) * the BSD one, but all else is the same. We must * reorder the one we've gotten so that flock() groks it. */ - if ((error = copyin(uap->arg, &osf_flock, sizeof(osf_flock)))) - return error; + error = copyin(uap->arg, &osf_flock, sizeof(osf_flock)); + if (error) + return (error); bsd_flock.l_type = osf_flock.l_type; bsd_flock.l_whence = osf_flock.l_whence; bsd_flock.l_start = osf_flock.l_start; bsd_flock.l_len = osf_flock.l_len; bsd_flock.l_pid = osf_flock.l_pid; - sg = stackgap_init(); - nflock = stackgap_alloc(&sg, sizeof(struct flock)); - if ((error = copyout(&bsd_flock, nflock, sizeof(bsd_flock))) != 0) - return error; - oarg = uap->arg; - uap->arg = nflock; - error = fcntl(td, (struct fcntl_args *) uap); + error = kern_fcntl(td, uap->fd, uap->cmd, (intptr_t)&bsd_flock); /* if (error) { printf("fcntl called with cmd=%d, args=0x%lx\n returns %d\n",uap->cmd,(long)uap->arg,error); printf("bsd_flock.l_type = 0x%x\n", bsd_flock.l_type); @@ -827,14 +817,17 @@ osf1_fcntl(td, uap) } */ if ((uap->cmd == F_GETLK) && !error) { + /* + * XXX: Why are we hardcoding F_UNLCK here instead of + * copying the structure members from bsd_flock? + */ osf_flock.l_type = F_UNLCK; - if ((error = copyout(&osf_flock, oarg, - sizeof(osf_flock)))) - return error; + error = copyout(&osf_flock, uap->arg, + sizeof(osf_flock)); } break; default: - error = fcntl(td, (struct fcntl_args *) uap); + error = kern_fcntl(td, uap->fd, uap->cmd, (intptr_t)uap->arg); if ((uap->cmd == OSF1_F_GETFL) && !error ) { tmp = td->td_retval[0] & O_ACCMODE; diff --git a/sys/alpha/osf1/syscalls.master b/sys/alpha/osf1/syscalls.master index f9e38e2..2c15f25 100644 --- a/sys/alpha/osf1/syscalls.master +++ b/sys/alpha/osf1/syscalls.master @@ -135,7 +135,7 @@ 89 MNOPROTO { int getdtablesize(void); } 90 MNOPROTO { int dup2(u_int from, u_int to); } 91 STD { int osf1_fstat(int fd, void *sb); } -92 STD { int osf1_fcntl(int fd, int cmd, void *arg); } +92 MSTD { int osf1_fcntl(int fd, int cmd, void *arg); } 93 STD { int osf1_select(u_int nd, fd_set *in, fd_set *ou, \ fd_set *ex, struct timeval *tv); } 94 NOPROTO { int poll(struct pollfd *fds, u_int nfds, int timeout); } |