2005-01-05 22:34:37 +00:00
|
|
|
/*-
|
2017-11-27 15:13:23 +00:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
*
|
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
|
|
|
* Copyright (c) 1994 Christos Zoulas
|
|
|
|
* Copyright (c) 1995 Frank van der Linden
|
|
|
|
* Copyright (c) 1995 Scott Bartram
|
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
|
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
|
|
|
* 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.
|
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
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
|
|
|
* derived from this software without specific prior written permission
|
1995-06-25 17:32:43 +00:00
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
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
|
|
|
* from: svr4_util.h,v 1.5 1994/11/18 02:54:31 christos Exp
|
|
|
|
* from: linux_util.h,v 1.2 1995/03/05 23:23:50 fvdl Exp
|
1999-08-28 01:08:13 +00:00
|
|
|
* $FreeBSD$
|
1995-06-25 17:32:43 +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
|
|
|
#ifndef _LINUX_UTIL_H_
|
|
|
|
#define _LINUX_UTIL_H_
|
|
|
|
|
|
|
|
#include <vm/vm.h>
|
1995-12-09 08:17:24 +00:00
|
|
|
#include <vm/vm_param.h>
|
|
|
|
#include <vm/pmap.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/exec.h>
|
|
|
|
#include <sys/sysent.h>
|
2003-01-02 02:19:10 +00:00
|
|
|
#include <sys/syslog.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/cdefs.h>
|
2002-09-01 21:15:37 +00:00
|
|
|
#include <sys/uio.h>
|
1995-06-25 17:32:43 +00:00
|
|
|
|
2015-05-24 15:51:18 +00:00
|
|
|
MALLOC_DECLARE(M_LINUX);
|
2015-05-24 16:41:39 +00:00
|
|
|
MALLOC_DECLARE(M_EPOLL);
|
2015-05-24 15:51:18 +00:00
|
|
|
|
2019-12-16 20:07:04 +00:00
|
|
|
extern char linux_emul_path[];
|
2020-08-18 22:04:22 +00:00
|
|
|
extern int linux_use_emul_path;
|
1999-12-04 11:10:22 +00:00
|
|
|
|
2021-11-25 21:42:13 +00:00
|
|
|
int linux_emul_convpath(const char *, enum uio_seg, char **, int, int);
|
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
|
|
|
|
2020-08-18 22:04:22 +00:00
|
|
|
#define LUSECONVPATH(td) atomic_load_int(&linux_use_emul_path)
|
|
|
|
|
2021-11-25 21:42:13 +00:00
|
|
|
#define LCONVPATH_AT(upath, pathp, i, dfd) \
|
2002-09-01 21:15:37 +00:00
|
|
|
do { \
|
|
|
|
int _error; \
|
|
|
|
\
|
2021-11-25 21:42:13 +00:00
|
|
|
_error = linux_emul_convpath(upath, UIO_USERSPACE, \
|
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
|
|
|
pathp, i, dfd); \
|
2002-09-01 21:15:37 +00:00
|
|
|
if (*(pathp) == NULL) \
|
|
|
|
return (_error); \
|
|
|
|
} while (0)
|
|
|
|
|
2021-11-25 21:42:13 +00:00
|
|
|
#define LCONVPATH(upath, pathp, i) \
|
|
|
|
LCONVPATH_AT(upath, pathp, i, AT_FDCWD)
|
2007-03-29 02:11:46 +00:00
|
|
|
|
2021-11-25 21:42:13 +00:00
|
|
|
#define LCONVPATHEXIST(upath, pathp) LCONVPATH(upath, pathp, 0)
|
|
|
|
#define LCONVPATHEXIST_AT(upath, pathp, dfd) LCONVPATH_AT(upath, pathp, 0, dfd)
|
|
|
|
#define LCONVPATHCREAT(upath, pathp) LCONVPATH(upath, pathp, 1)
|
|
|
|
#define LCONVPATHCREAT_AT(upath, pathp, dfd) LCONVPATH_AT(upath, pathp, 1, dfd)
|
2002-09-01 21:15:37 +00:00
|
|
|
#define LFREEPATH(path) free(path, M_TEMP)
|
|
|
|
|
2000-11-01 19:48:35 +00:00
|
|
|
#define DUMMY(s) \
|
2012-05-05 19:42:38 +00:00
|
|
|
LIN_SDT_PROBE_DEFINE0(dummy, s, not_implemented); \
|
2000-11-01 19:48:35 +00:00
|
|
|
int \
|
2004-10-10 18:34:30 +00:00
|
|
|
linux_ ## s(struct thread *td, struct linux_ ## s ## _args *args) \
|
2000-11-01 19:48:35 +00:00
|
|
|
{ \
|
2005-12-08 13:33:57 +00:00
|
|
|
static pid_t pid; \
|
|
|
|
\
|
|
|
|
if (pid != td->td_proc->p_pid) { \
|
|
|
|
linux_msg(td, "syscall %s not implemented", #s); \
|
2012-05-05 19:42:38 +00:00
|
|
|
LIN_SDT_PROBE0(dummy, s, not_implemented); \
|
2005-12-08 13:33:57 +00:00
|
|
|
pid = td->td_proc->p_pid; \
|
|
|
|
}; \
|
2012-05-05 19:42:38 +00:00
|
|
|
\
|
2005-12-08 13:33:57 +00:00
|
|
|
return (ENOSYS); \
|
2000-11-01 19:48:35 +00:00
|
|
|
} \
|
|
|
|
struct __hack
|
|
|
|
|
2017-03-06 18:11:38 +00:00
|
|
|
/*
|
|
|
|
* This is for the syscalls that are not even yet implemented in Linux.
|
|
|
|
*
|
|
|
|
* They're marked as UNIMPL in syscall.master so it will
|
|
|
|
* have nosys record in linux_sysent[].
|
|
|
|
*/
|
|
|
|
#define UNIMPLEMENTED(s)
|
|
|
|
|
2003-01-02 02:19:10 +00:00
|
|
|
void linux_msg(const struct thread *td, const char *fmt, ...)
|
|
|
|
__printflike(2, 3);
|
|
|
|
|
2006-05-05 16:10:45 +00:00
|
|
|
struct linux_device_handler {
|
|
|
|
char *bsd_driver_name;
|
|
|
|
char *linux_driver_name;
|
|
|
|
char *bsd_device_name;
|
|
|
|
char *linux_device_name;
|
|
|
|
int linux_major;
|
|
|
|
int linux_minor;
|
|
|
|
int linux_char_device;
|
|
|
|
};
|
|
|
|
|
|
|
|
int linux_device_register_handler(struct linux_device_handler *h);
|
|
|
|
int linux_device_unregister_handler(struct linux_device_handler *h);
|
|
|
|
char *linux_driver_get_name_dev(device_t dev);
|
2012-02-10 12:35:57 +00:00
|
|
|
int linux_driver_get_major_minor(const char *node, int *major, int *minor);
|
2020-10-20 17:19:10 +00:00
|
|
|
int linux_vn_get_major_minor(const struct vnode *vn, int *major, int *minor);
|
2006-05-05 16:10:45 +00:00
|
|
|
char *linux_get_char_devices(void);
|
|
|
|
void linux_free_get_char_devices(char *string);
|
|
|
|
|
2022-01-08 15:41:53 +00:00
|
|
|
/*
|
|
|
|
* Criteria for interface name translation
|
|
|
|
*/
|
|
|
|
#define IFP_IS_ETH(ifp) ((ifp)->if_type == IFT_ETHER)
|
|
|
|
#define IFP_IS_LOOP(ifp) ((ifp)->if_type == IFT_LOOP)
|
|
|
|
|
|
|
|
struct ifnet;
|
|
|
|
bool linux_use_real_ifname(const struct ifnet *ifp);
|
|
|
|
|
2009-05-07 10:01:05 +00:00
|
|
|
#if defined(KTR)
|
|
|
|
|
|
|
|
#define KTR_LINUX KTR_SUBSYS
|
|
|
|
#define LINUX_CTRFMT(nm, fmt) #nm"("fmt")"
|
|
|
|
|
|
|
|
#define LINUX_CTR6(f, m, p1, p2, p3, p4, p5, p6) do { \
|
|
|
|
CTR6(KTR_LINUX, LINUX_CTRFMT(f, m), \
|
|
|
|
p1, p2, p3, p4, p5, p6); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define LINUX_CTR(f) LINUX_CTR6(f, "", 0, 0, 0, 0, 0, 0)
|
|
|
|
#define LINUX_CTR0(f, m) LINUX_CTR6(f, m, 0, 0, 0, 0, 0, 0)
|
|
|
|
#define LINUX_CTR1(f, m, p1) LINUX_CTR6(f, m, p1, 0, 0, 0, 0, 0)
|
|
|
|
#define LINUX_CTR2(f, m, p1, p2) LINUX_CTR6(f, m, p1, p2, 0, 0, 0, 0)
|
|
|
|
#define LINUX_CTR3(f, m, p1, p2, p3) LINUX_CTR6(f, m, p1, p2, p3, 0, 0, 0)
|
|
|
|
#define LINUX_CTR4(f, m, p1, p2, p3, p4) LINUX_CTR6(f, m, p1, p2, p3, p4, 0, 0)
|
|
|
|
#define LINUX_CTR5(f, m, p1, p2, p3, p4, p5) LINUX_CTR6(f, m, p1, p2, p3, p4, p5, 0)
|
|
|
|
#else
|
|
|
|
#define LINUX_CTR(f)
|
|
|
|
#define LINUX_CTR0(f, m)
|
|
|
|
#define LINUX_CTR1(f, m, p1)
|
|
|
|
#define LINUX_CTR2(f, m, p1, p2)
|
|
|
|
#define LINUX_CTR3(f, m, p1, p2, p3)
|
|
|
|
#define LINUX_CTR4(f, m, p1, p2, p3, p4)
|
|
|
|
#define LINUX_CTR5(f, m, p1, p2, p3, p4, p5)
|
|
|
|
#define LINUX_CTR6(f, m, p1, p2, p3, p4, p5, p6)
|
|
|
|
#endif
|
|
|
|
|
2020-11-08 09:50:58 +00:00
|
|
|
/*
|
|
|
|
* Some macros for rate limiting messages:
|
|
|
|
* - noisy if compat.linux.debug = 1
|
|
|
|
* - print only once if compat.linux.debug > 1
|
|
|
|
*/
|
|
|
|
#define LINUX_RATELIMIT_MSG_NOTTESTED(_what) \
|
|
|
|
do { \
|
|
|
|
static int seen = 0; \
|
|
|
|
\
|
|
|
|
if (seen == 0 && linux_debug >= 2) { \
|
|
|
|
linux_msg(curthread, "%s is not tested, please report on emulation@FreeBSD.org how it works", _what); \
|
|
|
|
\
|
|
|
|
if (linux_debug < 3) \
|
|
|
|
seen = 1; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
2021-08-12 08:55:55 +00:00
|
|
|
#define LINUX_RATELIMIT_MSG(_message) \
|
|
|
|
do { \
|
|
|
|
static int seen = 0; \
|
|
|
|
\
|
|
|
|
if (seen == 0) { \
|
|
|
|
linux_msg(curthread, _message); \
|
|
|
|
\
|
|
|
|
if (linux_debug < 3) \
|
|
|
|
seen = 1; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
2020-11-08 09:50:58 +00:00
|
|
|
#define LINUX_RATELIMIT_MSG_OPT1(_message, _opt1) \
|
|
|
|
do { \
|
|
|
|
static int seen = 0; \
|
|
|
|
\
|
|
|
|
if (seen == 0) { \
|
|
|
|
linux_msg(curthread, _message, _opt1); \
|
|
|
|
\
|
|
|
|
if (linux_debug < 3) \
|
|
|
|
seen = 1; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
2022-05-28 20:47:23 +00:00
|
|
|
#define LINUX_RATELIMIT_MSG_OPT2(_message, _opt1, _opt2) \
|
|
|
|
do { \
|
|
|
|
static int seen = 0; \
|
|
|
|
\
|
|
|
|
if (seen == 0) { \
|
|
|
|
linux_msg(curthread, _message, _opt1, _opt2); \
|
|
|
|
\
|
|
|
|
if (linux_debug < 3) \
|
|
|
|
seen = 1; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
2020-11-08 09:50:58 +00:00
|
|
|
#endif /* ! _LINUX_UTIL_H_ */
|