1995-06-25 17:32:43 +00:00
|
|
|
/*-
|
2018-02-16 15:00:14 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
2017-11-27 15:13:23 +00:00
|
|
|
*
|
2012-01-15 13:23:18 +00:00
|
|
|
* Copyright (c) 1994-1995 Søren Schmidt
|
1995-06-25 17:32:43 +00:00
|
|
|
* 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
|
2018-02-16 15:00:14 +00:00
|
|
|
* notice, this list of conditions and the following disclaimer.
|
1995-06-25 17:32:43 +00:00
|
|
|
* 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.
|
|
|
|
*
|
2018-02-16 15:00:14 +00:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
|
1995-06-25 17:32:43 +00:00
|
|
|
*/
|
|
|
|
|
2003-06-10 21:29:12 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
2006-03-19 11:10:33 +00:00
|
|
|
#include "opt_compat.h"
|
1997-12-16 18:49:23 +00:00
|
|
|
|
1995-06-25 17:32:43 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
2014-03-16 10:55:57 +00:00
|
|
|
#include <sys/capsicum.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
#include <sys/conf.h>
|
|
|
|
#include <sys/dirent.h>
|
1995-06-25 17:32:43 +00:00
|
|
|
#include <sys/fcntl.h>
|
|
|
|
#include <sys/file.h>
|
|
|
|
#include <sys/filedesc.h>
|
1997-12-05 19:55:52 +00:00
|
|
|
#include <sys/lock.h>
|
1995-06-25 17:32:43 +00:00
|
|
|
#include <sys/malloc.h>
|
2001-02-16 14:42:11 +00:00
|
|
|
#include <sys/mount.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
#include <sys/mutex.h>
|
2007-03-29 02:11:46 +00:00
|
|
|
#include <sys/namei.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
#include <sys/proc.h>
|
2006-09-10 13:47:56 +00:00
|
|
|
#include <sys/stat.h>
|
2007-01-18 09:32:08 +00:00
|
|
|
#include <sys/sx.h>
|
2002-09-01 22:30:27 +00:00
|
|
|
#include <sys/syscallsubr.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
#include <sys/sysproto.h>
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
#include <sys/tty.h>
|
2006-09-23 19:06:54 +00:00
|
|
|
#include <sys/unistd.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
#include <sys/vnode.h>
|
1995-11-22 07:43:53 +00:00
|
|
|
|
2005-01-14 04:44:56 +00:00
|
|
|
#ifdef COMPAT_LINUX32
|
2004-08-16 07:28:16 +00:00
|
|
|
#include <machine/../linux32/linux.h>
|
|
|
|
#include <machine/../linux32/linux32_proto.h>
|
2005-01-14 04:44:56 +00:00
|
|
|
#else
|
|
|
|
#include <machine/../linux/linux.h>
|
|
|
|
#include <machine/../linux/linux_proto.h>
|
2004-08-16 07:28:16 +00:00
|
|
|
#endif
|
2013-01-29 18:41:30 +00:00
|
|
|
#include <compat/linux/linux_misc.h>
|
2000-08-22 01:27:36 +00:00
|
|
|
#include <compat/linux/linux_util.h>
|
Implement the linux syscalls
openat, mkdirat, mknodat, fchownat, futimesat, fstatat, unlinkat,
renameat, linkat, symlinkat, readlinkat, fchmodat, faccessat.
Submitted by: rdivacky
Sponsored by: Google Summer of Code 2007
Tested by: pho
2008-04-08 09:45:49 +00:00
|
|
|
#include <compat/linux/linux_file.h>
|
1995-06-25 17:32:43 +00:00
|
|
|
|
2017-02-14 19:13:27 +00:00
|
|
|
static int linux_common_open(struct thread *, int, char *, int, int);
|
|
|
|
static int linux_getdents_error(struct thread *, int, int);
|
|
|
|
|
|
|
|
|
1995-06-25 17:32:43 +00:00
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
linux_creat(struct thread *td, struct linux_creat_args *args)
|
1995-06-25 17:32:43 +00:00
|
|
|
{
|
2016-05-22 12:26:03 +00:00
|
|
|
char *path;
|
|
|
|
int error;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
2016-05-22 12:26:03 +00:00
|
|
|
LCONVPATHEXIST(td, args->path, &path);
|
1995-06-25 17:32:43 +00:00
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
if (ldebug(creat))
|
2002-09-01 22:30:27 +00:00
|
|
|
printf(ARGS(creat, "%s, %d"), path, args->mode);
|
1995-06-25 17:32:43 +00:00
|
|
|
#endif
|
2016-05-22 12:26:03 +00:00
|
|
|
error = kern_openat(td, AT_FDCWD, path, UIO_SYSSPACE,
|
|
|
|
O_WRONLY | O_CREAT | O_TRUNC, args->mode);
|
|
|
|
LFREEPATH(path);
|
|
|
|
return (error);
|
1995-06-25 17:32:43 +00:00
|
|
|
}
|
|
|
|
|
2007-03-29 02:11:46 +00:00
|
|
|
|
|
|
|
static int
|
Implement the linux syscalls
openat, mkdirat, mknodat, fchownat, futimesat, fstatat, unlinkat,
renameat, linkat, symlinkat, readlinkat, fchmodat, faccessat.
Submitted by: rdivacky
Sponsored by: Google Summer of Code 2007
Tested by: pho
2008-04-08 09:45:49 +00:00
|
|
|
linux_common_open(struct thread *td, int dirfd, char *path, int l_flags, int mode)
|
1995-06-25 17:32:43 +00:00
|
|
|
{
|
2016-05-22 12:26:03 +00:00
|
|
|
struct proc *p = td->td_proc;
|
|
|
|
struct file *fp;
|
|
|
|
int fd;
|
|
|
|
int bsd_flags, error;
|
|
|
|
|
|
|
|
bsd_flags = 0;
|
|
|
|
switch (l_flags & LINUX_O_ACCMODE) {
|
|
|
|
case LINUX_O_WRONLY:
|
|
|
|
bsd_flags |= O_WRONLY;
|
|
|
|
break;
|
|
|
|
case LINUX_O_RDWR:
|
|
|
|
bsd_flags |= O_RDWR;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
bsd_flags |= O_RDONLY;
|
|
|
|
}
|
|
|
|
if (l_flags & LINUX_O_NDELAY)
|
|
|
|
bsd_flags |= O_NONBLOCK;
|
|
|
|
if (l_flags & LINUX_O_APPEND)
|
|
|
|
bsd_flags |= O_APPEND;
|
|
|
|
if (l_flags & LINUX_O_SYNC)
|
|
|
|
bsd_flags |= O_FSYNC;
|
|
|
|
if (l_flags & LINUX_O_NONBLOCK)
|
|
|
|
bsd_flags |= O_NONBLOCK;
|
|
|
|
if (l_flags & LINUX_FASYNC)
|
|
|
|
bsd_flags |= O_ASYNC;
|
|
|
|
if (l_flags & LINUX_O_CREAT)
|
|
|
|
bsd_flags |= O_CREAT;
|
|
|
|
if (l_flags & LINUX_O_TRUNC)
|
|
|
|
bsd_flags |= O_TRUNC;
|
|
|
|
if (l_flags & LINUX_O_EXCL)
|
|
|
|
bsd_flags |= O_EXCL;
|
|
|
|
if (l_flags & LINUX_O_NOCTTY)
|
|
|
|
bsd_flags |= O_NOCTTY;
|
|
|
|
if (l_flags & LINUX_O_DIRECT)
|
|
|
|
bsd_flags |= O_DIRECT;
|
|
|
|
if (l_flags & LINUX_O_NOFOLLOW)
|
|
|
|
bsd_flags |= O_NOFOLLOW;
|
|
|
|
if (l_flags & LINUX_O_DIRECTORY)
|
|
|
|
bsd_flags |= O_DIRECTORY;
|
|
|
|
/* XXX LINUX_O_NOATIME: unable to be easily implemented. */
|
|
|
|
|
|
|
|
error = kern_openat(td, dirfd, path, UIO_SYSSPACE, bsd_flags, mode);
|
|
|
|
if (error != 0)
|
|
|
|
goto done;
|
|
|
|
if (bsd_flags & O_NOCTTY)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
/*
|
2017-10-27 16:36:05 +00:00
|
|
|
* XXX In between kern_openat() and fget(), another process
|
2016-05-22 12:26:03 +00:00
|
|
|
* having the same filedesc could use that fd without
|
|
|
|
* checking below.
|
|
|
|
*/
|
|
|
|
fd = td->td_retval[0];
|
2018-05-09 18:47:24 +00:00
|
|
|
if (fget(td, fd, &cap_ioctl_rights, &fp) == 0) {
|
2016-05-22 12:26:03 +00:00
|
|
|
if (fp->f_type != DTYPE_VNODE) {
|
|
|
|
fdrop(fp, td);
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
sx_slock(&proctree_lock);
|
|
|
|
PROC_LOCK(p);
|
|
|
|
if (SESS_LEADER(p) && !(p->p_flag & P_CONTROLT)) {
|
|
|
|
PROC_UNLOCK(p);
|
|
|
|
sx_sunlock(&proctree_lock);
|
|
|
|
/* XXXPJD: Verify if TIOCSCTTY is allowed. */
|
|
|
|
(void) fo_ioctl(fp, TIOCSCTTY, (caddr_t) 0,
|
|
|
|
td->td_ucred, td);
|
|
|
|
} else {
|
|
|
|
PROC_UNLOCK(p);
|
|
|
|
sx_sunlock(&proctree_lock);
|
|
|
|
}
|
|
|
|
fdrop(fp, td);
|
|
|
|
}
|
2007-01-18 09:32:08 +00:00
|
|
|
|
2015-04-19 07:12:16 +00:00
|
|
|
done:
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
#ifdef DEBUG
|
2016-05-22 12:26:03 +00:00
|
|
|
if (ldebug(open))
|
|
|
|
printf(LMSG("open returns error %d"), error);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
#endif
|
2016-05-22 12:26:03 +00:00
|
|
|
LFREEPATH(path);
|
|
|
|
return (error);
|
2007-03-29 02:11:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
linux_openat(struct thread *td, struct linux_openat_args *args)
|
|
|
|
{
|
Implement the linux syscalls
openat, mkdirat, mknodat, fchownat, futimesat, fstatat, unlinkat,
renameat, linkat, symlinkat, readlinkat, fchmodat, faccessat.
Submitted by: rdivacky
Sponsored by: Google Summer of Code 2007
Tested by: pho
2008-04-08 09:45:49 +00:00
|
|
|
char *path;
|
|
|
|
int dfd;
|
2007-03-29 02:11:46 +00:00
|
|
|
|
Implement the linux syscalls
openat, mkdirat, mknodat, fchownat, futimesat, fstatat, unlinkat,
renameat, linkat, symlinkat, readlinkat, fchmodat, faccessat.
Submitted by: rdivacky
Sponsored by: Google Summer of Code 2007
Tested by: pho
2008-04-08 09:45:49 +00:00
|
|
|
dfd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->dfd;
|
|
|
|
if (args->flags & LINUX_O_CREAT)
|
|
|
|
LCONVPATH_AT(td, args->filename, &path, 1, dfd);
|
|
|
|
else
|
|
|
|
LCONVPATH_AT(td, args->filename, &path, 0, dfd);
|
2007-03-29 02:11:46 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (ldebug(openat))
|
|
|
|
printf(ARGS(openat, "%i, %s, 0x%x, 0x%x"), args->dfd,
|
Implement the linux syscalls
openat, mkdirat, mknodat, fchownat, futimesat, fstatat, unlinkat,
renameat, linkat, symlinkat, readlinkat, fchmodat, faccessat.
Submitted by: rdivacky
Sponsored by: Google Summer of Code 2007
Tested by: pho
2008-04-08 09:45:49 +00:00
|
|
|
path, args->flags, args->mode);
|
2007-03-29 02:11:46 +00:00
|
|
|
#endif
|
Implement the linux syscalls
openat, mkdirat, mknodat, fchownat, futimesat, fstatat, unlinkat,
renameat, linkat, symlinkat, readlinkat, fchmodat, faccessat.
Submitted by: rdivacky
Sponsored by: Google Summer of Code 2007
Tested by: pho
2008-04-08 09:45:49 +00:00
|
|
|
return (linux_common_open(td, dfd, path, args->flags, args->mode));
|
2007-03-29 02:11:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
linux_open(struct thread *td, struct linux_open_args *args)
|
|
|
|
{
|
2016-05-22 12:26:03 +00:00
|
|
|
char *path;
|
2007-03-29 02:11:46 +00:00
|
|
|
|
2016-05-22 12:26:03 +00:00
|
|
|
if (args->flags & LINUX_O_CREAT)
|
|
|
|
LCONVPATHCREAT(td, args->path, &path);
|
|
|
|
else
|
|
|
|
LCONVPATHEXIST(td, args->path, &path);
|
2007-03-29 02:11:46 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (ldebug(open))
|
|
|
|
printf(ARGS(open, "%s, 0x%x, 0x%x"),
|
|
|
|
path, args->flags, args->mode);
|
|
|
|
#endif
|
2008-04-09 16:42:50 +00:00
|
|
|
return (linux_common_open(td, AT_FDCWD, path, args->flags, args->mode));
|
2007-03-29 02:11:46 +00:00
|
|
|
}
|
|
|
|
|
1995-06-25 17:32:43 +00:00
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
linux_lseek(struct thread *td, struct linux_lseek_args *args)
|
1995-06-25 17:32:43 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
if (ldebug(lseek))
|
|
|
|
printf(ARGS(lseek, "%d, %ld, %d"),
|
2001-09-08 19:07:04 +00:00
|
|
|
args->fdes, (long)args->off, args->whence);
|
1995-06-25 17:32:43 +00:00
|
|
|
#endif
|
2017-01-30 12:24:47 +00:00
|
|
|
return (kern_lseek(td, args->fdes, args->off, args->whence));
|
1995-06-25 17:32:43 +00:00
|
|
|
}
|
|
|
|
|
2015-05-24 15:43:53 +00:00
|
|
|
#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
linux_llseek(struct thread *td, struct linux_llseek_args *args)
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
{
|
|
|
|
int error;
|
|
|
|
off_t off;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
if (ldebug(llseek))
|
|
|
|
printf(ARGS(llseek, "%d, %d:%d, %d"),
|
|
|
|
args->fd, args->ohigh, args->olow, args->whence);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
#endif
|
|
|
|
off = (args->olow) | (((off_t) args->ohigh) << 32);
|
|
|
|
|
2017-01-30 12:24:47 +00:00
|
|
|
error = kern_lseek(td, args->fd, off, args->whence);
|
|
|
|
if (error != 0)
|
2016-05-22 12:26:03 +00:00
|
|
|
return (error);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
2017-01-30 12:24:47 +00:00
|
|
|
error = copyout(td->td_retval, args->res, sizeof(off_t));
|
|
|
|
if (error != 0)
|
2016-05-22 12:26:03 +00:00
|
|
|
return (error);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
2001-09-12 08:38:13 +00:00
|
|
|
td->td_retval[0] = 0;
|
2016-05-22 12:26:03 +00:00
|
|
|
return (0);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
}
|
2015-05-24 15:43:53 +00:00
|
|
|
#endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
2001-09-08 19:07:04 +00:00
|
|
|
/*
|
|
|
|
* Note that linux_getdents(2) and linux_getdents64(2) have the same
|
|
|
|
* arguments. They only differ in the definition of struct dirent they
|
2017-02-14 19:13:27 +00:00
|
|
|
* operate on.
|
|
|
|
* Note that linux_readdir(2) is a special case of linux_getdents(2)
|
|
|
|
* where count is always equals 1, meaning that the buffer is one
|
|
|
|
* dirent-structure in size and that the code can't handle more anyway.
|
|
|
|
* Note that linux_readdir(2) can't be implemented by means of linux_getdents(2)
|
|
|
|
* as in case when the *dent buffer size is equal to 1 linux_getdents(2) will
|
|
|
|
* trash user stack.
|
2001-09-08 19:07:04 +00:00
|
|
|
*/
|
1995-06-25 17:32:43 +00:00
|
|
|
|
2017-02-14 19:13:27 +00:00
|
|
|
static int
|
|
|
|
linux_getdents_error(struct thread *td, int fd, int err)
|
|
|
|
{
|
|
|
|
struct vnode *vp;
|
|
|
|
struct file *fp;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
/* Linux return ENOTDIR in case when fd is not a directory. */
|
2018-05-09 18:47:24 +00:00
|
|
|
error = getvnode(td, fd, &cap_read_rights, &fp);
|
2017-02-14 19:13:27 +00:00
|
|
|
if (error != 0)
|
|
|
|
return (error);
|
|
|
|
vp = fp->f_vnode;
|
|
|
|
if (vp->v_type != VDIR) {
|
|
|
|
fdrop(fp, td);
|
|
|
|
return (ENOTDIR);
|
|
|
|
}
|
|
|
|
fdrop(fp, td);
|
|
|
|
return (err);
|
|
|
|
}
|
|
|
|
|
2001-09-08 19:07:04 +00:00
|
|
|
struct l_dirent {
|
2008-06-08 11:09:25 +00:00
|
|
|
l_ulong d_ino;
|
2001-09-08 19:07:04 +00:00
|
|
|
l_off_t d_off;
|
|
|
|
l_ushort d_reclen;
|
|
|
|
char d_name[LINUX_NAME_MAX + 1];
|
|
|
|
};
|
1995-06-25 17:32:43 +00:00
|
|
|
|
2001-09-08 19:07:04 +00:00
|
|
|
struct l_dirent64 {
|
|
|
|
uint64_t d_ino;
|
|
|
|
int64_t d_off;
|
|
|
|
l_ushort d_reclen;
|
|
|
|
u_char d_type;
|
|
|
|
char d_name[LINUX_NAME_MAX + 1];
|
|
|
|
};
|
1995-06-25 17:32:43 +00:00
|
|
|
|
2008-09-09 16:00:17 +00:00
|
|
|
/*
|
|
|
|
* Linux uses the last byte in the dirent buffer to store d_type,
|
|
|
|
* at least glibc-2.7 requires it. That is why l_dirent is padded with 2 bytes.
|
|
|
|
*/
|
|
|
|
#define LINUX_RECLEN(namlen) \
|
2016-04-22 16:57:42 +00:00
|
|
|
roundup(offsetof(struct l_dirent, d_name) + (namlen) + 2, sizeof(l_ulong))
|
2008-09-09 16:00:17 +00:00
|
|
|
|
|
|
|
#define LINUX_RECLEN64(namlen) \
|
2016-04-22 16:57:42 +00:00
|
|
|
roundup(offsetof(struct l_dirent64, d_name) + (namlen) + 1, \
|
2008-09-09 16:00:17 +00:00
|
|
|
sizeof(uint64_t))
|
1995-06-25 17:32:43 +00:00
|
|
|
|
2017-02-14 19:13:27 +00:00
|
|
|
int
|
|
|
|
linux_getdents(struct thread *td, struct linux_getdents_args *args)
|
2001-09-08 19:07:04 +00:00
|
|
|
{
|
2003-03-03 09:17:12 +00:00
|
|
|
struct dirent *bdp;
|
2001-09-08 19:07:04 +00:00
|
|
|
caddr_t inp, buf; /* BSD-format */
|
|
|
|
int len, reclen; /* BSD-format */
|
|
|
|
caddr_t outp; /* Linux-format */
|
2017-02-14 19:13:27 +00:00
|
|
|
int resid, linuxreclen; /* Linux-format */
|
2008-09-09 16:00:17 +00:00
|
|
|
caddr_t lbuf; /* Linux-format */
|
Commit the 64-bit inode project.
Extend the ino_t, dev_t, nlink_t types to 64-bit ints. Modify
struct dirent layout to add d_off, increase the size of d_fileno
to 64-bits, increase the size of d_namlen to 16-bits, and change
the required alignment. Increase struct statfs f_mntfromname[] and
f_mntonname[] array length MNAMELEN to 1024.
ABI breakage is mitigated by providing compatibility using versioned
symbols, ingenious use of the existing padding in structures, and
by employing other tricks. Unfortunately, not everything can be
fixed, especially outside the base system. For instance, third-party
APIs which pass struct stat around are broken in backward and
forward incompatible ways.
Kinfo sysctl MIBs ABI is changed in backward-compatible way, but
there is no general mechanism to handle other sysctl MIBS which
return structures where the layout has changed. It was considered
that the breakage is either in the management interfaces, where we
usually allow ABI slip, or is not important.
Struct xvnode changed layout, no compat shims are provided.
For struct xtty, dev_t tty device member was reduced to uint32_t.
It was decided that keeping ABI compat in this case is more useful
than reporting 64-bit dev_t, for the sake of pstat.
Update note: strictly follow the instructions in UPDATING. Build
and install the new kernel with COMPAT_FREEBSD11 option enabled,
then reboot, and only then install new world.
Credits: The 64-bit inode project, also known as ino64, started life
many years ago as a project by Gleb Kurtsou (gleb). Kirk McKusick
(mckusick) then picked up and updated the patch, and acted as a
flag-waver. Feedback, suggestions, and discussions were carried
by Ed Maste (emaste), John Baldwin (jhb), Jilles Tjoelker (jilles),
and Rick Macklem (rmacklem). Kris Moore (kris) performed an initial
ports investigation followed by an exp-run by Antoine Brodin (antoine).
Essential and all-embracing testing was done by Peter Holm (pho).
The heavy lifting of coordinating all these efforts and bringing the
project to completion were done by Konstantin Belousov (kib).
Sponsored by: The FreeBSD Foundation (emaste, kib)
Differential revision: https://reviews.freebsd.org/D10439
2017-05-23 09:29:05 +00:00
|
|
|
off_t base;
|
2008-09-09 16:00:17 +00:00
|
|
|
struct l_dirent *linux_dirent;
|
2017-02-14 19:13:27 +00:00
|
|
|
int buflen, error;
|
|
|
|
size_t retval;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
2017-02-14 19:13:27 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (ldebug(getdents))
|
|
|
|
printf(ARGS(getdents, "%d, *, %d"), args->fd, args->count);
|
|
|
|
#endif
|
2017-06-12 07:35:59 +00:00
|
|
|
buflen = min(args->count, MAXBSIZE);
|
2017-02-14 19:13:27 +00:00
|
|
|
buf = malloc(buflen, M_TEMP, M_WAITOK);
|
2001-09-08 19:07:04 +00:00
|
|
|
|
2017-02-14 19:13:27 +00:00
|
|
|
error = kern_getdirentries(td, args->fd, buf, buflen,
|
|
|
|
&base, NULL, UIO_SYSSPACE);
|
|
|
|
if (error != 0) {
|
|
|
|
error = linux_getdents_error(td, args->fd, error);
|
|
|
|
goto out1;
|
2002-01-13 11:58:06 +00:00
|
|
|
}
|
2001-09-08 19:07:04 +00:00
|
|
|
|
2017-02-14 19:13:27 +00:00
|
|
|
lbuf = malloc(LINUX_RECLEN(LINUX_NAME_MAX), M_TEMP, M_WAITOK | M_ZERO);
|
2001-09-08 19:07:04 +00:00
|
|
|
|
2017-02-14 19:13:27 +00:00
|
|
|
len = td->td_retval[0];
|
2001-09-08 19:07:04 +00:00
|
|
|
inp = buf;
|
2017-02-14 19:13:27 +00:00
|
|
|
outp = (caddr_t)args->dent;
|
|
|
|
resid = args->count;
|
|
|
|
retval = 0;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
|
|
|
while (len > 0) {
|
|
|
|
bdp = (struct dirent *) inp;
|
|
|
|
reclen = bdp->d_reclen;
|
2017-02-14 19:13:27 +00:00
|
|
|
linuxreclen = LINUX_RECLEN(bdp->d_namlen);
|
|
|
|
/*
|
|
|
|
* No more space in the user supplied dirent buffer.
|
|
|
|
* Return EINVAL.
|
|
|
|
*/
|
|
|
|
if (resid < linuxreclen) {
|
|
|
|
error = EINVAL;
|
2001-09-08 19:07:04 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2017-02-14 19:13:27 +00:00
|
|
|
linux_dirent = (struct l_dirent*)lbuf;
|
|
|
|
linux_dirent->d_ino = bdp->d_fileno;
|
|
|
|
linux_dirent->d_off = base + reclen;
|
|
|
|
linux_dirent->d_reclen = linuxreclen;
|
|
|
|
/*
|
|
|
|
* Copy d_type to last byte of l_dirent buffer
|
|
|
|
*/
|
|
|
|
lbuf[linuxreclen - 1] = bdp->d_type;
|
|
|
|
strlcpy(linux_dirent->d_name, bdp->d_name,
|
|
|
|
linuxreclen - offsetof(struct l_dirent, d_name)-1);
|
|
|
|
error = copyout(linux_dirent, outp, linuxreclen);
|
|
|
|
if (error != 0)
|
2001-09-08 19:07:04 +00:00
|
|
|
goto out;
|
|
|
|
|
|
|
|
inp += reclen;
|
2017-02-14 19:13:27 +00:00
|
|
|
base += reclen;
|
|
|
|
len -= reclen;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
2017-02-14 19:13:27 +00:00
|
|
|
retval += linuxreclen;
|
2001-09-08 19:07:04 +00:00
|
|
|
outp += linuxreclen;
|
|
|
|
resid -= linuxreclen;
|
2011-01-19 12:19:25 +00:00
|
|
|
}
|
2017-02-14 19:13:27 +00:00
|
|
|
td->td_retval[0] = retval;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
1995-06-25 17:32:43 +00:00
|
|
|
out:
|
2017-06-26 09:13:25 +00:00
|
|
|
free(lbuf, M_TEMP);
|
2017-02-14 19:13:27 +00:00
|
|
|
out1:
|
2017-06-26 09:13:25 +00:00
|
|
|
free(buf, M_TEMP);
|
2001-09-08 19:07:04 +00:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2017-02-14 19:13:27 +00:00
|
|
|
linux_getdents64(struct thread *td, struct linux_getdents64_args *args)
|
2001-09-08 19:07:04 +00:00
|
|
|
{
|
2017-02-14 19:13:27 +00:00
|
|
|
struct dirent *bdp;
|
|
|
|
caddr_t inp, buf; /* BSD-format */
|
|
|
|
int len, reclen; /* BSD-format */
|
|
|
|
caddr_t outp; /* Linux-format */
|
|
|
|
int resid, linuxreclen; /* Linux-format */
|
|
|
|
caddr_t lbuf; /* Linux-format */
|
Commit the 64-bit inode project.
Extend the ino_t, dev_t, nlink_t types to 64-bit ints. Modify
struct dirent layout to add d_off, increase the size of d_fileno
to 64-bits, increase the size of d_namlen to 16-bits, and change
the required alignment. Increase struct statfs f_mntfromname[] and
f_mntonname[] array length MNAMELEN to 1024.
ABI breakage is mitigated by providing compatibility using versioned
symbols, ingenious use of the existing padding in structures, and
by employing other tricks. Unfortunately, not everything can be
fixed, especially outside the base system. For instance, third-party
APIs which pass struct stat around are broken in backward and
forward incompatible ways.
Kinfo sysctl MIBs ABI is changed in backward-compatible way, but
there is no general mechanism to handle other sysctl MIBS which
return structures where the layout has changed. It was considered
that the breakage is either in the management interfaces, where we
usually allow ABI slip, or is not important.
Struct xvnode changed layout, no compat shims are provided.
For struct xtty, dev_t tty device member was reduced to uint32_t.
It was decided that keeping ABI compat in this case is more useful
than reporting 64-bit dev_t, for the sake of pstat.
Update note: strictly follow the instructions in UPDATING. Build
and install the new kernel with COMPAT_FREEBSD11 option enabled,
then reboot, and only then install new world.
Credits: The 64-bit inode project, also known as ino64, started life
many years ago as a project by Gleb Kurtsou (gleb). Kirk McKusick
(mckusick) then picked up and updated the patch, and acted as a
flag-waver. Feedback, suggestions, and discussions were carried
by Ed Maste (emaste), John Baldwin (jhb), Jilles Tjoelker (jilles),
and Rick Macklem (rmacklem). Kris Moore (kris) performed an initial
ports investigation followed by an exp-run by Antoine Brodin (antoine).
Essential and all-embracing testing was done by Peter Holm (pho).
The heavy lifting of coordinating all these efforts and bringing the
project to completion were done by Konstantin Belousov (kib).
Sponsored by: The FreeBSD Foundation (emaste, kib)
Differential revision: https://reviews.freebsd.org/D10439
2017-05-23 09:29:05 +00:00
|
|
|
off_t base;
|
2017-02-14 19:13:27 +00:00
|
|
|
struct l_dirent64 *linux_dirent64;
|
|
|
|
int buflen, error;
|
|
|
|
size_t retval;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2017-02-14 19:13:27 +00:00
|
|
|
if (ldebug(getdents64))
|
|
|
|
uprintf(ARGS(getdents64, "%d, *, %d"), args->fd, args->count);
|
2001-09-08 19:07:04 +00:00
|
|
|
#endif
|
2017-06-12 07:35:59 +00:00
|
|
|
buflen = min(args->count, MAXBSIZE);
|
2017-02-14 19:13:27 +00:00
|
|
|
buf = malloc(buflen, M_TEMP, M_WAITOK);
|
|
|
|
|
|
|
|
error = kern_getdirentries(td, args->fd, buf, buflen,
|
|
|
|
&base, NULL, UIO_SYSSPACE);
|
|
|
|
if (error != 0) {
|
|
|
|
error = linux_getdents_error(td, args->fd, error);
|
|
|
|
goto out1;
|
|
|
|
}
|
|
|
|
|
|
|
|
lbuf = malloc(LINUX_RECLEN64(LINUX_NAME_MAX), M_TEMP, M_WAITOK | M_ZERO);
|
|
|
|
|
|
|
|
len = td->td_retval[0];
|
|
|
|
inp = buf;
|
|
|
|
outp = (caddr_t)args->dirent;
|
|
|
|
resid = args->count;
|
|
|
|
retval = 0;
|
|
|
|
|
|
|
|
while (len > 0) {
|
|
|
|
bdp = (struct dirent *) inp;
|
|
|
|
reclen = bdp->d_reclen;
|
|
|
|
linuxreclen = LINUX_RECLEN64(bdp->d_namlen);
|
|
|
|
/*
|
|
|
|
* No more space in the user supplied dirent buffer.
|
|
|
|
* Return EINVAL.
|
|
|
|
*/
|
|
|
|
if (resid < linuxreclen) {
|
|
|
|
error = EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
linux_dirent64 = (struct l_dirent64*)lbuf;
|
|
|
|
linux_dirent64->d_ino = bdp->d_fileno;
|
|
|
|
linux_dirent64->d_off = base + reclen;
|
|
|
|
linux_dirent64->d_reclen = linuxreclen;
|
|
|
|
linux_dirent64->d_type = bdp->d_type;
|
|
|
|
strlcpy(linux_dirent64->d_name, bdp->d_name,
|
|
|
|
linuxreclen - offsetof(struct l_dirent64, d_name));
|
|
|
|
error = copyout(linux_dirent64, outp, linuxreclen);
|
|
|
|
if (error != 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
inp += reclen;
|
|
|
|
base += reclen;
|
|
|
|
len -= reclen;
|
|
|
|
|
|
|
|
retval += linuxreclen;
|
|
|
|
outp += linuxreclen;
|
|
|
|
resid -= linuxreclen;
|
|
|
|
}
|
|
|
|
td->td_retval[0] = retval;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
2017-02-14 19:13:27 +00:00
|
|
|
out:
|
|
|
|
free(lbuf, M_TEMP);
|
|
|
|
out1:
|
|
|
|
free(buf, M_TEMP);
|
|
|
|
return (error);
|
2001-09-08 19:07:04 +00:00
|
|
|
}
|
|
|
|
|
2017-02-14 19:13:27 +00:00
|
|
|
#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
|
2001-09-08 19:07:04 +00:00
|
|
|
int
|
2017-02-14 19:13:27 +00:00
|
|
|
linux_readdir(struct thread *td, struct linux_readdir_args *args)
|
2001-09-08 19:07:04 +00:00
|
|
|
{
|
2017-02-14 19:13:27 +00:00
|
|
|
struct dirent *bdp;
|
|
|
|
caddr_t buf; /* BSD-format */
|
|
|
|
int linuxreclen; /* Linux-format */
|
|
|
|
caddr_t lbuf; /* Linux-format */
|
Commit the 64-bit inode project.
Extend the ino_t, dev_t, nlink_t types to 64-bit ints. Modify
struct dirent layout to add d_off, increase the size of d_fileno
to 64-bits, increase the size of d_namlen to 16-bits, and change
the required alignment. Increase struct statfs f_mntfromname[] and
f_mntonname[] array length MNAMELEN to 1024.
ABI breakage is mitigated by providing compatibility using versioned
symbols, ingenious use of the existing padding in structures, and
by employing other tricks. Unfortunately, not everything can be
fixed, especially outside the base system. For instance, third-party
APIs which pass struct stat around are broken in backward and
forward incompatible ways.
Kinfo sysctl MIBs ABI is changed in backward-compatible way, but
there is no general mechanism to handle other sysctl MIBS which
return structures where the layout has changed. It was considered
that the breakage is either in the management interfaces, where we
usually allow ABI slip, or is not important.
Struct xvnode changed layout, no compat shims are provided.
For struct xtty, dev_t tty device member was reduced to uint32_t.
It was decided that keeping ABI compat in this case is more useful
than reporting 64-bit dev_t, for the sake of pstat.
Update note: strictly follow the instructions in UPDATING. Build
and install the new kernel with COMPAT_FREEBSD11 option enabled,
then reboot, and only then install new world.
Credits: The 64-bit inode project, also known as ino64, started life
many years ago as a project by Gleb Kurtsou (gleb). Kirk McKusick
(mckusick) then picked up and updated the patch, and acted as a
flag-waver. Feedback, suggestions, and discussions were carried
by Ed Maste (emaste), John Baldwin (jhb), Jilles Tjoelker (jilles),
and Rick Macklem (rmacklem). Kris Moore (kris) performed an initial
ports investigation followed by an exp-run by Antoine Brodin (antoine).
Essential and all-embracing testing was done by Peter Holm (pho).
The heavy lifting of coordinating all these efforts and bringing the
project to completion were done by Konstantin Belousov (kib).
Sponsored by: The FreeBSD Foundation (emaste, kib)
Differential revision: https://reviews.freebsd.org/D10439
2017-05-23 09:29:05 +00:00
|
|
|
off_t base;
|
2017-02-14 19:13:27 +00:00
|
|
|
struct l_dirent *linux_dirent;
|
|
|
|
int buflen, error;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2017-02-14 19:13:27 +00:00
|
|
|
if (ldebug(readdir))
|
|
|
|
printf(ARGS(readdir, "%d, *"), args->fd);
|
2001-09-08 19:07:04 +00:00
|
|
|
#endif
|
2017-02-14 19:13:27 +00:00
|
|
|
buflen = LINUX_RECLEN(LINUX_NAME_MAX);
|
|
|
|
buf = malloc(buflen, M_TEMP, M_WAITOK);
|
|
|
|
|
|
|
|
error = kern_getdirentries(td, args->fd, buf, buflen,
|
|
|
|
&base, NULL, UIO_SYSSPACE);
|
|
|
|
if (error != 0) {
|
|
|
|
error = linux_getdents_error(td, args->fd, error);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
if (td->td_retval[0] == 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
lbuf = malloc(LINUX_RECLEN(LINUX_NAME_MAX), M_TEMP, M_WAITOK | M_ZERO);
|
2001-09-08 19:07:04 +00:00
|
|
|
|
2017-02-14 19:13:27 +00:00
|
|
|
bdp = (struct dirent *) buf;
|
|
|
|
linuxreclen = LINUX_RECLEN(bdp->d_namlen);
|
|
|
|
|
|
|
|
linux_dirent = (struct l_dirent*)lbuf;
|
|
|
|
linux_dirent->d_ino = bdp->d_fileno;
|
|
|
|
linux_dirent->d_off = linuxreclen;
|
|
|
|
linux_dirent->d_reclen = bdp->d_namlen;
|
|
|
|
strlcpy(linux_dirent->d_name, bdp->d_name,
|
|
|
|
linuxreclen - offsetof(struct l_dirent, d_name));
|
|
|
|
error = copyout(linux_dirent, args->dent, linuxreclen);
|
|
|
|
if (error == 0)
|
|
|
|
td->td_retval[0] = linuxreclen;
|
|
|
|
|
2017-06-26 09:13:25 +00:00
|
|
|
free(lbuf, M_TEMP);
|
2017-02-14 19:13:27 +00:00
|
|
|
out:
|
2017-06-26 09:13:25 +00:00
|
|
|
free(buf, M_TEMP);
|
2017-02-14 19:13:27 +00:00
|
|
|
return (error);
|
1995-06-25 17:32:43 +00:00
|
|
|
}
|
2017-02-14 19:13:27 +00:00
|
|
|
#endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */
|
|
|
|
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* These exist mainly for hooks for doing /compat/linux translation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
linux_access(struct thread *td, struct linux_access_args *args)
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
{
|
2002-09-01 22:30:27 +00:00
|
|
|
char *path;
|
|
|
|
int error;
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
2018-02-22 02:24:17 +00:00
|
|
|
/* Linux convention. */
|
2011-11-19 06:35:15 +00:00
|
|
|
if (args->amode & ~(F_OK | X_OK | W_OK | R_OK))
|
2006-09-23 19:06:54 +00:00
|
|
|
return (EINVAL);
|
|
|
|
|
2002-09-01 22:30:27 +00:00
|
|
|
LCONVPATHEXIST(td, args->path, &path);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
if (ldebug(access))
|
2011-11-19 06:35:15 +00:00
|
|
|
printf(ARGS(access, "%s, %d"), path, args->amode);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
#endif
|
2014-11-13 18:01:51 +00:00
|
|
|
error = kern_accessat(td, AT_FDCWD, path, UIO_SYSSPACE, 0,
|
|
|
|
args->amode);
|
2002-09-01 22:30:27 +00:00
|
|
|
LFREEPATH(path);
|
2006-09-23 19:06:54 +00:00
|
|
|
|
2002-09-01 22:30:27 +00:00
|
|
|
return (error);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
}
|
|
|
|
|
Implement the linux syscalls
openat, mkdirat, mknodat, fchownat, futimesat, fstatat, unlinkat,
renameat, linkat, symlinkat, readlinkat, fchmodat, faccessat.
Submitted by: rdivacky
Sponsored by: Google Summer of Code 2007
Tested by: pho
2008-04-08 09:45:49 +00:00
|
|
|
int
|
|
|
|
linux_faccessat(struct thread *td, struct linux_faccessat_args *args)
|
|
|
|
{
|
|
|
|
char *path;
|
2015-05-24 16:18:03 +00:00
|
|
|
int error, dfd;
|
Implement the linux syscalls
openat, mkdirat, mknodat, fchownat, futimesat, fstatat, unlinkat,
renameat, linkat, symlinkat, readlinkat, fchmodat, faccessat.
Submitted by: rdivacky
Sponsored by: Google Summer of Code 2007
Tested by: pho
2008-04-08 09:45:49 +00:00
|
|
|
|
2018-02-22 02:24:17 +00:00
|
|
|
/* Linux convention. */
|
2011-11-19 06:35:15 +00:00
|
|
|
if (args->amode & ~(F_OK | X_OK | W_OK | R_OK))
|
Implement the linux syscalls
openat, mkdirat, mknodat, fchownat, futimesat, fstatat, unlinkat,
renameat, linkat, symlinkat, readlinkat, fchmodat, faccessat.
Submitted by: rdivacky
Sponsored by: Google Summer of Code 2007
Tested by: pho
2008-04-08 09:45:49 +00:00
|
|
|
return (EINVAL);
|
|
|
|
|
|
|
|
dfd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->dfd;
|
|
|
|
LCONVPATHEXIST_AT(td, args->filename, &path, dfd);
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (ldebug(access))
|
2011-11-19 06:35:15 +00:00
|
|
|
printf(ARGS(access, "%s, %d"), path, args->amode);
|
Implement the linux syscalls
openat, mkdirat, mknodat, fchownat, futimesat, fstatat, unlinkat,
renameat, linkat, symlinkat, readlinkat, fchmodat, faccessat.
Submitted by: rdivacky
Sponsored by: Google Summer of Code 2007
Tested by: pho
2008-04-08 09:45:49 +00:00
|
|
|
#endif
|
|
|
|
|
2015-05-24 16:18:03 +00:00
|
|
|
error = kern_accessat(td, dfd, path, UIO_SYSSPACE, 0, args->amode);
|
Implement the linux syscalls
openat, mkdirat, mknodat, fchownat, futimesat, fstatat, unlinkat,
renameat, linkat, symlinkat, readlinkat, fchmodat, faccessat.
Submitted by: rdivacky
Sponsored by: Google Summer of Code 2007
Tested by: pho
2008-04-08 09:45:49 +00:00
|
|
|
LFREEPATH(path);
|
|
|
|
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
linux_unlink(struct thread *td, struct linux_unlink_args *args)
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
{
|
2002-09-01 22:30:27 +00:00
|
|
|
char *path;
|
|
|
|
int error;
|
2006-09-10 13:47:56 +00:00
|
|
|
struct stat st;
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
2002-09-01 22:30:27 +00:00
|
|
|
LCONVPATHEXIST(td, args->path, &path);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
if (ldebug(unlink))
|
2002-09-01 22:30:27 +00:00
|
|
|
printf(ARGS(unlink, "%s"), path);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
#endif
|
|
|
|
|
2014-11-13 18:01:51 +00:00
|
|
|
error = kern_unlinkat(td, AT_FDCWD, path, UIO_SYSSPACE, 0);
|
|
|
|
if (error == EPERM) {
|
2006-09-10 13:47:56 +00:00
|
|
|
/* Introduce POSIX noncompliant behaviour of Linux */
|
2014-11-13 18:01:51 +00:00
|
|
|
if (kern_statat(td, 0, AT_FDCWD, path, UIO_SYSSPACE, &st,
|
|
|
|
NULL) == 0) {
|
2006-09-10 13:47:56 +00:00
|
|
|
if (S_ISDIR(st.st_mode))
|
|
|
|
error = EISDIR;
|
2014-11-13 18:01:51 +00:00
|
|
|
}
|
|
|
|
}
|
2002-09-01 22:30:27 +00:00
|
|
|
LFREEPATH(path);
|
|
|
|
return (error);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
}
|
|
|
|
|
Implement the linux syscalls
openat, mkdirat, mknodat, fchownat, futimesat, fstatat, unlinkat,
renameat, linkat, symlinkat, readlinkat, fchmodat, faccessat.
Submitted by: rdivacky
Sponsored by: Google Summer of Code 2007
Tested by: pho
2008-04-08 09:45:49 +00:00
|
|
|
int
|
|
|
|
linux_unlinkat(struct thread *td, struct linux_unlinkat_args *args)
|
|
|
|
{
|
|
|
|
char *path;
|
|
|
|
int error, dfd;
|
|
|
|
struct stat st;
|
|
|
|
|
|
|
|
if (args->flag & ~LINUX_AT_REMOVEDIR)
|
|
|
|
return (EINVAL);
|
|
|
|
|
|
|
|
dfd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->dfd;
|
|
|
|
LCONVPATHEXIST_AT(td, args->pathname, &path, dfd);
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (ldebug(unlinkat))
|
|
|
|
printf(ARGS(unlinkat, "%s"), path);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (args->flag & LINUX_AT_REMOVEDIR)
|
|
|
|
error = kern_rmdirat(td, dfd, path, UIO_SYSSPACE);
|
|
|
|
else
|
2010-01-11 20:44:05 +00:00
|
|
|
error = kern_unlinkat(td, dfd, path, UIO_SYSSPACE, 0);
|
Implement the linux syscalls
openat, mkdirat, mknodat, fchownat, futimesat, fstatat, unlinkat,
renameat, linkat, symlinkat, readlinkat, fchmodat, faccessat.
Submitted by: rdivacky
Sponsored by: Google Summer of Code 2007
Tested by: pho
2008-04-08 09:45:49 +00:00
|
|
|
if (error == EPERM && !(args->flag & LINUX_AT_REMOVEDIR)) {
|
|
|
|
/* Introduce POSIX noncompliant behaviour of Linux */
|
|
|
|
if (kern_statat(td, AT_SYMLINK_NOFOLLOW, dfd, path,
|
2014-11-13 18:01:51 +00:00
|
|
|
UIO_SYSSPACE, &st, NULL) == 0 && S_ISDIR(st.st_mode))
|
Implement the linux syscalls
openat, mkdirat, mknodat, fchownat, futimesat, fstatat, unlinkat,
renameat, linkat, symlinkat, readlinkat, fchmodat, faccessat.
Submitted by: rdivacky
Sponsored by: Google Summer of Code 2007
Tested by: pho
2008-04-08 09:45:49 +00:00
|
|
|
error = EISDIR;
|
|
|
|
}
|
|
|
|
LFREEPATH(path);
|
|
|
|
return (error);
|
|
|
|
}
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
linux_chdir(struct thread *td, struct linux_chdir_args *args)
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
{
|
2002-09-01 22:30:27 +00:00
|
|
|
char *path;
|
|
|
|
int error;
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
2002-09-01 22:30:27 +00:00
|
|
|
LCONVPATHEXIST(td, args->path, &path);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
if (ldebug(chdir))
|
2002-09-01 22:30:27 +00:00
|
|
|
printf(ARGS(chdir, "%s"), path);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
#endif
|
2002-09-01 22:30:27 +00:00
|
|
|
error = kern_chdir(td, path, UIO_SYSSPACE);
|
|
|
|
LFREEPATH(path);
|
|
|
|
return (error);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
linux_chmod(struct thread *td, struct linux_chmod_args *args)
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
{
|
2002-09-01 22:30:27 +00:00
|
|
|
char *path;
|
|
|
|
int error;
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
2002-09-01 22:30:27 +00:00
|
|
|
LCONVPATHEXIST(td, args->path, &path);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
if (ldebug(chmod))
|
2002-09-01 22:30:27 +00:00
|
|
|
printf(ARGS(chmod, "%s, %d"), path, args->mode);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
#endif
|
2014-11-13 18:01:51 +00:00
|
|
|
error = kern_fchmodat(td, AT_FDCWD, path, UIO_SYSSPACE,
|
|
|
|
args->mode, 0);
|
2002-09-01 22:30:27 +00:00
|
|
|
LFREEPATH(path);
|
|
|
|
return (error);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
}
|
|
|
|
|
Implement the linux syscalls
openat, mkdirat, mknodat, fchownat, futimesat, fstatat, unlinkat,
renameat, linkat, symlinkat, readlinkat, fchmodat, faccessat.
Submitted by: rdivacky
Sponsored by: Google Summer of Code 2007
Tested by: pho
2008-04-08 09:45:49 +00:00
|
|
|
int
|
|
|
|
linux_fchmodat(struct thread *td, struct linux_fchmodat_args *args)
|
|
|
|
{
|
|
|
|
char *path;
|
|
|
|
int error, dfd;
|
|
|
|
|
|
|
|
dfd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->dfd;
|
|
|
|
LCONVPATHEXIST_AT(td, args->filename, &path, dfd);
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (ldebug(fchmodat))
|
|
|
|
printf(ARGS(fchmodat, "%s, %d"), path, args->mode);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
error = kern_fchmodat(td, dfd, path, UIO_SYSSPACE, args->mode, 0);
|
|
|
|
LFREEPATH(path);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
linux_mkdir(struct thread *td, struct linux_mkdir_args *args)
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
{
|
2002-09-01 22:30:27 +00:00
|
|
|
char *path;
|
|
|
|
int error;
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
2002-09-01 22:30:27 +00:00
|
|
|
LCONVPATHCREAT(td, args->path, &path);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
if (ldebug(mkdir))
|
2002-09-01 22:30:27 +00:00
|
|
|
printf(ARGS(mkdir, "%s, %d"), path, args->mode);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
#endif
|
2014-11-13 18:01:51 +00:00
|
|
|
error = kern_mkdirat(td, AT_FDCWD, path, UIO_SYSSPACE, args->mode);
|
2002-09-01 22:30:27 +00:00
|
|
|
LFREEPATH(path);
|
|
|
|
return (error);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
}
|
|
|
|
|
Implement the linux syscalls
openat, mkdirat, mknodat, fchownat, futimesat, fstatat, unlinkat,
renameat, linkat, symlinkat, readlinkat, fchmodat, faccessat.
Submitted by: rdivacky
Sponsored by: Google Summer of Code 2007
Tested by: pho
2008-04-08 09:45:49 +00:00
|
|
|
int
|
|
|
|
linux_mkdirat(struct thread *td, struct linux_mkdirat_args *args)
|
|
|
|
{
|
|
|
|
char *path;
|
|
|
|
int error, dfd;
|
|
|
|
|
|
|
|
dfd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->dfd;
|
|
|
|
LCONVPATHCREAT_AT(td, args->pathname, &path, dfd);
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (ldebug(mkdirat))
|
|
|
|
printf(ARGS(mkdirat, "%s, %d"), path, args->mode);
|
|
|
|
#endif
|
|
|
|
error = kern_mkdirat(td, dfd, path, UIO_SYSSPACE, args->mode);
|
|
|
|
LFREEPATH(path);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
linux_rmdir(struct thread *td, struct linux_rmdir_args *args)
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
{
|
2002-09-01 22:30:27 +00:00
|
|
|
char *path;
|
|
|
|
int error;
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
2002-09-01 22:30:27 +00:00
|
|
|
LCONVPATHEXIST(td, args->path, &path);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
if (ldebug(rmdir))
|
2002-09-01 22:30:27 +00:00
|
|
|
printf(ARGS(rmdir, "%s"), path);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
#endif
|
2014-11-13 18:01:51 +00:00
|
|
|
error = kern_rmdirat(td, AT_FDCWD, path, UIO_SYSSPACE);
|
2002-09-01 22:30:27 +00:00
|
|
|
LFREEPATH(path);
|
|
|
|
return (error);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
linux_rename(struct thread *td, struct linux_rename_args *args)
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
{
|
2002-09-01 22:30:27 +00:00
|
|
|
char *from, *to;
|
|
|
|
int error;
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
2002-09-01 22:30:27 +00:00
|
|
|
LCONVPATHEXIST(td, args->from, &from);
|
|
|
|
/* Expand LCONVPATHCREATE so that `from' can be freed on errors */
|
Implement the linux syscalls
openat, mkdirat, mknodat, fchownat, futimesat, fstatat, unlinkat,
renameat, linkat, symlinkat, readlinkat, fchmodat, faccessat.
Submitted by: rdivacky
Sponsored by: Google Summer of Code 2007
Tested by: pho
2008-04-08 09:45:49 +00:00
|
|
|
error = linux_emul_convpath(td, args->to, UIO_USERSPACE, &to, 1, AT_FDCWD);
|
2002-09-01 22:30:27 +00:00
|
|
|
if (to == NULL) {
|
|
|
|
LFREEPATH(from);
|
|
|
|
return (error);
|
|
|
|
}
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
if (ldebug(rename))
|
2002-09-01 22:30:27 +00:00
|
|
|
printf(ARGS(rename, "%s, %s"), from, to);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
#endif
|
2014-11-13 18:01:51 +00:00
|
|
|
error = kern_renameat(td, AT_FDCWD, from, AT_FDCWD, to, UIO_SYSSPACE);
|
2002-09-01 22:30:27 +00:00
|
|
|
LFREEPATH(from);
|
|
|
|
LFREEPATH(to);
|
|
|
|
return (error);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
}
|
|
|
|
|
Implement the linux syscalls
openat, mkdirat, mknodat, fchownat, futimesat, fstatat, unlinkat,
renameat, linkat, symlinkat, readlinkat, fchmodat, faccessat.
Submitted by: rdivacky
Sponsored by: Google Summer of Code 2007
Tested by: pho
2008-04-08 09:45:49 +00:00
|
|
|
int
|
|
|
|
linux_renameat(struct thread *td, struct linux_renameat_args *args)
|
|
|
|
{
|
|
|
|
char *from, *to;
|
|
|
|
int error, olddfd, newdfd;
|
|
|
|
|
|
|
|
olddfd = (args->olddfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->olddfd;
|
|
|
|
newdfd = (args->newdfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->newdfd;
|
|
|
|
LCONVPATHEXIST_AT(td, args->oldname, &from, olddfd);
|
|
|
|
/* Expand LCONVPATHCREATE so that `from' can be freed on errors */
|
|
|
|
error = linux_emul_convpath(td, args->newname, UIO_USERSPACE, &to, 1, newdfd);
|
|
|
|
if (to == NULL) {
|
|
|
|
LFREEPATH(from);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (ldebug(renameat))
|
|
|
|
printf(ARGS(renameat, "%s, %s"), from, to);
|
|
|
|
#endif
|
|
|
|
error = kern_renameat(td, olddfd, from, newdfd, to, UIO_SYSSPACE);
|
|
|
|
LFREEPATH(from);
|
|
|
|
LFREEPATH(to);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
linux_symlink(struct thread *td, struct linux_symlink_args *args)
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
{
|
2002-09-01 22:30:27 +00:00
|
|
|
char *path, *to;
|
|
|
|
int error;
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
2002-09-01 22:30:27 +00:00
|
|
|
LCONVPATHEXIST(td, args->path, &path);
|
|
|
|
/* Expand LCONVPATHCREATE so that `path' can be freed on errors */
|
Implement the linux syscalls
openat, mkdirat, mknodat, fchownat, futimesat, fstatat, unlinkat,
renameat, linkat, symlinkat, readlinkat, fchmodat, faccessat.
Submitted by: rdivacky
Sponsored by: Google Summer of Code 2007
Tested by: pho
2008-04-08 09:45:49 +00:00
|
|
|
error = linux_emul_convpath(td, args->to, UIO_USERSPACE, &to, 1, AT_FDCWD);
|
2002-09-01 22:30:27 +00:00
|
|
|
if (to == NULL) {
|
|
|
|
LFREEPATH(path);
|
|
|
|
return (error);
|
|
|
|
}
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
if (ldebug(symlink))
|
2002-09-01 22:30:27 +00:00
|
|
|
printf(ARGS(symlink, "%s, %s"), path, to);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
#endif
|
2014-11-13 18:01:51 +00:00
|
|
|
error = kern_symlinkat(td, path, AT_FDCWD, to, UIO_SYSSPACE);
|
2002-09-01 22:30:27 +00:00
|
|
|
LFREEPATH(path);
|
|
|
|
LFREEPATH(to);
|
|
|
|
return (error);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
}
|
|
|
|
|
Implement the linux syscalls
openat, mkdirat, mknodat, fchownat, futimesat, fstatat, unlinkat,
renameat, linkat, symlinkat, readlinkat, fchmodat, faccessat.
Submitted by: rdivacky
Sponsored by: Google Summer of Code 2007
Tested by: pho
2008-04-08 09:45:49 +00:00
|
|
|
int
|
|
|
|
linux_symlinkat(struct thread *td, struct linux_symlinkat_args *args)
|
|
|
|
{
|
|
|
|
char *path, *to;
|
|
|
|
int error, dfd;
|
|
|
|
|
|
|
|
dfd = (args->newdfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->newdfd;
|
2017-04-30 05:56:57 +00:00
|
|
|
LCONVPATHEXIST(td, args->oldname, &path);
|
Implement the linux syscalls
openat, mkdirat, mknodat, fchownat, futimesat, fstatat, unlinkat,
renameat, linkat, symlinkat, readlinkat, fchmodat, faccessat.
Submitted by: rdivacky
Sponsored by: Google Summer of Code 2007
Tested by: pho
2008-04-08 09:45:49 +00:00
|
|
|
/* Expand LCONVPATHCREATE so that `path' can be freed on errors */
|
|
|
|
error = linux_emul_convpath(td, args->newname, UIO_USERSPACE, &to, 1, dfd);
|
|
|
|
if (to == NULL) {
|
|
|
|
LFREEPATH(path);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (ldebug(symlinkat))
|
|
|
|
printf(ARGS(symlinkat, "%s, %s"), path, to);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
error = kern_symlinkat(td, path, dfd, to, UIO_SYSSPACE);
|
|
|
|
LFREEPATH(path);
|
|
|
|
LFREEPATH(to);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
linux_readlink(struct thread *td, struct linux_readlink_args *args)
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
{
|
2002-09-01 22:30:27 +00:00
|
|
|
char *name;
|
|
|
|
int error;
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
2002-09-01 22:30:27 +00:00
|
|
|
LCONVPATHEXIST(td, args->name, &name);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
if (ldebug(readlink))
|
2002-09-01 22:30:27 +00:00
|
|
|
printf(ARGS(readlink, "%s, %p, %d"), name, (void *)args->buf,
|
|
|
|
args->count);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
#endif
|
2014-11-13 18:01:51 +00:00
|
|
|
error = kern_readlinkat(td, AT_FDCWD, name, UIO_SYSSPACE,
|
|
|
|
args->buf, UIO_USERSPACE, args->count);
|
2002-09-01 22:30:27 +00:00
|
|
|
LFREEPATH(name);
|
|
|
|
return (error);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
}
|
|
|
|
|
Implement the linux syscalls
openat, mkdirat, mknodat, fchownat, futimesat, fstatat, unlinkat,
renameat, linkat, symlinkat, readlinkat, fchmodat, faccessat.
Submitted by: rdivacky
Sponsored by: Google Summer of Code 2007
Tested by: pho
2008-04-08 09:45:49 +00:00
|
|
|
int
|
|
|
|
linux_readlinkat(struct thread *td, struct linux_readlinkat_args *args)
|
|
|
|
{
|
|
|
|
char *name;
|
|
|
|
int error, dfd;
|
|
|
|
|
|
|
|
dfd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->dfd;
|
|
|
|
LCONVPATHEXIST_AT(td, args->path, &name, dfd);
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (ldebug(readlinkat))
|
|
|
|
printf(ARGS(readlinkat, "%s, %p, %d"), name, (void *)args->buf,
|
|
|
|
args->bufsiz);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
error = kern_readlinkat(td, dfd, name, UIO_SYSSPACE, args->buf,
|
|
|
|
UIO_USERSPACE, args->bufsiz);
|
|
|
|
LFREEPATH(name);
|
|
|
|
return (error);
|
|
|
|
}
|
2008-04-23 15:56:33 +00:00
|
|
|
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
linux_truncate(struct thread *td, struct linux_truncate_args *args)
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
{
|
2002-09-01 22:30:27 +00:00
|
|
|
char *path;
|
|
|
|
int error;
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
2002-09-01 22:30:27 +00:00
|
|
|
LCONVPATHEXIST(td, args->path, &path);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
if (ldebug(truncate))
|
2002-09-01 22:30:27 +00:00
|
|
|
printf(ARGS(truncate, "%s, %ld"), path, (long)args->length);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
#endif
|
|
|
|
|
2002-09-01 22:30:27 +00:00
|
|
|
error = kern_truncate(td, path, UIO_SYSSPACE, args->length);
|
|
|
|
LFREEPATH(path);
|
|
|
|
return (error);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
}
|
|
|
|
|
2015-05-24 15:43:53 +00:00
|
|
|
#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
|
2008-04-23 15:56:33 +00:00
|
|
|
int
|
|
|
|
linux_truncate64(struct thread *td, struct linux_truncate64_args *args)
|
|
|
|
{
|
|
|
|
char *path;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
LCONVPATHEXIST(td, args->path, &path);
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (ldebug(truncate64))
|
|
|
|
printf(ARGS(truncate64, "%s, %jd"), path, args->length);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
error = kern_truncate(td, path, UIO_SYSSPACE, args->length);
|
|
|
|
LFREEPATH(path);
|
|
|
|
return (error);
|
|
|
|
}
|
2015-05-24 15:43:53 +00:00
|
|
|
#endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */
|
|
|
|
|
2006-03-18 18:20:17 +00:00
|
|
|
int
|
|
|
|
linux_ftruncate(struct thread *td, struct linux_ftruncate_args *args)
|
|
|
|
{
|
2016-05-22 12:26:03 +00:00
|
|
|
|
2017-01-30 11:50:54 +00:00
|
|
|
return (kern_ftruncate(td, args->fd, args->length));
|
2006-03-18 18:20:17 +00:00
|
|
|
}
|
|
|
|
|
1999-08-12 19:53:33 +00:00
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
linux_link(struct thread *td, struct linux_link_args *args)
|
1999-08-12 19:53:33 +00:00
|
|
|
{
|
2002-09-01 22:30:27 +00:00
|
|
|
char *path, *to;
|
|
|
|
int error;
|
1999-08-12 19:53:33 +00:00
|
|
|
|
2002-09-01 22:30:27 +00:00
|
|
|
LCONVPATHEXIST(td, args->path, &path);
|
|
|
|
/* Expand LCONVPATHCREATE so that `path' can be freed on errors */
|
Implement the linux syscalls
openat, mkdirat, mknodat, fchownat, futimesat, fstatat, unlinkat,
renameat, linkat, symlinkat, readlinkat, fchmodat, faccessat.
Submitted by: rdivacky
Sponsored by: Google Summer of Code 2007
Tested by: pho
2008-04-08 09:45:49 +00:00
|
|
|
error = linux_emul_convpath(td, args->to, UIO_USERSPACE, &to, 1, AT_FDCWD);
|
2002-09-01 22:30:27 +00:00
|
|
|
if (to == NULL) {
|
|
|
|
LFREEPATH(path);
|
|
|
|
return (error);
|
|
|
|
}
|
1999-08-12 19:53:33 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
if (ldebug(link))
|
2002-09-01 22:30:27 +00:00
|
|
|
printf(ARGS(link, "%s, %s"), path, to);
|
1999-08-12 19:53:33 +00:00
|
|
|
#endif
|
2014-11-13 18:01:51 +00:00
|
|
|
error = kern_linkat(td, AT_FDCWD, AT_FDCWD, path, to, UIO_SYSSPACE,
|
|
|
|
FOLLOW);
|
2002-09-01 22:30:27 +00:00
|
|
|
LFREEPATH(path);
|
|
|
|
LFREEPATH(to);
|
|
|
|
return (error);
|
1999-08-12 19:53:33 +00:00
|
|
|
}
|
1999-08-14 18:20:44 +00:00
|
|
|
|
Implement the linux syscalls
openat, mkdirat, mknodat, fchownat, futimesat, fstatat, unlinkat,
renameat, linkat, symlinkat, readlinkat, fchmodat, faccessat.
Submitted by: rdivacky
Sponsored by: Google Summer of Code 2007
Tested by: pho
2008-04-08 09:45:49 +00:00
|
|
|
int
|
|
|
|
linux_linkat(struct thread *td, struct linux_linkat_args *args)
|
|
|
|
{
|
|
|
|
char *path, *to;
|
2011-11-19 07:19:37 +00:00
|
|
|
int error, olddfd, newdfd, follow;
|
Implement the linux syscalls
openat, mkdirat, mknodat, fchownat, futimesat, fstatat, unlinkat,
renameat, linkat, symlinkat, readlinkat, fchmodat, faccessat.
Submitted by: rdivacky
Sponsored by: Google Summer of Code 2007
Tested by: pho
2008-04-08 09:45:49 +00:00
|
|
|
|
2011-11-19 07:19:37 +00:00
|
|
|
if (args->flag & ~LINUX_AT_SYMLINK_FOLLOW)
|
Implement the linux syscalls
openat, mkdirat, mknodat, fchownat, futimesat, fstatat, unlinkat,
renameat, linkat, symlinkat, readlinkat, fchmodat, faccessat.
Submitted by: rdivacky
Sponsored by: Google Summer of Code 2007
Tested by: pho
2008-04-08 09:45:49 +00:00
|
|
|
return (EINVAL);
|
|
|
|
|
|
|
|
olddfd = (args->olddfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->olddfd;
|
|
|
|
newdfd = (args->newdfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->newdfd;
|
|
|
|
LCONVPATHEXIST_AT(td, args->oldname, &path, olddfd);
|
|
|
|
/* Expand LCONVPATHCREATE so that `path' can be freed on errors */
|
|
|
|
error = linux_emul_convpath(td, args->newname, UIO_USERSPACE, &to, 1, newdfd);
|
|
|
|
if (to == NULL) {
|
|
|
|
LFREEPATH(path);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (ldebug(linkat))
|
|
|
|
printf(ARGS(linkat, "%i, %s, %i, %s, %i"), args->olddfd, path,
|
2011-11-19 07:19:37 +00:00
|
|
|
args->newdfd, to, args->flag);
|
Implement the linux syscalls
openat, mkdirat, mknodat, fchownat, futimesat, fstatat, unlinkat,
renameat, linkat, symlinkat, readlinkat, fchmodat, faccessat.
Submitted by: rdivacky
Sponsored by: Google Summer of Code 2007
Tested by: pho
2008-04-08 09:45:49 +00:00
|
|
|
#endif
|
|
|
|
|
2011-11-19 07:19:37 +00:00
|
|
|
follow = (args->flag & LINUX_AT_SYMLINK_FOLLOW) == 0 ? NOFOLLOW :
|
|
|
|
FOLLOW;
|
|
|
|
error = kern_linkat(td, olddfd, newdfd, path, to, UIO_SYSSPACE, follow);
|
Implement the linux syscalls
openat, mkdirat, mknodat, fchownat, futimesat, fstatat, unlinkat,
renameat, linkat, symlinkat, readlinkat, fchmodat, faccessat.
Submitted by: rdivacky
Sponsored by: Google Summer of Code 2007
Tested by: pho
2008-04-08 09:45:49 +00:00
|
|
|
LFREEPATH(path);
|
|
|
|
LFREEPATH(to);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
1999-11-26 10:20:10 +00:00
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
linux_fdatasync(td, uap)
|
|
|
|
struct thread *td;
|
1999-11-26 10:20:10 +00:00
|
|
|
struct linux_fdatasync_args *uap;
|
|
|
|
{
|
|
|
|
|
2016-08-15 20:11:52 +00:00
|
|
|
return (kern_fsync(td, uap->fd, false));
|
1999-11-26 10:20:10 +00:00
|
|
|
}
|
2000-07-17 00:17:07 +00:00
|
|
|
|
|
|
|
int
|
2017-01-31 15:35:18 +00:00
|
|
|
linux_pread(struct thread *td, struct linux_pread_args *uap)
|
2000-07-17 00:17:07 +00:00
|
|
|
{
|
2006-09-23 19:06:54 +00:00
|
|
|
struct vnode *vp;
|
|
|
|
int error;
|
2000-07-17 00:17:07 +00:00
|
|
|
|
2017-01-31 15:35:18 +00:00
|
|
|
error = kern_pread(td, uap->fd, uap->buf, uap->nbyte, uap->offset);
|
2006-09-23 19:06:54 +00:00
|
|
|
if (error == 0) {
|
2018-02-22 02:24:17 +00:00
|
|
|
/* This seems to violate POSIX but Linux does it. */
|
2018-05-09 18:47:24 +00:00
|
|
|
error = fgetvp(td, uap->fd, &cap_pread_rights, &vp);
|
Change the cap_rights_t type from uint64_t to a structure that we can extend
in the future in a backward compatible (API and ABI) way.
The cap_rights_t represents capability rights. We used to use one bit to
represent one right, but we are running out of spare bits. Currently the new
structure provides place for 114 rights (so 50 more than the previous
cap_rights_t), but it is possible to grow the structure to hold at least 285
rights, although we can make it even larger if 285 rights won't be enough.
The structure definition looks like this:
struct cap_rights {
uint64_t cr_rights[CAP_RIGHTS_VERSION + 2];
};
The initial CAP_RIGHTS_VERSION is 0.
The top two bits in the first element of the cr_rights[] array contain total
number of elements in the array - 2. This means if those two bits are equal to
0, we have 2 array elements.
The top two bits in all remaining array elements should be 0.
The next five bits in all array elements contain array index. Only one bit is
used and bit position in this five-bits range defines array index. This means
there can be at most five array elements in the future.
To define new right the CAPRIGHT() macro must be used. The macro takes two
arguments - an array index and a bit to set, eg.
#define CAP_PDKILL CAPRIGHT(1, 0x0000000000000800ULL)
We still support aliases that combine few rights, but the rights have to belong
to the same array element, eg:
#define CAP_LOOKUP CAPRIGHT(0, 0x0000000000000400ULL)
#define CAP_FCHMOD CAPRIGHT(0, 0x0000000000002000ULL)
#define CAP_FCHMODAT (CAP_FCHMOD | CAP_LOOKUP)
There is new API to manage the new cap_rights_t structure:
cap_rights_t *cap_rights_init(cap_rights_t *rights, ...);
void cap_rights_set(cap_rights_t *rights, ...);
void cap_rights_clear(cap_rights_t *rights, ...);
bool cap_rights_is_set(const cap_rights_t *rights, ...);
bool cap_rights_is_valid(const cap_rights_t *rights);
void cap_rights_merge(cap_rights_t *dst, const cap_rights_t *src);
void cap_rights_remove(cap_rights_t *dst, const cap_rights_t *src);
bool cap_rights_contains(const cap_rights_t *big, const cap_rights_t *little);
Capability rights to the cap_rights_init(), cap_rights_set(),
cap_rights_clear() and cap_rights_is_set() functions are provided by
separating them with commas, eg:
cap_rights_t rights;
cap_rights_init(&rights, CAP_READ, CAP_WRITE, CAP_FSTAT);
There is no need to terminate the list of rights, as those functions are
actually macros that take care of the termination, eg:
#define cap_rights_set(rights, ...) \
__cap_rights_set((rights), __VA_ARGS__, 0ULL)
void __cap_rights_set(cap_rights_t *rights, ...);
Thanks to using one bit as an array index we can assert in those functions that
there are no two rights belonging to different array elements provided
together. For example this is illegal and will be detected, because CAP_LOOKUP
belongs to element 0 and CAP_PDKILL to element 1:
cap_rights_init(&rights, CAP_LOOKUP | CAP_PDKILL);
Providing several rights that belongs to the same array's element this way is
correct, but is not advised. It should only be used for aliases definition.
This commit also breaks compatibility with some existing Capsicum system calls,
but I see no other way to do that. This should be fine as Capsicum is still
experimental and this change is not going to 9.x.
Sponsored by: The FreeBSD Foundation
2013-09-05 00:09:56 +00:00
|
|
|
if (error != 0)
|
Merge Capsicum overhaul:
- Capability is no longer separate descriptor type. Now every descriptor
has set of its own capability rights.
- The cap_new(2) system call is left, but it is no longer documented and
should not be used in new code.
- The new syscall cap_rights_limit(2) should be used instead of
cap_new(2), which limits capability rights of the given descriptor
without creating a new one.
- The cap_getrights(2) syscall is renamed to cap_rights_get(2).
- If CAP_IOCTL capability right is present we can further reduce allowed
ioctls list with the new cap_ioctls_limit(2) syscall. List of allowed
ioctls can be retrived with cap_ioctls_get(2) syscall.
- If CAP_FCNTL capability right is present we can further reduce fcntls
that can be used with the new cap_fcntls_limit(2) syscall and retrive
them with cap_fcntls_get(2).
- To support ioctl and fcntl white-listing the filedesc structure was
heavly modified.
- The audit subsystem, kdump and procstat tools were updated to
recognize new syscalls.
- Capability rights were revised and eventhough I tried hard to provide
backward API and ABI compatibility there are some incompatible changes
that are described in detail below:
CAP_CREATE old behaviour:
- Allow for openat(2)+O_CREAT.
- Allow for linkat(2).
- Allow for symlinkat(2).
CAP_CREATE new behaviour:
- Allow for openat(2)+O_CREAT.
Added CAP_LINKAT:
- Allow for linkat(2). ABI: Reuses CAP_RMDIR bit.
- Allow to be target for renameat(2).
Added CAP_SYMLINKAT:
- Allow for symlinkat(2).
Removed CAP_DELETE. Old behaviour:
- Allow for unlinkat(2) when removing non-directory object.
- Allow to be source for renameat(2).
Removed CAP_RMDIR. Old behaviour:
- Allow for unlinkat(2) when removing directory.
Added CAP_RENAMEAT:
- Required for source directory for the renameat(2) syscall.
Added CAP_UNLINKAT (effectively it replaces CAP_DELETE and CAP_RMDIR):
- Allow for unlinkat(2) on any object.
- Required if target of renameat(2) exists and will be removed by this
call.
Removed CAP_MAPEXEC.
CAP_MMAP old behaviour:
- Allow for mmap(2) with any combination of PROT_NONE, PROT_READ and
PROT_WRITE.
CAP_MMAP new behaviour:
- Allow for mmap(2)+PROT_NONE.
Added CAP_MMAP_R:
- Allow for mmap(PROT_READ).
Added CAP_MMAP_W:
- Allow for mmap(PROT_WRITE).
Added CAP_MMAP_X:
- Allow for mmap(PROT_EXEC).
Added CAP_MMAP_RW:
- Allow for mmap(PROT_READ | PROT_WRITE).
Added CAP_MMAP_RX:
- Allow for mmap(PROT_READ | PROT_EXEC).
Added CAP_MMAP_WX:
- Allow for mmap(PROT_WRITE | PROT_EXEC).
Added CAP_MMAP_RWX:
- Allow for mmap(PROT_READ | PROT_WRITE | PROT_EXEC).
Renamed CAP_MKDIR to CAP_MKDIRAT.
Renamed CAP_MKFIFO to CAP_MKFIFOAT.
Renamed CAP_MKNODE to CAP_MKNODEAT.
CAP_READ old behaviour:
- Allow pread(2).
- Disallow read(2), readv(2) (if there is no CAP_SEEK).
CAP_READ new behaviour:
- Allow read(2), readv(2).
- Disallow pread(2) (CAP_SEEK was also required).
CAP_WRITE old behaviour:
- Allow pwrite(2).
- Disallow write(2), writev(2) (if there is no CAP_SEEK).
CAP_WRITE new behaviour:
- Allow write(2), writev(2).
- Disallow pwrite(2) (CAP_SEEK was also required).
Added convinient defines:
#define CAP_PREAD (CAP_SEEK | CAP_READ)
#define CAP_PWRITE (CAP_SEEK | CAP_WRITE)
#define CAP_MMAP_R (CAP_MMAP | CAP_SEEK | CAP_READ)
#define CAP_MMAP_W (CAP_MMAP | CAP_SEEK | CAP_WRITE)
#define CAP_MMAP_X (CAP_MMAP | CAP_SEEK | 0x0000000000000008ULL)
#define CAP_MMAP_RW (CAP_MMAP_R | CAP_MMAP_W)
#define CAP_MMAP_RX (CAP_MMAP_R | CAP_MMAP_X)
#define CAP_MMAP_WX (CAP_MMAP_W | CAP_MMAP_X)
#define CAP_MMAP_RWX (CAP_MMAP_R | CAP_MMAP_W | CAP_MMAP_X)
#define CAP_RECV CAP_READ
#define CAP_SEND CAP_WRITE
#define CAP_SOCK_CLIENT \
(CAP_CONNECT | CAP_GETPEERNAME | CAP_GETSOCKNAME | CAP_GETSOCKOPT | \
CAP_PEELOFF | CAP_RECV | CAP_SEND | CAP_SETSOCKOPT | CAP_SHUTDOWN)
#define CAP_SOCK_SERVER \
(CAP_ACCEPT | CAP_BIND | CAP_GETPEERNAME | CAP_GETSOCKNAME | \
CAP_GETSOCKOPT | CAP_LISTEN | CAP_PEELOFF | CAP_RECV | CAP_SEND | \
CAP_SETSOCKOPT | CAP_SHUTDOWN)
Added defines for backward API compatibility:
#define CAP_MAPEXEC CAP_MMAP_X
#define CAP_DELETE CAP_UNLINKAT
#define CAP_MKDIR CAP_MKDIRAT
#define CAP_RMDIR CAP_UNLINKAT
#define CAP_MKFIFO CAP_MKFIFOAT
#define CAP_MKNOD CAP_MKNODAT
#define CAP_SOCK_ALL (CAP_SOCK_CLIENT | CAP_SOCK_SERVER)
Sponsored by: The FreeBSD Foundation
Reviewed by: Christoph Mallon <christoph.mallon@gmx.de>
Many aspects discussed with: rwatson, benl, jonathan
ABI compatibility discussed with: kib
2013-03-02 00:53:12 +00:00
|
|
|
return (error);
|
2006-09-23 19:06:54 +00:00
|
|
|
if (vp->v_type == VDIR) {
|
Merge Capsicum overhaul:
- Capability is no longer separate descriptor type. Now every descriptor
has set of its own capability rights.
- The cap_new(2) system call is left, but it is no longer documented and
should not be used in new code.
- The new syscall cap_rights_limit(2) should be used instead of
cap_new(2), which limits capability rights of the given descriptor
without creating a new one.
- The cap_getrights(2) syscall is renamed to cap_rights_get(2).
- If CAP_IOCTL capability right is present we can further reduce allowed
ioctls list with the new cap_ioctls_limit(2) syscall. List of allowed
ioctls can be retrived with cap_ioctls_get(2) syscall.
- If CAP_FCNTL capability right is present we can further reduce fcntls
that can be used with the new cap_fcntls_limit(2) syscall and retrive
them with cap_fcntls_get(2).
- To support ioctl and fcntl white-listing the filedesc structure was
heavly modified.
- The audit subsystem, kdump and procstat tools were updated to
recognize new syscalls.
- Capability rights were revised and eventhough I tried hard to provide
backward API and ABI compatibility there are some incompatible changes
that are described in detail below:
CAP_CREATE old behaviour:
- Allow for openat(2)+O_CREAT.
- Allow for linkat(2).
- Allow for symlinkat(2).
CAP_CREATE new behaviour:
- Allow for openat(2)+O_CREAT.
Added CAP_LINKAT:
- Allow for linkat(2). ABI: Reuses CAP_RMDIR bit.
- Allow to be target for renameat(2).
Added CAP_SYMLINKAT:
- Allow for symlinkat(2).
Removed CAP_DELETE. Old behaviour:
- Allow for unlinkat(2) when removing non-directory object.
- Allow to be source for renameat(2).
Removed CAP_RMDIR. Old behaviour:
- Allow for unlinkat(2) when removing directory.
Added CAP_RENAMEAT:
- Required for source directory for the renameat(2) syscall.
Added CAP_UNLINKAT (effectively it replaces CAP_DELETE and CAP_RMDIR):
- Allow for unlinkat(2) on any object.
- Required if target of renameat(2) exists and will be removed by this
call.
Removed CAP_MAPEXEC.
CAP_MMAP old behaviour:
- Allow for mmap(2) with any combination of PROT_NONE, PROT_READ and
PROT_WRITE.
CAP_MMAP new behaviour:
- Allow for mmap(2)+PROT_NONE.
Added CAP_MMAP_R:
- Allow for mmap(PROT_READ).
Added CAP_MMAP_W:
- Allow for mmap(PROT_WRITE).
Added CAP_MMAP_X:
- Allow for mmap(PROT_EXEC).
Added CAP_MMAP_RW:
- Allow for mmap(PROT_READ | PROT_WRITE).
Added CAP_MMAP_RX:
- Allow for mmap(PROT_READ | PROT_EXEC).
Added CAP_MMAP_WX:
- Allow for mmap(PROT_WRITE | PROT_EXEC).
Added CAP_MMAP_RWX:
- Allow for mmap(PROT_READ | PROT_WRITE | PROT_EXEC).
Renamed CAP_MKDIR to CAP_MKDIRAT.
Renamed CAP_MKFIFO to CAP_MKFIFOAT.
Renamed CAP_MKNODE to CAP_MKNODEAT.
CAP_READ old behaviour:
- Allow pread(2).
- Disallow read(2), readv(2) (if there is no CAP_SEEK).
CAP_READ new behaviour:
- Allow read(2), readv(2).
- Disallow pread(2) (CAP_SEEK was also required).
CAP_WRITE old behaviour:
- Allow pwrite(2).
- Disallow write(2), writev(2) (if there is no CAP_SEEK).
CAP_WRITE new behaviour:
- Allow write(2), writev(2).
- Disallow pwrite(2) (CAP_SEEK was also required).
Added convinient defines:
#define CAP_PREAD (CAP_SEEK | CAP_READ)
#define CAP_PWRITE (CAP_SEEK | CAP_WRITE)
#define CAP_MMAP_R (CAP_MMAP | CAP_SEEK | CAP_READ)
#define CAP_MMAP_W (CAP_MMAP | CAP_SEEK | CAP_WRITE)
#define CAP_MMAP_X (CAP_MMAP | CAP_SEEK | 0x0000000000000008ULL)
#define CAP_MMAP_RW (CAP_MMAP_R | CAP_MMAP_W)
#define CAP_MMAP_RX (CAP_MMAP_R | CAP_MMAP_X)
#define CAP_MMAP_WX (CAP_MMAP_W | CAP_MMAP_X)
#define CAP_MMAP_RWX (CAP_MMAP_R | CAP_MMAP_W | CAP_MMAP_X)
#define CAP_RECV CAP_READ
#define CAP_SEND CAP_WRITE
#define CAP_SOCK_CLIENT \
(CAP_CONNECT | CAP_GETPEERNAME | CAP_GETSOCKNAME | CAP_GETSOCKOPT | \
CAP_PEELOFF | CAP_RECV | CAP_SEND | CAP_SETSOCKOPT | CAP_SHUTDOWN)
#define CAP_SOCK_SERVER \
(CAP_ACCEPT | CAP_BIND | CAP_GETPEERNAME | CAP_GETSOCKNAME | \
CAP_GETSOCKOPT | CAP_LISTEN | CAP_PEELOFF | CAP_RECV | CAP_SEND | \
CAP_SETSOCKOPT | CAP_SHUTDOWN)
Added defines for backward API compatibility:
#define CAP_MAPEXEC CAP_MMAP_X
#define CAP_DELETE CAP_UNLINKAT
#define CAP_MKDIR CAP_MKDIRAT
#define CAP_RMDIR CAP_UNLINKAT
#define CAP_MKFIFO CAP_MKFIFOAT
#define CAP_MKNOD CAP_MKNODAT
#define CAP_SOCK_ALL (CAP_SOCK_CLIENT | CAP_SOCK_SERVER)
Sponsored by: The FreeBSD Foundation
Reviewed by: Christoph Mallon <christoph.mallon@gmx.de>
Many aspects discussed with: rwatson, benl, jonathan
ABI compatibility discussed with: kib
2013-03-02 00:53:12 +00:00
|
|
|
vrele(vp);
|
2006-09-23 19:06:54 +00:00
|
|
|
return (EISDIR);
|
|
|
|
}
|
|
|
|
vrele(vp);
|
|
|
|
}
|
|
|
|
return (error);
|
2000-07-17 00:17:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2017-01-31 15:35:18 +00:00
|
|
|
linux_pwrite(struct thread *td, struct linux_pwrite_args *uap)
|
2000-07-17 00:17:07 +00:00
|
|
|
{
|
|
|
|
|
2017-01-31 15:35:18 +00:00
|
|
|
return (kern_pwrite(td, uap->fd, uap->buf, uap->nbyte, uap->offset));
|
2000-07-17 00:17:07 +00:00
|
|
|
}
|
2001-02-16 14:42:11 +00:00
|
|
|
|
2017-02-24 20:04:02 +00:00
|
|
|
int
|
|
|
|
linux_preadv(struct thread *td, struct linux_preadv_args *uap)
|
|
|
|
{
|
|
|
|
struct uio *auio;
|
|
|
|
int error;
|
|
|
|
off_t offset;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* According http://man7.org/linux/man-pages/man2/preadv.2.html#NOTES
|
|
|
|
* pos_l and pos_h, respectively, contain the
|
|
|
|
* low order and high order 32 bits of offset.
|
|
|
|
*/
|
|
|
|
offset = (((off_t)uap->pos_h << (sizeof(offset) * 4)) <<
|
|
|
|
(sizeof(offset) * 4)) | uap->pos_l;
|
|
|
|
if (offset < 0)
|
|
|
|
return (EINVAL);
|
|
|
|
#ifdef COMPAT_LINUX32
|
|
|
|
error = linux32_copyinuio(PTRIN(uap->vec), uap->vlen, &auio);
|
|
|
|
#else
|
|
|
|
error = copyinuio(uap->vec, uap->vlen, &auio);
|
|
|
|
#endif
|
|
|
|
if (error != 0)
|
|
|
|
return (error);
|
|
|
|
error = kern_preadv(td, uap->fd, auio, offset);
|
|
|
|
free(auio, M_IOV);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
linux_pwritev(struct thread *td, struct linux_pwritev_args *uap)
|
|
|
|
{
|
|
|
|
struct uio *auio;
|
|
|
|
int error;
|
|
|
|
off_t offset;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* According http://man7.org/linux/man-pages/man2/pwritev.2.html#NOTES
|
|
|
|
* pos_l and pos_h, respectively, contain the
|
|
|
|
* low order and high order 32 bits of offset.
|
|
|
|
*/
|
|
|
|
offset = (((off_t)uap->pos_h << (sizeof(offset) * 4)) <<
|
|
|
|
(sizeof(offset) * 4)) | uap->pos_l;
|
|
|
|
if (offset < 0)
|
|
|
|
return (EINVAL);
|
|
|
|
#ifdef COMPAT_LINUX32
|
|
|
|
error = linux32_copyinuio(PTRIN(uap->vec), uap->vlen, &auio);
|
|
|
|
#else
|
|
|
|
error = copyinuio(uap->vec, uap->vlen, &auio);
|
|
|
|
#endif
|
|
|
|
if (error != 0)
|
|
|
|
return (error);
|
|
|
|
error = kern_pwritev(td, uap->fd, auio, offset);
|
|
|
|
free(auio, M_IOV);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
2001-02-16 14:42:11 +00:00
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
linux_mount(struct thread *td, struct linux_mount_args *args)
|
2001-02-16 14:42:11 +00:00
|
|
|
{
|
2003-03-03 09:17:12 +00:00
|
|
|
char fstypename[MFSNAMELEN];
|
Commit the 64-bit inode project.
Extend the ino_t, dev_t, nlink_t types to 64-bit ints. Modify
struct dirent layout to add d_off, increase the size of d_fileno
to 64-bits, increase the size of d_namlen to 16-bits, and change
the required alignment. Increase struct statfs f_mntfromname[] and
f_mntonname[] array length MNAMELEN to 1024.
ABI breakage is mitigated by providing compatibility using versioned
symbols, ingenious use of the existing padding in structures, and
by employing other tricks. Unfortunately, not everything can be
fixed, especially outside the base system. For instance, third-party
APIs which pass struct stat around are broken in backward and
forward incompatible ways.
Kinfo sysctl MIBs ABI is changed in backward-compatible way, but
there is no general mechanism to handle other sysctl MIBS which
return structures where the layout has changed. It was considered
that the breakage is either in the management interfaces, where we
usually allow ABI slip, or is not important.
Struct xvnode changed layout, no compat shims are provided.
For struct xtty, dev_t tty device member was reduced to uint32_t.
It was decided that keeping ABI compat in this case is more useful
than reporting 64-bit dev_t, for the sake of pstat.
Update note: strictly follow the instructions in UPDATING. Build
and install the new kernel with COMPAT_FREEBSD11 option enabled,
then reboot, and only then install new world.
Credits: The 64-bit inode project, also known as ino64, started life
many years ago as a project by Gleb Kurtsou (gleb). Kirk McKusick
(mckusick) then picked up and updated the patch, and acted as a
flag-waver. Feedback, suggestions, and discussions were carried
by Ed Maste (emaste), John Baldwin (jhb), Jilles Tjoelker (jilles),
and Rick Macklem (rmacklem). Kris Moore (kris) performed an initial
ports investigation followed by an exp-run by Antoine Brodin (antoine).
Essential and all-embracing testing was done by Peter Holm (pho).
The heavy lifting of coordinating all these efforts and bringing the
project to completion were done by Konstantin Belousov (kib).
Sponsored by: The FreeBSD Foundation (emaste, kib)
Differential revision: https://reviews.freebsd.org/D10439
2017-05-23 09:29:05 +00:00
|
|
|
char *mntonname, *mntfromname;
|
|
|
|
int error, fsflags;
|
2001-02-16 14:42:11 +00:00
|
|
|
|
Commit the 64-bit inode project.
Extend the ino_t, dev_t, nlink_t types to 64-bit ints. Modify
struct dirent layout to add d_off, increase the size of d_fileno
to 64-bits, increase the size of d_namlen to 16-bits, and change
the required alignment. Increase struct statfs f_mntfromname[] and
f_mntonname[] array length MNAMELEN to 1024.
ABI breakage is mitigated by providing compatibility using versioned
symbols, ingenious use of the existing padding in structures, and
by employing other tricks. Unfortunately, not everything can be
fixed, especially outside the base system. For instance, third-party
APIs which pass struct stat around are broken in backward and
forward incompatible ways.
Kinfo sysctl MIBs ABI is changed in backward-compatible way, but
there is no general mechanism to handle other sysctl MIBS which
return structures where the layout has changed. It was considered
that the breakage is either in the management interfaces, where we
usually allow ABI slip, or is not important.
Struct xvnode changed layout, no compat shims are provided.
For struct xtty, dev_t tty device member was reduced to uint32_t.
It was decided that keeping ABI compat in this case is more useful
than reporting 64-bit dev_t, for the sake of pstat.
Update note: strictly follow the instructions in UPDATING. Build
and install the new kernel with COMPAT_FREEBSD11 option enabled,
then reboot, and only then install new world.
Credits: The 64-bit inode project, also known as ino64, started life
many years ago as a project by Gleb Kurtsou (gleb). Kirk McKusick
(mckusick) then picked up and updated the patch, and acted as a
flag-waver. Feedback, suggestions, and discussions were carried
by Ed Maste (emaste), John Baldwin (jhb), Jilles Tjoelker (jilles),
and Rick Macklem (rmacklem). Kris Moore (kris) performed an initial
ports investigation followed by an exp-run by Antoine Brodin (antoine).
Essential and all-embracing testing was done by Peter Holm (pho).
The heavy lifting of coordinating all these efforts and bringing the
project to completion were done by Konstantin Belousov (kib).
Sponsored by: The FreeBSD Foundation (emaste, kib)
Differential revision: https://reviews.freebsd.org/D10439
2017-05-23 09:29:05 +00:00
|
|
|
mntonname = malloc(MNAMELEN, M_TEMP, M_WAITOK);
|
|
|
|
mntfromname = malloc(MNAMELEN, M_TEMP, M_WAITOK);
|
2003-03-03 09:17:12 +00:00
|
|
|
error = copyinstr(args->filesystemtype, fstypename, MFSNAMELEN - 1,
|
2001-03-01 21:00:17 +00:00
|
|
|
NULL);
|
Commit the 64-bit inode project.
Extend the ino_t, dev_t, nlink_t types to 64-bit ints. Modify
struct dirent layout to add d_off, increase the size of d_fileno
to 64-bits, increase the size of d_namlen to 16-bits, and change
the required alignment. Increase struct statfs f_mntfromname[] and
f_mntonname[] array length MNAMELEN to 1024.
ABI breakage is mitigated by providing compatibility using versioned
symbols, ingenious use of the existing padding in structures, and
by employing other tricks. Unfortunately, not everything can be
fixed, especially outside the base system. For instance, third-party
APIs which pass struct stat around are broken in backward and
forward incompatible ways.
Kinfo sysctl MIBs ABI is changed in backward-compatible way, but
there is no general mechanism to handle other sysctl MIBS which
return structures where the layout has changed. It was considered
that the breakage is either in the management interfaces, where we
usually allow ABI slip, or is not important.
Struct xvnode changed layout, no compat shims are provided.
For struct xtty, dev_t tty device member was reduced to uint32_t.
It was decided that keeping ABI compat in this case is more useful
than reporting 64-bit dev_t, for the sake of pstat.
Update note: strictly follow the instructions in UPDATING. Build
and install the new kernel with COMPAT_FREEBSD11 option enabled,
then reboot, and only then install new world.
Credits: The 64-bit inode project, also known as ino64, started life
many years ago as a project by Gleb Kurtsou (gleb). Kirk McKusick
(mckusick) then picked up and updated the patch, and acted as a
flag-waver. Feedback, suggestions, and discussions were carried
by Ed Maste (emaste), John Baldwin (jhb), Jilles Tjoelker (jilles),
and Rick Macklem (rmacklem). Kris Moore (kris) performed an initial
ports investigation followed by an exp-run by Antoine Brodin (antoine).
Essential and all-embracing testing was done by Peter Holm (pho).
The heavy lifting of coordinating all these efforts and bringing the
project to completion were done by Konstantin Belousov (kib).
Sponsored by: The FreeBSD Foundation (emaste, kib)
Differential revision: https://reviews.freebsd.org/D10439
2017-05-23 09:29:05 +00:00
|
|
|
if (error != 0)
|
|
|
|
goto out;
|
2004-03-16 08:37:19 +00:00
|
|
|
error = copyinstr(args->specialfile, mntfromname, MNAMELEN - 1, NULL);
|
Commit the 64-bit inode project.
Extend the ino_t, dev_t, nlink_t types to 64-bit ints. Modify
struct dirent layout to add d_off, increase the size of d_fileno
to 64-bits, increase the size of d_namlen to 16-bits, and change
the required alignment. Increase struct statfs f_mntfromname[] and
f_mntonname[] array length MNAMELEN to 1024.
ABI breakage is mitigated by providing compatibility using versioned
symbols, ingenious use of the existing padding in structures, and
by employing other tricks. Unfortunately, not everything can be
fixed, especially outside the base system. For instance, third-party
APIs which pass struct stat around are broken in backward and
forward incompatible ways.
Kinfo sysctl MIBs ABI is changed in backward-compatible way, but
there is no general mechanism to handle other sysctl MIBS which
return structures where the layout has changed. It was considered
that the breakage is either in the management interfaces, where we
usually allow ABI slip, or is not important.
Struct xvnode changed layout, no compat shims are provided.
For struct xtty, dev_t tty device member was reduced to uint32_t.
It was decided that keeping ABI compat in this case is more useful
than reporting 64-bit dev_t, for the sake of pstat.
Update note: strictly follow the instructions in UPDATING. Build
and install the new kernel with COMPAT_FREEBSD11 option enabled,
then reboot, and only then install new world.
Credits: The 64-bit inode project, also known as ino64, started life
many years ago as a project by Gleb Kurtsou (gleb). Kirk McKusick
(mckusick) then picked up and updated the patch, and acted as a
flag-waver. Feedback, suggestions, and discussions were carried
by Ed Maste (emaste), John Baldwin (jhb), Jilles Tjoelker (jilles),
and Rick Macklem (rmacklem). Kris Moore (kris) performed an initial
ports investigation followed by an exp-run by Antoine Brodin (antoine).
Essential and all-embracing testing was done by Peter Holm (pho).
The heavy lifting of coordinating all these efforts and bringing the
project to completion were done by Konstantin Belousov (kib).
Sponsored by: The FreeBSD Foundation (emaste, kib)
Differential revision: https://reviews.freebsd.org/D10439
2017-05-23 09:29:05 +00:00
|
|
|
if (error != 0)
|
|
|
|
goto out;
|
2004-03-16 08:37:19 +00:00
|
|
|
error = copyinstr(args->dir, mntonname, MNAMELEN - 1, NULL);
|
Commit the 64-bit inode project.
Extend the ino_t, dev_t, nlink_t types to 64-bit ints. Modify
struct dirent layout to add d_off, increase the size of d_fileno
to 64-bits, increase the size of d_namlen to 16-bits, and change
the required alignment. Increase struct statfs f_mntfromname[] and
f_mntonname[] array length MNAMELEN to 1024.
ABI breakage is mitigated by providing compatibility using versioned
symbols, ingenious use of the existing padding in structures, and
by employing other tricks. Unfortunately, not everything can be
fixed, especially outside the base system. For instance, third-party
APIs which pass struct stat around are broken in backward and
forward incompatible ways.
Kinfo sysctl MIBs ABI is changed in backward-compatible way, but
there is no general mechanism to handle other sysctl MIBS which
return structures where the layout has changed. It was considered
that the breakage is either in the management interfaces, where we
usually allow ABI slip, or is not important.
Struct xvnode changed layout, no compat shims are provided.
For struct xtty, dev_t tty device member was reduced to uint32_t.
It was decided that keeping ABI compat in this case is more useful
than reporting 64-bit dev_t, for the sake of pstat.
Update note: strictly follow the instructions in UPDATING. Build
and install the new kernel with COMPAT_FREEBSD11 option enabled,
then reboot, and only then install new world.
Credits: The 64-bit inode project, also known as ino64, started life
many years ago as a project by Gleb Kurtsou (gleb). Kirk McKusick
(mckusick) then picked up and updated the patch, and acted as a
flag-waver. Feedback, suggestions, and discussions were carried
by Ed Maste (emaste), John Baldwin (jhb), Jilles Tjoelker (jilles),
and Rick Macklem (rmacklem). Kris Moore (kris) performed an initial
ports investigation followed by an exp-run by Antoine Brodin (antoine).
Essential and all-embracing testing was done by Peter Holm (pho).
The heavy lifting of coordinating all these efforts and bringing the
project to completion were done by Konstantin Belousov (kib).
Sponsored by: The FreeBSD Foundation (emaste, kib)
Differential revision: https://reviews.freebsd.org/D10439
2017-05-23 09:29:05 +00:00
|
|
|
if (error != 0)
|
|
|
|
goto out;
|
2001-02-16 14:42:11 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (ldebug(mount))
|
|
|
|
printf(ARGS(mount, "%s, %s, %s"),
|
|
|
|
fstypename, mntfromname, mntonname);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (strcmp(fstypename, "ext2") == 0) {
|
2004-03-16 09:05:56 +00:00
|
|
|
strcpy(fstypename, "ext2fs");
|
2001-02-16 14:42:11 +00:00
|
|
|
} else if (strcmp(fstypename, "proc") == 0) {
|
2004-03-16 09:05:56 +00:00
|
|
|
strcpy(fstypename, "linprocfs");
|
2009-03-26 17:14:22 +00:00
|
|
|
} else if (strcmp(fstypename, "vfat") == 0) {
|
|
|
|
strcpy(fstypename, "msdosfs");
|
2001-02-16 14:42:11 +00:00
|
|
|
}
|
|
|
|
|
2001-03-01 21:00:17 +00:00
|
|
|
fsflags = 0;
|
2001-02-16 14:42:11 +00:00
|
|
|
|
|
|
|
if ((args->rwflag & 0xffff0000) == 0xc0ed0000) {
|
|
|
|
/*
|
|
|
|
* Linux SYNC flag is not included; the closest equivalent
|
|
|
|
* FreeBSD has is !ASYNC, which is our default.
|
|
|
|
*/
|
|
|
|
if (args->rwflag & LINUX_MS_RDONLY)
|
2003-03-03 09:17:12 +00:00
|
|
|
fsflags |= MNT_RDONLY;
|
2001-02-16 14:42:11 +00:00
|
|
|
if (args->rwflag & LINUX_MS_NOSUID)
|
2003-03-03 09:17:12 +00:00
|
|
|
fsflags |= MNT_NOSUID;
|
2001-02-16 14:42:11 +00:00
|
|
|
if (args->rwflag & LINUX_MS_NOEXEC)
|
2003-03-03 09:17:12 +00:00
|
|
|
fsflags |= MNT_NOEXEC;
|
2001-02-16 14:42:11 +00:00
|
|
|
if (args->rwflag & LINUX_MS_REMOUNT)
|
2003-03-03 09:17:12 +00:00
|
|
|
fsflags |= MNT_UPDATE;
|
2001-02-16 14:42:11 +00:00
|
|
|
}
|
|
|
|
|
2015-04-18 09:49:09 +00:00
|
|
|
error = kernel_vmount(fsflags,
|
|
|
|
"fstype", fstypename,
|
|
|
|
"fspath", mntonname,
|
|
|
|
"from", mntfromname,
|
|
|
|
NULL);
|
Commit the 64-bit inode project.
Extend the ino_t, dev_t, nlink_t types to 64-bit ints. Modify
struct dirent layout to add d_off, increase the size of d_fileno
to 64-bits, increase the size of d_namlen to 16-bits, and change
the required alignment. Increase struct statfs f_mntfromname[] and
f_mntonname[] array length MNAMELEN to 1024.
ABI breakage is mitigated by providing compatibility using versioned
symbols, ingenious use of the existing padding in structures, and
by employing other tricks. Unfortunately, not everything can be
fixed, especially outside the base system. For instance, third-party
APIs which pass struct stat around are broken in backward and
forward incompatible ways.
Kinfo sysctl MIBs ABI is changed in backward-compatible way, but
there is no general mechanism to handle other sysctl MIBS which
return structures where the layout has changed. It was considered
that the breakage is either in the management interfaces, where we
usually allow ABI slip, or is not important.
Struct xvnode changed layout, no compat shims are provided.
For struct xtty, dev_t tty device member was reduced to uint32_t.
It was decided that keeping ABI compat in this case is more useful
than reporting 64-bit dev_t, for the sake of pstat.
Update note: strictly follow the instructions in UPDATING. Build
and install the new kernel with COMPAT_FREEBSD11 option enabled,
then reboot, and only then install new world.
Credits: The 64-bit inode project, also known as ino64, started life
many years ago as a project by Gleb Kurtsou (gleb). Kirk McKusick
(mckusick) then picked up and updated the patch, and acted as a
flag-waver. Feedback, suggestions, and discussions were carried
by Ed Maste (emaste), John Baldwin (jhb), Jilles Tjoelker (jilles),
and Rick Macklem (rmacklem). Kris Moore (kris) performed an initial
ports investigation followed by an exp-run by Antoine Brodin (antoine).
Essential and all-embracing testing was done by Peter Holm (pho).
The heavy lifting of coordinating all these efforts and bringing the
project to completion were done by Konstantin Belousov (kib).
Sponsored by: The FreeBSD Foundation (emaste, kib)
Differential revision: https://reviews.freebsd.org/D10439
2017-05-23 09:29:05 +00:00
|
|
|
out:
|
|
|
|
free(mntonname, M_TEMP);
|
|
|
|
free(mntfromname, M_TEMP);
|
2004-03-16 09:05:56 +00:00
|
|
|
return (error);
|
2001-02-16 14:42:11 +00:00
|
|
|
}
|
|
|
|
|
2015-05-24 15:43:53 +00:00
|
|
|
#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
|
2001-02-16 14:42:11 +00:00
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
linux_oldumount(struct thread *td, struct linux_oldumount_args *args)
|
2001-02-16 14:42:11 +00:00
|
|
|
{
|
2001-09-08 19:07:04 +00:00
|
|
|
struct linux_umount_args args2;
|
2001-02-16 14:42:11 +00:00
|
|
|
|
|
|
|
args2.path = args->path;
|
|
|
|
args2.flags = 0;
|
2001-09-12 08:38:13 +00:00
|
|
|
return (linux_umount(td, &args2));
|
2001-02-16 14:42:11 +00:00
|
|
|
}
|
2015-05-24 15:43:53 +00:00
|
|
|
#endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */
|
2001-02-16 14:42:11 +00:00
|
|
|
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
linux_umount(struct thread *td, struct linux_umount_args *args)
|
2001-02-16 14:42:11 +00:00
|
|
|
{
|
|
|
|
struct unmount_args bsd;
|
|
|
|
|
|
|
|
bsd.path = args->path;
|
|
|
|
bsd.flags = args->flags; /* XXX correct? */
|
2011-09-16 13:58:51 +00:00
|
|
|
return (sys_unmount(td, &bsd));
|
2001-02-16 14:42:11 +00:00
|
|
|
}
|
2001-09-08 19:07:04 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* fcntl family of syscalls
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct l_flock {
|
|
|
|
l_short l_type;
|
|
|
|
l_short l_whence;
|
|
|
|
l_off_t l_start;
|
|
|
|
l_off_t l_len;
|
|
|
|
l_pid_t l_pid;
|
2004-08-16 07:28:16 +00:00
|
|
|
}
|
2005-01-14 04:44:56 +00:00
|
|
|
#if defined(__amd64__) && defined(COMPAT_LINUX32)
|
2004-08-16 07:28:16 +00:00
|
|
|
__packed
|
|
|
|
#endif
|
|
|
|
;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
linux_to_bsd_flock(struct l_flock *linux_flock, struct flock *bsd_flock)
|
|
|
|
{
|
|
|
|
switch (linux_flock->l_type) {
|
|
|
|
case LINUX_F_RDLCK:
|
|
|
|
bsd_flock->l_type = F_RDLCK;
|
|
|
|
break;
|
|
|
|
case LINUX_F_WRLCK:
|
|
|
|
bsd_flock->l_type = F_WRLCK;
|
|
|
|
break;
|
|
|
|
case LINUX_F_UNLCK:
|
|
|
|
bsd_flock->l_type = F_UNLCK;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
bsd_flock->l_type = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
bsd_flock->l_whence = linux_flock->l_whence;
|
|
|
|
bsd_flock->l_start = (off_t)linux_flock->l_start;
|
|
|
|
bsd_flock->l_len = (off_t)linux_flock->l_len;
|
|
|
|
bsd_flock->l_pid = (pid_t)linux_flock->l_pid;
|
2008-03-26 15:23:12 +00:00
|
|
|
bsd_flock->l_sysid = 0;
|
2001-09-08 19:07:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
bsd_to_linux_flock(struct flock *bsd_flock, struct l_flock *linux_flock)
|
|
|
|
{
|
|
|
|
switch (bsd_flock->l_type) {
|
|
|
|
case F_RDLCK:
|
|
|
|
linux_flock->l_type = LINUX_F_RDLCK;
|
|
|
|
break;
|
|
|
|
case F_WRLCK:
|
|
|
|
linux_flock->l_type = LINUX_F_WRLCK;
|
|
|
|
break;
|
|
|
|
case F_UNLCK:
|
|
|
|
linux_flock->l_type = LINUX_F_UNLCK;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
linux_flock->l_whence = bsd_flock->l_whence;
|
|
|
|
linux_flock->l_start = (l_off_t)bsd_flock->l_start;
|
|
|
|
linux_flock->l_len = (l_off_t)bsd_flock->l_len;
|
|
|
|
linux_flock->l_pid = (l_pid_t)bsd_flock->l_pid;
|
|
|
|
}
|
|
|
|
|
2005-01-14 04:44:56 +00:00
|
|
|
#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
|
2001-09-08 19:07:04 +00:00
|
|
|
struct l_flock64 {
|
|
|
|
l_short l_type;
|
|
|
|
l_short l_whence;
|
|
|
|
l_loff_t l_start;
|
|
|
|
l_loff_t l_len;
|
|
|
|
l_pid_t l_pid;
|
2004-08-16 07:28:16 +00:00
|
|
|
}
|
2005-01-14 04:44:56 +00:00
|
|
|
#if defined(__amd64__) && defined(COMPAT_LINUX32)
|
2004-08-16 07:28:16 +00:00
|
|
|
__packed
|
|
|
|
#endif
|
|
|
|
;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
linux_to_bsd_flock64(struct l_flock64 *linux_flock, struct flock *bsd_flock)
|
|
|
|
{
|
|
|
|
switch (linux_flock->l_type) {
|
|
|
|
case LINUX_F_RDLCK:
|
|
|
|
bsd_flock->l_type = F_RDLCK;
|
|
|
|
break;
|
|
|
|
case LINUX_F_WRLCK:
|
|
|
|
bsd_flock->l_type = F_WRLCK;
|
|
|
|
break;
|
|
|
|
case LINUX_F_UNLCK:
|
|
|
|
bsd_flock->l_type = F_UNLCK;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
bsd_flock->l_type = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
bsd_flock->l_whence = linux_flock->l_whence;
|
|
|
|
bsd_flock->l_start = (off_t)linux_flock->l_start;
|
|
|
|
bsd_flock->l_len = (off_t)linux_flock->l_len;
|
|
|
|
bsd_flock->l_pid = (pid_t)linux_flock->l_pid;
|
2008-03-26 15:23:12 +00:00
|
|
|
bsd_flock->l_sysid = 0;
|
2001-09-08 19:07:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
bsd_to_linux_flock64(struct flock *bsd_flock, struct l_flock64 *linux_flock)
|
|
|
|
{
|
|
|
|
switch (bsd_flock->l_type) {
|
|
|
|
case F_RDLCK:
|
|
|
|
linux_flock->l_type = LINUX_F_RDLCK;
|
|
|
|
break;
|
|
|
|
case F_WRLCK:
|
|
|
|
linux_flock->l_type = LINUX_F_WRLCK;
|
|
|
|
break;
|
|
|
|
case F_UNLCK:
|
|
|
|
linux_flock->l_type = LINUX_F_UNLCK;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
linux_flock->l_whence = bsd_flock->l_whence;
|
|
|
|
linux_flock->l_start = (l_loff_t)bsd_flock->l_start;
|
|
|
|
linux_flock->l_len = (l_loff_t)bsd_flock->l_len;
|
|
|
|
linux_flock->l_pid = (l_pid_t)bsd_flock->l_pid;
|
|
|
|
}
|
2004-08-16 07:28:16 +00:00
|
|
|
#endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */
|
2001-09-08 19:07:04 +00:00
|
|
|
|
|
|
|
static int
|
2015-05-24 15:43:53 +00:00
|
|
|
fcntl_common(struct thread *td, struct linux_fcntl_args *args)
|
2001-09-08 19:07:04 +00:00
|
|
|
{
|
2002-12-08 18:30:44 +00:00
|
|
|
struct l_flock linux_flock;
|
|
|
|
struct flock bsd_flock;
|
2001-09-08 19:07:04 +00:00
|
|
|
struct file *fp;
|
2002-09-02 22:46:05 +00:00
|
|
|
long arg;
|
2001-09-08 19:07:04 +00:00
|
|
|
int error, result;
|
|
|
|
|
|
|
|
switch (args->cmd) {
|
|
|
|
case LINUX_F_DUPFD:
|
2002-09-02 22:46:05 +00:00
|
|
|
return (kern_fcntl(td, args->fd, F_DUPFD, args->arg));
|
2001-09-08 19:07:04 +00:00
|
|
|
|
|
|
|
case LINUX_F_GETFD:
|
2002-09-02 22:46:05 +00:00
|
|
|
return (kern_fcntl(td, args->fd, F_GETFD, 0));
|
2001-09-08 19:07:04 +00:00
|
|
|
|
|
|
|
case LINUX_F_SETFD:
|
2002-09-02 22:46:05 +00:00
|
|
|
return (kern_fcntl(td, args->fd, F_SETFD, args->arg));
|
2001-09-08 19:07:04 +00:00
|
|
|
|
|
|
|
case LINUX_F_GETFL:
|
2002-09-02 22:46:05 +00:00
|
|
|
error = kern_fcntl(td, args->fd, F_GETFL, 0);
|
2001-09-12 08:38:13 +00:00
|
|
|
result = td->td_retval[0];
|
|
|
|
td->td_retval[0] = 0;
|
2001-09-08 19:07:04 +00:00
|
|
|
if (result & O_RDONLY)
|
2001-09-12 08:38:13 +00:00
|
|
|
td->td_retval[0] |= LINUX_O_RDONLY;
|
2001-09-08 19:07:04 +00:00
|
|
|
if (result & O_WRONLY)
|
2001-09-12 08:38:13 +00:00
|
|
|
td->td_retval[0] |= LINUX_O_WRONLY;
|
2001-09-08 19:07:04 +00:00
|
|
|
if (result & O_RDWR)
|
2001-09-12 08:38:13 +00:00
|
|
|
td->td_retval[0] |= LINUX_O_RDWR;
|
2001-09-08 19:07:04 +00:00
|
|
|
if (result & O_NDELAY)
|
2001-09-12 08:38:13 +00:00
|
|
|
td->td_retval[0] |= LINUX_O_NONBLOCK;
|
2001-09-08 19:07:04 +00:00
|
|
|
if (result & O_APPEND)
|
2001-09-12 08:38:13 +00:00
|
|
|
td->td_retval[0] |= LINUX_O_APPEND;
|
2001-09-08 19:07:04 +00:00
|
|
|
if (result & O_FSYNC)
|
2001-09-12 08:38:13 +00:00
|
|
|
td->td_retval[0] |= LINUX_O_SYNC;
|
2001-09-08 19:07:04 +00:00
|
|
|
if (result & O_ASYNC)
|
2001-09-12 08:38:13 +00:00
|
|
|
td->td_retval[0] |= LINUX_FASYNC;
|
2005-04-13 04:31:43 +00:00
|
|
|
#ifdef LINUX_O_NOFOLLOW
|
|
|
|
if (result & O_NOFOLLOW)
|
|
|
|
td->td_retval[0] |= LINUX_O_NOFOLLOW;
|
|
|
|
#endif
|
|
|
|
#ifdef LINUX_O_DIRECT
|
|
|
|
if (result & O_DIRECT)
|
|
|
|
td->td_retval[0] |= LINUX_O_DIRECT;
|
|
|
|
#endif
|
2001-09-08 19:07:04 +00:00
|
|
|
return (error);
|
|
|
|
|
|
|
|
case LINUX_F_SETFL:
|
2002-09-02 22:46:05 +00:00
|
|
|
arg = 0;
|
2001-09-08 19:07:04 +00:00
|
|
|
if (args->arg & LINUX_O_NDELAY)
|
2002-09-02 22:46:05 +00:00
|
|
|
arg |= O_NONBLOCK;
|
2001-09-08 19:07:04 +00:00
|
|
|
if (args->arg & LINUX_O_APPEND)
|
2002-09-02 22:46:05 +00:00
|
|
|
arg |= O_APPEND;
|
2001-09-08 19:07:04 +00:00
|
|
|
if (args->arg & LINUX_O_SYNC)
|
2002-09-02 22:46:05 +00:00
|
|
|
arg |= O_FSYNC;
|
2001-09-08 19:07:04 +00:00
|
|
|
if (args->arg & LINUX_FASYNC)
|
2002-09-02 22:46:05 +00:00
|
|
|
arg |= O_ASYNC;
|
2005-04-13 04:31:43 +00:00
|
|
|
#ifdef LINUX_O_NOFOLLOW
|
|
|
|
if (args->arg & LINUX_O_NOFOLLOW)
|
|
|
|
arg |= O_NOFOLLOW;
|
|
|
|
#endif
|
|
|
|
#ifdef LINUX_O_DIRECT
|
|
|
|
if (args->arg & LINUX_O_DIRECT)
|
|
|
|
arg |= O_DIRECT;
|
|
|
|
#endif
|
2002-09-02 22:46:05 +00:00
|
|
|
return (kern_fcntl(td, args->fd, F_SETFL, arg));
|
2001-09-08 19:07:04 +00:00
|
|
|
|
2002-12-08 18:30:44 +00:00
|
|
|
case LINUX_F_GETLK:
|
2003-03-03 09:14:26 +00:00
|
|
|
error = copyin((void *)args->arg, &linux_flock,
|
2002-12-08 18:30:44 +00:00
|
|
|
sizeof(linux_flock));
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
linux_to_bsd_flock(&linux_flock, &bsd_flock);
|
|
|
|
error = kern_fcntl(td, args->fd, F_GETLK, (intptr_t)&bsd_flock);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
bsd_to_linux_flock(&bsd_flock, &linux_flock);
|
2003-03-03 09:14:26 +00:00
|
|
|
return (copyout(&linux_flock, (void *)args->arg,
|
2002-12-08 18:30:44 +00:00
|
|
|
sizeof(linux_flock)));
|
|
|
|
|
|
|
|
case LINUX_F_SETLK:
|
2003-03-03 09:14:26 +00:00
|
|
|
error = copyin((void *)args->arg, &linux_flock,
|
2002-12-08 18:30:44 +00:00
|
|
|
sizeof(linux_flock));
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
linux_to_bsd_flock(&linux_flock, &bsd_flock);
|
|
|
|
return (kern_fcntl(td, args->fd, F_SETLK,
|
|
|
|
(intptr_t)&bsd_flock));
|
|
|
|
|
|
|
|
case LINUX_F_SETLKW:
|
2003-03-03 09:14:26 +00:00
|
|
|
error = copyin((void *)args->arg, &linux_flock,
|
2002-12-08 18:30:44 +00:00
|
|
|
sizeof(linux_flock));
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
linux_to_bsd_flock(&linux_flock, &bsd_flock);
|
|
|
|
return (kern_fcntl(td, args->fd, F_SETLKW,
|
|
|
|
(intptr_t)&bsd_flock));
|
|
|
|
|
2001-09-08 19:07:04 +00:00
|
|
|
case LINUX_F_GETOWN:
|
2002-09-02 22:46:05 +00:00
|
|
|
return (kern_fcntl(td, args->fd, F_GETOWN, 0));
|
2001-09-08 19:07:04 +00:00
|
|
|
|
|
|
|
case LINUX_F_SETOWN:
|
|
|
|
/*
|
|
|
|
* XXX some Linux applications depend on F_SETOWN having no
|
|
|
|
* significant effect for pipes (SIGIO is not delivered for
|
|
|
|
* pipes under Linux-2.2.35 at least).
|
|
|
|
*/
|
Change the cap_rights_t type from uint64_t to a structure that we can extend
in the future in a backward compatible (API and ABI) way.
The cap_rights_t represents capability rights. We used to use one bit to
represent one right, but we are running out of spare bits. Currently the new
structure provides place for 114 rights (so 50 more than the previous
cap_rights_t), but it is possible to grow the structure to hold at least 285
rights, although we can make it even larger if 285 rights won't be enough.
The structure definition looks like this:
struct cap_rights {
uint64_t cr_rights[CAP_RIGHTS_VERSION + 2];
};
The initial CAP_RIGHTS_VERSION is 0.
The top two bits in the first element of the cr_rights[] array contain total
number of elements in the array - 2. This means if those two bits are equal to
0, we have 2 array elements.
The top two bits in all remaining array elements should be 0.
The next five bits in all array elements contain array index. Only one bit is
used and bit position in this five-bits range defines array index. This means
there can be at most five array elements in the future.
To define new right the CAPRIGHT() macro must be used. The macro takes two
arguments - an array index and a bit to set, eg.
#define CAP_PDKILL CAPRIGHT(1, 0x0000000000000800ULL)
We still support aliases that combine few rights, but the rights have to belong
to the same array element, eg:
#define CAP_LOOKUP CAPRIGHT(0, 0x0000000000000400ULL)
#define CAP_FCHMOD CAPRIGHT(0, 0x0000000000002000ULL)
#define CAP_FCHMODAT (CAP_FCHMOD | CAP_LOOKUP)
There is new API to manage the new cap_rights_t structure:
cap_rights_t *cap_rights_init(cap_rights_t *rights, ...);
void cap_rights_set(cap_rights_t *rights, ...);
void cap_rights_clear(cap_rights_t *rights, ...);
bool cap_rights_is_set(const cap_rights_t *rights, ...);
bool cap_rights_is_valid(const cap_rights_t *rights);
void cap_rights_merge(cap_rights_t *dst, const cap_rights_t *src);
void cap_rights_remove(cap_rights_t *dst, const cap_rights_t *src);
bool cap_rights_contains(const cap_rights_t *big, const cap_rights_t *little);
Capability rights to the cap_rights_init(), cap_rights_set(),
cap_rights_clear() and cap_rights_is_set() functions are provided by
separating them with commas, eg:
cap_rights_t rights;
cap_rights_init(&rights, CAP_READ, CAP_WRITE, CAP_FSTAT);
There is no need to terminate the list of rights, as those functions are
actually macros that take care of the termination, eg:
#define cap_rights_set(rights, ...) \
__cap_rights_set((rights), __VA_ARGS__, 0ULL)
void __cap_rights_set(cap_rights_t *rights, ...);
Thanks to using one bit as an array index we can assert in those functions that
there are no two rights belonging to different array elements provided
together. For example this is illegal and will be detected, because CAP_LOOKUP
belongs to element 0 and CAP_PDKILL to element 1:
cap_rights_init(&rights, CAP_LOOKUP | CAP_PDKILL);
Providing several rights that belongs to the same array's element this way is
correct, but is not advised. It should only be used for aliases definition.
This commit also breaks compatibility with some existing Capsicum system calls,
but I see no other way to do that. This should be fine as Capsicum is still
experimental and this change is not going to 9.x.
Sponsored by: The FreeBSD Foundation
2013-09-05 00:09:56 +00:00
|
|
|
error = fget(td, args->fd,
|
2018-05-09 18:47:24 +00:00
|
|
|
&cap_fcntl_rights, &fp);
|
2002-01-14 00:13:45 +00:00
|
|
|
if (error)
|
|
|
|
return (error);
|
2002-01-13 11:58:06 +00:00
|
|
|
if (fp->f_type == DTYPE_PIPE) {
|
|
|
|
fdrop(fp, td);
|
2001-09-08 19:07:04 +00:00
|
|
|
return (EINVAL);
|
2002-01-13 11:58:06 +00:00
|
|
|
}
|
|
|
|
fdrop(fp, td);
|
2001-09-08 19:07:04 +00:00
|
|
|
|
2002-09-02 22:46:05 +00:00
|
|
|
return (kern_fcntl(td, args->fd, F_SETOWN, args->arg));
|
2015-05-24 16:34:57 +00:00
|
|
|
|
|
|
|
case LINUX_F_DUPFD_CLOEXEC:
|
|
|
|
return (kern_fcntl(td, args->fd, F_DUPFD_CLOEXEC, args->arg));
|
2001-09-08 19:07:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
linux_fcntl(struct thread *td, struct linux_fcntl_args *args)
|
2001-09-08 19:07:04 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (ldebug(fcntl))
|
|
|
|
printf(ARGS(fcntl, "%d, %08x, *"), args->fd, args->cmd);
|
|
|
|
#endif
|
|
|
|
|
2015-05-24 15:43:53 +00:00
|
|
|
return (fcntl_common(td, args));
|
2001-09-08 19:07:04 +00:00
|
|
|
}
|
|
|
|
|
2005-01-14 04:44:56 +00:00
|
|
|
#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
|
2001-09-08 19:07:04 +00:00
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
linux_fcntl64(struct thread *td, struct linux_fcntl64_args *args)
|
2001-09-08 19:07:04 +00:00
|
|
|
{
|
|
|
|
struct l_flock64 linux_flock;
|
2002-09-02 22:46:05 +00:00
|
|
|
struct flock bsd_flock;
|
2015-05-24 15:43:53 +00:00
|
|
|
struct linux_fcntl_args fcntl_args;
|
2001-09-08 19:07:04 +00:00
|
|
|
int error;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (ldebug(fcntl64))
|
|
|
|
printf(ARGS(fcntl64, "%d, %08x, *"), args->fd, args->cmd);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
switch (args->cmd) {
|
2002-07-09 19:25:43 +00:00
|
|
|
case LINUX_F_GETLK64:
|
2003-03-03 09:14:26 +00:00
|
|
|
error = copyin((void *)args->arg, &linux_flock,
|
2001-09-08 19:07:04 +00:00
|
|
|
sizeof(linux_flock));
|
|
|
|
if (error)
|
|
|
|
return (error);
|
2002-09-02 22:46:05 +00:00
|
|
|
linux_to_bsd_flock64(&linux_flock, &bsd_flock);
|
|
|
|
error = kern_fcntl(td, args->fd, F_GETLK, (intptr_t)&bsd_flock);
|
2001-09-08 19:07:04 +00:00
|
|
|
if (error)
|
|
|
|
return (error);
|
2002-09-02 22:46:05 +00:00
|
|
|
bsd_to_linux_flock64(&bsd_flock, &linux_flock);
|
2003-03-03 09:14:26 +00:00
|
|
|
return (copyout(&linux_flock, (void *)args->arg,
|
|
|
|
sizeof(linux_flock)));
|
2001-09-08 19:07:04 +00:00
|
|
|
|
2002-07-09 19:25:43 +00:00
|
|
|
case LINUX_F_SETLK64:
|
2003-03-03 09:14:26 +00:00
|
|
|
error = copyin((void *)args->arg, &linux_flock,
|
2001-09-08 19:07:04 +00:00
|
|
|
sizeof(linux_flock));
|
|
|
|
if (error)
|
|
|
|
return (error);
|
2002-09-02 22:46:05 +00:00
|
|
|
linux_to_bsd_flock64(&linux_flock, &bsd_flock);
|
|
|
|
return (kern_fcntl(td, args->fd, F_SETLK,
|
|
|
|
(intptr_t)&bsd_flock));
|
2001-09-08 19:07:04 +00:00
|
|
|
|
2002-07-09 19:25:43 +00:00
|
|
|
case LINUX_F_SETLKW64:
|
2003-03-03 09:14:26 +00:00
|
|
|
error = copyin((void *)args->arg, &linux_flock,
|
2001-09-08 19:07:04 +00:00
|
|
|
sizeof(linux_flock));
|
|
|
|
if (error)
|
|
|
|
return (error);
|
2002-09-02 22:46:05 +00:00
|
|
|
linux_to_bsd_flock64(&linux_flock, &bsd_flock);
|
|
|
|
return (kern_fcntl(td, args->fd, F_SETLKW,
|
|
|
|
(intptr_t)&bsd_flock));
|
2001-09-08 19:07:04 +00:00
|
|
|
}
|
|
|
|
|
2015-05-24 15:43:53 +00:00
|
|
|
fcntl_args.fd = args->fd;
|
|
|
|
fcntl_args.cmd = args->cmd;
|
|
|
|
fcntl_args.arg = args->arg;
|
|
|
|
return (fcntl_common(td, &fcntl_args));
|
2001-09-08 19:07:04 +00:00
|
|
|
}
|
2004-08-16 07:28:16 +00:00
|
|
|
#endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */
|
2001-10-16 06:15:36 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
linux_chown(struct thread *td, struct linux_chown_args *args)
|
|
|
|
{
|
2002-09-01 22:30:27 +00:00
|
|
|
char *path;
|
|
|
|
int error;
|
2001-10-16 06:15:36 +00:00
|
|
|
|
2002-09-01 22:30:27 +00:00
|
|
|
LCONVPATHEXIST(td, args->path, &path);
|
2001-10-16 06:15:36 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (ldebug(chown))
|
2002-09-01 22:30:27 +00:00
|
|
|
printf(ARGS(chown, "%s, %d, %d"), path, args->uid, args->gid);
|
2001-10-16 06:15:36 +00:00
|
|
|
#endif
|
2014-11-13 18:01:51 +00:00
|
|
|
error = kern_fchownat(td, AT_FDCWD, path, UIO_SYSSPACE, args->uid,
|
|
|
|
args->gid, 0);
|
2002-09-01 22:30:27 +00:00
|
|
|
LFREEPATH(path);
|
|
|
|
return (error);
|
2001-10-16 06:15:36 +00:00
|
|
|
}
|
|
|
|
|
Implement the linux syscalls
openat, mkdirat, mknodat, fchownat, futimesat, fstatat, unlinkat,
renameat, linkat, symlinkat, readlinkat, fchmodat, faccessat.
Submitted by: rdivacky
Sponsored by: Google Summer of Code 2007
Tested by: pho
2008-04-08 09:45:49 +00:00
|
|
|
int
|
|
|
|
linux_fchownat(struct thread *td, struct linux_fchownat_args *args)
|
|
|
|
{
|
|
|
|
char *path;
|
2011-11-19 07:19:37 +00:00
|
|
|
int error, dfd, flag;
|
Implement the linux syscalls
openat, mkdirat, mknodat, fchownat, futimesat, fstatat, unlinkat,
renameat, linkat, symlinkat, readlinkat, fchmodat, faccessat.
Submitted by: rdivacky
Sponsored by: Google Summer of Code 2007
Tested by: pho
2008-04-08 09:45:49 +00:00
|
|
|
|
|
|
|
if (args->flag & ~LINUX_AT_SYMLINK_NOFOLLOW)
|
|
|
|
return (EINVAL);
|
|
|
|
|
|
|
|
dfd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->dfd;
|
|
|
|
LCONVPATHEXIST_AT(td, args->filename, &path, dfd);
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (ldebug(fchownat))
|
|
|
|
printf(ARGS(fchownat, "%s, %d, %d"), path, args->uid, args->gid);
|
|
|
|
#endif
|
|
|
|
|
2011-11-19 07:19:37 +00:00
|
|
|
flag = (args->flag & LINUX_AT_SYMLINK_NOFOLLOW) == 0 ? 0 :
|
Implement the linux syscalls
openat, mkdirat, mknodat, fchownat, futimesat, fstatat, unlinkat,
renameat, linkat, symlinkat, readlinkat, fchmodat, faccessat.
Submitted by: rdivacky
Sponsored by: Google Summer of Code 2007
Tested by: pho
2008-04-08 09:45:49 +00:00
|
|
|
AT_SYMLINK_NOFOLLOW;
|
|
|
|
error = kern_fchownat(td, dfd, path, UIO_SYSSPACE, args->uid, args->gid,
|
2011-11-19 07:19:37 +00:00
|
|
|
flag);
|
Implement the linux syscalls
openat, mkdirat, mknodat, fchownat, futimesat, fstatat, unlinkat,
renameat, linkat, symlinkat, readlinkat, fchmodat, faccessat.
Submitted by: rdivacky
Sponsored by: Google Summer of Code 2007
Tested by: pho
2008-04-08 09:45:49 +00:00
|
|
|
LFREEPATH(path);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
2001-10-16 06:15:36 +00:00
|
|
|
int
|
|
|
|
linux_lchown(struct thread *td, struct linux_lchown_args *args)
|
|
|
|
{
|
2002-09-01 22:30:27 +00:00
|
|
|
char *path;
|
|
|
|
int error;
|
2001-10-16 06:15:36 +00:00
|
|
|
|
2002-09-01 22:30:27 +00:00
|
|
|
LCONVPATHEXIST(td, args->path, &path);
|
2001-10-16 06:15:36 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (ldebug(lchown))
|
2002-09-01 22:30:27 +00:00
|
|
|
printf(ARGS(lchown, "%s, %d, %d"), path, args->uid, args->gid);
|
2001-10-16 06:15:36 +00:00
|
|
|
#endif
|
2014-11-13 18:01:51 +00:00
|
|
|
error = kern_fchownat(td, AT_FDCWD, path, UIO_SYSSPACE, args->uid,
|
|
|
|
args->gid, AT_SYMLINK_NOFOLLOW);
|
2002-09-01 22:30:27 +00:00
|
|
|
LFREEPATH(path);
|
|
|
|
return (error);
|
2001-10-16 06:15:36 +00:00
|
|
|
}
|
2011-12-29 15:34:59 +00:00
|
|
|
|
|
|
|
static int
|
|
|
|
convert_fadvice(int advice)
|
|
|
|
{
|
|
|
|
switch (advice) {
|
|
|
|
case LINUX_POSIX_FADV_NORMAL:
|
|
|
|
return (POSIX_FADV_NORMAL);
|
|
|
|
case LINUX_POSIX_FADV_RANDOM:
|
|
|
|
return (POSIX_FADV_RANDOM);
|
|
|
|
case LINUX_POSIX_FADV_SEQUENTIAL:
|
|
|
|
return (POSIX_FADV_SEQUENTIAL);
|
|
|
|
case LINUX_POSIX_FADV_WILLNEED:
|
|
|
|
return (POSIX_FADV_WILLNEED);
|
|
|
|
case LINUX_POSIX_FADV_DONTNEED:
|
|
|
|
return (POSIX_FADV_DONTNEED);
|
|
|
|
case LINUX_POSIX_FADV_NOREUSE:
|
|
|
|
return (POSIX_FADV_NOREUSE);
|
|
|
|
default:
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
linux_fadvise64(struct thread *td, struct linux_fadvise64_args *args)
|
|
|
|
{
|
|
|
|
int advice;
|
|
|
|
|
|
|
|
advice = convert_fadvice(args->advice);
|
|
|
|
if (advice == -1)
|
|
|
|
return (EINVAL);
|
|
|
|
return (kern_posix_fadvise(td, args->fd, args->offset, args->len,
|
|
|
|
advice));
|
|
|
|
}
|
|
|
|
|
2015-05-24 15:43:53 +00:00
|
|
|
#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
|
2011-12-29 15:34:59 +00:00
|
|
|
int
|
|
|
|
linux_fadvise64_64(struct thread *td, struct linux_fadvise64_64_args *args)
|
|
|
|
{
|
|
|
|
int advice;
|
|
|
|
|
|
|
|
advice = convert_fadvice(args->advice);
|
|
|
|
if (advice == -1)
|
|
|
|
return (EINVAL);
|
|
|
|
return (kern_posix_fadvise(td, args->fd, args->offset, args->len,
|
|
|
|
advice));
|
|
|
|
}
|
2015-05-24 15:43:53 +00:00
|
|
|
#endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */
|
2012-04-16 21:22:02 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
linux_pipe(struct thread *td, struct linux_pipe_args *args)
|
|
|
|
{
|
|
|
|
int fildes[2];
|
|
|
|
int error;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (ldebug(pipe))
|
|
|
|
printf(ARGS(pipe, "*"));
|
|
|
|
#endif
|
|
|
|
|
2015-07-29 17:18:27 +00:00
|
|
|
error = kern_pipe(td, fildes, 0, NULL, NULL);
|
2017-02-05 14:03:25 +00:00
|
|
|
if (error != 0)
|
2012-04-16 21:22:02 +00:00
|
|
|
return (error);
|
|
|
|
|
2017-02-05 14:03:25 +00:00
|
|
|
error = copyout(fildes, args->pipefds, sizeof(fildes));
|
|
|
|
if (error != 0) {
|
|
|
|
(void)kern_close(td, fildes[0]);
|
|
|
|
(void)kern_close(td, fildes[1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (error);
|
2012-04-16 21:22:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
linux_pipe2(struct thread *td, struct linux_pipe2_args *args)
|
|
|
|
{
|
|
|
|
int fildes[2];
|
|
|
|
int error, flags;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (ldebug(pipe2))
|
|
|
|
printf(ARGS(pipe2, "*, %d"), args->flags);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if ((args->flags & ~(LINUX_O_NONBLOCK | LINUX_O_CLOEXEC)) != 0)
|
|
|
|
return (EINVAL);
|
|
|
|
|
|
|
|
flags = 0;
|
|
|
|
if ((args->flags & LINUX_O_NONBLOCK) != 0)
|
|
|
|
flags |= O_NONBLOCK;
|
|
|
|
if ((args->flags & LINUX_O_CLOEXEC) != 0)
|
|
|
|
flags |= O_CLOEXEC;
|
2015-07-29 17:18:27 +00:00
|
|
|
error = kern_pipe(td, fildes, flags, NULL, NULL);
|
2017-02-05 14:03:25 +00:00
|
|
|
if (error != 0)
|
2012-04-16 21:22:02 +00:00
|
|
|
return (error);
|
|
|
|
|
2017-02-05 14:03:25 +00:00
|
|
|
error = copyout(fildes, args->pipefds, sizeof(fildes));
|
|
|
|
if (error != 0) {
|
|
|
|
(void)kern_close(td, fildes[0]);
|
|
|
|
(void)kern_close(td, fildes[1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (error);
|
2012-04-16 21:22:02 +00:00
|
|
|
}
|
2015-05-24 15:14:51 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
linux_dup3(struct thread *td, struct linux_dup3_args *args)
|
|
|
|
{
|
|
|
|
int cmd;
|
|
|
|
intptr_t newfd;
|
|
|
|
|
|
|
|
if (args->oldfd == args->newfd)
|
|
|
|
return (EINVAL);
|
|
|
|
if ((args->flags & ~LINUX_O_CLOEXEC) != 0)
|
|
|
|
return (EINVAL);
|
|
|
|
if (args->flags & LINUX_O_CLOEXEC)
|
|
|
|
cmd = F_DUP2FD_CLOEXEC;
|
|
|
|
else
|
|
|
|
cmd = F_DUP2FD;
|
|
|
|
|
|
|
|
newfd = args->newfd;
|
|
|
|
return (kern_fcntl(td, args->oldfd, cmd, newfd));
|
|
|
|
}
|
2015-05-24 17:33:21 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
linux_fallocate(struct thread *td, struct linux_fallocate_args *args)
|
|
|
|
{
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We emulate only posix_fallocate system call for which
|
|
|
|
* mode should be 0.
|
|
|
|
*/
|
|
|
|
if (args->mode != 0)
|
|
|
|
return (ENOSYS);
|
|
|
|
|
|
|
|
return (kern_posix_fallocate(td, args->fd, args->offset,
|
|
|
|
args->len));
|
|
|
|
}
|