2005-01-05 22:34:37 +00:00
|
|
|
/*-
|
1999-01-30 06:29:48 +00:00
|
|
|
* Copyright (c) 1998 Mark Newton
|
|
|
|
* Copyright (c) 1994, 1997 Christos Zoulas.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by Christos Zoulas.
|
|
|
|
* 4. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
2002-08-12 01:42:21 +00:00
|
|
|
|
2003-06-10 21:44:29 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
1999-01-30 06:29:48 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/file.h>
|
|
|
|
#include <sys/filedesc.h>
|
|
|
|
/*#include <sys/ioctl.h>*/
|
2001-05-01 08:13:21 +00:00
|
|
|
#include <sys/lock.h>
|
- Implement svr4_emul_find() using kern_alternate_path(). This changes
the semantics in that the returned filename to use is now a kernel
pointer rather than a user space pointer. This required changing the
arguments to the CHECKALT*() macros some and changing the various system
calls that used pathnames to use the kern_foo() functions that can accept
kernel space filename pointers instead of calling the system call
directly.
- Use kern_open(), kern_access(), kern_msgctl(), kern_execve(),
kern_mkfifo(), kern_mknod(), kern_statfs(), kern_fstatfs(),
kern_setitimer(), kern_stat(), kern_lstat(), kern_fstat(), kern_utimes(),
kern_pathconf(), and kern_unlink().
2005-02-07 21:53:42 +00:00
|
|
|
#include <sys/malloc.h>
|
1999-01-30 06:29:48 +00:00
|
|
|
#include <sys/mount.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
#include <sys/mutex.h>
|
|
|
|
#include <sys/namei.h>
|
2006-11-06 13:42:10 +00:00
|
|
|
#include <sys/priv.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/stat.h>
|
2004-08-24 20:21:21 +00:00
|
|
|
#include <sys/syscallsubr.h>
|
1999-01-30 06:29:48 +00:00
|
|
|
#include <sys/unistd.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
#include <sys/vnode.h>
|
1999-01-30 06:29:48 +00:00
|
|
|
|
|
|
|
#include <sys/sysproto.h>
|
|
|
|
|
2000-08-31 22:54:09 +00:00
|
|
|
#include <compat/svr4/svr4.h>
|
|
|
|
#include <compat/svr4/svr4_types.h>
|
|
|
|
#include <compat/svr4/svr4_signal.h>
|
|
|
|
#include <compat/svr4/svr4_proto.h>
|
|
|
|
#include <compat/svr4/svr4_util.h>
|
|
|
|
#include <compat/svr4/svr4_fcntl.h>
|
1999-01-30 06:29:48 +00:00
|
|
|
|
2006-10-22 11:52:19 +00:00
|
|
|
#include <security/mac/mac_framework.h>
|
|
|
|
|
2002-03-20 05:48:58 +00:00
|
|
|
static int svr4_to_bsd_flags(int);
|
|
|
|
static u_long svr4_to_bsd_cmd(u_long);
|
|
|
|
static int fd_revoke(struct thread *, int);
|
|
|
|
static int fd_truncate(struct thread *, int, struct flock *);
|
|
|
|
static int bsd_to_svr4_flags(int);
|
|
|
|
static void bsd_to_svr4_flock(struct flock *, struct svr4_flock *);
|
|
|
|
static void svr4_to_bsd_flock(struct svr4_flock *, struct flock *);
|
|
|
|
static void bsd_to_svr4_flock64(struct flock *, struct svr4_flock64 *);
|
|
|
|
static void svr4_to_bsd_flock64(struct svr4_flock64 *, struct flock *);
|
1999-01-30 06:29:48 +00:00
|
|
|
|
|
|
|
static u_long
|
|
|
|
svr4_to_bsd_cmd(cmd)
|
|
|
|
u_long cmd;
|
|
|
|
{
|
|
|
|
switch (cmd) {
|
|
|
|
case SVR4_F_DUPFD:
|
|
|
|
return F_DUPFD;
|
2008-03-17 18:27:28 +00:00
|
|
|
case SVR4_F_DUP2FD:
|
|
|
|
return F_DUP2FD;
|
1999-01-30 06:29:48 +00:00
|
|
|
case SVR4_F_GETFD:
|
|
|
|
return F_GETFD;
|
|
|
|
case SVR4_F_SETFD:
|
|
|
|
return F_SETFD;
|
|
|
|
case SVR4_F_GETFL:
|
|
|
|
return F_GETFL;
|
|
|
|
case SVR4_F_SETFL:
|
|
|
|
return F_SETFL;
|
|
|
|
case SVR4_F_GETLK:
|
|
|
|
return F_GETLK;
|
|
|
|
case SVR4_F_SETLK:
|
|
|
|
return F_SETLK;
|
|
|
|
case SVR4_F_SETLKW:
|
|
|
|
return F_SETLKW;
|
|
|
|
default:
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
svr4_to_bsd_flags(l)
|
|
|
|
int l;
|
|
|
|
{
|
|
|
|
int r = 0;
|
|
|
|
r |= (l & SVR4_O_RDONLY) ? O_RDONLY : 0;
|
|
|
|
r |= (l & SVR4_O_WRONLY) ? O_WRONLY : 0;
|
|
|
|
r |= (l & SVR4_O_RDWR) ? O_RDWR : 0;
|
|
|
|
r |= (l & SVR4_O_NDELAY) ? O_NONBLOCK : 0;
|
|
|
|
r |= (l & SVR4_O_APPEND) ? O_APPEND : 0;
|
|
|
|
r |= (l & SVR4_O_SYNC) ? O_FSYNC : 0;
|
|
|
|
r |= (l & SVR4_O_NONBLOCK) ? O_NONBLOCK : 0;
|
|
|
|
r |= (l & SVR4_O_PRIV) ? O_EXLOCK : 0;
|
|
|
|
r |= (l & SVR4_O_CREAT) ? O_CREAT : 0;
|
|
|
|
r |= (l & SVR4_O_TRUNC) ? O_TRUNC : 0;
|
|
|
|
r |= (l & SVR4_O_EXCL) ? O_EXCL : 0;
|
|
|
|
r |= (l & SVR4_O_NOCTTY) ? O_NOCTTY : 0;
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
bsd_to_svr4_flags(l)
|
|
|
|
int l;
|
|
|
|
{
|
|
|
|
int r = 0;
|
|
|
|
r |= (l & O_RDONLY) ? SVR4_O_RDONLY : 0;
|
|
|
|
r |= (l & O_WRONLY) ? SVR4_O_WRONLY : 0;
|
|
|
|
r |= (l & O_RDWR) ? SVR4_O_RDWR : 0;
|
|
|
|
r |= (l & O_NDELAY) ? SVR4_O_NONBLOCK : 0;
|
|
|
|
r |= (l & O_APPEND) ? SVR4_O_APPEND : 0;
|
|
|
|
r |= (l & O_FSYNC) ? SVR4_O_SYNC : 0;
|
|
|
|
r |= (l & O_NONBLOCK) ? SVR4_O_NONBLOCK : 0;
|
|
|
|
r |= (l & O_EXLOCK) ? SVR4_O_PRIV : 0;
|
|
|
|
r |= (l & O_CREAT) ? SVR4_O_CREAT : 0;
|
|
|
|
r |= (l & O_TRUNC) ? SVR4_O_TRUNC : 0;
|
|
|
|
r |= (l & O_EXCL) ? SVR4_O_EXCL : 0;
|
|
|
|
r |= (l & O_NOCTTY) ? SVR4_O_NOCTTY : 0;
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
bsd_to_svr4_flock(iflp, oflp)
|
|
|
|
struct flock *iflp;
|
|
|
|
struct svr4_flock *oflp;
|
|
|
|
{
|
|
|
|
switch (iflp->l_type) {
|
|
|
|
case F_RDLCK:
|
|
|
|
oflp->l_type = SVR4_F_RDLCK;
|
|
|
|
break;
|
|
|
|
case F_WRLCK:
|
|
|
|
oflp->l_type = SVR4_F_WRLCK;
|
|
|
|
break;
|
|
|
|
case F_UNLCK:
|
|
|
|
oflp->l_type = SVR4_F_UNLCK;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
oflp->l_type = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
oflp->l_whence = (short) iflp->l_whence;
|
|
|
|
oflp->l_start = (svr4_off_t) iflp->l_start;
|
|
|
|
oflp->l_len = (svr4_off_t) iflp->l_len;
|
|
|
|
oflp->l_sysid = 0;
|
|
|
|
oflp->l_pid = (svr4_pid_t) iflp->l_pid;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
svr4_to_bsd_flock(iflp, oflp)
|
|
|
|
struct svr4_flock *iflp;
|
|
|
|
struct flock *oflp;
|
|
|
|
{
|
|
|
|
switch (iflp->l_type) {
|
|
|
|
case SVR4_F_RDLCK:
|
|
|
|
oflp->l_type = F_RDLCK;
|
|
|
|
break;
|
|
|
|
case SVR4_F_WRLCK:
|
|
|
|
oflp->l_type = F_WRLCK;
|
|
|
|
break;
|
|
|
|
case SVR4_F_UNLCK:
|
|
|
|
oflp->l_type = F_UNLCK;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
oflp->l_type = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
oflp->l_whence = iflp->l_whence;
|
|
|
|
oflp->l_start = (off_t) iflp->l_start;
|
|
|
|
oflp->l_len = (off_t) iflp->l_len;
|
|
|
|
oflp->l_pid = (pid_t) iflp->l_pid;
|
2008-03-26 15:23:12 +00:00
|
|
|
oflp->l_sysid = iflp->l_sysid;
|
1999-01-30 06:29:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
bsd_to_svr4_flock64(iflp, oflp)
|
|
|
|
struct flock *iflp;
|
|
|
|
struct svr4_flock64 *oflp;
|
|
|
|
{
|
|
|
|
switch (iflp->l_type) {
|
|
|
|
case F_RDLCK:
|
|
|
|
oflp->l_type = SVR4_F_RDLCK;
|
|
|
|
break;
|
|
|
|
case F_WRLCK:
|
|
|
|
oflp->l_type = SVR4_F_WRLCK;
|
|
|
|
break;
|
|
|
|
case F_UNLCK:
|
|
|
|
oflp->l_type = SVR4_F_UNLCK;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
oflp->l_type = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
oflp->l_whence = (short) iflp->l_whence;
|
|
|
|
oflp->l_start = (svr4_off64_t) iflp->l_start;
|
|
|
|
oflp->l_len = (svr4_off64_t) iflp->l_len;
|
2008-03-26 15:23:12 +00:00
|
|
|
oflp->l_sysid = iflp->l_sysid;
|
1999-01-30 06:29:48 +00:00
|
|
|
oflp->l_pid = (svr4_pid_t) iflp->l_pid;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
svr4_to_bsd_flock64(iflp, oflp)
|
|
|
|
struct svr4_flock64 *iflp;
|
|
|
|
struct flock *oflp;
|
|
|
|
{
|
|
|
|
switch (iflp->l_type) {
|
|
|
|
case SVR4_F_RDLCK:
|
|
|
|
oflp->l_type = F_RDLCK;
|
|
|
|
break;
|
|
|
|
case SVR4_F_WRLCK:
|
|
|
|
oflp->l_type = F_WRLCK;
|
|
|
|
break;
|
|
|
|
case SVR4_F_UNLCK:
|
|
|
|
oflp->l_type = F_UNLCK;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
oflp->l_type = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
oflp->l_whence = iflp->l_whence;
|
|
|
|
oflp->l_start = (off_t) iflp->l_start;
|
|
|
|
oflp->l_len = (off_t) iflp->l_len;
|
|
|
|
oflp->l_pid = (pid_t) iflp->l_pid;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2001-09-12 08:38:13 +00:00
|
|
|
fd_revoke(td, fd)
|
|
|
|
struct thread *td;
|
1999-01-30 06:29:48 +00:00
|
|
|
int fd;
|
|
|
|
{
|
|
|
|
struct vnode *vp;
|
2000-07-11 22:07:57 +00:00
|
|
|
struct mount *mp;
|
1999-01-30 06:29:48 +00:00
|
|
|
struct vattr vattr;
|
|
|
|
int error, *retval;
|
|
|
|
|
2001-09-12 08:38:13 +00:00
|
|
|
retval = td->td_retval;
|
2002-01-14 00:13:45 +00:00
|
|
|
if ((error = fgetvp(td, fd, &vp)) != 0)
|
|
|
|
return (error);
|
1999-01-30 06:29:48 +00:00
|
|
|
|
|
|
|
if (vp->v_type != VCHR && vp->v_type != VBLK) {
|
|
|
|
error = EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2002-08-12 01:42:21 +00:00
|
|
|
#ifdef MAC
|
2008-01-10 01:10:58 +00:00
|
|
|
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
|
2007-10-24 19:04:04 +00:00
|
|
|
error = mac_vnode_check_revoke(td->td_ucred, vp);
|
2008-01-13 14:44:15 +00:00
|
|
|
VOP_UNLOCK(vp, 0);
|
2002-08-12 01:42:21 +00:00
|
|
|
if (error)
|
|
|
|
goto out;
|
|
|
|
#endif
|
|
|
|
|
2008-08-28 15:23:18 +00:00
|
|
|
if ((error = VOP_GETATTR(vp, &vattr, td->td_ucred)) != 0)
|
1999-01-30 06:29:48 +00:00
|
|
|
goto out;
|
|
|
|
|
2002-02-27 18:32:23 +00:00
|
|
|
if (td->td_ucred->cr_uid != vattr.va_uid &&
|
2007-06-12 00:12:01 +00:00
|
|
|
(error = priv_check(td, PRIV_VFS_ADMIN)) != 0)
|
1999-01-30 06:29:48 +00:00
|
|
|
goto out;
|
|
|
|
|
2000-07-11 22:07:57 +00:00
|
|
|
if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0)
|
|
|
|
goto out;
|
1999-08-26 14:53:31 +00:00
|
|
|
if (vcount(vp) > 1)
|
1999-01-30 06:29:48 +00:00
|
|
|
VOP_REVOKE(vp, REVOKEALL);
|
2000-07-11 22:07:57 +00:00
|
|
|
vn_finished_write(mp);
|
1999-01-30 06:29:48 +00:00
|
|
|
out:
|
|
|
|
vrele(vp);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2001-09-12 08:38:13 +00:00
|
|
|
fd_truncate(td, fd, flp)
|
|
|
|
struct thread *td;
|
1999-01-30 06:29:48 +00:00
|
|
|
int fd;
|
|
|
|
struct flock *flp;
|
|
|
|
{
|
|
|
|
off_t start, length;
|
2002-01-19 03:45:14 +00:00
|
|
|
struct file *fp;
|
1999-01-30 06:29:48 +00:00
|
|
|
struct vnode *vp;
|
|
|
|
struct vattr vattr;
|
|
|
|
int error, *retval;
|
|
|
|
struct ftruncate_args ft;
|
|
|
|
|
2001-09-12 08:38:13 +00:00
|
|
|
retval = td->td_retval;
|
1999-01-30 06:29:48 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We only support truncating the file.
|
|
|
|
*/
|
2002-01-19 03:45:14 +00:00
|
|
|
if ((error = fget(td, fd, &fp)) != 0)
|
2002-01-14 00:13:45 +00:00
|
|
|
return (error);
|
1999-01-30 06:29:48 +00:00
|
|
|
|
2003-06-22 08:41:43 +00:00
|
|
|
vp = fp->f_vnode;
|
2002-01-19 03:45:14 +00:00
|
|
|
|
|
|
|
if (fp->f_type != DTYPE_VNODE || vp->v_type == VFIFO) {
|
|
|
|
fdrop(fp, td);
|
1999-01-30 06:29:48 +00:00
|
|
|
return ESPIPE;
|
2002-01-13 11:58:06 +00:00
|
|
|
}
|
1999-01-30 06:29:48 +00:00
|
|
|
|
2008-08-28 15:23:18 +00:00
|
|
|
if ((error = VOP_GETATTR(vp, &vattr, td->td_ucred)) != 0) {
|
2002-01-19 03:45:14 +00:00
|
|
|
fdrop(fp, td);
|
1999-01-30 06:29:48 +00:00
|
|
|
return error;
|
2002-01-13 11:58:06 +00:00
|
|
|
}
|
1999-01-30 06:29:48 +00:00
|
|
|
|
|
|
|
length = vattr.va_size;
|
|
|
|
|
|
|
|
switch (flp->l_whence) {
|
|
|
|
case SEEK_CUR:
|
|
|
|
start = fp->f_offset + flp->l_start;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SEEK_END:
|
|
|
|
start = flp->l_start + length;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SEEK_SET:
|
|
|
|
start = flp->l_start;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2002-01-19 03:45:14 +00:00
|
|
|
fdrop(fp, td);
|
1999-01-30 06:29:48 +00:00
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (start + flp->l_len < length) {
|
|
|
|
/* We don't support free'ing in the middle of the file */
|
2002-01-19 03:45:14 +00:00
|
|
|
fdrop(fp, td);
|
1999-01-30 06:29:48 +00:00
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
2002-12-14 01:56:26 +00:00
|
|
|
ft.fd = fd;
|
|
|
|
ft.length = start;
|
1999-01-30 06:29:48 +00:00
|
|
|
|
2002-01-13 11:58:06 +00:00
|
|
|
error = ftruncate(td, &ft);
|
|
|
|
|
2002-01-19 03:45:14 +00:00
|
|
|
fdrop(fp, td);
|
2002-01-13 11:58:06 +00:00
|
|
|
return (error);
|
1999-01-30 06:29:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
svr4_sys_open(td, uap)
|
2009-05-29 05:58:46 +00:00
|
|
|
struct thread *td;
|
1999-01-30 06:29:48 +00:00
|
|
|
struct svr4_sys_open_args *uap;
|
|
|
|
{
|
2001-09-12 08:38:13 +00:00
|
|
|
struct proc *p = td->td_proc;
|
- Implement svr4_emul_find() using kern_alternate_path(). This changes
the semantics in that the returned filename to use is now a kernel
pointer rather than a user space pointer. This required changing the
arguments to the CHECKALT*() macros some and changing the various system
calls that used pathnames to use the kern_foo() functions that can accept
kernel space filename pointers instead of calling the system call
directly.
- Use kern_open(), kern_access(), kern_msgctl(), kern_execve(),
kern_mkfifo(), kern_mknod(), kern_statfs(), kern_fstatfs(),
kern_setitimer(), kern_stat(), kern_lstat(), kern_fstat(), kern_utimes(),
kern_pathconf(), and kern_unlink().
2005-02-07 21:53:42 +00:00
|
|
|
char *newpath;
|
|
|
|
int bsd_flags, error, retval;
|
1999-01-30 06:29:48 +00:00
|
|
|
|
- Implement svr4_emul_find() using kern_alternate_path(). This changes
the semantics in that the returned filename to use is now a kernel
pointer rather than a user space pointer. This required changing the
arguments to the CHECKALT*() macros some and changing the various system
calls that used pathnames to use the kern_foo() functions that can accept
kernel space filename pointers instead of calling the system call
directly.
- Use kern_open(), kern_access(), kern_msgctl(), kern_execve(),
kern_mkfifo(), kern_mknod(), kern_statfs(), kern_fstatfs(),
kern_setitimer(), kern_stat(), kern_lstat(), kern_fstat(), kern_utimes(),
kern_pathconf(), and kern_unlink().
2005-02-07 21:53:42 +00:00
|
|
|
CHECKALTEXIST(td, uap->path, &newpath);
|
1999-01-30 06:29:48 +00:00
|
|
|
|
- Implement svr4_emul_find() using kern_alternate_path(). This changes
the semantics in that the returned filename to use is now a kernel
pointer rather than a user space pointer. This required changing the
arguments to the CHECKALT*() macros some and changing the various system
calls that used pathnames to use the kern_foo() functions that can accept
kernel space filename pointers instead of calling the system call
directly.
- Use kern_open(), kern_access(), kern_msgctl(), kern_execve(),
kern_mkfifo(), kern_mknod(), kern_statfs(), kern_fstatfs(),
kern_setitimer(), kern_stat(), kern_lstat(), kern_fstat(), kern_utimes(),
kern_pathconf(), and kern_unlink().
2005-02-07 21:53:42 +00:00
|
|
|
bsd_flags = svr4_to_bsd_flags(uap->flags);
|
|
|
|
error = kern_open(td, newpath, UIO_SYSSPACE, bsd_flags, uap->mode);
|
|
|
|
free(newpath, M_TEMP);
|
1999-01-30 06:29:48 +00:00
|
|
|
|
|
|
|
if (error) {
|
Back out alpha/alpha/trap.c:1.124, osf1_ioctl.c:1.14, osf1_misc.c:1.57,
osf1_signal.c:1.41, amd64/amd64/trap.c:1.291, linux_socket.c:1.60,
svr4_fcntl.c:1.36, svr4_ioctl.c:1.23, svr4_ipc.c:1.18, svr4_misc.c:1.81,
svr4_signal.c:1.34, svr4_stat.c:1.21, svr4_stream.c:1.55,
svr4_termios.c:1.13, svr4_ttold.c:1.15, svr4_util.h:1.10,
ext2_alloc.c:1.43, i386/i386/trap.c:1.279, vm86.c:1.58,
unaligned.c:1.12, imgact_elf.c:1.164, ffs_alloc.c:1.133:
Now that Giant is acquired in uprintf() and tprintf(), the caller no
longer leads to acquire Giant unless it also holds another mutex that
would generate a lock order reversal when calling into these functions.
Specifically not backed out is the acquisition of Giant in nfs_socket.c
and rpcclnt.c, where local mutexes are held and would otherwise violate
the lock order with Giant.
This aligns this code more with the eventual locking of ttys.
Suggested by: bde
2005-09-28 07:03:03 +00:00
|
|
|
/* uprintf("svr4_open(%s, 0x%0x, 0%o): %d\n", uap->path,
|
|
|
|
uap->flags, uap->mode, error);*/
|
1999-01-30 06:29:48 +00:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2001-09-12 08:38:13 +00:00
|
|
|
retval = td->td_retval[0];
|
1999-01-30 06:29:48 +00:00
|
|
|
|
2001-01-23 21:33:55 +00:00
|
|
|
PROC_LOCK(p);
|
- Implement svr4_emul_find() using kern_alternate_path(). This changes
the semantics in that the returned filename to use is now a kernel
pointer rather than a user space pointer. This required changing the
arguments to the CHECKALT*() macros some and changing the various system
calls that used pathnames to use the kern_foo() functions that can accept
kernel space filename pointers instead of calling the system call
directly.
- Use kern_open(), kern_access(), kern_msgctl(), kern_execve(),
kern_mkfifo(), kern_mknod(), kern_statfs(), kern_fstatfs(),
kern_setitimer(), kern_stat(), kern_lstat(), kern_fstat(), kern_utimes(),
kern_pathconf(), and kern_unlink().
2005-02-07 21:53:42 +00:00
|
|
|
if (!(bsd_flags & O_NOCTTY) && SESS_LEADER(p) &&
|
|
|
|
!(p->p_flag & P_CONTROLT)) {
|
1999-01-30 06:29:48 +00:00
|
|
|
#if defined(NOTYET)
|
2002-01-13 11:58:06 +00:00
|
|
|
struct file *fp;
|
1999-01-30 06:29:48 +00:00
|
|
|
|
2002-01-14 00:13:45 +00:00
|
|
|
error = fget(td, retval, &fp);
|
2001-01-23 21:33:55 +00:00
|
|
|
PROC_UNLOCK(p);
|
2002-01-13 11:58:06 +00:00
|
|
|
/*
|
|
|
|
* we may have lost a race the above open() and
|
|
|
|
* another thread issuing a close()
|
|
|
|
*/
|
2002-01-14 00:13:45 +00:00
|
|
|
if (error)
|
2002-01-13 11:58:06 +00:00
|
|
|
return (EBADF); /* XXX: correct errno? */
|
1999-01-30 06:29:48 +00:00
|
|
|
/* ignore any error, just give it a try */
|
|
|
|
if (fp->f_type == DTYPE_VNODE)
|
2002-08-17 02:36:16 +00:00
|
|
|
fo_ioctl(fp, TIOCSCTTY, (caddr_t) 0, td->td_ucred,
|
|
|
|
td);
|
2002-01-13 11:58:06 +00:00
|
|
|
fdrop(fp, td);
|
|
|
|
} else {
|
2001-01-23 21:33:55 +00:00
|
|
|
PROC_UNLOCK(p);
|
2002-01-13 11:58:06 +00:00
|
|
|
}
|
2001-01-23 21:33:55 +00:00
|
|
|
#else
|
1999-01-30 06:29:48 +00:00
|
|
|
}
|
2001-01-23 21:33:55 +00:00
|
|
|
PROC_UNLOCK(p);
|
|
|
|
#endif
|
1999-01-30 06:29:48 +00:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
svr4_sys_open64(td, uap)
|
2009-05-29 05:58:46 +00:00
|
|
|
struct thread *td;
|
1999-01-30 06:29:48 +00:00
|
|
|
struct svr4_sys_open64_args *uap;
|
|
|
|
{
|
2001-09-12 08:38:13 +00:00
|
|
|
return svr4_sys_open(td, (struct svr4_sys_open_args *)uap);
|
1999-01-30 06:29:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
svr4_sys_creat(td, uap)
|
2009-05-29 05:58:46 +00:00
|
|
|
struct thread *td;
|
1999-01-30 06:29:48 +00:00
|
|
|
struct svr4_sys_creat_args *uap;
|
|
|
|
{
|
- Implement svr4_emul_find() using kern_alternate_path(). This changes
the semantics in that the returned filename to use is now a kernel
pointer rather than a user space pointer. This required changing the
arguments to the CHECKALT*() macros some and changing the various system
calls that used pathnames to use the kern_foo() functions that can accept
kernel space filename pointers instead of calling the system call
directly.
- Use kern_open(), kern_access(), kern_msgctl(), kern_execve(),
kern_mkfifo(), kern_mknod(), kern_statfs(), kern_fstatfs(),
kern_setitimer(), kern_stat(), kern_lstat(), kern_fstat(), kern_utimes(),
kern_pathconf(), and kern_unlink().
2005-02-07 21:53:42 +00:00
|
|
|
char *newpath;
|
|
|
|
int error;
|
1999-01-30 06:29:48 +00:00
|
|
|
|
- Implement svr4_emul_find() using kern_alternate_path(). This changes
the semantics in that the returned filename to use is now a kernel
pointer rather than a user space pointer. This required changing the
arguments to the CHECKALT*() macros some and changing the various system
calls that used pathnames to use the kern_foo() functions that can accept
kernel space filename pointers instead of calling the system call
directly.
- Use kern_open(), kern_access(), kern_msgctl(), kern_execve(),
kern_mkfifo(), kern_mknod(), kern_statfs(), kern_fstatfs(),
kern_setitimer(), kern_stat(), kern_lstat(), kern_fstat(), kern_utimes(),
kern_pathconf(), and kern_unlink().
2005-02-07 21:53:42 +00:00
|
|
|
CHECKALTEXIST(td, uap->path, &newpath);
|
1999-01-30 06:29:48 +00:00
|
|
|
|
- Implement svr4_emul_find() using kern_alternate_path(). This changes
the semantics in that the returned filename to use is now a kernel
pointer rather than a user space pointer. This required changing the
arguments to the CHECKALT*() macros some and changing the various system
calls that used pathnames to use the kern_foo() functions that can accept
kernel space filename pointers instead of calling the system call
directly.
- Use kern_open(), kern_access(), kern_msgctl(), kern_execve(),
kern_mkfifo(), kern_mknod(), kern_statfs(), kern_fstatfs(),
kern_setitimer(), kern_stat(), kern_lstat(), kern_fstat(), kern_utimes(),
kern_pathconf(), and kern_unlink().
2005-02-07 21:53:42 +00:00
|
|
|
error = kern_open(td, newpath, UIO_SYSSPACE, O_WRONLY | O_CREAT |
|
|
|
|
O_TRUNC, uap->mode);
|
|
|
|
free(newpath, M_TEMP);
|
|
|
|
return (error);
|
1999-01-30 06:29:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
svr4_sys_creat64(td, uap)
|
2009-05-29 05:58:46 +00:00
|
|
|
struct thread *td;
|
1999-01-30 06:29:48 +00:00
|
|
|
struct svr4_sys_creat64_args *uap;
|
|
|
|
{
|
2001-09-12 08:38:13 +00:00
|
|
|
return svr4_sys_creat(td, (struct svr4_sys_creat_args *)uap);
|
1999-01-30 06:29:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
svr4_sys_llseek(td, uap)
|
2009-05-29 05:58:46 +00:00
|
|
|
struct thread *td;
|
2001-01-23 21:33:55 +00:00
|
|
|
struct svr4_sys_llseek_args *uap;
|
1999-01-30 06:29:48 +00:00
|
|
|
{
|
|
|
|
struct lseek_args ap;
|
|
|
|
|
2002-12-14 01:56:26 +00:00
|
|
|
ap.fd = uap->fd;
|
1999-01-30 06:29:48 +00:00
|
|
|
|
|
|
|
#if BYTE_ORDER == BIG_ENDIAN
|
2002-12-14 01:56:26 +00:00
|
|
|
ap.offset = (((u_int64_t) uap->offset1) << 32) |
|
|
|
|
uap->offset2;
|
1999-01-30 06:29:48 +00:00
|
|
|
#else
|
2002-12-14 01:56:26 +00:00
|
|
|
ap.offset = (((u_int64_t) uap->offset2) << 32) |
|
|
|
|
uap->offset1;
|
1999-01-30 06:29:48 +00:00
|
|
|
#endif
|
2002-12-14 01:56:26 +00:00
|
|
|
ap.whence = uap->whence;
|
1999-01-30 06:29:48 +00:00
|
|
|
|
2001-09-12 08:38:13 +00:00
|
|
|
return lseek(td, &ap);
|
1999-01-30 06:29:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
svr4_sys_access(td, uap)
|
2009-05-29 05:58:46 +00:00
|
|
|
struct thread *td;
|
1999-01-30 06:29:48 +00:00
|
|
|
struct svr4_sys_access_args *uap;
|
|
|
|
{
|
- Implement svr4_emul_find() using kern_alternate_path(). This changes
the semantics in that the returned filename to use is now a kernel
pointer rather than a user space pointer. This required changing the
arguments to the CHECKALT*() macros some and changing the various system
calls that used pathnames to use the kern_foo() functions that can accept
kernel space filename pointers instead of calling the system call
directly.
- Use kern_open(), kern_access(), kern_msgctl(), kern_execve(),
kern_mkfifo(), kern_mknod(), kern_statfs(), kern_fstatfs(),
kern_setitimer(), kern_stat(), kern_lstat(), kern_fstat(), kern_utimes(),
kern_pathconf(), and kern_unlink().
2005-02-07 21:53:42 +00:00
|
|
|
char *newpath;
|
|
|
|
int error;
|
1999-01-30 06:29:48 +00:00
|
|
|
|
- Implement svr4_emul_find() using kern_alternate_path(). This changes
the semantics in that the returned filename to use is now a kernel
pointer rather than a user space pointer. This required changing the
arguments to the CHECKALT*() macros some and changing the various system
calls that used pathnames to use the kern_foo() functions that can accept
kernel space filename pointers instead of calling the system call
directly.
- Use kern_open(), kern_access(), kern_msgctl(), kern_execve(),
kern_mkfifo(), kern_mknod(), kern_statfs(), kern_fstatfs(),
kern_setitimer(), kern_stat(), kern_lstat(), kern_fstat(), kern_utimes(),
kern_pathconf(), and kern_unlink().
2005-02-07 21:53:42 +00:00
|
|
|
CHECKALTEXIST(td, uap->path, &newpath);
|
|
|
|
error = kern_access(td, newpath, UIO_SYSSPACE, uap->flags);
|
|
|
|
free(newpath, M_TEMP);
|
|
|
|
return (error);
|
1999-01-30 06:29:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(NOTYET)
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
svr4_sys_pread(td, uap)
|
2009-05-29 05:58:46 +00:00
|
|
|
struct thread *td;
|
1999-01-30 06:29:48 +00:00
|
|
|
struct svr4_sys_pread_args *uap;
|
|
|
|
{
|
|
|
|
struct pread_args pra;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Just translate the args structure and call the NetBSD
|
|
|
|
* pread(2) system call (offset type is 64-bit in NetBSD).
|
|
|
|
*/
|
2002-12-14 01:56:26 +00:00
|
|
|
pra.fd = uap->fd;
|
|
|
|
pra.buf = uap->buf;
|
|
|
|
pra.nbyte = uap->nbyte;
|
|
|
|
pra.offset = uap->off;
|
1999-01-30 06:29:48 +00:00
|
|
|
|
2001-09-12 08:38:13 +00:00
|
|
|
return pread(td, &pra);
|
1999-01-30 06:29:48 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(NOTYET)
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
svr4_sys_pread64(td, v, retval)
|
2009-05-29 05:58:46 +00:00
|
|
|
struct thread *td;
|
1999-01-30 06:29:48 +00:00
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
|
|
|
|
struct svr4_sys_pread64_args *uap = v;
|
|
|
|
struct sys_pread_args pra;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Just translate the args structure and call the NetBSD
|
|
|
|
* pread(2) system call (offset type is 64-bit in NetBSD).
|
|
|
|
*/
|
2002-12-14 01:56:26 +00:00
|
|
|
pra.fd = uap->fd;
|
|
|
|
pra.buf = uap->buf;
|
|
|
|
pra.nbyte = uap->nbyte;
|
|
|
|
pra.offset = uap->off;
|
1999-01-30 06:29:48 +00:00
|
|
|
|
2001-09-12 08:38:13 +00:00
|
|
|
return (sys_pread(td, &pra, retval));
|
1999-01-30 06:29:48 +00:00
|
|
|
}
|
|
|
|
#endif /* NOTYET */
|
|
|
|
|
|
|
|
#if defined(NOTYET)
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
svr4_sys_pwrite(td, uap)
|
2009-05-29 05:58:46 +00:00
|
|
|
struct thread *td;
|
1999-01-30 06:29:48 +00:00
|
|
|
struct svr4_sys_pwrite_args *uap;
|
|
|
|
{
|
|
|
|
struct pwrite_args pwa;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Just translate the args structure and call the NetBSD
|
|
|
|
* pwrite(2) system call (offset type is 64-bit in NetBSD).
|
|
|
|
*/
|
2002-12-14 01:56:26 +00:00
|
|
|
pwa.fd = uap->fd;
|
|
|
|
pwa.buf = uap->buf;
|
|
|
|
pwa.nbyte = uap->nbyte;
|
|
|
|
pwa.offset = uap->off;
|
1999-01-30 06:29:48 +00:00
|
|
|
|
2001-09-12 08:38:13 +00:00
|
|
|
return pwrite(td, &pwa);
|
1999-01-30 06:29:48 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(NOTYET)
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
svr4_sys_pwrite64(td, v, retval)
|
2009-05-29 05:58:46 +00:00
|
|
|
struct thread *td;
|
1999-01-30 06:29:48 +00:00
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct svr4_sys_pwrite64_args *uap = v;
|
|
|
|
struct sys_pwrite_args pwa;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Just translate the args structure and call the NetBSD
|
|
|
|
* pwrite(2) system call (offset type is 64-bit in NetBSD).
|
|
|
|
*/
|
2002-12-14 01:56:26 +00:00
|
|
|
pwa.fd = uap->fd;
|
|
|
|
pwa.buf = uap->buf;
|
|
|
|
pwa.nbyte = uap->nbyte;
|
|
|
|
pwa.offset = uap->off;
|
1999-01-30 06:29:48 +00:00
|
|
|
|
2001-09-12 08:38:13 +00:00
|
|
|
return (sys_pwrite(td, &pwa, retval));
|
1999-01-30 06:29:48 +00:00
|
|
|
}
|
|
|
|
#endif /* NOTYET */
|
|
|
|
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
svr4_sys_fcntl(td, uap)
|
2009-05-29 05:58:46 +00:00
|
|
|
struct thread *td;
|
1999-01-30 06:29:48 +00:00
|
|
|
struct svr4_sys_fcntl_args *uap;
|
|
|
|
{
|
2004-08-24 20:21:21 +00:00
|
|
|
int cmd, error, *retval;
|
1999-01-30 06:29:48 +00:00
|
|
|
|
2001-09-12 08:38:13 +00:00
|
|
|
retval = td->td_retval;
|
1999-01-30 06:29:48 +00:00
|
|
|
|
2004-08-24 20:21:21 +00:00
|
|
|
cmd = svr4_to_bsd_cmd(uap->cmd);
|
1999-01-30 06:29:48 +00:00
|
|
|
|
2004-08-24 20:21:21 +00:00
|
|
|
switch (cmd) {
|
1999-01-30 06:29:48 +00:00
|
|
|
case F_DUPFD:
|
2008-03-17 18:27:28 +00:00
|
|
|
case F_DUP2FD:
|
1999-01-30 06:29:48 +00:00
|
|
|
case F_GETFD:
|
|
|
|
case F_SETFD:
|
2004-08-24 20:21:21 +00:00
|
|
|
return (kern_fcntl(td, uap->fd, cmd, (intptr_t)uap->arg));
|
1999-01-30 06:29:48 +00:00
|
|
|
|
|
|
|
case F_GETFL:
|
2004-08-24 20:21:21 +00:00
|
|
|
error = kern_fcntl(td, uap->fd, cmd, (intptr_t)uap->arg);
|
1999-01-30 06:29:48 +00:00
|
|
|
if (error)
|
2004-08-24 20:21:21 +00:00
|
|
|
return (error);
|
1999-01-30 06:29:48 +00:00
|
|
|
*retval = bsd_to_svr4_flags(*retval);
|
2004-08-24 20:21:21 +00:00
|
|
|
return (error);
|
1999-01-30 06:29:48 +00:00
|
|
|
|
|
|
|
case F_SETFL:
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* we must save the O_ASYNC flag, as that is
|
|
|
|
* handled by ioctl(_, I_SETSIG, _) emulation.
|
|
|
|
*/
|
|
|
|
int flags;
|
|
|
|
|
2002-12-14 01:56:26 +00:00
|
|
|
DPRINTF(("Setting flags %p\n", uap->arg));
|
1999-01-30 06:29:48 +00:00
|
|
|
|
2004-08-24 20:21:21 +00:00
|
|
|
error = kern_fcntl(td, uap->fd, F_GETFL, 0);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
1999-01-30 06:29:48 +00:00
|
|
|
flags = *retval;
|
|
|
|
flags &= O_ASYNC;
|
2002-12-14 01:56:26 +00:00
|
|
|
flags |= svr4_to_bsd_flags((u_long) uap->arg);
|
2004-08-24 20:21:21 +00:00
|
|
|
return (kern_fcntl(td, uap->fd, F_SETFL, flags));
|
1999-01-30 06:29:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case F_GETLK:
|
|
|
|
case F_SETLK:
|
|
|
|
case F_SETLKW:
|
|
|
|
{
|
2004-08-24 20:21:21 +00:00
|
|
|
struct svr4_flock ifl;
|
|
|
|
struct flock fl;
|
1999-01-30 06:29:48 +00:00
|
|
|
|
2004-08-24 20:21:21 +00:00
|
|
|
error = copyin(uap->arg, &ifl, sizeof (ifl));
|
1999-01-30 06:29:48 +00:00
|
|
|
if (error)
|
2004-08-24 20:21:21 +00:00
|
|
|
return (error);
|
1999-01-30 06:29:48 +00:00
|
|
|
|
|
|
|
svr4_to_bsd_flock(&ifl, &fl);
|
|
|
|
|
2004-08-24 20:21:21 +00:00
|
|
|
error = kern_fcntl(td, uap->fd, cmd, (intptr_t)&fl);
|
|
|
|
if (error || cmd != F_GETLK)
|
|
|
|
return (error);
|
1999-01-30 06:29:48 +00:00
|
|
|
|
|
|
|
bsd_to_svr4_flock(&fl, &ifl);
|
|
|
|
|
2004-08-24 20:21:21 +00:00
|
|
|
return (copyout(&ifl, uap->arg, sizeof (ifl)));
|
1999-01-30 06:29:48 +00:00
|
|
|
}
|
|
|
|
case -1:
|
2002-12-14 01:56:26 +00:00
|
|
|
switch (uap->cmd) {
|
1999-01-30 06:29:48 +00:00
|
|
|
case SVR4_F_FREESP:
|
|
|
|
{
|
|
|
|
struct svr4_flock ifl;
|
|
|
|
struct flock fl;
|
|
|
|
|
2002-12-14 01:56:26 +00:00
|
|
|
error = copyin(uap->arg, &ifl,
|
1999-01-30 06:29:48 +00:00
|
|
|
sizeof ifl);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
svr4_to_bsd_flock(&ifl, &fl);
|
2002-12-14 01:56:26 +00:00
|
|
|
return fd_truncate(td, uap->fd, &fl);
|
1999-01-30 06:29:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case SVR4_F_GETLK64:
|
|
|
|
case SVR4_F_SETLK64:
|
|
|
|
case SVR4_F_SETLKW64:
|
|
|
|
{
|
2004-08-24 20:21:21 +00:00
|
|
|
struct svr4_flock64 ifl;
|
|
|
|
struct flock fl;
|
|
|
|
|
|
|
|
switch (uap->cmd) {
|
|
|
|
case SVR4_F_GETLK64:
|
|
|
|
cmd = F_GETLK;
|
|
|
|
break;
|
|
|
|
case SVR4_F_SETLK64:
|
|
|
|
cmd = F_SETLK;
|
|
|
|
break;
|
|
|
|
case SVR4_F_SETLKW64:
|
|
|
|
cmd = F_SETLKW;
|
|
|
|
break;
|
|
|
|
}
|
2002-12-14 01:56:26 +00:00
|
|
|
error = copyin(uap->arg, &ifl,
|
2004-08-24 20:21:21 +00:00
|
|
|
sizeof (ifl));
|
1999-01-30 06:29:48 +00:00
|
|
|
if (error)
|
2004-08-24 20:21:21 +00:00
|
|
|
return (error);
|
1999-01-30 06:29:48 +00:00
|
|
|
|
|
|
|
svr4_to_bsd_flock64(&ifl, &fl);
|
|
|
|
|
2004-08-24 20:21:21 +00:00
|
|
|
error = kern_fcntl(td, uap->fd, cmd,
|
|
|
|
(intptr_t)&fl);
|
|
|
|
if (error || cmd != F_GETLK)
|
|
|
|
return (error);
|
1999-01-30 06:29:48 +00:00
|
|
|
|
|
|
|
bsd_to_svr4_flock64(&fl, &ifl);
|
|
|
|
|
2004-08-24 20:21:21 +00:00
|
|
|
return (copyout(&ifl, uap->arg,
|
|
|
|
sizeof (ifl)));
|
1999-01-30 06:29:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case SVR4_F_FREESP64:
|
|
|
|
{
|
|
|
|
struct svr4_flock64 ifl;
|
|
|
|
struct flock fl;
|
|
|
|
|
2002-12-14 01:56:26 +00:00
|
|
|
error = copyin(uap->arg, &ifl,
|
1999-01-30 06:29:48 +00:00
|
|
|
sizeof ifl);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
svr4_to_bsd_flock64(&ifl, &fl);
|
2002-12-14 01:56:26 +00:00
|
|
|
return fd_truncate(td, uap->fd, &fl);
|
1999-01-30 06:29:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case SVR4_F_REVOKE:
|
2002-12-14 01:56:26 +00:00
|
|
|
return fd_revoke(td, uap->fd);
|
1999-01-30 06:29:48 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
return ENOSYS;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
return ENOSYS;
|
|
|
|
}
|
|
|
|
}
|