From 85aae976e20fc6b5be7ebb996fdf69c1c31e2b5b Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Sat, 6 Aug 2016 10:53:59 -0700 Subject: [PATCH] kernel, world - Remove the remaining vestiges of linux emul * Remove the remaining bits of the 32-bit linux emulation code. This code hasn't been used in ages and we have no plans to implement a 64-bit linux emulation. --- Makefile_upgrade.inc | 10 + etc/defaults/make.conf | 2 +- include/Makefile | 1 - share/man/man9/syscall.9 | 2 - sys/Makefile | 1 - sys/bus/cam/scsi/scsi_sg.c | 33 +- sys/dev/raid/aac/Makefile | 4 - sys/dev/raid/aac/aac_linux.c | 100 - sys/dev/raid/aac/aac_linux/Makefile | 8 - sys/dev/raid/amr/Makefile | 3 - sys/dev/raid/amr/amr_linux.c | 80 - sys/dev/raid/amr/amr_linux/Makefile | 8 - sys/dev/raid/mfi/Makefile | 5 - sys/dev/raid/mfi/mfi_linux.c | 77 - sys/dev/raid/mfi/mfi_linux/Makefile | 8 - sys/emulation/Makefile | 4 - sys/emulation/linux/Makefile | 43 - sys/emulation/linux/i386/Makefile | 22 - sys/emulation/linux/i386/imgact_linux.c | 239 --- sys/emulation/linux/i386/linprocfs/Makefile | 7 - sys/emulation/linux/i386/linprocfs/linprocfs.h | 173 -- .../linux/i386/linprocfs/linprocfs_misc.c | 869 --------- .../linux/i386/linprocfs/linprocfs_subr.c | 470 ----- .../linux/i386/linprocfs/linprocfs_vfsops.c | 170 -- .../linux/i386/linprocfs/linprocfs_vnops.c | 1664 ----------------- sys/emulation/linux/i386/linux.h | 821 -------- sys/emulation/linux/i386/linux_dummy.c | 121 -- sys/emulation/linux/i386/linux_genassym.c | 15 - sys/emulation/linux/i386/linux_locore.s | 37 - sys/emulation/linux/i386/linux_machdep.c | 1294 ------------- sys/emulation/linux/i386/linux_proto.h | 1951 ------------------- sys/emulation/linux/i386/linux_ptrace.c | 508 ----- sys/emulation/linux/i386/linux_support.s | 148 -- sys/emulation/linux/i386/linux_syscall.h | 299 --- sys/emulation/linux/i386/linux_sysent.c | 360 ---- sys/emulation/linux/i386/linux_sysvec.c | 980 ---------- sys/emulation/linux/i386/linux_union.h | 251 --- sys/emulation/linux/i386/syscalls.conf | 12 - sys/emulation/linux/i386/syscalls.master | 488 ----- sys/emulation/linux/linux_emuldata.c | 310 ---- sys/emulation/linux/linux_emuldata.h | 101 - sys/emulation/linux/linux_epoll.c | 282 --- sys/emulation/linux/linux_epoll.h | 55 - sys/emulation/linux/linux_file.c | 1697 ----------------- sys/emulation/linux/linux_futex.c | 838 --------- sys/emulation/linux/linux_futex.h | 87 - sys/emulation/linux/linux_getcwd.c | 105 -- sys/emulation/linux/linux_ioctl.c | 1427 -------------- sys/emulation/linux/linux_ioctl.h | 528 ------ sys/emulation/linux/linux_ipc.c | 811 -------- sys/emulation/linux/linux_ipc.h | 343 ---- sys/emulation/linux/linux_mib.c | 286 --- sys/emulation/linux/linux_mib.h | 44 - sys/emulation/linux/linux_misc.c | 1959 -------------------- sys/emulation/linux/linux_signal.c | 468 ----- sys/emulation/linux/linux_signal.h | 40 - sys/emulation/linux/linux_socket.c | 1364 -------------- sys/emulation/linux/linux_socket.h | 59 - sys/emulation/linux/linux_stats.c | 574 ------ sys/emulation/linux/linux_sysctl.c | 137 -- sys/emulation/linux/linux_sysproto.h | 8 - sys/emulation/linux/linux_time.c | 231 --- sys/emulation/linux/linux_uid16.c | 402 ---- sys/emulation/linux/linux_util.c | 219 --- sys/emulation/linux/linux_util.h | 116 -- usr.bin/truss/Makefile | 13 +- usr.bin/truss/extern.h | 6 - usr.bin/truss/i386-linux.c | 260 --- usr.bin/truss/i386linux.conf | 12 - usr.bin/truss/syscalls.c | 6 - 70 files changed, 16 insertions(+), 24060 deletions(-) delete mode 100644 sys/dev/raid/aac/aac_linux.c delete mode 100644 sys/dev/raid/aac/aac_linux/Makefile delete mode 100644 sys/dev/raid/amr/amr_linux.c delete mode 100644 sys/dev/raid/amr/amr_linux/Makefile delete mode 100644 sys/dev/raid/mfi/mfi_linux.c delete mode 100644 sys/dev/raid/mfi/mfi_linux/Makefile delete mode 100644 sys/emulation/linux/Makefile delete mode 100644 sys/emulation/linux/i386/Makefile delete mode 100644 sys/emulation/linux/i386/imgact_linux.c delete mode 100644 sys/emulation/linux/i386/linprocfs/Makefile delete mode 100644 sys/emulation/linux/i386/linprocfs/linprocfs.h delete mode 100644 sys/emulation/linux/i386/linprocfs/linprocfs_misc.c delete mode 100644 sys/emulation/linux/i386/linprocfs/linprocfs_subr.c delete mode 100644 sys/emulation/linux/i386/linprocfs/linprocfs_vfsops.c delete mode 100644 sys/emulation/linux/i386/linprocfs/linprocfs_vnops.c delete mode 100644 sys/emulation/linux/i386/linux.h delete mode 100644 sys/emulation/linux/i386/linux_dummy.c delete mode 100644 sys/emulation/linux/i386/linux_genassym.c delete mode 100644 sys/emulation/linux/i386/linux_locore.s delete mode 100644 sys/emulation/linux/i386/linux_machdep.c delete mode 100644 sys/emulation/linux/i386/linux_proto.h delete mode 100644 sys/emulation/linux/i386/linux_ptrace.c delete mode 100644 sys/emulation/linux/i386/linux_support.s delete mode 100644 sys/emulation/linux/i386/linux_syscall.h delete mode 100644 sys/emulation/linux/i386/linux_sysent.c delete mode 100644 sys/emulation/linux/i386/linux_sysvec.c delete mode 100644 sys/emulation/linux/i386/linux_union.h delete mode 100644 sys/emulation/linux/i386/syscalls.conf delete mode 100644 sys/emulation/linux/i386/syscalls.master delete mode 100644 sys/emulation/linux/linux_emuldata.c delete mode 100644 sys/emulation/linux/linux_emuldata.h delete mode 100644 sys/emulation/linux/linux_epoll.c delete mode 100644 sys/emulation/linux/linux_epoll.h delete mode 100644 sys/emulation/linux/linux_file.c delete mode 100644 sys/emulation/linux/linux_futex.c delete mode 100644 sys/emulation/linux/linux_futex.h delete mode 100644 sys/emulation/linux/linux_getcwd.c delete mode 100644 sys/emulation/linux/linux_ioctl.c delete mode 100644 sys/emulation/linux/linux_ioctl.h delete mode 100644 sys/emulation/linux/linux_ipc.c delete mode 100644 sys/emulation/linux/linux_ipc.h delete mode 100644 sys/emulation/linux/linux_mib.c delete mode 100644 sys/emulation/linux/linux_mib.h delete mode 100644 sys/emulation/linux/linux_misc.c delete mode 100644 sys/emulation/linux/linux_signal.c delete mode 100644 sys/emulation/linux/linux_signal.h delete mode 100644 sys/emulation/linux/linux_socket.c delete mode 100644 sys/emulation/linux/linux_socket.h delete mode 100644 sys/emulation/linux/linux_stats.c delete mode 100644 sys/emulation/linux/linux_sysctl.c delete mode 100644 sys/emulation/linux/linux_sysproto.h delete mode 100644 sys/emulation/linux/linux_time.c delete mode 100644 sys/emulation/linux/linux_uid16.c delete mode 100644 sys/emulation/linux/linux_util.c delete mode 100644 sys/emulation/linux/linux_util.h delete mode 100644 usr.bin/truss/i386-linux.c delete mode 100644 usr.bin/truss/i386linux.conf diff --git a/Makefile_upgrade.inc b/Makefile_upgrade.inc index e83ee35c89..99003b7b9d 100644 --- a/Makefile_upgrade.inc +++ b/Makefile_upgrade.inc @@ -3116,6 +3116,16 @@ TO_REMOVE+=/usr/share/man/man8/mk-amd-map.8.gz TO_REMOVE+=/usr/share/man/man8/wire-test.8.gz TO_REMOVE+=/usr/include/varargs.h TO_REMOVE+=/usr/include/bus/pci/pcibus.h +TO_REMOVE+=/usr/include/emulation/linux/linux_emuldata.h +TO_REMOVE+=/usr/include/emulation/linux/linux_epoll.h +TO_REMOVE+=/usr/include/emulation/linux/linux_futex.h +TO_REMOVE+=/usr/include/emulation/linux/linux_ioctl.h +TO_REMOVE+=/usr/include/emulation/linux/linux_ipc.h +TO_REMOVE+=/usr/include/emulation/linux/linux_mib.h +TO_REMOVE+=/usr/include/emulation/linux/linux_signal.h +TO_REMOVE+=/usr/include/emulation/linux/linux_socket.h +TO_REMOVE+=/usr/include/emulation/linux/linux_sysproto.h +TO_REMOVE+=/usr/include/emulation/linux/linux_util.h TO_REMOVE+=/usr/share/openssl/man/man3/CMS_set1_signer_certs.3.gz TO_REMOVE+=/usr/share/openssl/man/man3/d2i_509_CRL_fp.3.gz TO_REMOVE+=/usr/share/openssl/man/man3/EVP_PKEY_ctrl.3.gz diff --git a/etc/defaults/make.conf b/etc/defaults/make.conf index 408bf73e6f..b9a7604aeb 100644 --- a/etc/defaults/make.conf +++ b/etc/defaults/make.conf @@ -121,7 +121,7 @@ THREAD_LIB?= thread_xu #MODULES_WITH_WORLD=true # do not build modules when building kernel # # The list of modules to build instead of all of them. -#MODULES_OVERRIDE= emulation/linux net/ipfw +#MODULES_OVERRIDE= net/ipfw # # The paper size for groff(1), either "letter" or "A4" #GROFF_PAPER_SIZE= letter diff --git a/include/Makefile b/include/Makefile index f005fa6844..a232176ee8 100644 --- a/include/Makefile +++ b/include/Makefile @@ -62,7 +62,6 @@ LSUBDIRS= \ dev/raid/ciss dev/raid/mfi \ dev/smbus/smb \ dev/video/bktr dev/video/meteor \ - emulation/linux \ gnu/vfs/ext2fs \ libprop \ net/bridge net/tap net/tun net/ppp net/ppp_layer net/sl \ diff --git a/share/man/man9/syscall.9 b/share/man/man9/syscall.9 index 4e677b2638..0ff744e1eb 100644 --- a/share/man/man9/syscall.9 +++ b/share/man/man9/syscall.9 @@ -164,8 +164,6 @@ system call switch tables; system call argument lists; .It Pa sys/sys/syscall.h system call numbers. -.\".It Pa sys/emulation/linux/i386 -.\"Linux emulation system calls. .El .Sh SEE ALSO .Xr ktrace 2 , diff --git a/sys/Makefile b/sys/Makefile index 4b2539ee13..881afe0121 100644 --- a/sys/Makefile +++ b/sys/Makefile @@ -28,7 +28,6 @@ HTAGSFLAGS+= -at `awk -F= '/^RELEASE *=/{release=$2}; END {print "FreeBSD", rele all_sysent: (cd ${.CURDIR}/kern; ${MAKE} sysent) - (cd ${.CURDIR}/emulation/linux/i386; ${MAKE} sysent) # XXX this may be temporary, should the module build be incorporated # into the default build (make the SUBDIR additions above non-conditional)? diff --git a/sys/bus/cam/scsi/scsi_sg.c b/sys/bus/cam/scsi/scsi_sg.c index 9cb96edc92..916f7945e2 100644 --- a/sys/bus/cam/scsi/scsi_sg.c +++ b/sys/bus/cam/scsi/scsi_sg.c @@ -52,8 +52,6 @@ #include "../cam_debug.h" #include "../cam_sim.h" -#include - #include "scsi_all.h" #include "scsi_message.h" #include "scsi_sg.h" @@ -448,6 +446,7 @@ sgioctl(struct dev_ioctl_args *ap) error = 0; switch (ap->a_cmd) { +#if 0 case LINUX_SCSI_GET_BUS_NUMBER: { int busno; @@ -465,12 +464,11 @@ sgioctl(struct dev_ioctl_args *ap) error = copyout(&idlun, ap->a_data, sizeof(idlun)); break; } +#endif case SG_GET_VERSION_NUM: - case LINUX_SG_GET_VERSION_NUM: error = copyout(&sg_version, ap->a_data, sizeof(sg_version)); break; - case SG_SET_TIMEOUT: - case LINUX_SG_SET_TIMEOUT: { + case SG_SET_TIMEOUT: { u_int user_timeout; error = copyin(ap->a_data, &user_timeout, sizeof(u_int)); @@ -481,7 +479,6 @@ sgioctl(struct dev_ioctl_args *ap) break; } case SG_GET_TIMEOUT: - case LINUX_SG_GET_TIMEOUT: /* * The value is returned directly to the syscall. */ @@ -489,7 +486,6 @@ sgioctl(struct dev_ioctl_args *ap) error = 0; break; case SG_IO: - case LINUX_SG_IO: error = copyin(ap->a_data, &req, sizeof(req)); if (error) break; @@ -567,8 +563,7 @@ sgioctl(struct dev_ioctl_args *ap) xpt_release_ccb(ccb); break; - case SG_GET_RESERVED_SIZE: - case LINUX_SG_GET_RESERVED_SIZE: { + case SG_GET_RESERVED_SIZE: { int size = 32768; error = copyout(&size, ap->a_data, sizeof(size)); @@ -576,7 +571,6 @@ sgioctl(struct dev_ioctl_args *ap) } case SG_GET_SCSI_ID: - case LINUX_SG_GET_SCSI_ID: { struct sg_scsi_id id; @@ -613,25 +607,6 @@ sgioctl(struct dev_ioctl_args *ap) case SG_SET_COMMAND_Q: case SG_SET_DEBUG: case SG_NEXT_CMD_LEN: - case LINUX_SG_EMULATED_HOST: - case LINUX_SG_SET_TRANSFORM: - case LINUX_SG_GET_TRANSFORM: - case LINUX_SG_GET_NUM_WAITING: - case LINUX_SG_SCSI_RESET: - case LINUX_SG_GET_REQUEST_TABLE: - case LINUX_SG_SET_KEEP_ORPHAN: - case LINUX_SG_GET_KEEP_ORPHAN: - case LINUX_SG_GET_ACCESS_COUNT: - case LINUX_SG_SET_FORCE_LOW_DMA: - case LINUX_SG_GET_LOW_DMA: - case LINUX_SG_GET_SG_TABLESIZE: - case LINUX_SG_SET_FORCE_PACK_ID: - case LINUX_SG_GET_PACK_ID: - case LINUX_SG_SET_RESERVED_SIZE: - case LINUX_SG_GET_COMMAND_Q: - case LINUX_SG_SET_COMMAND_Q: - case LINUX_SG_SET_DEBUG: - case LINUX_SG_NEXT_CMD_LEN: default: #ifdef CAMDEBUG kprintf("sgioctl: rejecting cmd 0x%lx\n", ap->a_cmd); diff --git a/sys/dev/raid/aac/Makefile b/sys/dev/raid/aac/Makefile index 962a103522..a6a80b42cf 100644 --- a/sys/dev/raid/aac/Makefile +++ b/sys/dev/raid/aac/Makefile @@ -1,9 +1,5 @@ # $FreeBSD: src/sys/modules/aac/Makefile,v 1.9 2010/08/23 06:13:29 imp Exp $ -.if ${MACHINE_ARCH} == "i386" -SUBDIR= aac_linux -.endif - KMOD= aac SRCS= aac.c aac_pci.c aac_disk.c aac_cam.c SRCS+= opt_scsi.h opt_cam.h opt_aac.h diff --git a/sys/dev/raid/aac/aac_linux.c b/sys/dev/raid/aac/aac_linux.c deleted file mode 100644 index 60f0964466..0000000000 --- a/sys/dev/raid/aac/aac_linux.c +++ /dev/null @@ -1,100 +0,0 @@ -/*- - * Copyright (c) 2002 Scott Long - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 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. - * - * $FreeBSD: head/sys/dev/aac/aac_linux.c 165393 2006-12-20 17:10:53Z delphij $ - */ - -/* - * Linux ioctl handler for the aac device driver - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef __x86_64__ -#include -#include -#else -#include -#include -#endif -#include - -#include /* needed by aac_ioctl.h */ -#include - -/* Define ioctl mappings */ -static struct ioctl_map_range aac_linux_ioctl_cmds[] = { - MAPPED_IOCTL_MAP(FSACTL_LNX_SENDFIB, FSACTL_SENDFIB), - MAPPED_IOCTL_MAP(FSACTL_LNX_GET_COMM_PERF_DATA, FSACTL_GET_COMM_PERF_DATA), - MAPPED_IOCTL_MAP(FSACTL_LNX_OPENCLS_COMM_PERF_DATA, FSACTL_OPENCLS_COMM_PERF_DATA), - MAPPED_IOCTL_MAP(FSACTL_LNX_OPEN_GET_ADAPTER_FIB, FSACTL_OPEN_GET_ADAPTER_FIB), - MAPPED_IOCTL_MAP(FSACTL_LNX_GET_NEXT_ADAPTER_FIB, FSACTL_GET_NEXT_ADAPTER_FIB), - MAPPED_IOCTL_MAP(FSACTL_LNX_CLOSE_GET_ADAPTER_FIB, FSACTL_CLOSE_GET_ADAPTER_FIB), - MAPPED_IOCTL_MAP(FSACTL_LNX_CLOSE_ADAPTER_CONFIG, FSACTL_CLOSE_ADAPTER_CONFIG), - MAPPED_IOCTL_MAP(FSACTL_LNX_OPEN_ADAPTER_CONFIG, FSACTL_OPEN_ADAPTER_CONFIG), - MAPPED_IOCTL_MAP(FSACTL_LNX_MINIPORT_REV_CHECK, FSACTL_MINIPORT_REV_CHECK), - MAPPED_IOCTL_MAP(FSACTL_LNX_QUERY_ADAPTER_CONFIG, FSACTL_QUERY_ADAPTER_CONFIG), - MAPPED_IOCTL_MAP(FSACTL_LNX_GET_PCI_INFO, FSACTL_GET_PCI_INFO), - MAPPED_IOCTL_MAP(FSACTL_LNX_FORCE_DELETE_DISK, FSACTL_FORCE_DELETE_DISK), - MAPPED_IOCTL_MAP(FSACTL_LNX_AIF_THREAD, FSACTL_AIF_THREAD), - MAPPED_IOCTL_MAP(FSACTL_LNX_NULL_IO_TEST, FSACTL_NULL_IO_TEST), - MAPPED_IOCTL_MAP(FSACTL_LNX_SIM_IO_TEST, FSACTL_SIM_IO_TEST), - MAPPED_IOCTL_MAP(FSACTL_LNX_DOWNLOAD, FSACTL_DOWNLOAD), - MAPPED_IOCTL_MAP(FSACTL_LNX_GET_VAR, FSACTL_GET_VAR), - MAPPED_IOCTL_MAP(FSACTL_LNX_SET_VAR, FSACTL_SET_VAR), - MAPPED_IOCTL_MAP(FSACTL_LNX_GET_FIBTIMES, FSACTL_GET_FIBTIMES), - MAPPED_IOCTL_MAP(FSACTL_LNX_ZERO_FIBTIMES, FSACTL_ZERO_FIBTIMES), - MAPPED_IOCTL_MAP(FSACTL_LNX_DELETE_DISK, FSACTL_DELETE_DISK), - MAPPED_IOCTL_MAP(FSACTL_LNX_QUERY_DISK, FSACTL_QUERY_DISK), - MAPPED_IOCTL_MAP(FSACTL_LNX_PROBE_CONTAINERS, FSACTL_PROBE_CONTAINERS), - MAPPED_IOCTL_MAPF(0 ,0, NULL) -}; - -static struct ioctl_map_handler aac_linux_ioctl_handler = { - &linux_ioctl_map, - "aac_linux", - aac_linux_ioctl_cmds -}; - -SYSINIT (aac_register, SI_BOOT2_KLD, SI_ORDER_MIDDLE, - mapped_ioctl_register_handler, &aac_linux_ioctl_handler); -SYSUNINIT(aac_unregister, SI_BOOT2_KLD, SI_ORDER_MIDDLE, - mapped_ioctl_unregister_handler, &aac_linux_ioctl_handler); - -static int -aac_linux_modevent(module_t mod, int type, void *data) -{ - /* Do we care about any specific load/unload actions? */ - return (0); -} - -DEV_MODULE(aac_linux, aac_linux_modevent, NULL); -MODULE_DEPEND(aac_linux, linux, 1, 1, 1); diff --git a/sys/dev/raid/aac/aac_linux/Makefile b/sys/dev/raid/aac/aac_linux/Makefile deleted file mode 100644 index 5ada686475..0000000000 --- a/sys/dev/raid/aac/aac_linux/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -# $FreeBSD: src/sys/modules/aac/aac_linux/Makefile,v 1.1 2002/09/25 05:00:25 scottl Exp $ - -.PATH: ${.CURDIR}/.. - -KMOD= aac_linux -SRCS= aac_linux.c - -.include diff --git a/sys/dev/raid/amr/Makefile b/sys/dev/raid/amr/Makefile index debf8bb555..d8aec9fffd 100644 --- a/sys/dev/raid/amr/Makefile +++ b/sys/dev/raid/amr/Makefile @@ -1,9 +1,6 @@ # $FreeBSD: src/sys/modules/amr/Makefile,v 1.14 2010/08/23 06:13:29 imp Exp $ SUBDIR= amr_cam -#.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64" -#SUBDIR+= amr_linux -#.endif KMOD= amr SRCS= amr.c amr_pci.c amr_disk.c device_if.h bus_if.h pci_if.h diff --git a/sys/dev/raid/amr/amr_linux.c b/sys/dev/raid/amr/amr_linux.c deleted file mode 100644 index e43e5a0e4f..0000000000 --- a/sys/dev/raid/amr/amr_linux.c +++ /dev/null @@ -1,80 +0,0 @@ -/*- - * Copyright (c) 2005 Paul Saab - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 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. - * - * $FreeBSD: src/sys/dev/amr/amr_linux.c,v 1.5 2009/05/20 17:29:21 imp Exp $ - */ - -#include -#include -#include -#include -#include -#include -#include - -#if defined(__x86_64__) /* Assume amd64 wants 32 bit Linux */ -#include -#include -#else -#include -#include -#endif -#include - -/* There are multiple ioctl number ranges that need to be handled */ -#define AMR_LINUX_IOCTL_MIN 0x6d00 -#define AMR_LINUX_IOCTL_MAX 0x6d01 - -static linux_ioctl_function_t amr_linux_ioctl; -static struct linux_ioctl_handler amr_linux_handler = {amr_linux_ioctl, - AMR_LINUX_IOCTL_MIN, - AMR_LINUX_IOCTL_MAX}; - -SYSINIT (amr_register, SI_SUB_KLD, SI_ORDER_MIDDLE, - linux_ioctl_register_handler, &amr_linux_handler); -SYSUNINIT(amr_unregister, SI_SUB_KLD, SI_ORDER_MIDDLE, - linux_ioctl_unregister_handler, &amr_linux_handler); - -static int -amr_linux_modevent(module_t mod, int cmd, void *data) -{ - return (0); -} - -DEV_MODULE(amr_linux, amr_linux_modevent, NULL); -MODULE_DEPEND(amr, linux, 1, 1, 1); - -static int -amr_linux_ioctl(struct thread *p, struct linux_ioctl_args *args) -{ - struct file *fp; - int error; - - if ((error = fget(p, args->fd, &fp)) != 0) - return (error); - error = fo_ioctl(fp, args->cmd, (caddr_t)args->arg, p->td_ucred, p); - fdrop(fp, p); - return (error); -} diff --git a/sys/dev/raid/amr/amr_linux/Makefile b/sys/dev/raid/amr/amr_linux/Makefile deleted file mode 100644 index ec14676e8d..0000000000 --- a/sys/dev/raid/amr/amr_linux/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -# $FreeBSD: src/sys/modules/amr/amr_linux/Makefile,v 1.1 2006/01/24 21:13:49 ambrisko Exp $ - -.PATH: ${.CURDIR}/.. - -KMOD= amr_linux -SRCS= amr_linux.c device_if.h bus_if.h - -.include diff --git a/sys/dev/raid/mfi/Makefile b/sys/dev/raid/mfi/Makefile index 62557da25a..6932492443 100644 --- a/sys/dev/raid/mfi/Makefile +++ b/sys/dev/raid/mfi/Makefile @@ -2,11 +2,6 @@ SUBDIR= mfip -#.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64" -.if ${MACHINE_ARCH} == "i386" -SUBDIR+= mfi_linux -.endif - KMOD= mfi SRCS= mfi.c mfi_pci.c mfi_disk.c mfi_debug.c mfi_syspd.c mfi_tbolt.c SRCS+= opt_mfi.h opt_cam.h diff --git a/sys/dev/raid/mfi/mfi_linux.c b/sys/dev/raid/mfi/mfi_linux.c deleted file mode 100644 index 343add6aa6..0000000000 --- a/sys/dev/raid/mfi/mfi_linux.c +++ /dev/null @@ -1,77 +0,0 @@ -/*- - * Copyright (c) 2006 IronPort Systems - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 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. - * - * $FreeBSD: src/sys/dev/mfi/mfi_linux.c,v 1.3 2009/05/20 17:29:21 imp Exp $ - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(__x86_64__) /* Assume amd64 wants 32 bit Linux */ -#include -#include -#else -#include -#include -#endif -#include -#include - -#include -#include - -static struct ioctl_map_range mfi_linux_ioctl_cmds[] = { - MAPPED_IOCTL_MAP(MFI_LINUX_CMD, MFI_CMD), - MAPPED_IOCTL_MAP(MFI_LINUX_CMD_2, MFI_CMD), - MAPPED_IOCTL_MAP(MFI_LINUX_SET_AEN, MFI_SET_AEN), - MAPPED_IOCTL_MAP(MFI_LINUX_SET_AEN_2, MFI_SET_AEN), - MAPPED_IOCTL_MAPF(0 ,0, NULL) -}; - -static struct ioctl_map_handler mfi_linux_ioctl_handler = { - &linux_ioctl_map, - "mfi_linux", - mfi_linux_ioctl_cmds -}; - -SYSINIT (mfi_register, SI_BOOT2_KLD, SI_ORDER_MIDDLE, - mapped_ioctl_register_handler, &mfi_linux_ioctl_handler); -SYSUNINIT(mfi_unregister, SI_BOOT2_KLD, SI_ORDER_MIDDLE, - mapped_ioctl_unregister_handler, &mfi_linux_ioctl_handler); - -static int -mfi_linux_modevent(module_t mod, int cmd, void *data) -{ - return (0); -} - -DEV_MODULE(mfi_linux, mfi_linux_modevent, NULL); -MODULE_DEPEND(mfi, linux, 1, 1, 1); diff --git a/sys/dev/raid/mfi/mfi_linux/Makefile b/sys/dev/raid/mfi/mfi_linux/Makefile deleted file mode 100644 index ebc4ba5da3..0000000000 --- a/sys/dev/raid/mfi/mfi_linux/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -# $FreeBSD: src/sys/modules/mfi/mfi_linux/Makefile,v 1.1 2006/05/18 23:30:48 ambrisko Exp $ - -.PATH: ${.CURDIR}/.. - -KMOD= mfi_linux -SRCS= mfi_linux.c - -.include diff --git a/sys/emulation/Makefile b/sys/emulation/Makefile index 154652e294..5b0bf9ef00 100644 --- a/sys/emulation/Makefile +++ b/sys/emulation/Makefile @@ -1,7 +1,3 @@ SUBDIR= ndis -.if ${MACHINE_ARCH} == "i386" -SUBDIR+=linux -.endif - .include diff --git a/sys/emulation/linux/Makefile b/sys/emulation/linux/Makefile deleted file mode 100644 index 81bc9fdb5f..0000000000 --- a/sys/emulation/linux/Makefile +++ /dev/null @@ -1,43 +0,0 @@ -# $FreeBSD: src/sys/modules/linux/Makefile,v 1.34.2.12 2003/01/02 20:41:34 kan Exp $ - -.PATH: ${.CURDIR}/${MACHINE_ARCH} - -ARCH= arch_linux -KMOD= linux -SRCS= linux_dummy.c linux_emuldata.c linux_epoll.c \ - linux_file.c linux_futex.c linux_getcwd.c linux_ioctl.c \ - linux_ipc.c \ - linux_machdep.c linux_mib.c linux_misc.c linux_time.c linux_signal.c \ - linux_socket.c \ - linux_stats.c linux_sysctl.c linux_sysent.c linux_sysvec.c \ - linux_util.c opt_compat.h opt_global.h -SRCS+= bus_if.h device_if.h -SRCS+= opt_nfs.h assym.s -OBJS= linux_support.o linux_locore.o - -SUBDIR= ${MACHINE_ARCH} -.if ${MACHINE_ARCH} == "i386" -SRCS+= linux_ptrace.c linux_uid16.c imgact_linux.c opt_cpu.h -.endif - -CLEANFILES= linux_assym.h linux_genassym.o - -linux_assym.h: linux_genassym.o - -.if exists(@) -linux_assym.h: @/kern/genassym.sh -.endif - sh @/kern/genassym.sh linux_genassym.o > ${.TARGET} - -linux_locore.o: linux_locore.s linux_assym.h - ${CC} -c -x assembler-with-cpp -DLOCORE ${CFLAGS} \ - ${.IMPSRC} -o ${.TARGET} - -linux_support.o: linux_support.s linux_assym.h assym.s - ${CC} -c -x assembler-with-cpp -DLOCORE ${CFLAGS} \ - ${.IMPSRC} -o ${.TARGET} - -linux_genassym.o: linux_genassym.c linux.h @ - ${CC} -c ${CFLAGS:N-fno-common} ${.IMPSRC} - -.include diff --git a/sys/emulation/linux/i386/Makefile b/sys/emulation/linux/i386/Makefile deleted file mode 100644 index efd673250a..0000000000 --- a/sys/emulation/linux/i386/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -# Makefile for syscall tables -# -# $FreeBSD: src/sys/i386/linux/Makefile,v 1.4 1999/08/28 00:45:21 peter Exp $ - -all: - @echo "make sysent only" - -sysent: ${.CURDIR}/linux_sysent.c - -${.CURDIR}/linux_sysent.c ${.CURDIR}/linux_syscall.h \ -${.CURDIR}/linux_proto.h ${.CURDIR}/linux_union.h: \ - ${.CURDIR}/../../../kern/makesyscalls.sh \ - ${.CURDIR}/syscalls.master ${.CURDIR}/syscalls.conf - -mv -f ${.CURDIR}/linux_sysent.c ${.CURDIR}/linux_sysent.c.bak - -mv -f ${.CURDIR}/linux_syscall.h ${.CURDIR}/linux_syscall.h.bak - -mv -f ${.CURDIR}/linux_proto.h ${.CURDIR}/linux_proto.h.bak - -mv -f ${.CURDIR}/linux_union.h ${.CURDIR}/linux_union.h.bak - cd ${.CURDIR} && sh ../../../kern/makesyscalls.sh syscalls.master syscalls.conf - -SUBDIR= linprocfs - -.include diff --git a/sys/emulation/linux/i386/imgact_linux.c b/sys/emulation/linux/i386/imgact_linux.c deleted file mode 100644 index cd272bc8d3..0000000000 --- a/sys/emulation/linux/i386/imgact_linux.c +++ /dev/null @@ -1,239 +0,0 @@ -/*- - * Copyright (c) 1994-1996 Søren Schmidt - * All rights reserved. - * - * Based heavily on /sys/kern/imgact_aout.c which is: - * Copyright (c) 1993, David Greenman - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer - * in this position and unchanged. - * 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 - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD: src/sys/i386/linux/imgact_linux.c,v 1.35.2.2 2001/11/03 01:41:08 ps Exp $ - * $DragonFly: src/sys/emulation/linux/i386/imgact_linux.c,v 1.10 2006/12/28 21:24:02 dillon Exp $ - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "linux.h" - -static int exec_linux_imgact (struct image_params *iparams); - -static int -exec_linux_imgact(struct image_params *imgp) -{ - const struct exec *a_out = (const struct exec *) imgp->image_header; - struct vmspace *vmspace; - vm_offset_t vmaddr; - unsigned long virtual_offset, file_offset; - vm_offset_t buffer; - unsigned long bss_size; - int error; - - if (((a_out->a_magic >> 16) & 0xff) != 0x64) - return -1; - - /* - * Set file/virtual offset based on a.out variant. - */ - switch ((int)(a_out->a_magic & 0xffff)) { - case 0413: - virtual_offset = 0; - file_offset = 1024; - break; - case 0314: - virtual_offset = 4096; - file_offset = 0; - break; - default: - return (-1); - } - bss_size = round_page(a_out->a_bss); -#ifdef DEBUG - kprintf("imgact: text: %08lx, data: %08lx, bss: %08lx\n", - (u_long)a_out->a_text, (u_long)a_out->a_data, bss_size); -#endif - - /* - * Check various fields in header for validity/bounds. - */ - if (a_out->a_entry < virtual_offset || - a_out->a_entry >= virtual_offset + a_out->a_text || - a_out->a_text & PAGE_MASK || a_out->a_data & PAGE_MASK) - return (-1); - - /* text + data can't exceed file size */ - if (a_out->a_data + a_out->a_text > imgp->attr->va_size) - return (EFAULT); - /* - * text/data/bss must not exceed limits - */ - if (a_out->a_text > maxtsiz || - a_out->a_data + bss_size > imgp->proc->p_rlimit[RLIMIT_DATA].rlim_cur) - return (ENOMEM); - - /* - * Destroy old process VM and create a new one (with a new stack) - */ - exec_new_vmspace(imgp, NULL); - vmspace = imgp->proc->p_vmspace; - - /* - * Check if file_offset page aligned,. - * Currently we cannot handle misalinged file offsets, - * and so we read in the entire image (what a waste). - */ - if (file_offset & PAGE_MASK) { -#ifdef DEBUG - kprintf("imgact: Non page aligned binary %lu\n", file_offset); -#endif - /* - * Map text+data+bss read/write/execute - */ - vmaddr = virtual_offset; - error = vm_map_find(&vmspace->vm_map, NULL, NULL, - 0, &vmaddr, - a_out->a_text + a_out->a_data + bss_size, - PAGE_SIZE, - FALSE, VM_MAPTYPE_NORMAL, - VM_PROT_ALL, VM_PROT_ALL, 0); - if (error) - return error; - - error = vm_mmap(&kernel_map, &buffer, - round_page(a_out->a_text + a_out->a_data + file_offset), - VM_PROT_READ, VM_PROT_READ, 0, - (caddr_t) imgp->vp, trunc_page(file_offset)); - if (error) - return error; - - error = copyout((caddr_t)(void *)(uintptr_t)(buffer + file_offset), - (caddr_t)vmaddr, a_out->a_text + a_out->a_data); - - vm_map_remove(&kernel_map, buffer, - buffer + round_page(a_out->a_text + a_out->a_data + file_offset)); - - if (error) - return error; - - /* - * remove write enable on the 'text' part - */ - error = vm_map_protect(&vmspace->vm_map, - vmaddr, - vmaddr + a_out->a_text, - VM_PROT_EXECUTE|VM_PROT_READ, - TRUE); - if (error) - return error; - } - else { -#ifdef DEBUG - kprintf("imgact: Page aligned binary %lu\n", file_offset); -#endif - /* - * Map text+data read/execute - */ - vmaddr = virtual_offset; - error = vm_mmap(&vmspace->vm_map, &vmaddr, - a_out->a_text + a_out->a_data, - VM_PROT_READ | VM_PROT_EXECUTE, - VM_PROT_ALL, - MAP_PRIVATE | MAP_FIXED, - (caddr_t)imgp->vp, file_offset); - if (error) - return (error); - -#ifdef DEBUG - kprintf("imgact: startaddr=%08lx, length=%08lx\n", - (u_long)vmaddr, a_out->a_text + a_out->a_data); -#endif - /* - * allow read/write of data - */ - error = vm_map_protect(&vmspace->vm_map, - vmaddr + a_out->a_text, - vmaddr + a_out->a_text + a_out->a_data, - VM_PROT_ALL, - FALSE); - if (error) - return (error); - - /* - * Allocate anon demand-zeroed area for uninitialized data - */ - if (bss_size != 0) { - vmaddr = virtual_offset + a_out->a_text + a_out->a_data; - error = vm_map_find(&vmspace->vm_map, NULL, NULL, - 0, &vmaddr, - bss_size, PAGE_SIZE, - FALSE, VM_MAPTYPE_NORMAL, - VM_PROT_ALL, VM_PROT_ALL, - 0); - if (error) - return (error); -#ifdef DEBUG - kprintf("imgact: bssaddr=%08lx, length=%08lx\n", - (u_long)vmaddr, bss_size); -#endif - - } - /* Indicate that this file should not be modified */ - imgp->vp->v_flag |= VTEXT; - } - /* Fill in process VM information */ - vmspace->vm_tsize = round_page(a_out->a_text) >> PAGE_SHIFT; - vmspace->vm_dsize = round_page(a_out->a_data + bss_size) >> PAGE_SHIFT; - vmspace->vm_taddr = (caddr_t)(void *)(uintptr_t)virtual_offset; - vmspace->vm_daddr = (caddr_t)(void *)(uintptr_t) - (virtual_offset + a_out->a_text); - - /* Fill in image_params */ - imgp->interpreted = 0; - imgp->entry_addr = a_out->a_entry; - - imgp->proc->p_sysent = &linux_sysvec; - return (0); -} - -/* - * Tell kern_execve.c about it, with a little help from the linker. - */ -static struct execsw linux_execsw = { exec_linux_imgact, "linux a.out" }; -EXEC_SET(linuxaout, linux_execsw); diff --git a/sys/emulation/linux/i386/linprocfs/Makefile b/sys/emulation/linux/i386/linprocfs/Makefile deleted file mode 100644 index 5f05b5b7c0..0000000000 --- a/sys/emulation/linux/i386/linprocfs/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# $FreeBSD: src/sys/modules/linprocfs/Makefile,v 1.1.2.3 2000/06/06 11:53:28 des Exp $ - -KMOD= linprocfs -SRCS= linprocfs_misc.c linprocfs_subr.c \ - linprocfs_vfsops.c linprocfs_vnops.c - -.include diff --git a/sys/emulation/linux/i386/linprocfs/linprocfs.h b/sys/emulation/linux/i386/linprocfs/linprocfs.h deleted file mode 100644 index 89bf5582fc..0000000000 --- a/sys/emulation/linux/i386/linprocfs/linprocfs.h +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright (c) 2000 Dag-Erling Coïdan Smørgrav - * Copyright (c) 1999 Pierre Beyssac - * Copyright (c) 1993 Jan-Simon Pendry - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Jan-Simon Pendry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * @(#)procfs.h 8.9 (Berkeley) 5/14/95 - * - * $FreeBSD: src/sys/i386/linux/linprocfs/linprocfs.h,v 1.2.2.4 2001/06/25 19:46:47 pirzyk Exp $ - * $DragonFly: src/sys/emulation/linux/i386/linprocfs/linprocfs.h,v 1.10 2007/02/03 09:50:49 y0netan1 Exp $ - */ - -/* - * The different types of node in a procfs filesystem - */ -typedef enum { - Proot, /* the filesystem root */ - Pself, /* symbolic link for curproc */ - Pproc, /* a process-specific sub-directory */ - Pexe, /* the executable file */ - Pmem, /* the process's memory image */ - Pprocstat, /* the process's status */ - Pprocstatus, /* the process's status (again) */ - Pmeminfo, /* memory system statistics */ - Pcpuinfo, /* CPU model, speed and features */ - Pstat, /* kernel/system statistics */ - Puptime, /* system uptime */ - Pversion, /* system version */ - Ploadavg, /* system load average */ - Pnet, /* the net sub-directory */ - Pnetdev, /* net devices */ - Psys, /* the sys sub-directory */ - Psyskernel, /* the sys/kernel sub-directory */ - Pdevices, /* devices */ - Posrelease, /* osrelease */ - Postype, /* ostype */ - Ppidmax, /* pid_max */ - Pcwd, - Pprocroot, - Pfd, - Pcmdline, - Penviron, - Pmaps, - Pstatm, - Pmounts, -} pfstype; - -/* - * control data for the proc file system. - */ -struct pfsnode { - struct pfsnode *pfs_next; /* next on list */ - struct vnode *pfs_vnode; /* vnode associated with this pfsnode */ - pfstype pfs_type; /* type of procfs node */ - pid_t pfs_pid; /* associated process */ - u_short pfs_mode; /* mode bits for stat() */ - u_long pfs_flags; /* open flags */ - u_long pfs_fileno; /* unique file id */ - struct thread *pfs_lockowner; /* pfs lock owner */ -}; - -#define PROCFS_NAMELEN 8 /* max length of a filename component */ - -/* - * Kernel stuff follows - */ -#ifdef _KERNEL -#define CNEQ(cnp, s, len) \ - ((cnp)->cn_namelen == (len) && \ - (bcmp((s), (cnp)->cn_nameptr, (len)) == 0)) - -#define KMEM_GROUP 2 - -#define PROCFS_FILENO(pid, type) \ - (((type) < Pproc) ? \ - ((type) + 2) : \ - ((((pid)+1) << 4) + ((int) (type)))) - -/* - * Convert between pfsnode vnode - */ -#define VTOPFS(vp) ((struct pfsnode *)(vp)->v_data) -#define PFSTOV(pfs) ((pfs)->pfs_vnode) - -typedef struct vfs_namemap vfs_namemap_t; -struct vfs_namemap { - const char *nm_name; - int nm_val; -}; - -int vfs_getuserstr (struct uio *, char *, int *); -vfs_namemap_t *vfs_findname (vfs_namemap_t *, char *, int); - -/* */ -struct reg; -struct fpreg; -struct dbreg; - -#define PFIND(pid) ((pid) ? pfindn(pid) : &proc0) /* pfindn() not MPSAFE XXX */ - -void linprocfs_exit (struct thread *); -int linprocfs_freevp (struct vnode *); -int linprocfs_allocvp (struct mount *, struct vnode **, long, pfstype); -int linprocfs_sstep (struct proc *); -void linprocfs_fix_sstep (struct proc *); -struct proc *linprocfs_pfind(pid_t pfs_pid); -#if 0 -int linprocfs_read_regs (struct proc *, struct reg *); -int linprocfs_write_regs (struct proc *, struct reg *); -int linprocfs_read_fpregs (struct proc *, struct fpreg *); -int linprocfs_write_fpregs (struct proc *, struct fpreg *); -int linprocfs_read_dbregs (struct proc *, struct dbreg *); -int linprocfs_write_dbregs (struct proc *, struct dbreg *); -#endif -int linprocfs_domeminfo (struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio); -int linprocfs_docpuinfo (struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio); -int linprocfs_domounts (struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio); -int linprocfs_dostat (struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio); -int linprocfs_douptime (struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio); -int linprocfs_doversion (struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio); -int linprocfs_doprocstat (struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio); -int linprocfs_doprocstatus (struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio); -int linprocfs_doloadavg (struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio); -int linprocfs_donetdev (struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio); -int linprocfs_dodevices (struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio); -int linprocfs_doosrelease (struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio); -int linprocfs_doostype (struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio); -int linprocfs_dopidmax (struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio); -int linprocfs_domaps(struct proc *curp, struct proc *p, struct pfsnode *pfs, struct uio *uio); -int linprocfs_dostatm(struct proc *curp, struct proc *p, struct pfsnode *pfs, struct uio *uio); -/* functions to check whether or not files should be displayed */ -int linprocfs_validfile (struct proc *); - -#define PROCFS_LOCKED 0x01 -#define PROCFS_WANT 0x02 - -#define PFS_DEAD 0x80000000 /* or'd with pid */ - -int linprocfs_root (struct mount *, struct vnode **); -int linprocfs_rw (struct vop_read_args *); -#endif /* _KERNEL */ diff --git a/sys/emulation/linux/i386/linprocfs/linprocfs_misc.c b/sys/emulation/linux/i386/linprocfs/linprocfs_misc.c deleted file mode 100644 index d4080d1dfe..0000000000 --- a/sys/emulation/linux/i386/linprocfs/linprocfs_misc.c +++ /dev/null @@ -1,869 +0,0 @@ -/* - * Copyright (c) 2000 Dag-Erling Coïdan Smørgrav - * Copyright (c) 1999 Pierre Beyssac - * Copyright (c) 1993 Jan-Simon Pendry - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Jan-Simon Pendry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * @(#)procfs_status.c 8.4 (Berkeley) 6/15/94 - * - * $FreeBSD: src/sys/i386/linux/linprocfs/linprocfs_misc.c,v 1.3.2.8 2001/06/25 19:46:47 pirzyk Exp $ - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "linprocfs.h" -#include "../linux.h" -#include "../../linux_ioctl.h" -#include "../../linux_mib.h" - -/* - * Various conversion macros - */ -#define T2J(x) (((x) * 100) / (stathz ? stathz : hz)) /* ticks to jiffies */ -#define T2S(x) ((x) / (stathz ? stathz : hz)) /* ticks to seconds */ -#define B2K(x) ((unsigned long)((x) >> 10)) /* bytes to kbytes */ -#define P2B(x) ((x) << PAGE_SHIFT) /* pages to bytes */ -#define P2K(x) ((x) << (PAGE_SHIFT - 10)) /* pages to kbytes */ - -int -linprocfs_domeminfo(struct proc *curp, struct proc *p, struct pfsnode *pfs, - struct uio *uio) -{ - char *ps; - char psbuf[512]; /* XXX - conservative */ - unsigned long memtotal; /* total memory in bytes */ - unsigned long memused; /* used memory in bytes */ - unsigned long memfree; /* free memory in bytes */ - unsigned long memshared; /* shared memory ??? */ - unsigned long buffers, cached; /* buffer / cache memory ??? */ - unsigned long long swaptotal; /* total swap space in bytes */ - unsigned long long swapused; /* used swap space in bytes */ - unsigned long long swapfree; /* free swap space in bytes */ - int n; - - if (uio->uio_rw != UIO_READ) - return (EOPNOTSUPP); - - memtotal = Maxmem * PAGE_SIZE; - /* - * The correct thing here would be: - * - memfree = vmstats.v_free_count * PAGE_SIZE; - memused = memtotal - memfree; - * - * but it might mislead linux binaries into thinking there - * is very little memory left, so we cheat and tell them that - * all memory that isn't wired down is free. - */ - memused = vmstats.v_wire_count * PAGE_SIZE; - memfree = memtotal - memused; - if (swapblist == NULL) { - swaptotal = 0; - swapfree = 0; - } else { - swaptotal = swapblist->bl_blocks * 1024LL; /* XXX why 1024? */ - swapfree = (unsigned long long)swapblist->bl_root->u.bmu_avail * PAGE_SIZE; - } - swapused = swaptotal - swapfree; - memshared = 0; - - for (n = 0; n < ncpus; ++n) { - globaldata_t gd = globaldata_find(n); - - memshared += gd->gd_vmtotal.t_arm; - } - memshared *= PAGE_SIZE; - - /* - * We'd love to be able to write: - * - buffers = bufspace; - * - * but bufspace is internal to vfs_bio.c and we don't feel - * like unstaticizing it just for linprocfs's sake. - */ - buffers = 0; - cached = vmstats.v_cache_count * PAGE_SIZE; - - ps = psbuf; - ps += ksprintf(ps, - " total: used: free: shared: buffers: cached:\n" - "Mem: %lu %lu %lu %lu %lu %lu\n" - "Swap: %llu %llu %llu\n" - "MemTotal: %9lu kB\n" - "MemFree: %9lu kB\n" - "MemShared:%9lu kB\n" - "Buffers: %9lu kB\n" - "Cached: %9lu kB\n" - "SwapTotal:%9lu kB\n" - "SwapFree: %9lu kB\n", - memtotal, memused, memfree, memshared, buffers, cached, - swaptotal, swapused, swapfree, - B2K(memtotal), B2K(memfree), - B2K(memshared), B2K(buffers), B2K(cached), - B2K(swaptotal), B2K(swapfree)); - - return (uiomove_frombuf(psbuf, ps - psbuf, uio)); -} - -int -linprocfs_docpuinfo(struct proc *curp, struct proc *p, struct pfsnode *pfs, - struct uio *uio) -{ - char *ps; - char psbuf[8192]; - char hwmodel[128]; - size_t modellen = sizeof(hwmodel); - int mib[] = { CTL_HW, HW_MODEL }; - int class; - int cpu; - int i; - int error; -#if 0 - extern char *cpu_model; /* Yuck */ -#endif - /* We default the flags to include all non-conflicting flags, - and the Intel versions of conflicting flags. Note the space - before each name; that is significant, and should be - preserved. */ - - static char *flags[] = { - "fpu", "vme", "de", "pse", "tsc", - "msr", "pae", "mce", "cx8", "apic", - "sep", "sep", "mtrr", "pge", "mca", - "cmov", "pat", "pse36", "pn", "b19", - "b20", "b21", "mmxext", "mmx", "fxsr", - "xmm", "b26", "b27", "b28", "b29", - "3dnowext", "3dnow" - }; - - if (uio->uio_rw != UIO_READ) - return (EOPNOTSUPP); - - switch (cpu_class) { - case CPUCLASS_286: - class = 2; - break; - case CPUCLASS_386: - class = 3; - break; - case CPUCLASS_486: - class = 4; - break; - case CPUCLASS_586: - class = 5; - break; - case CPUCLASS_686: - class = 6; - break; - default: - class = 0; - break; - } - - ps = psbuf; - - error = kernel_sysctl(mib, 2, hwmodel, &modellen, NULL, 0, NULL); - if (error) - strcpy(hwmodel, "unknown"); - - for (cpu = 0; cpu < ncpus; cpu++) { - ps += ksprintf(ps, - "processor\t: %d\n" - "vendor_id\t: %.20s\n" - "cpu family\t: %d\n" - "model\t\t: %d\n" - "model name\t: %s\n" - "stepping\t: %d\n", - cpu, cpu_vendor, class, cpu, hwmodel, cpu_id & 0xf); - } - - ps += ksprintf(ps, - "flags\t\t:"); - - if (cpu_vendor_id == CPU_VENDOR_AMD && (class < 6)) { - flags[16] = "fcmov"; - } - - for (i = 0; i < 32; i++) - if (cpu_feature & (1 << i)) - ps += ksprintf(ps, " %s", flags[i]); - ps += ksprintf(ps, "\n"); - if (class >= 5) { - ps += ksprintf(ps, - "cpu MHz\t\t: %d.%02d\n" - "bogomips\t: %d.%02d\n", - (int)((tsc_frequency + 4999) / 1000000), - (int)((tsc_frequency + 4999) / 10000) % 100, - (int)((tsc_frequency + 4999) / 1000000), - (int)((tsc_frequency + 4999) / 10000) % 100); - } - - return (uiomove_frombuf(psbuf, ps - psbuf, uio)); -} - -static unsigned int -cpucnt(int offset) -{ - int i; - int count = 0; - - for (i = 0; i < ncpus; ++i) { - struct globaldata *gd = globaldata_find(i); - count += *(unsigned int *)((char *)&gd->gd_cnt + offset); - } - return(count); -} - -static int -linprocfs_domounts_callback(struct mount *mp, void *data) -{ - struct statfs *st; - struct sbuf *sb = (struct sbuf *)data; - char *to, *from, *fs; - - st = &mp->mnt_stat; - - from = st->f_mntfromname; - to = st->f_mntonname; - fs = st->f_fstypename; - - if (!strcmp(st->f_fstypename, "linprocfs")) - fs = "proc"; - else if (!strcmp(st->f_fstypename, "ext2fs")) - fs = "ext2"; - else if (!strcmp(st->f_fstypename, "msdos")) - fs = "vfat"; - else if (!strcmp(st->f_fstypename, "msdosfs")) - fs = "vfat"; - - sbuf_printf(sb, "%s %s %s %s", from, to, fs, - st->f_flags & MNT_RDONLY ? "ro" : "rw"); - -#define OPT_ADD(name, flag) if (st->f_flags & (flag)) sbuf_printf(sb, "," name) - OPT_ADD("sync", MNT_SYNCHRONOUS); - OPT_ADD("noexec", MNT_NOEXEC); - OPT_ADD("nosuid", MNT_NOSUID); - OPT_ADD("nodev", MNT_NODEV); - OPT_ADD("async", MNT_ASYNC); - OPT_ADD("suiddir", MNT_SUIDDIR); - OPT_ADD("nosymfollow", MNT_NOSYMFOLLOW); - OPT_ADD("noatime", MNT_NOATIME); -#undef OPT_ADD - - sbuf_printf(sb, " 0 0\n"); - - return 0; -} - -int -linprocfs_domounts(struct proc *curp, struct proc *p, struct pfsnode *pfs, - struct uio *uio) -{ - struct sbuf *sb; - int error; - - sb = sbuf_new_auto(); - - error = mountlist_scan(linprocfs_domounts_callback, sb, MNTSCAN_FORWARD); - - sbuf_finish(sb); - if (error == 0) - error = uiomove_frombuf(sbuf_data(sb), sbuf_len(sb), uio); - sbuf_delete(sb); - return (error); -} - -int -linprocfs_dostat(struct proc *curp, struct proc *p, struct pfsnode *pfs, - struct uio *uio) -{ - char *ps; - char psbuf[8192]; - int cpu; - - ps = psbuf; - ps += ksprintf(ps, - "cpu %"PRIu64" %"PRIu64" %"PRIu64" %"PRIu64"\n", - T2J(cpu_time.cp_user), - T2J(cpu_time.cp_nice), - T2J(cpu_time.cp_sys), - T2J(cpu_time.cp_idle)); - - for (cpu = 0; cpu < ncpus; cpu++) { - ps += ksprintf(ps, - "cpu%d %"PRIu64" %"PRIu64" %"PRIu64" %"PRIu64"\n", - cpu, - T2J(cputime_percpu[cpu].cp_user), - T2J(cputime_percpu[cpu].cp_nice), - T2J(cputime_percpu[cpu].cp_sys), - T2J(cputime_percpu[cpu].cp_idle)); - } - - ps += ksprintf(ps, - "disk 0 0 0 0\n" - "page %u %u\n" - "swap %u %u\n" - "intr %u\n" - "ctxt %u\n" - "btime %ld\n", - cpucnt(offsetof(struct vmmeter, v_vnodepgsin)), - cpucnt(offsetof(struct vmmeter, v_vnodepgsout)), - cpucnt(offsetof(struct vmmeter, v_swappgsin)), - cpucnt(offsetof(struct vmmeter, v_swappgsout)), - cpucnt(offsetof(struct vmmeter, v_intr)), - cpucnt(offsetof(struct vmmeter, v_swtch)), - boottime.tv_sec); - - return (uiomove_frombuf(psbuf, ps - psbuf, uio)); -} - -int -linprocfs_douptime(struct proc *curp, struct proc *p, struct pfsnode *pfs, - struct uio *uio) -{ - char *ps; - char psbuf[64]; - struct timeval tv; - - getmicrouptime(&tv); - ps = psbuf; - ps += ksprintf(ps, "%ld.%02ld %"PRIu64".%02"PRIu64"\n", - tv.tv_sec, tv.tv_usec / 10000, - T2S(cpu_time.cp_idle), T2J(cpu_time.cp_idle) % 100); - return (uiomove_frombuf(psbuf, ps - psbuf, uio)); -} - -int -linprocfs_doversion(struct proc *curp, struct proc *p, struct pfsnode *pfs, - struct uio *uio) -{ - char *ps; - size_t xlen; - - ps = version; /* XXX not entirely correct */ - for (xlen = 0; ps[xlen] != '\n'; ++xlen) - /* nothing */ ; - ++xlen; - return (uiomove_frombuf(ps, xlen, uio)); -} - -#define B2P(x) ((x) >> PAGE_SHIFT) /* bytes to pages */ -int -linprocfs_dostatm(struct proc *curp, struct proc *p, struct pfsnode *pfs, - struct uio *uio) -{ - char *ps, psbuf[1024]; - struct kinfo_proc kp; - - lwkt_gettoken(&p->p_token); - fill_kinfo_proc(p, &kp); - - ps = psbuf; - ps += ksprintf(ps, "%d", p->p_pid); -#define PS_ADD(name, fmt, arg) ps += ksprintf(ps, " " fmt, arg) - PS_ADD("", "%ju", B2P((uintmax_t)(kp.kp_vm_tsize + kp.kp_vm_dsize + kp.kp_vm_ssize))); - PS_ADD("", "%ju", (uintmax_t)kp.kp_vm_rssize); - PS_ADD("", "%ju", (uintmax_t)0); /* XXX */ - PS_ADD("", "%ju", (uintmax_t)kp.kp_vm_tsize); - PS_ADD("", "%ju", (uintmax_t)kp.kp_vm_dsize); - PS_ADD("", "%ju", (uintmax_t)kp.kp_vm_ssize); - PS_ADD("", "%ju", (uintmax_t)0); /* XXX */ -#undef PS_ADD - ps += ksprintf(ps, "\n"); - lwkt_reltoken(&p->p_token); - - return (uiomove_frombuf(psbuf, ps - psbuf, uio)); -} - -#define P2K(x) ((x) << (PAGE_SHIFT - 10)) /* pages to kbytes */ -int -linprocfs_doprocstat(struct proc *curp, struct proc *p, struct pfsnode *pfs, - struct uio *uio) -{ - vm_map_t map = &p->p_vmspace->vm_map; - vm_map_entry_t entry; - vm_offset_t start, end; - char *ps, psbuf[1024]; - struct kinfo_proc kp; - - lwkt_gettoken(&p->p_token); - fill_kinfo_proc(p, &kp); - - start = 0; - end = 0; - vm_map_lock_read(map); - for (entry = map->header.next; entry != &map->header; - entry = entry->next) { - if (entry->maptype != VM_MAPTYPE_NORMAL && - entry->maptype != VM_MAPTYPE_VPAGETABLE) { - continue; - } - /* Assuming that text is the first entry */ - start = entry->start; - end = entry->end; - } - vm_map_unlock_read(map); - - ps = psbuf; - ps += ksprintf(ps, "%d", p->p_pid); -#define PS_ADD(name, fmt, arg) ps += ksprintf(ps, " " fmt, arg) - PS_ADD("comm", "(%s)", p->p_comm); - PS_ADD("statr", "%c", '0'); /* XXX */ - PS_ADD("ppid", "%d", p->p_pptr ? p->p_pptr->p_pid : 0); - PS_ADD("pgrp", "%d", p->p_pgid); - PS_ADD("session", "%d", p->p_session->s_sid); - PS_ADD("tty", "%d", 0); /* XXX */ - PS_ADD("tpgid", "%d", kp.kp_tpgid); /* XXX */ - PS_ADD("flags", "%u", 0); /* XXX */ - PS_ADD("minflt", "%lu", kp.kp_ru.ru_minflt); /* XXX */ - PS_ADD("cminflt", "%lu", kp.kp_cru.ru_minflt); /* XXX */ - PS_ADD("majflt", "%lu", kp.kp_ru.ru_majflt); /* XXX */ - PS_ADD("cmajflt", "%lu", kp.kp_cru.ru_majflt); /* XXX */ - PS_ADD("utime", "%d", T2J(tvtohz_high(&kp.kp_ru.ru_utime))); /* XXX */ - PS_ADD("stime", "%d", T2J(tvtohz_high(&kp.kp_ru.ru_stime))); /* XXX */ - PS_ADD("cutime", "%d", T2J(tvtohz_high(&kp.kp_cru.ru_utime))); /* XXX */ - PS_ADD("cstime", "%d", T2J(tvtohz_high(&kp.kp_cru.ru_stime))); /* XXX */ - PS_ADD("priority", "%d", 0); /* XXX */ - PS_ADD("nice", "%d", kp.kp_nice); - PS_ADD("timeout", "%u", 0); /* XXX */ - PS_ADD("itrealvalue", "%u", 0); /* XXX */ - PS_ADD("starttime", "%d", T2J(tvtohz_high(&kp.kp_start))); /* XXX */ - PS_ADD("vsize", "%ju", P2K((uintmax_t)(kp.kp_vm_tsize + kp.kp_vm_dsize + kp.kp_vm_ssize))); /* XXX: not sure */ - PS_ADD("rss", "%ju", (uintmax_t)kp.kp_vm_rssize); /* XXX */ - PS_ADD("rlim", "%lu", kp.kp_ru.ru_maxrss); /* XXX */ - PS_ADD("startcode", "%lu", start); /* XXX */ - PS_ADD("endcode", "%lu", end); /* XXX */ - PS_ADD("startstack", "%lu", (u_long)p->p_vmspace->vm_minsaddr); /* XXX */ - PS_ADD("kstkesp", "%u", 0); /* XXX */ - PS_ADD("kstkeip", "%u", 0); /* XXX */ - PS_ADD("signal", "%d", 0); /* XXX */ - PS_ADD("blocked", "%d", 0); /* XXX */ - PS_ADD("sigignore", "%d", 0); /* XXX */ - PS_ADD("sigcatch", "%d", 0); /* XXX */ - PS_ADD("wchan", "%u", 0); /* XXX */ - PS_ADD("nswap", "%lu", kp.kp_ru.ru_nswap); /* XXX */ - PS_ADD("cnswap", "%lu", kp.kp_cru.ru_nswap); /* XXX */ - PS_ADD("exitsignal", "%d", 0); /* XXX */ - PS_ADD("processor", "%u", kp.kp_lwp.kl_cpuid); /* XXX */ - PS_ADD("rt_priority", "%u", 0); /* XXX */ /* >= 2.5.19 */ - PS_ADD("policy", "%u", kp.kp_nice); /* XXX */ /* >= 2.5.19 */ -#undef PS_ADD - ps += ksprintf(ps, "\n"); - lwkt_reltoken(&p->p_token); - - return (uiomove_frombuf(psbuf, ps - psbuf, uio)); -} - -/* - * Map process state to descriptive letter. Note that this does not - * quite correspond to what Linux outputs, but it's close enough. - */ -static char *state_str[] = { - "? (unknown)", - "I (idle)", - "R (running)", - "T (stopped)", - "Z (zombie)", - "S (sleeping)", - "W (waiting)", - "M (mutex)" -}; - -int -linprocfs_doprocstatus(struct proc *curp, struct proc *p, struct pfsnode *pfs, - struct uio *uio) -{ - char *ps, psbuf[1024]; - char *state; - int i; - - ps = psbuf; - - lwkt_gettoken(&p->p_token); - if (p->p_stat > NELEM(state_str)) - state = state_str[0]; - else - state = state_str[(int)p->p_stat]; - -#define PS_ADD ps += ksprintf - PS_ADD(ps, "Name:\t%s\n", p->p_comm); /* XXX escape */ - PS_ADD(ps, "State:\t%s\n", state); - - /* - * Credentials - */ - PS_ADD(ps, "Pid:\t%d\n", p->p_pid); - PS_ADD(ps, "PPid:\t%d\n", p->p_pptr ? p->p_pptr->p_pid : 0); - PS_ADD(ps, "Uid:\t%d %d %d %d\n", p->p_ucred->cr_ruid, - p->p_ucred->cr_uid, - p->p_ucred->cr_svuid, - /* FreeBSD doesn't have fsuid */ - p->p_ucred->cr_uid); - PS_ADD(ps, "Gid:\t%d %d %d %d\n", p->p_ucred->cr_rgid, - p->p_ucred->cr_gid, - p->p_ucred->cr_svgid, - /* FreeBSD doesn't have fsgid */ - p->p_ucred->cr_gid); - PS_ADD(ps, "Groups:\t"); - for (i = 0; i < p->p_ucred->cr_ngroups; i++) - PS_ADD(ps, "%d ", p->p_ucred->cr_groups[i]); - PS_ADD(ps, "\n"); - - /* - * Memory - */ - PS_ADD(ps, "VmSize:\t%8lu kB\n", B2K(p->p_vmspace->vm_map.size)); - PS_ADD(ps, "VmLck:\t%8u kB\n", P2K(0)); /* XXX */ - /* XXX vm_rssize seems to always be zero, how can this be? */ - PS_ADD(ps, "VmRss:\t%8u kB\n", P2K(p->p_vmspace->vm_rssize)); - PS_ADD(ps, "VmData:\t%8u kB\n", P2K(p->p_vmspace->vm_dsize)); - PS_ADD(ps, "VmStk:\t%8u kB\n", P2K(p->p_vmspace->vm_ssize)); - PS_ADD(ps, "VmExe:\t%8u kB\n", P2K(p->p_vmspace->vm_tsize)); - PS_ADD(ps, "VmLib:\t%8u kB\n", P2K(0)); /* XXX */ - - /* - * Signal masks - * - * We support up to 128 signals, while Linux supports 32, - * but we only define 32 (the same 32 as Linux, to boot), so - * just show the lower 32 bits of each mask. XXX hack. - * - * NB: on certain platforms (Sparc at least) Linux actually - * supports 64 signals, but this code is a long way from - * running on anything but i386, so ignore that for now. - */ - PS_ADD(ps, "SigPnd:\t%08x\n", p->p_siglist.__bits[0]); - PS_ADD(ps, "SigBlk:\t%08x\n", 0); /* XXX */ - PS_ADD(ps, "SigIgn:\t%08x\n", p->p_sigignore.__bits[0]); - PS_ADD(ps, "SigCgt:\t%08x\n", p->p_sigcatch.__bits[0]); - - /* - * Linux also prints the capability masks, but we don't have - * capabilities yet, and when we do get them they're likely to - * be meaningless to Linux programs, so we lie. XXX - */ - PS_ADD(ps, "CapInh:\t%016x\n", 0); - PS_ADD(ps, "CapPrm:\t%016x\n", 0); - PS_ADD(ps, "CapEff:\t%016x\n", 0); -#undef PS_ADD - lwkt_reltoken(&p->p_token); - - return (uiomove_frombuf(psbuf, ps - psbuf, uio)); -} - -int -linprocfs_doloadavg(struct proc *curp, struct proc *p, - struct pfsnode *pfs, struct uio *uio) -{ - char *ps, psbuf[512]; - - ps = psbuf; - ps += ksprintf(ps, "%d.%02d %d.%02d %d.%02d %d/%d %d\n", - (int)(averunnable.ldavg[0] / averunnable.fscale), - (int)(averunnable.ldavg[0] * 100 / averunnable.fscale % 100), - (int)(averunnable.ldavg[1] / averunnable.fscale), - (int)(averunnable.ldavg[1] * 100 / averunnable.fscale % 100), - (int)(averunnable.ldavg[2] / averunnable.fscale), - (int)(averunnable.ldavg[2] * 100 / averunnable.fscale % 100), - 1, /* number of running tasks */ - -1, /* number of tasks */ - 1 /* The last pid, just kidding */ - ); - return(uiomove_frombuf(psbuf, ps - psbuf, uio)); -} - -int -linprocfs_donetdev(struct proc *curp, struct proc *p, struct pfsnode *pfs, - struct uio *uio) -{ - struct sbuf *sb; - char ifname[16]; /* XXX LINUX_IFNAMSIZ */ - struct ifnet *ifp; - int error; - - sb = sbuf_new_auto(); - - sbuf_printf(sb, "%6s|%58s|%s\n%6s|%58s|%58s\n", - "Inter-", " Receive", " Transmit", " face", - "bytes packets errs drop fifo frame compressed", - "bytes packets errs drop fifo frame compressed"); - - ifnet_lock(); - TAILQ_FOREACH(ifp, &ifnetlist, if_link) { - linux_ifname(ifp, ifname, sizeof ifname); - sbuf_printf(sb, "%6.6s:", ifname); - sbuf_printf(sb, "%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu ", - 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL); - sbuf_printf(sb, "%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n", - 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL); - } - ifnet_unlock(); - sbuf_finish(sb); - error = uiomove_frombuf(sbuf_data(sb), sbuf_len(sb), uio); - sbuf_delete(sb); - return (error); -} - -static void -linprocfs_dodevices_callback(char *name, cdev_t dev, bool is_alias, void *arg) -{ - struct sbuf *sb = arg; - - sbuf_printf(sb, "%3d %s\n", dev->si_umajor, name); -} - -int -linprocfs_dodevices(struct proc *curp, struct proc *p, struct pfsnode *pfs, - struct uio *uio) -{ - struct sbuf *sb; - int error; - - sb = sbuf_new_auto(); - sbuf_printf(sb, "Character devices:\n"); - devfs_scan_callback(linprocfs_dodevices_callback, sb); - sbuf_printf(sb, "\nBlock devices:\n"); - sbuf_finish(sb); - error = uiomove_frombuf(sbuf_data(sb), sbuf_len(sb), uio); - sbuf_delete(sb); - return (error); -} - -int -linprocfs_doosrelease(struct proc *curp, struct proc *p, struct pfsnode *pfs, - struct uio *uio) -{ - char *osrelease; - - osrelease = linux_get_osrelease(curthread); - return(uiomove_frombuf(osrelease, strlen(osrelease)+1, uio)); -} - -int -linprocfs_doostype(struct proc *curp, struct proc *p, struct pfsnode *pfs, - struct uio *uio) -{ - char *osname; - - osname = linux_get_osname(curthread); - return(uiomove_frombuf(osname, strlen(osname)+1, uio)); -} - -int -linprocfs_dopidmax(struct proc *curp, struct proc *p, struct pfsnode *pfs, - struct uio *uio) -{ - char buf[32]; - - ksnprintf(buf, sizeof(buf), "%d", PID_MAX); - return(uiomove_frombuf(buf, strlen(buf)+1, uio)); -} - -int -linprocfs_domaps(struct proc *curp, struct proc *p, struct pfsnode *pfs, - struct uio *uio) -{ - int error; - vm_map_t map = &p->p_vmspace->vm_map; - vm_map_entry_t entry; - vm_ooffset_t off = 0; - struct sbuf *sb; - char *name = "", *freename = NULL; - struct vnode *vp; - struct vattr vat; - ino_t ino; - - if (uio->uio_rw != UIO_READ) - return (EOPNOTSUPP); - - sb = sbuf_new_auto(); - - error = 0; - vm_map_lock_read(map); - for (entry = map->header.next; - ((uio->uio_resid > 0) && (entry != &map->header)); - entry = entry->next) { - vm_object_t obj, tobj, lobj; - vm_offset_t ostart; - name = ""; - freename = NULL; - ino = 0; - if (entry->maptype != VM_MAPTYPE_NORMAL && - entry->maptype != VM_MAPTYPE_VPAGETABLE) { - continue; - } - /* - * Use map->hint as a poor man's ripout detector. - */ - map->hint = entry; - ostart = entry->start; - - /* - * Find the bottom-most object, leaving the base object - * and the bottom-most object held (but only one hold - * if they happen to be the same). - */ - obj = entry->object.vm_object; - if (obj) - vm_object_hold(obj); - - lobj = obj; - while (lobj && (tobj = lobj->backing_object) != NULL) { - KKASSERT(tobj != obj); - vm_object_hold(tobj); - if (tobj == lobj->backing_object) { - if (lobj != obj) { - vm_object_lock_swap(); - vm_object_drop(lobj); - } - lobj = tobj; - } else { - vm_object_drop(tobj); - } - } - - if (lobj) { - off = IDX_TO_OFF(lobj->size); - if (lobj->type == OBJT_VNODE) { - vp = lobj->handle; - if (vp) - vref(vp); - } else { - vp = NULL; - } - - if (vp) { - vn_fullpath(curproc, vp, &name, &freename, 1); - vn_lock(vp, LK_SHARED | LK_RETRY); - VOP_GETATTR(vp, &vat); - ino = vat.va_fileid; - vput(vp); - } - } - if (freename == NULL) { - if (entry->eflags & MAP_ENTRY_STACK) - name = "[stack]"; - } - - if (lobj != obj) - vm_object_drop(lobj); - if (obj) - vm_object_drop(obj); - - /* - * We cannot safely hold the map locked while accessing - * userspace as a VM fault might recurse the locked map. - */ - vm_map_unlock_read(map); - - /* - * format: - * start-end access offset major:minor inode [.text file] - */ - error = sbuf_printf(sb, - "%08lx-%08lx %s%s%s%s %08llx %02x:%02x %llu%s%s\n", - (u_long)entry->start, (u_long)entry->end, - (entry->protection & VM_PROT_READ)?"r":"-", - (entry->protection & VM_PROT_WRITE)?"w":"-", - (entry->protection & VM_PROT_EXECUTE)?"x":"-", - "p", - off, /* offset */ - 0, /* major */ - 0, /* minor */ - ino, /* inode */ - (name && *name) ? " " : "", - name ? name : ""); - if (error == -1) - error = ENOMEM; - if (freename) - kfree(freename, M_TEMP); - - vm_map_lock_read(map); - if (error) - break; - - /* - * We use map->hint as a poor man's ripout detector. If - * it does not match the entry we set it to prior to - * unlocking the map the entry MIGHT now be stale. In - * this case we do an expensive lookup to find our place - * in the iteration again. - */ - if (map->hint != entry) { - vm_map_entry_t reentry; - - vm_map_lookup_entry(map, ostart, &reentry); - entry = reentry; - } - } - vm_map_unlock_read(map); - - sbuf_finish(sb); - if (error == 0) - error = uiomove_frombuf(sbuf_data(sb) + uio->uio_offset, - sbuf_len(sb) - uio->uio_offset, uio); - sbuf_delete(sb); - return error; -} diff --git a/sys/emulation/linux/i386/linprocfs/linprocfs_subr.c b/sys/emulation/linux/i386/linprocfs/linprocfs_subr.c deleted file mode 100644 index 08e9b91451..0000000000 --- a/sys/emulation/linux/i386/linprocfs/linprocfs_subr.c +++ /dev/null @@ -1,470 +0,0 @@ -/* - * Copyright (c) 2000 Dag-Erling Coïdan Smørgrav - * Copyright (c) 1999 Pierre Beyssac - * Copyright (c) 1993 Jan-Simon Pendry - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Jan-Simon Pendry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * @(#)procfs_subr.c 8.6 (Berkeley) 5/14/95 - * - * $FreeBSD: src/sys/i386/linux/linprocfs/linprocfs_subr.c,v 1.3.2.4 2001/06/25 19:46:47 pirzyk Exp $ - */ - -#include -#include -#include -#include -#include -#include -#include -#include "linprocfs.h" - -#define PFSHSIZE 256 -#define PFSHMASK (PFSHSIZE - 1) - -static struct pfsnode *pfshead[PFSHSIZE]; -static struct lwkt_token pfs_token; -static int pfsvplock; - -extern int procfs_domem (struct proc *, struct lwp *, struct pfsnode *pfsp, struct uio *uio); - -/* - * allocate a pfsnode/vnode pair. the vnode is - * referenced, but not locked. - * - * the pid, pfs_type, and mount point uniquely - * identify a pfsnode. the mount point is needed - * because someone might mount this filesystem - * twice. - * - * all pfsnodes are maintained on a singly-linked - * list. new nodes are only allocated when they cannot - * be found on this list. entries on the list are - * removed when the vfs reclaim entry is called. - * - * a single lock is kept for the entire list. this is - * needed because the getnewvnode() function can block - * waiting for a vnode to become free, in which case there - * may be more than one process trying to get the same - * vnode. this lock is only taken if we are going to - * call getnewvnode, since the kernel itself is single-threaded. - * - * if an entry is found on the list, then call vget() to - * take a reference. this is done because there may be - * zero references to it and so it needs to removed from - * the vnode free list. - */ -int -linprocfs_allocvp(struct mount *mp, struct vnode **vpp, long pid, - pfstype pfs_type) -{ - struct pfsnode *pfs; - struct vnode *vp; - struct pfsnode **pp; - int error; - - lwkt_gettoken(&pfs_token); -loop: - for (pfs = pfshead[pid & PFSHMASK]; pfs; pfs = pfs->pfs_next) { - vp = PFSTOV(pfs); - if (pfs->pfs_pid == pid && - pfs->pfs_type == pfs_type && - vp->v_mount == mp) { - if (vget(vp, LK_EXCLUSIVE|LK_SLEEPFAIL)) - goto loop; - *vpp = vp; - lwkt_reltoken(&pfs_token); - return (0); - } - } - - /* - * otherwise lock the vp list while we call getnewvnode - * since that can block. - */ - if (pfsvplock & PROCFS_LOCKED) { - pfsvplock |= PROCFS_WANT; - (void) tsleep((caddr_t) &pfsvplock, 0, "pfsavp", 0); - goto loop; - } - pfsvplock |= PROCFS_LOCKED; - - /* - * Do the MALLOC before the getnewvnode since doing so afterward - * might cause a bogus v_data pointer to get dereferenced - * elsewhere if MALLOC should block. - */ - pfs = kmalloc(sizeof(struct pfsnode), M_TEMP, M_WAITOK); - - error = getnewvnode(VT_PROCFS, mp, vpp, 0, 0); - if (error) { - kfree(pfs, M_TEMP); - goto out; - } - vp = *vpp; - - vp->v_data = pfs; - - pfs->pfs_next = 0; - pfs->pfs_pid = (pid_t) pid; - pfs->pfs_type = pfs_type; - pfs->pfs_vnode = vp; - pfs->pfs_flags = 0; - pfs->pfs_lockowner = NULL; - pfs->pfs_fileno = PROCFS_FILENO(pid, pfs_type); - - switch (pfs_type) { - case Proot: /* /proc = dr-xr-xr-x */ - vsetflags(vp, VROOT); - /* fallthrough */ - case Pnet: - case Psys: - case Psyskernel: - pfs->pfs_mode = (VREAD|VEXEC) | - (VREAD|VEXEC) >> 3 | - (VREAD|VEXEC) >> 6; - vp->v_type = VDIR; - break; - - case Pself: /* /proc/self = lr--r--r-- */ - pfs->pfs_mode = (VREAD) | - (VREAD >> 3) | - (VREAD >> 6); - vp->v_type = VLNK; - break; - - case Pproc: - pfs->pfs_mode = (VREAD|VEXEC) | - (VREAD|VEXEC) >> 3 | - (VREAD|VEXEC) >> 6; - vp->v_type = VDIR; - break; - - case Pexe: - case Pcwd: - case Pprocroot: - case Pfd: - pfs->pfs_mode = (VREAD|VEXEC) | - (VREAD|VEXEC) >> 3 | - (VREAD|VEXEC) >> 6; - vp->v_type = VLNK; - break; - - case Pmem: - pfs->pfs_mode = (VREAD|VWRITE) | - (VREAD) >> 3; - vp->v_type = VREG; - break; - - case Pprocstat: - case Pprocstatus: - case Pcmdline: - case Penviron: - case Pstatm: - /* fallthrough */ - case Pmaps: - case Pmeminfo: - case Pcpuinfo: - case Pmounts: - case Pstat: - case Puptime: - case Pversion: - case Ploadavg: - case Pdevices: - case Pnetdev: - case Posrelease: - case Postype: - case Ppidmax: - pfs->pfs_mode = (VREAD) | - (VREAD >> 3) | - (VREAD >> 6); - vp->v_type = VREG; - break; - - default: - panic("linprocfs_allocvp"); - } - - /* add to procfs vnode list */ - for (pp = &pfshead[pid & PFSHMASK]; *pp; pp = &(*pp)->pfs_next) - continue; - *pp = pfs; - -out: - pfsvplock &= ~PROCFS_LOCKED; - - if (pfsvplock & PROCFS_WANT) { - pfsvplock &= ~PROCFS_WANT; - wakeup((caddr_t) &pfsvplock); - } - lwkt_reltoken(&pfs_token); - - return (error); -} - -int -linprocfs_freevp(struct vnode *vp) -{ - struct pfsnode **pfspp; - struct pfsnode *pfs = VTOPFS(vp); - - lwkt_gettoken(&pfs_token); - pfspp = &pfshead[pfs->pfs_pid & PFSHMASK]; - while (*pfspp != pfs) { - KKASSERT(*pfspp != NULL); - pfspp = &(*pfspp)->pfs_next; - } - *pfspp = pfs->pfs_next; - lwkt_reltoken(&pfs_token); - kfree(vp->v_data, M_TEMP); - vp->v_data = NULL; - return (0); -} - -/* - * Try to find the calling pid. Note that pfind() - * now references the proc structure to be returned - * and needs to be released later with PRELE(). - */ -struct proc * -linprocfs_pfind(pid_t pfs_pid) -{ - struct proc *p = NULL; - - if (pfs_pid == 0) { - p = &proc0; - PHOLD(p); - } else { - p = pfind(pfs_pid); - } - - return p; -} - -int -linprocfs_rw(struct vop_read_args *ap) -{ - struct vnode *vp = ap->a_vp; - struct uio *uio = ap->a_uio; - struct thread *td = uio->uio_td; - struct pfsnode *pfs = VTOPFS(vp); - struct proc *p; - struct proc *curp; - struct lwp *lp; - int rtval; - - curp = td->td_proc; - KKASSERT(curp); - - p = linprocfs_pfind(pfs->pfs_pid); - if (p == NULL) { - rtval = EINVAL; - goto out; - } - if (p->p_pid == 1 && securelevel > 0 && uio->uio_rw == UIO_WRITE) { - rtval = EACCES; - goto out; - } - lp = FIRST_LWP_IN_PROC(p); - LWPHOLD(lp); - - lwkt_gettoken(&pfs_token); - while (pfs->pfs_lockowner) { - tsleep(&pfs->pfs_lockowner, 0, "pfslck", 0); - } - pfs->pfs_lockowner = curthread; - lwkt_reltoken(&pfs_token); - - switch (pfs->pfs_type) { - case Pmem: - rtval = procfs_domem(curp, lp, pfs, uio); - break; - case Pprocstat: - rtval = linprocfs_doprocstat(curp, p, pfs, uio); - break; - case Pprocstatus: - rtval = linprocfs_doprocstatus(curp, p, pfs, uio); - break; - case Pmeminfo: - rtval = linprocfs_domeminfo(curp, p, pfs, uio); - break; - case Pcpuinfo: - rtval = linprocfs_docpuinfo(curp, p, pfs, uio); - break; - case Pmounts: - rtval = linprocfs_domounts(curp, p, pfs, uio); - break; - case Pstat: - rtval = linprocfs_dostat(curp, p, pfs, uio); - break; - case Puptime: - rtval = linprocfs_douptime(curp, p, pfs, uio); - break; - case Pversion: - rtval = linprocfs_doversion(curp, p, pfs, uio); - break; - case Ploadavg: - rtval = linprocfs_doloadavg(curp, p, pfs, uio); - break; - case Pnetdev: - rtval = linprocfs_donetdev(curp, p, pfs, uio); - break; - case Pdevices: - rtval = linprocfs_dodevices(curp, p, pfs, uio); - break; - case Posrelease: - rtval = linprocfs_doosrelease(curp, p, pfs, uio); - break; - case Postype: - rtval = linprocfs_doostype(curp, p, pfs, uio); - break; - case Ppidmax: - rtval = linprocfs_dopidmax(curp, p, pfs, uio); - break; - case Pmaps: - rtval = linprocfs_domaps(curp, p, pfs, uio); - break; - case Pstatm: - rtval = linprocfs_dostatm(curp, p, pfs, uio); - break; - default: - rtval = EOPNOTSUPP; - break; - } - LWPRELE(lp); - - lwkt_gettoken(&pfs_token); - pfs->pfs_lockowner = NULL; - wakeup(&pfs->pfs_lockowner); - lwkt_reltoken(&pfs_token); -out: - if (p) - PRELE(p); - - return rtval; -} - -#if 0 -/* - * Get a string from userland into (buf). Strip a trailing - * nl character (to allow easy access from the shell). - * The buffer should be *buflenp + 1 chars long. vfs_getuserstr - * will automatically add a nul char at the end. - * - * Returns 0 on success or the following errors - * - * EINVAL: file offset is non-zero. - * EMSGSIZE: message is longer than kernel buffer - * EFAULT: user i/o buffer is not addressable - */ -int -vfs_getuserstr(struct uio *uio, char *buf, int *buflenp) -{ - int xlen; - int error; - - if (uio->uio_offset != 0) - return (EINVAL); - - xlen = *buflenp; - - /* must be able to read the whole string in one go */ - if (xlen < uio->uio_resid) - return (EMSGSIZE); - xlen = uio->uio_resid; - - if ((error = uiomove(buf, xlen, uio)) != 0) - return (error); - - /* allow multiple writes without seeks */ - uio->uio_offset = 0; - - /* cleanup string and remove trailing newline */ - buf[xlen] = '\0'; - xlen = strlen(buf); - if (xlen > 0 && buf[xlen-1] == '\n') - buf[--xlen] = '\0'; - *buflenp = xlen; - - return (0); -} - -vfs_namemap_t * -vfs_findname(vfs_namemap_t *nm, char *buf, int buflen) -{ - - for (; nm->nm_name; nm++) - if (bcmp(buf, nm->nm_name, buflen+1) == 0) - return (nm); - - return (0); -} -#endif - -static void -linprocfs_init(void *arg __unused) -{ - lwkt_token_init(&pfs_token, "linprocfs"); -} -SYSINIT(linprocfs_init, SI_SUB_PRE_DRIVERS, SI_ORDER_FIRST, - linprocfs_init, NULL); - -void -linprocfs_exit(struct thread *td) -{ - struct pfsnode *pfs; - struct vnode *vp; - pid_t pid; - - KKASSERT(td->td_proc); - pid = td->td_proc->p_pid; - - /* - * Remove all the procfs vnodes associated with an exiting process. - */ - lwkt_gettoken(&pfs_token); -restart: - for (pfs = pfshead[pid & PFSHMASK]; pfs; pfs = pfs->pfs_next) { - if (pfs->pfs_pid == pid) { - vp = PFSTOV(pfs); - vx_get(vp); - pfs->pfs_pid |= PFS_DEAD; - vx_put(vp); - goto restart; - } - } - lwkt_reltoken(&pfs_token); - lwkt_token_uninit(&pfs_token); -} - diff --git a/sys/emulation/linux/i386/linprocfs/linprocfs_vfsops.c b/sys/emulation/linux/i386/linprocfs/linprocfs_vfsops.c deleted file mode 100644 index d5450ae592..0000000000 --- a/sys/emulation/linux/i386/linprocfs/linprocfs_vfsops.c +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (c) 2000 Dag-Erling Coïdan Smørgrav - * Copyright (c) 1999 Pierre Beyssac - * Copyright (c) 1993 Jan-Simon Pendry - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Jan-Simon Pendry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * @(#)procfs_vfsops.c 8.7 (Berkeley) 5/10/95 - * - * $FreeBSD: src/sys/i386/linux/linprocfs/linprocfs_vfsops.c,v 1.2.2.3 2001/10/15 20:42:01 des Exp $ - */ - -/* - * procfs VFS interface - */ - -#include -#include -#include -#include -#include -#include -#include -#include "linprocfs.h" - -extern struct vop_ops linprocfs_vnode_vops; - -static int linprocfs_mount (struct mount *mp, char *path, caddr_t data, - struct ucred *cred); -static int linprocfs_statfs (struct mount *mp, struct statfs *sbp, - struct ucred *cred); -static int linprocfs_unmount (struct mount *mp, int mntflags); - -/* - * VFS Operations. - * - * mount system call - */ -/* ARGSUSED */ -static int -linprocfs_mount(struct mount *mp, char *path, caddr_t data, struct ucred *cred) -{ - size_t size; - int error; - - if (mp->mnt_flag & MNT_UPDATE) - return (EOPNOTSUPP); - - if (mp->mnt_vfc->vfc_refcount == 1 && (error = at_exit(linprocfs_exit))) { - kprintf("linprocfs: cannot register linprocfs_exit with at_exit\n"); - return(error); - } - - mp->mnt_flag |= MNT_LOCAL; - mp->mnt_kern_flag |= MNTK_NOSTKMNT; - mp->mnt_data = 0; - vfs_getnewfsid(mp); - - vfs_add_vnodeops(mp, &linprocfs_vnode_vops, &mp->mnt_vn_norm_ops); - - size = sizeof("linprocfs") - 1; - bcopy("linprocfs", mp->mnt_stat.f_mntfromname, size); - bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); - (void)linprocfs_statfs(mp, &mp->mnt_stat, cred); - - return (0); -} - -/* - * unmount system call - */ -static int -linprocfs_unmount(struct mount *mp, int mntflags) -{ - int error; - int flags = 0; - - if (mntflags & MNT_FORCE) - flags |= FORCECLOSE; - - error = vflush(mp, 0, flags); - if (error) - return (error); - - if (mp->mnt_vfc->vfc_refcount == 1) - rm_at_exit(linprocfs_exit); - - return (0); -} - -int -linprocfs_root(struct mount *mp, struct vnode **vpp) -{ - - return (linprocfs_allocvp(mp, vpp, 0, Proot)); -} - -/* - * Get file system statistics. - */ -static int -linprocfs_statfs(struct mount *mp, struct statfs *sbp, struct ucred *cred) -{ - sbp->f_bsize = PAGE_SIZE; - sbp->f_iosize = PAGE_SIZE; - sbp->f_blocks = 1; /* avoid divide by zero in some df's */ - sbp->f_bfree = 0; - sbp->f_bavail = 0; - sbp->f_files = maxproc; /* approx */ - sbp->f_ffree = maxproc - nprocs; /* approx */ - - if (sbp != &mp->mnt_stat) { - sbp->f_type = mp->mnt_vfc->vfc_typenum; - bcopy(&mp->mnt_stat.f_fsid, &sbp->f_fsid, sizeof(sbp->f_fsid)); - bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN); - } - - return (0); -} - -static struct vfsops linprocfs_vfsops = { - linprocfs_mount, - vfs_stdstart, - linprocfs_unmount, - linprocfs_root, - vfs_stdquotactl, - linprocfs_statfs, - vfs_stdsync, - vfs_stdvget, - vfs_stdfhtovp, - vfs_stdcheckexp, - vfs_stdvptofh, - vfs_stdinit, -}; - -VFS_SET(linprocfs_vfsops, linprocfs, VFCF_SYNTHETIC); -MODULE_VERSION(linprocfs, 1); -MODULE_DEPEND(linprocfs, linux, 1, 1, 1); -MODULE_DEPEND(linprocfs, procfs, 1, 1, 1); diff --git a/sys/emulation/linux/i386/linprocfs/linprocfs_vnops.c b/sys/emulation/linux/i386/linprocfs/linprocfs_vnops.c deleted file mode 100644 index 3a4171d4f6..0000000000 --- a/sys/emulation/linux/i386/linprocfs/linprocfs_vnops.c +++ /dev/null @@ -1,1664 +0,0 @@ -/* - * Copyright (c) 2000 Dag-Erling Coïdan Smørgrav - * Copyright (c) 1999 Pierre Beyssac - * Copyright (c) 1993, 1995 Jan-Simon Pendry - * Copyright (c) 1993, 1995 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Jan-Simon Pendry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * @(#)procfs_vnops.c 8.18 (Berkeley) 5/21/95 - * - * $FreeBSD: src/sys/i386/linux/linprocfs/linprocfs_vnops.c,v 1.3.2.5 2001/08/12 14:29:19 rwatson Exp $ - */ - -/* - * procfs vnode interface - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "linprocfs.h" -#include -#include - -#include - -extern struct vnode *procfs_findtextvp (struct proc *); - -static int linprocfs_access (struct vop_access_args *); -static int linprocfs_badop (struct vop_generic_args *); -static int linprocfs_bmap (struct vop_bmap_args *); -static int linprocfs_close (struct vop_close_args *); -static int linprocfs_getattr (struct vop_getattr_args *); -static int linprocfs_inactive (struct vop_inactive_args *); -static int linprocfs_ioctl (struct vop_ioctl_args *); -static int linprocfs_lookup (struct vop_old_lookup_args *); -static int linprocfs_open (struct vop_open_args *); -static int linprocfs_print (struct vop_print_args *); -static int linprocfs_readdir (struct vop_readdir_args *); -static int linprocfs_readlink (struct vop_readlink_args *); -static int linprocfs_reclaim (struct vop_reclaim_args *); -static int linprocfs_setattr (struct vop_setattr_args *); - -static int linprocfs_readdir_proc(struct vop_readdir_args *); -static int linprocfs_readdir_root(struct vop_readdir_args *); -static int linprocfs_readdir_net(struct vop_readdir_args *ap); -static int linprocfs_readdir_sys(struct vop_readdir_args *ap); -static int linprocfs_readdir_syskernel(struct vop_readdir_args *ap); - -/* - * procfs vnode operations. - */ -struct vop_ops linprocfs_vnode_vops = { - .vop_default = vop_defaultop, - .vop_access = linprocfs_access, - .vop_advlock = (void *)linprocfs_badop, - .vop_bmap = linprocfs_bmap, - .vop_close = linprocfs_close, - .vop_old_create = (void *)linprocfs_badop, - .vop_getattr = linprocfs_getattr, - .vop_inactive = linprocfs_inactive, - .vop_old_link = (void *)linprocfs_badop, - .vop_old_lookup = linprocfs_lookup, - .vop_old_mkdir = (void *)linprocfs_badop, - .vop_old_mknod = (void *)linprocfs_badop, - .vop_open = linprocfs_open, - .vop_pathconf = vop_stdpathconf, - .vop_print = linprocfs_print, - .vop_read = (void *)linprocfs_rw, - .vop_readdir = linprocfs_readdir, - .vop_readlink = linprocfs_readlink, - .vop_reclaim = linprocfs_reclaim, - .vop_old_remove = (void *)linprocfs_badop, - .vop_old_rename = (void *)linprocfs_badop, - .vop_old_rmdir = (void *)linprocfs_badop, - .vop_setattr = linprocfs_setattr, - .vop_old_symlink = (void *)linprocfs_badop, - .vop_write = (void *)linprocfs_rw, - .vop_ioctl = linprocfs_ioctl -}; - -/* - * This is a list of the valid names in the - * process-specific sub-directories. It is - * used in linprocfs_lookup and linprocfs_readdir - */ -static struct proc_target { - u_char pt_type; - u_char pt_namlen; - char *pt_name; - pfstype pt_pfstype; - int (*pt_valid) (struct proc *p); -} proc_targets[] = { -#define N(s) sizeof(s)-1, s - /* name type validp */ - { DT_DIR, N("."), Pproc, NULL }, - { DT_DIR, N(".."), Proot, NULL }, - { DT_REG, N("mem"), Pmem, NULL }, - - { DT_LNK, N("exe"), Pexe, NULL }, - { DT_LNK, N("cwd"), Pcwd, NULL }, - { DT_LNK, N("root"), Pprocroot, NULL }, - { DT_LNK, N("fd"), Pfd, NULL }, - - { DT_REG, N("stat"), Pprocstat, NULL }, - { DT_REG, N("status"), Pprocstatus, NULL }, - { DT_REG, N("maps"), Pmaps, NULL }, - { DT_REG, N("statm"), Pstatm, NULL }, -#if 0 - { DT_REG, N("cmdline"), Pcmdline, NULL }, - { DT_REG, N("environ"), Penviron, NULL }, -#endif -#undef N -}; -static const int nproc_targets = NELEM(proc_targets); - -static pid_t atopid (const char *, u_int); - -/* - * set things up for doing i/o on - * the pfsnode (vp). (vp) is locked - * on entry, and should be left locked - * on exit. - * - * for procfs we don't need to do anything - * in particular for i/o. all that is done - * is to support exclusive open on process - * memory images. - */ -static int -linprocfs_open(struct vop_open_args *ap) -{ - struct pfsnode *pfs = VTOPFS(ap->a_vp); - struct proc *p2; - int error; - - p2 = linprocfs_pfind(pfs->pfs_pid); - if (p2 == NULL) { - error = ENOENT; - } else if (pfs->pfs_pid && !PRISON_CHECK(ap->a_cred, p2->p_ucred)) { - error = ENOENT; - } else { - error = 0; - - switch (pfs->pfs_type) { - case Pmem: - if (((pfs->pfs_flags & FWRITE) && - (ap->a_mode & O_EXCL)) || - ((pfs->pfs_flags & O_EXCL) && - (ap->a_mode & FWRITE))) { - error = EBUSY; - break; - } - - if (p_trespass(ap->a_cred, p2->p_ucred)) { - error = EPERM; - break; - } - if (ap->a_mode & FWRITE) - pfs->pfs_flags = ap->a_mode & (FWRITE|O_EXCL); - break; - default: - break; - } - } - if (error == 0) - error = vop_stdopen(ap); - if (p2) - PRELE(p2); - return error; -} - -/* - * close the pfsnode (vp) after doing i/o. - * (vp) is not locked on entry or exit. - * - * nothing to do for procfs other than undo - * any exclusive open flag (see _open above). - */ -static int -linprocfs_close(struct vop_close_args *ap) -{ - struct pfsnode *pfs = VTOPFS(ap->a_vp); - struct proc *p; - - switch (pfs->pfs_type) { - case Pmem: - if ((ap->a_fflag & FWRITE) && (pfs->pfs_flags & O_EXCL)) - pfs->pfs_flags &= ~(FWRITE|O_EXCL); - /* - * If this is the last close, then it checks to see if - * the target process has PF_LINGER set in p_pfsflags, - * if this is *not* the case, then the process' stop flags - * are cleared, and the process is woken up. This is - * to help prevent the case where a process has been - * told to stop on an event, but then the requesting process - * has gone away or forgotten about it. - */ - p = NULL; - if ((ap->a_vp->v_opencount < 2) - && (p = linprocfs_pfind(pfs->pfs_pid)) - && !(p->p_pfsflags & PF_LINGER)) { - spin_lock(&p->p_spin); - p->p_stops = 0; - p->p_step = 0; - spin_unlock(&p->p_spin); - wakeup(&p->p_stype); - } - if (p) - PRELE(p); - break; - default: - break; - } - return (vop_stdclose(ap)); -} - -/* - * do an ioctl operation on a pfsnode (vp). - * (vp) is not locked on entry or exit. - */ -static int -linprocfs_ioctl(struct vop_ioctl_args *ap) -{ - struct pfsnode *pfs = VTOPFS(ap->a_vp); - struct proc *procp; - int error; - int signo; - struct procfs_status *psp; - unsigned char flags; - - procp = linprocfs_pfind(pfs->pfs_pid); - if (procp == NULL) - return ENOTTY; - - if (p_trespass(ap->a_cred, procp->p_ucred)) { - error = EPERM; - goto done; - } - - switch (ap->a_command) { - case PIOCBIS: - procp->p_stops |= *(unsigned int*)ap->a_data; - break; - case PIOCBIC: - procp->p_stops &= ~*(unsigned int*)ap->a_data; - break; - case PIOCSFL: - /* - * NFLAGS is "non-suser_xxx flags" -- currently, only - * PFS_ISUGID ("ignore set u/g id"); - */ -#define NFLAGS (PF_ISUGID) - flags = (unsigned char)*(unsigned int*)ap->a_data; - if (flags & NFLAGS && (error = priv_check_cred(ap->a_cred, PRIV_ROOT, 0))) - goto done; - procp->p_pfsflags = flags; - break; - case PIOCGFL: - *(unsigned int*)ap->a_data = (unsigned int)procp->p_pfsflags; - case PIOCSTATUS: - psp = (struct procfs_status *)ap->a_data; - psp->flags = procp->p_pfsflags; - psp->events = procp->p_stops; - spin_lock(&procp->p_spin); - if (procp->p_step) { - psp->state = 0; - psp->why = procp->p_stype; - psp->val = procp->p_xstat; - spin_unlock(&procp->p_spin); - } else { - psp->state = 1; - spin_unlock(&procp->p_spin); - psp->why = 0; /* Not defined values */ - psp->val = 0; /* Not defined values */ - } - break; - case PIOCWAIT: - psp = (struct procfs_status *)ap->a_data; - spin_lock(&procp->p_spin); - if (procp->p_step == 0) { - tsleep_interlock(&procp->p_stype, PCATCH); - spin_unlock(&procp->p_spin); - if (procp->p_stops == 0) { - error = EINVAL; - goto done; - } - if (procp->p_flags & P_POSTEXIT) { - error = EINVAL; - goto done; - } - if (procp->p_flags & P_INEXEC) { - error = EAGAIN; - goto done; - } - error = tsleep(&procp->p_stype, PCATCH | PINTERLOCKED, - "piocwait", 0); - if (error) - goto done; - } else { - spin_unlock(&procp->p_spin); - } - psp->state = 1; /* It stopped */ - psp->flags = procp->p_pfsflags; - psp->events = procp->p_stops; - psp->why = procp->p_stype; /* why it stopped */ - psp->val = procp->p_xstat; /* any extra info */ - break; - case PIOCCONT: /* Restart a proc */ - if (procp->p_step == 0) { - error = EINVAL; /* Can only start a stopped process */ - goto done; - } - if ((signo = *(int*)ap->a_data) != 0) { - if (signo >= NSIG || signo <= 0) { - error = EINVAL; - goto done; - } - ksignal(procp, signo); - } - procp->p_step = 0; - wakeup(&procp->p_step); - break; - default: - error = ENOTTY; - goto done; - } - error = 0; -done: - if (procp) - PRELE(procp); - return error; -} - -/* - * do block mapping for pfsnode (vp). - * since we don't use the buffer cache - * for procfs this function should never - * be called. in any case, it's not clear - * what part of the kernel ever makes use - * of this function. for sanity, this is the - * usual no-op bmap, although returning - * (EIO) would be a reasonable alternative. - */ -static int -linprocfs_bmap(struct vop_bmap_args *ap) -{ - if (ap->a_doffsetp != NULL) - *ap->a_doffsetp = ap->a_loffset; - if (ap->a_runp != NULL) - *ap->a_runp = 0; - if (ap->a_runb != NULL) - *ap->a_runb = 0; - return (0); -} - -/* - * linprocfs_inactive is called when the pfsnode - * is vrele'd and the reference count is about - * to go to zero. (vp) will be on the vnode free - * list, so to get it back vget() must be - * used. - * - * (vp) is locked on entry and must remain locked - * on exit. - */ -static int -linprocfs_inactive(struct vop_inactive_args *ap) -{ - struct pfsnode *pfs = VTOPFS(ap->a_vp); - - if (pfs->pfs_pid & PFS_DEAD) - vrecycle(ap->a_vp); - return (0); -} - -/* - * _reclaim is called when getnewvnode() - * wants to make use of an entry on the vnode - * free list. at this time the filesystem needs - * to free any private data and remove the node - * from any private lists. - */ -static int -linprocfs_reclaim(struct vop_reclaim_args *ap) -{ - return (linprocfs_freevp(ap->a_vp)); -} - -/* - * _print is used for debugging. - * just print a readable description - * of (vp). - */ -static int -linprocfs_print(struct vop_print_args *ap) -{ - struct pfsnode *pfs = VTOPFS(ap->a_vp); - - kprintf("tag VT_PROCFS, type %d, pid %ld, mode %x, flags %lx\n", - pfs->pfs_type, (long)pfs->pfs_pid, pfs->pfs_mode, pfs->pfs_flags); - return (0); -} - -/* - * generic entry point for unsupported operations - */ -static int -linprocfs_badop(struct vop_generic_args *ap __unused) -{ - - return (EIO); -} - -/* - * Invent attributes for pfsnode (vp) and store - * them in (vap). - * Directories lengths are returned as zero since - * any real length would require the genuine size - * to be computed, and nothing cares anyway. - * - * this is relatively minimal for procfs. - */ -static int -linprocfs_getattr(struct vop_getattr_args *ap) -{ - struct pfsnode *pfs = VTOPFS(ap->a_vp); - struct vattr *vap = ap->a_vap; - struct proc *procp; - int error; - - /* - * First make sure that the process and its credentials - * still exist. - */ - switch (pfs->pfs_type) { - case Proot: - case Pself: - procp = NULL; - break; - - default: - procp = linprocfs_pfind(pfs->pfs_pid); - if (procp == NULL || procp->p_ucred == NULL) { - error = ENOENT; - goto done; - } - } - - error = 0; - - /* start by zeroing out the attributes */ - VATTR_NULL(vap); - - /* next do all the common fields */ - vap->va_type = ap->a_vp->v_type; - vap->va_mode = pfs->pfs_mode; - vap->va_fileid = pfs->pfs_fileno; - vap->va_flags = 0; - vap->va_blocksize = PAGE_SIZE; - vap->va_bytes = vap->va_size = 0; - vap->va_fsid = ap->a_vp->v_mount->mnt_stat.f_fsid.val[0]; - - /* - * Make all times be current TOD. - * It would be possible to get the process start - * time from the p_stat structure, but there's - * no "file creation" time stamp anyway, and the - * p_stat structure is not addressible if u. gets - * swapped out for that process. - */ - nanotime(&vap->va_ctime); - vap->va_atime = vap->va_mtime = vap->va_ctime; - - /* - * now do the object specific fields - * - * The size could be set from struct reg, but it's hardly - * worth the trouble, and it puts some (potentially) machine - * dependent data into this machine-independent code. If it - * becomes important then this function should break out into - * a per-file stat function in the corresponding .c file. - */ - - vap->va_nlink = 1; - if (procp) { - vap->va_uid = procp->p_ucred->cr_uid; - vap->va_gid = procp->p_ucred->cr_gid; - } - - switch (pfs->pfs_type) { - case Proot: - case Pnet: - case Psys: - case Psyskernel: - /* - * Set nlink to 1 to tell fts(3) we don't actually know. - */ - vap->va_nlink = 1; - vap->va_uid = 0; - vap->va_gid = 0; - vap->va_size = vap->va_bytes = DEV_BSIZE; - break; - - case Pself: { - char buf[16]; /* should be enough */ - vap->va_uid = 0; - vap->va_gid = 0; - vap->va_size = vap->va_bytes = - ksnprintf(buf, sizeof(buf), "%ld", (long)curproc->p_pid); - break; - } - - case Pproc: - vap->va_nlink = nproc_targets; - vap->va_size = vap->va_bytes = DEV_BSIZE; - break; - - case Pexe: { - char *fullpath, *freepath; - error = cache_fullpath(procp, &procp->p_textnch, NULL, - &fullpath, &freepath, 0); - /* error = vn_fullpath(procp, NULL, &fullpath, &freepath); */ - if (error == 0) { - vap->va_size = strlen(fullpath); - kfree(freepath, M_TEMP); - } else { - vap->va_size = sizeof("unknown") - 1; - error = 0; - } - vap->va_bytes = vap->va_size; - break; - } - case Pcwd: { - char *fullpath, *freepath; - error = cache_fullpath(procp, &procp->p_fd->fd_ncdir, NULL, - &fullpath, &freepath, 0); - if (error == 0) { - vap->va_size = strlen(fullpath); - kfree(freepath, M_TEMP); - } else { - vap->va_size = sizeof("unknown") - 1; - error = 0; - } - vap->va_bytes = vap->va_size; - break; - } - case Pprocroot: { - struct nchandle *nchp; - char *fullpath, *freepath; - nchp = jailed(procp->p_ucred) ? &procp->p_fd->fd_njdir : &procp->p_fd->fd_nrdir; - error = cache_fullpath(procp, nchp, NULL, - &fullpath, &freepath, 0); - if (error == 0) { - vap->va_size = strlen(fullpath); - kfree(freepath, M_TEMP); - } else { - vap->va_size = sizeof("unknown") - 1; - error = 0; - } - vap->va_bytes = vap->va_size; - break; - } - case Pfd: { - if (procp == curproc) { - vap->va_size = sizeof("/dev/fd") - 1; - error = 0; - } else { - vap->va_size = sizeof("unknown") - 1; - error = 0; - } - vap->va_bytes = vap->va_size; - break; - } - - case Pmeminfo: - case Pcpuinfo: - case Pmounts: - case Pstat: - case Puptime: - case Pversion: - case Ploadavg: - case Pnetdev: - case Pdevices: - case Posrelease: - case Postype: - case Ppidmax: - vap->va_bytes = vap->va_size = 0; - vap->va_uid = 0; - vap->va_gid = 0; - break; - - case Pmem: - /* - * If we denied owner access earlier, then we have to - * change the owner to root - otherwise 'ps' and friends - * will break even though they are setgid kmem. *SIGH* - */ - if (procp->p_flags & P_SUGID) - vap->va_uid = 0; - else - vap->va_uid = procp->p_ucred->cr_uid; - break; - - case Pprocstat: - case Pprocstatus: - case Pcmdline: - case Penviron: - case Pmaps: - case Pstatm: - vap->va_bytes = vap->va_size = 0; - /* uid, gid are already set */ - break; - - default: - panic("linprocfs_getattr"); - } -done: - if (procp) - PRELE(procp); - return (error); -} - -static int -linprocfs_setattr(struct vop_setattr_args *ap) -{ - - if (ap->a_vap->va_flags != VNOVAL) - return (EOPNOTSUPP); - - /* - * just fake out attribute setting - * it's not good to generate an error - * return, otherwise things like creat() - * will fail when they try to set the - * file length to 0. worse, this means - * that echo $note > /proc/$pid/note will fail. - */ - - return (0); -} - -/* - * implement access checking. - * - * something very similar to this code is duplicated - * throughout the 4bsd kernel and should be moved - * into kern/vfs_subr.c sometime. - * - * actually, the check for super-user is slightly - * broken since it will allow read access to write-only - * objects. this doesn't cause any particular trouble - * but does mean that the i/o entry points need to check - * that the operation really does make sense. - */ -static int -linprocfs_access(struct vop_access_args *ap) -{ - struct vattr *vap; - struct vattr vattr; - int error; - - /* - * If you're the super-user, - * you always get access. - */ - if (ap->a_cred->cr_uid == 0) - return (0); - - vap = &vattr; - error = VOP_GETATTR(ap->a_vp, vap); - if (error) - return (error); - - /* - * Access check is based on only one of owner, group, public. - * If not owner, then check group. If not a member of the - * group, then check public access. - */ - if (ap->a_cred->cr_uid != vap->va_uid) { - gid_t *gp; - int i; - - ap->a_mode >>= 3; - gp = ap->a_cred->cr_groups; - for (i = 0; i < ap->a_cred->cr_ngroups; i++, gp++) - if (vap->va_gid == *gp) - goto found; - ap->a_mode >>= 3; -found: - ; - } - - if ((vap->va_mode & ap->a_mode) == ap->a_mode) - return (0); - - return (EACCES); -} - -/* - * lookup. this is incredibly complicated in the general case, however - * for most pseudo-filesystems very little needs to be done. - */ -static int -linprocfs_lookup(struct vop_old_lookup_args *ap) -{ - struct componentname *cnp = ap->a_cnp; - struct vnode **vpp = ap->a_vpp; - struct vnode *dvp = ap->a_dvp; - char *pname = cnp->cn_nameptr; - struct proc_target *pt; - pid_t pid; - struct pfsnode *pfs; - struct proc *p; - int i; - int error; - - *vpp = NULL; - p = NULL; - - if (cnp->cn_nameiop == NAMEI_DELETE || - cnp->cn_nameiop == NAMEI_RENAME || - cnp->cn_nameiop == NAMEI_CREATE) { - return (EROFS); - } - - error = 0; - - if (cnp->cn_namelen == 1 && *pname == '.') { - *vpp = dvp; - vref(*vpp); - goto out; - } - - pfs = VTOPFS(dvp); - switch (pfs->pfs_type) { - case Psys: - if (cnp->cn_flags & CNP_ISDOTDOT) { - error = linprocfs_root(dvp->v_mount, vpp); - goto out; - } - if (CNEQ(cnp, "kernel", 6)) { - error = linprocfs_allocvp(dvp->v_mount, vpp, 0, Psyskernel); - goto out; - } - break; - case Pnet: - if (cnp->cn_flags & CNP_ISDOTDOT) { - error = linprocfs_root(dvp->v_mount, vpp); - goto out; - } - if (CNEQ(cnp, "dev", 3)) { - error = linprocfs_allocvp(dvp->v_mount, vpp, 0, Pnetdev); - goto out; - } - break; - case Psyskernel: - if (cnp->cn_flags & CNP_ISDOTDOT) { - /* XXX: this is wrong, wrong, wrong. */ - error = linprocfs_root(dvp->v_mount, vpp); - goto out; - } - if (CNEQ(cnp, "osrelease", 9)) { - error = linprocfs_allocvp(dvp->v_mount, vpp, 0, Posrelease); - goto out; - } - if (CNEQ(cnp, "ostype", 6)) { - error = linprocfs_allocvp(dvp->v_mount, vpp, 0, Postype); - goto out; - } - if (CNEQ(cnp, "pid_max", 7)) { - error = linprocfs_allocvp(dvp->v_mount, vpp, 0, Ppidmax); - goto out; - } - if (CNEQ(cnp, "version", 7)) { - error = linprocfs_allocvp(dvp->v_mount, vpp, 0, Pversion); - goto out; - } - break; - - case Proot: - if (cnp->cn_flags & CNP_ISDOTDOT) - return (EIO); - - if (CNEQ(cnp, "self", 4)) { - error = linprocfs_allocvp(dvp->v_mount, vpp, 0, Pself); - goto out; - } - if (CNEQ(cnp, "meminfo", 7)) { - error = linprocfs_allocvp(dvp->v_mount, vpp, 0, Pmeminfo); - goto out; - } - if (CNEQ(cnp, "cpuinfo", 7)) { - error = linprocfs_allocvp(dvp->v_mount, vpp, 0, Pcpuinfo); - goto out; - } - if (CNEQ(cnp, "mounts", 6)) { - error = linprocfs_allocvp(dvp->v_mount, vpp, 0, Pmounts); - goto out; - } - if (CNEQ(cnp, "stat", 4)) { - error = linprocfs_allocvp(dvp->v_mount, vpp, 0, Pstat); - goto out; - } - if (CNEQ(cnp, "uptime", 6)) { - error = linprocfs_allocvp(dvp->v_mount, vpp, 0, Puptime); - goto out; - } - if (CNEQ(cnp, "version", 7)) { - error = linprocfs_allocvp(dvp->v_mount, vpp, 0, Pversion); - goto out; - } - if (CNEQ(cnp, "loadavg", 7)) { - error = linprocfs_allocvp(dvp->v_mount, vpp, 0, Ploadavg); - goto out; - } - if (CNEQ(cnp, "net", 3)) { - error = linprocfs_allocvp(dvp->v_mount, vpp, 0, Pnet); - goto out; - } - if (CNEQ(cnp, "sys", 3)) { - error = linprocfs_allocvp(dvp->v_mount, vpp, 0, Psys); - goto out; - } - if (CNEQ(cnp, "devices", 7)) { - error = linprocfs_allocvp(dvp->v_mount, vpp, 0, Pdevices); - goto out; - } - - pid = atopid(pname, cnp->cn_namelen); - if (pid == NO_PID) - break; - - p = linprocfs_pfind(pid); - if (p == NULL) - break; - - if (!PRISON_CHECK(ap->a_cnp->cn_cred, p->p_ucred)) - break; - - if (ps_showallprocs == 0 && ap->a_cnp->cn_cred->cr_uid != 0 && - ap->a_cnp->cn_cred->cr_uid != p->p_ucred->cr_uid) - break; - - error = linprocfs_allocvp(dvp->v_mount, vpp, pid, Pproc); - goto out; - - case Pproc: - if (cnp->cn_flags & CNP_ISDOTDOT) { - error = linprocfs_root(dvp->v_mount, vpp); - goto out; - } - - p = linprocfs_pfind(pfs->pfs_pid); - if (p == NULL) - break; - - if (!PRISON_CHECK(ap->a_cnp->cn_cred, p->p_ucred)) - break; - - if (ps_showallprocs == 0 && ap->a_cnp->cn_cred->cr_uid != 0 && - ap->a_cnp->cn_cred->cr_uid != p->p_ucred->cr_uid) - break; - - for (pt = proc_targets, i = 0; i < nproc_targets; pt++, i++) { - if (cnp->cn_namelen == pt->pt_namlen && - bcmp(pt->pt_name, pname, cnp->cn_namelen) == 0 && - (pt->pt_valid == NULL || (*pt->pt_valid)(p))) - goto found; - } - break; - - found: - error = linprocfs_allocvp(dvp->v_mount, vpp, pfs->pfs_pid, - pt->pt_pfstype); - goto out; - - default: - error = ENOTDIR; - goto out; - } - - if (cnp->cn_nameiop == NAMEI_LOOKUP) - error = ENOENT; - else - error = EROFS; - - /* - * If no error occured *vpp will hold a referenced locked vnode. - * dvp was passed to us locked and *vpp must be returned locked - * so if dvp != *vpp and CNP_LOCKPARENT is not set, unlock dvp. - */ -out: - if (p) - PRELE(p); - if (error == 0) { - if (*vpp != dvp && (cnp->cn_flags & CNP_LOCKPARENT) == 0) { - cnp->cn_flags |= CNP_PDIRUNLOCK; - vn_unlock(dvp); - } - } - return (error); -} - -/* - * Does this process have a text file? - */ -int -linprocfs_validfile(struct proc *p) -{ - - return (procfs_findtextvp(p) != NULLVP); -} - -/* - * readdir() returns directory entries from pfsnode (vp). - * - * We generate just one directory entry at a time, as it would probably - * not pay off to buffer several entries locally to save uiomove calls. - * - * linprocfs_readdir(struct vnode *a_vp, struct uio *a_uio, - * struct ucred *a_cred, int *a_eofflag, - * int *a_ncookies, off_t **a_cookies) - */ -static int -linprocfs_readdir(struct vop_readdir_args *ap) -{ - struct pfsnode *pfs; - int error; - - if (ap->a_uio->uio_offset < 0 || ap->a_uio->uio_offset > INT_MAX) - return (EINVAL); - - pfs = VTOPFS(ap->a_vp); - error = vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY | LK_FAILRECLAIM); - if (error) - return (error); - - switch (pfs->pfs_type) { - case Pproc: - /* - * This is for the process-specific sub-directories. - * all that is needed to is copy out all the entries - * from the procent[] table (top of this file). - */ - error = linprocfs_readdir_proc(ap); - break; - case Proot: - /* - * This is for the root of the procfs filesystem - * what is needed is a special entry for "self" - * followed by an entry for each process on allproc - */ - error = linprocfs_readdir_root(ap); - break; - case Pnet: - error = linprocfs_readdir_net(ap); - break; - case Psys: - error = linprocfs_readdir_sys(ap); - break; - case Psyskernel: - error = linprocfs_readdir_syskernel(ap); - break; - default: - error = ENOTDIR; - break; - } - vn_unlock(ap->a_vp); - - return (error); -} - -static int -linprocfs_readdir_proc(struct vop_readdir_args *ap) -{ - struct pfsnode *pfs; - int error, i, retval; - struct proc *p; - struct proc_target *pt; - struct uio *uio = ap->a_uio; - - pfs = VTOPFS(ap->a_vp); - p = linprocfs_pfind(pfs->pfs_pid); - if (p == NULL) - return(0); - if (!PRISON_CHECK(ap->a_cred, p->p_ucred)) { - PRELE(p); - return(0); - } - - error = 0; - i = uio->uio_offset; - - for (pt = &proc_targets[i]; - !error && uio->uio_resid > 0 && i < nproc_targets; pt++, i++) { - if (pt->pt_valid && (*pt->pt_valid)(p) == 0) - continue; - - retval = vop_write_dirent(&error, uio, - PROCFS_FILENO(pfs->pfs_pid, pt->pt_pfstype), pt->pt_type, - pt->pt_namlen, pt->pt_name); - if (retval) - break; - } - - uio->uio_offset = i; - PRELE(p); - - return(error); -} - -struct linprocfs_readdir_root_info { - int error; - int pcnt; - int i; - struct uio *uio; - struct ucred *cred; -}; - -/* - * Scan the root directory by scanning all process - */ -static int linprocfs_readdir_root_callback(struct proc *p, void *data); - -static int -linprocfs_readdir_root(struct vop_readdir_args *ap) -{ - struct linprocfs_readdir_root_info info; - struct uio *uio = ap->a_uio; - int res = 0; - - info.error = 0; - info.i = uio->uio_offset; - info.pcnt = 0; - info.uio = uio; - info.cred = ap->a_cred; - - while (info.pcnt < 13) { - res = linprocfs_readdir_root_callback(NULL, &info); - if (res < 0) - break; - } - if (res >= 0) - allproc_scan(linprocfs_readdir_root_callback, &info); - - uio->uio_offset = info.i; - return(info.error); -} - -static int -linprocfs_readdir_root_callback(struct proc *p, void *data) -{ - struct linprocfs_readdir_root_info *info = data; - int retval; - struct uio *uio = info->uio; - ino_t d_ino; - const char *d_name; - char d_name_pid[20]; - size_t d_namlen; - uint8_t d_type; - - switch (info->pcnt) { - case 0: /* `.' */ - d_ino = PROCFS_FILENO(0, Proot); - d_name = "."; - d_namlen = 1; - d_type = DT_DIR; - break; - case 1: /* `..' */ - d_ino = PROCFS_FILENO(0, Proot); - d_name = ".."; - d_namlen = 2; - d_type = DT_DIR; - break; - - case 2: - d_ino = PROCFS_FILENO(0, Proot); - d_namlen = 4; - d_name = "self"; - d_type = DT_LNK; - break; - - case 3: - d_ino = PROCFS_FILENO(0, Pmeminfo); - d_namlen = 7; - d_name = "meminfo"; - d_type = DT_REG; - break; - - case 4: - d_ino = PROCFS_FILENO(0, Pcpuinfo); - d_namlen = 7; - d_name = "cpuinfo"; - d_type = DT_REG; - break; - - case 5: - d_ino = PROCFS_FILENO(0, Pstat); - d_namlen = 4; - d_name = "stat"; - d_type = DT_REG; - break; - - case 6: - d_ino = PROCFS_FILENO(0, Puptime); - d_namlen = 6; - d_name = "uptime"; - d_type = DT_REG; - break; - - case 7: - d_ino = PROCFS_FILENO(0, Pversion); - d_namlen = 7; - d_name = "version"; - d_type = DT_REG; - break; - - case 8: - d_ino = PROCFS_FILENO(0, Ploadavg); - d_namlen = 7; - d_name = "loadavg"; - d_type = DT_REG; - break; - case 9: - d_ino = PROCFS_FILENO(0, Pnet); - d_namlen = 3; - d_name = "net"; - d_type = DT_DIR; - break; - case 10: - d_ino = PROCFS_FILENO(0, Psys); - d_namlen = 3; - d_name = "sys"; - d_type = DT_DIR; - break; - case 11: - d_ino = PROCFS_FILENO(0, Pmounts); - d_namlen = 6; - d_name = "mounts"; - d_type = DT_DIR; - break; - case 12: - d_ino = PROCFS_FILENO(0, Pdevices); - d_namlen = 7; - d_name = "devices"; - d_type = DT_REG; - break; - default: - /* - * Ignore processes that aren't in our prison - */ - if (PRISON_CHECK(info->cred, p->p_ucred) == 0) - return(0); - - /* - * Ignore processes that we do not want to be visible. - */ - if (ps_showallprocs == 0 && - info->cred->cr_uid != 0 && - info->cred->cr_uid != p->p_ucred->cr_uid) { - return(0); - } - - /* - * Skip processes we have already read (optimization) - */ - if (info->pcnt < info->i) { - ++info->pcnt; - return(0); - } - d_ino = PROCFS_FILENO(p->p_pid, Pproc); - d_namlen = ksnprintf(d_name_pid, sizeof(d_name_pid), - "%ld", (long)p->p_pid); - d_name = d_name_pid; - d_type = DT_DIR; - break; - } - - /* - * Skip processes we have already read - */ - if (info->pcnt < info->i) { - ++info->pcnt; - return(0); - } - retval = vop_write_dirent(&info->error, info->uio, - d_ino, d_type, d_namlen, d_name); - if (retval == 0) { - ++info->pcnt; /* iterate proc candidates scanned */ - ++info->i; /* iterate entries written */ - } - if (retval || info->error || uio->uio_resid <= 0) - return(-1); - return(0); -} - -/* - * Scan the root directory by scanning all process - */ -static int linprocfs_readdir_net_callback(struct proc *p, void *data); - -static int -linprocfs_readdir_net(struct vop_readdir_args *ap) -{ - struct linprocfs_readdir_root_info info; - struct uio *uio = ap->a_uio; - int res; - - info.error = 0; - info.i = uio->uio_offset; - info.pcnt = 0; - info.uio = uio; - info.cred = ap->a_cred; - - while (info.pcnt < 3) { - res = linprocfs_readdir_net_callback(NULL, &info); - if (res < 0) - break; - } - - uio->uio_offset = info.i; - return(info.error); -} - -static int -linprocfs_readdir_net_callback(struct proc *p, void *data) -{ - struct linprocfs_readdir_root_info *info = data; - int retval; - struct uio *uio = info->uio; - ino_t d_ino; - const char *d_name; - size_t d_namlen; - uint8_t d_type; - - switch (info->pcnt) { - case 0: /* `.' */ - d_ino = PROCFS_FILENO(0, Pnet); - d_name = "."; - d_namlen = 1; - d_type = DT_DIR; - break; - case 1: /* `..' */ - d_ino = PROCFS_FILENO(0, Proot); - d_name = ".."; - d_namlen = 2; - d_type = DT_DIR; - break; - - case 2: - d_ino = PROCFS_FILENO(0, Pnet); - d_namlen = 3; - d_name = "dev"; - d_type = DT_REG; - break; - default: - d_ino = 0; - d_namlen = 0; - d_name = NULL; - d_type = DT_REG; - break; - } - - /* - * Skip processes we have already read - */ - if (info->pcnt < info->i) { - ++info->pcnt; - return(0); - } - retval = vop_write_dirent(&info->error, info->uio, - d_ino, d_type, d_namlen, d_name); - if (retval == 0) { - ++info->pcnt; /* iterate proc candidates scanned */ - ++info->i; /* iterate entries written */ - } - if (retval || info->error || uio->uio_resid <= 0) - return(-1); - return(0); -} - - - - - - - -/* - * Scan the root directory by scanning all process - */ -static int linprocfs_readdir_sys_callback(struct proc *p, void *data); - -static int -linprocfs_readdir_sys(struct vop_readdir_args *ap) -{ - struct linprocfs_readdir_root_info info; - struct uio *uio = ap->a_uio; - int res; - - info.error = 0; - info.i = uio->uio_offset; - info.pcnt = 0; - info.uio = uio; - info.cred = ap->a_cred; - - while (info.pcnt < 3) { - res = linprocfs_readdir_sys_callback(NULL, &info); - if (res < 0) - break; - } - - uio->uio_offset = info.i; - return(info.error); -} - -static int -linprocfs_readdir_sys_callback(struct proc *p, void *data) -{ - struct linprocfs_readdir_root_info *info = data; - int retval; - struct uio *uio = info->uio; - ino_t d_ino; - const char *d_name; - size_t d_namlen; - uint8_t d_type; - - switch (info->pcnt) { - case 0: /* `.' */ - d_ino = PROCFS_FILENO(0, Psys); - d_name = "."; - d_namlen = 1; - d_type = DT_DIR; - break; - case 1: /* `..' */ - d_ino = PROCFS_FILENO(0, Proot); - d_name = ".."; - d_namlen = 2; - d_type = DT_DIR; - break; - - case 2: - d_ino = PROCFS_FILENO(0, Psyskernel); - d_namlen = 6; - d_name = "kernel"; - d_type = DT_DIR; - break; - default: - d_ino = 0; - d_namlen = 0; - d_name = NULL; - d_type = DT_REG; - break; - } - - /* - * Skip processes we have already read - */ - if (info->pcnt < info->i) { - ++info->pcnt; - return(0); - } - retval = vop_write_dirent(&info->error, info->uio, - d_ino, d_type, d_namlen, d_name); - if (retval == 0) { - ++info->pcnt; /* iterate proc candidates scanned */ - ++info->i; /* iterate entries written */ - } - if (retval || info->error || uio->uio_resid <= 0) - return(-1); - return(0); -} - - - - - -/* - * Scan the root directory by scanning all process - */ -static int linprocfs_readdir_syskernel_callback(struct proc *p, void *data); - -static int -linprocfs_readdir_syskernel(struct vop_readdir_args *ap) -{ - struct linprocfs_readdir_root_info info; - struct uio *uio = ap->a_uio; - int res; - - info.error = 0; - info.i = uio->uio_offset; - info.pcnt = 0; - info.uio = uio; - info.cred = ap->a_cred; - - while (info.pcnt < 6) { - res = linprocfs_readdir_syskernel_callback(NULL, &info); - if (res < 0) - break; - } - - uio->uio_offset = info.i; - return(info.error); -} - -static int -linprocfs_readdir_syskernel_callback(struct proc *p, void *data) -{ - struct linprocfs_readdir_root_info *info = data; - int retval; - struct uio *uio = info->uio; - ino_t d_ino; - const char *d_name; - size_t d_namlen; - uint8_t d_type; - - switch (info->pcnt) { - case 0: /* `.' */ - d_ino = PROCFS_FILENO(0, Psyskernel); - d_name = "."; - d_namlen = 1; - d_type = DT_DIR; - break; - case 1: /* `..' */ - d_ino = PROCFS_FILENO(0, Psys); - d_name = ".."; - d_namlen = 2; - d_type = DT_DIR; - break; - - case 2: - d_ino = PROCFS_FILENO(0, Posrelease); - d_namlen = 9; - d_name = "osrelease"; - d_type = DT_REG; - break; - - case 3: - d_ino = PROCFS_FILENO(0, Postype); - d_namlen = 4; - d_name = "ostype"; - d_type = DT_REG; - break; - - case 4: - d_ino = PROCFS_FILENO(0, Pversion); - d_namlen = 7; - d_name = "version"; - d_type = DT_REG; - break; - - case 5: - d_ino = PROCFS_FILENO(0, Ppidmax); - d_namlen = 7; - d_name = "pid_max"; - d_type = DT_REG; - break; - default: - d_ino = 0; - d_namlen = 0; - d_name = NULL; - d_type = DT_REG; - break; - } - - /* - * Skip processes we have already read - */ - if (info->pcnt < info->i) { - ++info->pcnt; - return(0); - } - retval = vop_write_dirent(&info->error, info->uio, - d_ino, d_type, d_namlen, d_name); - if (retval == 0) { - ++info->pcnt; /* iterate proc candidates scanned */ - ++info->i; /* iterate entries written */ - } - if (retval || info->error || uio->uio_resid <= 0) - return(-1); - return(0); -} - -/* - * readlink reads the link of `self' or `exe' - */ -static int -linprocfs_readlink(struct vop_readlink_args *ap) -{ - char buf[16]; /* should be enough */ - struct proc *procp; - struct vnode *vp = ap->a_vp; - struct nchandle *nchp; - struct pfsnode *pfs = VTOPFS(vp); - char *fullpath, *freepath; - int error, len; - - error = 0; - procp = NULL; - - switch (pfs->pfs_type) { - case Pself: - if (pfs->pfs_fileno != PROCFS_FILENO(0, Pself)) - return (EINVAL); - - len = ksnprintf(buf, sizeof(buf), "%ld", (long)curproc->p_pid); - - error = uiomove(buf, len, ap->a_uio); - break; - /* - * There _should_ be no way for an entire process to disappear - * from under us... - */ - case Pexe: - procp = linprocfs_pfind(pfs->pfs_pid); - if (procp == NULL || procp->p_ucred == NULL) { - kprintf("linprocfs_readlink: pid %d disappeared\n", - pfs->pfs_pid); - error = uiomove("unknown", sizeof("unknown") - 1, - ap->a_uio); - break; - } - error = cache_fullpath(procp, &procp->p_textnch, NULL, - &fullpath, &freepath, 0); - if (error != 0) { - error = uiomove("unknown", sizeof("unknown") - 1, - ap->a_uio); - break; - } - error = uiomove(fullpath, strlen(fullpath), ap->a_uio); - kfree(freepath, M_TEMP); - break; - case Pcwd: - procp = linprocfs_pfind(pfs->pfs_pid); - if (procp == NULL || procp->p_ucred == NULL) { - kprintf("linprocfs_readlink: pid %d disappeared\n", - pfs->pfs_pid); - error = uiomove("unknown", sizeof("unknown") - 1, - ap->a_uio); - break; - } - error = cache_fullpath(procp, &procp->p_fd->fd_ncdir, NULL, - &fullpath, &freepath, 0); - if (error != 0) { - error = uiomove("unknown", sizeof("unknown") - 1, - ap->a_uio); - break; - } - error = uiomove(fullpath, strlen(fullpath), ap->a_uio); - kfree(freepath, M_TEMP); - break; - case Pprocroot: - procp = linprocfs_pfind(pfs->pfs_pid); - if (procp == NULL || procp->p_ucred == NULL) { - kprintf("linprocfs_readlink: pid %d disappeared\n", - pfs->pfs_pid); - error = uiomove("unknown", sizeof("unknown") - 1, - ap->a_uio); - break; - } - nchp = jailed(procp->p_ucred) ? &procp->p_fd->fd_njdir : &procp->p_fd->fd_nrdir; - error = cache_fullpath(procp, nchp, NULL, - &fullpath, &freepath, 0); - if (error != 0) { - error = uiomove("unknown", sizeof("unknown") - 1, - ap->a_uio); - break; - } - error = uiomove(fullpath, strlen(fullpath), ap->a_uio); - kfree(freepath, M_TEMP); - break; - case Pfd: - procp = linprocfs_pfind(pfs->pfs_pid); - if (procp == NULL || procp->p_ucred == NULL) { - kprintf("linprocfs_readlink: pid %d disappeared\n", - pfs->pfs_pid); - error = uiomove("unknown", sizeof("unknown") - 1, - ap->a_uio); - break; - } - if (procp == curproc) { - error = uiomove("/dev/fd", sizeof("/dev/fd") - 1, - ap->a_uio); - break; - } else { - error = uiomove("unknown", sizeof("unknown") - 1, - ap->a_uio); - break; - } - /* notreached */ - break; - default: - error = EINVAL; - break; - } - if (procp) - PRELE(procp); - return error; -} - -/* - * convert decimal ascii to pid_t - */ -static pid_t -atopid(const char *b, u_int len) -{ - pid_t p = 0; - - while (len--) { - char c = *b++; - if (c < '0' || c > '9') - return (NO_PID); - p = 10 * p + (c - '0'); - if (p > PID_MAX) - return (NO_PID); - } - - return (p); -} - diff --git a/sys/emulation/linux/i386/linux.h b/sys/emulation/linux/i386/linux.h deleted file mode 100644 index 5d89de9a17..0000000000 --- a/sys/emulation/linux/i386/linux.h +++ /dev/null @@ -1,821 +0,0 @@ -/*- - * Copyright (c) 1994-1996 Søren Schmidt - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer - * in this position and unchanged. - * 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 - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD: src/sys/i386/linux/linux.h,v 1.41.2.4 2003/01/06 09:19:43 fjoe Exp $ - * $DragonFly: src/sys/emulation/linux/i386/linux.h,v 1.9 2006/10/23 21:50:32 dillon Exp $ - */ - -#ifndef _EMULATION_LINUX_ARCH_LINUX_H_ -#define _EMULATION_LINUX_ARCH_LINUX_H_ - -#include /* for sigval union */ - -#include "linux_syscall.h" - -/* - * debugging support - */ -extern u_char linux_debug_map[]; -#define ldebug(name) isclr(linux_debug_map, LINUX_SYS_linux_ ## name) -#define ARGS(nm, fmt) "linux(%ld): "#nm"("fmt")\n", (long)(curthread->td_proc ? curthread->td_proc->p_pid : -1) -#define LMSG(fmt) "linux(%ld): "fmt"\n", (long)(curthread->td_proc ? curthread->td_proc->p_pid : -1) - -#if 0 -#define LINUX_DEBUG 1 -#endif - -#ifdef MALLOC_DECLARE -MALLOC_DECLARE(M_LINUX); -#endif - -#define PTRIN(v) (void *)(v) -#define PTROUT(v) (l_uintptr_t)(v) - -/* - * Provide a separate set of types for the Linux types. - */ -typedef int l_int; -typedef int32_t l_long; -typedef int64_t l_longlong; -typedef short l_short; -typedef unsigned int l_uint; -typedef uint32_t l_ulong; -typedef uint64_t l_ulonglong; -typedef unsigned short l_ushort; - -typedef l_ulong l_uintptr_t; -typedef char *l_caddr_t; -typedef l_long l_clock_t; -typedef l_int l_daddr_t; -typedef l_ushort l_dev_t; -typedef l_uint l_gid_t; -typedef l_ushort l_gid16_t; -typedef l_ulong l_ino_t; -typedef l_int l_key_t; -typedef l_longlong l_loff_t; -typedef l_ushort l_mode_t; -typedef l_long l_off_t; -typedef l_int l_pid_t; -typedef l_uint l_size_t; -typedef l_long l_suseconds_t; -typedef l_long l_time_t; -typedef l_uint l_uid_t; -typedef l_ushort l_uid16_t; -typedef l_int l_timer_t; -typedef l_int l_mqd_t; - -typedef struct { - l_int val[2]; -} l_fsid_t; - -typedef struct { - l_time_t tv_sec; - l_suseconds_t tv_usec; -} l_timeval; - -#define l_fd_set fd_set - -/* - * Miscellaneous - */ -#define LINUX_NAME_MAX 255 -#define LINUX_MAX_UTSNAME 65 - -#define LINUX_CTL_MAXNAME 10 - -struct l___sysctl_args -{ - l_int *name; - l_int nlen; - void *oldval; - l_size_t *oldlenp; - void *newval; - l_size_t newlen; - l_ulong __spare[4]; -}; - -/* Scheduling policies */ -#define LINUX_SCHED_OTHER 0 -#define LINUX_SCHED_FIFO 1 -#define LINUX_SCHED_RR 2 - -/* Resource limits */ -#define LINUX_RLIMIT_CPU 0 -#define LINUX_RLIMIT_FSIZE 1 -#define LINUX_RLIMIT_DATA 2 -#define LINUX_RLIMIT_STACK 3 -#define LINUX_RLIMIT_CORE 4 -#define LINUX_RLIMIT_RSS 5 -#define LINUX_RLIMIT_NPROC 6 -#define LINUX_RLIMIT_NOFILE 7 -#define LINUX_RLIMIT_MEMLOCK 8 -#define LINUX_RLIMIT_AS 9 /* address space limit */ - -#define LINUX_RLIM_NLIMITS 10 - -struct l_rlimit { - l_ulong rlim_cur; - l_ulong rlim_max; -}; - -/* mmap options */ -#define LINUX_MAP_SHARED 0x0001 -#define LINUX_MAP_PRIVATE 0x0002 -#define LINUX_MAP_FIXED 0x0010 -#define LINUX_MAP_ANON 0x0020 -#define LINUX_MAP_GROWSDOWN 0x0100 - -/* - * stat family of syscalls - */ -struct l_timespec { - l_time_t tv_sec; - l_long tv_nsec; -}; - -struct l_newstat { - l_ushort st_dev; - l_ushort __pad1; - l_ulong st_ino; - l_ushort st_mode; - l_ushort st_nlink; - l_ushort st_uid; - l_ushort st_gid; - l_ushort st_rdev; - l_ushort __pad2; - l_ulong st_size; - l_ulong st_blksize; - l_ulong st_blocks; - struct l_timespec st_atimespec; - struct l_timespec st_mtimespec; - struct l_timespec st_ctimespec; - l_ulong __unused4; - l_ulong __unused5; -}; - -struct l_stat64 { - l_ushort st_dev; - u_char __pad0[10]; - l_ulong __st_ino; - l_uint st_mode; - l_uint st_nlink; - l_ulong st_uid; - l_ulong st_gid; - l_ushort st_rdev; - u_char __pad3[10]; - l_longlong st_size; - l_ulong st_blksize; - l_ulong st_blocks; - l_ulong __pad4; - struct l_timespec st_atimespec; - struct l_timespec st_mtimespec; - struct l_timespec st_ctimespec; - l_ulonglong st_ino; -}; - -struct l_statfs64 { - l_int f_type; - l_int f_bsize; - uint64_t f_blocks; - uint64_t f_bfree; - uint64_t f_bavail; - uint64_t f_files; - uint64_t f_ffree; - l_fsid_t f_fsid; - l_int f_namelen; - l_int f_spare[6]; -}; - -struct l_new_utsname { - char sysname[LINUX_MAX_UTSNAME]; - char nodename[LINUX_MAX_UTSNAME]; - char release[LINUX_MAX_UTSNAME]; - char version[LINUX_MAX_UTSNAME]; - char machine[LINUX_MAX_UTSNAME]; - char domainname[LINUX_MAX_UTSNAME]; -}; - -/* - * Signalling - */ -#define LINUX_SIGHUP 1 -#define LINUX_SIGINT 2 -#define LINUX_SIGQUIT 3 -#define LINUX_SIGILL 4 -#define LINUX_SIGTRAP 5 -#define LINUX_SIGABRT 6 -#define LINUX_SIGIOT LINUX_SIGABRT -#define LINUX_SIGBUS 7 -#define LINUX_SIGFPE 8 -#define LINUX_SIGKILL 9 -#define LINUX_SIGUSR1 10 -#define LINUX_SIGSEGV 11 -#define LINUX_SIGUSR2 12 -#define LINUX_SIGPIPE 13 -#define LINUX_SIGALRM 14 -#define LINUX_SIGTERM 15 -#define LINUX_SIGSTKFLT 16 -#define LINUX_SIGCHLD 17 -#define LINUX_SIGCONT 18 -#define LINUX_SIGSTOP 19 -#define LINUX_SIGTSTP 20 -#define LINUX_SIGTTIN 21 -#define LINUX_SIGTTOU 22 -#define LINUX_SIGURG 23 -#define LINUX_SIGXCPU 24 -#define LINUX_SIGXFSZ 25 -#define LINUX_SIGVTALRM 26 -#define LINUX_SIGPROF 27 -#define LINUX_SIGWINCH 28 -#define LINUX_SIGIO 29 -#define LINUX_SIGPOLL LINUX_SIGIO -#define LINUX_SIGPWR 30 -#define LINUX_SIGSYS 31 - -#define LINUX_SIGTBLSZ 31 -#define LINUX_NSIG_WORDS 2 -#define LINUX_NBPW 32 -#define LINUX_NSIG (LINUX_NBPW * LINUX_NSIG_WORDS) - -/* sigaction flags */ -#define LINUX_SA_NOCLDSTOP 0x00000001 -#define LINUX_SA_NOCLDWAIT 0x00000002 -#define LINUX_SA_SIGINFO 0x00000004 -#define LINUX_SA_RESTORER 0x04000000 -#define LINUX_SA_ONSTACK 0x08000000 -#define LINUX_SA_RESTART 0x10000000 -#define LINUX_SA_INTERRUPT 0x20000000 -#define LINUX_SA_NOMASK 0x40000000 -#define LINUX_SA_ONESHOT 0x80000000 - -/* sigprocmask actions */ -#define LINUX_SIG_BLOCK 0 -#define LINUX_SIG_UNBLOCK 1 -#define LINUX_SIG_SETMASK 2 - -/* sigset_t macros */ -#define LINUX_SIGEMPTYSET(set) (set).__bits[0] = (set).__bits[1] = 0 -#define LINUX_SIGISMEMBER(set, sig) SIGISMEMBER(set, sig) -#define LINUX_SIGADDSET(set, sig) SIGADDSET(set, sig) - -/* sigaltstack */ -#define LINUX_MINSIGSTKSZ 2048 -#define LINUX_SS_ONSTACK 1 -#define LINUX_SS_DISABLE 2 - -int linux_to_bsd_sigaltstack(int lsa); -int bsd_to_linux_sigaltstack(int bsa); - -typedef void (*l_handler_t)(l_int); -typedef l_ulong l_osigset_t; - -typedef struct { - l_uint __bits[LINUX_NSIG_WORDS]; -} l_sigset_t; - -typedef struct { - l_handler_t lsa_handler; - l_osigset_t lsa_mask; - l_ulong lsa_flags; - void (*lsa_restorer)(void); -} l_osigaction_t; - -typedef struct { - l_handler_t lsa_handler; - l_ulong lsa_flags; - void (*lsa_restorer)(void); - l_sigset_t lsa_mask; -} l_sigaction_t; - -typedef struct { - void *ss_sp; - l_int ss_flags; - l_size_t ss_size; -} l_stack_t; - -/* The Linux sigcontext, pretty much a standard 386 trapframe. */ -struct l_sigcontext { - l_int sc_gs; - l_int sc_fs; - l_int sc_es; - l_int sc_ds; - l_int sc_edi; - l_int sc_esi; - l_int sc_ebp; - l_int sc_esp; - l_int sc_ebx; - l_int sc_edx; - l_int sc_ecx; - l_int sc_eax; - l_int sc_trapno; - l_int sc_err; - l_int sc_eip; - l_int sc_cs; - l_int sc_eflags; - l_int sc_esp_at_signal; - l_int sc_ss; - l_int sc_387; - l_int sc_mask; - l_int sc_cr2; -}; - -struct l_ucontext { - l_ulong uc_flags; - void *uc_link; - l_stack_t uc_stack; - struct l_sigcontext uc_mcontext; - l_sigset_t uc_sigmask; -}; - -#define LINUX_SI_MAX_SIZE 128 -#define LINUX_SI_PAD_SIZE ((LINUX_SI_MAX_SIZE/sizeof(l_int)) - 3) - -typedef struct l_siginfo { - l_int lsi_signo; - l_int lsi_errno; - l_int lsi_code; - union { - l_int _pad[LINUX_SI_PAD_SIZE]; - - struct { - l_pid_t _pid; - l_uid16_t _uid; - } _kill; - - struct { - l_uint _timer1; - l_uint _timer2; - } _timer; - - struct { - l_pid_t _pid; /* sender's pid */ - l_uid16_t _uid; /* sender's uid */ - union sigval _sigval; - } _rt; - - struct { - l_pid_t _pid; /* which child */ - l_uid16_t _uid; /* sender's uid */ - l_int _status; /* exit code */ - l_clock_t _utime; - l_clock_t _stime; - } _sigchld; - - struct { - void *_addr; /* faulting insn/memory ref. */ - } _sigfault; - - struct { - l_int _band; /* POLL_IN,POLL_OUT,POLL_MSG */ - l_int _fd; - } _sigpoll; - } _sifields; -} l_siginfo_t; - -#define lsi_pid _sifields._kill._pid -#define lsi_uid _sifields._kill._uid -#define lsi_status _sifields._sigchld._status -#define lsi_utime _sifields._sigchld._utime -#define lsi_stime _sifields._sigchld._stime -#define lsi_value _sifields._rt._sigval -#define lsi_int _sifields._rt._sigval.sival_int -#define lsi_ptr _sifields._rt._sigval.sival_ptr -#define lsi_addr _sifields._sigfault._addr -#define lsi_band _sifields._sigpoll._band -#define lsi_fd _sifields._sigpoll._fd - -struct l_fpreg { - u_int16_t significand[4]; - u_int16_t exponent; -}; - -struct l_fpxreg { - u_int16_t significand[4]; - u_int16_t exponent; - u_int16_t padding[3]; -}; - -struct l_xmmreg { - u_int32_t element[4]; -}; - -struct l_fpstate { - /* Regular FPU environment */ - u_int32_t cw; - u_int32_t sw; - u_int32_t tag; - u_int32_t ipoff; - u_int32_t cssel; - u_int32_t dataoff; - u_int32_t datasel; - struct l_fpreg _st[8]; - u_int16_t status; - u_int16_t magic; /* 0xffff = regular FPU data */ - - /* FXSR FPU environment */ - u_int32_t _fxsr_env[6]; /* env is ignored */ - u_int32_t mxcsr; - u_int32_t reserved; - struct l_fpxreg _fxsr_st[8]; /* reg data is ignored */ - struct l_xmmreg _xmm[8]; - u_int32_t padding[56]; -}; - -/* - * We make the stack look like Linux expects it when calling a signal - * handler, but use the BSD way of calling the handler and sigreturn(). - * This means that we need to pass the pointer to the handler too. - * It is appended to the frame to not interfere with the rest of it. - */ -struct l_sigframe { - l_int sf_sig; - struct l_sigcontext sf_sc; - struct l_fpstate sf_fpstate; - l_uint sf_extramask[LINUX_NSIG_WORDS-1]; - l_handler_t sf_handler; -}; - -struct l_rt_sigframe { - l_int sf_sig; - l_siginfo_t *sf_siginfo; - struct l_ucontext *sf_ucontext; - l_siginfo_t sf_si; - struct l_ucontext sf_sc; - l_handler_t sf_handler; -}; - -extern int bsd_to_linux_signal[]; -extern int linux_to_bsd_signal[]; -extern struct sysentvec linux_sysvec; -extern struct sysentvec elf_linux_sysvec; - -/* - * Pluggable ioctl handlers - */ - -extern struct ioctl_map linux_ioctl_map; - -/* - * open/fcntl flags - */ -#define LINUX_O_RDONLY 00 -#define LINUX_O_WRONLY 01 -#define LINUX_O_RDWR 02 -#define LINUX_O_CREAT 0100 -#define LINUX_O_EXCL 0200 -#define LINUX_O_NOCTTY 0400 -#define LINUX_O_TRUNC 01000 -#define LINUX_O_APPEND 02000 -#define LINUX_O_NONBLOCK 04000 -#define LINUX_O_NDELAY LINUX_O_NONBLOCK -#define LINUX_O_SYNC 010000 -#define LINUX_FASYNC 020000 -#define LINUX_O_DIRECTORY 00200000 - -#define LINUX_F_DUPFD 0 -#define LINUX_F_GETFD 1 -#define LINUX_F_SETFD 2 -#define LINUX_F_GETFL 3 -#define LINUX_F_SETFL 4 -#define LINUX_F_GETLK 5 -#define LINUX_F_SETLK 6 -#define LINUX_F_SETLKW 7 -#define LINUX_F_SETOWN 8 -#define LINUX_F_GETOWN 9 - -#define LINUX_F_GETLK64 12 -#define LINUX_F_SETLK64 13 -#define LINUX_F_SETLKW64 14 - -#define LINUX_F_RDLCK 0 -#define LINUX_F_WRLCK 1 -#define LINUX_F_UNLCK 2 - -/* - * mount flags - */ -#define LINUX_MS_RDONLY 0x0001 -#define LINUX_MS_NOSUID 0x0002 -#define LINUX_MS_NODEV 0x0004 -#define LINUX_MS_NOEXEC 0x0008 -#define LINUX_MS_REMOUNT 0x0020 - -/* - * SystemV IPC defines - */ -#define LINUX_SEMOP 1 -#define LINUX_SEMGET 2 -#define LINUX_SEMCTL 3 -#define LINUX_MSGSND 11 -#define LINUX_MSGRCV 12 -#define LINUX_MSGGET 13 -#define LINUX_MSGCTL 14 -#define LINUX_SHMAT 21 -#define LINUX_SHMDT 22 -#define LINUX_SHMGET 23 -#define LINUX_SHMCTL 24 - -#define LINUX_IPC_RMID 0 -#define LINUX_IPC_SET 1 -#define LINUX_IPC_STAT 2 -#define LINUX_IPC_INFO 3 - -#define LINUX_SHM_LOCK 11 -#define LINUX_SHM_UNLOCK 12 -#define LINUX_SHM_STAT 13 -#define LINUX_SHM_INFO 14 - -#define LINUX_SHM_RDONLY 0x1000 -#define LINUX_SHM_RND 0x2000 -#define LINUX_SHM_REMAP 0x4000 - -/* semctl commands */ -#define LINUX_GETPID 11 -#define LINUX_GETVAL 12 -#define LINUX_GETALL 13 -#define LINUX_GETNCNT 14 -#define LINUX_GETZCNT 15 -#define LINUX_SETVAL 16 -#define LINUX_SETALL 17 -#define LINUX_SEM_STAT 18 -#define LINUX_SEM_INFO 19 - -union l_semun { - l_int val; - struct l_semid_ds *buf; - l_ushort *array; - struct l_seminfo *__buf; - void *__pad; -}; - -/* - * Socket defines - */ -#define LINUX_SOCKET 1 -#define LINUX_BIND 2 -#define LINUX_CONNECT 3 -#define LINUX_LISTEN 4 -#define LINUX_ACCEPT 5 -#define LINUX_GETSOCKNAME 6 -#define LINUX_GETPEERNAME 7 -#define LINUX_SOCKETPAIR 8 -#define LINUX_SEND 9 -#define LINUX_RECV 10 -#define LINUX_SENDTO 11 -#define LINUX_RECVFROM 12 -#define LINUX_SHUTDOWN 13 -#define LINUX_SETSOCKOPT 14 -#define LINUX_GETSOCKOPT 15 -#define LINUX_SENDMSG 16 -#define LINUX_RECVMSG 17 - -#define LINUX_AF_UNSPEC 0 -#define LINUX_AF_UNIX 1 -#define LINUX_AF_INET 2 -#define LINUX_AF_AX25 3 -#define LINUX_AF_IPX 4 -#define LINUX_AF_APPLETALK 5 - -#define LINUX_SOL_SOCKET 1 -#define LINUX_SOL_IP 0 -#define LINUX_SOL_IPX 256 -#define LINUX_SOL_AX25 257 -#define LINUX_SOL_TCP 6 -#define LINUX_SOL_UDP 17 - -#define LINUX_SO_DEBUG 1 -#define LINUX_SO_REUSEADDR 2 -#define LINUX_SO_TYPE 3 -#define LINUX_SO_ERROR 4 -#define LINUX_SO_DONTROUTE 5 -#define LINUX_SO_BROADCAST 6 -#define LINUX_SO_SNDBUF 7 -#define LINUX_SO_RCVBUF 8 -#define LINUX_SO_KEEPALIVE 9 -#define LINUX_SO_OOBINLINE 10 -#define LINUX_SO_NO_CHECK 11 -#define LINUX_SO_PRIORITY 12 -#define LINUX_SO_LINGER 13 -#define LINUX_SO_PEERCRED 17 -#define LINUX_SO_RCVLOWAT 18 -#define LINUX_SO_SNDLOWAT 19 -#define LINUX_SO_RCVTIMEO 20 -#define LINUX_SO_SNDTIMEO 21 -#define LINUX_SO_TIMESTAMP 29 -#define LINUX_SO_ACCEPTCONN 30 - -#define LINUX_IP_TOS 1 -#define LINUX_IP_TTL 2 -#define LINUX_IP_HDRINCL 3 -#define LINUX_IP_OPTIONS 4 - -#define LINUX_IP_MULTICAST_IF 32 -#define LINUX_IP_MULTICAST_TTL 33 -#define LINUX_IP_MULTICAST_LOOP 34 -#define LINUX_IP_ADD_MEMBERSHIP 35 -#define LINUX_IP_DROP_MEMBERSHIP 36 - -struct l_sockaddr { - l_ushort sa_family; - char sa_data[14]; -}; - -struct l_ifmap { - l_ulong mem_start; - l_ulong mem_end; - l_ushort base_addr; - u_char irq; - u_char dma; - u_char port; -}; - -#define LINUX_IFHWADDRLEN 6 -#define LINUX_IFNAMSIZ 16 - -struct l_ifreq { - union { - char ifrn_name[LINUX_IFNAMSIZ]; - } ifr_ifrn; - - union { - struct l_sockaddr ifru_addr; - struct l_sockaddr ifru_dstaddr; - struct l_sockaddr ifru_broadaddr; - struct l_sockaddr ifru_netmask; - struct l_sockaddr ifru_hwaddr; - l_short ifru_flags[1]; - l_int ifru_metric; - l_int ifru_ivalue; - l_int ifru_mtu; - struct l_ifmap ifru_map; - char ifru_slave[LINUX_IFNAMSIZ]; - l_caddr_t ifru_data; - } ifr_ifru; -}; - -#define ifr_name ifr_ifrn.ifrn_name /* interface name */ -#define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */ -#define ifr_ifindex ifr_ifru.ifru_ivalue /* Interface index */ -#define ifr_ifmetric ifr_ifru.ifru_metric /* Interface index */ - -/* - * poll() - */ -#define LINUX_POLLIN 0x0001 -#define LINUX_POLLPRI 0x0002 -#define LINUX_POLLOUT 0x0004 -#define LINUX_POLLERR 0x0008 -#define LINUX_POLLHUP 0x0010 -#define LINUX_POLLNVAL 0x0020 -#define LINUX_POLLRDNORM 0x0040 -#define LINUX_POLLRDBAND 0x0080 -#define LINUX_POLLWRNORM 0x0100 -#define LINUX_POLLWRBAND 0x0200 -#define LINUX_POLLMSG 0x0400 - -struct l_pollfd { - l_int fd; - l_short events; - l_short revents; -}; - -struct l_user_desc { - l_uint entry_number; - l_uint base_addr; - l_uint limit; - l_uint seg_32bit:1; - l_uint contents:2; - l_uint read_exec_only:1; - l_uint limit_in_pages:1; - l_uint seg_not_present:1; - l_uint useable:1; -}; - -struct l_desc_struct { - unsigned long a, b; -}; - - -#define LINUX_LOWERWORD 0x0000ffff - -/* - * Macros which does the same thing as those in Linux include/asm-um/ldt-i386.h. - * These convert Linux user space descriptor to machine one. - */ -#define LINUX_LDT_entry_a(info) \ - ((((info)->base_addr & LINUX_LOWERWORD) << 16) | \ - ((info)->limit & LINUX_LOWERWORD)) - -#define LINUX_ENTRY_B_READ_EXEC_ONLY 9 -#define LINUX_ENTRY_B_CONTENTS 10 -#define LINUX_ENTRY_B_SEG_NOT_PRESENT 15 -#define LINUX_ENTRY_B_BASE_ADDR 16 -#define LINUX_ENTRY_B_USEABLE 20 -#define LINUX_ENTRY_B_SEG32BIT 22 -#define LINUX_ENTRY_B_LIMIT 23 - -#define LINUX_LDT_entry_b(info) \ - (((info)->base_addr & 0xff000000) | \ - ((info)->limit & 0xf0000) | \ - ((info)->contents << LINUX_ENTRY_B_CONTENTS) | \ - (((info)->seg_not_present == 0) << LINUX_ENTRY_B_SEG_NOT_PRESENT) | \ - (((info)->base_addr & 0x00ff0000) >> LINUX_ENTRY_B_BASE_ADDR) | \ - (((info)->read_exec_only == 0) << LINUX_ENTRY_B_READ_EXEC_ONLY) | \ - ((info)->seg_32bit << LINUX_ENTRY_B_SEG32BIT) | \ - ((info)->useable << LINUX_ENTRY_B_USEABLE) | \ - ((info)->limit_in_pages << LINUX_ENTRY_B_LIMIT) | 0x7000) - -#define LINUX_LDT_empty(info) \ - ((info)->base_addr == 0 && \ - (info)->limit == 0 && \ - (info)->contents == 0 && \ - (info)->seg_not_present == 1 && \ - (info)->read_exec_only == 1 && \ - (info)->seg_32bit == 0 && \ - (info)->limit_in_pages == 0 && \ - (info)->useable == 0) - -/* - * Macros for converting segments. - * They do the same as those in arch/i386/kernel/process.c in Linux. - */ -#define LINUX_GET_BASE(desc) \ - ((((desc)->a >> 16) & LINUX_LOWERWORD) | \ - (((desc)->b << 16) & 0x00ff0000) | \ - ((desc)->b & 0xff000000)) - -#define LINUX_GET_LIMIT(desc) \ - (((desc)->a & LINUX_LOWERWORD) | \ - ((desc)->b & 0xf0000)) - -#define LINUX_GET_32BIT(desc) \ - (((desc)->b >> LINUX_ENTRY_B_SEG32BIT) & 1) -#define LINUX_GET_CONTENTS(desc) \ - (((desc)->b >> LINUX_ENTRY_B_CONTENTS) & 3) -#define LINUX_GET_WRITABLE(desc) \ - (((desc)->b >> LINUX_ENTRY_B_READ_EXEC_ONLY) & 1) -#define LINUX_GET_LIMIT_PAGES(desc) \ - (((desc)->b >> LINUX_ENTRY_B_LIMIT) & 1) -#define LINUX_GET_PRESENT(desc) \ - (((desc)->b >> LINUX_ENTRY_B_SEG_NOT_PRESENT) & 1) -#define LINUX_GET_USEABLE(desc) \ - (((desc)->b >> LINUX_ENTRY_B_USEABLE) & 1) - -#define LINUX_CLOCK_REALTIME 0 -#define LINUX_CLOCK_MONOTONIC 1 -#define LINUX_CLOCK_PROCESS_CPUTIME_ID 2 -#define LINUX_CLOCK_THREAD_CPUTIME_ID 3 -#define LINUX_CLOCK_REALTIME_HR 4 -#define LINUX_CLOCK_MONOTONIC_HR 5 - -#define LINUX_CLONE_VM 0x00000100 -#define LINUX_CLONE_FS 0x00000200 -#define LINUX_CLONE_FILES 0x00000400 -#define LINUX_CLONE_SIGHAND 0x00000800 -#define LINUX_CLONE_PID 0x00001000 /* No longer exist in Linux */ -#define LINUX_CLONE_VFORK 0x00004000 -#define LINUX_CLONE_PARENT 0x00008000 -#define LINUX_CLONE_THREAD 0x00010000 -#define LINUX_CLONE_SETTLS 0x00080000 -#define LINUX_CLONE_PARENT_SETTID 0x00100000 -#define LINUX_CLONE_CHILD_CLEARTID 0x00200000 -#define LINUX_CLONE_CHILD_SETTID 0x01000000 - -#define LINUX_THREADING_FLAGS \ - (LINUX_CLONE_VM | LINUX_CLONE_FS | LINUX_CLONE_FILES | \ - LINUX_CLONE_SIGHAND | LINUX_CLONE_THREAD) - -#define LINUX_AT_FDCWD -100 -#define LINUX_AT_SYMLINK_NOFOLLOW 0x100 -#define LINUX_AT_REMOVEDIR 0x200 - -#define LINUX_MREMAP_MAYMOVE 1 -#define LINUX_MREMAP_FIXED 2 - -#define LINUX_UTIME_NOW (-1) -#define LINUX_UTIME_OMIT (-2) -#endif /* !_EMULATION_LINUX_ARCH_LINUX_H_ */ diff --git a/sys/emulation/linux/i386/linux_dummy.c b/sys/emulation/linux/i386/linux_dummy.c deleted file mode 100644 index d55933852a..0000000000 --- a/sys/emulation/linux/i386/linux_dummy.c +++ /dev/null @@ -1,121 +0,0 @@ -/*- - * Copyright (c) 1994-1995 Søren Schmidt - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer - * in this position and unchanged. - * 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 - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD: src/sys/i386/linux/linux_dummy.c,v 1.21.2.7 2003/01/02 20:41:33 kan Exp $ - * $DragonFly: src/sys/emulation/linux/i386/linux_dummy.c,v 1.7 2006/06/05 07:26:10 dillon Exp $ - */ - -#include -#include -#include - -#include "linux.h" -#include "linux_proto.h" -#include "../linux_util.h" - -DUMMY(stat); -DUMMY(mount); -DUMMY(stime); -DUMMY(fstat); -DUMMY(olduname); -DUMMY(syslog); -DUMMY(uname); -DUMMY(vhangup); -DUMMY(vm86old); -DUMMY(swapoff); -DUMMY(adjtimex); -DUMMY(create_module); -DUMMY(init_module); -DUMMY(delete_module); -DUMMY(get_kernel_syms); -DUMMY(quotactl); -DUMMY(bdflush); -DUMMY(sysfs); -DUMMY(vm86); -DUMMY(query_module); -DUMMY(nfsservctl); -DUMMY(prctl); -DUMMY(rt_sigpending); -DUMMY(rt_sigtimedwait); -DUMMY(rt_sigqueueinfo); -DUMMY(capget); -DUMMY(capset); -DUMMY(sendfile); -DUMMY(setfsuid); -DUMMY(setfsgid); -DUMMY(pivot_root); -DUMMY(mincore); -DUMMY(fadvise64); -DUMMY(statfs64); -DUMMY(fstatfs64); -DUMMY(fadvise64_64); -DUMMY(mbind); -DUMMY(get_mempolicy); -DUMMY(set_mempolicy); -DUMMY(kexec_load); -DUMMY(waitid); -DUMMY(add_key); -DUMMY(request_key); -DUMMY(keyctl); -DUMMY(ioprio_set); -DUMMY(ioprio_get); -DUMMY(inotify_init); -DUMMY(inotify_add_watch); -DUMMY(inotify_rm_watch); -DUMMY(migrate_pages); -DUMMY(pselect6); -DUMMY(ppoll); -DUMMY(unshare); -DUMMY(splice); -DUMMY(sync_file_range); -DUMMY(tee); -DUMMY(vmsplice); -DUMMY(move_pages); -DUMMY(epoll_pwait); -DUMMY(signalfd); -DUMMY(timerfd); -DUMMY(eventfd); - -#define DUMMY_XATTR(s) \ -int \ -sys_linux_ ## s ## xattr( struct linux_ ## s ## xattr_args *arg) \ -{ \ - return (ENOATTR); \ -} - -DUMMY_XATTR(set); -DUMMY_XATTR(lset); -DUMMY_XATTR(fset); -DUMMY_XATTR(get); -DUMMY_XATTR(lget); -DUMMY_XATTR(fget); -DUMMY_XATTR(list); -DUMMY_XATTR(llist); -DUMMY_XATTR(flist); -DUMMY_XATTR(remove); -DUMMY_XATTR(lremove); -DUMMY_XATTR(fremove); diff --git a/sys/emulation/linux/i386/linux_genassym.c b/sys/emulation/linux/i386/linux_genassym.c deleted file mode 100644 index 9a85b1fde7..0000000000 --- a/sys/emulation/linux/i386/linux_genassym.c +++ /dev/null @@ -1,15 +0,0 @@ -/* $FreeBSD: src/sys/i386/linux/linux_genassym.c,v 1.13.2.3 2001/11/05 19:08:23 marcel Exp $ */ -/* $DragonFly: src/sys/emulation/linux/i386/linux_genassym.c,v 1.3 2003/08/07 21:17:18 dillon Exp $ */ - -#include -#include - -#include "linux.h" - -ASSYM(LINUX_SIGF_HANDLER, offsetof(struct l_sigframe, sf_handler)); -ASSYM(LINUX_SIGF_SC, offsetof(struct l_sigframe, sf_sc)); -ASSYM(LINUX_SC_GS, offsetof(struct l_sigcontext, sc_gs)); -ASSYM(LINUX_SC_EFLAGS, offsetof(struct l_sigcontext, sc_eflags)); -ASSYM(LINUX_RT_SIGF_HANDLER, offsetof(struct l_rt_sigframe, sf_handler)); -ASSYM(LINUX_RT_SIGF_UC, offsetof(struct l_rt_sigframe, sf_sc)); -ASSYM(LINUX_RT_SIGF_SC, offsetof(struct l_ucontext, uc_mcontext)); diff --git a/sys/emulation/linux/i386/linux_locore.s b/sys/emulation/linux/i386/linux_locore.s deleted file mode 100644 index 1f20d9c60a..0000000000 --- a/sys/emulation/linux/i386/linux_locore.s +++ /dev/null @@ -1,37 +0,0 @@ -/* $FreeBSD: src/sys/i386/linux/linux_locore.s,v 1.5.2.3 2001/11/05 19:08:23 marcel Exp $ */ -/* $DragonFly: src/sys/emulation/linux/i386/linux_locore.s,v 1.4 2007/04/13 12:12:27 corecode Exp $ */ - -#include "linux_assym.h" /* system definitions */ -#include /* miscellaneous asm macros */ -#include "linux_syscall.h" /* system call numbers */ - -NON_GPROF_ENTRY(linux_sigcode) - call *LINUX_SIGF_HANDLER(%esp) - leal LINUX_SIGF_SC(%esp),%ebx /* linux scp */ - mov LINUX_SC_GS(%ebx),%gs - movl %esp, %ebx /* pass sigframe */ - push %eax /* fake ret addr */ - movl $LINUX_SYS_linux_sigreturn,%eax /* linux_sigreturn() */ - int $0x80 /* enter kernel with args */ -0: jmp 0b - ALIGN_TEXT -/* XXXXX */ -linux_rt_sigcode: - call *LINUX_RT_SIGF_HANDLER(%esp) - leal LINUX_RT_SIGF_UC(%esp),%ebx /* linux ucp */ - leal LINUX_RT_SIGF_SC(%ebx),%ecx /* linux sigcontext */ - mov LINUX_SC_GS(%ecx),%gs - push %eax /* fake ret addr */ - movl $LINUX_SYS_linux_rt_sigreturn,%eax /* linux_rt_sigreturn() */ - int $0x80 /* enter kernel with args */ -0: jmp 0b - ALIGN_TEXT -/* XXXXX */ -linux_esigcode: - - .data - .globl linux_szsigcode, linux_sznonrtsigcode -linux_szsigcode: - .long linux_esigcode-linux_sigcode -linux_sznonrtsigcode: - .long linux_rt_sigcode-linux_sigcode diff --git a/sys/emulation/linux/i386/linux_machdep.c b/sys/emulation/linux/i386/linux_machdep.c deleted file mode 100644 index 8df21ac0c6..0000000000 --- a/sys/emulation/linux/i386/linux_machdep.c +++ /dev/null @@ -1,1294 +0,0 @@ -/*- - * Copyright (c) 2000 Marcel Moolenaar - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer - * in this position and unchanged. - * 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 - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD: src/sys/i386/linux/linux_machdep.c,v 1.6.2.4 2001/11/05 19:08:23 marcel Exp $ - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include "linux.h" -#include "linux_proto.h" -#include "../linux_ipc.h" -#include "../linux_signal.h" -#include "../linux_util.h" -#include "../linux_emuldata.h" - -struct l_descriptor { - l_uint entry_number; - l_ulong base_addr; - l_uint limit; - l_uint seg_32bit:1; - l_uint contents:2; - l_uint read_exec_only:1; - l_uint limit_in_pages:1; - l_uint seg_not_present:1; - l_uint useable:1; -}; - -struct l_old_select_argv { - l_int nfds; - l_fd_set *readfds; - l_fd_set *writefds; - l_fd_set *exceptfds; - struct l_timeval *timeout; -}; - -int -linux_to_bsd_sigaltstack(int lsa) -{ - int bsa = 0; - - if (lsa & LINUX_SS_DISABLE) - bsa |= SS_DISABLE; - if (lsa & LINUX_SS_ONSTACK) - bsa |= SS_ONSTACK; - return (bsa); -} - -int -bsd_to_linux_sigaltstack(int bsa) -{ - int lsa = 0; - - if (bsa & SS_DISABLE) - lsa |= LINUX_SS_DISABLE; - if (bsa & SS_ONSTACK) - lsa |= LINUX_SS_ONSTACK; - return (lsa); -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_execve(struct linux_execve_args *args) -{ - struct nlookupdata nd; - struct image_args exec_args; - char *path; - int error; - - error = linux_copyin_path(args->path, &path, LINUX_PATH_EXISTS); - if (error) - return (error); -#ifdef DEBUG - if (ldebug(execve)) - kprintf(ARGS(execve, "%s"), path); -#endif - get_mplock(); - error = nlookup_init(&nd, path, UIO_SYSSPACE, NLC_FOLLOW); - bzero(&exec_args, sizeof(exec_args)); - if (error == 0) { - error = exec_copyin_args(&exec_args, path, PATH_SYSSPACE, - args->argp, args->envp); - } - if (error == 0) - error = kern_execve(&nd, &exec_args); - nlookup_done(&nd); - - /* - * The syscall result is returned in registers to the new program. - * Linux will register %edx as an atexit function and we must be - * sure to set it to 0. XXX - */ - if (error == 0) { - args->sysmsg_result64 = 0; - if (curproc->p_sysent == &elf_linux_sysvec) - error = emuldata_init(curproc, NULL, 0); - } - - exec_free_args(&exec_args); - linux_free_path(&path); - - if (error < 0) { - /* We hit a lethal error condition. Let's die now. */ - exit1(W_EXITCODE(0, SIGABRT)); - /* NOTREACHED */ - } - rel_mplock(); - - return(error); -} - -struct l_ipc_kludge { - struct l_msgbuf *msgp; - l_long msgtyp; -}; - -/* - * MPALMOSTSAFE - */ -int -sys_linux_ipc(struct linux_ipc_args *args) -{ - int error = 0; - - get_mplock(); - - switch (args->what & 0xFFFF) { - case LINUX_SEMOP: { - struct linux_semop_args a; - - a.semid = args->arg1; - a.tsops = args->ptr; - a.nsops = args->arg2; - a.sysmsg_lresult = 0; - error = linux_semop(&a); - args->sysmsg_lresult = a.sysmsg_lresult; - break; - } - case LINUX_SEMGET: { - struct linux_semget_args a; - - a.key = args->arg1; - a.nsems = args->arg2; - a.semflg = args->arg3; - a.sysmsg_lresult = 0; - error = linux_semget(&a); - args->sysmsg_lresult = a.sysmsg_lresult; - break; - } - case LINUX_SEMCTL: { - struct linux_semctl_args a; - int error; - - a.semid = args->arg1; - a.semnum = args->arg2; - a.cmd = args->arg3; - a.sysmsg_lresult = 0; - error = copyin((caddr_t)args->ptr, &a.arg, sizeof(a.arg)); - if (error) - break; - error = linux_semctl(&a); - args->sysmsg_lresult = a.sysmsg_lresult; - break; - } - case LINUX_MSGSND: { - struct linux_msgsnd_args a; - - a.msqid = args->arg1; - a.msgp = args->ptr; - a.msgsz = args->arg2; - a.msgflg = args->arg3; - a.sysmsg_lresult = 0; - error = linux_msgsnd(&a); - args->sysmsg_lresult = a.sysmsg_lresult; - break; - } - case LINUX_MSGRCV: { - struct linux_msgrcv_args a; - - a.msqid = args->arg1; - a.msgsz = args->arg2; - if (a.msgsz < 0) { - error = EINVAL; - break; - } - a.msgflg = args->arg3; - a.sysmsg_lresult = 0; - if ((args->what >> 16) == 0) { - struct l_ipc_kludge tmp; - int error; - - if (args->ptr == NULL) { - error = EINVAL; - break; - } - error = copyin((caddr_t)args->ptr, &tmp, sizeof(tmp)); - if (error) - break; - a.msgp = tmp.msgp; - a.msgtyp = tmp.msgtyp; - } else { - a.msgp = args->ptr; - a.msgtyp = args->arg5; - } - error = linux_msgrcv(&a); - args->sysmsg_lresult = a.sysmsg_lresult; - break; - } - case LINUX_MSGGET: { - struct linux_msgget_args a; - - a.key = args->arg1; - a.msgflg = args->arg2; - a.sysmsg_lresult = 0; - error = linux_msgget(&a); - args->sysmsg_lresult = a.sysmsg_lresult; - break; - } - case LINUX_MSGCTL: { - struct linux_msgctl_args a; - - a.msqid = args->arg1; - a.cmd = args->arg2; - a.buf = args->ptr; - a.sysmsg_lresult = 0; - error = linux_msgctl(&a); - args->sysmsg_lresult = a.sysmsg_lresult; - break; - } - case LINUX_SHMAT: { - struct linux_shmat_args a; - - a.shmid = args->arg1; - a.shmaddr = args->ptr; - a.shmflg = args->arg2; - a.raddr = (l_ulong *)args->arg3; - a.sysmsg_lresult = 0; - error = linux_shmat(&a); - args->sysmsg_lresult = a.sysmsg_lresult; - break; - } - case LINUX_SHMDT: { - struct linux_shmdt_args a; - - a.shmaddr = args->ptr; - a.sysmsg_lresult = 0; - error = linux_shmdt(&a); - args->sysmsg_lresult = a.sysmsg_lresult; - break; - } - case LINUX_SHMGET: { - struct linux_shmget_args a; - - a.key = args->arg1; - a.size = args->arg2; - a.shmflg = args->arg3; - a.sysmsg_lresult = 0; - error = linux_shmget(&a); - args->sysmsg_lresult = a.sysmsg_lresult; - break; - } - case LINUX_SHMCTL: { - struct linux_shmctl_args a; - - a.shmid = args->arg1; - a.cmd = args->arg2; - a.buf = args->ptr; - a.sysmsg_lresult = 0; - error = linux_shmctl(&a); - args->sysmsg_lresult = a.sysmsg_lresult; - break; - } - default: - error = EINVAL; - break; - } - rel_mplock(); - return(error); -} - -/* - * MPSAFE - */ -int -sys_linux_old_select(struct linux_old_select_args *args) -{ - struct l_old_select_argv linux_args; - struct linux_select_args newsel; - int error; - -#ifdef DEBUG - if (ldebug(old_select)) - kprintf(ARGS(old_select, "%p"), args->ptr); -#endif - - error = copyin((caddr_t)args->ptr, &linux_args, sizeof(linux_args)); - if (error) - return (error); - - newsel.sysmsg_iresult = 0; - newsel.nfds = linux_args.nfds; - newsel.readfds = linux_args.readfds; - newsel.writefds = linux_args.writefds; - newsel.exceptfds = linux_args.exceptfds; - newsel.timeout = linux_args.timeout; - error = sys_linux_select(&newsel); - args->sysmsg_iresult = newsel.sysmsg_iresult; - return(error); -} - -/* - * MPSAFE - */ -int -sys_linux_fork(struct linux_fork_args *args) -{ - struct lwp *lp = curthread->td_lwp; - struct proc *p2; - int error; - - get_mplock(); - error = fork1(lp, RFFDG | RFPROC | RFPGLOCK, &p2); - if (error == 0) { - emuldata_init(curproc, p2, 0); - - start_forked_proc(lp, p2); - args->sysmsg_fds[0] = p2->p_pid; - args->sysmsg_fds[1] = 0; - } - rel_mplock(); - - /* Are we the child? */ - if (args->sysmsg_iresult == 1) - args->sysmsg_iresult = 0; - - return (error); -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_exit_group(struct linux_exit_group_args *args) -{ - struct linux_emuldata *em, *e; - struct proc *p; - int rval; - - rval = args->rval; - EMUL_LOCK(); - - em = emuldata_get(curproc); - - if (em->s->refs == 1) { - EMUL_UNLOCK(); - exit1(W_EXITCODE(rval, 0)); - /* NOTREACHED */ - return (0); - } - KKASSERT(em->proc == curproc); - em->flags |= EMUL_DIDKILL; - em->s->flags |= LINUX_LES_INEXITGROUP; - em->s->xstat = W_EXITCODE(rval, 0); - - LIST_REMOVE(em, threads); - LIST_INSERT_HEAD(&em->s->threads, em, threads); - - while ((e = LIST_NEXT(em, threads)) != NULL) { - LIST_REMOVE(em, threads); - LIST_INSERT_AFTER(e, em, threads); - if ((e->flags & EMUL_DIDKILL) == 0) { - e->flags |= EMUL_DIDKILL; - p = e->proc; - PHOLD(p); - ksignal(p, SIGKILL); - PRELE(p); - } - } - - EMUL_UNLOCK(); - exit1(W_EXITCODE(rval, 0)); - /* NOTREACHED */ - - return (0); -} - -/* - * MPSAFE - */ -int -sys_linux_vfork(struct linux_vfork_args *args) -{ - struct lwp *lp = curthread->td_lwp; - struct proc *p2; - int error; - - get_mplock(); - error = fork1(lp, RFFDG | RFPROC | RFPPWAIT | RFMEM | RFPGLOCK, &p2); - if (error == 0) { - emuldata_init(curproc, p2, 0); - - start_forked_proc(lp, p2); - args->sysmsg_fds[0] = p2->p_pid; - args->sysmsg_fds[1] = 0; - } - rel_mplock(); - - if (args->sysmsg_iresult == 1) - args->sysmsg_iresult = 0; - - return (error); -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_clone(struct linux_clone_args *args) -{ - struct segment_descriptor *desc; - struct l_user_desc info; - int idx; - int a[2]; - - struct lwp *lp = curthread->td_lwp; - int error, ff = RFPROC; - struct proc *p2 = NULL; - int exit_signal; - - exit_signal = args->flags & 0x000000ff; - if (exit_signal >= LINUX_NSIG) - return (EINVAL); - if (exit_signal <= LINUX_SIGTBLSZ) - exit_signal = linux_to_bsd_signal[_SIG_IDX(exit_signal)]; - - if (args->flags & LINUX_CLONE_VM) - ff |= RFMEM; - if (args->flags & LINUX_CLONE_SIGHAND) - ff |= RFSIGSHARE; - if (!(args->flags & (LINUX_CLONE_FILES | LINUX_CLONE_FS))) - ff |= RFFDG; - if ((args->flags & 0xffffff00) == LINUX_THREADING_FLAGS) - ff |= RFTHREAD; - if (args->flags & LINUX_CLONE_VFORK) - ff |= RFPPWAIT; - if (args->flags & LINUX_CLONE_PARENT_SETTID) { - if (args->parent_tidptr == NULL) - return (EINVAL); - } - - error = 0; - - get_mplock(); - error = fork1(lp, ff | RFPGLOCK, &p2); - if (error) { - rel_mplock(); - return error; - } - - args->sysmsg_fds[0] = p2 ? p2->p_pid : 0; - args->sysmsg_fds[1] = 0; - - if (args->flags & (LINUX_CLONE_PARENT | LINUX_CLONE_THREAD)) { - lwkt_gettoken(&curproc->p_token); - while (p2->p_pptr != curproc->p_pptr) - proc_reparent(p2, curproc->p_pptr); - lwkt_reltoken(&curproc->p_token); - } - - emuldata_init(curproc, p2, args->flags); - linux_proc_fork(p2, curproc, args->child_tidptr); - /* - * XXX: this can't happen, p2 is never NULL, or else we'd have - * other problems, too (see p2->p_sigparent == ..., - * linux_proc_fork and emuldata_init. - */ - if (p2 == NULL) { - error = ESRCH; - } else { - if (args->flags & LINUX_CLONE_PARENT_SETTID) { - error = copyout(&p2->p_pid, args->parent_tidptr, sizeof(p2->p_pid)); - } - } - - p2->p_sigparent = exit_signal; - if (args->stack) { - ONLY_LWP_IN_PROC(p2)->lwp_md.md_regs->tf_esp = - (unsigned long)args->stack; - } - - if (args->flags & LINUX_CLONE_SETTLS) { - error = copyin((void *)curthread->td_lwp->lwp_md.md_regs->tf_esi, &info, sizeof(struct l_user_desc)); - if (error) { - kprintf("copyin of tf_esi to info failed\n"); - } else { - idx = info.entry_number; - /* - * We understand both our own entries such as the ones - * we provide on linux_set_thread_area, as well as the - * linux-type entries 6-8. - */ - if ((idx < 6 || idx > 8) && (idx < GTLS_START)) { - kprintf("LINUX_CLONE_SETTLS, invalid idx requested: %d\n", idx); - goto out; - } - if (idx < GTLS_START) { - idx -= 6; - } else { -#if 0 /* was SMP */ - idx -= (GTLS_START + mycpu->gd_cpuid * NGDT); -#endif - idx -= GTLS_START; - } - KKASSERT(idx >= 0); - - a[0] = LINUX_LDT_entry_a(&info); - a[1] = LINUX_LDT_entry_b(&info); - if (p2) { - desc = &FIRST_LWP_IN_PROC(p2)->lwp_thread->td_tls.tls[idx]; - memcpy(desc, &a, sizeof(a)); - } else { - kprintf("linux_clone... we don't have a p2\n"); - } - } - } -out: - if (p2) - start_forked_proc(lp, p2); - - rel_mplock(); -#ifdef DEBUG - if (ldebug(clone)) - kprintf(LMSG("clone: successful rfork to %ld"), - (long)p2->p_pid); -#endif - - return (error); -} - -/* XXX move */ -struct l_mmap_argv { - l_caddr_t addr; - l_int len; - l_int prot; - l_int flags; - l_int fd; - l_int pos; -}; - -#define STACK_SIZE (2 * 1024 * 1024) -#define GUARD_SIZE (4 * PAGE_SIZE) - -/* - * MPALMOSTSAFE - */ -static int -linux_mmap_common(caddr_t linux_addr, size_t linux_len, int linux_prot, - int linux_flags, int linux_fd, off_t pos, void **res) -{ - struct thread *td = curthread; - struct proc *p = td->td_proc; - caddr_t addr; - void *new; - int error, flags, len, prot, fd; - - flags = 0; - if (linux_flags & LINUX_MAP_SHARED) - flags |= MAP_SHARED; - if (linux_flags & LINUX_MAP_PRIVATE) - flags |= MAP_PRIVATE; - if (linux_flags & LINUX_MAP_FIXED) - flags |= MAP_FIXED; - if (linux_flags & LINUX_MAP_ANON) { - flags |= MAP_ANON; - } else { - flags |= MAP_NOSYNC; - } - - lwkt_gettoken(&curproc->p_vmspace->vm_map.token); - - if (linux_flags & LINUX_MAP_GROWSDOWN) { - flags |= MAP_STACK; - /* The linux MAP_GROWSDOWN option does not limit auto - * growth of the region. Linux mmap with this option - * takes as addr the inital BOS, and as len, the initial - * region size. It can then grow down from addr without - * limit. However, linux threads has an implicit internal - * limit to stack size of STACK_SIZE. Its just not - * enforced explicitly in linux. But, here we impose - * a limit of (STACK_SIZE - GUARD_SIZE) on the stack - * region, since we can do this with our mmap. - * - * Our mmap with MAP_STACK takes addr as the maximum - * downsize limit on BOS, and as len the max size of - * the region. It them maps the top SGROWSIZ bytes, - * and autgrows the region down, up to the limit - * in addr. - * - * If we don't use the MAP_STACK option, the effect - * of this code is to allocate a stack region of a - * fixed size of (STACK_SIZE - GUARD_SIZE). - */ - - /* This gives us TOS */ - addr = linux_addr + linux_len; - - if (addr > p->p_vmspace->vm_maxsaddr) { - /* Some linux apps will attempt to mmap - * thread stacks near the top of their - * address space. If their TOS is greater - * than vm_maxsaddr, vm_map_growstack() - * will confuse the thread stack with the - * process stack and deliver a SEGV if they - * attempt to grow the thread stack past their - * current stacksize rlimit. To avoid this, - * adjust vm_maxsaddr upwards to reflect - * the current stacksize rlimit rather - * than the maximum possible stacksize. - * It would be better to adjust the - * mmap'ed region, but some apps do not check - * mmap's return value. - */ - p->p_vmspace->vm_maxsaddr = (char *)USRSTACK - - p->p_rlimit[RLIMIT_STACK].rlim_cur; - } - - /* This gives us our maximum stack size */ - if (linux_len > STACK_SIZE - GUARD_SIZE) { - len = linux_len; - } else { - len = STACK_SIZE - GUARD_SIZE; - } - /* This gives us a new BOS. If we're using VM_STACK, then - * mmap will just map the top SGROWSIZ bytes, and let - * the stack grow down to the limit at BOS. If we're - * not using VM_STACK we map the full stack, since we - * don't have a way to autogrow it. - */ - addr -= len; - } else { - addr = linux_addr; - len = linux_len; - } - - prot = linux_prot; - - if (prot & (PROT_READ | PROT_WRITE | PROT_EXEC)) - prot |= PROT_READ | PROT_EXEC; - - if (linux_flags & LINUX_MAP_ANON) { - fd = -1; - } else { - fd = linux_fd; - } - -#ifdef DEBUG - if (ldebug(mmap) || ldebug(mmap2)) - kprintf("-> (%p, %d, %d, 0x%08x, %d, %lld)\n", - addr, len, prot, flags, fd, pos); -#endif - error = kern_mmap(curproc->p_vmspace, addr, len, - prot, flags, fd, pos, &new); - - lwkt_reltoken(&curproc->p_vmspace->vm_map.token); - - if (error == 0) - *res = new; - return (error); -} - -/* - * MPSAFE - */ -int -sys_linux_mmap(struct linux_mmap_args *args) -{ - struct l_mmap_argv linux_args; - int error; - - error = copyin((caddr_t)args->ptr, &linux_args, sizeof(linux_args)); - if (error) - return (error); - -#ifdef DEBUG - if (ldebug(mmap)) - kprintf(ARGS(mmap, "%p, %d, %d, 0x%08x, %d, %d"), - (void *)linux_args.addr, linux_args.len, linux_args.prot, - linux_args.flags, linux_args.fd, linux_args.pos); -#endif - error = linux_mmap_common(linux_args.addr, linux_args.len, - linux_args.prot, linux_args.flags, linux_args.fd, - linux_args.pos, &args->sysmsg_resultp); -#ifdef DEBUG - if (ldebug(mmap)) - kprintf("-> %p\n", args->sysmsg_resultp); -#endif - return(error); -} - -/* - * MPSAFE - */ -int -sys_linux_mmap2(struct linux_mmap2_args *args) -{ - int error; - -#ifdef DEBUG - if (ldebug(mmap2)) - kprintf(ARGS(mmap2, "%p, %d, %d, 0x%08x, %d, %d"), - (void *)args->addr, args->len, args->prot, args->flags, - args->fd, args->pgoff); -#endif - error = linux_mmap_common((void *)args->addr, args->len, args->prot, - args->flags, args->fd, args->pgoff * PAGE_SIZE, - &args->sysmsg_resultp); -#ifdef DEBUG - if (ldebug(mmap2)) - kprintf("-> %p\n", args->sysmsg_resultp); -#endif - return (error); -} - -/* - * MPSAFE - */ -int -sys_linux_pipe(struct linux_pipe_args *args) -{ - int error; - int reg_edx; - struct pipe_args bsd_args; - -#ifdef DEBUG - if (ldebug(pipe)) - kprintf(ARGS(pipe, "*")); -#endif - - reg_edx = args->sysmsg_fds[1]; - error = sys_pipe(&bsd_args); - if (error) { - args->sysmsg_fds[1] = reg_edx; - return (error); - } - - error = copyout(bsd_args.sysmsg_fds, args->pipefds, 2*sizeof(int)); - if (error) { - args->sysmsg_fds[1] = reg_edx; - return (error); - } - - args->sysmsg_fds[1] = reg_edx; - args->sysmsg_fds[0] = 0; - return (0); -} - -/* - * XXX: Preliminary - */ -int -sys_linux_pipe2(struct linux_pipe2_args *args) -{ - struct thread *td = curthread; - int error; - int reg_edx; - struct pipe_args bsd_args; - union fcntl_dat dat; - - reg_edx = args->sysmsg_fds[1]; - error = sys_pipe(&bsd_args); - if (error) { - args->sysmsg_fds[1] = reg_edx; - return (error); - } - -// if (args->flags & LINUX_O_CLOEXEC) { -// } - - if (args->flags & LINUX_O_NONBLOCK) { - dat.fc_flags = O_NONBLOCK; - kern_fcntl(bsd_args.sysmsg_fds[0], F_SETFL, &dat, td->td_ucred); - kern_fcntl(bsd_args.sysmsg_fds[1], F_SETFL, &dat, td->td_ucred); - } - - error = copyout(bsd_args.sysmsg_fds, args->pipefds, 2*sizeof(int)); - if (error) { - args->sysmsg_fds[1] = reg_edx; - return (error); - } - - args->sysmsg_fds[1] = reg_edx; - args->sysmsg_fds[0] = 0; - return (0); -} - -/* - * MPSAFE - */ -int -sys_linux_ioperm(struct linux_ioperm_args *args) -{ - struct sysarch_args sa; - struct i386_ioperm_args *iia; - caddr_t sg; - int error; - - sg = stackgap_init(); - iia = stackgap_alloc(&sg, sizeof(struct i386_ioperm_args)); - iia->start = args->start; - iia->length = args->length; - iia->enable = args->enable; - sa.sysmsg_resultp = NULL; - sa.op = I386_SET_IOPERM; - sa.parms = (char *)iia; - error = sys_sysarch(&sa); - args->sysmsg_resultp = sa.sysmsg_resultp; - return(error); -} - -/* - * MPSAFE - */ -int -sys_linux_iopl(struct linux_iopl_args *args) -{ - struct thread *td = curthread; - struct lwp *lp = td->td_lwp; - int error; - - if (args->level < 0 || args->level > 3) - return (EINVAL); - if ((error = priv_check(td, PRIV_ROOT)) != 0) - return (error); - if (securelevel > 0) - return (EPERM); - lp->lwp_md.md_regs->tf_eflags = - (lp->lwp_md.md_regs->tf_eflags & ~PSL_IOPL) | - (args->level * (PSL_IOPL / 3)); - return (0); -} - -/* - * MPSAFE - */ -int -sys_linux_modify_ldt(struct linux_modify_ldt_args *uap) -{ - int error; - caddr_t sg; - struct sysarch_args args; - struct i386_ldt_args *ldt; - struct l_descriptor ld; - union descriptor *desc; - int size, written; - - sg = stackgap_init(); - - if (uap->ptr == NULL) - return (EINVAL); - - switch (uap->func) { - case 0x00: /* read_ldt */ - ldt = stackgap_alloc(&sg, sizeof(*ldt)); - ldt->start = 0; - ldt->descs = uap->ptr; - ldt->num = uap->bytecount / sizeof(union descriptor); - args.op = I386_GET_LDT; - args.parms = (char*)ldt; - args.sysmsg_iresult = 0; - error = sys_sysarch(&args); - uap->sysmsg_iresult = args.sysmsg_iresult * - sizeof(union descriptor); - break; - case 0x02: /* read_default_ldt = 0 */ - size = 5*sizeof(struct l_desc_struct); - if (size > uap->bytecount) - size = uap->bytecount; - for (written = error = 0; written < size && error == 0; written++) - error = subyte((char *)uap->ptr + written, 0); - uap->sysmsg_iresult = written; - break; - case 0x01: /* write_ldt */ - case 0x11: /* write_ldt */ - if (uap->bytecount != sizeof(ld)) - return (EINVAL); - - error = copyin(uap->ptr, &ld, sizeof(ld)); - if (error) - return (error); - - ldt = stackgap_alloc(&sg, sizeof(*ldt)); - desc = stackgap_alloc(&sg, sizeof(*desc)); - ldt->start = ld.entry_number; - ldt->descs = desc; - ldt->num = 1; - desc->sd.sd_lolimit = (ld.limit & 0x0000ffff); - desc->sd.sd_hilimit = (ld.limit & 0x000f0000) >> 16; - desc->sd.sd_lobase = (ld.base_addr & 0x00ffffff); - desc->sd.sd_hibase = (ld.base_addr & 0xff000000) >> 24; - desc->sd.sd_type = SDT_MEMRO | ((ld.read_exec_only ^ 1) << 1) | - (ld.contents << 2); - desc->sd.sd_dpl = 3; - desc->sd.sd_p = (ld.seg_not_present ^ 1); - desc->sd.sd_xx = 0; - desc->sd.sd_def32 = ld.seg_32bit; - desc->sd.sd_gran = ld.limit_in_pages; - args.op = I386_SET_LDT; - args.parms = (char*)ldt; - args.sysmsg_iresult = 0; - error = sys_sysarch(&args); - uap->sysmsg_iresult = args.sysmsg_iresult; - break; - default: - error = EINVAL; - break; - } - - return (error); -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_sigaction(struct linux_sigaction_args *args) -{ - l_osigaction_t osa; - l_sigaction_t linux_act, linux_oact; - struct sigaction act, oact; - int error, sig; - -#ifdef DEBUG - if (ldebug(sigaction)) - kprintf(ARGS(sigaction, "%d, %p, %p"), - args->sig, (void *)args->nsa, (void *)args->osa); -#endif - - if (args->nsa) { - error = copyin(args->nsa, &osa, sizeof(l_osigaction_t)); - if (error) - return (error); - linux_act.lsa_handler = osa.lsa_handler; - linux_act.lsa_flags = osa.lsa_flags; - linux_act.lsa_restorer = osa.lsa_restorer; - LINUX_SIGEMPTYSET(linux_act.lsa_mask); - linux_act.lsa_mask.__bits[0] = osa.lsa_mask; - linux_to_bsd_sigaction(&linux_act, &act); - } - - if (args->sig <= LINUX_SIGTBLSZ) - sig = linux_to_bsd_signal[_SIG_IDX(args->sig)]; - else - sig = args->sig; - - get_mplock(); - error = kern_sigaction(sig, args->nsa ? &act : NULL, - args->osa ? &oact : NULL); - rel_mplock(); - - if (args->osa != NULL && !error) { - bsd_to_linux_sigaction(&oact, &linux_oact); - osa.lsa_handler = linux_oact.lsa_handler; - osa.lsa_flags = linux_oact.lsa_flags; - osa.lsa_restorer = linux_oact.lsa_restorer; - osa.lsa_mask = linux_oact.lsa_mask.__bits[0]; - error = copyout(&osa, args->osa, sizeof(l_osigaction_t)); - } - return (error); -} - -/* - * Linux has two extra args, restart and oldmask. We dont use these, - * but it seems that "restart" is actually a context pointer that - * enables the signal to happen with a different register set. - * - * MPALMOSTSAFE - */ -int -sys_linux_sigsuspend(struct linux_sigsuspend_args *args) -{ - l_sigset_t linux_mask; - sigset_t mask; - int error; - -#ifdef DEBUG - if (ldebug(sigsuspend)) - kprintf(ARGS(sigsuspend, "%08lx"), (unsigned long)args->mask); -#endif - - LINUX_SIGEMPTYSET(mask); - mask.__bits[0] = args->mask; - linux_to_bsd_sigset(&linux_mask, &mask); - - get_mplock(); - error = kern_sigsuspend(&mask); - rel_mplock(); - - return(error); -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_rt_sigsuspend(struct linux_rt_sigsuspend_args *uap) -{ - l_sigset_t linux_mask; - sigset_t mask; - int error; - -#ifdef DEBUG - if (ldebug(rt_sigsuspend)) - kprintf(ARGS(rt_sigsuspend, "%p, %d"), - (void *)uap->newset, uap->sigsetsize); -#endif - - if (uap->sigsetsize != sizeof(l_sigset_t)) - return (EINVAL); - - error = copyin(uap->newset, &linux_mask, sizeof(l_sigset_t)); - if (error) - return (error); - - linux_to_bsd_sigset(&linux_mask, &mask); - - get_mplock(); - error = kern_sigsuspend(&mask); - rel_mplock(); - - return(error); -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_pause(struct linux_pause_args *args) -{ - struct thread *td = curthread; - struct lwp *lp = td->td_lwp; - sigset_t mask; - int error; - -#ifdef DEBUG - if (ldebug(pause)) - kprintf(ARGS(pause, "")); -#endif - - mask = lp->lwp_sigmask; - - get_mplock(); - error = kern_sigsuspend(&mask); - rel_mplock(); - - return(error); -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_sigaltstack(struct linux_sigaltstack_args *uap) -{ - stack_t ss, oss; - l_stack_t linux_ss; - int error; - -#ifdef DEBUG - if (ldebug(sigaltstack)) - kprintf(ARGS(sigaltstack, "%p, %p"), uap->uss, uap->uoss); -#endif - - if (uap->uss) { - error = copyin(uap->uss, &linux_ss, sizeof(l_stack_t)); - if (error) - return (error); - - ss.ss_sp = linux_ss.ss_sp; - ss.ss_size = linux_ss.ss_size; - ss.ss_flags = linux_to_bsd_sigaltstack(linux_ss.ss_flags); - } - - get_mplock(); - error = kern_sigaltstack(uap->uss ? &ss : NULL, - uap->uoss ? &oss : NULL); - rel_mplock(); - - if (error == 0 && uap->uoss) { - linux_ss.ss_sp = oss.ss_sp; - linux_ss.ss_size = oss.ss_size; - linux_ss.ss_flags = bsd_to_linux_sigaltstack(oss.ss_flags); - error = copyout(&linux_ss, uap->uoss, sizeof(l_stack_t)); - } - - return (error); -} - -int -sys_linux_set_thread_area(struct linux_set_thread_area_args *args) -{ - struct segment_descriptor *desc; - struct l_user_desc info; - int error; - int idx; - int a[2]; - int i; - - error = copyin(args->desc, &info, sizeof(struct l_user_desc)); - if (error) - return (EFAULT); - -#ifdef DEBUG - if (ldebug(set_thread_area)) - kprintf(ARGS(set_thread_area, "%i, %x, %x, %i, %i, %i, %i, %i, %i\n"), - info.entry_number, - info.base_addr, - info.limit, - info.seg_32bit, - info.contents, - info.read_exec_only, - info.limit_in_pages, - info.seg_not_present, - info.useable); -#endif - - idx = info.entry_number; - if (idx != -1 && (idx < 6 || idx > 8)) - return (EINVAL); - - if (idx == -1) { - /* -1 means finding the first free TLS entry */ - for (i = 0; i < NGTLS; i++) { - /* - * try to determine if the TLS entry is empty by looking - * at the lolimit entry. - */ - if (curthread->td_tls.tls[idx].sd_lolimit == 0) { - idx = i; - break; - } - } - - if (idx == -1) { - /* - * By now we should have an index. If not, it means - * that no entry is free, so return ESRCH. - */ - return (ESRCH); - } - } else { - /* translate the index from Linux to ours */ - idx -= 6; - KKASSERT(idx >= 0); - } - - /* Tell the caller about the allocated entry number */ -#if 0 /* was SMP */ - info.entry_number = GTLS_START + mycpu->gd_cpuid * NGDT + idx; -#endif - info.entry_number = GTLS_START + idx; - - - error = copyout(&info, args->desc, sizeof(struct l_user_desc)); - if (error) - return (error); - - if (LINUX_LDT_empty(&info)) { - a[0] = 0; - a[1] = 0; - } else { - a[0] = LINUX_LDT_entry_a(&info); - a[1] = LINUX_LDT_entry_b(&info); - } - - /* - * Update the TLS and the TLS entries in the GDT, but hold a critical - * section as required by set_user_TLS(). - */ - crit_enter(); - desc = &curthread->td_tls.tls[idx]; - memcpy(desc, &a, sizeof(a)); - set_user_TLS(); - crit_exit(); - - return (0); -} - -int -sys_linux_get_thread_area(struct linux_get_thread_area_args *args) -{ - struct segment_descriptor *sd; - struct l_desc_struct desc; - struct l_user_desc info; - int error; - int idx; - -#ifdef DEBUG - if (ldebug(get_thread_area)) - kprintf(ARGS(get_thread_area, "%p"), args->desc); -#endif - - error = copyin(args->desc, &info, sizeof(struct l_user_desc)); - if (error) - return (EFAULT); - - idx = info.entry_number; - if ((idx < 6 || idx > 8) && (idx < GTLS_START)) { - kprintf("sys_linux_get_thread_area, invalid idx requested: %d\n", idx); - return (EINVAL); - } - - memset(&info, 0, sizeof(info)); - - /* translate the index from Linux to ours */ - info.entry_number = idx; - if (idx < GTLS_START) { - idx -= 6; - } else { -#if 0 /* was SMP */ - idx -= (GTLS_START + mycpu->gd_cpuid * NGDT); -#endif - idx -= GTLS_START; - - } - KKASSERT(idx >= 0); - - sd = &curthread->td_tls.tls[idx]; - memcpy(&desc, sd, sizeof(desc)); - info.base_addr = LINUX_GET_BASE(&desc); - info.limit = LINUX_GET_LIMIT(&desc); - info.seg_32bit = LINUX_GET_32BIT(&desc); - info.contents = LINUX_GET_CONTENTS(&desc); - info.read_exec_only = !LINUX_GET_WRITABLE(&desc); - info.limit_in_pages = LINUX_GET_LIMIT_PAGES(&desc); - info.seg_not_present = !LINUX_GET_PRESENT(&desc); - info.useable = LINUX_GET_USEABLE(&desc); - - error = copyout(&info, args->desc, sizeof(struct l_user_desc)); - if (error) - return (EFAULT); - - return (0); -} diff --git a/sys/emulation/linux/i386/linux_proto.h b/sys/emulation/linux/i386/linux_proto.h deleted file mode 100644 index 382db81ef4..0000000000 --- a/sys/emulation/linux/i386/linux_proto.h +++ /dev/null @@ -1,1951 +0,0 @@ -/* - * System call prototypes. - * - * DO NOT EDIT-- To regenerate this file, edit syscalls.master followed - * by running make sysent in the same directory. - */ - -#ifndef _LINUX_SYSPROTO_H_ -#define _LINUX_SYSPROTO_H_ - -#include - -#include - -#include - -#include - -#include - -#include - -#define PAD_(t) (sizeof(register_t) <= sizeof(t) ? \ - 0 : sizeof(register_t) - sizeof(t)) - -#define nosys linux_nosys -struct linux_fork_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_open_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - char * path; char path_[PAD_(char *)]; - l_int flags; char flags_[PAD_(l_int)]; - l_int mode; char mode_[PAD_(l_int)]; -}; -struct linux_waitpid_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_pid_t pid; char pid_[PAD_(l_pid_t)]; - l_int * status; char status_[PAD_(l_int *)]; - l_int options; char options_[PAD_(l_int)]; -}; -struct linux_creat_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - char * path; char path_[PAD_(char *)]; - l_int mode; char mode_[PAD_(l_int)]; -}; -struct linux_link_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - char * path; char path_[PAD_(char *)]; - char * to; char to_[PAD_(char *)]; -}; -struct linux_unlink_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - char * path; char path_[PAD_(char *)]; -}; -struct linux_execve_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - char * path; char path_[PAD_(char *)]; - char ** argp; char argp_[PAD_(char **)]; - char ** envp; char envp_[PAD_(char **)]; -}; -struct linux_chdir_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - char * path; char path_[PAD_(char *)]; -}; -struct linux_time_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_time_t * tm; char tm_[PAD_(l_time_t *)]; -}; -struct linux_mknod_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - char * path; char path_[PAD_(char *)]; - l_int mode; char mode_[PAD_(l_int)]; - l_dev_t dev; char dev_[PAD_(l_dev_t)]; -}; -struct linux_chmod_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - char * path; char path_[PAD_(char *)]; - l_mode_t mode; char mode_[PAD_(l_mode_t)]; -}; -struct linux_lchown16_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - char * path; char path_[PAD_(char *)]; - l_uid16_t uid; char uid_[PAD_(l_uid16_t)]; - l_gid16_t gid; char gid_[PAD_(l_gid16_t)]; -}; -struct linux_stat_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - char * path; char path_[PAD_(char *)]; - struct ostat * statbuf; char statbuf_[PAD_(struct ostat *)]; -}; -struct linux_lseek_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_uint fdes; char fdes_[PAD_(l_uint)]; - l_off_t off; char off_[PAD_(l_off_t)]; - l_int whence; char whence_[PAD_(l_int)]; -}; -struct linux_getpid_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_mount_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - char * specialfile; char specialfile_[PAD_(char *)]; - char * dir; char dir_[PAD_(char *)]; - char * filesystemtype; char filesystemtype_[PAD_(char *)]; - l_ulong rwflag; char rwflag_[PAD_(l_ulong)]; - void * data; char data_[PAD_(void *)]; -}; -struct linux_oldumount_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - char * path; char path_[PAD_(char *)]; -}; -struct linux_setuid16_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_uid16_t uid; char uid_[PAD_(l_uid16_t)]; -}; -struct linux_getuid16_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_stime_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_ptrace_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_long req; char req_[PAD_(l_long)]; - l_long pid; char pid_[PAD_(l_long)]; - l_long addr; char addr_[PAD_(l_long)]; - l_long data; char data_[PAD_(l_long)]; -}; -struct linux_alarm_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_uint secs; char secs_[PAD_(l_uint)]; -}; -struct linux_fstat_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_uint fd; char fd_[PAD_(l_uint)]; - struct ostat * up; char up_[PAD_(struct ostat *)]; -}; -struct linux_pause_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_utime_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - char * fname; char fname_[PAD_(char *)]; - struct l_utimbuf * times; char times_[PAD_(struct l_utimbuf *)]; -}; -struct linux_access_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - char * path; char path_[PAD_(char *)]; - l_int flags; char flags_[PAD_(l_int)]; -}; -struct linux_nice_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_int inc; char inc_[PAD_(l_int)]; -}; -struct linux_kill_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_int pid; char pid_[PAD_(l_int)]; - l_int signum; char signum_[PAD_(l_int)]; -}; -struct linux_rename_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - char * from; char from_[PAD_(char *)]; - char * to; char to_[PAD_(char *)]; -}; -struct linux_mkdir_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - char * path; char path_[PAD_(char *)]; - l_int mode; char mode_[PAD_(l_int)]; -}; -struct linux_rmdir_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - char * path; char path_[PAD_(char *)]; -}; -struct linux_pipe_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_ulong * pipefds; char pipefds_[PAD_(l_ulong *)]; -}; -struct linux_times_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - struct l_times_argv * buf; char buf_[PAD_(struct l_times_argv *)]; -}; -struct linux_brk_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_ulong dsend; char dsend_[PAD_(l_ulong)]; -}; -struct linux_setgid16_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_gid16_t gid; char gid_[PAD_(l_gid16_t)]; -}; -struct linux_getgid16_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_signal_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_int sig; char sig_[PAD_(l_int)]; - l_handler_t handler; char handler_[PAD_(l_handler_t)]; -}; -struct linux_geteuid16_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_getegid16_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_umount_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - char * path; char path_[PAD_(char *)]; - l_int flags; char flags_[PAD_(l_int)]; -}; -struct linux_ioctl_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_uint fd; char fd_[PAD_(l_uint)]; - l_uint cmd; char cmd_[PAD_(l_uint)]; - l_ulong arg; char arg_[PAD_(l_ulong)]; -}; -struct linux_fcntl_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_uint fd; char fd_[PAD_(l_uint)]; - l_uint cmd; char cmd_[PAD_(l_uint)]; - l_ulong arg; char arg_[PAD_(l_ulong)]; -}; -struct linux_olduname_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_ustat_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_dev_t dev; char dev_[PAD_(l_dev_t)]; - struct l_ustat * ubuf; char ubuf_[PAD_(struct l_ustat *)]; -}; -struct linux_getppid_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_sigaction_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_int sig; char sig_[PAD_(l_int)]; - l_osigaction_t * nsa; char nsa_[PAD_(l_osigaction_t *)]; - l_osigaction_t * osa; char osa_[PAD_(l_osigaction_t *)]; -}; -struct linux_sgetmask_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_ssetmask_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_osigset_t mask; char mask_[PAD_(l_osigset_t)]; -}; -struct linux_setreuid16_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_uid16_t ruid; char ruid_[PAD_(l_uid16_t)]; - l_uid16_t euid; char euid_[PAD_(l_uid16_t)]; -}; -struct linux_setregid16_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_gid16_t rgid; char rgid_[PAD_(l_gid16_t)]; - l_gid16_t egid; char egid_[PAD_(l_gid16_t)]; -}; -struct linux_sigsuspend_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_int hist0; char hist0_[PAD_(l_int)]; - l_int hist1; char hist1_[PAD_(l_int)]; - l_osigset_t mask; char mask_[PAD_(l_osigset_t)]; -}; -struct linux_sigpending_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_osigset_t * mask; char mask_[PAD_(l_osigset_t *)]; -}; -struct linux_sethostname_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - char * hostname; char hostname_[PAD_(char *)]; - u_int len; char len_[PAD_(u_int)]; -}; -struct linux_setrlimit_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_uint resource; char resource_[PAD_(l_uint)]; - struct l_rlimit * rlim; char rlim_[PAD_(struct l_rlimit *)]; -}; -struct linux_old_getrlimit_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_uint resource; char resource_[PAD_(l_uint)]; - struct l_rlimit * rlim; char rlim_[PAD_(struct l_rlimit *)]; -}; -struct linux_getgroups16_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_uint gidsetsize; char gidsetsize_[PAD_(l_uint)]; - l_gid16_t * gidset; char gidset_[PAD_(l_gid16_t *)]; -}; -struct linux_setgroups16_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_uint gidsetsize; char gidsetsize_[PAD_(l_uint)]; - l_gid16_t * gidset; char gidset_[PAD_(l_gid16_t *)]; -}; -struct linux_old_select_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - struct l_old_select_argv * ptr; char ptr_[PAD_(struct l_old_select_argv *)]; -}; -struct linux_symlink_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - char * path; char path_[PAD_(char *)]; - char * to; char to_[PAD_(char *)]; -}; -struct linux_ostat_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - char * path; char path_[PAD_(char *)]; - struct ostat * statbuf; char statbuf_[PAD_(struct ostat *)]; -}; -struct linux_readlink_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - char * name; char name_[PAD_(char *)]; - char * buf; char buf_[PAD_(char *)]; - l_int count; char count_[PAD_(l_int)]; -}; -struct linux_uselib_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - char * library; char library_[PAD_(char *)]; -}; -struct linux_reboot_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_int magic1; char magic1_[PAD_(l_int)]; - l_int magic2; char magic2_[PAD_(l_int)]; - l_uint cmd; char cmd_[PAD_(l_uint)]; - void * arg; char arg_[PAD_(void *)]; -}; -struct linux_readdir_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_uint fd; char fd_[PAD_(l_uint)]; - struct l_dirent * dent; char dent_[PAD_(struct l_dirent *)]; - l_uint count; char count_[PAD_(l_uint)]; -}; -struct linux_mmap_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - struct l_mmap_argv * ptr; char ptr_[PAD_(struct l_mmap_argv *)]; -}; -struct linux_truncate_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - char * path; char path_[PAD_(char *)]; - l_ulong length; char length_[PAD_(l_ulong)]; -}; -struct linux_ftruncate_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - int fd; char fd_[PAD_(int)]; - long length; char length_[PAD_(long)]; -}; -struct linux_statfs_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - char * path; char path_[PAD_(char *)]; - struct l_statfs_buf * buf; char buf_[PAD_(struct l_statfs_buf *)]; -}; -struct linux_fstatfs_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_uint fd; char fd_[PAD_(l_uint)]; - struct l_statfs_buf * buf; char buf_[PAD_(struct l_statfs_buf *)]; -}; -struct linux_ioperm_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_ulong start; char start_[PAD_(l_ulong)]; - l_ulong length; char length_[PAD_(l_ulong)]; - l_int enable; char enable_[PAD_(l_int)]; -}; -struct linux_socketcall_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_int what; char what_[PAD_(l_int)]; - l_ulong args; char args_[PAD_(l_ulong)]; -}; -struct linux_syslog_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_int type; char type_[PAD_(l_int)]; - char * buf; char buf_[PAD_(char *)]; - l_int len; char len_[PAD_(l_int)]; -}; -struct linux_setitimer_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_int which; char which_[PAD_(l_int)]; - struct l_itimerval * itv; char itv_[PAD_(struct l_itimerval *)]; - struct l_itimerval * oitv; char oitv_[PAD_(struct l_itimerval *)]; -}; -struct linux_getitimer_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_int which; char which_[PAD_(l_int)]; - struct l_itimerval * itv; char itv_[PAD_(struct l_itimerval *)]; -}; -struct linux_newstat_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - char * path; char path_[PAD_(char *)]; - struct l_newstat * buf; char buf_[PAD_(struct l_newstat *)]; -}; -struct linux_newlstat_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - char * path; char path_[PAD_(char *)]; - struct l_newstat * buf; char buf_[PAD_(struct l_newstat *)]; -}; -struct linux_newfstat_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_uint fd; char fd_[PAD_(l_uint)]; - struct l_newstat * buf; char buf_[PAD_(struct l_newstat *)]; -}; -struct linux_uname_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_iopl_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_ulong level; char level_[PAD_(l_ulong)]; -}; -struct linux_vhangup_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_vm86old_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_wait4_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_pid_t pid; char pid_[PAD_(l_pid_t)]; - l_uint * status; char status_[PAD_(l_uint *)]; - l_int options; char options_[PAD_(l_int)]; - struct l_rusage * rusage; char rusage_[PAD_(struct l_rusage *)]; -}; -struct linux_swapoff_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_sysinfo_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - struct l_sysinfo * info; char info_[PAD_(struct l_sysinfo *)]; -}; -struct linux_ipc_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_uint what; char what_[PAD_(l_uint)]; - l_int arg1; char arg1_[PAD_(l_int)]; - l_int arg2; char arg2_[PAD_(l_int)]; - l_int arg3; char arg3_[PAD_(l_int)]; - void * ptr; char ptr_[PAD_(void *)]; - l_long arg5; char arg5_[PAD_(l_long)]; -}; -struct linux_sigreturn_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - struct l_sigframe * sfp; char sfp_[PAD_(struct l_sigframe *)]; -}; -struct linux_clone_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_int flags; char flags_[PAD_(l_int)]; - void * stack; char stack_[PAD_(void *)]; - void * parent_tidptr; char parent_tidptr_[PAD_(void *)]; - int dummy; char dummy_[PAD_(int)]; - void * child_tidptr; char child_tidptr_[PAD_(void *)]; -}; -struct linux_newuname_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - struct l_new_utsname * buf; char buf_[PAD_(struct l_new_utsname *)]; -}; -struct linux_modify_ldt_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_int func; char func_[PAD_(l_int)]; - void * ptr; char ptr_[PAD_(void *)]; - l_ulong bytecount; char bytecount_[PAD_(l_ulong)]; -}; -struct linux_adjtimex_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_sigprocmask_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_int how; char how_[PAD_(l_int)]; - l_osigset_t * mask; char mask_[PAD_(l_osigset_t *)]; - l_osigset_t * omask; char omask_[PAD_(l_osigset_t *)]; -}; -struct linux_create_module_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_init_module_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_delete_module_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_get_kernel_syms_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_quotactl_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_bdflush_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_sysfs_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_int option; char option_[PAD_(l_int)]; - l_ulong arg1; char arg1_[PAD_(l_ulong)]; - l_ulong arg2; char arg2_[PAD_(l_ulong)]; -}; -struct linux_personality_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_ulong per; char per_[PAD_(l_ulong)]; -}; -struct linux_setfsuid16_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_uid16_t uid; char uid_[PAD_(l_uid16_t)]; -}; -struct linux_setfsgid16_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_gid16_t gid; char gid_[PAD_(l_gid16_t)]; -}; -struct linux_llseek_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_int fd; char fd_[PAD_(l_int)]; - l_ulong ohigh; char ohigh_[PAD_(l_ulong)]; - l_ulong olow; char olow_[PAD_(l_ulong)]; - l_loff_t * res; char res_[PAD_(l_loff_t *)]; - l_uint whence; char whence_[PAD_(l_uint)]; -}; -struct linux_getdents_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_uint fd; char fd_[PAD_(l_uint)]; - void * dent; char dent_[PAD_(void *)]; - l_uint count; char count_[PAD_(l_uint)]; -}; -struct linux_select_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_int nfds; char nfds_[PAD_(l_int)]; - l_fd_set * readfds; char readfds_[PAD_(l_fd_set *)]; - l_fd_set * writefds; char writefds_[PAD_(l_fd_set *)]; - l_fd_set * exceptfds; char exceptfds_[PAD_(l_fd_set *)]; - struct l_timeval * timeout; char timeout_[PAD_(struct l_timeval *)]; -}; -struct linux_msync_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_ulong addr; char addr_[PAD_(l_ulong)]; - l_size_t len; char len_[PAD_(l_size_t)]; - l_int fl; char fl_[PAD_(l_int)]; -}; -struct linux_getsid_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_pid_t pid; char pid_[PAD_(l_pid_t)]; -}; -struct linux_fdatasync_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_uint fd; char fd_[PAD_(l_uint)]; -}; -struct linux_sysctl_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - struct l___sysctl_args * args; char args_[PAD_(struct l___sysctl_args *)]; -}; -struct linux_sched_setscheduler_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_pid_t pid; char pid_[PAD_(l_pid_t)]; - l_int policy; char policy_[PAD_(l_int)]; - struct l_sched_param * param; char param_[PAD_(struct l_sched_param *)]; -}; -struct linux_sched_getscheduler_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_pid_t pid; char pid_[PAD_(l_pid_t)]; -}; -struct linux_sched_get_priority_max_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_int policy; char policy_[PAD_(l_int)]; -}; -struct linux_sched_get_priority_min_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_int policy; char policy_[PAD_(l_int)]; -}; -struct linux_mremap_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_ulong addr; char addr_[PAD_(l_ulong)]; - l_ulong old_len; char old_len_[PAD_(l_ulong)]; - l_ulong new_len; char new_len_[PAD_(l_ulong)]; - l_ulong flags; char flags_[PAD_(l_ulong)]; - l_ulong new_addr; char new_addr_[PAD_(l_ulong)]; -}; -struct linux_setresuid16_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_uid16_t ruid; char ruid_[PAD_(l_uid16_t)]; - l_uid16_t euid; char euid_[PAD_(l_uid16_t)]; - l_uid16_t suid; char suid_[PAD_(l_uid16_t)]; -}; -struct linux_getresuid16_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_uid16_t * ruid; char ruid_[PAD_(l_uid16_t *)]; - l_uid16_t * euid; char euid_[PAD_(l_uid16_t *)]; - l_uid16_t * suid; char suid_[PAD_(l_uid16_t *)]; -}; -struct linux_vm86_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_query_module_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_nfsservctl_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_setresgid16_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_gid16_t rgid; char rgid_[PAD_(l_gid16_t)]; - l_gid16_t egid; char egid_[PAD_(l_gid16_t)]; - l_gid16_t sgid; char sgid_[PAD_(l_gid16_t)]; -}; -struct linux_getresgid16_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_gid16_t * rgid; char rgid_[PAD_(l_gid16_t *)]; - l_gid16_t * egid; char egid_[PAD_(l_gid16_t *)]; - l_gid16_t * sgid; char sgid_[PAD_(l_gid16_t *)]; -}; -struct linux_prctl_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_rt_sigreturn_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - struct l_ucontext * ucp; char ucp_[PAD_(struct l_ucontext *)]; -}; -struct linux_rt_sigaction_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_int sig; char sig_[PAD_(l_int)]; - l_sigaction_t * act; char act_[PAD_(l_sigaction_t *)]; - l_sigaction_t * oact; char oact_[PAD_(l_sigaction_t *)]; - l_size_t sigsetsize; char sigsetsize_[PAD_(l_size_t)]; -}; -struct linux_rt_sigprocmask_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_int how; char how_[PAD_(l_int)]; - l_sigset_t * mask; char mask_[PAD_(l_sigset_t *)]; - l_sigset_t * omask; char omask_[PAD_(l_sigset_t *)]; - l_size_t sigsetsize; char sigsetsize_[PAD_(l_size_t)]; -}; -struct linux_rt_sigpending_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_rt_sigtimedwait_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_rt_sigqueueinfo_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_rt_sigsuspend_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_sigset_t * newset; char newset_[PAD_(l_sigset_t *)]; - l_size_t sigsetsize; char sigsetsize_[PAD_(l_size_t)]; -}; -struct linux_pread_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_uint fd; char fd_[PAD_(l_uint)]; - char * buf; char buf_[PAD_(char *)]; - l_size_t nbyte; char nbyte_[PAD_(l_size_t)]; - l_loff_t offset; char offset_[PAD_(l_loff_t)]; -}; -struct linux_pwrite_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_uint fd; char fd_[PAD_(l_uint)]; - char * buf; char buf_[PAD_(char *)]; - l_size_t nbyte; char nbyte_[PAD_(l_size_t)]; - l_loff_t offset; char offset_[PAD_(l_loff_t)]; -}; -struct linux_chown16_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - char * path; char path_[PAD_(char *)]; - l_uid16_t uid; char uid_[PAD_(l_uid16_t)]; - l_gid16_t gid; char gid_[PAD_(l_gid16_t)]; -}; -struct linux_getcwd_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - char * buf; char buf_[PAD_(char *)]; - l_ulong bufsize; char bufsize_[PAD_(l_ulong)]; -}; -struct linux_capget_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_capset_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_sigaltstack_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_stack_t * uss; char uss_[PAD_(l_stack_t *)]; - l_stack_t * uoss; char uoss_[PAD_(l_stack_t *)]; -}; -struct linux_sendfile_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_vfork_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_getrlimit_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_uint resource; char resource_[PAD_(l_uint)]; - struct l_rlimit * rlim; char rlim_[PAD_(struct l_rlimit *)]; -}; -struct linux_mmap2_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_ulong addr; char addr_[PAD_(l_ulong)]; - l_ulong len; char len_[PAD_(l_ulong)]; - l_ulong prot; char prot_[PAD_(l_ulong)]; - l_ulong flags; char flags_[PAD_(l_ulong)]; - l_ulong fd; char fd_[PAD_(l_ulong)]; - l_ulong pgoff; char pgoff_[PAD_(l_ulong)]; -}; -struct linux_truncate64_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - char * path; char path_[PAD_(char *)]; - l_loff_t length; char length_[PAD_(l_loff_t)]; -}; -struct linux_ftruncate64_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_uint fd; char fd_[PAD_(l_uint)]; - l_loff_t length; char length_[PAD_(l_loff_t)]; -}; -struct linux_stat64_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - char * filename; char filename_[PAD_(char *)]; - struct l_stat64 * statbuf; char statbuf_[PAD_(struct l_stat64 *)]; - l_long flags; char flags_[PAD_(l_long)]; -}; -struct linux_lstat64_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - char * filename; char filename_[PAD_(char *)]; - struct l_stat64 * statbuf; char statbuf_[PAD_(struct l_stat64 *)]; - l_long flags; char flags_[PAD_(l_long)]; -}; -struct linux_fstat64_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_ulong fd; char fd_[PAD_(l_ulong)]; - struct l_stat64 * statbuf; char statbuf_[PAD_(struct l_stat64 *)]; - l_long flags; char flags_[PAD_(l_long)]; -}; -struct linux_lchown_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - char * path; char path_[PAD_(char *)]; - l_uid_t uid; char uid_[PAD_(l_uid_t)]; - l_gid_t gid; char gid_[PAD_(l_gid_t)]; -}; -struct linux_getuid_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_getgid_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_getgroups_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_int gidsetsize; char gidsetsize_[PAD_(l_int)]; - l_gid_t * grouplist; char grouplist_[PAD_(l_gid_t *)]; -}; -struct linux_setgroups_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_int gidsetsize; char gidsetsize_[PAD_(l_int)]; - l_gid_t * grouplist; char grouplist_[PAD_(l_gid_t *)]; -}; -struct linux_chown_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - char * path; char path_[PAD_(char *)]; - l_uid_t uid; char uid_[PAD_(l_uid_t)]; - l_gid_t gid; char gid_[PAD_(l_gid_t)]; -}; -struct linux_setfsuid_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_uid_t uid; char uid_[PAD_(l_uid_t)]; -}; -struct linux_setfsgid_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_gid_t gid; char gid_[PAD_(l_gid_t)]; -}; -struct linux_pivot_root_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - char * new_root; char new_root_[PAD_(char *)]; - char * put_old; char put_old_[PAD_(char *)]; -}; -struct linux_mincore_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_ulong start; char start_[PAD_(l_ulong)]; - l_size_t len; char len_[PAD_(l_size_t)]; - u_char * vec; char vec_[PAD_(u_char *)]; -}; -struct linux_madvise_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_getdents64_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_uint fd; char fd_[PAD_(l_uint)]; - void * dirent; char dirent_[PAD_(void *)]; - l_uint count; char count_[PAD_(l_uint)]; -}; -struct linux_fcntl64_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_uint fd; char fd_[PAD_(l_uint)]; - l_uint cmd; char cmd_[PAD_(l_uint)]; - l_ulong arg; char arg_[PAD_(l_ulong)]; -}; -struct linux_gettid_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_setxattr_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_lsetxattr_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_fsetxattr_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_getxattr_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_lgetxattr_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_fgetxattr_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_listxattr_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_llistxattr_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_flistxattr_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_removexattr_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_lremovexattr_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_fremovexattr_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_tkill_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - int tid; char tid_[PAD_(int)]; - int sig; char sig_[PAD_(int)]; -}; -struct linux_sys_futex_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - void * uaddr; char uaddr_[PAD_(void *)]; - int op; char op_[PAD_(int)]; - int val; char val_[PAD_(int)]; - struct l_timespec * timeout; char timeout_[PAD_(struct l_timespec *)]; - void * uaddr2; char uaddr2_[PAD_(void *)]; - int val3; char val3_[PAD_(int)]; -}; -struct linux_sched_setaffinity_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_pid_t pid; char pid_[PAD_(l_pid_t)]; - l_uint len; char len_[PAD_(l_uint)]; - l_ulong * user_mask_ptr; char user_mask_ptr_[PAD_(l_ulong *)]; -}; -struct linux_sched_getaffinity_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_pid_t pid; char pid_[PAD_(l_pid_t)]; - l_uint len; char len_[PAD_(l_uint)]; - l_ulong * user_mask_ptr; char user_mask_ptr_[PAD_(l_ulong *)]; -}; -struct linux_set_thread_area_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - struct l_user_desc * desc; char desc_[PAD_(struct l_user_desc *)]; -}; -struct linux_get_thread_area_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - struct l_user_desc * desc; char desc_[PAD_(struct l_user_desc *)]; -}; -struct linux_fadvise64_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_exit_group_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - int rval; char rval_[PAD_(int)]; -}; -struct linux_epoll_create_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_int size; char size_[PAD_(l_int)]; -}; -struct linux_epoll_ctl_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_int epfd; char epfd_[PAD_(l_int)]; - l_int op; char op_[PAD_(l_int)]; - l_int fd; char fd_[PAD_(l_int)]; - struct linux_epoll_event * event; char event_[PAD_(struct linux_epoll_event *)]; -}; -struct linux_epoll_wait_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_int epfd; char epfd_[PAD_(l_int)]; - struct linux_epoll_event * events; char events_[PAD_(struct linux_epoll_event *)]; - l_int maxevents; char maxevents_[PAD_(l_int)]; - l_int timeout; char timeout_[PAD_(l_int)]; -}; -struct linux_set_tid_address_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - int * tidptr; char tidptr_[PAD_(int *)]; -}; -struct linux_clock_settime_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - clockid_t which; char which_[PAD_(clockid_t)]; - struct l_timespec * tp; char tp_[PAD_(struct l_timespec *)]; -}; -struct linux_clock_gettime_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - clockid_t which; char which_[PAD_(clockid_t)]; - struct l_timespec * tp; char tp_[PAD_(struct l_timespec *)]; -}; -struct linux_clock_getres_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - clockid_t which; char which_[PAD_(clockid_t)]; - struct l_timespec * tp; char tp_[PAD_(struct l_timespec *)]; -}; -struct linux_clock_nanosleep_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - clockid_t which; char which_[PAD_(clockid_t)]; - int flags; char flags_[PAD_(int)]; - struct l_timespec * rqtp; char rqtp_[PAD_(struct l_timespec *)]; - struct l_timespec * rmtp; char rmtp_[PAD_(struct l_timespec *)]; -}; -struct linux_statfs64_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_fstatfs64_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_tgkill_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - int tgid; char tgid_[PAD_(int)]; - int pid; char pid_[PAD_(int)]; - int sig; char sig_[PAD_(int)]; -}; -struct linux_utimes_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - char * fname; char fname_[PAD_(char *)]; - struct l_timeval * tptr; char tptr_[PAD_(struct l_timeval *)]; -}; -struct linux_fadvise64_64_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_mbind_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_get_mempolicy_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_set_mempolicy_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_mq_open_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - const char * name; char name_[PAD_(const char *)]; - int oflag; char oflag_[PAD_(int)]; - mode_t mode; char mode_[PAD_(mode_t)]; - struct mq_attr * attr; char attr_[PAD_(struct mq_attr *)]; -}; -struct linux_mq_getsetattr_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_mqd_t mqd; char mqd_[PAD_(l_mqd_t)]; - const struct mq_attr * attr; char attr_[PAD_(const struct mq_attr *)]; - struct mq_attr * oattr; char oattr_[PAD_(struct mq_attr *)]; -}; -struct linux_kexec_load_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_waitid_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_add_key_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_request_key_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_keyctl_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_ioprio_set_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_ioprio_get_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_inotify_init_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_inotify_add_watch_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_inotify_rm_watch_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_migrate_pages_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_openat_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_int dfd; char dfd_[PAD_(l_int)]; - char * path; char path_[PAD_(char *)]; - l_int flags; char flags_[PAD_(l_int)]; - l_int mode; char mode_[PAD_(l_int)]; -}; -struct linux_mkdirat_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_int dfd; char dfd_[PAD_(l_int)]; - char * path; char path_[PAD_(char *)]; - l_int mode; char mode_[PAD_(l_int)]; -}; -struct linux_mknodat_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_int dfd; char dfd_[PAD_(l_int)]; - char * path; char path_[PAD_(char *)]; - l_int mode; char mode_[PAD_(l_int)]; - l_uint dev; char dev_[PAD_(l_uint)]; -}; -struct linux_fchownat_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_int dfd; char dfd_[PAD_(l_int)]; - char * filename; char filename_[PAD_(char *)]; - l_uid16_t uid; char uid_[PAD_(l_uid16_t)]; - l_gid16_t gid; char gid_[PAD_(l_gid16_t)]; - l_int flag; char flag_[PAD_(l_int)]; -}; -struct linux_futimesat_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_int dfd; char dfd_[PAD_(l_int)]; - char * fname; char fname_[PAD_(char *)]; - struct l_timeval * tptr; char tptr_[PAD_(struct l_timeval *)]; -}; -struct linux_fstatat64_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_int dfd; char dfd_[PAD_(l_int)]; - char * path; char path_[PAD_(char *)]; - struct l_stat64 * statbuf; char statbuf_[PAD_(struct l_stat64 *)]; - l_int flag; char flag_[PAD_(l_int)]; -}; -struct linux_unlinkat_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_int dfd; char dfd_[PAD_(l_int)]; - char * path; char path_[PAD_(char *)]; - l_int flag; char flag_[PAD_(l_int)]; -}; -struct linux_renameat_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_int olddfd; char olddfd_[PAD_(l_int)]; - char * from; char from_[PAD_(char *)]; - l_int newdfd; char newdfd_[PAD_(l_int)]; - char * to; char to_[PAD_(char *)]; -}; -struct linux_linkat_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_int olddfd; char olddfd_[PAD_(l_int)]; - char * path; char path_[PAD_(char *)]; - l_int newdfd; char newdfd_[PAD_(l_int)]; - char * to; char to_[PAD_(char *)]; - l_int flags; char flags_[PAD_(l_int)]; -}; -struct linux_symlinkat_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - char * path; char path_[PAD_(char *)]; - l_int newdfd; char newdfd_[PAD_(l_int)]; - char * to; char to_[PAD_(char *)]; -}; -struct linux_readlinkat_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_int dfd; char dfd_[PAD_(l_int)]; - char * path; char path_[PAD_(char *)]; - char * buf; char buf_[PAD_(char *)]; - l_int count; char count_[PAD_(l_int)]; -}; -struct linux_fchmodat_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_int dfd; char dfd_[PAD_(l_int)]; - char * filename; char filename_[PAD_(char *)]; - l_mode_t mode; char mode_[PAD_(l_mode_t)]; -}; -struct linux_faccessat_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_int dfd; char dfd_[PAD_(l_int)]; - char * filename; char filename_[PAD_(char *)]; - l_int mode; char mode_[PAD_(l_int)]; -}; -struct linux_pselect6_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_ppoll_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_unshare_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_set_robust_list_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - struct linux_robust_list_head * head; char head_[PAD_(struct linux_robust_list_head *)]; - l_size_t len; char len_[PAD_(l_size_t)]; -}; -struct linux_get_robust_list_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_int pid; char pid_[PAD_(l_int)]; - struct linux_robust_list_head ** head; char head_[PAD_(struct linux_robust_list_head **)]; - l_size_t * len; char len_[PAD_(l_size_t *)]; -}; -struct linux_splice_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_sync_file_range_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_tee_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_vmsplice_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_move_pages_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_getcpu_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_uint * pcpu; char pcpu_[PAD_(l_uint *)]; - l_uint * pnode; char pnode_[PAD_(l_uint *)]; - void * ptcache; char ptcache_[PAD_(void *)]; -}; -struct linux_epoll_pwait_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_utimensat_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_int dfd; char dfd_[PAD_(l_int)]; - char * fname; char fname_[PAD_(char *)]; - struct l_timespec * tptr; char tptr_[PAD_(struct l_timespec *)]; - l_int flag; char flag_[PAD_(l_int)]; -}; -struct linux_signalfd_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_timerfd_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_eventfd_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - register_t dummy; -}; -struct linux_pipe2_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - l_ulong * pipefds; char pipefds_[PAD_(l_ulong *)]; - l_int flags; char flags_[PAD_(l_int)]; -}; - -#ifdef COMPAT_43 - -#define nosys linux_nosys - -#ifdef _KERNEL - - -#endif /* _KERNEL */ - -#endif /* COMPAT_43 */ - - -#ifdef COMPAT_DF12 - -#define nosys linux_nosys - -#ifdef _KERNEL - - -#endif /* _KERNEL */ - -#endif /* COMPAT_DF12 */ - - -#ifdef _KERNEL - -#define nosys linux_nosys -int sys_linux_fork (struct linux_fork_args *); -int sys_linux_open (struct linux_open_args *); -int sys_linux_waitpid (struct linux_waitpid_args *); -int sys_linux_creat (struct linux_creat_args *); -int sys_linux_link (struct linux_link_args *); -int sys_linux_unlink (struct linux_unlink_args *); -int sys_linux_execve (struct linux_execve_args *); -int sys_linux_chdir (struct linux_chdir_args *); -int sys_linux_time (struct linux_time_args *); -int sys_linux_mknod (struct linux_mknod_args *); -int sys_linux_chmod (struct linux_chmod_args *); -int sys_linux_lchown16 (struct linux_lchown16_args *); -int sys_linux_stat (struct linux_stat_args *); -int sys_linux_lseek (struct linux_lseek_args *); -int sys_linux_getpid (struct linux_getpid_args *); -int sys_linux_mount (struct linux_mount_args *); -int sys_linux_oldumount (struct linux_oldumount_args *); -int sys_linux_setuid16 (struct linux_setuid16_args *); -int sys_linux_getuid16 (struct linux_getuid16_args *); -int sys_linux_stime (struct linux_stime_args *); -int sys_linux_ptrace (struct linux_ptrace_args *); -int sys_linux_alarm (struct linux_alarm_args *); -int sys_linux_fstat (struct linux_fstat_args *); -int sys_linux_pause (struct linux_pause_args *); -int sys_linux_utime (struct linux_utime_args *); -int sys_linux_access (struct linux_access_args *); -int sys_linux_nice (struct linux_nice_args *); -int sys_linux_kill (struct linux_kill_args *); -int sys_linux_rename (struct linux_rename_args *); -int sys_linux_mkdir (struct linux_mkdir_args *); -int sys_linux_rmdir (struct linux_rmdir_args *); -int sys_linux_pipe (struct linux_pipe_args *); -int sys_linux_times (struct linux_times_args *); -int sys_linux_brk (struct linux_brk_args *); -int sys_linux_setgid16 (struct linux_setgid16_args *); -int sys_linux_getgid16 (struct linux_getgid16_args *); -int sys_linux_signal (struct linux_signal_args *); -int sys_linux_geteuid16 (struct linux_geteuid16_args *); -int sys_linux_getegid16 (struct linux_getegid16_args *); -int sys_linux_umount (struct linux_umount_args *); -int sys_linux_ioctl (struct linux_ioctl_args *); -int sys_linux_fcntl (struct linux_fcntl_args *); -int sys_linux_olduname (struct linux_olduname_args *); -int sys_linux_ustat (struct linux_ustat_args *); -int sys_linux_getppid (struct linux_getppid_args *); -int sys_linux_sigaction (struct linux_sigaction_args *); -int sys_linux_sgetmask (struct linux_sgetmask_args *); -int sys_linux_ssetmask (struct linux_ssetmask_args *); -int sys_linux_setreuid16 (struct linux_setreuid16_args *); -int sys_linux_setregid16 (struct linux_setregid16_args *); -int sys_linux_sigsuspend (struct linux_sigsuspend_args *); -int sys_linux_sigpending (struct linux_sigpending_args *); -int sys_linux_sethostname (struct linux_sethostname_args *); -int sys_linux_setrlimit (struct linux_setrlimit_args *); -int sys_linux_old_getrlimit (struct linux_old_getrlimit_args *); -int sys_linux_getgroups16 (struct linux_getgroups16_args *); -int sys_linux_setgroups16 (struct linux_setgroups16_args *); -int sys_linux_old_select (struct linux_old_select_args *); -int sys_linux_symlink (struct linux_symlink_args *); -int sys_linux_ostat (struct linux_ostat_args *); -int sys_linux_readlink (struct linux_readlink_args *); -int sys_linux_uselib (struct linux_uselib_args *); -int sys_linux_reboot (struct linux_reboot_args *); -int sys_linux_readdir (struct linux_readdir_args *); -int sys_linux_mmap (struct linux_mmap_args *); -int sys_linux_truncate (struct linux_truncate_args *); -int sys_linux_ftruncate (struct linux_ftruncate_args *); -int sys_linux_statfs (struct linux_statfs_args *); -int sys_linux_fstatfs (struct linux_fstatfs_args *); -int sys_linux_ioperm (struct linux_ioperm_args *); -int sys_linux_socketcall (struct linux_socketcall_args *); -int sys_linux_syslog (struct linux_syslog_args *); -int sys_linux_setitimer (struct linux_setitimer_args *); -int sys_linux_getitimer (struct linux_getitimer_args *); -int sys_linux_newstat (struct linux_newstat_args *); -int sys_linux_newlstat (struct linux_newlstat_args *); -int sys_linux_newfstat (struct linux_newfstat_args *); -int sys_linux_uname (struct linux_uname_args *); -int sys_linux_iopl (struct linux_iopl_args *); -int sys_linux_vhangup (struct linux_vhangup_args *); -int sys_linux_vm86old (struct linux_vm86old_args *); -int sys_linux_wait4 (struct linux_wait4_args *); -int sys_linux_swapoff (struct linux_swapoff_args *); -int sys_linux_sysinfo (struct linux_sysinfo_args *); -int sys_linux_ipc (struct linux_ipc_args *); -int sys_linux_sigreturn (struct linux_sigreturn_args *); -int sys_linux_clone (struct linux_clone_args *); -int sys_linux_newuname (struct linux_newuname_args *); -int sys_linux_modify_ldt (struct linux_modify_ldt_args *); -int sys_linux_adjtimex (struct linux_adjtimex_args *); -int sys_linux_sigprocmask (struct linux_sigprocmask_args *); -int sys_linux_create_module (struct linux_create_module_args *); -int sys_linux_init_module (struct linux_init_module_args *); -int sys_linux_delete_module (struct linux_delete_module_args *); -int sys_linux_get_kernel_syms (struct linux_get_kernel_syms_args *); -int sys_linux_quotactl (struct linux_quotactl_args *); -int sys_linux_bdflush (struct linux_bdflush_args *); -int sys_linux_sysfs (struct linux_sysfs_args *); -int sys_linux_personality (struct linux_personality_args *); -int sys_linux_setfsuid16 (struct linux_setfsuid16_args *); -int sys_linux_setfsgid16 (struct linux_setfsgid16_args *); -int sys_linux_llseek (struct linux_llseek_args *); -int sys_linux_getdents (struct linux_getdents_args *); -int sys_linux_select (struct linux_select_args *); -int sys_linux_msync (struct linux_msync_args *); -int sys_linux_getsid (struct linux_getsid_args *); -int sys_linux_fdatasync (struct linux_fdatasync_args *); -int sys_linux_sysctl (struct linux_sysctl_args *); -int sys_linux_sched_setscheduler (struct linux_sched_setscheduler_args *); -int sys_linux_sched_getscheduler (struct linux_sched_getscheduler_args *); -int sys_linux_sched_get_priority_max (struct linux_sched_get_priority_max_args *); -int sys_linux_sched_get_priority_min (struct linux_sched_get_priority_min_args *); -int sys_linux_mremap (struct linux_mremap_args *); -int sys_linux_setresuid16 (struct linux_setresuid16_args *); -int sys_linux_getresuid16 (struct linux_getresuid16_args *); -int sys_linux_vm86 (struct linux_vm86_args *); -int sys_linux_query_module (struct linux_query_module_args *); -int sys_linux_nfsservctl (struct linux_nfsservctl_args *); -int sys_linux_setresgid16 (struct linux_setresgid16_args *); -int sys_linux_getresgid16 (struct linux_getresgid16_args *); -int sys_linux_prctl (struct linux_prctl_args *); -int sys_linux_rt_sigreturn (struct linux_rt_sigreturn_args *); -int sys_linux_rt_sigaction (struct linux_rt_sigaction_args *); -int sys_linux_rt_sigprocmask (struct linux_rt_sigprocmask_args *); -int sys_linux_rt_sigpending (struct linux_rt_sigpending_args *); -int sys_linux_rt_sigtimedwait (struct linux_rt_sigtimedwait_args *); -int sys_linux_rt_sigqueueinfo (struct linux_rt_sigqueueinfo_args *); -int sys_linux_rt_sigsuspend (struct linux_rt_sigsuspend_args *); -int sys_linux_pread (struct linux_pread_args *); -int sys_linux_pwrite (struct linux_pwrite_args *); -int sys_linux_chown16 (struct linux_chown16_args *); -int sys_linux_getcwd (struct linux_getcwd_args *); -int sys_linux_capget (struct linux_capget_args *); -int sys_linux_capset (struct linux_capset_args *); -int sys_linux_sigaltstack (struct linux_sigaltstack_args *); -int sys_linux_sendfile (struct linux_sendfile_args *); -int sys_linux_vfork (struct linux_vfork_args *); -int sys_linux_getrlimit (struct linux_getrlimit_args *); -int sys_linux_mmap2 (struct linux_mmap2_args *); -int sys_linux_truncate64 (struct linux_truncate64_args *); -int sys_linux_ftruncate64 (struct linux_ftruncate64_args *); -int sys_linux_stat64 (struct linux_stat64_args *); -int sys_linux_lstat64 (struct linux_lstat64_args *); -int sys_linux_fstat64 (struct linux_fstat64_args *); -int sys_linux_lchown (struct linux_lchown_args *); -int sys_linux_getuid (struct linux_getuid_args *); -int sys_linux_getgid (struct linux_getgid_args *); -int sys_linux_getgroups (struct linux_getgroups_args *); -int sys_linux_setgroups (struct linux_setgroups_args *); -int sys_linux_chown (struct linux_chown_args *); -int sys_linux_setfsuid (struct linux_setfsuid_args *); -int sys_linux_setfsgid (struct linux_setfsgid_args *); -int sys_linux_pivot_root (struct linux_pivot_root_args *); -int sys_linux_mincore (struct linux_mincore_args *); -int sys_linux_madvise (struct linux_madvise_args *); -int sys_linux_getdents64 (struct linux_getdents64_args *); -int sys_linux_fcntl64 (struct linux_fcntl64_args *); -int sys_linux_gettid (struct linux_gettid_args *); -int sys_linux_setxattr (struct linux_setxattr_args *); -int sys_linux_lsetxattr (struct linux_lsetxattr_args *); -int sys_linux_fsetxattr (struct linux_fsetxattr_args *); -int sys_linux_getxattr (struct linux_getxattr_args *); -int sys_linux_lgetxattr (struct linux_lgetxattr_args *); -int sys_linux_fgetxattr (struct linux_fgetxattr_args *); -int sys_linux_listxattr (struct linux_listxattr_args *); -int sys_linux_llistxattr (struct linux_llistxattr_args *); -int sys_linux_flistxattr (struct linux_flistxattr_args *); -int sys_linux_removexattr (struct linux_removexattr_args *); -int sys_linux_lremovexattr (struct linux_lremovexattr_args *); -int sys_linux_fremovexattr (struct linux_fremovexattr_args *); -int sys_linux_tkill (struct linux_tkill_args *); -int sys_linux_sys_futex (struct linux_sys_futex_args *); -int sys_linux_sched_setaffinity (struct linux_sched_setaffinity_args *); -int sys_linux_sched_getaffinity (struct linux_sched_getaffinity_args *); -int sys_linux_set_thread_area (struct linux_set_thread_area_args *); -int sys_linux_get_thread_area (struct linux_get_thread_area_args *); -int sys_linux_fadvise64 (struct linux_fadvise64_args *); -int sys_linux_exit_group (struct linux_exit_group_args *); -int sys_linux_epoll_create (struct linux_epoll_create_args *); -int sys_linux_epoll_ctl (struct linux_epoll_ctl_args *); -int sys_linux_epoll_wait (struct linux_epoll_wait_args *); -int sys_linux_set_tid_address (struct linux_set_tid_address_args *); -int sys_linux_clock_settime (struct linux_clock_settime_args *); -int sys_linux_clock_gettime (struct linux_clock_gettime_args *); -int sys_linux_clock_getres (struct linux_clock_getres_args *); -int sys_linux_clock_nanosleep (struct linux_clock_nanosleep_args *); -int sys_linux_statfs64 (struct linux_statfs64_args *); -int sys_linux_fstatfs64 (struct linux_fstatfs64_args *); -int sys_linux_tgkill (struct linux_tgkill_args *); -int sys_linux_utimes (struct linux_utimes_args *); -int sys_linux_fadvise64_64 (struct linux_fadvise64_64_args *); -int sys_linux_mbind (struct linux_mbind_args *); -int sys_linux_get_mempolicy (struct linux_get_mempolicy_args *); -int sys_linux_set_mempolicy (struct linux_set_mempolicy_args *); -int sys_linux_mq_open (struct linux_mq_open_args *); -int sys_linux_mq_getsetattr (struct linux_mq_getsetattr_args *); -int sys_linux_kexec_load (struct linux_kexec_load_args *); -int sys_linux_waitid (struct linux_waitid_args *); -int sys_linux_add_key (struct linux_add_key_args *); -int sys_linux_request_key (struct linux_request_key_args *); -int sys_linux_keyctl (struct linux_keyctl_args *); -int sys_linux_ioprio_set (struct linux_ioprio_set_args *); -int sys_linux_ioprio_get (struct linux_ioprio_get_args *); -int sys_linux_inotify_init (struct linux_inotify_init_args *); -int sys_linux_inotify_add_watch (struct linux_inotify_add_watch_args *); -int sys_linux_inotify_rm_watch (struct linux_inotify_rm_watch_args *); -int sys_linux_migrate_pages (struct linux_migrate_pages_args *); -int sys_linux_openat (struct linux_openat_args *); -int sys_linux_mkdirat (struct linux_mkdirat_args *); -int sys_linux_mknodat (struct linux_mknodat_args *); -int sys_linux_fchownat (struct linux_fchownat_args *); -int sys_linux_futimesat (struct linux_futimesat_args *); -int sys_linux_fstatat64 (struct linux_fstatat64_args *); -int sys_linux_unlinkat (struct linux_unlinkat_args *); -int sys_linux_renameat (struct linux_renameat_args *); -int sys_linux_linkat (struct linux_linkat_args *); -int sys_linux_symlinkat (struct linux_symlinkat_args *); -int sys_linux_readlinkat (struct linux_readlinkat_args *); -int sys_linux_fchmodat (struct linux_fchmodat_args *); -int sys_linux_faccessat (struct linux_faccessat_args *); -int sys_linux_pselect6 (struct linux_pselect6_args *); -int sys_linux_ppoll (struct linux_ppoll_args *); -int sys_linux_unshare (struct linux_unshare_args *); -int sys_linux_set_robust_list (struct linux_set_robust_list_args *); -int sys_linux_get_robust_list (struct linux_get_robust_list_args *); -int sys_linux_splice (struct linux_splice_args *); -int sys_linux_sync_file_range (struct linux_sync_file_range_args *); -int sys_linux_tee (struct linux_tee_args *); -int sys_linux_vmsplice (struct linux_vmsplice_args *); -int sys_linux_move_pages (struct linux_move_pages_args *); -int sys_linux_getcpu (struct linux_getcpu_args *); -int sys_linux_epoll_pwait (struct linux_epoll_pwait_args *); -int sys_linux_utimensat (struct linux_utimensat_args *); -int sys_linux_signalfd (struct linux_signalfd_args *); -int sys_linux_timerfd (struct linux_timerfd_args *); -int sys_linux_eventfd (struct linux_eventfd_args *); -int sys_linux_pipe2 (struct linux_pipe2_args *); - -#endif /* !_LINUX_SYSPROTO_H_ */ -#undef PAD_ - -#endif /* _KERNEL */ diff --git a/sys/emulation/linux/i386/linux_ptrace.c b/sys/emulation/linux/i386/linux_ptrace.c deleted file mode 100644 index 71d70f2531..0000000000 --- a/sys/emulation/linux/i386/linux_ptrace.c +++ /dev/null @@ -1,508 +0,0 @@ -/* - * Copyright (c) 2001 Alexander Kabaev - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer - * in this position and unchanged. - * 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 - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD: src/sys/i386/linux/linux_ptrace.c,v 1.7.4.3 2003/01/03 17:13:23 kan Exp $ - * $DragonFly: src/sys/emulation/linux/i386/linux_ptrace.c,v 1.15 2007/02/19 01:14:23 corecode Exp $ - */ - -#include "opt_cpu.h" - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include - -#include "linux.h" -#include "linux_proto.h" - -/* - * Linux ptrace requests numbers. Mostly identical to FreeBSD, - * except for MD ones and PT_ATTACH/PT_DETACH. - */ -#define PTRACE_TRACEME 0 -#define PTRACE_PEEKTEXT 1 -#define PTRACE_PEEKDATA 2 -#define PTRACE_PEEKUSR 3 -#define PTRACE_POKETEXT 4 -#define PTRACE_POKEDATA 5 -#define PTRACE_POKEUSR 6 -#define PTRACE_CONT 7 -#define PTRACE_KILL 8 -#define PTRACE_SINGLESTEP 9 - -#define PTRACE_ATTACH 16 -#define PTRACE_DETACH 17 - -#define PTRACE_SYSCALL 24 - -#define PTRACE_GETREGS 12 -#define PTRACE_SETREGS 13 -#define PTRACE_GETFPREGS 14 -#define PTRACE_SETFPREGS 15 -#define PTRACE_GETFPXREGS 18 -#define PTRACE_SETFPXREGS 19 - -#define PTRACE_SETOPTIONS 21 - -/* - * Linux keeps debug registers at the following - * offset in the user struct - */ -#define LINUX_DBREG_OFFSET 252 -#define LINUX_DBREG_SIZE (8*sizeof(l_int)) - -static __inline__ int -map_signum(int signum) -{ - - if (signum > 0 && signum <= LINUX_SIGTBLSZ) - signum = linux_to_bsd_signal[_SIG_IDX(signum)]; - return ((signum == SIGSTOP)? 0 : signum); -} - -struct linux_pt_reg { - l_long ebx; - l_long ecx; - l_long edx; - l_long esi; - l_long edi; - l_long ebp; - l_long eax; - l_int xds; - l_int xes; - l_int xfs; - l_int xgs; - l_long orig_eax; - l_long eip; - l_int xcs; - l_long eflags; - l_long esp; - l_int xss; -}; - -/* - * Translate i386 ptrace registers between Linux and FreeBSD formats. - * The translation is pretty straighforward, for all registers, but - * orig_eax on Linux side and r_trapno and r_err in FreeBSD - */ -static void -map_regs_to_linux(struct reg *bsd_r, struct linux_pt_reg *linux_r) -{ - linux_r->ebx = bsd_r->r_ebx; - linux_r->ecx = bsd_r->r_ecx; - linux_r->edx = bsd_r->r_edx; - linux_r->esi = bsd_r->r_esi; - linux_r->edi = bsd_r->r_edi; - linux_r->ebp = bsd_r->r_ebp; - linux_r->eax = bsd_r->r_eax; - linux_r->xds = bsd_r->r_ds; - linux_r->xes = bsd_r->r_es; - linux_r->xfs = bsd_r->r_fs; - linux_r->xgs = bsd_r->r_gs; - linux_r->orig_eax = bsd_r->r_eax; - linux_r->eip = bsd_r->r_eip; - linux_r->xcs = bsd_r->r_cs; - linux_r->eflags = bsd_r->r_eflags; - linux_r->esp = bsd_r->r_esp; - linux_r->xss = bsd_r->r_ss; -} - -static void -map_regs_from_linux(struct reg *bsd_r, struct linux_pt_reg *linux_r) -{ - bsd_r->r_ebx = linux_r->ebx; - bsd_r->r_ecx = linux_r->ecx; - bsd_r->r_edx = linux_r->edx; - bsd_r->r_esi = linux_r->esi; - bsd_r->r_edi = linux_r->edi; - bsd_r->r_ebp = linux_r->ebp; - bsd_r->r_eax = linux_r->eax; - bsd_r->r_ds = linux_r->xds; - bsd_r->r_es = linux_r->xes; - bsd_r->r_fs = linux_r->xfs; - bsd_r->r_gs = linux_r->xgs; - bsd_r->r_eip = linux_r->eip; - bsd_r->r_cs = linux_r->xcs; - bsd_r->r_eflags = linux_r->eflags; - bsd_r->r_esp = linux_r->esp; - bsd_r->r_ss = linux_r->xss; -} - -struct linux_pt_fpreg { - l_long cwd; - l_long swd; - l_long twd; - l_long fip; - l_long fcs; - l_long foo; - l_long fos; - l_long st_space[2*10]; -}; - -static void -map_fpregs_to_linux(struct fpreg *bsd_r, struct linux_pt_fpreg *linux_r) -{ - linux_r->cwd = bsd_r->fpr_env[0]; - linux_r->swd = bsd_r->fpr_env[1]; - linux_r->twd = bsd_r->fpr_env[2]; - linux_r->fip = bsd_r->fpr_env[3]; - linux_r->fcs = bsd_r->fpr_env[4]; - linux_r->foo = bsd_r->fpr_env[5]; - linux_r->fos = bsd_r->fpr_env[6]; - bcopy(bsd_r->fpr_acc, linux_r->st_space, sizeof(linux_r->st_space)); -} - -static void -map_fpregs_from_linux(struct fpreg *bsd_r, struct linux_pt_fpreg *linux_r) -{ - bsd_r->fpr_env[0] = linux_r->cwd; - bsd_r->fpr_env[1] = linux_r->swd; - bsd_r->fpr_env[2] = linux_r->twd; - bsd_r->fpr_env[3] = linux_r->fip; - bsd_r->fpr_env[4] = linux_r->fcs; - bsd_r->fpr_env[5] = linux_r->foo; - bsd_r->fpr_env[6] = linux_r->fos; - bcopy(bsd_r->fpr_acc, linux_r->st_space, sizeof(bsd_r->fpr_acc)); -} - -struct linux_pt_fpxreg { - l_ushort cwd; - l_ushort swd; - l_ushort twd; - l_ushort fop; - l_long fip; - l_long fcs; - l_long foo; - l_long fos; - l_long mxcsr; - l_long reserved; - l_long st_space[32]; - l_long xmm_space[32]; - l_long padding[56]; -}; - -#ifndef CPU_DISABLE_SSE -static int -linux_proc_read_fpxregs(struct lwp *lp, struct linux_pt_fpxreg *fpxregs) -{ - int error; - - error = 0; - if (cpu_fxsr == 0) - error = EIO; - else - bcopy(&lp->lwp_thread->td_pcb->pcb_save.sv_xmm, - fpxregs, sizeof(*fpxregs)); - return (error); -} - -static int -linux_proc_write_fpxregs(struct lwp *lp, struct linux_pt_fpxreg *fpxregs) -{ - int error; - - error = 0; - if (cpu_fxsr == 0) - error = EIO; - else - bcopy(fpxregs, &lp->lwp_thread->td_pcb->pcb_save.sv_xmm, - sizeof(*fpxregs)); - return (error); -} -#endif - -/* - * MPALMOSTSAFE - */ -int -sys_linux_ptrace(struct linux_ptrace_args *uap) -{ - struct thread *td = curthread; - struct proc *curp = td->td_proc; - union { - struct linux_pt_reg reg; - struct linux_pt_fpreg fpreg; - struct linux_pt_fpxreg fpxreg; - } r; - union { - struct reg bsd_reg; - struct fpreg bsd_fpreg; - struct dbreg bsd_dbreg; - } u; - void *addr; - pid_t pid; - int error, req; - struct proc *p = NULL; /* held process */ - - error = 0; - - /* by default, just copy data intact */ - req = uap->req; - pid = (pid_t)uap->pid; - addr = (void *)uap->addr; - - switch (req) { - case PTRACE_TRACEME: - case PTRACE_POKETEXT: - case PTRACE_POKEDATA: - case PTRACE_KILL: - error = kern_ptrace(curp, req, pid, addr, uap->data, - &uap->sysmsg_iresult); - break; - case PTRACE_PEEKTEXT: - case PTRACE_PEEKDATA: { - /* need to preserve return value, use dummy */ - l_int rval = 0; - error = kern_ptrace(curp, req, pid, addr, 0, &rval); - if (error == 0) { - error = copyout(&rval, (caddr_t)uap->data, sizeof(l_int)); - } - break; - } - case PTRACE_DETACH: - error = kern_ptrace(curp, PT_DETACH, pid, (void *)1, - map_signum(uap->data), - &uap->sysmsg_iresult); - break; - case PTRACE_SINGLESTEP: - case PTRACE_CONT: - error = kern_ptrace(curp, req, pid, (void *)1, - map_signum(uap->data), - &uap->sysmsg_iresult); - break; - case PTRACE_ATTACH: - error = kern_ptrace(curp, PT_ATTACH, pid, addr, uap->data, - &uap->sysmsg_iresult); - break; - case PTRACE_GETREGS: - /* Linux is using data where FreeBSD is using addr */ - error = kern_ptrace(curp, PT_GETREGS, pid, &u.bsd_reg, 0, - &uap->sysmsg_iresult); - if (error == 0) { - map_regs_to_linux(&u.bsd_reg, &r.reg); - error = copyout(&r.reg, (void *)uap->data, - sizeof(r.reg)); - } - break; - case PTRACE_SETREGS: - /* Linux is using data where FreeBSD is using addr */ - error = copyin((caddr_t)uap->data, &r.reg, sizeof(r.reg)); - if (error == 0) { - map_regs_from_linux(&u.bsd_reg, &r.reg); - error = kern_ptrace(curp, PT_SETREGS, pid, &u.bsd_reg, - 0, &uap->sysmsg_iresult); - } - break; - case PTRACE_GETFPREGS: - /* Linux is using data where FreeBSD is using addr */ - error = kern_ptrace(curp, PT_GETFPREGS, pid, &u.bsd_fpreg, - 0, &uap->sysmsg_iresult); - if (error == 0) { - map_fpregs_to_linux(&u.bsd_fpreg, &r.fpreg); - error = copyout(&r.fpreg, (caddr_t)uap->data, - sizeof(r.fpreg)); - } - break; - case PTRACE_SETFPREGS: - /* Linux is using data where FreeBSD is using addr */ - error = copyin((caddr_t)uap->data, &r.fpreg, sizeof(r.fpreg)); - if (error == 0) { - map_fpregs_from_linux(&u.bsd_fpreg, &r.fpreg); - error = kern_ptrace(curp, PT_SETFPREGS, pid, - &u.bsd_fpreg, - 0, &uap->sysmsg_iresult); - } - break; - case PTRACE_SETFPXREGS: -#ifndef CPU_DISABLE_SSE - error = copyin((caddr_t)uap->data, &r.fpxreg, - sizeof(r.fpxreg)); - if (error) - break; -#endif - /* FALL THROUGH */ - case PTRACE_GETFPXREGS: { -#ifndef CPU_DISABLE_SSE - struct proc *p; - struct lwp *lp; - - if (sizeof(struct linux_pt_fpxreg) != sizeof(struct savexmm)) { - static int once = 0; - if (!once) { - kprintf("linux: savexmm != linux_pt_fpxreg\n"); - once = 1; - } - error = EIO; - break; - } - - if ((p = pfind(uap->pid)) == NULL) { - error = ESRCH; - break; - } - - if (!PRISON_CHECK(curp->p_ucred, p->p_ucred)) { - error = ESRCH; - goto fail; - } - - /* System processes can't be debugged. */ - if ((p->p_flags & P_SYSTEM) != 0) { - error = EINVAL; - goto fail; - } - - /* not being traced... */ - if ((p->p_flags & P_TRACED) == 0) { - error = EPERM; - goto fail; - } - - /* not being traced by YOU */ - if (p->p_pptr != curp) { - error = EBUSY; - goto fail; - } - - /* not currently stopped */ - if ((p->p_flags & (P_TRACED|P_WAITED)) == 0) { - error = EBUSY; - goto fail; - } - - /* XXX lwp */ - lp = FIRST_LWP_IN_PROC(p); - - if (req == PTRACE_GETFPXREGS) { - LWPHOLD(lp); - error = linux_proc_read_fpxregs(lp, &r.fpxreg); - LWPRELE(lp); - if (error == 0) - error = copyout(&r.fpxreg, (caddr_t)uap->data, - sizeof(r.fpxreg)); - } else { - /* clear dangerous bits exactly as Linux does*/ - r.fpxreg.mxcsr &= 0xffbf; - LWPHOLD(lp); - error = linux_proc_write_fpxregs(lp, &r.fpxreg); - LWPRELE(lp); - } - break; - - fail: -#else - error = EIO; -#endif - break; - } - case PTRACE_PEEKUSR: - case PTRACE_POKEUSR: { - error = EIO; - - /* check addr for alignment */ - if (uap->addr < 0 || uap->addr & (sizeof(l_int) - 1)) - break; - /* - * Allow linux programs to access register values in - * user struct. We simulate this through PT_GET/SETREGS - * as necessary. - */ - if (uap->addr < sizeof(struct linux_pt_reg)) { - error = kern_ptrace(curp, PT_GETREGS, pid, &u.bsd_reg, - 0, &uap->sysmsg_iresult); - if (error != 0) - break; - - map_regs_to_linux(&u.bsd_reg, &r.reg); - if (req == PTRACE_PEEKUSR) { - error = copyout((char *)&r.reg + uap->addr, - (caddr_t)uap->data, sizeof(l_int)); - break; - } - - *(l_int *)((char *)&r.reg + uap->addr) = - (l_int)uap->data; - - map_regs_from_linux(&u.bsd_reg, &r.reg); - error = kern_ptrace(curp, PT_SETREGS, pid, &u.bsd_reg, - 0, &uap->sysmsg_iresult); - } - - /* - * Simulate debug registers access - */ - if (uap->addr >= LINUX_DBREG_OFFSET && - uap->addr <= LINUX_DBREG_OFFSET + LINUX_DBREG_SIZE) { - error = kern_ptrace(curp, PT_GETDBREGS, pid, - &u.bsd_dbreg, - 0, &uap->sysmsg_iresult); - if (error != 0) - break; - - uap->addr -= LINUX_DBREG_OFFSET; - if (req == PTRACE_PEEKUSR) { - error = copyout((char *)&u.bsd_dbreg + - uap->addr, (caddr_t)uap->data, - sizeof(l_int)); - break; - } - - *(l_int *)((char *)&u.bsd_dbreg + uap->addr) = - uap->data; - error = kern_ptrace(curp, PT_SETDBREGS, pid, - &u.bsd_dbreg, - 0, &uap->sysmsg_iresult); - } - - break; - } - case PTRACE_SYSCALL: - /* fall through */ - default: - kprintf("linux: ptrace(%u, ...) not implemented\n", - (unsigned int)uap->req); - error = EINVAL; - break; - } - - /* - * Release held proces (if any) before returning. - */ - if (p) - PRELE(p); - return (error); -} diff --git a/sys/emulation/linux/i386/linux_support.s b/sys/emulation/linux/i386/linux_support.s deleted file mode 100644 index 1424e8510d..0000000000 --- a/sys/emulation/linux/i386/linux_support.s +++ /dev/null @@ -1,148 +0,0 @@ -/*- - * Copyright (c) 2006,2007 Konstantin Belousov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * $FreeBSD$ - */ - -#include "linux_assym.h" /* system definitions */ -#include /* miscellaneous asm macros */ -#include -#include -#include - -#include "assym.s" - -/* - * A stack-based on-fault routine is used for more complex PCB_ONFAULT - * situations (such as memcpy/bcopy/bzero). In this case the on-fault - * routine must be pushed on the stack. - */ -stack_onfault: - ret - -futex_fault_decx: - movl PCPU(curthread),%ecx - movl TD_PCB(%ecx), %ecx -futex_fault: - movl $0,PCB_ONFAULT(%ecx) - movl $EFAULT,%eax - ret - -futex_fault_pop: - addl $4,%esp - movl $0,PCB_ONFAULT(%ecx) - movl $EFAULT,%eax - ret - -ENTRY(futex_xchgl) - movl PCPU(curthread),%ecx - movl TD_PCB(%ecx),%ecx - pushl $futex_fault - movl $stack_onfault, PCB_ONFAULT(%ecx) - movl 8(%esp),%eax - movl 12(%esp),%edx - cmpl $VM_MAX_USER_ADDRESS-4,%edx - ja futex_fault_pop - xchgl %eax,(%edx) - movl 16(%esp),%edx - movl %eax,(%edx) - xorl %eax,%eax - movl %eax,PCB_ONFAULT(%ecx) - ret - -ENTRY(futex_addl) - movl PCPU(curthread),%ecx - movl TD_PCB(%ecx),%ecx - pushl $futex_fault - movl $stack_onfault,PCB_ONFAULT(%ecx) - movl 8(%esp),%eax - movl 12(%esp),%edx - cmpl $VM_MAX_USER_ADDRESS-4,%edx - ja futex_fault_pop - lock - xaddl %eax,(%edx) - movl 16(%esp),%edx - movl %eax,(%edx) - xorl %eax,%eax - movl %eax,PCB_ONFAULT(%ecx) - ret - -ENTRY(futex_orl) - movl PCPU(curthread),%ecx - movl TD_PCB(%ecx),%ecx - pushl $futex_fault_decx - movl $stack_onfault,PCB_ONFAULT(%ecx) - movl 12(%esp),%edx - cmpl $VM_MAX_USER_ADDRESS-4,%edx - ja futex_fault_pop - movl (%edx),%eax -1: movl %eax,%ecx - orl 8(%esp),%ecx - lock - cmpxchgl %ecx,(%edx) - jnz 1b -futex_tail: - movl 16(%esp),%edx - movl %eax,(%edx) - xorl %eax,%eax - movl PCPU(curthread),%ecx - movl TD_PCB(%ecx),%ecx - movl %eax,PCB_ONFAULT(%ecx) - ret - -ENTRY(futex_andl) - movl PCPU(curthread),%ecx - movl TD_PCB(%ecx),%ecx - pushl $futex_fault_decx - movl $stack_onfault,PCB_ONFAULT(%ecx) - movl 12(%esp),%edx - cmpl $VM_MAX_USER_ADDRESS-4,%edx - ja futex_fault_pop - movl (%edx),%eax -1: movl %eax,%ecx - andl 8(%esp),%ecx - lock - cmpxchgl %ecx,(%edx) - jnz 1b - jmp futex_tail - -ENTRY(futex_xorl) - movl PCPU(curthread),%ecx - movl TD_PCB(%ecx),%ecx - pushl $futex_fault_decx - movl $stack_onfault,PCB_ONFAULT(%ecx) - movl 12(%esp),%edx - cmpl $VM_MAX_USER_ADDRESS-4,%edx - ja futex_fault_pop - movl (%edx),%eax -1: movl %eax,%ecx - xorl 8(%esp),%ecx - lock - cmpxchgl %ecx,(%edx) - jnz 1b - jmp futex_tail diff --git a/sys/emulation/linux/i386/linux_syscall.h b/sys/emulation/linux/i386/linux_syscall.h deleted file mode 100644 index de3d81b702..0000000000 --- a/sys/emulation/linux/i386/linux_syscall.h +++ /dev/null @@ -1,299 +0,0 @@ -/* - * System call numbers. - * - * DO NOT EDIT-- To regenerate this file, edit syscalls.master followed - * by running make sysent in the same directory. - */ - -#define LINUX_SYS_exit 1 -#define LINUX_SYS_linux_fork 2 -#define LINUX_SYS_read 3 -#define LINUX_SYS_write 4 -#define LINUX_SYS_linux_open 5 -#define LINUX_SYS_close 6 -#define LINUX_SYS_linux_waitpid 7 -#define LINUX_SYS_linux_creat 8 -#define LINUX_SYS_linux_link 9 -#define LINUX_SYS_linux_unlink 10 -#define LINUX_SYS_linux_execve 11 -#define LINUX_SYS_linux_chdir 12 -#define LINUX_SYS_linux_time 13 -#define LINUX_SYS_linux_mknod 14 -#define LINUX_SYS_linux_chmod 15 -#define LINUX_SYS_linux_lchown16 16 -#define LINUX_SYS_linux_stat 18 -#define LINUX_SYS_linux_lseek 19 -#define LINUX_SYS_linux_getpid 20 -#define LINUX_SYS_linux_mount 21 -#define LINUX_SYS_linux_oldumount 22 -#define LINUX_SYS_linux_setuid16 23 -#define LINUX_SYS_linux_getuid16 24 -#define LINUX_SYS_linux_stime 25 -#define LINUX_SYS_linux_ptrace 26 -#define LINUX_SYS_linux_alarm 27 -#define LINUX_SYS_linux_fstat 28 -#define LINUX_SYS_linux_pause 29 -#define LINUX_SYS_linux_utime 30 -#define LINUX_SYS_linux_access 33 -#define LINUX_SYS_linux_nice 34 -#define LINUX_SYS_sync 36 -#define LINUX_SYS_linux_kill 37 -#define LINUX_SYS_linux_rename 38 -#define LINUX_SYS_linux_mkdir 39 -#define LINUX_SYS_linux_rmdir 40 -#define LINUX_SYS_dup 41 -#define LINUX_SYS_linux_pipe 42 -#define LINUX_SYS_linux_times 43 -#define LINUX_SYS_linux_brk 45 -#define LINUX_SYS_linux_setgid16 46 -#define LINUX_SYS_linux_getgid16 47 -#define LINUX_SYS_linux_signal 48 -#define LINUX_SYS_linux_geteuid16 49 -#define LINUX_SYS_linux_getegid16 50 -#define LINUX_SYS_acct 51 -#define LINUX_SYS_linux_umount 52 -#define LINUX_SYS_linux_ioctl 54 -#define LINUX_SYS_linux_fcntl 55 -#define LINUX_SYS_setpgid 57 -#define LINUX_SYS_linux_olduname 59 -#define LINUX_SYS_umask 60 -#define LINUX_SYS_chroot 61 -#define LINUX_SYS_linux_ustat 62 -#define LINUX_SYS_dup2 63 -#define LINUX_SYS_linux_getppid 64 -#define LINUX_SYS_getpgrp 65 -#define LINUX_SYS_setsid 66 -#define LINUX_SYS_linux_sigaction 67 -#define LINUX_SYS_linux_sgetmask 68 -#define LINUX_SYS_linux_ssetmask 69 -#define LINUX_SYS_linux_setreuid16 70 -#define LINUX_SYS_linux_setregid16 71 -#define LINUX_SYS_linux_sigsuspend 72 -#define LINUX_SYS_linux_sigpending 73 -#define LINUX_SYS_linux_sethostname 74 -#define LINUX_SYS_linux_setrlimit 75 -#define LINUX_SYS_linux_old_getrlimit 76 -#define LINUX_SYS_getrusage 77 -#define LINUX_SYS_gettimeofday 78 -#define LINUX_SYS_settimeofday 79 -#define LINUX_SYS_linux_getgroups16 80 -#define LINUX_SYS_linux_setgroups16 81 -#define LINUX_SYS_linux_old_select 82 -#define LINUX_SYS_linux_symlink 83 -#define LINUX_SYS_linux_ostat 84 -#define LINUX_SYS_linux_readlink 85 -#define LINUX_SYS_linux_uselib 86 -#define LINUX_SYS_swapon 87 -#define LINUX_SYS_linux_reboot 88 -#define LINUX_SYS_linux_readdir 89 -#define LINUX_SYS_linux_mmap 90 -#define LINUX_SYS_munmap 91 -#define LINUX_SYS_linux_truncate 92 -#define LINUX_SYS_linux_ftruncate 93 -#define LINUX_SYS_fchmod 94 -#define LINUX_SYS_fchown 95 -#define LINUX_SYS_getpriority 96 -#define LINUX_SYS_setpriority 97 -#define LINUX_SYS_linux_statfs 99 -#define LINUX_SYS_linux_fstatfs 100 -#define LINUX_SYS_linux_ioperm 101 -#define LINUX_SYS_linux_socketcall 102 -#define LINUX_SYS_linux_syslog 103 -#define LINUX_SYS_linux_setitimer 104 -#define LINUX_SYS_linux_getitimer 105 -#define LINUX_SYS_linux_newstat 106 -#define LINUX_SYS_linux_newlstat 107 -#define LINUX_SYS_linux_newfstat 108 -#define LINUX_SYS_linux_uname 109 -#define LINUX_SYS_linux_iopl 110 -#define LINUX_SYS_linux_vhangup 111 -#define LINUX_SYS_linux_vm86old 113 -#define LINUX_SYS_linux_wait4 114 -#define LINUX_SYS_linux_swapoff 115 -#define LINUX_SYS_linux_sysinfo 116 -#define LINUX_SYS_linux_ipc 117 -#define LINUX_SYS_fsync 118 -#define LINUX_SYS_linux_sigreturn 119 -#define LINUX_SYS_linux_clone 120 -#define LINUX_SYS_setdomainname 121 -#define LINUX_SYS_linux_newuname 122 -#define LINUX_SYS_linux_modify_ldt 123 -#define LINUX_SYS_linux_adjtimex 124 -#define LINUX_SYS_mprotect 125 -#define LINUX_SYS_linux_sigprocmask 126 -#define LINUX_SYS_linux_create_module 127 -#define LINUX_SYS_linux_init_module 128 -#define LINUX_SYS_linux_delete_module 129 -#define LINUX_SYS_linux_get_kernel_syms 130 -#define LINUX_SYS_linux_quotactl 131 -#define LINUX_SYS_getpgid 132 -#define LINUX_SYS_fchdir 133 -#define LINUX_SYS_linux_bdflush 134 -#define LINUX_SYS_linux_sysfs 135 -#define LINUX_SYS_linux_personality 136 -#define LINUX_SYS_linux_setfsuid16 138 -#define LINUX_SYS_linux_setfsgid16 139 -#define LINUX_SYS_linux_llseek 140 -#define LINUX_SYS_linux_getdents 141 -#define LINUX_SYS_linux_select 142 -#define LINUX_SYS_flock 143 -#define LINUX_SYS_linux_msync 144 -#define LINUX_SYS_readv 145 -#define LINUX_SYS_writev 146 -#define LINUX_SYS_linux_getsid 147 -#define LINUX_SYS_linux_fdatasync 148 -#define LINUX_SYS_linux_sysctl 149 -#define LINUX_SYS_mlock 150 -#define LINUX_SYS_munlock 151 -#define LINUX_SYS_mlockall 152 -#define LINUX_SYS_munlockall 153 -#define LINUX_SYS_sched_setparam 154 -#define LINUX_SYS_sched_getparam 155 -#define LINUX_SYS_linux_sched_setscheduler 156 -#define LINUX_SYS_linux_sched_getscheduler 157 -#define LINUX_SYS_sched_yield 158 -#define LINUX_SYS_linux_sched_get_priority_max 159 -#define LINUX_SYS_linux_sched_get_priority_min 160 -#define LINUX_SYS_sched_rr_get_interval 161 -#define LINUX_SYS_nanosleep 162 -#define LINUX_SYS_linux_mremap 163 -#define LINUX_SYS_linux_setresuid16 164 -#define LINUX_SYS_linux_getresuid16 165 -#define LINUX_SYS_linux_vm86 166 -#define LINUX_SYS_linux_query_module 167 -#define LINUX_SYS_poll 168 -#define LINUX_SYS_linux_nfsservctl 169 -#define LINUX_SYS_linux_setresgid16 170 -#define LINUX_SYS_linux_getresgid16 171 -#define LINUX_SYS_linux_prctl 172 -#define LINUX_SYS_linux_rt_sigreturn 173 -#define LINUX_SYS_linux_rt_sigaction 174 -#define LINUX_SYS_linux_rt_sigprocmask 175 -#define LINUX_SYS_linux_rt_sigpending 176 -#define LINUX_SYS_linux_rt_sigtimedwait 177 -#define LINUX_SYS_linux_rt_sigqueueinfo 178 -#define LINUX_SYS_linux_rt_sigsuspend 179 -#define LINUX_SYS_linux_pread 180 -#define LINUX_SYS_linux_pwrite 181 -#define LINUX_SYS_linux_chown16 182 -#define LINUX_SYS_linux_getcwd 183 -#define LINUX_SYS_linux_capget 184 -#define LINUX_SYS_linux_capset 185 -#define LINUX_SYS_linux_sigaltstack 186 -#define LINUX_SYS_linux_sendfile 187 -#define LINUX_SYS_linux_vfork 190 -#define LINUX_SYS_linux_getrlimit 191 -#define LINUX_SYS_linux_mmap2 192 -#define LINUX_SYS_linux_truncate64 193 -#define LINUX_SYS_linux_ftruncate64 194 -#define LINUX_SYS_linux_stat64 195 -#define LINUX_SYS_linux_lstat64 196 -#define LINUX_SYS_linux_fstat64 197 -#define LINUX_SYS_linux_lchown 198 -#define LINUX_SYS_linux_getuid 199 -#define LINUX_SYS_linux_getgid 200 -#define LINUX_SYS_geteuid 201 -#define LINUX_SYS_getegid 202 -#define LINUX_SYS_setreuid 203 -#define LINUX_SYS_setregid 204 -#define LINUX_SYS_linux_getgroups 205 -#define LINUX_SYS_linux_setgroups 206 -#define LINUX_SYS_setresuid 208 -#define LINUX_SYS_getresuid 209 -#define LINUX_SYS_setresgid 210 -#define LINUX_SYS_getresgid 211 -#define LINUX_SYS_linux_chown 212 -#define LINUX_SYS_setuid 213 -#define LINUX_SYS_setgid 214 -#define LINUX_SYS_linux_setfsuid 215 -#define LINUX_SYS_linux_setfsgid 216 -#define LINUX_SYS_linux_pivot_root 217 -#define LINUX_SYS_linux_mincore 218 -#define LINUX_SYS_linux_madvise 219 -#define LINUX_SYS_linux_getdents64 220 -#define LINUX_SYS_linux_fcntl64 221 -#define LINUX_SYS_linux_gettid 224 -#define LINUX_SYS_linux_setxattr 226 -#define LINUX_SYS_linux_lsetxattr 227 -#define LINUX_SYS_linux_fsetxattr 228 -#define LINUX_SYS_linux_getxattr 229 -#define LINUX_SYS_linux_lgetxattr 230 -#define LINUX_SYS_linux_fgetxattr 231 -#define LINUX_SYS_linux_listxattr 232 -#define LINUX_SYS_linux_llistxattr 233 -#define LINUX_SYS_linux_flistxattr 234 -#define LINUX_SYS_linux_removexattr 235 -#define LINUX_SYS_linux_lremovexattr 236 -#define LINUX_SYS_linux_fremovexattr 237 -#define LINUX_SYS_linux_tkill 238 -#define LINUX_SYS_linux_sys_futex 240 -#define LINUX_SYS_linux_sched_setaffinity 241 -#define LINUX_SYS_linux_sched_getaffinity 242 -#define LINUX_SYS_linux_set_thread_area 243 -#define LINUX_SYS_linux_get_thread_area 244 -#define LINUX_SYS_linux_fadvise64 250 -#define LINUX_SYS_linux_exit_group 252 -#define LINUX_SYS_linux_epoll_create 254 -#define LINUX_SYS_linux_epoll_ctl 255 -#define LINUX_SYS_linux_epoll_wait 256 -#define LINUX_SYS_linux_set_tid_address 258 -#define LINUX_SYS_linux_clock_settime 264 -#define LINUX_SYS_linux_clock_gettime 265 -#define LINUX_SYS_linux_clock_getres 266 -#define LINUX_SYS_linux_clock_nanosleep 267 -#define LINUX_SYS_linux_statfs64 268 -#define LINUX_SYS_linux_fstatfs64 269 -#define LINUX_SYS_linux_tgkill 270 -#define LINUX_SYS_linux_utimes 271 -#define LINUX_SYS_linux_fadvise64_64 272 -#define LINUX_SYS_linux_mbind 274 -#define LINUX_SYS_linux_get_mempolicy 275 -#define LINUX_SYS_linux_set_mempolicy 276 -#define LINUX_SYS_linux_mq_open 277 -#define LINUX_SYS_mq_unlink 278 -#define LINUX_SYS_mq_timedsend 279 -#define LINUX_SYS_mq_timedreceive 280 -#define LINUX_SYS_mq_notify 281 -#define LINUX_SYS_linux_mq_getsetattr 282 -#define LINUX_SYS_linux_kexec_load 283 -#define LINUX_SYS_linux_waitid 284 -#define LINUX_SYS_linux_add_key 286 -#define LINUX_SYS_linux_request_key 287 -#define LINUX_SYS_linux_keyctl 288 -#define LINUX_SYS_linux_ioprio_set 289 -#define LINUX_SYS_linux_ioprio_get 290 -#define LINUX_SYS_linux_inotify_init 291 -#define LINUX_SYS_linux_inotify_add_watch 292 -#define LINUX_SYS_linux_inotify_rm_watch 293 -#define LINUX_SYS_linux_migrate_pages 294 -#define LINUX_SYS_linux_openat 295 -#define LINUX_SYS_linux_mkdirat 296 -#define LINUX_SYS_linux_mknodat 297 -#define LINUX_SYS_linux_fchownat 298 -#define LINUX_SYS_linux_futimesat 299 -#define LINUX_SYS_linux_fstatat64 300 -#define LINUX_SYS_linux_unlinkat 301 -#define LINUX_SYS_linux_renameat 302 -#define LINUX_SYS_linux_linkat 303 -#define LINUX_SYS_linux_symlinkat 304 -#define LINUX_SYS_linux_readlinkat 305 -#define LINUX_SYS_linux_fchmodat 306 -#define LINUX_SYS_linux_faccessat 307 -#define LINUX_SYS_linux_pselect6 308 -#define LINUX_SYS_linux_ppoll 309 -#define LINUX_SYS_linux_unshare 310 -#define LINUX_SYS_linux_set_robust_list 311 -#define LINUX_SYS_linux_get_robust_list 312 -#define LINUX_SYS_linux_splice 313 -#define LINUX_SYS_linux_sync_file_range 314 -#define LINUX_SYS_linux_tee 315 -#define LINUX_SYS_linux_vmsplice 316 -#define LINUX_SYS_linux_move_pages 317 -#define LINUX_SYS_linux_getcpu 318 -#define LINUX_SYS_linux_epoll_pwait 319 -#define LINUX_SYS_linux_utimensat 320 -#define LINUX_SYS_linux_signalfd 321 -#define LINUX_SYS_linux_timerfd 322 -#define LINUX_SYS_linux_eventfd 323 -#define LINUX_SYS_linux_pipe2 331 -#define LINUX_SYS_MAXSYSCALL 338 diff --git a/sys/emulation/linux/i386/linux_sysent.c b/sys/emulation/linux/i386/linux_sysent.c deleted file mode 100644 index 20b2c8caae..0000000000 --- a/sys/emulation/linux/i386/linux_sysent.c +++ /dev/null @@ -1,360 +0,0 @@ -/* - * System call switch table. - * - * DO NOT EDIT-- To regenerate this file, edit syscalls.master followed - * by running make sysent in the same directory. - */ - -#include "opt_compat.h" -#include -#include -#include -#include -#include "linux.h" -#include "linux_proto.h" -#include - -#define AS(name) ((sizeof(struct name) - sizeof(struct sysmsg)) / sizeof(register_t)) - -/* The casts are bogus but will do for now. */ -struct sysent linux_sysent[] = { -#define nosys linux_nosys - { 0, (sy_call_t *)sys_nosys }, /* 0 = setup */ - { AS(exit_args), (sy_call_t *)sys_exit }, /* 1 = exit */ - { 0, (sy_call_t *)sys_linux_fork }, /* 2 = linux_fork */ - { AS(read_args), (sy_call_t *)sys_read }, /* 3 = read */ - { AS(write_args), (sy_call_t *)sys_write }, /* 4 = write */ - { AS(linux_open_args), (sy_call_t *)sys_linux_open }, /* 5 = linux_open */ - { AS(close_args), (sy_call_t *)sys_close }, /* 6 = close */ - { AS(linux_waitpid_args), (sy_call_t *)sys_linux_waitpid }, /* 7 = linux_waitpid */ - { AS(linux_creat_args), (sy_call_t *)sys_linux_creat }, /* 8 = linux_creat */ - { AS(linux_link_args), (sy_call_t *)sys_linux_link }, /* 9 = linux_link */ - { AS(linux_unlink_args), (sy_call_t *)sys_linux_unlink }, /* 10 = linux_unlink */ - { AS(linux_execve_args), (sy_call_t *)sys_linux_execve }, /* 11 = linux_execve */ - { AS(linux_chdir_args), (sy_call_t *)sys_linux_chdir }, /* 12 = linux_chdir */ - { AS(linux_time_args), (sy_call_t *)sys_linux_time }, /* 13 = linux_time */ - { AS(linux_mknod_args), (sy_call_t *)sys_linux_mknod }, /* 14 = linux_mknod */ - { AS(linux_chmod_args), (sy_call_t *)sys_linux_chmod }, /* 15 = linux_chmod */ - { AS(linux_lchown16_args), (sy_call_t *)sys_linux_lchown16 }, /* 16 = linux_lchown16 */ - { 0, (sy_call_t *)sys_nosys }, /* 17 = break */ - { AS(linux_stat_args), (sy_call_t *)sys_linux_stat }, /* 18 = linux_stat */ - { AS(linux_lseek_args), (sy_call_t *)sys_linux_lseek }, /* 19 = linux_lseek */ - { 0, (sy_call_t *)sys_linux_getpid }, /* 20 = linux_getpid */ - { AS(linux_mount_args), (sy_call_t *)sys_linux_mount }, /* 21 = linux_mount */ - { AS(linux_oldumount_args), (sy_call_t *)sys_linux_oldumount }, /* 22 = linux_oldumount */ - { AS(linux_setuid16_args), (sy_call_t *)sys_linux_setuid16 }, /* 23 = linux_setuid16 */ - { 0, (sy_call_t *)sys_linux_getuid16 }, /* 24 = linux_getuid16 */ - { 0, (sy_call_t *)sys_linux_stime }, /* 25 = linux_stime */ - { AS(linux_ptrace_args), (sy_call_t *)sys_linux_ptrace }, /* 26 = linux_ptrace */ - { AS(linux_alarm_args), (sy_call_t *)sys_linux_alarm }, /* 27 = linux_alarm */ - { AS(linux_fstat_args), (sy_call_t *)sys_linux_fstat }, /* 28 = linux_fstat */ - { 0, (sy_call_t *)sys_linux_pause }, /* 29 = linux_pause */ - { AS(linux_utime_args), (sy_call_t *)sys_linux_utime }, /* 30 = linux_utime */ - { 0, (sy_call_t *)sys_nosys }, /* 31 = stty */ - { 0, (sy_call_t *)sys_nosys }, /* 32 = gtty */ - { AS(linux_access_args), (sy_call_t *)sys_linux_access }, /* 33 = linux_access */ - { AS(linux_nice_args), (sy_call_t *)sys_linux_nice }, /* 34 = linux_nice */ - { 0, (sy_call_t *)sys_nosys }, /* 35 = ftime */ - { 0, (sy_call_t *)sys_sync }, /* 36 = sync */ - { AS(linux_kill_args), (sy_call_t *)sys_linux_kill }, /* 37 = linux_kill */ - { AS(linux_rename_args), (sy_call_t *)sys_linux_rename }, /* 38 = linux_rename */ - { AS(linux_mkdir_args), (sy_call_t *)sys_linux_mkdir }, /* 39 = linux_mkdir */ - { AS(linux_rmdir_args), (sy_call_t *)sys_linux_rmdir }, /* 40 = linux_rmdir */ - { AS(dup_args), (sy_call_t *)sys_dup }, /* 41 = dup */ - { AS(linux_pipe_args), (sy_call_t *)sys_linux_pipe }, /* 42 = linux_pipe */ - { AS(linux_times_args), (sy_call_t *)sys_linux_times }, /* 43 = linux_times */ - { 0, (sy_call_t *)sys_nosys }, /* 44 = prof */ - { AS(linux_brk_args), (sy_call_t *)sys_linux_brk }, /* 45 = linux_brk */ - { AS(linux_setgid16_args), (sy_call_t *)sys_linux_setgid16 }, /* 46 = linux_setgid16 */ - { 0, (sy_call_t *)sys_linux_getgid16 }, /* 47 = linux_getgid16 */ - { AS(linux_signal_args), (sy_call_t *)sys_linux_signal }, /* 48 = linux_signal */ - { 0, (sy_call_t *)sys_linux_geteuid16 }, /* 49 = linux_geteuid16 */ - { 0, (sy_call_t *)sys_linux_getegid16 }, /* 50 = linux_getegid16 */ - { AS(acct_args), (sy_call_t *)sys_acct }, /* 51 = acct */ - { AS(linux_umount_args), (sy_call_t *)sys_linux_umount }, /* 52 = linux_umount */ - { 0, (sy_call_t *)sys_nosys }, /* 53 = lock */ - { AS(linux_ioctl_args), (sy_call_t *)sys_linux_ioctl }, /* 54 = linux_ioctl */ - { AS(linux_fcntl_args), (sy_call_t *)sys_linux_fcntl }, /* 55 = linux_fcntl */ - { 0, (sy_call_t *)sys_nosys }, /* 56 = mpx */ - { AS(setpgid_args), (sy_call_t *)sys_setpgid }, /* 57 = setpgid */ - { 0, (sy_call_t *)sys_nosys }, /* 58 = ulimit */ - { 0, (sy_call_t *)sys_linux_olduname }, /* 59 = linux_olduname */ - { AS(umask_args), (sy_call_t *)sys_umask }, /* 60 = umask */ - { AS(chroot_args), (sy_call_t *)sys_chroot }, /* 61 = chroot */ - { AS(linux_ustat_args), (sy_call_t *)sys_linux_ustat }, /* 62 = linux_ustat */ - { AS(dup2_args), (sy_call_t *)sys_dup2 }, /* 63 = dup2 */ - { 0, (sy_call_t *)sys_linux_getppid }, /* 64 = linux_getppid */ - { 0, (sy_call_t *)sys_getpgrp }, /* 65 = getpgrp */ - { 0, (sy_call_t *)sys_setsid }, /* 66 = setsid */ - { AS(linux_sigaction_args), (sy_call_t *)sys_linux_sigaction }, /* 67 = linux_sigaction */ - { 0, (sy_call_t *)sys_linux_sgetmask }, /* 68 = linux_sgetmask */ - { AS(linux_ssetmask_args), (sy_call_t *)sys_linux_ssetmask }, /* 69 = linux_ssetmask */ - { AS(linux_setreuid16_args), (sy_call_t *)sys_linux_setreuid16 }, /* 70 = linux_setreuid16 */ - { AS(linux_setregid16_args), (sy_call_t *)sys_linux_setregid16 }, /* 71 = linux_setregid16 */ - { AS(linux_sigsuspend_args), (sy_call_t *)sys_linux_sigsuspend }, /* 72 = linux_sigsuspend */ - { AS(linux_sigpending_args), (sy_call_t *)sys_linux_sigpending }, /* 73 = linux_sigpending */ - { AS(linux_sethostname_args), (sy_call_t *)sys_linux_sethostname }, /* 74 = linux_sethostname */ - { AS(linux_setrlimit_args), (sy_call_t *)sys_linux_setrlimit }, /* 75 = linux_setrlimit */ - { AS(linux_old_getrlimit_args), (sy_call_t *)sys_linux_old_getrlimit }, /* 76 = linux_old_getrlimit */ - { AS(getrusage_args), (sy_call_t *)sys_getrusage }, /* 77 = getrusage */ - { AS(gettimeofday_args), (sy_call_t *)sys_gettimeofday }, /* 78 = gettimeofday */ - { AS(settimeofday_args), (sy_call_t *)sys_settimeofday }, /* 79 = settimeofday */ - { AS(linux_getgroups16_args), (sy_call_t *)sys_linux_getgroups16 }, /* 80 = linux_getgroups16 */ - { AS(linux_setgroups16_args), (sy_call_t *)sys_linux_setgroups16 }, /* 81 = linux_setgroups16 */ - { AS(linux_old_select_args), (sy_call_t *)sys_linux_old_select }, /* 82 = linux_old_select */ - { AS(linux_symlink_args), (sy_call_t *)sys_linux_symlink }, /* 83 = linux_symlink */ - { AS(linux_ostat_args), (sy_call_t *)sys_linux_ostat }, /* 84 = linux_ostat */ - { AS(linux_readlink_args), (sy_call_t *)sys_linux_readlink }, /* 85 = linux_readlink */ - { AS(linux_uselib_args), (sy_call_t *)sys_linux_uselib }, /* 86 = linux_uselib */ - { AS(swapon_args), (sy_call_t *)sys_swapon }, /* 87 = swapon */ - { AS(linux_reboot_args), (sy_call_t *)sys_linux_reboot }, /* 88 = linux_reboot */ - { AS(linux_readdir_args), (sy_call_t *)sys_linux_readdir }, /* 89 = linux_readdir */ - { AS(linux_mmap_args), (sy_call_t *)sys_linux_mmap }, /* 90 = linux_mmap */ - { AS(munmap_args), (sy_call_t *)sys_munmap }, /* 91 = munmap */ - { AS(linux_truncate_args), (sy_call_t *)sys_linux_truncate }, /* 92 = linux_truncate */ - { AS(linux_ftruncate_args), (sy_call_t *)sys_linux_ftruncate }, /* 93 = linux_ftruncate */ - { AS(fchmod_args), (sy_call_t *)sys_fchmod }, /* 94 = fchmod */ - { AS(fchown_args), (sy_call_t *)sys_fchown }, /* 95 = fchown */ - { AS(getpriority_args), (sy_call_t *)sys_getpriority }, /* 96 = getpriority */ - { AS(setpriority_args), (sy_call_t *)sys_setpriority }, /* 97 = setpriority */ - { 0, (sy_call_t *)sys_nosys }, /* 98 = profil */ - { AS(linux_statfs_args), (sy_call_t *)sys_linux_statfs }, /* 99 = linux_statfs */ - { AS(linux_fstatfs_args), (sy_call_t *)sys_linux_fstatfs }, /* 100 = linux_fstatfs */ - { AS(linux_ioperm_args), (sy_call_t *)sys_linux_ioperm }, /* 101 = linux_ioperm */ - { AS(linux_socketcall_args), (sy_call_t *)sys_linux_socketcall }, /* 102 = linux_socketcall */ - { AS(linux_syslog_args), (sy_call_t *)sys_linux_syslog }, /* 103 = linux_syslog */ - { AS(linux_setitimer_args), (sy_call_t *)sys_linux_setitimer }, /* 104 = linux_setitimer */ - { AS(linux_getitimer_args), (sy_call_t *)sys_linux_getitimer }, /* 105 = linux_getitimer */ - { AS(linux_newstat_args), (sy_call_t *)sys_linux_newstat }, /* 106 = linux_newstat */ - { AS(linux_newlstat_args), (sy_call_t *)sys_linux_newlstat }, /* 107 = linux_newlstat */ - { AS(linux_newfstat_args), (sy_call_t *)sys_linux_newfstat }, /* 108 = linux_newfstat */ - { 0, (sy_call_t *)sys_linux_uname }, /* 109 = linux_uname */ - { AS(linux_iopl_args), (sy_call_t *)sys_linux_iopl }, /* 110 = linux_iopl */ - { 0, (sy_call_t *)sys_linux_vhangup }, /* 111 = linux_vhangup */ - { 0, (sy_call_t *)sys_nosys }, /* 112 = idle */ - { 0, (sy_call_t *)sys_linux_vm86old }, /* 113 = linux_vm86old */ - { AS(linux_wait4_args), (sy_call_t *)sys_linux_wait4 }, /* 114 = linux_wait4 */ - { 0, (sy_call_t *)sys_linux_swapoff }, /* 115 = linux_swapoff */ - { AS(linux_sysinfo_args), (sy_call_t *)sys_linux_sysinfo }, /* 116 = linux_sysinfo */ - { AS(linux_ipc_args), (sy_call_t *)sys_linux_ipc }, /* 117 = linux_ipc */ - { AS(fsync_args), (sy_call_t *)sys_fsync }, /* 118 = fsync */ - { AS(linux_sigreturn_args), (sy_call_t *)sys_linux_sigreturn }, /* 119 = linux_sigreturn */ - { AS(linux_clone_args), (sy_call_t *)sys_linux_clone }, /* 120 = linux_clone */ - { AS(setdomainname_args), (sy_call_t *)sys_setdomainname }, /* 121 = setdomainname */ - { AS(linux_newuname_args), (sy_call_t *)sys_linux_newuname }, /* 122 = linux_newuname */ - { AS(linux_modify_ldt_args), (sy_call_t *)sys_linux_modify_ldt }, /* 123 = linux_modify_ldt */ - { 0, (sy_call_t *)sys_linux_adjtimex }, /* 124 = linux_adjtimex */ - { AS(mprotect_args), (sy_call_t *)sys_mprotect }, /* 125 = mprotect */ - { AS(linux_sigprocmask_args), (sy_call_t *)sys_linux_sigprocmask }, /* 126 = linux_sigprocmask */ - { 0, (sy_call_t *)sys_linux_create_module }, /* 127 = linux_create_module */ - { 0, (sy_call_t *)sys_linux_init_module }, /* 128 = linux_init_module */ - { 0, (sy_call_t *)sys_linux_delete_module }, /* 129 = linux_delete_module */ - { 0, (sy_call_t *)sys_linux_get_kernel_syms }, /* 130 = linux_get_kernel_syms */ - { 0, (sy_call_t *)sys_linux_quotactl }, /* 131 = linux_quotactl */ - { AS(getpgid_args), (sy_call_t *)sys_getpgid }, /* 132 = getpgid */ - { AS(fchdir_args), (sy_call_t *)sys_fchdir }, /* 133 = fchdir */ - { 0, (sy_call_t *)sys_linux_bdflush }, /* 134 = linux_bdflush */ - { AS(linux_sysfs_args), (sy_call_t *)sys_linux_sysfs }, /* 135 = linux_sysfs */ - { AS(linux_personality_args), (sy_call_t *)sys_linux_personality }, /* 136 = linux_personality */ - { 0, (sy_call_t *)sys_nosys }, /* 137 = afs_syscall */ - { AS(linux_setfsuid16_args), (sy_call_t *)sys_linux_setfsuid16 }, /* 138 = linux_setfsuid16 */ - { AS(linux_setfsgid16_args), (sy_call_t *)sys_linux_setfsgid16 }, /* 139 = linux_setfsgid16 */ - { AS(linux_llseek_args), (sy_call_t *)sys_linux_llseek }, /* 140 = linux_llseek */ - { AS(linux_getdents_args), (sy_call_t *)sys_linux_getdents }, /* 141 = linux_getdents */ - { AS(linux_select_args), (sy_call_t *)sys_linux_select }, /* 142 = linux_select */ - { AS(flock_args), (sy_call_t *)sys_flock }, /* 143 = flock */ - { AS(linux_msync_args), (sy_call_t *)sys_linux_msync }, /* 144 = linux_msync */ - { AS(readv_args), (sy_call_t *)sys_readv }, /* 145 = readv */ - { AS(writev_args), (sy_call_t *)sys_writev }, /* 146 = writev */ - { AS(linux_getsid_args), (sy_call_t *)sys_linux_getsid }, /* 147 = linux_getsid */ - { AS(linux_fdatasync_args), (sy_call_t *)sys_linux_fdatasync }, /* 148 = linux_fdatasync */ - { AS(linux_sysctl_args), (sy_call_t *)sys_linux_sysctl }, /* 149 = linux_sysctl */ - { AS(mlock_args), (sy_call_t *)sys_mlock }, /* 150 = mlock */ - { AS(munlock_args), (sy_call_t *)sys_munlock }, /* 151 = munlock */ - { AS(mlockall_args), (sy_call_t *)sys_mlockall }, /* 152 = mlockall */ - { 0, (sy_call_t *)sys_munlockall }, /* 153 = munlockall */ - { AS(sched_setparam_args), (sy_call_t *)sys_sched_setparam }, /* 154 = sched_setparam */ - { AS(sched_getparam_args), (sy_call_t *)sys_sched_getparam }, /* 155 = sched_getparam */ - { AS(linux_sched_setscheduler_args), (sy_call_t *)sys_linux_sched_setscheduler }, /* 156 = linux_sched_setscheduler */ - { AS(linux_sched_getscheduler_args), (sy_call_t *)sys_linux_sched_getscheduler }, /* 157 = linux_sched_getscheduler */ - { 0, (sy_call_t *)sys_sched_yield }, /* 158 = sched_yield */ - { AS(linux_sched_get_priority_max_args), (sy_call_t *)sys_linux_sched_get_priority_max }, /* 159 = linux_sched_get_priority_max */ - { AS(linux_sched_get_priority_min_args), (sy_call_t *)sys_linux_sched_get_priority_min }, /* 160 = linux_sched_get_priority_min */ - { AS(sched_rr_get_interval_args), (sy_call_t *)sys_sched_rr_get_interval }, /* 161 = sched_rr_get_interval */ - { AS(nanosleep_args), (sy_call_t *)sys_nanosleep }, /* 162 = nanosleep */ - { AS(linux_mremap_args), (sy_call_t *)sys_linux_mremap }, /* 163 = linux_mremap */ - { AS(linux_setresuid16_args), (sy_call_t *)sys_linux_setresuid16 }, /* 164 = linux_setresuid16 */ - { AS(linux_getresuid16_args), (sy_call_t *)sys_linux_getresuid16 }, /* 165 = linux_getresuid16 */ - { 0, (sy_call_t *)sys_linux_vm86 }, /* 166 = linux_vm86 */ - { 0, (sy_call_t *)sys_linux_query_module }, /* 167 = linux_query_module */ - { AS(poll_args), (sy_call_t *)sys_poll }, /* 168 = poll */ - { 0, (sy_call_t *)sys_linux_nfsservctl }, /* 169 = linux_nfsservctl */ - { AS(linux_setresgid16_args), (sy_call_t *)sys_linux_setresgid16 }, /* 170 = linux_setresgid16 */ - { AS(linux_getresgid16_args), (sy_call_t *)sys_linux_getresgid16 }, /* 171 = linux_getresgid16 */ - { 0, (sy_call_t *)sys_linux_prctl }, /* 172 = linux_prctl */ - { AS(linux_rt_sigreturn_args), (sy_call_t *)sys_linux_rt_sigreturn }, /* 173 = linux_rt_sigreturn */ - { AS(linux_rt_sigaction_args), (sy_call_t *)sys_linux_rt_sigaction }, /* 174 = linux_rt_sigaction */ - { AS(linux_rt_sigprocmask_args), (sy_call_t *)sys_linux_rt_sigprocmask }, /* 175 = linux_rt_sigprocmask */ - { 0, (sy_call_t *)sys_linux_rt_sigpending }, /* 176 = linux_rt_sigpending */ - { 0, (sy_call_t *)sys_linux_rt_sigtimedwait }, /* 177 = linux_rt_sigtimedwait */ - { 0, (sy_call_t *)sys_linux_rt_sigqueueinfo }, /* 178 = linux_rt_sigqueueinfo */ - { AS(linux_rt_sigsuspend_args), (sy_call_t *)sys_linux_rt_sigsuspend }, /* 179 = linux_rt_sigsuspend */ - { AS(linux_pread_args), (sy_call_t *)sys_linux_pread }, /* 180 = linux_pread */ - { AS(linux_pwrite_args), (sy_call_t *)sys_linux_pwrite }, /* 181 = linux_pwrite */ - { AS(linux_chown16_args), (sy_call_t *)sys_linux_chown16 }, /* 182 = linux_chown16 */ - { AS(linux_getcwd_args), (sy_call_t *)sys_linux_getcwd }, /* 183 = linux_getcwd */ - { 0, (sy_call_t *)sys_linux_capget }, /* 184 = linux_capget */ - { 0, (sy_call_t *)sys_linux_capset }, /* 185 = linux_capset */ - { AS(linux_sigaltstack_args), (sy_call_t *)sys_linux_sigaltstack }, /* 186 = linux_sigaltstack */ - { 0, (sy_call_t *)sys_linux_sendfile }, /* 187 = linux_sendfile */ - { 0, (sy_call_t *)sys_nosys }, /* 188 = getpmsg */ - { 0, (sy_call_t *)sys_nosys }, /* 189 = putpmsg */ - { 0, (sy_call_t *)sys_linux_vfork }, /* 190 = linux_vfork */ - { AS(linux_getrlimit_args), (sy_call_t *)sys_linux_getrlimit }, /* 191 = linux_getrlimit */ - { AS(linux_mmap2_args), (sy_call_t *)sys_linux_mmap2 }, /* 192 = linux_mmap2 */ - { AS(linux_truncate64_args), (sy_call_t *)sys_linux_truncate64 }, /* 193 = linux_truncate64 */ - { AS(linux_ftruncate64_args), (sy_call_t *)sys_linux_ftruncate64 }, /* 194 = linux_ftruncate64 */ - { AS(linux_stat64_args), (sy_call_t *)sys_linux_stat64 }, /* 195 = linux_stat64 */ - { AS(linux_lstat64_args), (sy_call_t *)sys_linux_lstat64 }, /* 196 = linux_lstat64 */ - { AS(linux_fstat64_args), (sy_call_t *)sys_linux_fstat64 }, /* 197 = linux_fstat64 */ - { AS(linux_lchown_args), (sy_call_t *)sys_linux_lchown }, /* 198 = linux_lchown */ - { 0, (sy_call_t *)sys_linux_getuid }, /* 199 = linux_getuid */ - { 0, (sy_call_t *)sys_linux_getgid }, /* 200 = linux_getgid */ - { 0, (sy_call_t *)sys_geteuid }, /* 201 = geteuid */ - { 0, (sy_call_t *)sys_getegid }, /* 202 = getegid */ - { AS(setreuid_args), (sy_call_t *)sys_setreuid }, /* 203 = setreuid */ - { AS(setregid_args), (sy_call_t *)sys_setregid }, /* 204 = setregid */ - { AS(linux_getgroups_args), (sy_call_t *)sys_linux_getgroups }, /* 205 = linux_getgroups */ - { AS(linux_setgroups_args), (sy_call_t *)sys_linux_setgroups }, /* 206 = linux_setgroups */ - { AS(fchown_args), (sy_call_t *)sys_fchown }, /* 207 = fchown */ - { AS(setresuid_args), (sy_call_t *)sys_setresuid }, /* 208 = setresuid */ - { AS(getresuid_args), (sy_call_t *)sys_getresuid }, /* 209 = getresuid */ - { AS(setresgid_args), (sy_call_t *)sys_setresgid }, /* 210 = setresgid */ - { AS(getresgid_args), (sy_call_t *)sys_getresgid }, /* 211 = getresgid */ - { AS(linux_chown_args), (sy_call_t *)sys_linux_chown }, /* 212 = linux_chown */ - { AS(setuid_args), (sy_call_t *)sys_setuid }, /* 213 = setuid */ - { AS(setgid_args), (sy_call_t *)sys_setgid }, /* 214 = setgid */ - { AS(linux_setfsuid_args), (sy_call_t *)sys_linux_setfsuid }, /* 215 = linux_setfsuid */ - { AS(linux_setfsgid_args), (sy_call_t *)sys_linux_setfsgid }, /* 216 = linux_setfsgid */ - { AS(linux_pivot_root_args), (sy_call_t *)sys_linux_pivot_root }, /* 217 = linux_pivot_root */ - { AS(linux_mincore_args), (sy_call_t *)sys_linux_mincore }, /* 218 = linux_mincore */ - { 0, (sy_call_t *)sys_linux_madvise }, /* 219 = linux_madvise */ - { AS(linux_getdents64_args), (sy_call_t *)sys_linux_getdents64 }, /* 220 = linux_getdents64 */ - { AS(linux_fcntl64_args), (sy_call_t *)sys_linux_fcntl64 }, /* 221 = linux_fcntl64 */ - { 0, (sy_call_t *)sys_nosys }, /* 222 = none */ - { 0, (sy_call_t *)sys_nosys }, /* 223 = none */ - { 0, (sy_call_t *)sys_linux_gettid }, /* 224 = linux_gettid */ - { 0, (sy_call_t *)sys_nosys }, /* 225 = linux_readahead */ - { 0, (sy_call_t *)sys_linux_setxattr }, /* 226 = linux_setxattr */ - { 0, (sy_call_t *)sys_linux_lsetxattr }, /* 227 = linux_lsetxattr */ - { 0, (sy_call_t *)sys_linux_fsetxattr }, /* 228 = linux_fsetxattr */ - { 0, (sy_call_t *)sys_linux_getxattr }, /* 229 = linux_getxattr */ - { 0, (sy_call_t *)sys_linux_lgetxattr }, /* 230 = linux_lgetxattr */ - { 0, (sy_call_t *)sys_linux_fgetxattr }, /* 231 = linux_fgetxattr */ - { 0, (sy_call_t *)sys_linux_listxattr }, /* 232 = linux_listxattr */ - { 0, (sy_call_t *)sys_linux_llistxattr }, /* 233 = linux_llistxattr */ - { 0, (sy_call_t *)sys_linux_flistxattr }, /* 234 = linux_flistxattr */ - { 0, (sy_call_t *)sys_linux_removexattr }, /* 235 = linux_removexattr */ - { 0, (sy_call_t *)sys_linux_lremovexattr }, /* 236 = linux_lremovexattr */ - { 0, (sy_call_t *)sys_linux_fremovexattr }, /* 237 = linux_fremovexattr */ - { AS(linux_tkill_args), (sy_call_t *)sys_linux_tkill }, /* 238 = linux_tkill */ - { 0, (sy_call_t *)sys_nosys }, /* 239 = linux_sendfile64 */ - { AS(linux_sys_futex_args), (sy_call_t *)sys_linux_sys_futex }, /* 240 = linux_sys_futex */ - { AS(linux_sched_setaffinity_args), (sy_call_t *)sys_linux_sched_setaffinity }, /* 241 = linux_sched_setaffinity */ - { AS(linux_sched_getaffinity_args), (sy_call_t *)sys_linux_sched_getaffinity }, /* 242 = linux_sched_getaffinity */ - { AS(linux_set_thread_area_args), (sy_call_t *)sys_linux_set_thread_area }, /* 243 = linux_set_thread_area */ - { AS(linux_get_thread_area_args), (sy_call_t *)sys_linux_get_thread_area }, /* 244 = linux_get_thread_area */ - { 0, (sy_call_t *)sys_nosys }, /* 245 = linux_io_setup */ - { 0, (sy_call_t *)sys_nosys }, /* 246 = linux_io_destroy */ - { 0, (sy_call_t *)sys_nosys }, /* 247 = linux_io_getevents */ - { 0, (sy_call_t *)sys_nosys }, /* 248 = linux_io_submit */ - { 0, (sy_call_t *)sys_nosys }, /* 249 = linux_io_cancel */ - { 0, (sy_call_t *)sys_linux_fadvise64 }, /* 250 = linux_fadvise64 */ - { 0, (sy_call_t *)sys_nosys }, /* 251 = */ - { AS(linux_exit_group_args), (sy_call_t *)sys_linux_exit_group }, /* 252 = linux_exit_group */ - { 0, (sy_call_t *)sys_nosys }, /* 253 = linux_lookup_dcookie */ - { AS(linux_epoll_create_args), (sy_call_t *)sys_linux_epoll_create }, /* 254 = linux_epoll_create */ - { AS(linux_epoll_ctl_args), (sy_call_t *)sys_linux_epoll_ctl }, /* 255 = linux_epoll_ctl */ - { AS(linux_epoll_wait_args), (sy_call_t *)sys_linux_epoll_wait }, /* 256 = linux_epoll_wait */ - { 0, (sy_call_t *)sys_nosys }, /* 257 = linux_remap_file_pages */ - { AS(linux_set_tid_address_args), (sy_call_t *)sys_linux_set_tid_address }, /* 258 = linux_set_tid_address */ - { 0, (sy_call_t *)sys_nosys }, /* 259 = linux_timer_create */ - { 0, (sy_call_t *)sys_nosys }, /* 260 = linux_timer_settime */ - { 0, (sy_call_t *)sys_nosys }, /* 261 = linux_timer_gettime */ - { 0, (sy_call_t *)sys_nosys }, /* 262 = linux_timer_getoverrun */ - { 0, (sy_call_t *)sys_nosys }, /* 263 = linux_timer_delete */ - { AS(linux_clock_settime_args), (sy_call_t *)sys_linux_clock_settime }, /* 264 = linux_clock_settime */ - { AS(linux_clock_gettime_args), (sy_call_t *)sys_linux_clock_gettime }, /* 265 = linux_clock_gettime */ - { AS(linux_clock_getres_args), (sy_call_t *)sys_linux_clock_getres }, /* 266 = linux_clock_getres */ - { AS(linux_clock_nanosleep_args), (sy_call_t *)sys_linux_clock_nanosleep }, /* 267 = linux_clock_nanosleep */ - { 0, (sy_call_t *)sys_linux_statfs64 }, /* 268 = linux_statfs64 */ - { 0, (sy_call_t *)sys_linux_fstatfs64 }, /* 269 = linux_fstatfs64 */ - { AS(linux_tgkill_args), (sy_call_t *)sys_linux_tgkill }, /* 270 = linux_tgkill */ - { AS(linux_utimes_args), (sy_call_t *)sys_linux_utimes }, /* 271 = linux_utimes */ - { 0, (sy_call_t *)sys_linux_fadvise64_64 }, /* 272 = linux_fadvise64_64 */ - { 0, (sy_call_t *)sys_nosys }, /* 273 = / */ - { 0, (sy_call_t *)sys_linux_mbind }, /* 274 = linux_mbind */ - { 0, (sy_call_t *)sys_linux_get_mempolicy }, /* 275 = linux_get_mempolicy */ - { 0, (sy_call_t *)sys_linux_set_mempolicy }, /* 276 = linux_set_mempolicy */ - { AS(linux_mq_open_args), (sy_call_t *)sys_linux_mq_open }, /* 277 = linux_mq_open */ - { AS(mq_unlink_args), (sy_call_t *)sys_mq_unlink }, /* 278 = mq_unlink */ - { AS(mq_timedsend_args), (sy_call_t *)sys_mq_timedsend }, /* 279 = mq_timedsend */ - { AS(mq_timedreceive_args), (sy_call_t *)sys_mq_timedreceive }, /* 280 = mq_timedreceive */ - { AS(mq_notify_args), (sy_call_t *)sys_mq_notify }, /* 281 = mq_notify */ - { AS(linux_mq_getsetattr_args), (sy_call_t *)sys_linux_mq_getsetattr }, /* 282 = linux_mq_getsetattr */ - { 0, (sy_call_t *)sys_linux_kexec_load }, /* 283 = linux_kexec_load */ - { 0, (sy_call_t *)sys_linux_waitid }, /* 284 = linux_waitid */ - { 0, (sy_call_t *)sys_nosys }, /* 285 = / */ - { 0, (sy_call_t *)sys_linux_add_key }, /* 286 = linux_add_key */ - { 0, (sy_call_t *)sys_linux_request_key }, /* 287 = linux_request_key */ - { 0, (sy_call_t *)sys_linux_keyctl }, /* 288 = linux_keyctl */ - { 0, (sy_call_t *)sys_linux_ioprio_set }, /* 289 = linux_ioprio_set */ - { 0, (sy_call_t *)sys_linux_ioprio_get }, /* 290 = linux_ioprio_get */ - { 0, (sy_call_t *)sys_linux_inotify_init }, /* 291 = linux_inotify_init */ - { 0, (sy_call_t *)sys_linux_inotify_add_watch }, /* 292 = linux_inotify_add_watch */ - { 0, (sy_call_t *)sys_linux_inotify_rm_watch }, /* 293 = linux_inotify_rm_watch */ - { 0, (sy_call_t *)sys_linux_migrate_pages }, /* 294 = linux_migrate_pages */ - { AS(linux_openat_args), (sy_call_t *)sys_linux_openat }, /* 295 = linux_openat */ - { AS(linux_mkdirat_args), (sy_call_t *)sys_linux_mkdirat }, /* 296 = linux_mkdirat */ - { AS(linux_mknodat_args), (sy_call_t *)sys_linux_mknodat }, /* 297 = linux_mknodat */ - { AS(linux_fchownat_args), (sy_call_t *)sys_linux_fchownat }, /* 298 = linux_fchownat */ - { AS(linux_futimesat_args), (sy_call_t *)sys_linux_futimesat }, /* 299 = linux_futimesat */ - { AS(linux_fstatat64_args), (sy_call_t *)sys_linux_fstatat64 }, /* 300 = linux_fstatat64 */ - { AS(linux_unlinkat_args), (sy_call_t *)sys_linux_unlinkat }, /* 301 = linux_unlinkat */ - { AS(linux_renameat_args), (sy_call_t *)sys_linux_renameat }, /* 302 = linux_renameat */ - { AS(linux_linkat_args), (sy_call_t *)sys_linux_linkat }, /* 303 = linux_linkat */ - { AS(linux_symlinkat_args), (sy_call_t *)sys_linux_symlinkat }, /* 304 = linux_symlinkat */ - { AS(linux_readlinkat_args), (sy_call_t *)sys_linux_readlinkat }, /* 305 = linux_readlinkat */ - { AS(linux_fchmodat_args), (sy_call_t *)sys_linux_fchmodat }, /* 306 = linux_fchmodat */ - { AS(linux_faccessat_args), (sy_call_t *)sys_linux_faccessat }, /* 307 = linux_faccessat */ - { 0, (sy_call_t *)sys_linux_pselect6 }, /* 308 = linux_pselect6 */ - { 0, (sy_call_t *)sys_linux_ppoll }, /* 309 = linux_ppoll */ - { 0, (sy_call_t *)sys_linux_unshare }, /* 310 = linux_unshare */ - { AS(linux_set_robust_list_args), (sy_call_t *)sys_linux_set_robust_list }, /* 311 = linux_set_robust_list */ - { AS(linux_get_robust_list_args), (sy_call_t *)sys_linux_get_robust_list }, /* 312 = linux_get_robust_list */ - { 0, (sy_call_t *)sys_linux_splice }, /* 313 = linux_splice */ - { 0, (sy_call_t *)sys_linux_sync_file_range }, /* 314 = linux_sync_file_range */ - { 0, (sy_call_t *)sys_linux_tee }, /* 315 = linux_tee */ - { 0, (sy_call_t *)sys_linux_vmsplice }, /* 316 = linux_vmsplice */ - { 0, (sy_call_t *)sys_linux_move_pages }, /* 317 = linux_move_pages */ - { AS(linux_getcpu_args), (sy_call_t *)sys_linux_getcpu }, /* 318 = linux_getcpu */ - { 0, (sy_call_t *)sys_linux_epoll_pwait }, /* 319 = linux_epoll_pwait */ - { AS(linux_utimensat_args), (sy_call_t *)sys_linux_utimensat }, /* 320 = linux_utimensat */ - { 0, (sy_call_t *)sys_linux_signalfd }, /* 321 = linux_signalfd */ - { 0, (sy_call_t *)sys_linux_timerfd }, /* 322 = linux_timerfd */ - { 0, (sy_call_t *)sys_linux_eventfd }, /* 323 = linux_eventfd */ - { 0, (sy_call_t *)sys_nosys }, /* 324 = linux_fallocate */ - { 0, (sy_call_t *)sys_nosys }, /* 325 = linux_timerfd_settime */ - { 0, (sy_call_t *)sys_nosys }, /* 326 = linux_timerfd_gettime */ - { 0, (sy_call_t *)sys_nosys }, /* 327 = linux_signalfd4 */ - { 0, (sy_call_t *)sys_nosys }, /* 328 = linux_eventfd2 */ - { 0, (sy_call_t *)sys_nosys }, /* 329 = linux_epoll_create1 */ - { 0, (sy_call_t *)sys_nosys }, /* 330 = linux_dup3 */ - { AS(linux_pipe2_args), (sy_call_t *)sys_linux_pipe2 }, /* 331 = linux_pipe2 */ - { 0, (sy_call_t *)sys_nosys }, /* 332 = linux_inotify_init1 */ - { 0, (sy_call_t *)sys_nosys }, /* 333 = linux_preadv */ - { 0, (sy_call_t *)sys_nosys }, /* 334 = linux_pwritev */ - { 0, (sy_call_t *)sys_nosys }, /* 335 = linux_rt_tgsigqueueinfo */ - { 0, (sy_call_t *)sys_nosys }, /* 336 = linux_perf_event_open */ - { 0, (sy_call_t *)sys_nosys }, /* 337 = linux_recvmmsg */ -}; diff --git a/sys/emulation/linux/i386/linux_sysvec.c b/sys/emulation/linux/i386/linux_sysvec.c deleted file mode 100644 index 88c130a534..0000000000 --- a/sys/emulation/linux/i386/linux_sysvec.c +++ /dev/null @@ -1,980 +0,0 @@ -/*- - * Copyright (c) 1994-1996 Søren Schmidt - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer - * in this position and unchanged. - * 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 - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD: src/sys/i386/linux/linux_sysvec.c,v 1.55.2.9 2002/01/12 11:03:30 bde Exp $ - */ - -/* XXX we use functions that might not exist. */ -#include "opt_compat.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "linux.h" -#include "linux_proto.h" -#include "../linux_signal.h" -#include "../linux_util.h" -#include "../linux_futex.h" -#include "../linux_emuldata.h" - -MODULE_VERSION(linux, 1); - -MALLOC_DEFINE(M_LINUX, "linux", "Linux mode structures"); - -#if BYTE_ORDER == LITTLE_ENDIAN -#define SHELLMAGIC 0x2123 /* #! */ -#else -#define SHELLMAGIC 0x2321 -#endif - -/* - * Allow the sendsig functions to use the ldebug() facility - * even though they are not syscalls themselves. Map them - * to syscall 0. This is slightly less bogus than using - * ldebug(sigreturn). - */ -#define LINUX_SYS_linux_rt_sendsig 0 -#define LINUX_SYS_linux_sendsig 0 - -extern char linux_sigcode[]; -extern int linux_szsigcode; - -extern struct sysent linux_sysent[LINUX_SYS_MAXSYSCALL]; - -static int linux_fixup (register_t **stack_base, - struct image_params *iparams); -static int elf_linux_fixup (register_t **stack_base, - struct image_params *iparams); -static void linux_prepsyscall (struct trapframe *tf, int *args, - u_int *code, caddr_t *params); -static void linux_sendsig (sig_t catcher, int sig, sigset_t *mask, - u_long code); -static boolean_t linux_trans_osrel(const Elf_Note *note, int32_t *osrel); - -static eventhandler_tag linux_exec_tag; -static eventhandler_tag linux_exit_tag; - -/* - * Linux syscalls return negative errno's, we do positive and map them - */ -static int bsd_to_linux_errno[ELAST + 1] = { - -0, -1, -2, -3, -4, -5, -6, -7, -8, -9, - -10, -35, -12, -13, -14, -15, -16, -17, -18, -19, - -20, -21, -22, -23, -24, -25, -26, -27, -28, -29, - -30, -31, -32, -33, -34, -11,-115,-114, -88, -89, - -90, -91, -92, -93, -94, -95, -96, -97, -98, -99, - -100,-101,-102,-103,-104,-105,-106,-107,-108,-109, - -110,-111, -40, -36,-112,-113, -39, -11, -87,-122, - -116, -66, -6, -6, -6, -6, -6, -37, -38, -9, - -6, -6, -43, -42, -75, -6, -84 -}; - -int bsd_to_linux_signal[LINUX_SIGTBLSZ] = { - LINUX_SIGHUP, LINUX_SIGINT, LINUX_SIGQUIT, LINUX_SIGILL, - LINUX_SIGTRAP, LINUX_SIGABRT, 0, LINUX_SIGFPE, - LINUX_SIGKILL, LINUX_SIGBUS, LINUX_SIGSEGV, LINUX_SIGSYS, - LINUX_SIGPIPE, LINUX_SIGALRM, LINUX_SIGTERM, LINUX_SIGURG, - LINUX_SIGSTOP, LINUX_SIGTSTP, LINUX_SIGCONT, LINUX_SIGCHLD, - LINUX_SIGTTIN, LINUX_SIGTTOU, LINUX_SIGIO, LINUX_SIGXCPU, - LINUX_SIGXFSZ, LINUX_SIGVTALRM, LINUX_SIGPROF, LINUX_SIGWINCH, - 0, LINUX_SIGUSR1, LINUX_SIGUSR2 -}; - -int linux_to_bsd_signal[LINUX_SIGTBLSZ] = { - SIGHUP, SIGINT, SIGQUIT, SIGILL, - SIGTRAP, SIGABRT, SIGBUS, SIGFPE, - SIGKILL, SIGUSR1, SIGSEGV, SIGUSR2, - SIGPIPE, SIGALRM, SIGTERM, SIGBUS, - SIGCHLD, SIGCONT, SIGSTOP, SIGTSTP, - SIGTTIN, SIGTTOU, SIGURG, SIGXCPU, - SIGXFSZ, SIGVTALRM, SIGPROF, SIGWINCH, - SIGIO, SIGURG, SIGSYS -}; - -#define LINUX_T_UNKNOWN 255 -static int _bsd_to_linux_trapcode[] = { - LINUX_T_UNKNOWN, /* 0 */ - 6, /* 1 T_PRIVINFLT */ - LINUX_T_UNKNOWN, /* 2 */ - 3, /* 3 T_BPTFLT */ - LINUX_T_UNKNOWN, /* 4 */ - LINUX_T_UNKNOWN, /* 5 */ - 16, /* 6 T_ARITHTRAP */ - 254, /* 7 T_ASTFLT */ - LINUX_T_UNKNOWN, /* 8 */ - 13, /* 9 T_PROTFLT */ - 1, /* 10 T_TRCTRAP */ - LINUX_T_UNKNOWN, /* 11 */ - 14, /* 12 T_PAGEFLT */ - LINUX_T_UNKNOWN, /* 13 */ - 17, /* 14 T_ALIGNFLT */ - LINUX_T_UNKNOWN, /* 15 */ - LINUX_T_UNKNOWN, /* 16 */ - LINUX_T_UNKNOWN, /* 17 */ - 0, /* 18 T_DIVIDE */ - 2, /* 19 T_NMI */ - 4, /* 20 T_OFLOW */ - 5, /* 21 T_BOUND */ - 7, /* 22 T_DNA */ - 8, /* 23 T_DOUBLEFLT */ - 9, /* 24 T_FPOPFLT */ - 10, /* 25 T_TSSFLT */ - 11, /* 26 T_SEGNPFLT */ - 12, /* 27 T_STKFLT */ - 18, /* 28 T_MCHK */ - 19, /* 29 T_XMMFLT */ - 15 /* 30 T_RESERVED */ -}; -#define bsd_to_linux_trapcode(code) \ - ((code)args->argc + 1); - (*stack_base)--; - **stack_base = (intptr_t)(void *)envp; - (*stack_base)--; - **stack_base = (intptr_t)(void *)argv; - (*stack_base)--; - **stack_base = imgp->args->argc; - return 0; -} - -static int -elf_linux_fixup(register_t **stack_base, struct image_params *imgp) -{ - Elf32_Auxargs *args = (Elf32_Auxargs *)imgp->auxargs; - register_t *pos; - - pos = *stack_base + (imgp->args->argc + imgp->args->envc + 2); - - if (args->execfd != -1) { - AUXARGS_ENTRY(pos, AT_EXECFD, args->execfd); - } - AUXARGS_ENTRY(pos, AT_PHDR, args->phdr); - AUXARGS_ENTRY(pos, AT_PHENT, args->phent); - AUXARGS_ENTRY(pos, AT_PHNUM, args->phnum); - AUXARGS_ENTRY(pos, AT_PAGESZ, args->pagesz); - AUXARGS_ENTRY(pos, AT_FLAGS, args->flags); - AUXARGS_ENTRY(pos, AT_ENTRY, args->entry); - AUXARGS_ENTRY(pos, AT_BASE, args->base); - AUXARGS_ENTRY(pos, AT_UID, imgp->proc->p_ucred->cr_ruid); - AUXARGS_ENTRY(pos, AT_EUID, imgp->proc->p_ucred->cr_svuid); - AUXARGS_ENTRY(pos, AT_GID, imgp->proc->p_ucred->cr_rgid); - AUXARGS_ENTRY(pos, AT_EGID, imgp->proc->p_ucred->cr_svgid); - AUXARGS_ENTRY(pos, AT_NULL, 0); - - kfree(imgp->auxargs, M_TEMP); - imgp->auxargs = NULL; - - (*stack_base)--; - **stack_base = (long)imgp->args->argc; - return 0; -} - -extern int _ucodesel, _udatasel; -extern unsigned long linux_sznonrtsigcode; - -static void -linux_rt_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) -{ - struct proc *p = curproc; - struct lwp *lp = curthread->td_lwp; - struct trapframe *regs; - struct l_rt_sigframe *fp, frame; - int oonstack; - - regs = lp->lwp_md.md_regs; - oonstack = lp->lwp_sigstk.ss_flags & SS_ONSTACK; - -#ifdef DEBUG - if (ldebug(rt_sendsig)) - kprintf(ARGS(rt_sendsig, "%p, %d, %p, %lu"), - catcher, sig, (void*)mask, code); -#endif - /* - * Allocate space for the signal handler context. - */ - if ((lp->lwp_flags & LWP_ALTSTACK) && !oonstack && - SIGISMEMBER(p->p_sigacts->ps_sigonstack, sig)) { - fp = (struct l_rt_sigframe *)(lp->lwp_sigstk.ss_sp + - lp->lwp_sigstk.ss_size - sizeof(struct l_rt_sigframe)); - lp->lwp_sigstk.ss_flags |= SS_ONSTACK; - } else - fp = (struct l_rt_sigframe *)regs->tf_esp - 1; - - /* - * grow() will return FALSE if the fp will not fit inside the stack - * and the stack can not be grown. useracc will return FALSE - * if access is denied. - */ - if ((vm_map_growstack(p, (vm_offset_t)fp) != KERN_SUCCESS) || - !useracc((caddr_t)fp, sizeof (struct l_rt_sigframe), - VM_PROT_WRITE)) { - /* - * Process has trashed its stack; give it an illegal - * instruction to halt it in its tracks. - */ - SIGACTION(p, SIGILL) = SIG_DFL; - SIGDELSET(p->p_sigignore, SIGILL); - SIGDELSET(p->p_sigcatch, SIGILL); - SIGDELSET(lp->lwp_sigmask, SIGILL); -#ifdef DEBUG - if (ldebug(rt_sendsig)) - kprintf(LMSG("rt_sendsig: bad stack %p, oonstack=%x"), - fp, oonstack); -#endif - lwpsignal(p, lp, SIGILL); - return; - } - - /* - * Build the argument list for the signal handler. - */ - if (p->p_sysent->sv_sigtbl) - if (sig <= p->p_sysent->sv_sigsize) - sig = p->p_sysent->sv_sigtbl[_SIG_IDX(sig)]; - - frame.sf_handler = catcher; - frame.sf_sig = sig; - frame.sf_siginfo = &fp->sf_si; - frame.sf_ucontext = &fp->sf_sc; - - /* Fill siginfo structure. */ - frame.sf_si.lsi_signo = sig; - frame.sf_si.lsi_code = code; - frame.sf_si.lsi_addr = (void *)regs->tf_err; - - /* - * Build the signal context to be used by sigreturn. - */ - frame.sf_sc.uc_flags = 0; /* XXX ??? */ - frame.sf_sc.uc_link = NULL; /* XXX ??? */ - - frame.sf_sc.uc_stack.ss_sp = lp->lwp_sigstk.ss_sp; - frame.sf_sc.uc_stack.ss_size = lp->lwp_sigstk.ss_size; - frame.sf_sc.uc_stack.ss_flags = (lp->lwp_flags & LWP_ALTSTACK) - ? ((oonstack) ? LINUX_SS_ONSTACK : 0) : LINUX_SS_DISABLE; - - bsd_to_linux_sigset(mask, &frame.sf_sc.uc_sigmask); - - frame.sf_sc.uc_mcontext.sc_mask = frame.sf_sc.uc_sigmask.__bits[0]; - frame.sf_sc.uc_mcontext.sc_gs = regs->tf_gs; - frame.sf_sc.uc_mcontext.sc_fs = regs->tf_fs; - frame.sf_sc.uc_mcontext.sc_es = regs->tf_es; - frame.sf_sc.uc_mcontext.sc_ds = regs->tf_ds; - frame.sf_sc.uc_mcontext.sc_edi = regs->tf_edi; - frame.sf_sc.uc_mcontext.sc_esi = regs->tf_esi; - frame.sf_sc.uc_mcontext.sc_ebp = regs->tf_ebp; - frame.sf_sc.uc_mcontext.sc_ebx = regs->tf_ebx; - frame.sf_sc.uc_mcontext.sc_edx = regs->tf_edx; - frame.sf_sc.uc_mcontext.sc_ecx = regs->tf_ecx; - frame.sf_sc.uc_mcontext.sc_eax = regs->tf_eax; - frame.sf_sc.uc_mcontext.sc_eip = regs->tf_eip; - frame.sf_sc.uc_mcontext.sc_cs = regs->tf_cs; - frame.sf_sc.uc_mcontext.sc_eflags = regs->tf_eflags; - frame.sf_sc.uc_mcontext.sc_esp_at_signal = regs->tf_esp; - frame.sf_sc.uc_mcontext.sc_ss = regs->tf_ss; - frame.sf_sc.uc_mcontext.sc_err = regs->tf_err; - frame.sf_sc.uc_mcontext.sc_trapno = bsd_to_linux_trapcode(code); - -#ifdef DEBUG - if (ldebug(rt_sendsig)) - kprintf(LMSG("rt_sendsig flags: 0x%x, sp: %p, ss: 0x%x, mask: 0x%x"), - frame.sf_sc.uc_stack.ss_flags, lp->lwp_sigstk.ss_sp, - lp->lwp_sigstk.ss_size, frame.sf_sc.uc_mcontext.sc_mask); -#endif - - if (copyout(&frame, fp, sizeof(frame)) != 0) { - /* - * Process has trashed its stack; give it an illegal - * instruction to halt it in its tracks. - */ - sigexit(lp, SIGILL); - /* NOTREACHED */ - } - - /* - * Build context to run handler in. - */ - regs->tf_esp = (int)fp; - regs->tf_eip = PS_STRINGS - *(p->p_sysent->sv_szsigcode) + - linux_sznonrtsigcode; - - /* - * i386 abi specifies that the direction flag must be cleared - * on function entry - */ - regs->tf_eflags &= ~(PSL_T | PSL_VM | PSL_D); - - regs->tf_cs = _ucodesel; - regs->tf_ds = _udatasel; - regs->tf_es = _udatasel; - /* allow %fs and %gs to be inherited by the signal handler */ - /* - regs->tf_fs = _udatasel; - regs->tf_gs = _udatasel; - */ - regs->tf_ss = _udatasel; - clear_quickret(); -} - - -/* - * Send an interrupt to process. - * - * Stack is set up to allow sigcode stored - * in u. to call routine, followed by kcall - * to sigreturn routine below. After sigreturn - * resets the signal mask, the stack, and the - * frame pointer, it returns to the user - * specified pc, psl. - */ - -static void -linux_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) -{ - struct proc *p = curproc; - struct lwp *lp = curthread->td_lwp; - struct trapframe *regs; - struct l_sigframe *fp, frame; - l_sigset_t lmask; - int oonstack, i; - - if (SIGISMEMBER(p->p_sigacts->ps_siginfo, sig)) { - /* Signal handler installed with SA_SIGINFO. */ - linux_rt_sendsig(catcher, sig, mask, code); - return; - } - - regs = lp->lwp_md.md_regs; - oonstack = lp->lwp_sigstk.ss_flags & SS_ONSTACK; - -#ifdef DEBUG - if (ldebug(sendsig)) - kprintf(ARGS(sendsig, "%p, %d, %p, %lu"), - catcher, sig, (void*)mask, code); -#endif - - /* - * Allocate space for the signal handler context. - */ - if ((lp->lwp_flags & LWP_ALTSTACK) && !oonstack && - SIGISMEMBER(p->p_sigacts->ps_sigonstack, sig)) { - fp = (struct l_sigframe *)(lp->lwp_sigstk.ss_sp + - lp->lwp_sigstk.ss_size - sizeof(struct l_sigframe)); - lp->lwp_sigstk.ss_flags |= SS_ONSTACK; - } else - fp = (struct l_sigframe *)regs->tf_esp - 1; - - /* - * grow() will return FALSE if the fp will not fit inside the stack - * and the stack can not be grown. useracc will return FALSE - * if access is denied. - */ - if ((vm_map_growstack(p, (vm_offset_t)fp) != KERN_SUCCESS) || - !useracc((caddr_t)fp, sizeof (struct l_sigframe), - VM_PROT_WRITE)) { - /* - * Process has trashed its stack; give it an illegal - * instruction to halt it in its tracks. - */ - SIGACTION(p, SIGILL) = SIG_DFL; - SIGDELSET(p->p_sigignore, SIGILL); - SIGDELSET(p->p_sigcatch, SIGILL); - SIGDELSET(lp->lwp_sigmask, SIGILL); - lwpsignal(p, lp, SIGILL); - return; - } - - /* - * Build the argument list for the signal handler. - */ - if (p->p_sysent->sv_sigtbl) - if (sig <= p->p_sysent->sv_sigsize) - sig = p->p_sysent->sv_sigtbl[_SIG_IDX(sig)]; - - frame.sf_handler = catcher; - frame.sf_sig = sig; - - bsd_to_linux_sigset(mask, &lmask); - - /* - * Build the signal context to be used by sigreturn. - */ - frame.sf_sc.sc_mask = lmask.__bits[0]; - frame.sf_sc.sc_gs = regs->tf_gs; - frame.sf_sc.sc_fs = regs->tf_fs; - frame.sf_sc.sc_es = regs->tf_es; - frame.sf_sc.sc_ds = regs->tf_ds; - frame.sf_sc.sc_edi = regs->tf_edi; - frame.sf_sc.sc_esi = regs->tf_esi; - frame.sf_sc.sc_ebp = regs->tf_ebp; - frame.sf_sc.sc_ebx = regs->tf_ebx; - frame.sf_sc.sc_edx = regs->tf_edx; - frame.sf_sc.sc_ecx = regs->tf_ecx; - frame.sf_sc.sc_eax = regs->tf_eax; - frame.sf_sc.sc_eip = regs->tf_eip; - frame.sf_sc.sc_cs = regs->tf_cs; - frame.sf_sc.sc_eflags = regs->tf_eflags; - frame.sf_sc.sc_esp_at_signal = regs->tf_esp; - frame.sf_sc.sc_ss = regs->tf_ss; - frame.sf_sc.sc_err = regs->tf_err; - frame.sf_sc.sc_trapno = bsd_to_linux_trapcode(code); - - bzero(&frame.sf_fpstate, sizeof(struct l_fpstate)); - - for (i = 0; i < (LINUX_NSIG_WORDS-1); i++) - frame.sf_extramask[i] = lmask.__bits[i+1]; - - if (copyout(&frame, fp, sizeof(frame)) != 0) { - /* - * Process has trashed its stack; give it an illegal - * instruction to halt it in its tracks. - */ - sigexit(lp, SIGILL); - /* NOTREACHED */ - } - - /* - * Build context to run handler in. - */ - regs->tf_esp = (int)fp; - regs->tf_eip = PS_STRINGS - *(p->p_sysent->sv_szsigcode); - - /* - * i386 abi specifies that the direction flag must be cleared - * on function entry - */ - regs->tf_eflags &= ~(PSL_T | PSL_VM | PSL_D); - - regs->tf_cs = _ucodesel; - regs->tf_ds = _udatasel; - regs->tf_es = _udatasel; - /* Allow %fs and %gs to be inherited by the signal handler */ - /* - regs->tf_fs = _udatasel; - regs->tf_gs = _udatasel; - */ - regs->tf_ss = _udatasel; - clear_quickret(); -} - -/* - * System call to cleanup state after a signal - * has been taken. Reset signal mask and - * stack state from context left by sendsig (above). - * Return to previous pc and psl as specified by - * context left by sendsig. Check carefully to - * make sure that the user has not modified the - * psl to gain improper privileges or to cause - * a machine fault. - * - * MPSAFE - */ -int -sys_linux_sigreturn(struct linux_sigreturn_args *args) -{ - struct lwp *lp = curthread->td_lwp; - struct l_sigframe frame; - struct trapframe *regs; - l_sigset_t lmask; - int eflags, i; - - regs = lp->lwp_md.md_regs; - -#ifdef DEBUG - if (ldebug(sigreturn)) - kprintf(ARGS(sigreturn, "%p"), (void *)args->sfp); -#endif - /* - * The trampoline code hands us the sigframe. - * It is unsafe to keep track of it ourselves, in the event that a - * program jumps out of a signal handler. - */ - if (copyin((caddr_t)args->sfp, &frame, sizeof(frame)) != 0) - return (EFAULT); - - /* - * Check for security violations. - */ -#define EFLAGS_SECURE(ef, oef) ((((ef) ^ (oef)) & ~PSL_USERCHANGE) == 0) - eflags = frame.sf_sc.sc_eflags; - /* - * XXX do allow users to change the privileged flag PSL_RF. The - * cpu sets PSL_RF in tf_eflags for faults. Debuggers should - * sometimes set it there too. tf_eflags is kept in the signal - * context during signal handling and there is no other place - * to remember it, so the PSL_RF bit may be corrupted by the - * signal handler without us knowing. Corruption of the PSL_RF - * bit at worst causes one more or one less debugger trap, so - * allowing it is fairly harmless. - */ - if (!EFLAGS_SECURE(eflags & ~PSL_RF, regs->tf_eflags & ~PSL_RF)) { - return(EINVAL); - } - - /* - * Don't allow users to load a valid privileged %cs. Let the - * hardware check for invalid selectors, excess privilege in - * other selectors, invalid %eip's and invalid %esp's. - */ -#define CS_SECURE(cs) (ISPL(cs) == SEL_UPL) - if (!CS_SECURE(frame.sf_sc.sc_cs)) { - trapsignal(lp, SIGBUS, T_PROTFLT); - return(EINVAL); - } - - lp->lwp_sigstk.ss_flags &= ~SS_ONSTACK; - lmask.__bits[0] = frame.sf_sc.sc_mask; - for (i = 0; i < (LINUX_NSIG_WORDS-1); i++) - lmask.__bits[i+1] = frame.sf_extramask[i]; - linux_to_bsd_sigset(&lmask, &lp->lwp_sigmask); - SIG_CANTMASK(lp->lwp_sigmask); - - /* - * Restore signal context. - */ - /* %gs was restored by the trampoline. */ - regs->tf_fs = frame.sf_sc.sc_fs; - regs->tf_es = frame.sf_sc.sc_es; - regs->tf_ds = frame.sf_sc.sc_ds; - regs->tf_edi = frame.sf_sc.sc_edi; - regs->tf_esi = frame.sf_sc.sc_esi; - regs->tf_ebp = frame.sf_sc.sc_ebp; - regs->tf_ebx = frame.sf_sc.sc_ebx; - regs->tf_edx = frame.sf_sc.sc_edx; - regs->tf_ecx = frame.sf_sc.sc_ecx; - regs->tf_eax = frame.sf_sc.sc_eax; - regs->tf_eip = frame.sf_sc.sc_eip; - regs->tf_cs = frame.sf_sc.sc_cs; - regs->tf_eflags = eflags; - regs->tf_esp = frame.sf_sc.sc_esp_at_signal; - regs->tf_ss = frame.sf_sc.sc_ss; - clear_quickret(); - - return (EJUSTRETURN); -} - -/* - * System call to cleanup state after a signal - * has been taken. Reset signal mask and - * stack state from context left by rt_sendsig (above). - * Return to previous pc and psl as specified by - * context left by sendsig. Check carefully to - * make sure that the user has not modified the - * psl to gain improper privileges or to cause - * a machine fault. - * - * MPSAFE - */ -int -sys_linux_rt_sigreturn(struct linux_rt_sigreturn_args *args) -{ - struct lwp *lp = curthread->td_lwp; - struct l_ucontext uc; - struct l_sigcontext *context; - l_stack_t *lss; - stack_t ss; - struct trapframe *regs; - int eflags; - - regs = lp->lwp_md.md_regs; - -#ifdef DEBUG - if (ldebug(rt_sigreturn)) - kprintf(ARGS(rt_sigreturn, "%p"), (void *)args->ucp); -#endif - /* - * The trampoline code hands us the ucontext. - * It is unsafe to keep track of it ourselves, in the event that a - * program jumps out of a signal handler. - */ - if (copyin((caddr_t)args->ucp, &uc, sizeof(uc)) != 0) - return (EFAULT); - - context = &uc.uc_mcontext; - - /* - * Check for security violations. - */ -#define EFLAGS_SECURE(ef, oef) ((((ef) ^ (oef)) & ~PSL_USERCHANGE) == 0) - eflags = context->sc_eflags; - /* - * XXX do allow users to change the privileged flag PSL_RF. The - * cpu sets PSL_RF in tf_eflags for faults. Debuggers should - * sometimes set it there too. tf_eflags is kept in the signal - * context during signal handling and there is no other place - * to remember it, so the PSL_RF bit may be corrupted by the - * signal handler without us knowing. Corruption of the PSL_RF - * bit at worst causes one more or one less debugger trap, so - * allowing it is fairly harmless. - */ - if (!EFLAGS_SECURE(eflags & ~PSL_RF, regs->tf_eflags & ~PSL_RF)) { - return(EINVAL); - } - - /* - * Don't allow users to load a valid privileged %cs. Let the - * hardware check for invalid selectors, excess privilege in - * other selectors, invalid %eip's and invalid %esp's. - */ -#define CS_SECURE(cs) (ISPL(cs) == SEL_UPL) - if (!CS_SECURE(context->sc_cs)) { - trapsignal(lp, SIGBUS, T_PROTFLT); - return(EINVAL); - } - - lp->lwp_sigstk.ss_flags &= ~SS_ONSTACK; - linux_to_bsd_sigset(&uc.uc_sigmask, &lp->lwp_sigmask); - SIG_CANTMASK(lp->lwp_sigmask); - - /* - * Restore signal context - */ - /* %gs was restored by the trampoline. */ - regs->tf_fs = context->sc_fs; - regs->tf_es = context->sc_es; - regs->tf_ds = context->sc_ds; - regs->tf_edi = context->sc_edi; - regs->tf_esi = context->sc_esi; - regs->tf_ebp = context->sc_ebp; - regs->tf_ebx = context->sc_ebx; - regs->tf_edx = context->sc_edx; - regs->tf_ecx = context->sc_ecx; - regs->tf_eax = context->sc_eax; - regs->tf_eip = context->sc_eip; - regs->tf_cs = context->sc_cs; - regs->tf_eflags = eflags; - regs->tf_esp = context->sc_esp_at_signal; - regs->tf_ss = context->sc_ss; - - /* - * call sigaltstack & ignore results.. - */ - lss = &uc.uc_stack; - ss.ss_sp = lss->ss_sp; - ss.ss_size = lss->ss_size; - ss.ss_flags = linux_to_bsd_sigaltstack(lss->ss_flags); - -#ifdef DEBUG - if (ldebug(rt_sigreturn)) - kprintf(LMSG("rt_sigret flags: 0x%x, sp: %p, ss: 0x%x, mask: 0x%x"), - ss.ss_flags, ss.ss_sp, ss.ss_size, context->sc_mask); -#endif - kern_sigaltstack(&ss, NULL); - clear_quickret(); - - return (EJUSTRETURN); -} - -/* - * Prep arguments. - * - * MUST BE MPSAFE - */ -static void -linux_prepsyscall(struct trapframe *tf, int *args, u_int *code, caddr_t *params) -{ - args[0] = tf->tf_ebx; - args[1] = tf->tf_ecx; - args[2] = tf->tf_edx; - args[3] = tf->tf_esi; - args[4] = tf->tf_edi; - args[5] = tf->tf_ebp; - *params = NULL; /* no copyin */ -} - -/* - * If a linux binary is exec'ing something, try this image activator - * first. We override standard shell script execution in order to - * be able to modify the interpreter path. We only do this if a linux - * binary is doing the exec, so we do not create an EXEC module for it. - */ -static int exec_linux_imgact_try (struct image_params *iparams); - -static int -exec_linux_imgact_try(struct image_params *imgp) -{ - const char *head = (const char *)imgp->image_header; - int error = -1; - - /* - * The interpreter for shell scripts run from a linux binary needs - * to be located in /compat/linux if possible in order to recursively - * maintain linux path emulation. - */ - if (((const short *)head)[0] == SHELLMAGIC) { - /* - * Run our normal shell image activator. If it succeeds attempt - * to use the alternate path for the interpreter. If an alternate - * path is found, use our stringspace to store it. - */ - if ((error = exec_shell_imgact(imgp)) == 0) { - linux_translate_path(imgp->interpreter_name, - MAXSHELLCMDLEN); - } - } - return(error); -} - -struct sysentvec linux_sysvec = { - .sv_size = LINUX_SYS_MAXSYSCALL, - .sv_table = linux_sysent, - .sv_mask = 0xffffffff, - .sv_sigsize = LINUX_SIGTBLSZ, - .sv_sigtbl = bsd_to_linux_signal, - .sv_errsize = ELAST + 1, - .sv_errtbl = bsd_to_linux_errno, - .sv_transtrap = translate_traps, - .sv_fixup = linux_fixup, - .sv_sendsig = linux_sendsig, - .sv_sigcode = linux_sigcode, - .sv_szsigcode = &linux_szsigcode, - .sv_prepsyscall = linux_prepsyscall, - .sv_name = "Linux a.out", - .sv_coredump = NULL, - .sv_imgact_try = exec_linux_imgact_try, - .sv_minsigstksz = LINUX_MINSIGSTKSZ -}; - -struct sysentvec elf_linux_sysvec = { - .sv_size = LINUX_SYS_MAXSYSCALL, - .sv_table = linux_sysent, - .sv_mask = 0xffffffff, - .sv_sigsize = LINUX_SIGTBLSZ, - .sv_sigtbl = bsd_to_linux_signal, - .sv_errsize = ELAST + 1, - .sv_errtbl = bsd_to_linux_errno, - .sv_transtrap = translate_traps, - .sv_fixup = elf_linux_fixup, - .sv_sendsig = linux_sendsig, - .sv_sigcode = linux_sigcode, - .sv_szsigcode = &linux_szsigcode, - .sv_prepsyscall = linux_prepsyscall, - .sv_name = "Linux ELF32", - .sv_coredump = elf32_coredump, - .sv_imgact_try = exec_linux_imgact_try, - .sv_minsigstksz = LINUX_MINSIGSTKSZ -}; - -static const char GNU_ABI_VENDOR[] = "GNU"; -static const char SUSE_ABI_VENDOR[] = "SuSE"; -static int GNULINUX_ABI_DESC = 0; - -static boolean_t -linux_trans_osrel(const Elf_Note *note, int32_t *osrel) -{ - const Elf32_Word *desc; - uintptr_t p; - - p = (uintptr_t)(note + 1); - p += roundup2(note->n_namesz, sizeof(Elf32_Addr)); - - desc = (const Elf32_Word *)p; - if (desc[0] != GNULINUX_ABI_DESC) - return (FALSE); - /* - * For Linux we encode osrel as follows: - * VVVMMMIII (version, major, minor) - */ - *osrel = desc[1] * 1000000 + - desc[2] * 1000 + - desc[3]; - - return (TRUE); -} - -static Elf_Brandnote linux32_generic_brandnote = { - .hdr.n_namesz = sizeof(GNU_ABI_VENDOR), - .hdr.n_descsz = 16, - .hdr.n_type = 1, - .vendor = GNU_ABI_VENDOR, - .flags = BN_TRANSLATE_OSREL, - .trans_osrel = linux_trans_osrel, -}; - -static Elf_Brandnote linux32_suse_brandnote = { - .hdr.n_namesz = sizeof(SUSE_ABI_VENDOR), - .hdr.n_descsz = 16, - .hdr.n_type = 1, - .vendor = SUSE_ABI_VENDOR, - .flags = BN_TRANSLATE_OSREL, - .trans_osrel = linux_trans_osrel, -}; - -static Elf32_Brandinfo linux32_brand = { - .brand = ELFOSABI_LINUX, - .machine = EM_386, - .compat_3_brand = "Linux", - .emul_path = "/compat/linux", - .interp_path = "/lib/ld-linux.so.1", - .sysvec = &elf_linux_sysvec, - .interp_newpath = NULL, - .flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE, - .brand_note = &linux32_generic_brandnote, -}; - -static Elf32_Brandinfo linux32_glibc2_brand = { - .brand = ELFOSABI_LINUX, - .machine = EM_386, - .compat_3_brand = "Linux", - .emul_path = "/compat/linux", - .interp_path = "/lib/ld-linux.so.2", - .sysvec = &elf_linux_sysvec, - .interp_newpath = NULL, - .flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE, - .brand_note = &linux32_generic_brandnote, -}; - -static Elf32_Brandinfo linux32_suse_brand = { - .brand = ELFOSABI_LINUX, - .machine = EM_386, - .compat_3_brand = "Linux", - .emul_path = "/compat/linux", - .interp_path = "/lib/ld-linux.so.2", - .sysvec = &elf_linux_sysvec, - .interp_newpath = NULL, - .flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE, - .brand_note = &linux32_suse_brandnote, -}; - -Elf32_Brandinfo *linux_brandlist[] = { - &linux32_brand, - &linux32_glibc2_brand, - &linux32_suse_brand, - NULL -}; - -static int -linux_elf_modevent(module_t mod, int type, void *data) -{ - Elf32_Brandinfo **brandinfo; - int error; - - error = 0; - - switch(type) { - case MOD_LOAD: - for (brandinfo = &linux_brandlist[0]; *brandinfo != NULL; - ++brandinfo) - if (elf32_insert_brand_entry(*brandinfo) < 0) - error = EINVAL; - if (error == 0) { - if (bootverbose) - kprintf("Linux ELF exec handler installed\n"); - } else { - kprintf("cannot insert Linux ELF brand handler\n"); - } - EMUL_LOCKINIT(); - lockinit(&futex_mtx, "linftxs", 0, LK_CANRECURSE); - linux_exec_tag = EVENTHANDLER_REGISTER(process_exec, linux_proc_transition, - NULL, 1000); - linux_exit_tag = EVENTHANDLER_REGISTER(process_exit, emuldata_exit, - NULL, 1000); - break; - case MOD_UNLOAD: - for (brandinfo = &linux_brandlist[0]; *brandinfo != NULL; - ++brandinfo) - if (elf32_brand_inuse(*brandinfo)) - error = EBUSY; - if (error == 0) { - for (brandinfo = &linux_brandlist[0]; - *brandinfo != NULL; ++brandinfo) - if (elf32_remove_brand_entry(*brandinfo) < 0) - error = EINVAL; - } - if (error == 0) { - if (bootverbose) - kprintf("Linux ELF exec handler removed\n"); - } else { - kprintf("Could not deinstall ELF interpreter entry\n"); - } - EVENTHANDLER_DEREGISTER(process_exec, linux_exec_tag); - EVENTHANDLER_DEREGISTER(process_exit, linux_exit_tag); - lockuninit(&futex_mtx); - EMUL_LOCKUNINIT(); - break; - default: - break; - } - return error; -} - -static moduledata_t linux_elf_mod = { - "linuxelf", - linux_elf_modevent, - 0 -}; - -DECLARE_MODULE(linuxelf, linux_elf_mod, SI_SUB_EXEC, SI_ORDER_ANY); diff --git a/sys/emulation/linux/i386/linux_union.h b/sys/emulation/linux/i386/linux_union.h deleted file mode 100644 index ec3469ea57..0000000000 --- a/sys/emulation/linux/i386/linux_union.h +++ /dev/null @@ -1,251 +0,0 @@ -/* - * Union of syscall args for messaging. - * - * DO NOT EDIT-- To regenerate this file, edit syscalls.master followed - * by running make sysent in the same directory. - */ - -union sysunion { -#ifdef _KERNEL /* header only applies in kernel */ - struct lwkt_msg lmsg; - struct sysmsg sysmsg; -#endif -#define nosys linux_nosys - struct linux_fork_args linux_fork; - struct linux_open_args linux_open; - struct linux_waitpid_args linux_waitpid; - struct linux_creat_args linux_creat; - struct linux_link_args linux_link; - struct linux_unlink_args linux_unlink; - struct linux_execve_args linux_execve; - struct linux_chdir_args linux_chdir; - struct linux_time_args linux_time; - struct linux_mknod_args linux_mknod; - struct linux_chmod_args linux_chmod; - struct linux_lchown16_args linux_lchown16; - struct linux_stat_args linux_stat; - struct linux_lseek_args linux_lseek; - struct linux_getpid_args linux_getpid; - struct linux_mount_args linux_mount; - struct linux_oldumount_args linux_oldumount; - struct linux_setuid16_args linux_setuid16; - struct linux_getuid16_args linux_getuid16; - struct linux_stime_args linux_stime; - struct linux_ptrace_args linux_ptrace; - struct linux_alarm_args linux_alarm; - struct linux_fstat_args linux_fstat; - struct linux_pause_args linux_pause; - struct linux_utime_args linux_utime; - struct linux_access_args linux_access; - struct linux_nice_args linux_nice; - struct linux_kill_args linux_kill; - struct linux_rename_args linux_rename; - struct linux_mkdir_args linux_mkdir; - struct linux_rmdir_args linux_rmdir; - struct linux_pipe_args linux_pipe; - struct linux_times_args linux_times; - struct linux_brk_args linux_brk; - struct linux_setgid16_args linux_setgid16; - struct linux_getgid16_args linux_getgid16; - struct linux_signal_args linux_signal; - struct linux_geteuid16_args linux_geteuid16; - struct linux_getegid16_args linux_getegid16; - struct linux_umount_args linux_umount; - struct linux_ioctl_args linux_ioctl; - struct linux_fcntl_args linux_fcntl; - struct linux_olduname_args linux_olduname; - struct linux_ustat_args linux_ustat; - struct linux_getppid_args linux_getppid; - struct linux_sigaction_args linux_sigaction; - struct linux_sgetmask_args linux_sgetmask; - struct linux_ssetmask_args linux_ssetmask; - struct linux_setreuid16_args linux_setreuid16; - struct linux_setregid16_args linux_setregid16; - struct linux_sigsuspend_args linux_sigsuspend; - struct linux_sigpending_args linux_sigpending; - struct linux_sethostname_args linux_sethostname; - struct linux_setrlimit_args linux_setrlimit; - struct linux_old_getrlimit_args linux_old_getrlimit; - struct linux_getgroups16_args linux_getgroups16; - struct linux_setgroups16_args linux_setgroups16; - struct linux_old_select_args linux_old_select; - struct linux_symlink_args linux_symlink; - struct linux_ostat_args linux_ostat; - struct linux_readlink_args linux_readlink; - struct linux_uselib_args linux_uselib; - struct linux_reboot_args linux_reboot; - struct linux_readdir_args linux_readdir; - struct linux_mmap_args linux_mmap; - struct linux_truncate_args linux_truncate; - struct linux_ftruncate_args linux_ftruncate; - struct linux_statfs_args linux_statfs; - struct linux_fstatfs_args linux_fstatfs; - struct linux_ioperm_args linux_ioperm; - struct linux_socketcall_args linux_socketcall; - struct linux_syslog_args linux_syslog; - struct linux_setitimer_args linux_setitimer; - struct linux_getitimer_args linux_getitimer; - struct linux_newstat_args linux_newstat; - struct linux_newlstat_args linux_newlstat; - struct linux_newfstat_args linux_newfstat; - struct linux_uname_args linux_uname; - struct linux_iopl_args linux_iopl; - struct linux_vhangup_args linux_vhangup; - struct linux_vm86old_args linux_vm86old; - struct linux_wait4_args linux_wait4; - struct linux_swapoff_args linux_swapoff; - struct linux_sysinfo_args linux_sysinfo; - struct linux_ipc_args linux_ipc; - struct linux_sigreturn_args linux_sigreturn; - struct linux_clone_args linux_clone; - struct linux_newuname_args linux_newuname; - struct linux_modify_ldt_args linux_modify_ldt; - struct linux_adjtimex_args linux_adjtimex; - struct linux_sigprocmask_args linux_sigprocmask; - struct linux_create_module_args linux_create_module; - struct linux_init_module_args linux_init_module; - struct linux_delete_module_args linux_delete_module; - struct linux_get_kernel_syms_args linux_get_kernel_syms; - struct linux_quotactl_args linux_quotactl; - struct linux_bdflush_args linux_bdflush; - struct linux_sysfs_args linux_sysfs; - struct linux_personality_args linux_personality; - struct linux_setfsuid16_args linux_setfsuid16; - struct linux_setfsgid16_args linux_setfsgid16; - struct linux_llseek_args linux_llseek; - struct linux_getdents_args linux_getdents; - struct linux_select_args linux_select; - struct linux_msync_args linux_msync; - struct linux_getsid_args linux_getsid; - struct linux_fdatasync_args linux_fdatasync; - struct linux_sysctl_args linux_sysctl; - struct linux_sched_setscheduler_args linux_sched_setscheduler; - struct linux_sched_getscheduler_args linux_sched_getscheduler; - struct linux_sched_get_priority_max_args linux_sched_get_priority_max; - struct linux_sched_get_priority_min_args linux_sched_get_priority_min; - struct linux_mremap_args linux_mremap; - struct linux_setresuid16_args linux_setresuid16; - struct linux_getresuid16_args linux_getresuid16; - struct linux_vm86_args linux_vm86; - struct linux_query_module_args linux_query_module; - struct linux_nfsservctl_args linux_nfsservctl; - struct linux_setresgid16_args linux_setresgid16; - struct linux_getresgid16_args linux_getresgid16; - struct linux_prctl_args linux_prctl; - struct linux_rt_sigreturn_args linux_rt_sigreturn; - struct linux_rt_sigaction_args linux_rt_sigaction; - struct linux_rt_sigprocmask_args linux_rt_sigprocmask; - struct linux_rt_sigpending_args linux_rt_sigpending; - struct linux_rt_sigtimedwait_args linux_rt_sigtimedwait; - struct linux_rt_sigqueueinfo_args linux_rt_sigqueueinfo; - struct linux_rt_sigsuspend_args linux_rt_sigsuspend; - struct linux_pread_args linux_pread; - struct linux_pwrite_args linux_pwrite; - struct linux_chown16_args linux_chown16; - struct linux_getcwd_args linux_getcwd; - struct linux_capget_args linux_capget; - struct linux_capset_args linux_capset; - struct linux_sigaltstack_args linux_sigaltstack; - struct linux_sendfile_args linux_sendfile; - struct linux_vfork_args linux_vfork; - struct linux_getrlimit_args linux_getrlimit; - struct linux_mmap2_args linux_mmap2; - struct linux_truncate64_args linux_truncate64; - struct linux_ftruncate64_args linux_ftruncate64; - struct linux_stat64_args linux_stat64; - struct linux_lstat64_args linux_lstat64; - struct linux_fstat64_args linux_fstat64; - struct linux_lchown_args linux_lchown; - struct linux_getuid_args linux_getuid; - struct linux_getgid_args linux_getgid; - struct linux_getgroups_args linux_getgroups; - struct linux_setgroups_args linux_setgroups; - struct linux_chown_args linux_chown; - struct linux_setfsuid_args linux_setfsuid; - struct linux_setfsgid_args linux_setfsgid; - struct linux_pivot_root_args linux_pivot_root; - struct linux_mincore_args linux_mincore; - struct linux_madvise_args linux_madvise; - struct linux_getdents64_args linux_getdents64; - struct linux_fcntl64_args linux_fcntl64; - struct linux_gettid_args linux_gettid; - struct linux_setxattr_args linux_setxattr; - struct linux_lsetxattr_args linux_lsetxattr; - struct linux_fsetxattr_args linux_fsetxattr; - struct linux_getxattr_args linux_getxattr; - struct linux_lgetxattr_args linux_lgetxattr; - struct linux_fgetxattr_args linux_fgetxattr; - struct linux_listxattr_args linux_listxattr; - struct linux_llistxattr_args linux_llistxattr; - struct linux_flistxattr_args linux_flistxattr; - struct linux_removexattr_args linux_removexattr; - struct linux_lremovexattr_args linux_lremovexattr; - struct linux_fremovexattr_args linux_fremovexattr; - struct linux_tkill_args linux_tkill; - struct linux_sys_futex_args linux_sys_futex; - struct linux_sched_setaffinity_args linux_sched_setaffinity; - struct linux_sched_getaffinity_args linux_sched_getaffinity; - struct linux_set_thread_area_args linux_set_thread_area; - struct linux_get_thread_area_args linux_get_thread_area; - struct linux_fadvise64_args linux_fadvise64; - struct linux_exit_group_args linux_exit_group; - struct linux_epoll_create_args linux_epoll_create; - struct linux_epoll_ctl_args linux_epoll_ctl; - struct linux_epoll_wait_args linux_epoll_wait; - struct linux_set_tid_address_args linux_set_tid_address; - struct linux_clock_settime_args linux_clock_settime; - struct linux_clock_gettime_args linux_clock_gettime; - struct linux_clock_getres_args linux_clock_getres; - struct linux_clock_nanosleep_args linux_clock_nanosleep; - struct linux_statfs64_args linux_statfs64; - struct linux_fstatfs64_args linux_fstatfs64; - struct linux_tgkill_args linux_tgkill; - struct linux_utimes_args linux_utimes; - struct linux_fadvise64_64_args linux_fadvise64_64; - struct linux_mbind_args linux_mbind; - struct linux_get_mempolicy_args linux_get_mempolicy; - struct linux_set_mempolicy_args linux_set_mempolicy; - struct linux_mq_open_args linux_mq_open; - struct linux_mq_getsetattr_args linux_mq_getsetattr; - struct linux_kexec_load_args linux_kexec_load; - struct linux_waitid_args linux_waitid; - struct linux_add_key_args linux_add_key; - struct linux_request_key_args linux_request_key; - struct linux_keyctl_args linux_keyctl; - struct linux_ioprio_set_args linux_ioprio_set; - struct linux_ioprio_get_args linux_ioprio_get; - struct linux_inotify_init_args linux_inotify_init; - struct linux_inotify_add_watch_args linux_inotify_add_watch; - struct linux_inotify_rm_watch_args linux_inotify_rm_watch; - struct linux_migrate_pages_args linux_migrate_pages; - struct linux_openat_args linux_openat; - struct linux_mkdirat_args linux_mkdirat; - struct linux_mknodat_args linux_mknodat; - struct linux_fchownat_args linux_fchownat; - struct linux_futimesat_args linux_futimesat; - struct linux_fstatat64_args linux_fstatat64; - struct linux_unlinkat_args linux_unlinkat; - struct linux_renameat_args linux_renameat; - struct linux_linkat_args linux_linkat; - struct linux_symlinkat_args linux_symlinkat; - struct linux_readlinkat_args linux_readlinkat; - struct linux_fchmodat_args linux_fchmodat; - struct linux_faccessat_args linux_faccessat; - struct linux_pselect6_args linux_pselect6; - struct linux_ppoll_args linux_ppoll; - struct linux_unshare_args linux_unshare; - struct linux_set_robust_list_args linux_set_robust_list; - struct linux_get_robust_list_args linux_get_robust_list; - struct linux_splice_args linux_splice; - struct linux_sync_file_range_args linux_sync_file_range; - struct linux_tee_args linux_tee; - struct linux_vmsplice_args linux_vmsplice; - struct linux_move_pages_args linux_move_pages; - struct linux_getcpu_args linux_getcpu; - struct linux_epoll_pwait_args linux_epoll_pwait; - struct linux_utimensat_args linux_utimensat; - struct linux_signalfd_args linux_signalfd; - struct linux_timerfd_args linux_timerfd; - struct linux_eventfd_args linux_eventfd; - struct linux_pipe2_args linux_pipe2; -}; diff --git a/sys/emulation/linux/i386/syscalls.conf b/sys/emulation/linux/i386/syscalls.conf deleted file mode 100644 index b641dfa4b7..0000000000 --- a/sys/emulation/linux/i386/syscalls.conf +++ /dev/null @@ -1,12 +0,0 @@ -# $FreeBSD: src/sys/i386/linux/syscalls.conf,v 1.5 1999/08/28 00:45:25 peter Exp $ -sysnames="/dev/null" -sysproto="linux_proto.h" -sysunion="linux_union.h" -sysproto_h=_LINUX_SYSPROTO_H_ -syshdr="linux_syscall.h" -syssw="linux_sysent.c" -sysmk="/dev/null" -sysargs="/dev/null" -syscallprefix="LINUX_SYS_" -switchname="linux_sysent" -namesname="linux_syscallnames" diff --git a/sys/emulation/linux/i386/syscalls.master b/sys/emulation/linux/i386/syscalls.master deleted file mode 100644 index 9fff31ba3b..0000000000 --- a/sys/emulation/linux/i386/syscalls.master +++ /dev/null @@ -1,488 +0,0 @@ -; @(#)syscalls.master 8.1 (Berkeley) 7/19/93 -; $FreeBSD: src/sys/i386/linux/syscalls.master,v 1.30.2.8 2003/01/02 20:41:33 kan Exp $ -; System call name/number master file (or rather, slave, from LINUX). -; Processed to create linux_sysent.c, linux_proto.h and linux_syscall.h. - -; Columns: number type nargs namespc name alt{name,tag,rtyp}/comments -; number system call number, must be in order -; type one of STD, OBSOL, UNIMPL, COMPAT -; name psuedo-prototype of syscall routine -; If one of the following alts is different, then all appear: -; altname name of system call if different -; alttag name of args struct tag if different from [o]`name'"_args" -; altrtyp return type if not int (bogus - syscalls always return int) -; for UNIMPL/OBSOL, name continues with comments - -; types: -; STD always included -; COMPAT included on COMPAT #ifdef -; LIBCOMPAT included on COMPAT #ifdef, and placed in syscall.h -; OBSOL obsolete, not included in system, only specifies name -; UNIMPL not implemented, placeholder only - -#include "opt_compat.h" -#include -#include -#include -#include -#include "linux.h" -#include "linux_proto.h" - -#include - -; Isn't pretty, but there seems to be no other way to trap nosys -#define nosys linux_nosys - -; #ifdef's, etc. may be included, and are copied to the output files. - -0 UNIMPL setup -1 NOPROTO { void exit(int rval); } -2 STD { int linux_fork(void); } -3 NOPROTO { int read(int fd, char *buf, u_int nbyte); } -4 NOPROTO { int write(int fd, char *buf, u_int nbyte); } -5 STD { int linux_open(char *path, l_int flags, \ - l_int mode); } -6 NOPROTO { int close(int fd); } -7 STD { int linux_waitpid(l_pid_t pid, l_int *status, \ - l_int options); } -8 STD { int linux_creat(char *path, l_int mode); } -9 STD { int linux_link(char *path, char *to); } -10 STD { int linux_unlink(char *path); } -11 STD { int linux_execve(char *path, char **argp, \ - char **envp); } -12 STD { int linux_chdir(char *path); } -13 STD { int linux_time(l_time_t *tm); } -14 STD { int linux_mknod(char *path, l_int mode, \ - l_dev_t dev); } -15 STD { int linux_chmod(char *path, l_mode_t mode); } -16 STD { int linux_lchown16(char *path, l_uid16_t uid, \ - l_gid16_t gid); } -17 UNIMPL break -18 STD { int linux_stat(char *path, struct ostat *statbuf); } -19 STD { int linux_lseek(l_uint fdes, l_off_t off, \ - l_int whence); } -20 STD { int linux_getpid(void); } -21 STD { int linux_mount(char *specialfile, char *dir, \ - char *filesystemtype, l_ulong rwflag, \ - void *data); } -22 STD { int linux_oldumount(char *path); } -23 STD { int linux_setuid16(l_uid16_t uid); } -24 STD { int linux_getuid16(void); } -25 STD { int linux_stime(void); } -26 STD { int linux_ptrace(l_long req, l_long pid, l_long addr, \ - l_long data); } -27 STD { int linux_alarm(l_uint secs); } -28 STD { int linux_fstat(l_uint fd, struct ostat *up); } -29 STD { int linux_pause(void); } -30 STD { int linux_utime(char *fname, \ - struct l_utimbuf *times); } -31 UNIMPL stty -32 UNIMPL gtty -33 STD { int linux_access(char *path, l_int flags); } -34 STD { int linux_nice(l_int inc); } -35 UNIMPL ftime -36 NOPROTO { int sync(void); } -37 STD { int linux_kill(l_int pid, l_int signum); } -38 STD { int linux_rename(char *from, char *to); } -39 STD { int linux_mkdir(char *path, l_int mode); } -40 STD { int linux_rmdir(char *path); } -41 NOPROTO { int dup(u_int fd); } -42 STD { int linux_pipe(l_ulong *pipefds); } -43 STD { int linux_times(struct l_times_argv *buf); } -44 UNIMPL prof -45 STD { int linux_brk(l_ulong dsend); } -46 STD { int linux_setgid16(l_gid16_t gid); } -47 STD { int linux_getgid16(void); } -48 STD { int linux_signal(l_int sig, l_handler_t handler); } -49 STD { int linux_geteuid16(void); } -50 STD { int linux_getegid16(void); } -51 NOPROTO { int acct(char *path); } -52 STD { int linux_umount(char *path, l_int flags); } -53 UNIMPL lock -54 STD { int linux_ioctl(l_uint fd, l_uint cmd, \ - l_ulong arg); } -55 STD { int linux_fcntl(l_uint fd, l_uint cmd, \ - l_ulong arg); } -56 UNIMPL mpx -57 NOPROTO { int setpgid(int pid, int pgid); } -58 UNIMPL ulimit -59 STD { int linux_olduname(void); } -60 NOPROTO { int umask(int newmask); } -61 NOPROTO { int chroot(char *path); } -62 STD { int linux_ustat(l_dev_t dev, struct l_ustat *ubuf); } -63 NOPROTO { int dup2(u_int from, u_int to); } -64 STD { int linux_getppid(void); } -65 NOPROTO { int getpgrp(void); } -66 NOPROTO { int setsid(void); } -67 STD { int linux_sigaction(l_int sig, l_osigaction_t *nsa, \ - l_osigaction_t *osa); } -68 STD { int linux_sgetmask(void); } -69 STD { int linux_ssetmask(l_osigset_t mask); } -70 STD { int linux_setreuid16(l_uid16_t ruid, \ - l_uid16_t euid); } -71 STD { int linux_setregid16(l_gid16_t rgid, \ - l_gid16_t egid); } -72 STD { int linux_sigsuspend(l_int hist0, l_int hist1, \ - l_osigset_t mask); } -73 STD { int linux_sigpending(l_osigset_t *mask); } -74 STD { int linux_sethostname(char *hostname, u_int len); } -75 STD { int linux_setrlimit(l_uint resource, \ - struct l_rlimit *rlim); } -76 STD { int linux_old_getrlimit(l_uint resource, \ - struct l_rlimit *rlim); } -77 NOPROTO { int getrusage(int who, struct rusage *rusage); } -78 NOPROTO { int gettimeofday(struct timeval *tp, \ - struct timezone *tzp); } -79 NOPROTO { int settimeofday(struct timeval *tp, \ - struct timezone *tzp); } -80 STD { int linux_getgroups16(l_uint gidsetsize, \ - l_gid16_t *gidset); } -81 STD { int linux_setgroups16(l_uint gidsetsize, \ - l_gid16_t *gidset); } -82 STD { int linux_old_select(struct l_old_select_argv \ - *ptr); } -83 STD { int linux_symlink(char *path, char *to); } -84 STD { int linux_ostat(char *path, struct ostat *statbuf); } -85 STD { int linux_readlink(char *name, char *buf, \ - l_int count); } -86 STD { int linux_uselib(char *library); } -87 NOPROTO { int swapon(char *name); } -88 STD { int linux_reboot(l_int magic1, l_int magic2, \ - l_uint cmd, void *arg); } -89 STD { int linux_readdir(l_uint fd, struct l_dirent *dent, \ - l_uint count); } -90 STD { int linux_mmap(struct l_mmap_argv *ptr); } -91 NOPROTO { int munmap(caddr_t addr, int len); } -92 STD { int linux_truncate(char *path, l_ulong length); } -93 STD { int linux_ftruncate(int fd, long length); } -94 NOPROTO { int fchmod(int fd, int mode); } -95 NOPROTO { int fchown(int fd, int uid, int gid); } -96 NOPROTO { int getpriority(int which, int who); } -97 NOPROTO { int setpriority(int which, int who, int prio); } -98 UNIMPL profil -99 STD { int linux_statfs(char *path, \ - struct l_statfs_buf *buf); } -100 STD { int linux_fstatfs(l_uint fd, \ - struct l_statfs_buf *buf); } -101 STD { int linux_ioperm(l_ulong start, l_ulong length, \ - l_int enable); } -102 STD { int linux_socketcall(l_int what, l_ulong args); } -103 STD { int linux_syslog(l_int type, char *buf, l_int len); } -104 STD { int linux_setitimer(l_int which, \ - struct l_itimerval *itv, \ - struct l_itimerval *oitv); } -105 STD { int linux_getitimer(l_int which, \ - struct l_itimerval *itv); } -106 STD { int linux_newstat(char *path, \ - struct l_newstat *buf); } -107 STD { int linux_newlstat(char *path, \ - struct l_newstat *buf); } -108 STD { int linux_newfstat(l_uint fd, \ - struct l_newstat *buf); } -109 STD { int linux_uname(void); } -110 STD { int linux_iopl(l_ulong level); } -111 STD { int linux_vhangup(void); } -112 UNIMPL idle -113 STD { int linux_vm86old(void); } -114 STD { int linux_wait4(l_pid_t pid, l_uint *status, \ - l_int options, struct l_rusage *rusage); } -115 STD { int linux_swapoff(void); } -116 STD { int linux_sysinfo(struct l_sysinfo *info); } -117 STD { int linux_ipc(l_uint what, l_int arg1, l_int arg2, \ - l_int arg3, void *ptr, l_long arg5); } -118 NOPROTO { int fsync(int fd); } -119 STD { int linux_sigreturn(struct l_sigframe *sfp); } -120 STD { int linux_clone(l_int flags, void *stack, \ - void *parent_tidptr, int dummy, void *child_tidptr); } -121 NOPROTO { int setdomainname(char *name, int len); } -122 STD { int linux_newuname(struct l_new_utsname *buf); } -123 STD { int linux_modify_ldt(l_int func, void *ptr, \ - l_ulong bytecount); } -124 STD { int linux_adjtimex(void); } -125 NOPROTO { int mprotect(caddr_t addr, int len, int prot); } -126 STD { int linux_sigprocmask(l_int how, l_osigset_t *mask, \ - l_osigset_t *omask); } -127 STD { int linux_create_module(void); } -128 STD { int linux_init_module(void); } -129 STD { int linux_delete_module(void); } -130 STD { int linux_get_kernel_syms(void); } -131 STD { int linux_quotactl(void); } -132 NOPROTO { int getpgid(int pid); } -133 NOPROTO { int fchdir(int fd); } -134 STD { int linux_bdflush(void); } -135 STD { int linux_sysfs(l_int option, l_ulong arg1, \ - l_ulong arg2); } -136 STD { int linux_personality(l_ulong per); } -137 UNIMPL afs_syscall -138 STD { int linux_setfsuid16(l_uid16_t uid); } -139 STD { int linux_setfsgid16(l_gid16_t gid); } -140 STD { int linux_llseek(l_int fd, l_ulong ohigh, \ - l_ulong olow, l_loff_t *res, l_uint whence); } -141 STD { int linux_getdents(l_uint fd, void *dent, \ - l_uint count); } -142 STD { int linux_select(l_int nfds, l_fd_set *readfds, \ - l_fd_set *writefds, l_fd_set *exceptfds, \ - struct l_timeval *timeout); } -143 NOPROTO { int flock(int fd, int how); } -144 STD { int linux_msync(l_ulong addr, l_size_t len, \ - l_int fl); } -145 NOPROTO { int readv(int fd, struct iovec *iovp, \ - u_int iovcnt); } -146 NOPROTO { int writev(int fd, struct iovec *iovp, \ - u_int iovcnt); } -147 STD { int linux_getsid(l_pid_t pid); } -148 STD { int linux_fdatasync(l_uint fd); } -149 STD { int linux_sysctl(struct l___sysctl_args *args); } -150 NOPROTO { int mlock(const void *addr, size_t len); } -151 NOPROTO { int munlock(const void *addr, size_t len); } -152 NOPROTO { int mlockall(int how); } -153 NOPROTO { int munlockall(void); } -154 NOPROTO { int sched_setparam(pid_t pid, \ - const struct sched_param *param); } -155 NOPROTO { int sched_getparam(pid_t pid, \ - struct sched_param *param); } -156 STD { int linux_sched_setscheduler(l_pid_t pid, \ - l_int policy, struct l_sched_param *param); } -157 STD { int linux_sched_getscheduler(l_pid_t pid); } -158 NOPROTO { int sched_yield(void); } -159 STD { int linux_sched_get_priority_max(l_int policy); } -160 STD { int linux_sched_get_priority_min(l_int policy); } -161 NOPROTO { int sched_rr_get_interval(l_pid_t pid, \ - struct l_timespec *interval); } -162 NOPROTO { int nanosleep(const struct timespec *rqtp, \ - struct timespec *rmtp); } -163 STD { int linux_mremap(l_ulong addr, l_ulong old_len, \ - l_ulong new_len, l_ulong flags, \ - l_ulong new_addr); } -164 STD { int linux_setresuid16(l_uid16_t ruid, \ - l_uid16_t euid, l_uid16_t suid); } -165 STD { int linux_getresuid16(l_uid16_t *ruid, \ - l_uid16_t *euid, l_uid16_t *suid); } -166 STD { int linux_vm86(void); } -167 STD { int linux_query_module(void); } -168 NOPROTO { int poll(struct pollfd*, unsigned int nfds, \ - long timeout); } -169 STD { int linux_nfsservctl(void); } -170 STD { int linux_setresgid16(l_gid16_t rgid, \ - l_gid16_t egid, l_gid16_t sgid); } -171 STD { int linux_getresgid16(l_gid16_t *rgid, \ - l_gid16_t *egid, l_gid16_t *sgid); } -172 STD { int linux_prctl(void); } -173 STD { int linux_rt_sigreturn(struct l_ucontext *ucp); } -174 STD { int linux_rt_sigaction(l_int sig, \ - l_sigaction_t *act, l_sigaction_t *oact, \ - l_size_t sigsetsize); } -175 STD { int linux_rt_sigprocmask(l_int how, \ - l_sigset_t *mask, l_sigset_t *omask, \ - l_size_t sigsetsize); } -176 STD { int linux_rt_sigpending(void); } -177 STD { int linux_rt_sigtimedwait(void); } -178 STD { int linux_rt_sigqueueinfo(void); } -179 STD { int linux_rt_sigsuspend(l_sigset_t *newset, \ - l_size_t sigsetsize); } -180 STD { int linux_pread(l_uint fd, char *buf, \ - l_size_t nbyte, l_loff_t offset); } -181 STD { int linux_pwrite(l_uint fd, char *buf, \ - l_size_t nbyte, l_loff_t offset); } -182 STD { int linux_chown16(char *path, l_uid16_t uid, \ - l_gid16_t gid); } -183 STD { int linux_getcwd(char *buf, l_ulong bufsize); } -184 STD { int linux_capget(void); } -185 STD { int linux_capset(void); } -186 STD { int linux_sigaltstack(l_stack_t *uss, \ - l_stack_t *uoss); } -187 STD { int linux_sendfile(void); } -188 UNIMPL getpmsg -189 UNIMPL putpmsg -190 STD { int linux_vfork(void); } -191 STD { int linux_getrlimit(l_uint resource, \ - struct l_rlimit *rlim); } -192 STD { int linux_mmap2(l_ulong addr, l_ulong len, \ - l_ulong prot, l_ulong flags, l_ulong fd, \ - l_ulong pgoff); } -193 STD { int linux_truncate64(char *path, l_loff_t length); } -194 STD { int linux_ftruncate64(l_uint fd, l_loff_t length); } -195 STD { int linux_stat64(char *filename, \ - struct l_stat64 *statbuf, l_long flags); } -196 STD { int linux_lstat64(char *filename, \ - struct l_stat64 *statbuf, l_long flags); } -197 STD { int linux_fstat64(l_ulong fd, \ - struct l_stat64 *statbuf, l_long flags); } -198 STD { int linux_lchown(char *path, l_uid_t uid, \ - l_gid_t gid); } -199 STD { int linux_getuid(void); } -200 STD { int linux_getgid(void); } -201 NOPROTO { int geteuid(void); } -202 NOPROTO { int getegid(void); } -203 NOPROTO { int setreuid(uid_t ruid, uid_t euid); } -204 NOPROTO { int setregid(gid_t rgid, gid_t egid); } -205 STD { int linux_getgroups(l_int gidsetsize, \ - l_gid_t *grouplist); } -206 STD { int linux_setgroups(l_int gidsetsize, \ - l_gid_t *grouplist); } -207 NODEF fchown fchown fchown_args int -208 NOPROTO { int setresuid(uid_t ruid, uid_t euid, uid_t suid); } -209 NOPROTO { int getresuid(uid_t *ruid, uid_t *euid, \ - uid_t *suid); } -210 NOPROTO { int setresgid(gid_t rgid, gid_t egid, gid_t sgid); } -211 NOPROTO { int getresgid(gid_t *rgid, gid_t *egid, \ - gid_t *sgid); } -212 STD { int linux_chown(char *path, l_uid_t uid, \ - l_gid_t gid); } -213 NOPROTO { int setuid(uid_t uid); } -214 NOPROTO { int setgid(gid_t gid); } -215 STD { int linux_setfsuid(l_uid_t uid); } -216 STD { int linux_setfsgid(l_gid_t gid); } -217 STD { int linux_pivot_root(char *new_root, \ - char *put_old); } -218 STD { int linux_mincore(l_ulong start, l_size_t len, \ - u_char *vec); } -219 STD { int linux_madvise(void); } -220 STD { int linux_getdents64(l_uint fd, void *dirent, \ - l_uint count); } -221 STD { int linux_fcntl64(l_uint fd, l_uint cmd, \ - l_ulong arg); } -222 UNIMPL none -223 UNIMPL none -224 STD { int linux_gettid(void); } -225 UNIMPL linux_readahead -226 STD { int linux_setxattr(void); } -227 STD { int linux_lsetxattr(void); } -228 STD { int linux_fsetxattr(void); } -229 STD { int linux_getxattr(void); } -230 STD { int linux_lgetxattr(void); } -231 STD { int linux_fgetxattr(void); } -232 STD { int linux_listxattr(void); } -233 STD { int linux_llistxattr(void); } -234 STD { int linux_flistxattr(void); } -235 STD { int linux_removexattr(void); } -236 STD { int linux_lremovexattr(void); } -237 STD { int linux_fremovexattr(void); } -238 STD { int linux_tkill(int tid, int sig); } -239 UNIMPL linux_sendfile64 -240 STD { int linux_sys_futex(void *uaddr, int op, int val, \ - struct l_timespec *timeout, void *uaddr2, int val3); } -241 STD { int linux_sched_setaffinity(l_pid_t pid, l_uint len, \ - l_ulong *user_mask_ptr); } -242 STD { int linux_sched_getaffinity(l_pid_t pid, l_uint len, \ - l_ulong *user_mask_ptr); } -243 STD { int linux_set_thread_area(struct l_user_desc *desc); } -244 STD { int linux_get_thread_area(struct l_user_desc *desc); } -245 UNIMPL linux_io_setup -246 UNIMPL linux_io_destroy -247 UNIMPL linux_io_getevents -248 UNIMPL linux_io_submit -249 UNIMPL linux_io_cancel -250 STD { int linux_fadvise64(void); } -251 UNIMPL -252 STD { void linux_exit_group(int rval); } -253 UNIMPL linux_lookup_dcookie -254 STD { int linux_epoll_create(l_int size); } -255 STD { int linux_epoll_ctl(l_int epfd, l_int op, l_int fd, \ - struct linux_epoll_event *event); } -256 STD { int linux_epoll_wait(l_int epfd, struct linux_epoll_event *events, \ - l_int maxevents, l_int timeout); } -257 UNIMPL linux_remap_file_pages -258 STD { int linux_set_tid_address(int *tidptr); } -259 UNIMPL linux_timer_create -260 UNIMPL linux_timer_settime -261 UNIMPL linux_timer_gettime -262 UNIMPL linux_timer_getoverrun -263 UNIMPL linux_timer_delete -264 STD { int linux_clock_settime(clockid_t which, struct l_timespec *tp); } -265 STD { int linux_clock_gettime(clockid_t which, struct l_timespec *tp); } -266 STD { int linux_clock_getres(clockid_t which, struct l_timespec *tp); } -267 STD { int linux_clock_nanosleep(clockid_t which, int flags, \ - struct l_timespec *rqtp, struct l_timespec *rmtp); } -268 STD { int linux_statfs64(void); } -269 STD { int linux_fstatfs64(void); } -270 STD { int linux_tgkill(int tgid, int pid, int sig); } -271 STD { int linux_utimes(char *fname, \ - struct l_timeval *tptr); } -272 STD { int linux_fadvise64_64(void); } -273 UNIMPL /* sys_vserver */ -274 STD { int linux_mbind(void); } -275 STD { int linux_get_mempolicy(void); } -276 STD { int linux_set_mempolicy(void); } -277 STD { int linux_mq_open(const char *name, int oflag, mode_t mode, \ - struct mq_attr *attr); } -278 NOPROTO { int mq_unlink(const char *name); } -279 NOPROTO { int mq_timedsend(l_mqd_t mqd, const char *msg_ptr, \ - size_t msg_len, unsigned int msg_prio, const struct \ - l_timespec *abs_timeout); } -280 NOPROTO { int mq_timedreceive(l_mqd_t mqd, char *msg_ptr, \ - size_t msg_len, unsigned int msg_prio, const struct \ - l_timespec *abs_timeout); } -281 NOPROTO { int mq_notify(l_mqd_t mqd, const struct sigevent *notification); } -282 STD { int linux_mq_getsetattr(l_mqd_t mqd, const struct mq_attr *attr, \ - struct mq_attr *oattr); } -283 STD { int linux_kexec_load(void); } -284 STD { int linux_waitid(void); } -285 UNIMPL /* available */ -286 STD { int linux_add_key(void); } -287 STD { int linux_request_key(void); } -288 STD { int linux_keyctl(void); } -289 STD { int linux_ioprio_set(void); } -290 STD { int linux_ioprio_get(void); } -291 STD { int linux_inotify_init(void); } -292 STD { int linux_inotify_add_watch(void); } -293 STD { int linux_inotify_rm_watch(void); } -294 STD { int linux_migrate_pages(void); } -295 STD { int linux_openat(l_int dfd, char *path, \ - l_int flags, l_int mode); } -296 STD { int linux_mkdirat(l_int dfd, char *path, \ - l_int mode); } -297 STD { int linux_mknodat(l_int dfd, char *path, \ - l_int mode, l_uint dev); } -298 STD { int linux_fchownat(l_int dfd, char *filename, \ - l_uid16_t uid, l_gid16_t gid, l_int flag); } -299 STD { int linux_futimesat(l_int dfd, char *fname, \ - struct l_timeval *tptr); } -300 STD { int linux_fstatat64(l_int dfd, char *path, \ - struct l_stat64 *statbuf, l_int flag); } -301 STD { int linux_unlinkat(l_int dfd, char *path, \ - l_int flag); } -302 STD { int linux_renameat(l_int olddfd, char *from, \ - l_int newdfd, char *to); } -303 STD { int linux_linkat(l_int olddfd, char *path, \ - l_int newdfd, char *to, l_int flags); } -304 STD { int linux_symlinkat(char *path, l_int newdfd, \ - char *to); } -305 STD { int linux_readlinkat(l_int dfd, char *path, \ - char *buf, l_int count); } -306 STD { int linux_fchmodat(l_int dfd, char *filename, \ - l_mode_t mode); } -307 STD { int linux_faccessat(l_int dfd, char *filename, l_int mode); } -308 STD { int linux_pselect6(void); } -309 STD { int linux_ppoll(void); } -310 STD { int linux_unshare(void); } -311 STD { int linux_set_robust_list(struct linux_robust_list_head *head, \ - l_size_t len); } -312 STD { int linux_get_robust_list(l_int pid, struct linux_robust_list_head **head, \ - l_size_t *len); } -313 STD { int linux_splice(void); } -314 STD { int linux_sync_file_range(void); } -315 STD { int linux_tee(void); } -316 STD { int linux_vmsplice(void); } -317 STD { int linux_move_pages(void); } -318 STD { int linux_getcpu(l_uint *pcpu, l_uint *pnode, void *ptcache); } -319 STD { int linux_epoll_pwait(void); } -320 STD { int linux_utimensat(l_int dfd, char *fname, \ - struct l_timespec *tptr, l_int flag); } -321 STD { int linux_signalfd(void); } -322 STD { int linux_timerfd(void); } -323 STD { int linux_eventfd(void); } -324 UNIMPL linux_fallocate -325 UNIMPL linux_timerfd_settime -326 UNIMPL linux_timerfd_gettime -327 UNIMPL linux_signalfd4 -328 UNIMPL linux_eventfd2 -329 UNIMPL linux_epoll_create1 -330 UNIMPL linux_dup3 -331 STD { int linux_pipe2(l_ulong *pipefds, l_int flags); } -332 UNIMPL linux_inotify_init1 -333 UNIMPL linux_preadv -334 UNIMPL linux_pwritev -335 UNIMPL linux_rt_tgsigqueueinfo -336 UNIMPL linux_perf_event_open -337 UNIMPL linux_recvmmsg diff --git a/sys/emulation/linux/linux_emuldata.c b/sys/emulation/linux/linux_emuldata.c deleted file mode 100644 index 79cb1805ea..0000000000 --- a/sys/emulation/linux/linux_emuldata.c +++ /dev/null @@ -1,310 +0,0 @@ -/* - * Copyright (c) 2010 The DragonFly Project. All rights reserved. - * - * This code is derived from software contributed to The DragonFly Project - * by Alex Hornung - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of The DragonFly Project nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific, prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 - * COPYRIGHT HOLDERS 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. - */ - -#include "opt_compat.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "i386/linux.h" -#include "i386/linux_proto.h" -#include "linux_signal.h" -#include "linux_util.h" -#include "linux_emuldata.h" - - -struct lock emul_lock; - -struct linux_emuldata * -emuldata_get(struct proc *p) -{ - struct linux_emuldata *em; - - EMUL_LOCK(); - - em = p->p_emuldata; - - EMUL_UNLOCK(); - return (em); -} - -void -emuldata_set_robust(struct proc *p, struct linux_robust_list_head *robust_ftx) -{ - struct linux_emuldata *em; - - EMUL_LOCK(); - - em = emuldata_get(p); - KKASSERT(em != NULL); - - em->robust_futexes = robust_ftx; - EMUL_UNLOCK(); -} - -int -emuldata_init(struct proc *p, struct proc *pchild, int flags) -{ - struct linux_emuldata_shared *s; - struct linux_emuldata *em, *ep; - int error = 0; - - EMUL_LOCK(); - - em = emuldata_get(p); - - if (pchild == NULL) { - ep = NULL; - /* This is the execv* case, where a process gets overwritten */ - KKASSERT(em != NULL); - KKASSERT(em->s != NULL); - if (atomic_fetchadd_int(&em->s->refs, -1) == 1) { - kfree(em->s, M_LINUX); - em->s = NULL; - } - if (em->s) - KKASSERT(em->s->refs >= 0); - - em->parent_tidptr = NULL; - em->child_tidptr = NULL; - em->clone_flags = 0; - em->clear_tid = NULL; - em->set_tls = NULL; - em->proc = p; - } else { - ep = em; - em = kmalloc(sizeof(*em), M_LINUX, M_WAITOK | M_ZERO); - } - - if (flags & LINUX_CLONE_THREAD) { - /* - * If CLONE_THREAD is set, the child is placed in the same - * thread group as the calling process. - */ - KKASSERT(ep != NULL); - em->s = ep->s; - s = em->s; - } else { - /* new thread group */ - s = kmalloc(sizeof(*s), M_LINUX, M_WAITOK | M_ZERO); - LIST_INIT(&s->threads); - if (pchild) - s->group_pid = pchild->p_pid; - else - s->group_pid = p->p_pid; - } - - if (ep != NULL) { - em->parent_tidptr = ep->parent_tidptr; - em->child_tidptr = ep->child_tidptr; -#if 0 - em->clone_flags = ep->clone_flags; -#endif - } - - em->clone_flags = flags; - - atomic_add_int(&s->refs, 1); - KKASSERT(s->refs >= 0); - em->s = s; - LIST_INSERT_HEAD(&s->threads, em, threads); - - - if (pchild != NULL) { - em->proc = pchild; - pchild->p_emuldata = em; - } - - EMUL_UNLOCK(); - return (error); -} - -/* emuldata_exit is modelled after NetBSD's */ -void -emuldata_exit(void *unused, struct proc *p) -{ - struct linux_sys_futex_args cup; - struct linux_emuldata *em; - int error = 0; - - if (__predict_true(p->p_sysent != &elf_linux_sysvec)) - return; - - release_futexes(p); - EMUL_LOCK(); - - em = emuldata_get(p); - if (em == NULL) { - EMUL_UNLOCK(); - return; - } - - LIST_REMOVE(em, threads); - p->p_emuldata = NULL; - - /* - * Members of the thread groups others than the leader should - * exit quietely: no zombie stage, no signal. We do that by - * reparenting to init. init will collect us and nobody will - * notice what happened. - */ - if ((em->s->group_pid != p->p_pid) && - (em->clone_flags & LINUX_CLONE_THREAD)) { - p->p_sigparent = SIGCHLD; - - proc_reparent(p, initproc); - wakeup((caddr_t)initproc); /* kern_exit seems to do this */ - } - - if ((em->s->group_pid == p->p_pid) && - (em->s->flags & LINUX_LES_INEXITGROUP)) { - p->p_xstat = em->s->xstat; - } - - if (atomic_fetchadd_int(&em->s->refs, -1) == 1) { - kfree(em->s, M_LINUX); - em->s = NULL; - } - if (em->s) - KKASSERT(em->s->refs >= 0); - - EMUL_UNLOCK(); - - if (em->clear_tid != NULL) { - int tid = 0; - copyout(&tid, em->clear_tid, sizeof(tid)); - cup.uaddr = em->clear_tid; - cup.op = LINUX_FUTEX_WAKE; - cup.val = 0x7fffffff; /* Awake everyone */ - cup.timeout = NULL; - cup.uaddr2 = NULL; - cup.val3 = 0; - error = sys_linux_sys_futex(&cup); - if (error) - kprintf("emuldata_exit futex stuff failed miserably\n"); - } - - kfree(em, M_LINUX); -} - -void -linux_proc_transition(void *unused, struct image_params *imgp) -{ - struct proc *p; - - p = imgp->proc; - if (__predict_false(imgp->proc->p_sysent == &elf_linux_sysvec && - imgp->proc->p_emuldata == NULL)) { -#ifdef LINUX_DEBUG - kprintf("timidly hello from proc_transition\n"); -#endif - emuldata_init(p, p, 0); - } -} - -static void -linux_proc_userret(void) -{ - struct proc *p = curproc; - struct linux_emuldata *em; - - em = emuldata_get(p); - KKASSERT(em != NULL); - - if (em->clone_flags & LINUX_CLONE_CHILD_SETTID) { - copyout(&p->p_pid, (int *)em->child_tidptr, - sizeof(p->p_pid)); - } - - return; -} - -void -linux_proc_fork(struct proc *p, struct proc *parent, void *child_tidptr) -{ - struct linux_emuldata *em; - - em = emuldata_get(p); - KKASSERT(em != NULL); - - if (child_tidptr != NULL) - em->child_tidptr = child_tidptr; - - /* LINUX_CLONE_CHILD_CLEARTID: clear TID in child's memory on exit() */ - if (em->clone_flags & LINUX_CLONE_CHILD_CLEARTID) - em->clear_tid = em->child_tidptr; - - if (em->clone_flags & LINUX_CLONE_CHILD_SETTID) - p->p_userret = linux_proc_userret; - - return; -} - -int -sys_linux_set_tid_address(struct linux_set_tid_address_args *args) -{ - struct linux_emuldata *em; - - EMUL_LOCK(); - - em = emuldata_get(curproc); - KKASSERT(em != NULL); - - em->clear_tid = args->tidptr; - args->sysmsg_iresult = curproc->p_pid; - - EMUL_UNLOCK(); - return 0; -} diff --git a/sys/emulation/linux/linux_emuldata.h b/sys/emulation/linux/linux_emuldata.h deleted file mode 100644 index 61d39972b1..0000000000 --- a/sys/emulation/linux/linux_emuldata.h +++ /dev/null @@ -1,101 +0,0 @@ -/* $NetBSD: linux_emuldata.h,v 1.16 2008/10/26 16:38:22 christos Exp $ */ - -/*- - * Copyright (c) 1998,2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Eric Haszlakiewicz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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. - */ - -#include "linux_futex.h" - -#ifndef _SYS_LOCK_H -#include -#endif - -#ifndef _COMMON_LINUX_EMULDATA_H -#define _COMMON_LINUX_EMULDATA_H - -/* - * This is auxillary data the linux compat code - * needs to do its work. A pointer to it is - * stored in the emuldata field of the proc - * structure. - */ -struct linux_emuldata_shared { - void * p_break; /* Processes' idea of break */ - int refs; - pid_t group_pid; /* PID of Linux process (group of threads) */ - /* List of Linux threads (NetBSD processes) in the Linux process */ - LIST_HEAD(, linux_emuldata) threads; - int flags; /* See below */ - int xstat; /* Thread group exit code, for exit_group */ -}; - -#define LINUX_LES_INEXITGROUP 0x1 /* thread group doing exit_group() */ -#define LINUX_LES_USE_NPTL 0x2 /* Need to emulate NPTL threads */ - -struct linux_emuldata { -#if 0 /* notyet */ - sigset_t ps_siginfo; /* Which signals have a RT handler */ -#endif - int debugreg[8]; /* GDB information for ptrace - for use, */ - /* see ../arch/i386/linux_ptrace.c */ - struct linux_emuldata_shared *s; - - void *parent_tidptr; /* Used during clone() */ - void *child_tidptr; /* Used during clone() */ - int clone_flags; /* Used during clone() */ - int flags; - void *clear_tid; /* Own TID to clear on exit */ - void *set_tls; /* Pointer to child TLS desc in user space */ - - struct linux_robust_list_head *robust_futexes; - - /* List of Linux threads (NetBSD processes) in the Linux process */ - LIST_ENTRY(linux_emuldata) threads; - struct proc *proc; /* backpointer to struct proc */ -}; - -#define EMUL_DIDKILL 0x01 - -#define LINUX_CHILD_QUIETEXIT 0x1 /* Child will have quietexit set */ -#define LINUX_QUIETEXIT 0x2 /* Quiet exit (no zombie state) */ - -#define EMUL_LOCKINIT(x) lockinit(&emul_lock, "tux_emul", 0, LK_CANRECURSE) -#define EMUL_LOCKUNINIT(x) lockuninit(&emul_lock) - -#define EMUL_LOCK(x) lockmgr(&emul_lock, LK_EXCLUSIVE) -#define EMUL_UNLOCK(x) lockmgr(&emul_lock, LK_RELEASE) - -extern struct lock emul_lock; - -struct linux_emuldata *emuldata_get(struct proc *p); -void emuldata_set_robust(struct proc *p, struct linux_robust_list_head *robust_ftx); -int emuldata_init(struct proc *p, struct proc *pchild, int flags); -void emuldata_exit(void *unused, struct proc *p); -void linux_proc_transition(void *unused, struct image_params *imgp); -void linux_proc_fork(struct proc *p, struct proc *parent, void *child_tidptr); -#endif /* !_COMMON_LINUX_EMULDATA_H */ diff --git a/sys/emulation/linux/linux_epoll.c b/sys/emulation/linux/linux_epoll.c deleted file mode 100644 index 767a8786f5..0000000000 --- a/sys/emulation/linux/linux_epoll.c +++ /dev/null @@ -1,282 +0,0 @@ -/*- - * Copyright (c) 2007 Roman Divacky - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 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. - */ - -#include "opt_compat.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "i386/linux.h" -#include "i386/linux_proto.h" -#include "linux_signal.h" -#include "linux_util.h" -#include "linux_epoll.h" - - -/* Create a new epoll file descriptor. */ -int -sys_linux_epoll_create(struct linux_epoll_create_args *args) -{ - struct kqueue_args k_args; - - if (args->size <= 0) - return (EINVAL); - /* args->size is unused. Linux ignores it as well. */ - - return (sys_kqueue(&k_args)); -} - -/* Structure converting function from epoll to kevent. */ -static void -linux_epoll_to_kevent(int fd, struct linux_epoll_event *event, struct kevent *kevent) -{ - int filter = 0; - int flags = kevent->flags; - - if (event->events & LINUX_EPOLLIN) - filter |= EVFILT_READ; - if (event->events & LINUX_EPOLLOUT) - filter |= EVFILT_WRITE; - if (event->events & LINUX_EPOLLPRI) - filter |= EVFILT_READ; - if (event->events & LINUX_EPOLLET) - flags |= EV_CLEAR; - if (event->events & LINUX_EPOLLONESHOT) - flags |= EV_ONESHOT; - - EV_SET(kevent, fd, filter, flags, 0, 0, NULL); -} - -/* - * Structure converting function from kevent to epoll. In a case - * this is called on error in registration we store the error in - * event->data and pick it up later in linux_epoll_ctl(). - */ -static void -linux_kevent_to_epoll(struct kevent *kevent, struct linux_epoll_event *event) -{ - if (kevent->flags & EV_ERROR) { - event->data = kevent->data; - return; - } - switch (kevent->filter) { - case EVFILT_READ: - if (kevent->data > 0) - event->events = LINUX_EPOLLIN; - event->data = kevent->ident; - break; - case EVFILT_WRITE: - if (kevent->data > 0) - event->events = LINUX_EPOLLOUT; - event->data = kevent->ident; - break; - } -} - -/* - * Copyout callback used by kevent. This converts kevent - * events to epoll events and copies them back to the - * userspace. This is also called on error on registering - * of the filter. - */ -static int -linux_kev_copyout(void *arg, struct kevent *kevp, int count, int *res) -{ - struct kevent_args *uap; - struct linux_epoll_event *eep; - int error, i; - - uap = (struct kevent_args*) arg; - - eep = kmalloc(sizeof(*eep) * count, M_TEMP, M_WAITOK | M_ZERO); - - for (i = 0; i < count; i++) { - linux_kevent_to_epoll(&kevp[i], &eep[i]); - } - - error = copyout(eep, uap->eventlist, count * sizeof(*eep)); - if (error == 0) { - uap->eventlist = (struct kevent *)((char *)uap->eventlist + count * sizeof(*eep)); - *res += count; - } - - kfree(eep, M_TEMP); - return (error); -} - -/* - * Copyin callback used by kevent. This copies already - * converted filters to the kevent internal memory. - */ -static int -linux_kev_copyin(void *arg, struct kevent *kevp, int maxevents, int *events) -{ - struct kevent_args *uap; - - uap = (struct kevent_args*) arg; - - memcpy(kevp, uap->changelist, maxevents * sizeof(*kevp)); - - uap->changelist += maxevents; - *events = maxevents; - - return (0); -} - -/* - * Load epoll filter, convert it to kevent filter - * and load it into kevent subsystem. - */ -int -sys_linux_epoll_ctl(struct linux_epoll_ctl_args *args) -{ - struct thread *td = curthread; - struct proc *p = td->td_proc; - struct kevent_args k_args; - struct kevent kev; - struct kqueue *kq; - struct linux_epoll_event le; - struct file *fp = NULL; - int error; - - error = copyin(args->event, &le, sizeof(le)); - if (error) - return (error); -#ifdef DEBUG - if (ldebug(epoll_ctl)) - kprintf(ARGS(epoll_ctl,"%i, %i, %i, %u"), args->epfd, args->op, - args->fd, le.events); -#endif - k_args.fd = args->epfd; - k_args.changelist = &kev; - /* The epoll can register only 1 filter at once. */ - k_args.nchanges = 1; - k_args.eventlist = NULL; - k_args.nevents = 0; - k_args.timeout = NULL; - - switch (args->op) { - case LINUX_EPOLL_CTL_ADD: - kev.flags = EV_ADD | EV_ENABLE; - break; - case LINUX_EPOLL_CTL_MOD: - /* TODO: DELETE && ADD maybe? */ - return (EINVAL); - break; - case LINUX_EPOLL_CTL_DEL: - kev.flags = EV_DELETE | EV_DISABLE; - break; - } - linux_epoll_to_kevent(args->fd, &le, &kev); - - fp = holdfp(p->p_fd, args->epfd, -1); - if (fp == NULL) - return (EBADF); - if (fp->f_type != DTYPE_KQUEUE) { - fdrop(fp); - return (EBADF); - } - - kq = (struct kqueue *)fp->f_data; - - error = kern_kevent(kq, 0, &k_args.sysmsg_result, &k_args, - linux_kev_copyin, linux_kev_copyout, NULL, 0); - /* Check if there was an error during registration. */ - if (error == 0 && k_args.sysmsg_result != 0) { - /* The copyout callback stored the error there. */ - error = le.data; - } - - fdrop(fp); - return (error); -} - -/* - * Wait for a filter to be triggered on the epoll file descriptor. */ -int -sys_linux_epoll_wait(struct linux_epoll_wait_args *args) -{ - struct thread *td = curthread; - struct proc *p = td->td_proc; - struct timespec ts; - struct kqueue *kq; - struct file *fp = NULL; - struct kevent_args k_args; - int error; - - /* Convert from milliseconds to timespec. */ - ts.tv_sec = args->timeout / 1000; - ts.tv_nsec = (args->timeout % 1000) * 1000 * 1000; - - k_args.fd = args->epfd; - k_args.changelist = NULL; - k_args.nchanges = 0; - /* - * We don't mind the bogus type-cast because - * our copyout function knows about this and - * handles it correctly. - */ - k_args.eventlist = (struct kevent *)args->events; - k_args.nevents = args->maxevents; - k_args.timeout = &ts; - - fp = holdfp(p->p_fd, args->epfd, -1); - if (fp == NULL) - return (EBADF); - if (fp->f_type != DTYPE_KQUEUE) { - fdrop(fp); - return (EBADF); - } - - kq = (struct kqueue *)fp->f_data; - - error = kern_kevent(kq, args->maxevents, &args->sysmsg_result, - &k_args, linux_kev_copyin, linux_kev_copyout, &ts, 0); - - fdrop(fp); - /* translation? */ - return (error); -} diff --git a/sys/emulation/linux/linux_epoll.h b/sys/emulation/linux/linux_epoll.h deleted file mode 100644 index a5797ee291..0000000000 --- a/sys/emulation/linux/linux_epoll.h +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * Copyright (c) 2007 Roman Divacky - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 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. - * - * $FreeBSD$ - */ - -#ifndef _LINUX_EPOLL_H_ -#define _LINUX_EPOLL_H_ - -#ifdef __x86_64__ -#define EPOLL_PACKED __packed -#else -#define EPOLL_PACKED -#endif - -struct linux_epoll_event { - uint32_t events; - uint64_t data; -} EPOLL_PACKED; - -#define LINUX_EPOLLIN 0x001 -#define LINUX_EPOLLPRI 0x002 -#define LINUX_EPOLLOUT 0x004 -#define LINUX_EPOLLONESHOT (1 << 30) -#define LINUX_EPOLLET (1 << 31) - -#define LINUX_EPOLL_CTL_ADD 1 -#define LINUX_EPOLL_CTL_DEL 2 -#define LINUX_EPOLL_CTL_MOD 3 - -#define LINUX_MAX_EVENTS (INT_MAX / sizeof(struct linux_epoll_event)) - -#endif /* !_LINUX_EPOLL_H_ */ diff --git a/sys/emulation/linux/linux_file.c b/sys/emulation/linux/linux_file.c deleted file mode 100644 index 5e3a160310..0000000000 --- a/sys/emulation/linux/linux_file.c +++ /dev/null @@ -1,1697 +0,0 @@ -/*- - * Copyright (c) 1994-1995 Søren Schmidt - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer - * in this position and unchanged. - * 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 - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD: src/sys/compat/linux/linux_file.c,v 1.41.2.6 2003/01/06 09:19:43 fjoe Exp $ - */ - -#include "opt_compat.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include -#include -#include "linux_util.h" - -/* - * MPALMOSTSAFE - */ -int -sys_linux_creat(struct linux_creat_args *args) -{ - struct nlookupdata nd; - char *path; - int error; - - error = linux_copyin_path(args->path, &path, LINUX_PATH_CREATE); - if (error) - return (error); -#ifdef DEBUG - if (ldebug(creat)) - kprintf(ARGS(creat, "%s, %d"), path, args->mode); -#endif - error = nlookup_init(&nd, path, UIO_SYSSPACE, NLC_FOLLOW); - if (error == 0) { - error = kern_open(&nd, O_WRONLY | O_CREAT | O_TRUNC, - args->mode, &args->sysmsg_iresult); - } - linux_free_path(&path); - return(error); -} - -/* - * MPALMOSTSAFE - */ -static int -linux_open_common(int dfd, char *lpath, int lflags, int mode, int *iresult) -{ - struct thread *td = curthread; - struct proc *p = td->td_proc; - struct nlookupdata nd; - struct file *fp; - char *path; - int error, flags; - - if (lflags & LINUX_O_CREAT) { - error = linux_copyin_path(lpath, &path, - LINUX_PATH_CREATE); - } else { - error = linux_copyin_path(lpath, &path, - LINUX_PATH_EXISTS); - } - if (error) - return (error); - - flags = 0; - if (lflags & LINUX_O_RDONLY) - flags |= O_RDONLY; - if (lflags & LINUX_O_WRONLY) - flags |= O_WRONLY; - if (lflags & LINUX_O_RDWR) - flags |= O_RDWR; - if (lflags & LINUX_O_NDELAY) - flags |= O_NONBLOCK; - if (lflags & LINUX_O_APPEND) - flags |= O_APPEND; - if (lflags & LINUX_O_SYNC) - flags |= O_FSYNC; - if (lflags & LINUX_O_NONBLOCK) - flags |= O_NONBLOCK; - if (lflags & LINUX_FASYNC) - flags |= O_ASYNC; - if (lflags & LINUX_O_CREAT) - flags |= O_CREAT; - if (lflags & LINUX_O_TRUNC) - flags |= O_TRUNC; - if (lflags & LINUX_O_EXCL) - flags |= O_EXCL; - if (lflags & LINUX_O_NOCTTY) - flags |= O_NOCTTY; - - error = nlookup_init_at(&nd, &fp, dfd, path, UIO_SYSSPACE, NLC_FOLLOW); - if (error == 0) { - error = kern_open(&nd, flags, mode, iresult); - } - nlookup_done_at(&nd, fp); - - if (error == 0 && !(flags & O_NOCTTY) && - SESS_LEADER(p) && !(p->p_flags & P_CONTROLT)) { - struct file *fp; - - fp = holdfp(p->p_fd, *iresult, -1); - if (fp) { - if (fp->f_type == DTYPE_VNODE) { - fo_ioctl(fp, TIOCSCTTY, NULL, - td->td_ucred, NULL); - } - fdrop(fp); - } - } - - if (error == 0 && lflags & LINUX_O_DIRECTORY) { - struct file *fp; - struct vnode *vp; - - fp = holdfp(p->p_fd, *iresult, -1); - if (fp) { - vp = (struct vnode *) fp->f_data; - if (vp->v_type != VDIR) - error = ENOTDIR; - fdrop(fp); - - if (error) - kern_close(*iresult); - } - } - - linux_free_path(&path); - return error; -} - -int -sys_linux_open(struct linux_open_args *args) -{ - int error; - -#ifdef DEBUG - if (ldebug(open)) - kprintf(ARGS(open, "%s, 0x%x, 0x%x"), args->path, args->flags, - args->mode); -#endif - - error = linux_open_common(AT_FDCWD, args->path, args->flags, - args->mode, &args->sysmsg_iresult); - -#ifdef DEBUG - if (ldebug(open)) - kprintf(LMSG("open returns error %d"), error); -#endif - return error; -} - -int -sys_linux_openat(struct linux_openat_args *args) -{ - int error; - int dfd; - -#ifdef DEBUG - if (ldebug(openat)) - kprintf(ARGS(openat, "%s, 0x%x, 0x%x"), args->path, - args->flags, args->mode); -#endif - - dfd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->dfd; - - error = linux_open_common(dfd, args->path, args->flags, - args->mode, &args->sysmsg_iresult); - -#ifdef DEBUG - if (ldebug(openat)) - kprintf(LMSG("openat returns error %d"), error); -#endif - return error; -} - -/* - * MPSAFE - */ -int -sys_linux_lseek(struct linux_lseek_args *args) -{ - int error; - -#ifdef DEBUG - if (ldebug(lseek)) - kprintf(ARGS(lseek, "%d, %ld, %d"), - args->fdes, (long)args->off, args->whence); -#endif - error = kern_lseek(args->fdes, args->off, args->whence, - &args->sysmsg_offset); - - return error; -} - -/* - * MPSAFE - */ -int -sys_linux_llseek(struct linux_llseek_args *args) -{ - int error; - off_t off, res; - -#ifdef DEBUG - if (ldebug(llseek)) - kprintf(ARGS(llseek, "%d, %d:%d, %d"), - args->fd, args->ohigh, args->olow, args->whence); -#endif - off = (args->olow) | (((off_t) args->ohigh) << 32); - - error = kern_lseek(args->fd, off, args->whence, &res); - - if (error == 0) - error = copyout(&res, args->res, sizeof(res)); - return (error); -} - -/* - * MPSAFE - */ -int -sys_linux_readdir(struct linux_readdir_args *args) -{ - struct linux_getdents_args lda; - int error; - - lda.fd = args->fd; - lda.dent = args->dent; - lda.count = -1; - lda.sysmsg_iresult = 0; - error = sys_linux_getdents(&lda); - args->sysmsg_iresult = lda.sysmsg_iresult; - return(error); -} - -/* - * Note that linux_getdents(2) and linux_getdents64(2) have the same - * arguments. They only differ in the definition of struct dirent they - * operate on. We use this to common the code, with the exception of - * accessing struct dirent. Note that linux_readdir(2) is implemented - * by means of linux_getdents(2). In this case we never operate on - * struct dirent64 and thus don't need to handle it... - */ - -struct l_dirent { - l_long d_ino; - l_off_t d_off; - l_ushort d_reclen; - char d_name[LINUX_NAME_MAX + 1]; -}; - -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]; -}; - -#define LINUX_RECLEN(de,namlen) \ - ALIGN((((char *)&(de)->d_name - (char *)de) + (namlen) + 1)) - -#define LINUX_DIRBLKSIZ 512 - -/* - * MPALMOSTSAFE - */ -static int -getdents_common(struct linux_getdents64_args *args, int is64bit) -{ - struct thread *td = curthread; - struct proc *p = td->td_proc; - struct dirent *bdp; - struct vnode *vp; - caddr_t inp, buf; /* BSD-format */ - int reclen; /* BSD-format */ - size_t len; - caddr_t outp; /* Linux-format */ - int linuxreclen = 0; /* Linux-format */ - size_t resid; - struct file *fp; - struct uio auio; - struct iovec aiov; - struct vattr va; - off_t off; - struct l_dirent linux_dirent; - struct l_dirent64 linux_dirent64; - int error, eofflag, justone; - size_t buflen, nbytes; - off_t *cookies = NULL, *cookiep; - int ncookies; - - if ((error = holdvnode(p->p_fd, args->fd, &fp)) != 0) - return (error); - - get_mplock(); - if ((fp->f_flag & FREAD) == 0) { - error = EBADF; - goto done; - } - - vp = (struct vnode *) fp->f_data; - if (vp->v_type != VDIR) { - error = EINVAL; - goto done; - } - - if ((error = VOP_GETATTR(vp, &va)) != 0) - goto done; - - nbytes = args->count; - if (nbytes == (size_t)-1) { - /* readdir(2) case. Always struct dirent. */ - if (is64bit) { - error = EINVAL; - goto done; - } - nbytes = sizeof(linux_dirent); - justone = 1; - } else { - justone = 0; - } - if ((ssize_t)nbytes < 0) - nbytes = 0; - - off = fp->f_offset; - - buflen = max(LINUX_DIRBLKSIZ, nbytes); - buflen = min(buflen, MAXBSIZE); - buf = kmalloc(buflen, M_TEMP, M_WAITOK); - -again: - aiov.iov_base = buf; - aiov.iov_len = buflen; - auio.uio_iov = &aiov; - auio.uio_iovcnt = 1; - auio.uio_rw = UIO_READ; - auio.uio_segflg = UIO_SYSSPACE; - auio.uio_td = td; - auio.uio_resid = buflen; - auio.uio_offset = off; - - if (cookies) { - kfree(cookies, M_TEMP); - cookies = NULL; - } - - eofflag = 0; - ncookies = 0; - if ((error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, &ncookies, - &cookies))) - goto out; - - inp = buf; - outp = (caddr_t)args->dirent; - resid = nbytes; - if (auio.uio_resid >= buflen) - goto eof; - len = buflen - auio.uio_resid; - cookiep = cookies; - - if (cookies) { - /* - * When using cookies, the vfs has the option of reading from - * a different offset than that supplied (UFS truncates the - * offset to a block boundary to make sure that it never reads - * partway through a directory entry, even if the directory - * has been compacted). - */ - while (len > 0 && ncookies > 0 && *cookiep < off) { - bdp = (struct dirent *) inp; - len -= _DIRENT_DIRSIZ(bdp); - inp += _DIRENT_DIRSIZ(bdp); - cookiep++; - ncookies--; - } - } - - while (len > 0) { - if (cookiep && ncookies == 0) - break; - bdp = (struct dirent *) inp; - reclen = _DIRENT_DIRSIZ(bdp); - if (reclen & 3) { - error = EFAULT; - goto out; - } - - if (bdp->d_ino == 0) { - inp += reclen; - if (cookiep) { - off = *cookiep++; - ++off; - ncookies--; - } else { - off += reclen; - } - len -= reclen; - continue; - } - - linuxreclen = (is64bit) - ? LINUX_RECLEN(&linux_dirent64, bdp->d_namlen) - : LINUX_RECLEN(&linux_dirent, bdp->d_namlen); - - if (reclen > len || resid < linuxreclen) { - outp++; - break; - } - - bzero(&linux_dirent, sizeof(linux_dirent)); - bzero(&linux_dirent64, sizeof(linux_dirent64)); - if (justone) { - /* readdir(2) case. */ - linux_dirent.d_ino = (l_long)INO64TO32(bdp->d_ino); - linux_dirent.d_off = (l_off_t)linuxreclen; - linux_dirent.d_reclen = (l_ushort)bdp->d_namlen; - strcpy(linux_dirent.d_name, bdp->d_name); - error = copyout(&linux_dirent, outp, linuxreclen); - } else { - if (is64bit) { - linux_dirent64.d_ino = INO64TO32(bdp->d_ino); - linux_dirent64.d_off = (cookiep) - ? (l_off_t)*cookiep - : (l_off_t)(off + reclen); - linux_dirent64.d_reclen = - (l_ushort)linuxreclen; - linux_dirent64.d_type = bdp->d_type; - strcpy(linux_dirent64.d_name, bdp->d_name); - error = copyout(&linux_dirent64, outp, - linuxreclen); - } else { - linux_dirent.d_ino = INO64TO32(bdp->d_ino); - linux_dirent.d_off = (cookiep) - ? (l_off_t)*cookiep - : (l_off_t)(off + reclen); - linux_dirent.d_reclen = (l_ushort)linuxreclen; - strcpy(linux_dirent.d_name, bdp->d_name); - error = copyout(&linux_dirent, outp, - linuxreclen); - } - } - if (error) - goto out; - - inp += reclen; - if (cookiep) { - off = *cookiep++; - ++off; - ncookies--; - } else { - off += reclen; - } - - outp += linuxreclen; - resid -= linuxreclen; - len -= reclen; - if (justone) - break; - } - - if (outp == (caddr_t)args->dirent && eofflag == 0) - goto again; - - fp->f_offset = off; - if (justone) - nbytes = resid + linuxreclen; - -eof: - args->sysmsg_iresult = (int)(nbytes - resid); - -out: - if (cookies) - kfree(cookies, M_TEMP); - - kfree(buf, M_TEMP); -done: - rel_mplock(); - fdrop(fp); - return (error); -} - -/* - * MPSAFE - */ -int -sys_linux_getdents(struct linux_getdents_args *args) -{ -#ifdef DEBUG - if (ldebug(getdents)) - kprintf(ARGS(getdents, "%d, *, %d"), args->fd, args->count); -#endif - return (getdents_common((struct linux_getdents64_args*)args, 0)); -} - -/* - * MPSAFE - */ -int -sys_linux_getdents64(struct linux_getdents64_args *args) -{ -#ifdef DEBUG - if (ldebug(getdents64)) - kprintf(ARGS(getdents64, "%d, *, %d"), args->fd, args->count); -#endif - return (getdents_common(args, 1)); -} - -/* - * These exist mainly for hooks for doing /compat/linux translation. - * - * MPALMOSTSAFE - */ -int -sys_linux_access(struct linux_access_args *args) -{ - struct nlookupdata nd; - char *path; - int error; - - error = linux_copyin_path(args->path, &path, LINUX_PATH_EXISTS); - if (error) - return (error); -#ifdef DEBUG - if (ldebug(access)) - kprintf(ARGS(access, "%s, %d"), path, args->flags); -#endif - get_mplock(); - error = nlookup_init(&nd, path, UIO_SYSSPACE, NLC_FOLLOW); - if (error == 0) - error = kern_access(&nd, args->flags, 0); - nlookup_done(&nd); - rel_mplock(); - linux_free_path(&path); - return(error); -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_unlink(struct linux_unlink_args *args) -{ - struct nlookupdata nd; - char *path; - int error; - - error = linux_copyin_path(args->path, &path, LINUX_PATH_EXISTS); - if (error) - return (error); -#ifdef DEBUG - if (ldebug(unlink)) - kprintf(ARGS(unlink, "%s"), path); -#endif - get_mplock(); - error = nlookup_init(&nd, path, UIO_SYSSPACE, 0); - if (error == 0) - error = kern_unlink(&nd); - nlookup_done(&nd); - rel_mplock(); - linux_free_path(&path); - return(error); -} - -int -sys_linux_unlinkat(struct linux_unlinkat_args *args) -{ - struct nlookupdata nd; - struct file *fp; - char *path; - int dfd, error; - - if (args->flag & ~LINUX_AT_REMOVEDIR) - return (EINVAL); - - error = linux_copyin_path(args->path, &path, LINUX_PATH_EXISTS); - if (error) { - kprintf("linux_copyin_path says error = %d\n", error); - return (error); - } -#ifdef DEBUG - if (ldebug(unlink)) - kprintf(ARGS(unlink, "%s"), path); -#endif - - dfd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->dfd; - get_mplock(); - error = nlookup_init_at(&nd, &fp, dfd, path, UIO_SYSSPACE, 0); - if (error == 0) { - if (args->flag & LINUX_AT_REMOVEDIR) - error = kern_rmdir(&nd); - else - error = kern_unlink(&nd); - } - nlookup_done_at(&nd, fp); - rel_mplock(); - linux_free_path(&path); - return(error); -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_chdir(struct linux_chdir_args *args) -{ - struct nlookupdata nd; - char *path; - int error; - - error = linux_copyin_path(args->path, &path, LINUX_PATH_EXISTS); - if (error) - return (error); -#ifdef DEBUG - if (ldebug(chdir)) - kprintf(ARGS(chdir, "%s"), path); -#endif - get_mplock(); - error = nlookup_init(&nd, path, UIO_SYSSPACE, NLC_FOLLOW); - if (error == 0) { - error = kern_chdir(&nd); - nlookup_done(&nd); - } - rel_mplock(); - linux_free_path(&path); - return(error); -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_chmod(struct linux_chmod_args *args) -{ - struct nlookupdata nd; - char *path; - int error; - - error = linux_copyin_path(args->path, &path, LINUX_PATH_EXISTS); - if (error) - return (error); -#ifdef DEBUG - if (ldebug(chmod)) - kprintf(ARGS(chmod, "%s, %d"), path, args->mode); -#endif - get_mplock(); - error = nlookup_init(&nd, path, UIO_SYSSPACE, NLC_FOLLOW); - if (error == 0) - error = kern_chmod(&nd, args->mode); - nlookup_done(&nd); - rel_mplock(); - linux_free_path(&path); - return(error); -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_mkdir(struct linux_mkdir_args *args) -{ - struct nlookupdata nd; - char *path; - int error; - - error = linux_copyin_path(args->path, &path, LINUX_PATH_CREATE); - if (error) - return (error); -#ifdef DEBUG - if (ldebug(mkdir)) - kprintf(ARGS(mkdir, "%s, %d"), path, args->mode); -#endif - get_mplock(); - error = nlookup_init(&nd, path, UIO_SYSSPACE, 0); - if (error == 0) - error = kern_mkdir(&nd, args->mode); - nlookup_done(&nd); - rel_mplock(); - - linux_free_path(&path); - return(error); -} - -int -sys_linux_mkdirat(struct linux_mkdirat_args *args) -{ - struct nlookupdata nd; - struct file *fp; - char *path; - int dfd, error; - - error = linux_copyin_path(args->path, &path, LINUX_PATH_CREATE); - if (error) - return (error); -#ifdef DEBUG - if (ldebug(mkdir)) - kprintf(ARGS(mkdir, "%s, %d"), path, args->mode); -#endif - dfd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->dfd; - get_mplock(); - error = nlookup_init_at(&nd, &fp, dfd, path, UIO_SYSSPACE, 0); - if (error == 0) - error = kern_mkdir(&nd, args->mode); - nlookup_done_at(&nd, fp); - rel_mplock(); - - linux_free_path(&path); - return(error); -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_rmdir(struct linux_rmdir_args *args) -{ - struct nlookupdata nd; - char *path; - int error; - - error = linux_copyin_path(args->path, &path, LINUX_PATH_EXISTS); - if (error) - return (error); -#ifdef DEBUG - if (ldebug(rmdir)) - kprintf(ARGS(rmdir, "%s"), path); -#endif - get_mplock(); - error = nlookup_init(&nd, path, UIO_SYSSPACE, 0); - if (error == 0) - error = kern_rmdir(&nd); - nlookup_done(&nd); - rel_mplock(); - linux_free_path(&path); - return(error); -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_rename(struct linux_rename_args *args) -{ - struct nlookupdata fromnd, tond; - char *from, *to; - int error; - - error = linux_copyin_path(args->from, &from, LINUX_PATH_EXISTS); - if (error) - return (error); - error = linux_copyin_path(args->to, &to, LINUX_PATH_CREATE); - if (error) { - linux_free_path(&from); - return (error); - } -#ifdef DEBUG - if (ldebug(rename)) - kprintf(ARGS(rename, "%s, %s"), from, to); -#endif - get_mplock(); - do { - error = nlookup_init(&fromnd, from, UIO_SYSSPACE, 0); - if (error == 0) { - error = nlookup_init(&tond, to, UIO_SYSSPACE, 0); - if (error == 0) - error = kern_rename(&fromnd, &tond); - nlookup_done(&tond); - } - nlookup_done(&fromnd); - } while (error == EAGAIN); - rel_mplock(); - linux_free_path(&from); - linux_free_path(&to); - return(error); -} - -int -sys_linux_renameat(struct linux_renameat_args *args) -{ - struct nlookupdata fromnd, tond; - struct file *fp, *fp2; - char *from, *to; - int olddfd, newdfd,error; - - error = linux_copyin_path(args->from, &from, LINUX_PATH_EXISTS); - if (error) - return (error); - error = linux_copyin_path(args->to, &to, LINUX_PATH_CREATE); - if (error) { - linux_free_path(&from); - return (error); - } -#ifdef DEBUG - if (ldebug(rename)) - kprintf(ARGS(rename, "%s, %s"), from, to); -#endif - olddfd = (args->olddfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->olddfd; - newdfd = (args->newdfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->newdfd; - get_mplock(); - error = nlookup_init_at(&fromnd, &fp, olddfd, from, UIO_SYSSPACE, 0); - if (error == 0) { - error = nlookup_init_at(&tond, &fp2, newdfd, to, UIO_SYSSPACE, 0); - if (error == 0) - error = kern_rename(&fromnd, &tond); - nlookup_done_at(&tond, fp2); - } - nlookup_done_at(&fromnd, fp); - rel_mplock(); - linux_free_path(&from); - linux_free_path(&to); - return(error); -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_symlink(struct linux_symlink_args *args) -{ - struct thread *td = curthread; - struct nlookupdata nd; - char *path, *link; - int error; - int mode; - - error = linux_copyin_path(args->path, &path, LINUX_PATH_EXISTS); - if (error) - return (error); - error = linux_copyin_path(args->to, &link, LINUX_PATH_CREATE); - if (error) { - linux_free_path(&path); - return (error); - } -#ifdef DEBUG - if (ldebug(symlink)) - kprintf(ARGS(symlink, "%s, %s"), path, link); -#endif - get_mplock(); - error = nlookup_init(&nd, link, UIO_SYSSPACE, 0); - if (error == 0) { - mode = ACCESSPERMS & ~td->td_proc->p_fd->fd_cmask; - error = kern_symlink(&nd, path, mode); - } - nlookup_done(&nd); - rel_mplock(); - linux_free_path(&path); - linux_free_path(&link); - return(error); -} - -int -sys_linux_symlinkat(struct linux_symlinkat_args *args) -{ - struct thread *td = curthread; - struct nlookupdata nd; - struct file *fp; - char *path, *link; - int error; - int newdfd, mode; - - error = linux_copyin_path(args->path, &path, LINUX_PATH_EXISTS); - if (error) - return (error); - error = linux_copyin_path(args->to, &link, LINUX_PATH_CREATE); - if (error) { - linux_free_path(&path); - return (error); - } -#ifdef DEBUG - if (ldebug(symlink)) - kprintf(ARGS(symlink, "%s, %s"), path, link); -#endif - newdfd = (args->newdfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->newdfd; - get_mplock(); - error = nlookup_init_at(&nd, &fp, newdfd, link, UIO_SYSSPACE, 0); - if (error == 0) { - mode = ACCESSPERMS & ~td->td_proc->p_fd->fd_cmask; - error = kern_symlink(&nd, path, mode); - } - nlookup_done_at(&nd, fp); - rel_mplock(); - linux_free_path(&path); - linux_free_path(&link); - return(error); -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_readlink(struct linux_readlink_args *args) -{ - struct nlookupdata nd; - char *path; - int error; - - error = linux_copyin_path(args->name, &path, LINUX_PATH_EXISTS); - if (error) - return (error); -#ifdef DEBUG - if (ldebug(readlink)) - kprintf(ARGS(readlink, "%s, %p, %d"), path, (void *)args->buf, - args->count); -#endif - get_mplock(); - error = nlookup_init(&nd, path, UIO_SYSSPACE, 0); - if (error == 0) { - error = kern_readlink(&nd, args->buf, args->count, - &args->sysmsg_iresult); - } - nlookup_done(&nd); - rel_mplock(); - linux_free_path(&path); - return(error); -} - -int -sys_linux_readlinkat(struct linux_readlinkat_args *args) -{ - struct nlookupdata nd; - struct file *fp; - char *path; - int dfd, error; - - error = linux_copyin_path(args->path, &path, LINUX_PATH_EXISTS); - if (error) - return (error); -#ifdef DEBUG - if (ldebug(readlink)) - kprintf(ARGS(readlink, "%s, %p, %d"), path, (void *)args->buf, - args->count); -#endif - dfd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->dfd; - get_mplock(); - error = nlookup_init_at(&nd, &fp, dfd, path, UIO_SYSSPACE, 0); - if (error == 0) { - error = kern_readlink(&nd, args->buf, args->count, - &args->sysmsg_iresult); - } - nlookup_done_at(&nd, fp); - rel_mplock(); - linux_free_path(&path); - return(error); -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_truncate(struct linux_truncate_args *args) -{ - struct nlookupdata nd; - char *path; - int error; - - error = linux_copyin_path(args->path, &path, LINUX_PATH_EXISTS); - if (error) - return (error); -#ifdef DEBUG - if (ldebug(truncate)) - kprintf(ARGS(truncate, "%s, %ld"), path, - (long)args->length); -#endif - get_mplock(); - error = nlookup_init(&nd, path, UIO_SYSSPACE, NLC_FOLLOW); - if (error == 0) - error = kern_truncate(&nd, args->length); - nlookup_done(&nd); - rel_mplock(); - linux_free_path(&path); - return(error); -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_truncate64(struct linux_truncate64_args *args) -{ - struct nlookupdata nd; - char *path; - int error; - - error = linux_copyin_path(args->path, &path, LINUX_PATH_EXISTS); - if (error) - return (error); -#ifdef DEBUG - if (ldebug(truncate64)) - kprintf(ARGS(truncate64, "%s, %lld"), path, - (off_t)args->length); -#endif - get_mplock(); - error = nlookup_init(&nd, path, UIO_SYSSPACE, NLC_FOLLOW); - if (error == 0) - error = kern_truncate(&nd, args->length); - nlookup_done(&nd); - rel_mplock(); - linux_free_path(&path); - return error; -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_ftruncate(struct linux_ftruncate_args *args) -{ - int error; - -#ifdef DEBUG - if (ldebug(ftruncate)) - kprintf(ARGS(ftruncate, "%d, %ld"), args->fd, - (long)args->length); -#endif - get_mplock(); - error = kern_ftruncate(args->fd, args->length); - rel_mplock(); - - return error; -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_ftruncate64(struct linux_ftruncate64_args *args) -{ - int error; - -#ifdef DEBUG - if (ldebug(ftruncate)) - kprintf(ARGS(ftruncate64, "%d, %lld"), args->fd, - (off_t)args->length); -#endif - get_mplock(); - error = kern_ftruncate(args->fd, args->length); - rel_mplock(); - - return error; -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_link(struct linux_link_args *args) -{ - struct nlookupdata nd, linknd; - char *path, *link; - int error; - - error = linux_copyin_path(args->path, &path, LINUX_PATH_EXISTS); - if (error) - return (error); - error = linux_copyin_path(args->to, &link, LINUX_PATH_CREATE); - if (error) { - linux_free_path(&path); - return (error); - } -#ifdef DEBUG - if (ldebug(link)) - kprintf(ARGS(link, "%s, %s"), path, link); -#endif - get_mplock(); - error = nlookup_init(&nd, path, UIO_SYSSPACE, NLC_FOLLOW); - if (error == 0) { - error = nlookup_init(&linknd, link, UIO_SYSSPACE, 0); - if (error == 0) - error = kern_link(&nd, &linknd); - nlookup_done(&linknd); - } - nlookup_done(&nd); - rel_mplock(); - linux_free_path(&path); - linux_free_path(&link); - return(error); -} - -int -sys_linux_linkat(struct linux_linkat_args *args) -{ - struct nlookupdata nd, linknd; - struct file *fp, *fp2; - char *path, *link; - int olddfd, newdfd, error; - - if (args->flags != 0) - return (EINVAL); - - error = linux_copyin_path(args->path, &path, LINUX_PATH_EXISTS); - if (error) - return (error); - error = linux_copyin_path(args->to, &link, LINUX_PATH_CREATE); - if (error) { - linux_free_path(&path); - return (error); - } -#ifdef DEBUG - if (ldebug(link)) - kprintf(ARGS(link, "%s, %s"), path, link); -#endif - olddfd = (args->olddfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->olddfd; - newdfd = (args->newdfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->newdfd; - get_mplock(); - error = nlookup_init_at(&nd, &fp, olddfd, path, UIO_SYSSPACE, NLC_FOLLOW); - if (error == 0) { - error = nlookup_init_at(&linknd, &fp2, newdfd, link, UIO_SYSSPACE, 0); - if (error == 0) - error = kern_link(&nd, &linknd); - nlookup_done_at(&linknd, fp2); - } - nlookup_done_at(&nd, fp); - rel_mplock(); - linux_free_path(&path); - linux_free_path(&link); - return(error); -} - -/* - * MPSAFE - */ -int -sys_linux_fdatasync(struct linux_fdatasync_args *uap) -{ - struct fsync_args bsd; - int error; - - bsd.fd = uap->fd; - bsd.sysmsg_iresult = 0; - - error = sys_fsync(&bsd); - uap->sysmsg_iresult = bsd.sysmsg_iresult; - return(error); -} - -/* - * MPSAFE - */ -int -sys_linux_pread(struct linux_pread_args *uap) -{ - struct thread *td = curthread; - struct uio auio; - struct iovec aiov; - int error; - - aiov.iov_base = uap->buf; - aiov.iov_len = uap->nbyte; - auio.uio_iov = &aiov; - auio.uio_iovcnt = 1; - auio.uio_offset = uap->offset; - auio.uio_resid = uap->nbyte; - auio.uio_rw = UIO_READ; - auio.uio_segflg = UIO_USERSPACE; - auio.uio_td = td; - - if ((ssize_t)auio.uio_resid < 0) { - error = EINVAL; - } else { - error = kern_preadv(uap->fd, &auio, O_FOFFSET, - &uap->sysmsg_szresult); - } - return(error); -} - -/* - * MPSAFE - */ -int -sys_linux_pwrite(struct linux_pwrite_args *uap) -{ - struct thread *td = curthread; - struct uio auio; - struct iovec aiov; - int error; - - aiov.iov_base = uap->buf; - aiov.iov_len = uap->nbyte; - auio.uio_iov = &aiov; - auio.uio_iovcnt = 1; - auio.uio_offset = uap->offset; - auio.uio_resid = uap->nbyte; - auio.uio_rw = UIO_WRITE; - auio.uio_segflg = UIO_USERSPACE; - auio.uio_td = td; - - if ((ssize_t)auio.uio_resid < 0) { - error = EINVAL; - } else { - error = kern_pwritev(uap->fd, &auio, O_FOFFSET, - &uap->sysmsg_szresult); - } - return(error); -} - -/* - * MPSAFE - */ -int -sys_linux_oldumount(struct linux_oldumount_args *args) -{ - struct linux_umount_args args2; - int error; - - args2.path = args->path; - args2.flags = 0; - args2.sysmsg_iresult = 0; - error = sys_linux_umount(&args2); - args->sysmsg_iresult = args2.sysmsg_iresult; - return(error); -} - -/* - * MPSAFE - */ -int -sys_linux_umount(struct linux_umount_args *args) -{ - struct unmount_args bsd; - int error; - - bsd.path = args->path; - bsd.flags = args->flags; /* XXX correct? */ - bsd.sysmsg_iresult = 0; - - error = sys_unmount(&bsd); - args->sysmsg_iresult = bsd.sysmsg_iresult; - return(error); -} - -/* - * 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; -}; - -/* - * MPSAFE - */ -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; -} - -/* - * MPSAFE - */ -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; -} - -#if defined(__i386__) -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; -}; - -/* - * MPSAFE - */ -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; -} - -/* - * MPSAFE - */ -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; -} -#endif /* __i386__ */ - -/* - * MPSAFE - */ -static int -linux_fcntl_common(struct linux_fcntl64_args *args) -{ - struct thread *td = curthread; - struct l_flock linux_flock; - struct file *fp; - union fcntl_dat dat; - int error, cmd; - - switch (args->cmd) { - case LINUX_F_DUPFD: - cmd = F_DUPFD; - dat.fc_fd = args->arg; - break; - case LINUX_F_GETFD: - cmd = F_GETFD; - break; - case LINUX_F_SETFD: - cmd = F_SETFD; - dat.fc_cloexec = args->arg; - break; - case LINUX_F_GETFL: - cmd = F_GETFL; - break; - case LINUX_F_SETFL: - cmd = F_SETFL; - dat.fc_flags = 0; - if (args->arg & LINUX_O_NDELAY) - dat.fc_flags |= O_NONBLOCK; - if (args->arg & LINUX_O_APPEND) - dat.fc_flags |= O_APPEND; - if (args->arg & LINUX_O_SYNC) - dat.fc_flags |= O_FSYNC; - if (args->arg & LINUX_FASYNC) - dat.fc_flags |= O_ASYNC; - break; - case LINUX_F_GETLK: - case LINUX_F_SETLK: - case LINUX_F_SETLKW: - cmd = F_GETLK; - error = copyin((caddr_t)args->arg, &linux_flock, - sizeof(linux_flock)); - if (error) - return (error); - linux_to_bsd_flock(&linux_flock, &dat.fc_flock); - break; - case LINUX_F_GETOWN: - cmd = F_GETOWN; - break; - 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). - */ - fp = holdfp(td->td_proc->p_fd, args->fd, -1); - if (fp == NULL) - return (EBADF); - if (fp->f_type == DTYPE_PIPE) { - fdrop(fp); - return (EINVAL); - } - fdrop(fp); - cmd = F_SETOWN; - dat.fc_owner = args->arg; - break; - default: - return (EINVAL); - } - - /* MPSAFE */ - error = kern_fcntl(args->fd, cmd, &dat, td->td_ucred); - - if (error == 0) { - switch (args->cmd) { - case LINUX_F_DUPFD: - args->sysmsg_iresult = dat.fc_fd; - break; - case LINUX_F_GETFD: - args->sysmsg_iresult = dat.fc_cloexec; - break; - case LINUX_F_SETFD: - break; - case LINUX_F_GETFL: - args->sysmsg_iresult = 0; - if (dat.fc_flags & O_RDONLY) - args->sysmsg_iresult |= LINUX_O_RDONLY; - if (dat.fc_flags & O_WRONLY) - args->sysmsg_iresult |= LINUX_O_WRONLY; - if (dat.fc_flags & O_RDWR) - args->sysmsg_iresult |= LINUX_O_RDWR; - if (dat.fc_flags & O_NDELAY) - args->sysmsg_iresult |= LINUX_O_NONBLOCK; - if (dat.fc_flags & O_APPEND) - args->sysmsg_iresult |= LINUX_O_APPEND; - if (dat.fc_flags & O_FSYNC) - args->sysmsg_iresult |= LINUX_O_SYNC; - if (dat.fc_flags & O_ASYNC) - args->sysmsg_iresult |= LINUX_FASYNC; - break; - case LINUX_F_GETLK: - bsd_to_linux_flock(&dat.fc_flock, &linux_flock); - error = copyout(&linux_flock, (caddr_t)args->arg, - sizeof(linux_flock)); - break; - case LINUX_F_SETLK: - case LINUX_F_SETLKW: - break; - case LINUX_F_GETOWN: - args->sysmsg_iresult = dat.fc_owner; - break; - case LINUX_F_SETOWN: - break; - } - } - - return(error); -} - -/* - * MPSAFE - */ -int -sys_linux_fcntl(struct linux_fcntl_args *args) -{ - struct linux_fcntl64_args args64; - int error; - -#ifdef DEBUG - if (ldebug(fcntl)) - kprintf(ARGS(fcntl, "%d, %08x, *"), args->fd, args->cmd); -#endif - - args64.fd = args->fd; - args64.cmd = args->cmd; - args64.arg = args->arg; - args64.sysmsg_iresult = 0; - error = linux_fcntl_common(&args64); - args->sysmsg_iresult = args64.sysmsg_iresult; - return(error); -} - -#if defined(__i386__) -/* - * MPSAFE - */ -int -sys_linux_fcntl64(struct linux_fcntl64_args *args) -{ - struct thread *td = curthread; - struct l_flock64 linux_flock; - union fcntl_dat dat; - int error, cmd = 0; - -#ifdef DEBUG - if (ldebug(fcntl64)) - kprintf(ARGS(fcntl64, "%d, %08x, *"), args->fd, args->cmd); -#endif - if (args->cmd == LINUX_F_GETLK64 || args->cmd == LINUX_F_SETLK64 || - args->cmd == LINUX_F_SETLKW64) { - switch (args->cmd) { - case LINUX_F_GETLK64: - cmd = F_GETLK; - break; - case LINUX_F_SETLK64: - cmd = F_SETLK; - break; - case LINUX_F_SETLKW64: - cmd = F_SETLKW; - break; - } - - error = copyin((caddr_t)args->arg, &linux_flock, - sizeof(linux_flock)); - if (error) - return (error); - linux_to_bsd_flock64(&linux_flock, &dat.fc_flock); - - /* MPSAFE */ - error = kern_fcntl(args->fd, cmd, &dat, td->td_ucred); - - if (error == 0 && args->cmd == LINUX_F_GETLK64) { - bsd_to_linux_flock64(&dat.fc_flock, &linux_flock); - error = copyout(&linux_flock, (caddr_t)args->arg, - sizeof(linux_flock)); - } - } else { - error = linux_fcntl_common(args); - } - - return (error); -} -#endif /* __i386__ */ - -/* - * MPALMOSTSAFE - */ -int -sys_linux_chown(struct linux_chown_args *args) -{ - struct nlookupdata nd; - char *path; - int error; - - error = linux_copyin_path(args->path, &path, LINUX_PATH_EXISTS); - if (error) - return (error); -#ifdef DEBUG - if (ldebug(chown)) - kprintf(ARGS(chown, "%s, %d, %d"), path, args->uid, args->gid); -#endif - get_mplock(); - error = nlookup_init(&nd, path, UIO_SYSSPACE, NLC_FOLLOW); - if (error == 0) - error = kern_chown(&nd, args->uid, args->gid); - nlookup_done(&nd); - rel_mplock(); - linux_free_path(&path); - return(error); -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_lchown(struct linux_lchown_args *args) -{ - struct nlookupdata nd; - char *path; - int error; - - error = linux_copyin_path(args->path, &path, LINUX_PATH_EXISTS); - if (error) - return (error); -#ifdef DEBUG - if (ldebug(lchown)) - kprintf(ARGS(lchown, "%s, %d, %d"), path, args->uid, args->gid); -#endif - get_mplock(); - error = nlookup_init(&nd, path, UIO_SYSSPACE, 0); - if (error == 0) - error = kern_chown(&nd, args->uid, args->gid); - nlookup_done(&nd); - rel_mplock(); - linux_free_path(&path); - return(error); -} - -int -sys_linux_fchmodat(struct linux_fchmodat_args *args) -{ - struct fchmodat_args uap; - int error; - - uap.fd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->dfd; - uap.path = args->filename; - uap.mode = args->mode; - uap.flags = 0; - - error = sys_fchmodat(&uap); - - return (error); -} - -int -sys_linux_fchownat(struct linux_fchownat_args *args) -{ - struct fchownat_args uap; - int error; - - if (args->flag & ~LINUX_AT_SYMLINK_NOFOLLOW) - return (EINVAL); - - uap.fd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->dfd; - uap.path = args->filename; - uap.uid = args->uid; - uap.gid = args->gid; - uap.flags = (args->flag & LINUX_AT_SYMLINK_NOFOLLOW) == 0 ? 0 : - AT_SYMLINK_NOFOLLOW; - - error = sys_fchownat(&uap); - - return (error); -} - -int -sys_linux_faccessat(struct linux_faccessat_args *args) -{ - struct faccessat_args uap; - int error; - - uap.fd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->dfd; - uap.path = args->filename; - uap.amode = args->mode; - uap.flags = 0; - - error = sys_faccessat(&uap); - - return error; -} diff --git a/sys/emulation/linux/linux_futex.c b/sys/emulation/linux/linux_futex.c deleted file mode 100644 index 809e216773..0000000000 --- a/sys/emulation/linux/linux_futex.c +++ /dev/null @@ -1,838 +0,0 @@ -/* $NetBSD: linux_futex.c,v 1.7 2006/07/24 19:01:49 manu Exp $ */ - -/*- - * Copyright (c) 2005 Emmanuel Dreyfus, all rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Emmanuel Dreyfus - * 4. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE 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. - */ - -#include "opt_compat.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "i386/linux.h" -#include "i386/linux_proto.h" -#include "linux_signal.h" -#include "linux_util.h" -#include "linux_emuldata.h" - -MALLOC_DEFINE(M_FUTEX, "futex", "Linux futexes"); -MALLOC_DEFINE(M_FUTEX_WP, "futex wp", "Linux futexes wp"); - -struct futex; - -struct waiting_proc { - uint32_t wp_flags; - struct futex *wp_futex; - TAILQ_ENTRY(waiting_proc) wp_list; -}; - -struct futex { - struct lock f_lck; - uint32_t *f_uaddr; - uint32_t f_refcount; - LIST_ENTRY(futex) f_list; - TAILQ_HEAD(lf_waiting_proc, waiting_proc) f_waiting_proc; -}; - -struct futex_list futex_list; - -#if 0 -#define FUTEX_LOCK(f) spin_lock(&(f)->f_lck) -#define FUTEX_UNLOCK(f) spin_unlock(&(f)->f_lck) -#define FUTEX_INIT(f) spin_init(&(f)->f_lck, "futex") -#define FUTEX_SLEEP(f, id, flag, wm, timo) ssleep((id), &(f)->f_lck, (flag), (wm), (timo)) -#endif - -#define FUTEX_LOCK(f) lockmgr(&(f)->f_lck, LK_EXCLUSIVE) -#define FUTEX_UNLOCK(f) lockmgr(&(f)->f_lck, LK_RELEASE) -#define FUTEX_INIT(f) lockinit(&(f)->f_lck, "ftlk", 0, LK_CANRECURSE) -#define FUTEX_DESTROY(f) lockuninit(&(f)->f_lck) -#define FUTEX_ASSERT_LOCKED(f) KKASSERT(lockstatus(&(f)->f_lck, curthread) == LK_EXCLUSIVE) -#define FUTEX_SLEEP(f, id, flag, wm, timo) lksleep((id), &(f)->f_lck, (flag), (wm), (timo)) - -struct lock futex_mtx; /* protects the futex list */ -#define FUTEXES_LOCK lockmgr(&futex_mtx, LK_EXCLUSIVE) -#define FUTEXES_UNLOCK lockmgr(&futex_mtx, LK_RELEASE) - -/* Debug magic to take advantage of freebsd's mess */ -#ifdef LINUX_DEBUG -#define LINUX_CTR_PREFIX -#else -#define LINUX_CTR_PREFIX while (0) -#endif - -#define LINUX_CTR1(a,b,c) LINUX_CTR_PREFIX kprintf("linux_futex: " b "\n",c) -#define LINUX_CTR2(a,b,c,d) LINUX_CTR_PREFIX kprintf("linux_futex: " b "\n",c,d) -#define LINUX_CTR3(a,b,c,d,e) LINUX_CTR_PREFIX kprintf("linux_futex: " b "\n",c,d,e) -#define LINUX_CTR4(a,b,c,d,e,f) LINUX_CTR_PREFIX kprintf("linux_futex: " b "\n",c,d,e,f) -#define LINUX_CTR5(a,b,c,d,e,f,g) LINUX_CTR_PREFIX kprintf("linux_futex: " b "\n",c,d,e,f,g) - - - -/* flags for futex_get() */ -#define FUTEX_CREATE_WP 0x1 /* create waiting_proc */ -#define FUTEX_DONTCREATE 0x2 /* don't create futex if not exists */ -#define FUTEX_DONTEXISTS 0x4 /* return EINVAL if futex exists */ - -/* wp_flags */ -#define FUTEX_WP_REQUEUED 0x1 /* wp requeued - wp moved from wp_list - * of futex where thread sleep to wp_list - * of another futex. - */ -#define FUTEX_WP_REMOVED 0x2 /* wp is woken up and removed from futex - * wp_list to prevent double wakeup. - */ - -/* support.s */ -int futex_xchgl(int oparg, uint32_t *uaddr, int *oldval); -int futex_addl(int oparg, uint32_t *uaddr, int *oldval); -int futex_orl(int oparg, uint32_t *uaddr, int *oldval); -int futex_andl(int oparg, uint32_t *uaddr, int *oldval); -int futex_xorl(int oparg, uint32_t *uaddr, int *oldval); - -static void -futex_put(struct futex *f, struct waiting_proc *wp) -{ - FUTEX_ASSERT_LOCKED(f); - if (wp != NULL) { - if ((wp->wp_flags & FUTEX_WP_REMOVED) == 0) - TAILQ_REMOVE(&f->f_waiting_proc, wp, wp_list); - kfree(wp, M_FUTEX_WP); - } - - FUTEXES_LOCK; - if (--f->f_refcount == 0) { - LIST_REMOVE(f, f_list); - FUTEXES_UNLOCK; - FUTEX_UNLOCK(f); - - LINUX_CTR2(sys_futex, "futex_put destroy uaddr %p ref %d", - f->f_uaddr, f->f_refcount); - FUTEX_DESTROY(f); - kfree(f, M_FUTEX); - return; - } - - LINUX_CTR2(sys_futex, "futex_put uaddr %p ref %d", - f->f_uaddr, f->f_refcount); - FUTEXES_UNLOCK; - FUTEX_UNLOCK(f); -} - -static int -futex_get0(uint32_t *uaddr, struct futex **newf, uint32_t flags) -{ - struct futex *f, *tmpf; - - *newf = tmpf = NULL; - -retry: - FUTEXES_LOCK; - LIST_FOREACH(f, &futex_list, f_list) { - if (f->f_uaddr == uaddr) { - if (tmpf != NULL) { - FUTEX_UNLOCK(tmpf); - FUTEX_DESTROY(tmpf); - kfree(tmpf, M_FUTEX); - } - if (flags & FUTEX_DONTEXISTS) { - FUTEXES_UNLOCK; - return (EINVAL); - } - - /* - * Increment refcount of the found futex to - * prevent it from deallocation before FUTEX_LOCK() - */ - ++f->f_refcount; - FUTEXES_UNLOCK; - - FUTEX_LOCK(f); - *newf = f; - LINUX_CTR2(sys_futex, "futex_get uaddr %p ref %d", - uaddr, f->f_refcount); - return (0); - } - } - - if (flags & FUTEX_DONTCREATE) { - FUTEXES_UNLOCK; - LINUX_CTR1(sys_futex, "futex_get uaddr %p null", uaddr); - return (0); - } - - if (tmpf == NULL) { - FUTEXES_UNLOCK; - tmpf = kmalloc(sizeof(*tmpf), M_FUTEX, M_WAITOK | M_ZERO); - tmpf->f_uaddr = uaddr; - tmpf->f_refcount = 1; - FUTEX_INIT(tmpf); - TAILQ_INIT(&tmpf->f_waiting_proc); - - /* - * Lock the new futex before an insert into the futex_list - * to prevent futex usage by other. - */ - FUTEX_LOCK(tmpf); - goto retry; - } - - LIST_INSERT_HEAD(&futex_list, tmpf, f_list); - FUTEXES_UNLOCK; - - LINUX_CTR2(sys_futex, "futex_get uaddr %p ref %d new", - uaddr, tmpf->f_refcount); - *newf = tmpf; - return (0); -} - -static int -futex_get(uint32_t *uaddr, struct waiting_proc **wp, struct futex **f, - uint32_t flags) -{ - int error; - - if (flags & FUTEX_CREATE_WP) { - *wp = kmalloc(sizeof(struct waiting_proc), M_FUTEX_WP, M_WAITOK); - (*wp)->wp_flags = 0; - } - error = futex_get0(uaddr, f, flags); - if (error) { - if (flags & FUTEX_CREATE_WP) - kfree(*wp, M_FUTEX_WP); - return (error); - } - if (flags & FUTEX_CREATE_WP) { - TAILQ_INSERT_HEAD(&(*f)->f_waiting_proc, *wp, wp_list); - (*wp)->wp_futex = *f; - } - - return (error); -} - -static int -futex_sleep(struct futex *f, struct waiting_proc *wp, int timeout) -{ - int error; - - FUTEX_ASSERT_LOCKED(f); - LINUX_CTR4(sys_futex, "futex_sleep enter uaddr %p wp %p timo %d ref %d", - f->f_uaddr, wp, timeout, f->f_refcount); - error = FUTEX_SLEEP(f, wp, PCATCH, "futex", timeout); - if (wp->wp_flags & FUTEX_WP_REQUEUED) { - KASSERT(f != wp->wp_futex, ("futex != wp_futex")); - LINUX_CTR5(sys_futex, "futex_sleep out error %d uaddr %p w" - " %p requeued uaddr %p ref %d", - error, f->f_uaddr, wp, wp->wp_futex->f_uaddr, - wp->wp_futex->f_refcount); - futex_put(f, NULL); - f = wp->wp_futex; - FUTEX_LOCK(f); - } - - futex_put(f, wp); - return (error); -} - -static int -futex_wake(struct futex *f, int n) -{ - struct waiting_proc *wp, *wpt; - int count = 0; - - FUTEX_ASSERT_LOCKED(f); - TAILQ_FOREACH_MUTABLE(wp, &f->f_waiting_proc, wp_list, wpt) { - LINUX_CTR3(sys_futex, "futex_wake uaddr %p wp %p ref %d", - f->f_uaddr, wp, f->f_refcount); - wp->wp_flags |= FUTEX_WP_REMOVED; - TAILQ_REMOVE(&f->f_waiting_proc, wp, wp_list); - wakeup_one(wp); - if (++count == n) - break; - } - - return (count); -} - -static int -futex_requeue(struct futex *f, int n, struct futex *f2, int n2) -{ - struct waiting_proc *wp, *wpt; - int count = 0; - - FUTEX_ASSERT_LOCKED(f); - FUTEX_ASSERT_LOCKED(f2); - - TAILQ_FOREACH_MUTABLE(wp, &f->f_waiting_proc, wp_list, wpt) { - if (++count <= n) { - LINUX_CTR2(sys_futex, "futex_req_wake uaddr %p wp %p", - f->f_uaddr, wp); - wp->wp_flags |= FUTEX_WP_REMOVED; - TAILQ_REMOVE(&f->f_waiting_proc, wp, wp_list); - wakeup_one(wp); - } else { - LINUX_CTR3(sys_futex, "futex_requeue uaddr %p wp %p to %p", - f->f_uaddr, wp, f2->f_uaddr); - wp->wp_flags |= FUTEX_WP_REQUEUED; - /* Move wp to wp_list of f2 futex */ - TAILQ_REMOVE(&f->f_waiting_proc, wp, wp_list); - TAILQ_INSERT_HEAD(&f2->f_waiting_proc, wp, wp_list); - - /* - * Thread which sleeps on wp after waking should - * acquire f2 lock, so increment refcount of f2 to - * prevent it from premature deallocation. - */ - wp->wp_futex = f2; - FUTEXES_LOCK; - ++f2->f_refcount; - FUTEXES_UNLOCK; - if (count - n >= n2) - break; - } - } - - return (count); -} - -static int -futex_wait(struct futex *f, struct waiting_proc *wp, struct l_timespec *ts) -{ - struct l_timespec timeout; - struct timeval tv; - int timeout_hz; - int error; - - if (ts != NULL) { - error = copyin(ts, &timeout, sizeof(timeout)); - if (error) - return (error); - TIMESPEC_TO_TIMEVAL(&tv, &timeout); - error = itimerfix(&tv); - if (error) - return (error); - timeout_hz = tvtohz_high(&tv); - } else { - timeout_hz = 0; - } - - error = futex_sleep(f, wp, timeout_hz); - if (error == EWOULDBLOCK) - error = ETIMEDOUT; - - return (error); -} - -static int -futex_atomic_op(struct proc *p, int encoded_op, uint32_t *uaddr) -{ - int op = (encoded_op >> 28) & 7; - int cmp = (encoded_op >> 24) & 15; - int oparg = (encoded_op << 8) >> 20; - int cmparg = (encoded_op << 20) >> 20; - int oldval = 0, ret; - - if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) - oparg = 1 << oparg; - -#ifdef DEBUG - if (ldebug(sys_futex)) - kprintf("futex_atomic_op: op = %d, cmp = %d, oparg = %x, " - "cmparg = %x, uaddr = %p\n", - op, cmp, oparg, cmparg, uaddr); -#endif - /* XXX: linux verifies access here and returns EFAULT */ - - switch (op) { - case FUTEX_OP_SET: - ret = futex_xchgl(oparg, uaddr, &oldval); - break; - case FUTEX_OP_ADD: - ret = futex_addl(oparg, uaddr, &oldval); - break; - case FUTEX_OP_OR: - ret = futex_orl(oparg, uaddr, &oldval); - break; - case FUTEX_OP_ANDN: - ret = futex_andl(~oparg, uaddr, &oldval); - break; - case FUTEX_OP_XOR: - ret = futex_xorl(oparg, uaddr, &oldval); - break; - default: - ret = -ENOSYS; - break; - } - - if (ret) - return (ret); - - switch (cmp) { - case FUTEX_OP_CMP_EQ: - return (oldval == cmparg); - case FUTEX_OP_CMP_NE: - return (oldval != cmparg); - case FUTEX_OP_CMP_LT: - return (oldval < cmparg); - case FUTEX_OP_CMP_GE: - return (oldval >= cmparg); - case FUTEX_OP_CMP_LE: - return (oldval <= cmparg); - case FUTEX_OP_CMP_GT: - return (oldval > cmparg); - default: - return (-ENOSYS); - } -} - -int -sys_linux_sys_futex(struct linux_sys_futex_args *args) -{ - int op_ret, val, ret, nrwake; - struct waiting_proc *wp; - struct futex *f, *f2 = NULL; - int error = 0; - - /* - * Our implementation provides only privates futexes. Most of the apps - * should use private futexes but don't claim so. Therefore we treat - * all futexes as private by clearing the FUTEX_PRIVATE_FLAG. It works - * in most cases (ie. when futexes are not shared on file descriptor - * or between different processes.). - */ - args->op = (args->op & ~LINUX_FUTEX_PRIVATE_FLAG); - - switch (args->op) { - case LINUX_FUTEX_WAIT: - LINUX_CTR2(sys_futex, "WAIT val %d uaddr %p", - args->val, args->uaddr); -#ifdef DEBUG - if (ldebug(sys_futex)) - kprintf(ARGS(sys_futex, "futex_wait val %d uaddr %p"), - args->val, args->uaddr); -#endif - error = futex_get(args->uaddr, &wp, &f, FUTEX_CREATE_WP); - if (error) - return (error); - error = copyin(args->uaddr, &val, sizeof(val)); - if (error) { - LINUX_CTR1(sys_futex, "WAIT copyin failed %d", - error); - futex_put(f, wp); - return (error); - } - if (val != args->val) { - LINUX_CTR3(sys_futex, "WAIT uaddr %p val %d != uval %d", - args->uaddr, args->val, val); - futex_put(f, wp); - return (EWOULDBLOCK); - } - - error = futex_wait(f, wp, args->timeout); - break; - - case LINUX_FUTEX_WAKE: - - LINUX_CTR2(sys_futex, "WAKE val %d uaddr %p", - args->val, args->uaddr); - - /* - * XXX: Linux is able to cope with different addresses - * corresponding to the same mapped memory in the sleeping - * and waker process(es). - */ -#ifdef DEBUG - if (ldebug(sys_futex)) - kprintf(ARGS(sys_futex, "futex_wake val %d uaddr %p"), - args->val, args->uaddr); -#endif - error = futex_get(args->uaddr, NULL, &f, FUTEX_DONTCREATE); - if (error) - return (error); - if (f == NULL) { - args->sysmsg_iresult = 0; - return (error); - } - args->sysmsg_iresult = futex_wake(f, args->val); - futex_put(f, NULL); - break; - - case LINUX_FUTEX_CMP_REQUEUE: - - LINUX_CTR5(sys_futex, "CMP_REQUEUE uaddr %p " - "val %d val3 %d uaddr2 %p val2 %d", - args->uaddr, args->val, args->val3, args->uaddr2, - (int)(unsigned long)args->timeout); - -#ifdef DEBUG - if (ldebug(sys_futex)) - kprintf(ARGS(sys_futex, "futex_cmp_requeue uaddr %p " - "val %d val3 %d uaddr2 %p val2 %d"), - args->uaddr, args->val, args->val3, args->uaddr2, - (int)(unsigned long)args->timeout); -#endif - /* - * Linux allows this, we would not, it is an incorrect - * usage of declared ABI, so return EINVAL. - */ - if (args->uaddr == args->uaddr2) - return (EINVAL); - error = futex_get0(args->uaddr, &f, 0); - if (error) - return (error); - - /* - * To avoid deadlocks return EINVAL if second futex - * exists at this time. Otherwise create the new futex - * and ignore false positive LOR which thus happens. - * - * Glibc fall back to FUTEX_WAKE in case of any error - * returned by FUTEX_CMP_REQUEUE. - */ - error = futex_get0(args->uaddr2, &f2, FUTEX_DONTEXISTS); - if (error) { - futex_put(f, NULL); - return (error); - } - error = copyin(args->uaddr, &val, sizeof(val)); - if (error) { - LINUX_CTR1(sys_futex, "CMP_REQUEUE copyin failed %d", - error); - futex_put(f2, NULL); - futex_put(f, NULL); - return (error); - } - if (val != args->val3) { - LINUX_CTR2(sys_futex, "CMP_REQUEUE val %d != uval %d", - args->val, val); - futex_put(f2, NULL); - futex_put(f, NULL); - return (EAGAIN); - } - - nrwake = (int)(unsigned long)args->timeout; - args->sysmsg_iresult = futex_requeue(f, args->val, f2, nrwake); - futex_put(f2, NULL); - futex_put(f, NULL); - break; - - case LINUX_FUTEX_WAKE_OP: - - LINUX_CTR5(sys_futex, "WAKE_OP " - "uaddr %p op %d val %x uaddr2 %p val3 %x", - args->uaddr, args->op, args->val, - args->uaddr2, args->val3); - -#ifdef DEBUG - if (ldebug(sys_futex)) - kprintf(ARGS(sys_futex, "futex_wake_op " - "uaddr %p op %d val %x uaddr2 %p val3 %x"), - args->uaddr, args->op, args->val, - args->uaddr2, args->val3); -#endif - error = futex_get0(args->uaddr, &f, 0); - if (error) - return (error); - if (args->uaddr != args->uaddr2) - error = futex_get0(args->uaddr2, &f2, 0); - if (error) { - futex_put(f, NULL); - return (error); - } - - /* - * This function returns positive number as results and - * negative as errors - */ - op_ret = futex_atomic_op(curproc, args->val3, args->uaddr2); - - if (op_ret < 0) { - /* XXX: We don't handle the EFAULT yet. */ - if (op_ret != -EFAULT) { - if (f2 != NULL) - futex_put(f2, NULL); - futex_put(f, NULL); - return (-op_ret); - } - if (f2 != NULL) - futex_put(f2, NULL); - futex_put(f, NULL); - return (EFAULT); - } - - ret = futex_wake(f, args->val); - - if (op_ret > 0) { - op_ret = 0; - nrwake = (int)(unsigned long)args->timeout; - - if (f2 != NULL) - op_ret += futex_wake(f2, nrwake); - else - op_ret += futex_wake(f, nrwake); - ret += op_ret; - - } - if (f2 != NULL) - futex_put(f2, NULL); - futex_put(f, NULL); - args->sysmsg_iresult = ret; - break; - - case LINUX_FUTEX_LOCK_PI: - /* not yet implemented */ - return (ENOSYS); - - case LINUX_FUTEX_UNLOCK_PI: - /* not yet implemented */ - return (ENOSYS); - - case LINUX_FUTEX_TRYLOCK_PI: - /* not yet implemented */ - return (ENOSYS); - - case LINUX_FUTEX_REQUEUE: - - /* - * Glibc does not use this operation since version 2.3.3, - * as it is racy and replaced by FUTEX_CMP_REQUEUE operation. - * Glibc versions prior to 2.3.3 fall back to FUTEX_WAKE when - * FUTEX_REQUEUE returned EINVAL. - */ - return (EINVAL); - - default: - kprintf("linux_sys_futex: unknown op %d\n", args->op); - return (ENOSYS); - } - - return (error); -} - -int -sys_linux_set_robust_list(struct linux_set_robust_list_args *args) -{ -#ifdef DEBUG - if (ldebug(set_robust_list)) - kprintf(ARGS(set_robust_list, "head %p len %d"), - args->head, args->len); -#endif - - if (args->len != sizeof(struct linux_robust_list_head)) - return (EINVAL); - - emuldata_set_robust(curproc, args->head); - - return (0); -} - - - -int -sys_linux_get_robust_list(struct linux_get_robust_list_args *args) -{ - struct linux_emuldata *em; - struct linux_robust_list_head empty_head; - struct linux_robust_list_head *head; - l_size_t len = sizeof(struct linux_robust_list_head); - int error = 0; - -#ifdef DEBUG - if (ldebug(get_robust_list)) - kprintf(ARGS(get_robust_list, "")); -#endif - - if (args->pid == 0) { - EMUL_LOCK(); - em = emuldata_get(curproc); - KKASSERT(em != NULL); - if (em->robust_futexes == NULL) { - bzero(&empty_head, sizeof(empty_head)); - head = &empty_head; - } else { - head = em->robust_futexes; - } - EMUL_UNLOCK(); - } else { - struct proc *p; - - p = pfind(args->pid); - if (p == NULL) { - return (ESRCH); - } - - EMUL_LOCK(); - em = emuldata_get(p); - head = em->robust_futexes; - EMUL_UNLOCK(); - /* XXX: ptrace? p_candebug?*/ - if (priv_check(curthread, PRIV_CRED_SETUID) || - priv_check(curthread, PRIV_CRED_SETEUID)/* || - p_candebug(curproc, p) */) { - PRELE(p); - return (EPERM); - } - PRELE(p); - } - - error = copyout(&len, args->len, sizeof(l_size_t)); - if (error) - return (EFAULT); - - error = copyout(head, args->head, sizeof(struct linux_robust_list_head)); - - return (error); -} - -static int -handle_futex_death(struct proc *p, uint32_t *uaddr, int pi) -{ - uint32_t uval, nval, mval; - struct futex *f; - int error; - -retry: - if (copyin(uaddr, &uval, 4)) - return (EFAULT); - if ((uval & FUTEX_TID_MASK) == p->p_pid) { - mval = (uval & FUTEX_WAITERS) | FUTEX_OWNER_DIED; - nval = casuword((u_long *)uaddr, uval, mval); - - if (nval == -1) - return (EFAULT); - - if (nval != uval) - goto retry; - - if (!pi && (uval & FUTEX_WAITERS)) { - error = futex_get(uaddr, NULL, &f, - FUTEX_DONTCREATE); - if (error) - return (error); - if (f != NULL) { - futex_wake(f, 1); - futex_put(f, NULL); - } - } - } - - return (0); -} - -static int -fetch_robust_entry(struct linux_robust_list **entry, - struct linux_robust_list **head, int *pi) -{ - l_ulong uentry; - - if (copyin((const void *)head, &uentry, sizeof(l_ulong))) - return (EFAULT); - - *entry = (void *)(uentry & ~1UL); - *pi = uentry & 1; - - return (0); -} - -/* This walks the list of robust futexes releasing them. */ -void -release_futexes(struct proc *p) -{ - struct linux_robust_list_head *head = NULL; - struct linux_robust_list *entry, *next_entry, *pending; - unsigned int limit = 2048, pi, next_pi, pip; - struct linux_emuldata *em; - l_long futex_offset; - int rc; - - EMUL_LOCK(); - KKASSERT(p != NULL); - em = emuldata_get(p); - KKASSERT(em != NULL); - head = em->robust_futexes; - EMUL_UNLOCK(); - - if (head == NULL) - return; - - if (fetch_robust_entry(&entry, PTRIN(&head->list.next), &pi)) - return; - - if (copyin(&head->futex_offset, &futex_offset, sizeof(futex_offset))) - return; - - if (fetch_robust_entry(&pending, PTRIN(&head->pending_list), &pip)) - return; - - while (entry != &head->list) { - rc = fetch_robust_entry(&next_entry, PTRIN(&entry->next), &next_pi); - - if (entry != pending) - if (handle_futex_death(p, (uint32_t *)entry + futex_offset, pi)) - return; - if (rc) - return; - - entry = next_entry; - pi = next_pi; - - if (!--limit) - break; - - /* XXX: not sure about this yield, was sched_relinquish(curthread); */ - lwkt_yield(); - } - - if (pending) - handle_futex_death(p, (uint32_t *)pending + futex_offset, pip); -} diff --git a/sys/emulation/linux/linux_futex.h b/sys/emulation/linux/linux_futex.h deleted file mode 100644 index d9335ebdbf..0000000000 --- a/sys/emulation/linux/linux_futex.h +++ /dev/null @@ -1,87 +0,0 @@ -/* $NetBSD: linux_futex.h,v 1.3 2008/10/126 16:38:22 christos Exp $ */ - -/*- - * Copyright (c) 2005 Emmanuel Dreyfus, all rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Emmanuel Dreyfus - * 4. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE 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. - */ - -#ifndef _LINUX_FUTEX_H -#define _LINUX_FUTEX_H - -extern LIST_HEAD(futex_list, futex) futex_list; -extern struct lock futex_lock; - -#define LINUX_FUTEX_WAIT 0 -#define LINUX_FUTEX_WAKE 1 -#define LINUX_FUTEX_FD 2 /* unused */ -#define LINUX_FUTEX_REQUEUE 3 -#define LINUX_FUTEX_CMP_REQUEUE 4 -#define LINUX_FUTEX_WAKE_OP 5 - -/* XXX: what are these? netbsd doesn't have them */ -#define LINUX_FUTEX_LOCK_PI 6 -#define LINUX_FUTEX_UNLOCK_PI 7 -#define LINUX_FUTEX_TRYLOCK_PI 8 - -#define LINUX_FUTEX_PRIVATE_FLAG 128 - -#define FUTEX_OP_SET 0 /* *(int *)UADDR2 = OPARG; */ -#define FUTEX_OP_ADD 1 /* *(int *)UADDR2 += OPARG; */ -#define FUTEX_OP_OR 2 /* *(int *)UADDR2 |= OPARG; */ -#define FUTEX_OP_ANDN 3 /* *(int *)UADDR2 &= ~OPARG; */ -#define FUTEX_OP_XOR 4 /* *(int *)UADDR2 ^= OPARG; */ - -#define FUTEX_OP_OPARG_SHIFT 8 /* Use (1 << OPARG) instead of OPARG. */ - -#define FUTEX_OP_CMP_EQ 0 /* if (oldval == CMPARG) wake */ -#define FUTEX_OP_CMP_NE 1 /* if (oldval != CMPARG) wake */ -#define FUTEX_OP_CMP_LT 2 /* if (oldval < CMPARG) wake */ -#define FUTEX_OP_CMP_LE 3 /* if (oldval <= CMPARG) wake */ -#define FUTEX_OP_CMP_GT 4 /* if (oldval > CMPARG) wake */ -#define FUTEX_OP_CMP_GE 5 /* if (oldval >= CMPARG) wake */ - -#define FUTEX_WAITERS 0x80000000 -#define FUTEX_OWNER_DIED 0x40000000 -#define FUTEX_TID_MASK 0x3fffffff - - -/* robust futexes */ -struct linux_robust_list { - struct linux_robust_list *next; -}; - -struct linux_robust_list_head { - struct linux_robust_list list; - l_long futex_offset; - struct linux_robust_list *pending_list; -}; - -void release_futexes(struct proc *); -extern struct lock futex_mtx; -#endif /* !_LINUX_FUTEX_H */ diff --git a/sys/emulation/linux/linux_getcwd.c b/sys/emulation/linux/linux_getcwd.c deleted file mode 100644 index e8ad1b8513..0000000000 --- a/sys/emulation/linux/linux_getcwd.c +++ /dev/null @@ -1,105 +0,0 @@ -/* $FreeBSD: src/sys/compat/linux/linux_getcwd.c,v 1.2.2.3 2001/11/05 19:08:22 marcel Exp $ */ -/* $DragonFly: src/sys/emulation/linux/linux_getcwd.c,v 1.23 2006/12/23 00:27:02 swildner Exp $ */ -/* $OpenBSD: linux_getcwd.c,v 1.2 2001/05/16 12:50:21 ho Exp $ */ -/* $NetBSD: vfs_getcwd.c,v 1.3.2.3 1999/07/11 10:24:09 sommerfeld Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Bill Sommerfeld. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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. - */ -#include "opt_compat.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include /* XXX only for DIRBLKSIZ */ - -#include - -#include -#include -#include "linux_util.h" - -/* - * Find pathname of process's current directory. - * - * Use vfs vnode-to-name reverse cache; if that fails, fall back - * to reading directory contents. - * - * MPALMOSTSAFE - */ -int -sys_linux_getcwd(struct linux_getcwd_args *args) -{ - int buflen; - int error; - char *buf; - char *bp; - -#ifdef DEBUG - kprintf("Linux-emul(%d): getcwd(%p, %d)\n", - (curthread->td_proc ? (int)curthread->td_proc->p_pid : -1), - args->buf, args->bufsize); -#endif - buflen = args->bufsize; - if (buflen < 2) - return (EINVAL); - if (buflen > MAXPATHLEN) - buflen = MAXPATHLEN; - - buf = kmalloc(buflen, M_TEMP, M_WAITOK); - get_mplock(); - bp = kern_getcwd(buf, buflen, &error); - rel_mplock(); - if (error == 0) { - buflen = strlen(bp) + 1; - error = copyout(bp, args->buf, buflen); - args->sysmsg_result = buflen; - } - kfree(buf, M_TEMP); - return (error); -} - diff --git a/sys/emulation/linux/linux_ioctl.c b/sys/emulation/linux/linux_ioctl.c deleted file mode 100644 index e006c839bf..0000000000 --- a/sys/emulation/linux/linux_ioctl.c +++ /dev/null @@ -1,1427 +0,0 @@ -/* - * Copyright (c) 1994-1995 Søren Schmidt - * Copyright (c) 2004 Simon 'corecode' Schubert - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer - * in this position and unchanged. - * 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 - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD: src/sys/compat/linux/linux_ioctl.c,v 1.55.2.11 2003/05/01 20:16:09 anholt Exp $ - * $DragonFly: src/sys/emulation/linux/linux_ioctl.c,v 1.25 2008/03/07 11:34:19 sephe Exp $ - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include "linux_ioctl.h" -#include "linux_mib.h" -#include "linux_util.h" - - -static int -linux_ioctl_BLKGETSIZE32(struct file *fp, u_long cmd, u_long ocmd, - caddr_t data, struct ucred *cred) -{ - struct partinfo dpart; - u_int32_t value; - int error; - - error = fo_ioctl(fp, DIOCGPART, (caddr_t)&dpart, cred, NULL); - if (error) - return (error); - value = dpart.media_blocks; /* 64->32 */ - bcopy(&value, data, sizeof(value)); - return (0); -} - - -/* - * termio related ioctls - */ - -struct linux_termio { - unsigned short c_iflag; - unsigned short c_oflag; - unsigned short c_cflag; - unsigned short c_lflag; - unsigned char c_line; - unsigned char c_cc[LINUX_NCC]; -}; - -struct linux_termios { - unsigned int c_iflag; - unsigned int c_oflag; - unsigned int c_cflag; - unsigned int c_lflag; - unsigned char c_line; - unsigned char c_cc[LINUX_NCCS]; -}; - -struct linux_winsize { - unsigned short ws_row, ws_col; - unsigned short ws_xpixel, ws_ypixel; -}; - -static struct speedtab sptab[] = { - { B0, LINUX_B0 }, { B50, LINUX_B50 }, - { B75, LINUX_B75 }, { B110, LINUX_B110 }, - { B134, LINUX_B134 }, { B150, LINUX_B150 }, - { B200, LINUX_B200 }, { B300, LINUX_B300 }, - { B600, LINUX_B600 }, { B1200, LINUX_B1200 }, - { B1800, LINUX_B1800 }, { B2400, LINUX_B2400 }, - { B4800, LINUX_B4800 }, { B9600, LINUX_B9600 }, - { B19200, LINUX_B19200 }, { B38400, LINUX_B38400 }, - { B57600, LINUX_B57600 }, { B115200, LINUX_B115200 }, - {-1, -1 } -}; - -struct linux_serial_struct { - int type; - int line; - int port; - int irq; - int flags; - int xmit_fifo_size; - int custom_divisor; - int baud_base; - unsigned short close_delay; - char reserved_char[2]; - int hub6; - unsigned short closing_wait; - unsigned short closing_wait2; - int reserved[4]; -}; - -static int -linux_to_bsd_speed(int code, struct speedtab *table) -{ - for ( ; table->sp_code != -1; table++) - if (table->sp_code == code) - return (table->sp_speed); - return -1; -} - -static int -bsd_to_linux_speed(int speed, struct speedtab *table) -{ - for ( ; table->sp_speed != -1; table++) - if (table->sp_speed == speed) - return (table->sp_code); - return -1; -} - -static void -bsd_to_linux_termios(struct termios *bios, struct linux_termios *lios) -{ - int i; - -#ifdef DEBUG - if (ldebug(ioctl)) { - kprintf("LINUX: BSD termios structure (input):\n"); - kprintf("i=%08x o=%08x c=%08x l=%08x ispeed=%d ospeed=%d\n", - bios->c_iflag, bios->c_oflag, bios->c_cflag, bios->c_lflag, - bios->c_ispeed, bios->c_ospeed); - kprintf("c_cc "); - for (i=0; ic_cc[i]); - kprintf("\n"); - } -#endif - - lios->c_iflag = 0; - if (bios->c_iflag & IGNBRK) - lios->c_iflag |= LINUX_IGNBRK; - if (bios->c_iflag & BRKINT) - lios->c_iflag |= LINUX_BRKINT; - if (bios->c_iflag & IGNPAR) - lios->c_iflag |= LINUX_IGNPAR; - if (bios->c_iflag & PARMRK) - lios->c_iflag |= LINUX_PARMRK; - if (bios->c_iflag & INPCK) - lios->c_iflag |= LINUX_INPCK; - if (bios->c_iflag & ISTRIP) - lios->c_iflag |= LINUX_ISTRIP; - if (bios->c_iflag & INLCR) - lios->c_iflag |= LINUX_INLCR; - if (bios->c_iflag & IGNCR) - lios->c_iflag |= LINUX_IGNCR; - if (bios->c_iflag & ICRNL) - lios->c_iflag |= LINUX_ICRNL; - if (bios->c_iflag & IXON) - lios->c_iflag |= LINUX_IXON; - if (bios->c_iflag & IXANY) - lios->c_iflag |= LINUX_IXANY; - if (bios->c_iflag & IXOFF) - lios->c_iflag |= LINUX_IXOFF; - if (bios->c_iflag & IMAXBEL) - lios->c_iflag |= LINUX_IMAXBEL; - - lios->c_oflag = 0; - if (bios->c_oflag & OPOST) - lios->c_oflag |= LINUX_OPOST; - if (bios->c_oflag & ONLCR) - lios->c_oflag |= LINUX_ONLCR; - if (bios->c_oflag & OXTABS) - lios->c_oflag |= LINUX_XTABS; - - lios->c_cflag = bsd_to_linux_speed(bios->c_ispeed, sptab); - lios->c_cflag |= (bios->c_cflag & CSIZE) >> 4; - if (bios->c_cflag & CSTOPB) - lios->c_cflag |= LINUX_CSTOPB; - if (bios->c_cflag & CREAD) - lios->c_cflag |= LINUX_CREAD; - if (bios->c_cflag & PARENB) - lios->c_cflag |= LINUX_PARENB; - if (bios->c_cflag & PARODD) - lios->c_cflag |= LINUX_PARODD; - if (bios->c_cflag & HUPCL) - lios->c_cflag |= LINUX_HUPCL; - if (bios->c_cflag & CLOCAL) - lios->c_cflag |= LINUX_CLOCAL; - if (bios->c_cflag & CRTSCTS) - lios->c_cflag |= LINUX_CRTSCTS; - - lios->c_lflag = 0; - if (bios->c_lflag & ISIG) - lios->c_lflag |= LINUX_ISIG; - if (bios->c_lflag & ICANON) - lios->c_lflag |= LINUX_ICANON; - if (bios->c_lflag & ECHO) - lios->c_lflag |= LINUX_ECHO; - if (bios->c_lflag & ECHOE) - lios->c_lflag |= LINUX_ECHOE; - if (bios->c_lflag & ECHOK) - lios->c_lflag |= LINUX_ECHOK; - if (bios->c_lflag & ECHONL) - lios->c_lflag |= LINUX_ECHONL; - if (bios->c_lflag & NOFLSH) - lios->c_lflag |= LINUX_NOFLSH; - if (bios->c_lflag & TOSTOP) - lios->c_lflag |= LINUX_TOSTOP; - if (bios->c_lflag & ECHOCTL) - lios->c_lflag |= LINUX_ECHOCTL; - if (bios->c_lflag & ECHOPRT) - lios->c_lflag |= LINUX_ECHOPRT; - if (bios->c_lflag & ECHOKE) - lios->c_lflag |= LINUX_ECHOKE; - if (bios->c_lflag & FLUSHO) - lios->c_lflag |= LINUX_FLUSHO; - if (bios->c_lflag & PENDIN) - lios->c_lflag |= LINUX_PENDIN; - if (bios->c_lflag & IEXTEN) - lios->c_lflag |= LINUX_IEXTEN; - - for (i=0; ic_cc[i] = LINUX_POSIX_VDISABLE; - lios->c_cc[LINUX_VINTR] = bios->c_cc[VINTR]; - lios->c_cc[LINUX_VQUIT] = bios->c_cc[VQUIT]; - lios->c_cc[LINUX_VERASE] = bios->c_cc[VERASE]; - lios->c_cc[LINUX_VKILL] = bios->c_cc[VKILL]; - lios->c_cc[LINUX_VEOF] = bios->c_cc[VEOF]; - lios->c_cc[LINUX_VEOL] = bios->c_cc[VEOL]; - lios->c_cc[LINUX_VMIN] = bios->c_cc[VMIN]; - lios->c_cc[LINUX_VTIME] = bios->c_cc[VTIME]; - lios->c_cc[LINUX_VEOL2] = bios->c_cc[VEOL2]; - lios->c_cc[LINUX_VSUSP] = bios->c_cc[VSUSP]; - lios->c_cc[LINUX_VSTART] = bios->c_cc[VSTART]; - lios->c_cc[LINUX_VSTOP] = bios->c_cc[VSTOP]; - lios->c_cc[LINUX_VREPRINT] = bios->c_cc[VREPRINT]; - lios->c_cc[LINUX_VDISCARD] = bios->c_cc[VDISCARD]; - lios->c_cc[LINUX_VWERASE] = bios->c_cc[VWERASE]; - lios->c_cc[LINUX_VLNEXT] = bios->c_cc[VLNEXT]; - - for (i=0; ic_cc[i] == _POSIX_VDISABLE) - lios->c_cc[i] = LINUX_POSIX_VDISABLE; - } - lios->c_line = 0; - -#ifdef DEBUG - if (ldebug(ioctl)) { - kprintf("LINUX: LINUX termios structure (output):\n"); - kprintf("i=%08x o=%08x c=%08x l=%08x line=%d\n", - lios->c_iflag, lios->c_oflag, lios->c_cflag, - lios->c_lflag, (int)lios->c_line); - kprintf("c_cc "); - for (i=0; ic_cc[i]); - kprintf("\n"); - } -#endif -} - -static void -linux_to_bsd_termios(struct linux_termios *lios, struct termios *bios) -{ - int i; - -#ifdef DEBUG - if (ldebug(ioctl)) { - kprintf("LINUX: LINUX termios structure (input):\n"); - kprintf("i=%08x o=%08x c=%08x l=%08x line=%d\n", - lios->c_iflag, lios->c_oflag, lios->c_cflag, - lios->c_lflag, (int)lios->c_line); - kprintf("c_cc "); - for (i=0; ic_cc[i]); - kprintf("\n"); - } -#endif - - bios->c_iflag = 0; - if (lios->c_iflag & LINUX_IGNBRK) - bios->c_iflag |= IGNBRK; - if (lios->c_iflag & LINUX_BRKINT) - bios->c_iflag |= BRKINT; - if (lios->c_iflag & LINUX_IGNPAR) - bios->c_iflag |= IGNPAR; - if (lios->c_iflag & LINUX_PARMRK) - bios->c_iflag |= PARMRK; - if (lios->c_iflag & LINUX_INPCK) - bios->c_iflag |= INPCK; - if (lios->c_iflag & LINUX_ISTRIP) - bios->c_iflag |= ISTRIP; - if (lios->c_iflag & LINUX_INLCR) - bios->c_iflag |= INLCR; - if (lios->c_iflag & LINUX_IGNCR) - bios->c_iflag |= IGNCR; - if (lios->c_iflag & LINUX_ICRNL) - bios->c_iflag |= ICRNL; - if (lios->c_iflag & LINUX_IXON) - bios->c_iflag |= IXON; - if (lios->c_iflag & LINUX_IXANY) - bios->c_iflag |= IXANY; - if (lios->c_iflag & LINUX_IXOFF) - bios->c_iflag |= IXOFF; - if (lios->c_iflag & LINUX_IMAXBEL) - bios->c_iflag |= IMAXBEL; - - bios->c_oflag = 0; - if (lios->c_oflag & LINUX_OPOST) - bios->c_oflag |= OPOST; - if (lios->c_oflag & LINUX_ONLCR) - bios->c_oflag |= ONLCR; - if (lios->c_oflag & LINUX_XTABS) - bios->c_oflag |= OXTABS; - - bios->c_cflag = (lios->c_cflag & LINUX_CSIZE) << 4; - if (lios->c_cflag & LINUX_CSTOPB) - bios->c_cflag |= CSTOPB; - if (lios->c_cflag & LINUX_CREAD) - bios->c_cflag |= CREAD; - if (lios->c_cflag & LINUX_PARENB) - bios->c_cflag |= PARENB; - if (lios->c_cflag & LINUX_PARODD) - bios->c_cflag |= PARODD; - if (lios->c_cflag & LINUX_HUPCL) - bios->c_cflag |= HUPCL; - if (lios->c_cflag & LINUX_CLOCAL) - bios->c_cflag |= CLOCAL; - if (lios->c_cflag & LINUX_CRTSCTS) - bios->c_cflag |= CRTSCTS; - - bios->c_lflag = 0; - if (lios->c_lflag & LINUX_ISIG) - bios->c_lflag |= ISIG; - if (lios->c_lflag & LINUX_ICANON) - bios->c_lflag |= ICANON; - if (lios->c_lflag & LINUX_ECHO) - bios->c_lflag |= ECHO; - if (lios->c_lflag & LINUX_ECHOE) - bios->c_lflag |= ECHOE; - if (lios->c_lflag & LINUX_ECHOK) - bios->c_lflag |= ECHOK; - if (lios->c_lflag & LINUX_ECHONL) - bios->c_lflag |= ECHONL; - if (lios->c_lflag & LINUX_NOFLSH) - bios->c_lflag |= NOFLSH; - if (lios->c_lflag & LINUX_TOSTOP) - bios->c_lflag |= TOSTOP; - if (lios->c_lflag & LINUX_ECHOCTL) - bios->c_lflag |= ECHOCTL; - if (lios->c_lflag & LINUX_ECHOPRT) - bios->c_lflag |= ECHOPRT; - if (lios->c_lflag & LINUX_ECHOKE) - bios->c_lflag |= ECHOKE; - if (lios->c_lflag & LINUX_FLUSHO) - bios->c_lflag |= FLUSHO; - if (lios->c_lflag & LINUX_PENDIN) - bios->c_lflag |= PENDIN; - if (lios->c_lflag & LINUX_IEXTEN) - bios->c_lflag |= IEXTEN; - - for (i=0; ic_cc[i] = _POSIX_VDISABLE; - bios->c_cc[VINTR] = lios->c_cc[LINUX_VINTR]; - bios->c_cc[VQUIT] = lios->c_cc[LINUX_VQUIT]; - bios->c_cc[VERASE] = lios->c_cc[LINUX_VERASE]; - bios->c_cc[VKILL] = lios->c_cc[LINUX_VKILL]; - bios->c_cc[VEOF] = lios->c_cc[LINUX_VEOF]; - bios->c_cc[VEOL] = lios->c_cc[LINUX_VEOL]; - bios->c_cc[VMIN] = lios->c_cc[LINUX_VMIN]; - bios->c_cc[VTIME] = lios->c_cc[LINUX_VTIME]; - bios->c_cc[VEOL2] = lios->c_cc[LINUX_VEOL2]; - bios->c_cc[VSUSP] = lios->c_cc[LINUX_VSUSP]; - bios->c_cc[VSTART] = lios->c_cc[LINUX_VSTART]; - bios->c_cc[VSTOP] = lios->c_cc[LINUX_VSTOP]; - bios->c_cc[VREPRINT] = lios->c_cc[LINUX_VREPRINT]; - bios->c_cc[VDISCARD] = lios->c_cc[LINUX_VDISCARD]; - bios->c_cc[VWERASE] = lios->c_cc[LINUX_VWERASE]; - bios->c_cc[VLNEXT] = lios->c_cc[LINUX_VLNEXT]; - - for (i=0; ic_cc[i] == LINUX_POSIX_VDISABLE) - bios->c_cc[i] = _POSIX_VDISABLE; - } - - bios->c_ispeed = bios->c_ospeed = - linux_to_bsd_speed(lios->c_cflag & LINUX_CBAUD, sptab); - -#ifdef DEBUG - if (ldebug(ioctl)) { - kprintf("LINUX: BSD termios structure (output):\n"); - kprintf("i=%08x o=%08x c=%08x l=%08x ispeed=%d ospeed=%d\n", - bios->c_iflag, bios->c_oflag, bios->c_cflag, bios->c_lflag, - bios->c_ispeed, bios->c_ospeed); - kprintf("c_cc "); - for (i=0; ic_cc[i]); - kprintf("\n"); - } -#endif -} - -static void -bsd_to_linux_termio(struct termios *bios, struct linux_termio *lio) -{ - struct linux_termios lios; - - bsd_to_linux_termios(bios, &lios); - lio->c_iflag = lios.c_iflag; - lio->c_oflag = lios.c_oflag; - lio->c_cflag = lios.c_cflag; - lio->c_lflag = lios.c_lflag; - lio->c_line = lios.c_line; - memcpy(lio->c_cc, lios.c_cc, LINUX_NCC); -} - -static void -linux_to_bsd_termio(struct linux_termio *lio, struct termios *bios) -{ - struct linux_termios lios; - int i; - - lios.c_iflag = lio->c_iflag; - lios.c_oflag = lio->c_oflag; - lios.c_cflag = lio->c_cflag; - lios.c_lflag = lio->c_lflag; - for (i=LINUX_NCC; ic_cc, LINUX_NCC); - linux_to_bsd_termios(&lios, bios); -} - -static int -linux_ioctl_TCGETS(struct file *fp, u_long cmd, u_long ocmd, caddr_t data, struct ucred *cred) -{ - struct termios bios; - struct linux_termios lios; - int error; - - error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bios, cred, NULL); - if (error) - return (error); - bsd_to_linux_termios(&bios, &lios); - bcopy(&lios, data, sizeof(lios)); - return (0); -} - -static int -linux_ioctl_TCSETS(struct file *fp, u_long cmd, u_long ocmd, caddr_t data, struct ucred *cred) -{ - struct termios bios; - struct linux_termios lios; - - bcopy(data, &lios, sizeof(lios)); - linux_to_bsd_termios(&lios, &bios); - return (fo_ioctl(fp, TIOCSETA, (caddr_t)&bios, cred, NULL)); -} - -static int -linux_ioctl_TCSETSW(struct file *fp, u_long cmd, u_long ocmd, caddr_t data, struct ucred *cred) -{ - struct termios bios; - struct linux_termios lios; - - bcopy(data, &lios, sizeof(lios)); - linux_to_bsd_termios(&lios, &bios); - return (fo_ioctl(fp, TIOCSETAW, (caddr_t)&bios, cred, NULL)); -} - -static int -linux_ioctl_TCSETSF(struct file *fp, u_long cmd, u_long ocmd, caddr_t data, struct ucred *cred) -{ - struct termios bios; - struct linux_termios lios; - - bcopy(data, &lios, sizeof(lios)); - linux_to_bsd_termios(&lios, &bios); - return (fo_ioctl(fp, TIOCSETAF, (caddr_t)&bios, cred, NULL)); -} - -static int -linux_ioctl_TCGETA(struct file *fp, u_long cmd, u_long ocmd, caddr_t data, struct ucred *cred) -{ - struct termios bios; - struct linux_termio lio; - int error; - - error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bios, cred, NULL); - if (error) - return (error); - bsd_to_linux_termio(&bios, &lio); - bcopy(&lio, data, sizeof(lio)); - return (0); -} - -static int -linux_ioctl_TCSETA(struct file *fp, u_long cmd, u_long ocmd, caddr_t data, struct ucred *cred) -{ - struct termios bios; - struct linux_termio lio; - - bcopy(data, &lio, sizeof(lio)); - linux_to_bsd_termio(&lio, &bios); - return (fo_ioctl(fp, TIOCSETA, (caddr_t)&bios, cred, NULL)); -} - -static int -linux_ioctl_TCSETAW(struct file *fp, u_long cmd, u_long ocmd, caddr_t data, struct ucred *cred) -{ - struct termios bios; - struct linux_termio lio; - - bcopy(data, &lio, sizeof(lio)); - linux_to_bsd_termio(&lio, &bios); - return (fo_ioctl(fp, TIOCSETAW, (caddr_t)&bios, cred, NULL)); -} - -static int -linux_ioctl_TCSETAF(struct file *fp, u_long cmd, u_long ocmd, caddr_t data, struct ucred *cred) -{ - struct termios bios; - struct linux_termio lio; - - bcopy(data, &lio, sizeof(lio)); - linux_to_bsd_termio(&lio, &bios); - return (fo_ioctl(fp, TIOCSETAF, (caddr_t)&bios, cred, NULL)); -} - -static int -linux_ioctl_TIOCLINUX(struct file *fp, u_long cmd, u_long ocmd, caddr_t data, struct ucred *cred) -{ - switch ((u_char)*data) { - case 11: /* LINUX_TIOCLINUX_KERNMSG */ - return 0; - default: - kprintf("Unknown LINUX_TIOCLINUX: %d\n", ((u_char)*data)); - kprintf("cmd = %lu, ocmd = %lu\n", cmd, ocmd); - return 0; - } - return 0; -} - -static int -linux_ioctl_TCXONC(struct file *fp, u_long cmd, u_long ocmd, caddr_t data, struct ucred *cred) -{ - switch ((u_long)data) { - case LINUX_TCOOFF: - cmd = TIOCSTOP; - break; - case LINUX_TCOON: - cmd = TIOCSTART; - break; - case LINUX_TCIOFF: - case LINUX_TCION: { - struct termios bios; - int error, c; - - error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bios, cred, NULL); - if (error) - return (error); - c = ((u_long)data == LINUX_TCIOFF) ? VSTOP : VSTART; - c = bios.c_cc[c]; - if (c != _POSIX_VDISABLE) { - struct uio auio; - struct iovec aiov; - - aiov.iov_base = (char *)&c; - aiov.iov_len = sizeof(*bios.c_cc); - auio.uio_iov = &aiov; - auio.uio_iovcnt = 1; - auio.uio_offset = -1; - auio.uio_resid = sizeof(*bios.c_cc); - auio.uio_rw = UIO_WRITE; - auio.uio_segflg = UIO_SYSSPACE; - auio.uio_td = curthread; - - return (fo_write(fp, &auio, fp->f_cred, 0)); - } - - return (0); - } - default: - return (EINVAL); - } - return (fo_ioctl(fp, cmd, 0, cred, NULL)); -} - -static int -linux_ioctl_TCFLSH(struct file *fp, u_long cmd, u_long ocmd, caddr_t data, struct ucred *cred) -{ - switch ((u_long)data) { - case LINUX_TCIFLUSH: - *(u_long *)data = FREAD; - break; - case LINUX_TCOFLUSH: - *(u_long *)data = FWRITE; - break; - case LINUX_TCIOFLUSH: - *(u_long *)data = FREAD | FWRITE; - break; - default: - return (EINVAL); - } - return (fo_ioctl(fp, TIOCFLUSH, data, cred, NULL)); -} - -static int -linux_ioctl_TIOCGSERIAL(struct file *fp, u_long cmd, u_long ocmd, caddr_t data, struct ucred *cred) -{ - struct linux_serial_struct lss; - - lss.type = LINUX_PORT_16550A; - lss.flags = 0; - lss.close_delay = 0; - bcopy(&lss, data, sizeof(lss)); - return (0); -} - -static int -linux_ioctl_TIOCSSERIAL(struct file *fp, u_long cmd, u_long ocmd, caddr_t data, struct ucred *cred) -{ -#if 0 - struct linux_serial_struct lss; - - bcopy(data, &lss, sizeof(lss)); - /* XXX - It really helps to have an implementation that - * does nothing. NOT! - */ -#endif - return (0); -} - -static int -linux_ioctl_TIOCSETD(struct file *fp, u_long cmd, u_long ocmd, caddr_t data, struct ucred *cred) -{ - int line; - - switch ((u_long)data) { - case LINUX_N_TTY: - line = TTYDISC; - break; - case LINUX_N_SLIP: - line = SLIPDISC; - break; - case LINUX_N_PPP: - line = PPPDISC; - break; - default: - return (EINVAL); - } - return (fo_ioctl(fp, TIOCSETD, (caddr_t)&line, cred, NULL)); -} - -static int -linux_ioctl_TIOCGETD(struct file *fp, u_long cmd, u_long ocmd, caddr_t data, struct ucred *cred) -{ - int linux_line, error; - int bsd_line = TTYDISC; - - error = fo_ioctl(fp, TIOCGETD, (caddr_t)&bsd_line, cred, NULL); - if (error) - return (error); - switch (bsd_line) { - case TTYDISC: - linux_line = LINUX_N_TTY; - break; - case SLIPDISC: - linux_line = LINUX_N_SLIP; - break; - case PPPDISC: - linux_line = LINUX_N_PPP; - break; - default: - return (EINVAL); - } - bcopy(&linux_line, data, sizeof(int)); - return (0); -} - - -/* - * CDROM related ioctls - */ - -struct linux_cdrom_msf -{ - u_char cdmsf_min0; - u_char cdmsf_sec0; - u_char cdmsf_frame0; - u_char cdmsf_min1; - u_char cdmsf_sec1; - u_char cdmsf_frame1; -}; - -struct linux_cdrom_tochdr -{ - u_char cdth_trk0; - u_char cdth_trk1; -}; - -union linux_cdrom_addr -{ - struct { - u_char minute; - u_char second; - u_char frame; - } msf; - int lba; -}; - -struct linux_cdrom_tocentry -{ - u_char cdte_track; - u_char cdte_adr:4; - u_char cdte_ctrl:4; - u_char cdte_format; - union linux_cdrom_addr cdte_addr; - u_char cdte_datamode; -}; - -struct linux_cdrom_subchnl -{ - u_char cdsc_format; - u_char cdsc_audiostatus; - u_char cdsc_adr:4; - u_char cdsc_ctrl:4; - u_char cdsc_trk; - u_char cdsc_ind; - union linux_cdrom_addr cdsc_absaddr; - union linux_cdrom_addr cdsc_reladdr; -}; - -static void -bsd_to_linux_msf_lba(u_char af, union msf_lba *bp, union linux_cdrom_addr *lp) -{ - if (af == CD_LBA_FORMAT) - lp->lba = bp->lba; - else { - lp->msf.minute = bp->msf.minute; - lp->msf.second = bp->msf.second; - lp->msf.frame = bp->msf.frame; - } -} - -static void -set_linux_cdrom_addr(union linux_cdrom_addr *addr, int format, int lba) -{ - if (format == LINUX_CDROM_MSF) { - addr->msf.frame = lba % 75; - lba /= 75; - lba += 2; - addr->msf.second = lba % 60; - addr->msf.minute = lba / 60; - } else - addr->lba = lba; -} - -static int -linux_ioctl_CDROMREADTOCHDR(struct file *fp, u_long cmd, u_long ocmd, caddr_t data, struct ucred *cred) -{ - struct ioc_toc_header th; - struct linux_cdrom_tochdr lth; - int error; - - error = fo_ioctl(fp, CDIOREADTOCHEADER, (caddr_t)&th, cred, NULL); - if (error) - return (error); - lth.cdth_trk0 = th.starting_track; - lth.cdth_trk1 = th.ending_track; - bcopy(<h, data, sizeof(lth)); - return (0); -} - -static int -linux_ioctl_CDROMREADTOCENTRY(struct file *fp, u_long cmd, u_long ocmd, caddr_t data, struct ucred *cred) -{ - struct linux_cdrom_tocentry *ltep = (struct linux_cdrom_tocentry *)data; - struct ioc_read_toc_single_entry irtse; - int error; - - irtse.address_format = ltep->cdte_format; - irtse.track = ltep->cdte_track; - error = fo_ioctl(fp, CDIOREADTOCENTRY, (caddr_t)&irtse, cred, NULL); - if (error) - return (error); - - ltep->cdte_ctrl = irtse.entry.control; - ltep->cdte_adr = irtse.entry.addr_type; - bsd_to_linux_msf_lba(irtse.address_format, &irtse.entry.addr, - <ep->cdte_addr); - return (0); -} - -static int -linux_ioctl_CDROMSUBCHNL(struct file *fp, u_long cmd, u_long ocmd, caddr_t data, struct ucred *cred) -{ - struct linux_cdrom_subchnl *sc = (struct linux_cdrom_subchnl *)data; - struct ioc_read_subchannel bsdsc; - struct cd_sub_channel_info *bsdinfo; - int error; - caddr_t sg = stackgap_init(); - - bsdinfo = stackgap_alloc(&sg, sizeof(struct cd_sub_channel_info)); - bsdsc.address_format = CD_LBA_FORMAT; - bsdsc.data_format = CD_CURRENT_POSITION; - bsdsc.track = 0; - bsdsc.data_len = sizeof(struct cd_sub_channel_info); - bsdsc.data = bsdinfo; - error = fo_ioctl(fp, CDIOCREADSUBCHANNEL, (caddr_t)&bsdsc, cred, NULL); - if (error) - return (error); - sc->cdsc_audiostatus = bsdinfo->header.audio_status; - sc->cdsc_adr = bsdinfo->what.position.addr_type; - sc->cdsc_ctrl = bsdinfo->what.position.control; - sc->cdsc_trk = bsdinfo->what.position.track_number; - sc->cdsc_ind = bsdinfo->what.position.index_number; - set_linux_cdrom_addr(&sc->cdsc_absaddr, sc->cdsc_format, bsdinfo->what.position.absaddr.lba); - set_linux_cdrom_addr(&sc->cdsc_reladdr, sc->cdsc_format, bsdinfo->what.position.reladdr.lba); - return (0); -} - - -/* - * Sound related ioctls - */ - -static int -linux_ioctl_OSS_GETVERSION(struct file *fp, u_long cmd, u_long ocmd, caddr_t data, struct ucred *cred) -{ - int version = linux_get_oss_version(curthread); - - bcopy(&version, data, sizeof(int)); - return (0); -} - - -/* - * Console related ioctls - */ - -#define ISSIGVALID(sig) ((sig) > 0 && (sig) < NSIG) - -static int -linux_ioctl_KDSKBMODE(struct file *fp, u_long cmd, u_long ocmd, caddr_t data, struct ucred *cred) -{ - int kbdmode; - - switch ((u_long)data) { - case LINUX_KBD_RAW: - kbdmode = K_RAW; - break; - case LINUX_KBD_XLATE: - kbdmode = K_XLATE; - break; - case LINUX_KBD_MEDIUMRAW: - kbdmode = K_RAW; - break; - default: - return (EINVAL); - } - return (fo_ioctl(fp, KDSKBMODE, (caddr_t)&kbdmode, cred, NULL)); -} - -static int -linux_ioctl_VT_SETMODE(struct file *fp, u_long cmd, u_long ocmd, caddr_t data, struct ucred *cred) -{ - struct vt_mode *mode = (struct vt_mode *)data; - - if (!ISSIGVALID(mode->frsig) && ISSIGVALID(mode->acqsig)) - mode->frsig = mode->acqsig; - return (fo_ioctl(fp, VT_SETMODE, data, cred, NULL)); -} - - -/* - * Socket related ioctls - */ - -/* - * Criteria for interface name translation - */ -#define IFP_IS_ETH(ifp) (ifp->if_type == IFT_ETHER) - -/* - * Interface function used by linprocfs (at the time of writing). It's not - * used by the Linuxulator itself. - */ -int -linux_ifname(struct ifnet *ifp, char *buffer, size_t buflen) -{ - struct ifnet *ifscan; - int ethno; - - /* Short-circuit non ethernet interfaces */ - if (!IFP_IS_ETH(ifp)) - return (strlcpy(buffer, ifp->if_xname, buflen)); - - /* Determine the (relative) unit number for ethernet interfaces */ - ethno = 0; - TAILQ_FOREACH(ifscan, &ifnetlist, if_link) { - if (ifscan == ifp) - return (ksnprintf(buffer, buflen, "eth%d", ethno)); - if (IFP_IS_ETH(ifscan)) - ethno++; - } - - return (0); -} - -/* - * Translate a Linux interface name to a FreeBSD interface name, - * and return the associated ifnet structure - * bsdname and lxname need to be least IFNAMSIZ bytes long, but - * can point to the same buffer. - */ - -static struct ifnet * -ifname_linux_to_bsd(const char *lxname, char *bsdname) -{ - struct ifnet *ifp; - int len, unit; - char *ep; - int is_eth, index; - - for (len = 0; len < LINUX_IFNAMSIZ; ++len) - if (!isalpha(lxname[len])) - break; - if (len == 0 || len == LINUX_IFNAMSIZ) - return (NULL); - unit = (int)strtoul(lxname + len, &ep, 10); - if (ep == NULL || ep == lxname + len || ep >= lxname + LINUX_IFNAMSIZ) - return (NULL); - index = 0; - is_eth = (len == 3 && !strncmp(lxname, "eth", len)) ? 1 : 0; - TAILQ_FOREACH(ifp, &ifnetlist, if_link) { - /* - * Allow Linux programs to use FreeBSD names. Don't presume - * we never have an interface named "eth", so don't make - * the test optional based on is_eth. - */ - if (strncmp(ifp->if_xname, lxname, LINUX_IFNAMSIZ) == 0) - break; - if (is_eth && IFP_IS_ETH(ifp) && unit == index++) - break; - } - if (ifp != NULL) - strlcpy(bsdname, ifp->if_xname, IFNAMSIZ); - return (ifp); -} - -static int -linux_ioctl_SIOCGIFCONF(struct file *fp, u_long cmd, u_long ocmd, caddr_t data, struct ucred *cred) -{ - struct ifconf *ifc = (struct ifconf *)data; - struct l_ifreq ifr; - struct ifnet *ifp; - struct iovec iov; - struct uio uio; - int error, ethno; - - /* much easier to use uiomove than keep track ourselves */ - iov.iov_base = ifc->ifc_buf; - iov.iov_len = ifc->ifc_len; - uio.uio_iov = &iov; - uio.uio_iovcnt = 1; - uio.uio_offset = 0; - uio.uio_resid = ifc->ifc_len; - uio.uio_segflg = UIO_USERSPACE; - uio.uio_rw = UIO_READ; - uio.uio_td = curthread; - - /* Keep track of eth interfaces */ - ethno = 0; - - /* Return all AF_INET addresses of all interfaces */ - ifnet_lock(); - TAILQ_FOREACH(ifp, &ifnetlist, if_link) { - struct ifaddr_container *ifac, *ifac_mark; - struct ifaddr_marker mark; - struct ifaddrhead *head; - - if (uio.uio_resid <= 0) - break; - - bzero(&ifr, sizeof ifr); - if (IFP_IS_ETH(ifp)) - ksnprintf(ifr.ifr_name, LINUX_IFNAMSIZ, "eth%d", - ethno++); - else - strlcpy(ifr.ifr_name, ifp->if_xname, LINUX_IFNAMSIZ); - - /* - * Walk the address list - * - * Add a marker, since uiomove() could block and during that - * period the list could be changed. Inserting the marker to - * the header of the list will not cause trouble for the code - * assuming that the first element of the list is AF_LINK; the - * marker will be moved to the next position w/o blocking. - */ - ifa_marker_init(&mark, ifp); - ifac_mark = &mark.ifac; - head = &ifp->if_addrheads[mycpuid]; - - TAILQ_INSERT_HEAD(head, ifac_mark, ifa_link); - while ((ifac = TAILQ_NEXT(ifac_mark, ifa_link)) != NULL) { - struct ifaddr *ifa = ifac->ifa; - struct sockaddr *sa = ifa->ifa_addr; - - TAILQ_REMOVE(head, ifac_mark, ifa_link); - TAILQ_INSERT_AFTER(head, ifac, ifac_mark, ifa_link); - - if (uio.uio_resid <= 0) - break; - - if (sa->sa_family == AF_INET) { - ifr.ifr_addr.sa_family = LINUX_AF_INET; - memcpy(ifr.ifr_addr.sa_data, sa->sa_data, - sizeof(ifr.ifr_addr.sa_data)); - - error = uiomove((caddr_t)&ifr, sizeof ifr, - &uio); - if (error != 0) { - TAILQ_REMOVE(head, ifac_mark, ifa_link); - ifnet_unlock(); - return (error); - } - } - } - TAILQ_REMOVE(head, ifac_mark, ifa_link); - } - ifnet_unlock(); - - ifc->ifc_len -= uio.uio_resid; - - return (0); -} - -static int -linux_ioctl_SIOCGIFFLAGS(struct file *fp, u_long cmd, u_long ocmd, caddr_t data, struct ucred *cred) -{ - struct l_ifreq *ifr = (struct l_ifreq *)data; - struct ifnet *ifp; - char ifname[IFNAMSIZ]; - l_short flags; - -#if 0 - if (fp->f_type != DTYPE_SOCKET) { - /* XXX: I doubt this is correct because - * we don't translate the ifname and - * use l_ifreq instead of ifreq - */ - return (fo_ioctl(fp, SIOCGIFFLAGS, data, cred, NULL)); - } -#endif - - ifnet_lock(); - - ifp = ifname_linux_to_bsd(ifr->ifr_name, ifname); - if (ifp == NULL) { - ifnet_unlock(); - return (EINVAL); - } - flags = ifp->if_flags; - - ifnet_unlock(); - - /* these flags have no Linux equivalent */ - flags &= ~(IFF_SMART|IFF_SIMPLEX| IFF_LINK0|IFF_LINK1|IFF_LINK2); - /* Linux' multicast flag is in a different bit */ - if (flags & IFF_MULTICAST) { - flags &= ~IFF_MULTICAST; - flags |= 0x1000; - } - - ifr->ifr_flags = flags; - return (0); -} - -#define ARPHRD_ETHER 1 -#define ARPHRD_LOOPBACK 772 - -/* XXX: could implement using native ioctl, so only mapping */ -static int -linux_ioctl_SIOCGIFINDEX(struct file *fp, u_long cmd, u_long ocmd, caddr_t data, struct ucred *cred) -{ - struct l_ifreq *ifr = (struct l_ifreq *)data; - struct ifnet *ifp; - char ifname[IFNAMSIZ]; - l_int index; - - ifnet_lock(); - - ifp = ifname_linux_to_bsd(ifr->ifr_name, ifname); - if (ifp == NULL) { - ifnet_unlock(); - return EINVAL; - } -#if DEBUG - kprintf("Interface index: %d\n", ifp->if_index); -#endif - index = ifp->if_index; - - ifnet_unlock(); - - return (copyout(&index, &ifr->ifr_ifindex, sizeof(index))); -} - -static int -linux_ioctl_SIOCGIFMETRIC(struct file *fp, u_long cmd, u_long ocmd, caddr_t data, struct ucred *cred) -{ - struct l_ifreq *ifr = (struct l_ifreq *)data; - struct ifnet *ifp; - char ifname[IFNAMSIZ]; - l_int metric; - - ifnet_lock(); - - ifp = ifname_linux_to_bsd(ifr->ifr_name, ifname); - if (ifp == NULL) { - ifnet_unlock(); - return EINVAL; - } - metric = ifp->if_metric; - - ifnet_unlock(); - - return (copyout(&metric, &ifr->ifr_ifmetric, sizeof(metric))); -} - -static int -linux_ioctl_SIOGIFHWADDR(struct file *fp, u_long cmd, u_long ocmd, caddr_t data, struct ucred *cred) -{ - struct l_ifreq *ifr = (struct l_ifreq *)data; - struct ifnet *ifp; - char ifname[IFNAMSIZ]; - struct sockaddr_dl *sdl; - struct l_sockaddr lsa; - struct ifaddr_container *ifac; - - ifnet_lock(); - - ifp = ifname_linux_to_bsd(ifr->ifr_name, ifname); - if (ifp == NULL) { - ifnet_unlock(); - return EINVAL; - } - - if (ifp->if_type == IFT_LOOP) { - ifnet_unlock(); - bzero(&ifr->ifr_hwaddr, sizeof lsa); - ifr->ifr_hwaddr.sa_family = ARPHRD_LOOPBACK; - return (0); - } - - if (ifp->if_type != IFT_ETHER) { - ifnet_unlock(); - return (ENOENT); - } - - TAILQ_FOREACH(ifac, &ifp->if_addrheads[mycpuid], ifa_link) { - struct ifaddr *ifa = ifac->ifa; - - sdl = (struct sockaddr_dl*)ifa->ifa_addr; - if (sdl != NULL && (sdl->sdl_family == AF_LINK) && - (sdl->sdl_type == IFT_ETHER)) { - bzero(&ifr->ifr_hwaddr, sizeof lsa); - ifr->ifr_hwaddr.sa_family = ARPHRD_ETHER; - bcopy(LLADDR(sdl), ifr->ifr_hwaddr.sa_data, LINUX_IFHWADDRLEN); - ifnet_unlock(); - return (0); - } - } - - ifnet_unlock(); - return (ENOENT); -} - -static int -linux_ioctl_map_ifname(struct file *fp, u_long cmd, u_long ocmd, caddr_t data, struct ucred *cred) -{ - struct ifnet *ifp; - int error; - char *oifname = (char *)data; - char lifname[LINUX_IFNAMSIZ]; - - KASSERT(LINUX_IFNAMSIZ == IFNAMSIZ, - ("%s(): LINUX_IFNAMSIZ != IFNAMSIZ", __func__)); - - if (fp->f_type != DTYPE_SOCKET) { - /* - * XXX: I doubt this is correct because - * we don't map the ifname - */ - /* not a socket - probably a tap / vmnet device */ - if (ocmd == LINUX_SIOCGIFADDR || ocmd == LINUX_SIOCSIFADDR) { - cmd = (ocmd == LINUX_SIOCGIFADDR) ? SIOCGIFADDR : SIOCSIFADDR; - return (fo_ioctl(fp, cmd, data, cred, NULL)); - } else - return (ENOIOCTL); - } - - /* Save the original ifname */ - bcopy(oifname, lifname, LINUX_IFNAMSIZ); -#ifdef DEBUG - kprintf("%s(): ioctl %d on %.*s\n", __func__, - (int)(cmd & 0xffff), LINUX_IFNAMSIZ, lifname); -#endif - ifnet_lock(); - /* Replace linux ifname with bsd ifname */ - ifp = ifname_linux_to_bsd(lifname, oifname); - if (ifp == NULL) { - error = EINVAL; - ifnet_unlock(): - goto clean_ifname; - } - ifnet_unlock(): - -#ifdef DEBUG - kprintf("%s(): %s translated to %s\n", __func__, - lifname, oifname); -#endif - - error = fo_ioctl(fp, cmd, data, cred, NULL); - -clean_ifname: - bcopy(lifname, oifname, LINUX_IFNAMSIZ); - return (error); -} - - -/* - * generic linux -> BSD syscall direction mapper - */ -u_long -linux_gen_dirmap(u_long lstart, u_long lend, u_long bstart, u_long bend, u_long cmd, u_long ocmd) -{ - static u_int32_t dirbits[4] = { IOC_VOID, IOC_IN, IOC_OUT, IOC_INOUT }; - - return ((cmd & ~IOC_DIRMASK) | dirbits[ocmd >> 30]); -} - - -static struct ioctl_map_range linux_ioctl_map_entries[] = { - /* disk ioctl */ - MAPPED_IOCTL_IOR(LINUX_BLKGETSIZE, linux_ioctl_BLKGETSIZE32, uint32_t), - /* termio ioctl */ - MAPPED_IOCTL_IOR(LINUX_TCGETS, linux_ioctl_TCGETS, struct linux_termios), - MAPPED_IOCTL_IOW(LINUX_TCSETS, linux_ioctl_TCSETS, struct linux_termios), - MAPPED_IOCTL_IOW(LINUX_TCSETSW, linux_ioctl_TCSETSW, struct linux_termios), - MAPPED_IOCTL_IOW(LINUX_TCSETSF, linux_ioctl_TCSETSF, struct linux_termios), - MAPPED_IOCTL_IOR(LINUX_TCGETA, linux_ioctl_TCGETA, struct linux_termio), - MAPPED_IOCTL_IOW(LINUX_TCSETA, linux_ioctl_TCSETA, struct linux_termio), - MAPPED_IOCTL_IOW(LINUX_TCSETAW, linux_ioctl_TCSETAW, struct linux_termio), - MAPPED_IOCTL_IOW(LINUX_TCSETAF, linux_ioctl_TCSETAF, struct linux_termio), - MAPPED_IOCTL_IO(LINUX_TCXONC, linux_ioctl_TCXONC), - MAPPED_IOCTL_IO(LINUX_TCFLSH, linux_ioctl_TCFLSH), - MAPPED_IOCTL_IO(LINUX_TIOCLINUX, linux_ioctl_TIOCLINUX), - MAPPED_IOCTL_MAP(LINUX_TIOCEXCL, TIOCEXCL), - MAPPED_IOCTL_MAP(LINUX_TIOCNXCL, TIOCNXCL), - MAPPED_IOCTL_MAP(LINUX_TIOCGPGRP, TIOCGPGRP), - MAPPED_IOCTL_MAP(LINUX_TIOCSPGRP, TIOCSPGRP), - MAPPED_IOCTL_MAP(LINUX_TIOCGWINSZ, TIOCGWINSZ), - MAPPED_IOCTL_MAP(LINUX_TIOCSWINSZ, TIOCSWINSZ), - MAPPED_IOCTL_MAP(LINUX_TIOCMGET, TIOCMGET), - MAPPED_IOCTL_MAP(LINUX_TIOCMBIS, TIOCMBIS), - MAPPED_IOCTL_MAP(LINUX_TIOCMBIC, TIOCMBIC), - MAPPED_IOCTL_MAP(LINUX_TIOCMSET, TIOCMSET), - MAPPED_IOCTL_MAP(LINUX_FIONREAD, FIONREAD), - MAPPED_IOCTL_MAP(LINUX_TIOCCONS, TIOCCONS), - MAPPED_IOCTL_IOR(LINUX_TIOCGSERIAL, linux_ioctl_TIOCGSERIAL, struct linux_serial_struct), - MAPPED_IOCTL_IOW(LINUX_TIOCSSERIAL, linux_ioctl_TIOCSSERIAL, struct linux_serial_struct), - MAPPED_IOCTL_MAP(LINUX_FIONBIO, FIONBIO), - MAPPED_IOCTL_MAP(LINUX_TIOCNOTTY, TIOCNOTTY), - MAPPED_IOCTL_IO(LINUX_TIOCSETD, linux_ioctl_TIOCSETD), - MAPPED_IOCTL_IOR(LINUX_TIOCGETD, linux_ioctl_TIOCGETD, int), - MAPPED_IOCTL_MAP(LINUX_FIONCLEX, FIONCLEX), - MAPPED_IOCTL_MAP(LINUX_FIOCLEX, FIOCLEX), - MAPPED_IOCTL_MAP(LINUX_FIOASYNC, FIOASYNC), - /* cdrom ioctl */ - MAPPED_IOCTL_MAP(LINUX_CDROMPAUSE, CDIOCPAUSE), - MAPPED_IOCTL_MAP(LINUX_CDROMRESUME, CDIOCRESUME), - MAPPED_IOCTL_MAP(LINUX_CDROMPLAYMSF, CDIOCPLAYMSF), - MAPPED_IOCTL_MAP(LINUX_CDROMPLAYTRKIND, CDIOCPLAYTRACKS), - MAPPED_IOCTL_IOR(LINUX_CDROMREADTOCHDR, linux_ioctl_CDROMREADTOCHDR, struct linux_cdrom_tochdr), - MAPPED_IOCTL_IOWR(LINUX_CDROMREADTOCENTRY, linux_ioctl_CDROMREADTOCENTRY, struct linux_cdrom_tocentry), - MAPPED_IOCTL_MAP(LINUX_CDROMSTOP, CDIOCSTOP), - MAPPED_IOCTL_MAP(LINUX_CDROMSTART, CDIOCSTART), - MAPPED_IOCTL_MAP(LINUX_CDROMEJECT, CDIOCEJECT), - MAPPED_IOCTL_IOWR(LINUX_CDROMSUBCHNL, linux_ioctl_CDROMSUBCHNL, struct linux_cdrom_subchnl), - MAPPED_IOCTL_MAP(LINUX_CDROMRESET, CDIOCRESET), - /* sound ioctl */ - MAPPED_IOCTL_MAPRANGE(LINUX_SOUND_MIXER_WRITE_MIN, LINUX_SOUND_MIXER_WRITE_MAX, - LINUX_SOUND_MIXER_WRITE_MIN, LINUX_SOUND_MIXER_WRITE_MAX, - NULL, linux_gen_dirmap), - MAPPED_IOCTL_IOR(LINUX_OSS_GETVERSION, linux_ioctl_OSS_GETVERSION, int), - MAPPED_IOCTL_MAP(LINUX_SOUND_MIXER_READ_DEVMASK, SOUND_MIXER_READ_DEVMASK), - MAPPED_IOCTL_MAPRANGE(LINUX_SNDCTL_DSP_MIN, LINUX_SNDCTL_DSP_MAX, LINUX_SNDCTL_DSP_MIN, - LINUX_SNDCTL_DSP_MAX, NULL, linux_gen_dirmap), - MAPPED_IOCTL_MAPRANGE(LINUX_SNDCTL_SEQ_MIN, LINUX_SNDCTL_SEQ_MAX, LINUX_SNDCTL_SEQ_MIN, - LINUX_SNDCTL_SEQ_MAX, NULL, linux_gen_dirmap), - /* console ioctl */ - MAPPED_IOCTL_MAP(LINUX_KIOCSOUND, KIOCSOUND), - MAPPED_IOCTL_MAP(LINUX_KDMKTONE, KDMKTONE), - MAPPED_IOCTL_MAP(LINUX_KDGETLED, KDGETLED), - MAPPED_IOCTL_MAP(LINUX_KDSETLED, KDSETLED), - MAPPED_IOCTL_MAP(LINUX_KDSETMODE, KDSETMODE), - MAPPED_IOCTL_MAP(LINUX_KDGETMODE, KDGETMODE), - MAPPED_IOCTL_MAP(LINUX_KDGKBMODE, KDGKBMODE), - MAPPED_IOCTL_IOW(LINUX_KDSKBMODE, linux_ioctl_KDSKBMODE, int), - MAPPED_IOCTL_MAP(LINUX_VT_OPENQRY, VT_OPENQRY), - MAPPED_IOCTL_MAP(LINUX_VT_GETMODE, VT_GETMODE), - MAPPED_IOCTL_IOW(LINUX_VT_SETMODE, linux_ioctl_VT_SETMODE, struct vt_mode), - MAPPED_IOCTL_MAP(LINUX_VT_GETSTATE, VT_GETACTIVE), - MAPPED_IOCTL_MAP(LINUX_VT_RELDISP, VT_RELDISP), - MAPPED_IOCTL_MAP(LINUX_VT_ACTIVATE, VT_ACTIVATE), - MAPPED_IOCTL_MAP(LINUX_VT_WAITACTIVE, VT_WAITACTIVE), - /* socket ioctl */ - MAPPED_IOCTL_MAP(LINUX_FIOSETOWN, FIOSETOWN), - MAPPED_IOCTL_MAP(LINUX_SIOCSPGRP, SIOCSPGRP), - MAPPED_IOCTL_MAP(LINUX_FIOGETOWN, FIOGETOWN), - MAPPED_IOCTL_MAP(LINUX_SIOCGPGRP, SIOCGPGRP), - MAPPED_IOCTL_MAP(LINUX_SIOCATMARK, SIOCATMARK), - MAPPED_IOCTL_IOWR(LINUX_SIOCGIFCONF, linux_ioctl_SIOCGIFCONF, struct ifconf), - MAPPED_IOCTL_IOWR(LINUX_SIOCGIFFLAGS, linux_ioctl_SIOCGIFFLAGS, struct l_ifreq), - MAPPED_IOCTL_MAPF(LINUX_SIOCGIFADDR, OSIOCGIFADDR, linux_ioctl_map_ifname), - MAPPED_IOCTL_MAPF(LINUX_SIOCSIFADDR, SIOCSIFADDR, linux_ioctl_map_ifname), - MAPPED_IOCTL_MAPF(LINUX_SIOCGIFDSTADDR, OSIOCGIFDSTADDR, linux_ioctl_map_ifname), - MAPPED_IOCTL_MAPF(LINUX_SIOCGIFBRDADDR, OSIOCGIFBRDADDR, linux_ioctl_map_ifname), - MAPPED_IOCTL_MAPF(LINUX_SIOCGIFNETMASK, OSIOCGIFNETMASK, linux_ioctl_map_ifname), - /*MAPPED_IOCTL_IOx(LINUX_SIOCSIFNETMASK, x, x),*/ - MAPPED_IOCTL_MAPF(LINUX_SIOCGIFMTU, SIOCGIFMTU, linux_ioctl_map_ifname), - MAPPED_IOCTL_MAPF(LINUX_SIOCSIFMTU, SIOCSIFMTU, linux_ioctl_map_ifname), - MAPPED_IOCTL_IOWR(LINUX_SIOCGIFHWADDR, linux_ioctl_SIOGIFHWADDR, struct l_ifreq), - MAPPED_IOCTL_IOR(LINUX_SIOCGIFINDEX, linux_ioctl_SIOCGIFINDEX, struct l_ifreq), - MAPPED_IOCTL_IOR(LINUX_SIOCGIFMETRIC, linux_ioctl_SIOCGIFMETRIC, struct l_ifreq), - MAPPED_IOCTL_MAP(LINUX_SIOCADDMULTI, SIOCADDMULTI), - MAPPED_IOCTL_MAP(LINUX_SIOCDELMULTI, SIOCDELMULTI), - /* - * XXX This is slightly bogus, but these ioctls are currently - * XXX only used by the aironet (if_an) network driver. - */ - MAPPED_IOCTL_MAPF(LINUX_SIOCDEVPRIVATE, SIOCGPRIVATE_0, linux_ioctl_map_ifname), - MAPPED_IOCTL_MAPF(LINUX_SIOCDEVPRIVATE+1, SIOCGPRIVATE_1, linux_ioctl_map_ifname), - MAPPED_IOCTL_MAPF(0, 0, NULL) - }; - -struct ioctl_map linux_ioctl_map = { - 0xffff, /* mask */ - "linux", /* subsys */ - LIST_HEAD_INITIALIZER(mapping) - }; - -static struct ioctl_map_handler linux_ioctl_base_handler = { - &linux_ioctl_map, - "base", - linux_ioctl_map_entries - }; - -/* - * main ioctl syscall function - * - * MPALMOSTSAFE - */ -int -sys_linux_ioctl(struct linux_ioctl_args *args) -{ - int error; - -#ifdef DEBUG - if (ldebug(ioctl)) - kprintf(ARGS(ioctl, "%d, %04x, *"), args->fd, args->cmd); -#endif - - get_mplock(); - error = mapped_ioctl(args->fd, args->cmd, (caddr_t)args->arg, - &linux_ioctl_map, &args->sysmsg); - rel_mplock(); - return (error); -} - -SYSINIT (linux_ioctl_register, SI_BOOT2_KLD, SI_ORDER_MIDDLE, - mapped_ioctl_register_handler, &linux_ioctl_base_handler); -SYSUNINIT(linux_ioctl_register, SI_BOOT2_KLD, SI_ORDER_MIDDLE, - mapped_ioctl_unregister_handler, &linux_ioctl_base_handler); diff --git a/sys/emulation/linux/linux_ioctl.h b/sys/emulation/linux/linux_ioctl.h deleted file mode 100644 index 004c9edda7..0000000000 --- a/sys/emulation/linux/linux_ioctl.h +++ /dev/null @@ -1,528 +0,0 @@ -/* - * Copyright (c) 1999 Marcel Moolenaar - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer - * in this position and unchanged. - * 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 - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD: src/sys/compat/linux/linux_ioctl.h,v 1.4.2.4 2003/05/01 20:16:09 anholt Exp $ - * $DragonFly: src/sys/emulation/linux/linux_ioctl.h,v 1.6 2005/04/22 02:18:46 swildner Exp $ - */ - -#ifndef _LINUX_IOCTL_H_ -#define _LINUX_IOCTL_H_ - -/* - * direction flags - */ -#define LINUX_IOC_VOID 0x00000000 -#define LINUX_IOC_IN 0x40000000 -#define LINUX_IOC_OUT 0x80000000 -#define LINUX_IOC_INOUT (LINUX_IOC_IN | LINUX_IOC_OUT) -#define LINUX_IOC_DIRMASK 0xc0000000 - -/* - * disk - */ -#define LINUX_BLKROSET 0x125d -#define LINUX_BLKROGET 0x125e -#define LINUX_BLKRRPART 0x125f -#define LINUX_BLKGETSIZE 0x1260 -#define LINUX_BLKFLSBUF 0x1261 -#define LINUX_BLKRASET 0x1262 -#define LINUX_BLKRAGET 0x1263 -#define LINUX_BLKFRASET 0x1264 -#define LINUX_BLKFRAGET 0x1265 -#define LINUX_BLKSECTSET 0x1266 -#define LINUX_BLKSECTGET 0x1267 -#define LINUX_BLKSSZGET 0x1268 - -#define LINUX_IOCTL_DISK_MIN LINUX_BLKROSET -#define LINUX_IOCTL_DISK_MAX LINUX_BLKSSZGET - -/* - * hdio - */ -#define LINUX_HDIO_GET_GEO 0x0301 -#define LINUX_HDIO_GET_IDENTITY 0x030D /* not yet implemented */ -#define LINUX_HDIO_GET_GEO_BIG 0x0330 - -#define LINUX_IOCTL_HDIO_MIN LINUX_HDIO_GET_GEO -#define LINUX_IOCTL_HDIO_MAX LINUX_HDIO_GET_GEO_BIG - -/* - * cdrom - */ -#define LINUX_CDROMPAUSE 0x5301 -#define LINUX_CDROMRESUME 0x5302 -#define LINUX_CDROMPLAYMSF 0x5303 -#define LINUX_CDROMPLAYTRKIND 0x5304 -#define LINUX_CDROMREADTOCHDR 0x5305 -#define LINUX_CDROMREADTOCENTRY 0x5306 -#define LINUX_CDROMSTOP 0x5307 -#define LINUX_CDROMSTART 0x5308 -#define LINUX_CDROMEJECT 0x5309 -#define LINUX_CDROMVOLCTRL 0x530a -#define LINUX_CDROMSUBCHNL 0x530b -#define LINUX_CDROMREADMODE2 0x530c -#define LINUX_CDROMREADMODE1 0x530d -#define LINUX_CDROMREADAUDIO 0x530e -#define LINUX_CDROMEJECT_SW 0x530f -#define LINUX_CDROMMULTISESSION 0x5310 -#define LINUX_CDROM_GET_UPC 0x5311 -#define LINUX_CDROMRESET 0x5312 -#define LINUX_CDROMVOLREAD 0x5313 -#define LINUX_CDROMREADRAW 0x5314 -#define LINUX_CDROMREADCOOKED 0x5315 -#define LINUX_CDROMSEEK 0x5316 -#define LINUX_CDROMPLAYBLK 0x5317 -#define LINUX_CDROMREADALL 0x5318 -#define LINUX_CDROMCLOSETRAY 0x5319 -#define LINUX_CDROMLOADFROMSLOT 0x531a -#define LINUX_CDROMGETSPINDOWN 0x531d -#define LINUX_CDROMSETSPINDOWN 0x531e -#define LINUX_CDROM_SET_OPTIONS 0x5320 -#define LINUX_CDROM_CLEAR_OPTIONS 0x5321 -#define LINUX_CDROM_SELECT_SPEED 0x5322 -#define LINUX_CDROM_SELECT_DISC 0x5323 -#define LINUX_CDROM_MEDIA_CHANGED 0x5325 -#define LINUX_CDROM_DRIVE_STATUS 0x5326 -#define LINUX_CDROM_DISC_STATUS 0x5327 -#define LINUX_CDROM_CHANGER_NSLOTS 0x5328 -#define LINUX_CDROM_LOCKDOOR 0x5329 -#define LINUX_CDROM_DEBUG 0x5330 -#define LINUX_CDROM_GET_CAPABILITY 0x5331 -#define LINUX_CDROMAUDIOBUFSIZ 0x5382 -#define LINUX_SCSI_GET_IDLUN 0x5382 -#define LINUX_SCSI_GET_BUS_NUMBER 0x5386 -#define LINUX_DVD_READ_STRUCT 0x5390 -#define LINUX_DVD_WRITE_STRUCT 0x5391 -#define LINUX_DVD_AUTH 0x5392 -#define LINUX_CDROM_SEND_PACKET 0x5393 -#define LINUX_CDROM_NEXT_WRITABLE 0x5394 -#define LINUX_CDROM_LAST_WRITTEN 0x5395 - -#define LINUX_IOCTL_CDROM_MIN LINUX_CDROMPAUSE -#define LINUX_IOCTL_CDROM_MAX LINUX_CDROM_LAST_WRITTEN - -#define LINUX_CDROM_LBA 0x01 -#define LINUX_CDROM_MSF 0x02 - -#define LINUX_DVD_LU_SEND_AGID 0 -#define LINUX_DVD_HOST_SEND_CHALLENGE 1 -#define LINUX_DVD_LU_SEND_KEY1 2 -#define LINUX_DVD_LU_SEND_CHALLENGE 3 -#define LINUX_DVD_HOST_SEND_KEY2 4 -#define LINUX_DVD_AUTH_ESTABLISHED 5 -#define LINUX_DVD_AUTH_FAILURE 6 -#define LINUX_DVD_LU_SEND_TITLE_KEY 7 -#define LINUX_DVD_LU_SEND_ASF 8 -#define LINUX_DVD_INVALIDATE_AGID 9 -#define LINUX_DVD_LU_SEND_RPC_STATE 10 -#define LINUX_DVD_HOST_SEND_RPC_STATE 11 - -/* - * SG - */ -#define LINUX_SG_SET_TIMEOUT 0x2201 -#define LINUX_SG_GET_TIMEOUT 0x2202 -#define LINUX_SG_EMULATED_HOST 0x2203 -#define LINUX_SG_SET_TRANSFORM 0x2204 -#define LINUX_SG_GET_TRANSFORM 0x2205 -#define LINUX_SG_GET_COMMAND_Q 0x2270 -#define LINUX_SG_SET_COMMAND_Q 0x2271 -#define LINUX_SG_SET_RESERVED_SIZE 0x2275 -#define LINUX_SG_GET_RESERVED_SIZE 0x2272 -#define LINUX_SG_GET_SCSI_ID 0x2276 -#define LINUX_SG_SET_FORCE_LOW_DMA 0x2279 -#define LINUX_SG_GET_LOW_DMA 0x227a -#define LINUX_SG_SET_FORCE_PACK_ID 0x227b -#define LINUX_SG_GET_PACK_ID 0x227c -#define LINUX_SG_GET_NUM_WAITING 0x227d -#define LINUX_SG_SET_DEBUG 0x227e -#define LINUX_SG_GET_SG_TABLESIZE 0x227f -#define LINUX_SG_GET_VERSION_NUM 0x2282 -#define LINUX_SG_NEXT_CMD_LEN 0x2283 -#define LINUX_SG_SCSI_RESET 0x2284 -#define LINUX_SG_IO 0x2285 -#define LINUX_SG_GET_REQUEST_TABLE 0x2286 -#define LINUX_SG_SET_KEEP_ORPHAN 0x2287 -#define LINUX_SG_GET_KEEP_ORPHAN 0x2288 -#define LINUX_SG_GET_ACCESS_COUNT 0x2289 - -#define LINUX_IOCTL_SG_MIN 0x2200 -#define LINUX_IOCTL_SG_MAX 0x22ff - -/* - * VFAT - */ -#define LINUX_VFAT_READDIR_BOTH 0x7201 - -#define LINUX_IOCTL_VFAT_MIN LINUX_VFAT_READDIR_BOTH -#define LINUX_IOCTL_VFAT_MAX LINUX_VFAT_READDIR_BOTH -/* - * console - */ -#define LINUX_KIOCSOUND 0x4B2F -#define LINUX_KDMKTONE 0x4B30 -#define LINUX_KDGETLED 0x4B31 -#define LINUX_KDSETLED 0x4B32 -#define LINUX_KDSETMODE 0x4B3A -#define LINUX_KDGETMODE 0x4B3B -#define LINUX_KDGKBMODE 0x4B44 -#define LINUX_KDSKBMODE 0x4B45 -#define LINUX_VT_OPENQRY 0x5600 -#define LINUX_VT_GETMODE 0x5601 -#define LINUX_VT_SETMODE 0x5602 -#define LINUX_VT_GETSTATE 0x5603 -#define LINUX_VT_RELDISP 0x5605 -#define LINUX_VT_ACTIVATE 0x5606 -#define LINUX_VT_WAITACTIVE 0x5607 - -#define LINUX_IOCTL_CONSOLE_MIN LINUX_KIOCSOUND -#define LINUX_IOCTL_CONSOLE_MAX LINUX_VT_WAITACTIVE - -#define LINUX_LED_SCR 0x01 -#define LINUX_LED_NUM 0x02 -#define LINUX_LED_CAP 0x04 - -#define LINUX_KD_TEXT 0x0 -#define LINUX_KD_GRAPHICS 0x1 -#define LINUX_KD_TEXT0 0x2 -#define LINUX_KD_TEXT1 0x3 - -#define LINUX_KBD_RAW 0 -#define LINUX_KBD_XLATE 1 -#define LINUX_KBD_MEDIUMRAW 2 - -/* - * socket (http://lxr.oss.org.cn/source/include/linux/sockios.h) - */ -#define LINUX_FIOSETOWN 0x8901 -#define LINUX_SIOCSPGRP 0x8902 -#define LINUX_FIOGETOWN 0x8903 -#define LINUX_SIOCGPGRP 0x8904 -#define LINUX_SIOCATMARK 0x8905 -#define LINUX_SIOCGSTAMP 0x8906 -#define LINUX_SIOCGIFCONF 0x8912 -#define LINUX_SIOCGIFFLAGS 0x8913 -#define LINUX_SIOCGIFADDR 0x8915 -#define LINUX_SIOCSIFADDR 0x8916 -#define LINUX_SIOCGIFDSTADDR 0x8917 -#define LINUX_SIOCGIFBRDADDR 0x8919 -#define LINUX_SIOCGIFNETMASK 0x891b -#define LINUX_SIOCSIFNETMASK 0x891c -#define LINUX_SIOCGIFMETRIC 0x891d /* get metric */ -#define LINUX_SIOCGIFMTU 0x8921 -#define LINUX_SIOCSIFMTU 0x8922 -#define LINUX_SIOCSIFNAME 0x8923 -#define LINUX_SIOCSIFHWADDR 0x8924 -#define LINUX_SIOCGIFHWADDR 0x8927 -#define LINUX_SIOCADDMULTI 0x8931 -#define LINUX_SIOCDELMULTI 0x8932 -#define LINUX_SIOCGIFINDEX 0x8933 /* name -> if_index mapping */ -#define LINUX_SIOCGIFCOUNT 0x8938 /* get number of devices */ -#define LINUX_SIOCGIFTXQLEN 0x8942 /* Get the tx queue length */ -#define LINUX_SIOCGIFMAP 0x8970 /* Get device parameters */ - - -#define LINUX_IOCTL_SOCKET_MIN LINUX_FIOSETOWN -#define LINUX_IOCTL_SOCKET_MAX LINUX_SIOCGIFMAP - -/* - * Device private ioctl calls - */ -#define LINUX_SIOCDEVPRIVATE 0x89F0 /* to 89FF */ -#define LINUX_IOCTL_PRIVATE_MIN LINUX_SIOCDEVPRIVATE -#define LINUX_IOCTL_PRIVATE_MAX LINUX_SIOCDEVPRIVATE+0xf - -/* - * sound - */ -#define LINUX_SOUND_MIXER_WRITE_MIN 0x4d00 -#define LINUX_SOUND_MIXER_WRITE_MAX 0x4d18 -#define LINUX_OSS_GETVERSION 0x4d76 -#define LINUX_SOUND_MIXER_READ_DEVMASK 0x4dfe -#define LINUX_SNDCTL_DSP_MIN 0x5000 -#define LINUX_SNDCTL_DSP_MAX 0x5017 -#define LINUX_SNDCTL_SEQ_MIN 0x5100 -#define LINUX_SNDCTL_SEQ_MAX 0x5116 - -#define LINUX_IOCTL_SOUND_MIN LINUX_SOUND_MIXER_WRITE_MIN -#define LINUX_IOCTL_SOUND_MAX LINUX_SNDCTL_SEQ_MAX - -/* - * termio - */ -#define LINUX_TCGETS 0x5401 -#define LINUX_TCSETS 0x5402 -#define LINUX_TCSETSW 0x5403 -#define LINUX_TCSETSF 0x5404 -#define LINUX_TCGETA 0x5405 -#define LINUX_TCSETA 0x5406 -#define LINUX_TCSETAW 0x5407 -#define LINUX_TCSETAF 0x5408 -#define LINUX_TCSBRK 0x5409 -#define LINUX_TCXONC 0x540A -#define LINUX_TCFLSH 0x540B - -#define LINUX_TIOCEXCL 0x540C -#define LINUX_TIOCNXCL 0x540D -#define LINUX_TIOCSCTTY 0x540E - -#define LINUX_TIOCGPGRP 0x540F -#define LINUX_TIOCSPGRP 0x5410 - -#define LINUX_TIOCOUTQ 0x5411 -#define LINUX_TIOCSTI 0x5412 - -#define LINUX_TIOCGWINSZ 0x5413 -#define LINUX_TIOCSWINSZ 0x5414 - -#define LINUX_TIOCMGET 0x5415 -#define LINUX_TIOCMBIS 0x5416 -#define LINUX_TIOCMBIC 0x5417 -#define LINUX_TIOCMSET 0x5418 -#define LINUX_TIOCGSOFTCAR 0x5419 -#define LINUX_TIOCSSOFTCAR 0x541A - -#define LINUX_FIONREAD 0x541B - -#define LINUX_TIOCINQ FIONREAD -#define LINUX_TIOCLINUX 0x541C -#define LINUX_TIOCCONS 0x541D -#define LINUX_TIOCGSERIAL 0x541E -#define LINUX_TIOCSSERIAL 0x541F -#define LINUX_TIOCPKT 0x5420 - -#define LINUX_FIONBIO 0x5421 - -#define LINUX_TIOCNOTTY 0x5422 -#define LINUX_TIOCSETD 0x5423 -#define LINUX_TIOCGETD 0x5424 -#define LINUX_TCSBRKP 0x5425 -#define LINUX_TIOCTTYGSTRUCT 0x5426 - -#define LINUX_FIONCLEX 0x5450 -#define LINUX_FIOCLEX 0x5451 -#define LINUX_FIOASYNC 0x5452 - -#define LINUX_TIOCSERCONFIG 0x5453 -#define LINUX_TIOCSERGWILD 0x5454 -#define LINUX_TIOCSERSWILD 0x5455 -#define LINUX_TIOCGLCKTRMIOS 0x5456 -#define LINUX_TIOCSLCKTRMIOS 0x5457 - -#define LINUX_IOCTL_TERMIO_MIN LINUX_TCGETS -#define LINUX_IOCTL_TERMIO_MAX LINUX_TIOCSLCKTRMIOS - -/* arguments for tcflow() and LINUX_TCXONC */ -#define LINUX_TCOOFF 0 -#define LINUX_TCOON 1 -#define LINUX_TCIOFF 2 -#define LINUX_TCION 3 - -/* arguments for tcflush() and LINUX_TCFLSH */ -#define LINUX_TCIFLUSH 0 -#define LINUX_TCOFLUSH 1 -#define LINUX_TCIOFLUSH 2 - -/* line disciplines */ -#define LINUX_N_TTY 0 -#define LINUX_N_SLIP 1 -#define LINUX_N_MOUSE 2 -#define LINUX_N_PPP 3 - -/* Linux termio c_cc values */ -#define LINUX_VINTR 0 -#define LINUX_VQUIT 1 -#define LINUX_VERASE 2 -#define LINUX_VKILL 3 -#define LINUX_VEOF 4 -#define LINUX_VTIME 5 -#define LINUX_VMIN 6 -#define LINUX_VSWTC 7 -#define LINUX_NCC 8 - -/* Linux termios c_cc values. In addition to the termio values */ -#define LINUX_VSTART 8 -#define LINUX_VSTOP 9 -#define LINUX_VSUSP 10 -#define LINUX_VEOL 11 -#define LINUX_VREPRINT 12 -#define LINUX_VDISCARD 13 -#define LINUX_VWERASE 14 -#define LINUX_VLNEXT 15 -#define LINUX_VEOL2 16 -#define LINUX_NCCS 19 - -#define LINUX_POSIX_VDISABLE '\0' - -/* Linux c_iflag masks */ -#define LINUX_IGNBRK 0x0000001 -#define LINUX_BRKINT 0x0000002 -#define LINUX_IGNPAR 0x0000004 -#define LINUX_PARMRK 0x0000008 -#define LINUX_INPCK 0x0000010 -#define LINUX_ISTRIP 0x0000020 -#define LINUX_INLCR 0x0000040 -#define LINUX_IGNCR 0x0000080 -#define LINUX_ICRNL 0x0000100 - -#define LINUX_IUCLC 0x0000200 -#define LINUX_IXON 0x0000400 -#define LINUX_IXANY 0x0000800 -#define LINUX_IXOFF 0x0001000 - -#define LINUX_IMAXBEL 0x0002000 - -/* Linux c_oflag masks */ -#define LINUX_OPOST 0x0000001 - -#define LINUX_OLCUC 0x0000002 -#define LINUX_ONLCR 0x0000004 - -#define LINUX_OCRNL 0x0000008 -#define LINUX_ONOCR 0x0000010 -#define LINUX_ONLRET 0x0000020 -#define LINUX_OFILL 0x0000040 -#define LINUX_OFDEL 0x0000080 - -#define LINUX_NLDLY 0x0000100 -#define LINUX_NL0 0x0000000 -#define LINUX_NL1 0x0000100 -#define LINUX_CRDLY 0x0000600 -#define LINUX_CR0 0x0000000 -#define LINUX_CR1 0x0000200 -#define LINUX_CR2 0x0000400 -#define LINUX_CR3 0x0000600 -#define LINUX_TABDLY 0x0001800 -#define LINUX_TAB0 0x0000000 -#define LINUX_TAB1 0x0000800 -#define LINUX_TAB2 0x0001000 -#define LINUX_TAB3 0x0001800 -#define LINUX_XTABS 0x0001800 -#define LINUX_BSDLY 0x0002000 -#define LINUX_BS0 0x0000000 -#define LINUX_BS1 0x0002000 -#define LINUX_VTDLY 0x0004000 -#define LINUX_VT0 0x0000000 -#define LINUX_VT1 0x0004000 -#define LINUX_FFDLY 0x0008000 -#define LINUX_FF0 0x0000000 -#define LINUX_FF1 0x0008000 - -#define LINUX_CBAUD 0x0000100f - -#define LINUX_B0 0x00000000 -#define LINUX_B50 0x00000001 -#define LINUX_B75 0x00000002 -#define LINUX_B110 0x00000003 -#define LINUX_B134 0x00000004 -#define LINUX_B150 0x00000005 -#define LINUX_B200 0x00000006 -#define LINUX_B300 0x00000007 -#define LINUX_B600 0x00000008 -#define LINUX_B1200 0x00000009 -#define LINUX_B1800 0x0000000a -#define LINUX_B2400 0x0000000b -#define LINUX_B4800 0x0000000c -#define LINUX_B9600 0x0000000d -#define LINUX_B19200 0x0000000e -#define LINUX_B38400 0x0000000f -#define LINUX_EXTA LINUX_B19200 -#define LINUX_EXTB LINUX_B38400 - -#define LINUX_CBAUDEX 0x00001000 -#define LINUX_B57600 0x00001001 -#define LINUX_B115200 0x00001002 - -#define LINUX_CSIZE 0x00000030 -#define LINUX_CS5 0x00000000 -#define LINUX_CS6 0x00000010 -#define LINUX_CS7 0x00000020 -#define LINUX_CS8 0x00000030 -#define LINUX_CSTOPB 0x00000040 -#define LINUX_CREAD 0x00000080 -#define LINUX_PARENB 0x00000100 -#define LINUX_PARODD 0x00000200 -#define LINUX_HUPCL 0x00000400 -#define LINUX_CLOCAL 0x00000800 - -#define LINUX_CRTSCTS 0x80000000 - -/* Linux c_lflag masks */ -#define LINUX_ISIG 0x00000001 -#define LINUX_ICANON 0x00000002 -#define LINUX_XCASE 0x00000004 -#define LINUX_ECHO 0x00000008 -#define LINUX_ECHOE 0x00000010 -#define LINUX_ECHOK 0x00000020 -#define LINUX_ECHONL 0x00000040 -#define LINUX_NOFLSH 0x00000080 -#define LINUX_TOSTOP 0x00000100 -#define LINUX_ECHOCTL 0x00000200 -#define LINUX_ECHOPRT 0x00000400 -#define LINUX_ECHOKE 0x00000800 -#define LINUX_FLUSHO 0x00001000 -#define LINUX_PENDIN 0x00002000 -#define LINUX_IEXTEN 0x00008000 - -/* serial_struct values for TIOC[GS]SERIAL ioctls */ -#define LINUX_ASYNC_CLOSING_WAIT_INF 0 -#define LINUX_ASYNC_CLOSING_WAIT_NONE 65535 - -#define LINUX_PORT_UNKNOWN 0 -#define LINUX_PORT_8250 1 -#define LINUX_PORT_16450 2 -#define LINUX_PORT_16550 3 -#define LINUX_PORT_16550A 4 -#define LINUX_PORT_CIRRUS 5 -#define LINUX_PORT_16650 6 - -#define LINUX_PORT_MAX 6 - -#define LINUX_ASYNC_HUP_NOTIFY 0x0001 -#define LINUX_ASYNC_FOURPORT 0x0002 -#define LINUX_ASYNC_SAK 0x0004 -#define LINUX_ASYNC_SPLIT_TERMIOS 0x0008 -#define LINUX_ASYNC_SPD_MASK 0x0030 -#define LINUX_ASYNC_SPD_HI 0x0010 -#define LINUX_ASYNC_SPD_VHI 0x0020 -#define LINUX_ASYNC_SPD_CUST 0x0030 -#define LINUX_ASYNC_SKIP_TEST 0x0040 -#define LINUX_ASYNC_AUTO_IRQ 0x0080 -#define LINUX_ASYNC_SESSION_LOCKOUT 0x0100 -#define LINUX_ASYNC_PGRP_LOCKOUT 0x0200 -#define LINUX_ASYNC_CALLOUT_NOHUP 0x0400 -#define LINUX_ASYNC_FLAGS 0x0FFF - -/* - * This doesn't really belong here, but I can't think of a better - * place to put it. - */ -struct ifnet; -int linux_ifname(struct ifnet *, char *, size_t); -u_long linux_gen_dirmap(u_long, u_long, u_long, u_long, u_long, u_long); - -#endif /* !_LINUX_IOCTL_H_ */ diff --git a/sys/emulation/linux/linux_ipc.c b/sys/emulation/linux/linux_ipc.c deleted file mode 100644 index 54620f05c4..0000000000 --- a/sys/emulation/linux/linux_ipc.c +++ /dev/null @@ -1,811 +0,0 @@ -/*- - * Copyright (c) 1994-1995 Søren Schmidt - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer - * in this position and unchanged. - * 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 - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD: src/sys/compat/linux/linux_ipc.c,v 1.17.2.3 2001/11/05 19:08:22 marcel Exp $ - * $DragonFly: src/sys/emulation/linux/linux_ipc.c,v 1.8 2006/06/05 07:26:09 dillon Exp $ - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include "linux_ipc.h" -#include "linux_util.h" - - -static void -bsd_to_linux_shminfo( struct shminfo *bpp, struct l_shminfo *lpp) -{ - lpp->shmmax = bpp->shmmax; - lpp->shmmin = bpp->shmmin; - lpp->shmmni = bpp->shmmni; - lpp->shmseg = bpp->shmseg; - lpp->shmall = bpp->shmall; -} - -#if 0 -static void -bsd_to_linux_shm_info( struct shm_info *bpp, struct l_shm_info *lpp) -{ - lpp->used_ids = bpp->used_ids ; - lpp->shm_tot = bpp->shm_tot ; - lpp->shm_rss = bpp->shm_rss ; - lpp->shm_swp = bpp->shm_swp ; - lpp->swap_attempts = bpp->swap_attempts ; - lpp->swap_successes = bpp->swap_successes ; -} -#endif - -/* - * MPSAFE - */ -static void -linux_to_bsd_ipc_perm(struct l_ipc_perm *lpp, struct ipc_perm *bpp) -{ - bpp->key = lpp->key; - bpp->uid = lpp->uid; - bpp->gid = lpp->gid; - bpp->cuid = lpp->cuid; - bpp->cgid = lpp->cgid; - bpp->mode = lpp->mode; - bpp->seq = lpp->seq; -} - -/* - * MPSAFE - */ -static void -bsd_to_linux_ipc_perm(struct ipc_perm *bpp, struct l_ipc_perm *lpp) -{ - lpp->key = bpp->key; - lpp->uid = bpp->uid; - lpp->gid = bpp->gid; - lpp->cuid = bpp->cuid; - lpp->cgid = bpp->cgid; - lpp->mode = bpp->mode; - lpp->seq = bpp->seq; -} - -/* - * MPSAFE - */ -static void -linux_to_bsd_semid_ds(struct l_semid_ds *lsp, struct semid_ds *bsp) -{ - linux_to_bsd_ipc_perm(&lsp->sem_perm, &bsp->sem_perm); - bsp->sem_otime = lsp->sem_otime; - bsp->sem_ctime = lsp->sem_ctime; - bsp->sem_nsems = lsp->sem_nsems; - bsp->sem_base = lsp->sem_base; -} - -/* - * MPSAFE - */ -static void -bsd_to_linux_semid_ds(struct semid_ds *bsp, struct l_semid_ds *lsp) -{ - bsd_to_linux_ipc_perm(&bsp->sem_perm, &lsp->sem_perm); - lsp->sem_otime = bsp->sem_otime; - lsp->sem_ctime = bsp->sem_ctime; - lsp->sem_nsems = bsp->sem_nsems; - lsp->sem_base = bsp->sem_base; -} - -/* - * MPSAFE - */ -static void -linux_to_bsd_shmid_ds(struct l_shmid_ds *lsp, struct shmid_ds *bsp) -{ - linux_to_bsd_ipc_perm(&lsp->shm_perm, &bsp->shm_perm); - bsp->shm_segsz = lsp->shm_segsz; - bsp->shm_lpid = lsp->shm_lpid; - bsp->shm_cpid = lsp->shm_cpid; - bsp->shm_nattch = lsp->shm_nattch; - bsp->shm_atime = lsp->shm_atime; - bsp->shm_dtime = lsp->shm_dtime; - bsp->shm_ctime = lsp->shm_ctime; -} - -/* - * MPSAFE - */ -static void -bsd_to_linux_shmid_ds(struct shmid_ds *bsp, struct l_shmid_ds *lsp) -{ - bsd_to_linux_ipc_perm(&bsp->shm_perm, &lsp->shm_perm); - if (bsp->shm_segsz > INT_MAX) - lsp->shm_segsz = INT_MAX; - else - lsp->shm_segsz = bsp->shm_segsz; - lsp->shm_lpid = bsp->shm_lpid; - lsp->shm_cpid = bsp->shm_cpid; - lsp->shm_nattch = bsp->shm_nattch; - lsp->shm_atime = bsp->shm_atime; - lsp->shm_dtime = bsp->shm_dtime; - lsp->shm_ctime = bsp->shm_ctime; - lsp->private3 = 0; -} - -static void -linux_to_bsd_msqid_ds(struct l_msqid_ds *lsp, struct msqid_ds *bsp) -{ - linux_to_bsd_ipc_perm(&lsp->msg_perm, &bsp->msg_perm); - bsp->msg_cbytes = lsp->msg_cbytes; - bsp->msg_qnum = lsp->msg_qnum; - bsp->msg_qbytes = lsp->msg_qbytes; - bsp->msg_lspid = lsp->msg_lspid; - bsp->msg_lrpid = lsp->msg_lrpid; - bsp->msg_stime = lsp->msg_stime; - bsp->msg_rtime = lsp->msg_rtime; - bsp->msg_ctime = lsp->msg_ctime; -} - -static void -bsd_to_linux_msqid_ds(struct msqid_ds *bsp, struct l_msqid_ds *lsp) -{ - bsd_to_linux_ipc_perm(&bsp->msg_perm, &lsp->msg_perm); - lsp->msg_cbytes = bsp->msg_cbytes; - lsp->msg_qnum = bsp->msg_qnum; - lsp->msg_qbytes = bsp->msg_qbytes; - lsp->msg_lspid = bsp->msg_lspid; - lsp->msg_lrpid = bsp->msg_lrpid; - lsp->msg_stime = bsp->msg_stime; - lsp->msg_rtime = bsp->msg_rtime; - lsp->msg_ctime = bsp->msg_ctime; -} - -static void -linux_ipc_perm_to_ipc64_perm(struct l_ipc_perm *in, struct l_ipc64_perm *out) -{ - - /* XXX: do we really need to do something here? */ - out->key = in->key; - out->uid = in->uid; - out->gid = in->gid; - out->cuid = in->cuid; - out->cgid = in->cgid; - out->mode = in->mode; - out->seq = in->seq; -} - -static int -linux_msqid_pullup(l_int ver, struct l_msqid_ds *linux_msqid, caddr_t uaddr) -{ - struct l_msqid64_ds linux_msqid64; - int error; - - if (ver == LINUX_IPC_64) { - error = copyin(uaddr, &linux_msqid64, sizeof(linux_msqid64)); - if (error != 0) - return (error); - - bzero(linux_msqid, sizeof(*linux_msqid)); - - linux_msqid->msg_perm.uid = linux_msqid64.msg_perm.uid; - linux_msqid->msg_perm.gid = linux_msqid64.msg_perm.gid; - linux_msqid->msg_perm.mode = linux_msqid64.msg_perm.mode; - - if (linux_msqid64.msg_qbytes > USHRT_MAX) - linux_msqid->msg_lqbytes = linux_msqid64.msg_qbytes; - else - linux_msqid->msg_qbytes = linux_msqid64.msg_qbytes; - } else { - error = copyin(uaddr, linux_msqid, sizeof(*linux_msqid)); - } - return (error); -} - -static int -linux_msqid_pushdown(l_int ver, struct l_msqid_ds *linux_msqid, caddr_t uaddr) -{ - struct l_msqid64_ds linux_msqid64; - - if (ver == LINUX_IPC_64) { - bzero(&linux_msqid64, sizeof(linux_msqid64)); - - linux_ipc_perm_to_ipc64_perm(&linux_msqid->msg_perm, - &linux_msqid64.msg_perm); - - linux_msqid64.msg_stime = linux_msqid->msg_stime; - linux_msqid64.msg_rtime = linux_msqid->msg_rtime; - linux_msqid64.msg_ctime = linux_msqid->msg_ctime; - - if (linux_msqid->msg_cbytes == 0) - linux_msqid64.msg_cbytes = linux_msqid->msg_lcbytes; - else - linux_msqid64.msg_cbytes = linux_msqid->msg_cbytes; - - linux_msqid64.msg_qnum = linux_msqid->msg_qnum; - - if (linux_msqid->msg_qbytes == 0) - linux_msqid64.msg_qbytes = linux_msqid->msg_lqbytes; - else - linux_msqid64.msg_qbytes = linux_msqid->msg_qbytes; - - linux_msqid64.msg_lspid = linux_msqid->msg_lspid; - linux_msqid64.msg_lrpid = linux_msqid->msg_lrpid; - - return (copyout(&linux_msqid64, uaddr, sizeof(linux_msqid64))); - } else { - return (copyout(linux_msqid, uaddr, sizeof(*linux_msqid))); - } -} - -static int -linux_semid_pullup(l_int ver, struct l_semid_ds *linux_semid, caddr_t uaddr) -{ - struct l_semid64_ds linux_semid64; - int error; - - if (ver == LINUX_IPC_64) { - error = copyin(uaddr, &linux_semid64, sizeof(linux_semid64)); - if (error != 0) - return (error); - - bzero(linux_semid, sizeof(*linux_semid)); - - linux_semid->sem_perm.uid = linux_semid64.sem_perm.uid; - linux_semid->sem_perm.gid = linux_semid64.sem_perm.gid; - linux_semid->sem_perm.mode = linux_semid64.sem_perm.mode; - } else { - error = copyin(uaddr, linux_semid, sizeof(*linux_semid)); - } - return (error); -} - -static int -linux_semid_pushdown(l_int ver, struct l_semid_ds *linux_semid, caddr_t uaddr) -{ - struct l_semid64_ds linux_semid64; - - if (ver == LINUX_IPC_64) { - bzero(&linux_semid64, sizeof(linux_semid64)); - - linux_ipc_perm_to_ipc64_perm(&linux_semid->sem_perm, - &linux_semid64.sem_perm); - - linux_semid64.sem_otime = linux_semid->sem_otime; - linux_semid64.sem_ctime = linux_semid->sem_ctime; - linux_semid64.sem_nsems = linux_semid->sem_nsems; - - return (copyout(&linux_semid64, uaddr, sizeof(linux_semid64))); - } else { - return (copyout(linux_semid, uaddr, sizeof(*linux_semid))); - } -} - -static int -linux_shmid_pullup(l_int ver, struct l_shmid_ds *linux_shmid, caddr_t uaddr) -{ - struct l_shmid64_ds linux_shmid64; - int error; - - if (ver == LINUX_IPC_64) { - error = copyin(uaddr, &linux_shmid64, sizeof(linux_shmid64)); - if (error != 0) - return (error); - - bzero(linux_shmid, sizeof(*linux_shmid)); - - linux_shmid->shm_perm.uid = linux_shmid64.shm_perm.uid; - linux_shmid->shm_perm.gid = linux_shmid64.shm_perm.gid; - linux_shmid->shm_perm.mode = linux_shmid64.shm_perm.mode; - } else { - error = copyin(uaddr, linux_shmid, sizeof(*linux_shmid)); - } - return (error); -} - -static int -linux_shmid_pushdown(l_int ver, struct l_shmid_ds *linux_shmid, caddr_t uaddr) -{ - struct l_shmid64_ds linux_shmid64; - - /* - * XXX: This is backwards and loses information in shm_nattch - * and shm_segsz. We should probably either expose the BSD - * shmid structure directly and convert it to either the - * non-64 or 64 variant directly or the code should always - * convert to the 64 variant and then truncate values into the - * non-64 variant if needed since the 64 variant has more - * precision. - */ - if (ver == LINUX_IPC_64) { - bzero(&linux_shmid64, sizeof(linux_shmid64)); - - linux_ipc_perm_to_ipc64_perm(&linux_shmid->shm_perm, - &linux_shmid64.shm_perm); - - linux_shmid64.shm_segsz = linux_shmid->shm_segsz; - linux_shmid64.shm_atime = linux_shmid->shm_atime; - linux_shmid64.shm_dtime = linux_shmid->shm_dtime; - linux_shmid64.shm_ctime = linux_shmid->shm_ctime; - linux_shmid64.shm_cpid = linux_shmid->shm_cpid; - linux_shmid64.shm_lpid = linux_shmid->shm_lpid; - linux_shmid64.shm_nattch = linux_shmid->shm_nattch; - - return (copyout(&linux_shmid64, uaddr, sizeof(linux_shmid64))); - } else { - return (copyout(linux_shmid, uaddr, sizeof(*linux_shmid))); - } -} - -static int -linux_shminfo_pushdown(l_int ver, struct l_shminfo *linux_shminfo, - caddr_t uaddr) -{ - struct l_shminfo64 linux_shminfo64; - - if (ver == LINUX_IPC_64) { - bzero(&linux_shminfo64, sizeof(linux_shminfo64)); - - linux_shminfo64.shmmax = linux_shminfo->shmmax; - linux_shminfo64.shmmin = linux_shminfo->shmmin; - linux_shminfo64.shmmni = linux_shminfo->shmmni; - linux_shminfo64.shmseg = linux_shminfo->shmseg; - linux_shminfo64.shmall = linux_shminfo->shmall; - - return (copyout(&linux_shminfo64, uaddr, - sizeof(linux_shminfo64))); - } else { - return (copyout(linux_shminfo, uaddr, sizeof(*linux_shminfo))); - } -} - -/* - * MPSAFE - */ -int -linux_semop(struct linux_semop_args *args) -{ - struct semop_args bsd_args; - int error; - - bsd_args.sysmsg_result = 0; - bsd_args.semid = args->semid; - bsd_args.sops = (struct sembuf *)args->tsops; - bsd_args.nsops = args->nsops; - error = sys_semop(&bsd_args); - args->sysmsg_result = bsd_args.sysmsg_result; - return(error); -} - -/* - * MPSAFE - */ -int -linux_semget(struct linux_semget_args *args) -{ - struct semget_args bsd_args; - int error; - - bsd_args.sysmsg_result = 0; - bsd_args.key = args->key; - bsd_args.nsems = args->nsems; - bsd_args.semflg = args->semflg; - error = sys_semget(&bsd_args); - args->sysmsg_result = bsd_args.sysmsg_result; - return(error); -} - -/* - * MPSAFE - */ -int -linux_semctl(struct linux_semctl_args *args) -{ - struct l_semid_ds linux_semid; - struct __semctl_args bsd_args; - struct l_seminfo linux_seminfo; - int error; - union semun *unptr; - caddr_t sg; - - sg = stackgap_init(); - - /* Make sure the arg parameter can be copied in. */ - unptr = stackgap_alloc(&sg, sizeof(union semun)); - bcopy(&args->arg, unptr, sizeof(union semun)); - - bsd_args.sysmsg_result = 0; - bsd_args.semid = args->semid; - bsd_args.semnum = args->semnum; - bsd_args.arg = unptr; - - switch (args->cmd & ~LINUX_IPC_64) { - case LINUX_IPC_RMID: - bsd_args.cmd = IPC_RMID; - break; - case LINUX_GETNCNT: - bsd_args.cmd = GETNCNT; - break; - case LINUX_GETPID: - bsd_args.cmd = GETPID; - break; - case LINUX_GETVAL: - bsd_args.cmd = GETVAL; - break; - case LINUX_GETZCNT: - bsd_args.cmd = GETZCNT; - break; - case LINUX_SETVAL: - bsd_args.cmd = SETVAL; - break; - case LINUX_IPC_SET: - bsd_args.cmd = IPC_SET; - error = linux_semid_pullup(args->cmd & LINUX_IPC_64, - &linux_semid, (caddr_t)args->arg.buf); - if (error) - return (error); - unptr->buf = stackgap_alloc(&sg, sizeof(struct semid_ds)); - linux_to_bsd_semid_ds(&linux_semid, unptr->buf); - break; - case LINUX_IPC_STAT: - case LINUX_SEM_STAT: - if ((args->cmd & ~LINUX_IPC_64) == LINUX_IPC_STAT) - bsd_args.cmd = IPC_STAT; - else - bsd_args.cmd = SEM_STAT; - unptr->buf = stackgap_alloc(&sg, sizeof(struct semid_ds)); - error = sys___semctl(&bsd_args); - if (error) - return error; - args->sysmsg_result = IXSEQ_TO_IPCID(bsd_args.semid, - unptr->buf->sem_perm); - bsd_to_linux_semid_ds(unptr->buf, &linux_semid); - error = linux_semid_pushdown(args->cmd & LINUX_IPC_64, - &linux_semid, (caddr_t)(args->arg.buf)); - if (error == 0) - args->sysmsg_iresult = ((args->cmd & ~LINUX_IPC_64) == SEM_STAT) - ? bsd_args.sysmsg_result : 0; - return (error); - case LINUX_IPC_INFO: - case LINUX_SEM_INFO: - error = copyin((caddr_t)args->arg.buf, &linux_seminfo, - sizeof(linux_seminfo) ); - if (error) - return error; - bcopy(&seminfo, &linux_seminfo, sizeof(linux_seminfo) ); -/* XXX BSD equivalent? -#define used_semids 10 -#define used_sems 10 - linux_seminfo.semusz = used_semids; - linux_seminfo.semaem = used_sems; -*/ - error = copyout((caddr_t)&linux_seminfo, (caddr_t)args->arg.buf, - sizeof(linux_seminfo) ); - if (error) - return error; - args->sysmsg_result = seminfo.semmni; - return 0; /* No need for __semctl call */ - case LINUX_GETALL: - bsd_args.cmd = GETALL; - break; - case LINUX_SETALL: - bsd_args.cmd = SETALL; - break; - default: - uprintf("linux: 'ipc' type=%d not implemented\n", args->cmd & ~LINUX_IPC_64); - return EINVAL; - } - error = sys___semctl(&bsd_args); - args->sysmsg_result = bsd_args.sysmsg_result; - return(error); -} - -/* - * MPSAFE - */ -int -linux_msgsnd(struct linux_msgsnd_args *args) -{ - struct msgsnd_args bsd_args; - int error; - - if ((l_long)args->msgsz < 0 || args->msgsz > (l_long)msginfo.msgmax) - return (EINVAL); - bsd_args.sysmsg_result = 0; - bsd_args.msqid = args->msqid; - bsd_args.msgp = args->msgp; - bsd_args.msgsz = args->msgsz; - bsd_args.msgflg = args->msgflg; - error = sys_msgsnd(&bsd_args); - args->sysmsg_result = bsd_args.sysmsg_result; - return(error); -} - -/* - * MPSAFE - */ -int -linux_msgrcv(struct linux_msgrcv_args *args) -{ - struct msgrcv_args bsd_args; - int error; - if ((l_long)args->msgsz < 0 || args->msgsz > (l_long)msginfo.msgmax) - return (EINVAL); - bsd_args.sysmsg_result = 0; - bsd_args.msqid = args->msqid; - bsd_args.msgp = args->msgp; - bsd_args.msgsz = args->msgsz; - bsd_args.msgtyp = 0; /* XXX - args->msgtyp; */ - bsd_args.msgflg = args->msgflg; - error = sys_msgrcv(&bsd_args); - args->sysmsg_result = bsd_args.sysmsg_result; - return(error); -} - -/* - * MPSAFE - */ -int -linux_msgget(struct linux_msgget_args *args) -{ - struct msgget_args bsd_args; - int error; - - bsd_args.sysmsg_result = 0; - bsd_args.key = args->key; - bsd_args.msgflg = args->msgflg; - error = sys_msgget(&bsd_args); - args->sysmsg_result = bsd_args.sysmsg_result; - return(error); -} - -/* - * MPSAFE - */ -int -linux_msgctl(struct linux_msgctl_args *args) -{ - struct msgctl_args bsd_args; - struct l_msqid_ds linux_msqid; - int error, bsd_cmd; - struct msqid_ds *unptr; - caddr_t sg; - - sg = stackgap_init(); - /* Make sure the arg parameter can be copied in. */ - unptr = stackgap_alloc(&sg, sizeof(struct msqid_ds)); - bcopy(&args->buf, unptr, sizeof(struct msqid_ds)); - - bsd_cmd = args->cmd & ~LINUX_IPC_64; - bsd_args.sysmsg_result = 0; - bsd_args.msqid = args->msqid; - bsd_args.cmd = bsd_cmd; - bsd_args.buf = unptr; - switch(bsd_cmd) { - case LINUX_IPC_INFO: - case LINUX_MSG_INFO: { - struct l_msginfo linux_msginfo; - - /* - * XXX MSG_INFO uses the same data structure but returns different - * dynamic counters in msgpool, msgmap, and msgtql fields. - */ - linux_msginfo.msgpool = (long)msginfo.msgmni * - (long)msginfo.msgmnb / 1024L; /* XXX MSG_INFO. */ - linux_msginfo.msgmap = msginfo.msgmnb; /* XXX MSG_INFO. */ - linux_msginfo.msgmax = msginfo.msgmax; - linux_msginfo.msgmnb = msginfo.msgmnb; - linux_msginfo.msgmni = msginfo.msgmni; - linux_msginfo.msgssz = msginfo.msgssz; - linux_msginfo.msgtql = msginfo.msgtql; /* XXX MSG_INFO. */ - linux_msginfo.msgseg = msginfo.msgseg; - error = copyout(&linux_msginfo, PTRIN(args->buf), - sizeof(linux_msginfo)); - if (error == 0) - args->sysmsg_iresult = msginfo.msgmni; /* XXX */ - - return (error); - } - -/* - * TODO: implement this - * case LINUX_MSG_STAT: - */ - case LINUX_IPC_STAT: - /* NOTHING */ - break; - - case LINUX_IPC_SET: - error = linux_msqid_pullup(args->cmd & LINUX_IPC_64, - &linux_msqid, (caddr_t)(args->buf)); - if (error) - return (error); - linux_to_bsd_msqid_ds(&linux_msqid, unptr); - break; - - case LINUX_IPC_RMID: - /* NOTHING */ - break; - - default: - return (EINVAL); - break; - } - - error = sys_msgctl(&bsd_args); - if (error != 0) - if (bsd_cmd != LINUX_IPC_RMID || error != EINVAL) - return (error); - if (bsd_cmd == LINUX_IPC_STAT) { - bsd_to_linux_msqid_ds(bsd_args.buf, &linux_msqid); - return (linux_msqid_pushdown(args->cmd & LINUX_IPC_64, - &linux_msqid, PTRIN(args->buf))); - } - args->sysmsg_result = bsd_args.sysmsg_result; - return ((args->cmd == LINUX_IPC_RMID && error == EINVAL) ? 0 : error); - - - - -} - -/* - * MPSAFE - */ -int -linux_shmat(struct linux_shmat_args *args) -{ - struct shmat_args bsd_args; - int error; - - bsd_args.sysmsg_result = 0; - bsd_args.shmid = args->shmid; - bsd_args.shmaddr = args->shmaddr; - bsd_args.shmflg = args->shmflg; - if ((error = sys_shmat(&bsd_args))) - return error; -#ifdef __i386__ - if ((error = copyout(&bsd_args.sysmsg_lresult, (caddr_t)args->raddr, sizeof(l_ulong)))) - return error; - args->sysmsg_result = 0; -#else - args->sysmsg_result = bsd_args.sysmsg_result; -#endif - return 0; -} - -/* - * MPSAFE - */ -int -linux_shmdt(struct linux_shmdt_args *args) -{ - struct shmdt_args bsd_args; - int error; - - bsd_args.sysmsg_result = 0; - bsd_args.shmaddr = args->shmaddr; - error = sys_shmdt(&bsd_args); - args->sysmsg_result = bsd_args.sysmsg_result; - return(error); -} - -/* - * MPSAFE - */ -int -linux_shmget(struct linux_shmget_args *args) -{ - struct shmget_args bsd_args; - int error; - - bsd_args.sysmsg_result = 0; - bsd_args.key = args->key; - bsd_args.size = args->size; - bsd_args.shmflg = args->shmflg; - error = sys_shmget(&bsd_args); - args->sysmsg_result = bsd_args.sysmsg_result; - return(error); -} - -/* - * MPSAFE - */ -extern int shm_nused; -int -linux_shmctl(struct linux_shmctl_args *args) -{ - struct l_shmid_ds linux_shmid; - struct l_shminfo linux_shminfo; - struct l_shm_info linux_shm_info; - struct shmctl_args bsd_args; - int error; - caddr_t sg = stackgap_init(); - - bsd_args.sysmsg_result = 0; - switch (args->cmd & ~LINUX_IPC_64) { - case LINUX_IPC_STAT: - case LINUX_SHM_STAT: - bsd_args.shmid = args->shmid; - bsd_args.cmd = IPC_STAT; - bsd_args.buf = (struct shmid_ds*)stackgap_alloc(&sg, sizeof(struct shmid_ds)); - if ((error = sys_shmctl(&bsd_args))) - return error; - bsd_to_linux_shmid_ds(bsd_args.buf, &linux_shmid); - args->sysmsg_result = bsd_args.sysmsg_result; - return (linux_shmid_pushdown(args->cmd & LINUX_IPC_64, - &linux_shmid, PTRIN(args->buf))); - - case LINUX_IPC_SET: - if ((error = linux_shmid_pullup(args->cmd & LINUX_IPC_64, - &linux_shmid, PTRIN(args->buf)))) - return error; - bsd_args.buf = (struct shmid_ds*)stackgap_alloc(&sg, sizeof(struct shmid_ds)); - linux_to_bsd_shmid_ds(&linux_shmid, bsd_args.buf); - bsd_args.shmid = args->shmid; - bsd_args.cmd = IPC_SET; - break; - case LINUX_IPC_RMID: - bsd_args.shmid = args->shmid; - bsd_args.cmd = IPC_RMID; - if (args->buf == NULL) - bsd_args.buf = NULL; - else { - if ((error = linux_shmid_pullup(args->cmd & LINUX_IPC_64, - &linux_shmid, PTRIN(args->buf)))) - return error; - bsd_args.buf = (struct shmid_ds*)stackgap_alloc(&sg, sizeof(struct shmid_ds)); - linux_to_bsd_shmid_ds(&linux_shmid, bsd_args.buf); - } - break; - case LINUX_IPC_INFO: - bsd_to_linux_shminfo(&shminfo, &linux_shminfo); - return (linux_shminfo_pushdown(args->cmd & LINUX_IPC_64, - &linux_shminfo, PTRIN(args->buf))); - break; - case LINUX_SHM_INFO: - linux_shm_info.used_ids = shm_nused; - linux_shm_info.shm_tot = 0; - linux_shm_info.shm_rss = 0; - linux_shm_info.shm_swp = 0; - linux_shm_info.swap_attempts = 0; - linux_shm_info.swap_successes = 0; - return copyout(&linux_shm_info, PTRIN(args->buf), - sizeof(struct l_shm_info)); - - case LINUX_SHM_LOCK: - case LINUX_SHM_UNLOCK: - default: - uprintf("linux: 'ipc' type=%d not implemented\n", args->cmd & ~LINUX_IPC_64); - return EINVAL; - } - error = sys_shmctl(&bsd_args); - args->sysmsg_result = bsd_args.sysmsg_result; - return(error); -} diff --git a/sys/emulation/linux/linux_ipc.h b/sys/emulation/linux/linux_ipc.h deleted file mode 100644 index 67d565d2a6..0000000000 --- a/sys/emulation/linux/linux_ipc.h +++ /dev/null @@ -1,343 +0,0 @@ -/*- - * Copyright (c) 2000 Marcel Moolenaar - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer - * in this position and unchanged. - * 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 - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD: src/sys/compat/linux/linux_ipc.h,v 1.2.2.4 2001/11/05 19:08:22 marcel Exp $ - * $DragonFly: src/sys/emulation/linux/linux_ipc.h,v 1.7 2003/11/20 06:05:29 dillon Exp $ - */ - -#ifndef _LINUX_IPC_H_ -#define _LINUX_IPC_H_ - -#ifdef __i386__ - - -struct l_msginfo { - l_int msgpool; - l_int msgmap; - l_int msgmax; - l_int msgmnb; - l_int msgmni; - l_int msgssz; - l_int msgtql; - l_ushort msgseg; -}; - -struct linux_msgctl_args -{ - struct sysmsg sysmsg; - l_int msqid; - l_int cmd; - struct l_msqid_ds *buf; -}; - -struct linux_msgget_args -{ - struct sysmsg sysmsg; - l_key_t key; - l_int msgflg; -}; - -struct linux_msgrcv_args -{ - struct sysmsg sysmsg; - l_int msqid; - struct l_msgbuf *msgp; - l_size_t msgsz; - l_long msgtyp; - l_int msgflg; -}; - -struct linux_msgsnd_args -{ - struct sysmsg sysmsg; - l_int msqid; - struct l_msgbuf *msgp; - l_size_t msgsz; - l_int msgflg; -}; - -struct linux_semctl_args -{ - struct sysmsg sysmsg; - l_int semid; - l_int semnum; - l_int cmd; - union l_semun arg; -}; - -struct linux_semget_args -{ - struct sysmsg sysmsg; - l_key_t key; - l_int nsems; - l_int semflg; -}; - -struct linux_semop_args -{ - struct sysmsg sysmsg; - l_int semid; - struct l_sembuf *tsops; - l_uint nsops; -}; - -struct linux_shmat_args -{ - struct sysmsg sysmsg; - l_int shmid; - char *shmaddr; - l_int shmflg; - l_ulong *raddr; -}; - -struct linux_shmctl_args -{ - struct sysmsg sysmsg; - l_int shmid; - l_int cmd; - struct l_shmid_ds *buf; -}; - -struct linux_shmdt_args -{ - struct sysmsg sysmsg; - char *shmaddr; -}; - -struct linux_shmget_args -{ - struct sysmsg sysmsg; - l_key_t key; - l_size_t size; - l_int shmflg; -}; - - - -struct l_seminfo { - l_int semmap; - l_int semmni; - l_int semmns; - l_int semmnu; - l_int semmsl; - l_int semopm; - l_int semume; - l_int semusz; - l_int semvmx; - l_int semaem; -}; - - -struct l_shminfo { - l_int shmmax; - l_int shmmin; - l_int shmmni; - l_int shmseg; - l_int shmall; -}; - -struct l_shm_info { - l_int used_ids; - l_ulong shm_tot; /* total allocated shm */ - l_ulong shm_rss; /* total resident shm */ - l_ulong shm_swp; /* total swapped shm */ - l_ulong swap_attempts; - l_ulong swap_successes; -}; - - -struct l_ipc64_perm -{ - l_key_t key; - l_uid_t uid; - l_gid_t gid; - l_uid_t cuid; - l_gid_t cgid; - l_mode_t mode; - l_ushort __pad1; - l_ushort seq; - l_ushort __pad2; - l_ulong __unused1; - l_ulong __unused2; -}; - -/* - * The msqid64_ds structure for i386 architecture. - * Note extra padding because this structure is passed back and forth - * between kernel and user space. - * - * Pad space is left for: - * - 64-bit time_t to solve y2038 problem - * - 2 miscellaneous 32-bit values - */ - -struct l_msqid64_ds { - struct l_ipc64_perm msg_perm; - l_time_t msg_stime; /* last msgsnd time */ - l_ulong __unused1; - l_time_t msg_rtime; /* last msgrcv time */ - l_ulong __unused2; - l_time_t msg_ctime; /* last change time */ - l_ulong __unused3; - l_ulong msg_cbytes; /* current number of bytes on queue */ - l_ulong msg_qnum; /* number of messages in queue */ - l_ulong msg_qbytes; /* max number of bytes on queue */ - l_pid_t msg_lspid; /* pid of last msgsnd */ - l_pid_t msg_lrpid; /* last receive pid */ - l_ulong __unused4; - l_ulong __unused5; -}; - -/* - * The semid64_ds structure for i386 architecture. - * Note extra padding because this structure is passed back and forth - * between kernel and user space. - * - * Pad space is left for: - * - 64-bit time_t to solve y2038 problem - * - 2 miscellaneous 32-bit values - */ - -struct l_semid64_ds { - struct l_ipc64_perm sem_perm; /* permissions */ - l_time_t sem_otime; /* last semop time */ - l_ulong __unused1; - l_time_t sem_ctime; /* last change time */ - l_ulong __unused2; - l_ulong sem_nsems; /* no. of semaphores in array */ - l_ulong __unused3; - l_ulong __unused4; -}; - -/* - * The shmid64_ds structure for i386 architecture. - * Note extra padding because this structure is passed back and forth - * between kernel and user space. - * - * Pad space is left for: - * - 64-bit time_t to solve y2038 problem - * - 2 miscellaneous 32-bit values - */ - -struct l_shmid64_ds { - struct l_ipc64_perm shm_perm; /* operation perms */ - l_size_t shm_segsz; /* size of segment (bytes) */ - l_time_t shm_atime; /* last attach time */ - l_ulong __unused1; - l_time_t shm_dtime; /* last detach time */ - l_ulong __unused2; - l_time_t shm_ctime; /* last change time */ - l_ulong __unused3; - l_pid_t shm_cpid; /* pid of creator */ - l_pid_t shm_lpid; /* pid of last operator */ - l_ulong shm_nattch; /* no. of current attaches */ - l_ulong __unused4; - l_ulong __unused5; -}; - -struct l_shminfo64 { - l_ulong shmmax; - l_ulong shmmin; - l_ulong shmmni; - l_ulong shmseg; - l_ulong shmall; - l_ulong __unused1; - l_ulong __unused2; - l_ulong __unused3; - l_ulong __unused4; -}; - - -struct l_ipc_perm { - l_key_t key; - l_uid16_t uid; - l_gid16_t gid; - l_uid16_t cuid; - l_gid16_t cgid; - l_ushort mode; - l_ushort seq; -}; - -struct l_msqid_ds { - struct l_ipc_perm msg_perm; - l_uintptr_t msg_first; /* first message on queue,unused */ - l_uintptr_t msg_last; /* last message in queue,unused */ - l_time_t msg_stime; /* last msgsnd time */ - l_time_t msg_rtime; /* last msgrcv time */ - l_time_t msg_ctime; /* last change time */ - l_ulong msg_lcbytes; /* Reuse junk fields for 32 bit */ - l_ulong msg_lqbytes; /* ditto */ - l_ushort msg_cbytes; /* current number of bytes on queue */ - l_ushort msg_qnum; /* number of messages in queue */ - l_ushort msg_qbytes; /* max number of bytes on queue */ - l_pid_t msg_lspid; /* pid of last msgsnd */ - l_pid_t msg_lrpid; /* last receive pid */ -}; - -struct l_semid_ds { - struct l_ipc_perm sem_perm; - l_time_t sem_otime; - l_time_t sem_ctime; - void *sem_base; - void *sem_pending; - void *sem_pending_last; - void *undo; - l_ushort sem_nsems; -}; - -struct l_shmid_ds { - struct l_ipc_perm shm_perm; - l_int shm_segsz; - l_time_t shm_atime; - l_time_t shm_dtime; - l_time_t shm_ctime; - l_ushort shm_cpid; - l_ushort shm_lpid; - l_short shm_nattch; - l_ushort private1; - void *private2; - void *private3; -}; - -int linux_msgctl (struct linux_msgctl_args *); -int linux_msgget (struct linux_msgget_args *); -int linux_msgrcv (struct linux_msgrcv_args *); -int linux_msgsnd (struct linux_msgsnd_args *); - -int linux_semctl (struct linux_semctl_args *); -int linux_semget (struct linux_semget_args *); -int linux_semop (struct linux_semop_args *); - -int linux_shmat (struct linux_shmat_args *); -int linux_shmctl (struct linux_shmctl_args *); -int linux_shmdt (struct linux_shmdt_args *); -int linux_shmget (struct linux_shmget_args *); -#define LINUX_MSG_INFO 12 -#define LINUX_IPC_64 0x0100 /* New version (support 32-bit UIDs, bigger */ -#endif /* __i386__ */ - -#endif /* _LINUX_IPC_H_ */ diff --git a/sys/emulation/linux/linux_mib.c b/sys/emulation/linux/linux_mib.c deleted file mode 100644 index ce2cb94876..0000000000 --- a/sys/emulation/linux/linux_mib.c +++ /dev/null @@ -1,286 +0,0 @@ -/*- - * Copyright (c) 1999 Marcel Moolenaar - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer - * in this position and unchanged. - * 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 - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD: src/sys/compat/linux/linux_mib.c,v 1.7.2.2 2001/11/05 19:08:22 marcel Exp $ - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include "linux_mib.h" - -struct linux_prison { - char pr_osname[LINUX_MAX_UTSNAME]; - char pr_osrelease[LINUX_MAX_UTSNAME]; - int pr_oss_version; -}; - -SYSCTL_NODE(_compat, OID_AUTO, linux, CTLFLAG_RW, 0, - "Linux mode"); - -static char linux_osname[LINUX_MAX_UTSNAME] = "Linux"; - -static int -linux_sysctl_osname(SYSCTL_HANDLER_ARGS) -{ - char osname[LINUX_MAX_UTSNAME]; - int error; - - strcpy(osname, linux_get_osname(req->td)); - error = sysctl_handle_string(oidp, osname, LINUX_MAX_UTSNAME, req); - if (error || req->newptr == NULL) - return (error); - error = linux_set_osname(req->td, osname); - return (error); -} - -SYSCTL_PROC(_compat_linux, OID_AUTO, osname, - CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_PRISON, - 0, 0, linux_sysctl_osname, "A", - "Linux kernel OS name"); - -static char linux_osrelease[LINUX_MAX_UTSNAME] = "2.6.16"; - -static int -linux_sysctl_osrelease(SYSCTL_HANDLER_ARGS) -{ - char osrelease[LINUX_MAX_UTSNAME]; - int error; - - strcpy(osrelease, linux_get_osrelease(req->td)); - error = sysctl_handle_string(oidp, osrelease, LINUX_MAX_UTSNAME, req); - if (error || req->newptr == NULL) - return (error); - error = linux_set_osrelease(req->td, osrelease); - return (error); -} - -SYSCTL_PROC(_compat_linux, OID_AUTO, osrelease, - CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_PRISON, - 0, 0, linux_sysctl_osrelease, "A", - "Linux kernel OS release"); - -static int linux_oss_version = 0x030600; - -static int -linux_sysctl_oss_version(SYSCTL_HANDLER_ARGS) -{ - int oss_version; - int error; - - oss_version = linux_get_oss_version(req->td); - error = sysctl_handle_int(oidp, &oss_version, 0, req); - if (error || req->newptr == NULL) - return (error); - error = linux_set_oss_version(req->td, oss_version); - return (error); -} - -SYSCTL_PROC(_compat_linux, OID_AUTO, oss_version, - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_PRISON, - 0, 0, linux_sysctl_oss_version, "I", - "Linux OSS version"); - -static struct linux_prison * -get_prison(struct thread *td) -{ - struct prison *pr; - struct linux_prison *lpr; - - KKASSERT(td->td_proc); - pr = td->td_proc->p_ucred->cr_prison; - if (pr == NULL) - return (NULL); - - if (pr->pr_linux == NULL) { - lpr = kmalloc(sizeof *lpr, M_PRISON, M_WAITOK | M_ZERO); - pr->pr_linux = lpr; - } - - return (pr->pr_linux); -} - -char * -linux_get_osname(struct thread *td) -{ - struct prison *pr; - struct linux_prison *lpr; - - KKASSERT(td->td_proc); - pr = td->td_proc->p_ucred->cr_prison; - if (pr != NULL && pr->pr_linux != NULL) { - lpr = pr->pr_linux; - if (lpr->pr_osname[0]) - return (lpr->pr_osname); - } - - return (linux_osname); -} - -int -linux_set_osname(struct thread *td, char *osname) -{ - struct linux_prison *lpr; - - KKASSERT(td->td_proc); - lpr = get_prison(td); - if (lpr != NULL) - strcpy(lpr->pr_osname, osname); - else - strcpy(linux_osname, osname); - - return (0); -} - -char * -linux_get_osrelease(struct thread *td) -{ - struct prison *pr; - struct linux_prison *lpr; - - KKASSERT(td->td_proc); - pr = td->td_proc->p_ucred->cr_prison; - if (pr != NULL && pr->pr_linux != NULL) { - lpr = pr->pr_linux; - if (lpr->pr_osrelease[0]) - return (lpr->pr_osrelease); - } - - return (linux_osrelease); -} - -int -linux_set_osrelease(struct thread *td, char *osrelease) -{ - struct linux_prison *lpr; - - lpr = get_prison(td); - if (lpr != NULL) - strcpy(lpr->pr_osrelease, osrelease); - else - strcpy(linux_osrelease, osrelease); - - return (0); -} - -int -linux_get_oss_version(struct thread *td) -{ - struct prison *pr; - struct linux_prison *lpr; - - KKASSERT(td->td_proc); - pr = td->td_proc->p_ucred->cr_prison; - if (pr != NULL && pr->pr_linux != NULL) { - lpr = pr->pr_linux; - if (lpr->pr_oss_version) - return (lpr->pr_oss_version); - } - - return (linux_oss_version); -} - -int -linux_set_oss_version(struct thread *td, int oss_version) -{ - struct linux_prison *lpr; - - lpr = get_prison(td); - if (lpr != NULL) - lpr->pr_oss_version = oss_version; - else - linux_oss_version = oss_version; - - return (0); -} - -#ifdef DEBUG - -u_char linux_debug_map[howmany(LINUX_SYS_MAXSYSCALL, sizeof(u_char))]; - -static int -linux_debug(int syscall, int toggle, int global) -{ - - if (global) { - char c = toggle ? 0 : 0xff; - - memset(linux_debug_map, c, sizeof(linux_debug_map)); - return (0); - } - if (syscall < 0 || syscall >= LINUX_SYS_MAXSYSCALL) - return (EINVAL); - if (toggle) - clrbit(linux_debug_map, syscall); - else - setbit(linux_debug_map, syscall); - return (0); -} - -/* - * Usage: sysctl -w linux.debug=.<0/1> - * - * E.g.: sysctl -w linux.debug=21.0 - * - * As a special case, syscall "all" will apply to all syscalls globally. - */ -#define LINUX_MAX_DEBUGSTR 16 -static int -linux_sysctl_debug(SYSCTL_HANDLER_ARGS) -{ - char value[LINUX_MAX_DEBUGSTR], *p; - int error, sysc, toggle; - int global = 0; - - value[0] = '\0'; - error = sysctl_handle_string(oidp, value, LINUX_MAX_DEBUGSTR, req); - if (error || req->newptr == NULL) - return (error); - for (p = value; *p != '\0' && *p != '.'; p++); - if (*p == '\0') - return (EINVAL); - *p++ = '\0'; - sysc = strtol(value, NULL, 0); - toggle = strtol(p, NULL, 0); - if (strcmp(value, "all") == 0) - global = 1; - error = linux_debug(sysc, toggle, global); - return (error); -} - -SYSCTL_PROC(_compat_linux, OID_AUTO, debug, - CTLTYPE_STRING | CTLFLAG_RW, - 0, 0, linux_sysctl_debug, "A", - "Linux debugging control"); - -#endif /* DEBUG */ diff --git a/sys/emulation/linux/linux_mib.h b/sys/emulation/linux/linux_mib.h deleted file mode 100644 index b91ced921a..0000000000 --- a/sys/emulation/linux/linux_mib.h +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * Copyright (c) 1999 Marcel Moolenaar - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer - * in this position and unchanged. - * 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 - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD: src/sys/compat/linux/linux_mib.h,v 1.3.2.1 2000/10/30 10:51:37 obrien Exp $ - * $DragonFly: src/sys/emulation/linux/linux_mib.h,v 1.4 2003/08/27 06:30:03 rob Exp $ - */ - -#ifndef _LINUX_MIB_H_ -#define _LINUX_MIB_H_ - -char* linux_get_osname (struct thread *td); -int linux_set_osname (struct thread *td, char *osname); - -char* linux_get_osrelease (struct thread *td); -int linux_set_osrelease (struct thread *td, char *osrelease); - -int linux_get_oss_version (struct thread *td); -int linux_set_oss_version (struct thread *td, int oss_version); - -#endif /* _LINUX_MIB_H_ */ diff --git a/sys/emulation/linux/linux_misc.c b/sys/emulation/linux/linux_misc.c deleted file mode 100644 index 3d1575029e..0000000000 --- a/sys/emulation/linux/linux_misc.c +++ /dev/null @@ -1,1959 +0,0 @@ -/*- - * Copyright (c) 1994-1995 Søren Schmidt - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer - * in this position and unchanged. - * 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 - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD: src/sys/compat/linux/linux_misc.c,v 1.85.2.9 2002/09/24 08:11:41 mdodd Exp $ - */ - -#include "opt_compat.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#ifdef __i386__ -#include -#endif - -#include - -#include -#include -#include -#include "linux_mib.h" -#include "linux_util.h" -#include "linux_emuldata.h" -#include "i386/linux.h" - -#define BSD_TO_LINUX_SIGNAL(sig) \ - (((sig) <= LINUX_SIGTBLSZ) ? bsd_to_linux_signal[_SIG_IDX(sig)] : sig) - -static unsigned int linux_to_bsd_resource[LINUX_RLIM_NLIMITS] = { - RLIMIT_CPU, RLIMIT_FSIZE, RLIMIT_DATA, RLIMIT_STACK, - RLIMIT_CORE, RLIMIT_RSS, RLIMIT_NPROC, RLIMIT_NOFILE, - RLIMIT_MEMLOCK, -1 -}; - -struct l_sysinfo { - l_long uptime; /* Seconds since boot */ - l_ulong loads[3]; /* 1, 5, and 15 minute load averages */ - l_ulong totalram; /* Total usable main memory size */ - l_ulong freeram; /* Available memory size */ - l_ulong sharedram; /* Amount of shared memory */ - l_ulong bufferram; /* Memory used by buffers */ - l_ulong totalswap; /* Total swap space size */ - l_ulong freeswap; /* swap space still available */ - l_ushort procs; /* Number of current processes */ - l_ushort pad; /* explicit padding */ - l_ulong totalhigh; /* Total high memory size */ - l_ulong freehigh; /* Available high memory size */ - l_uint mem_unit; /* Memory unit size in bytes */ - char _f[20-2*sizeof(l_long)-sizeof(l_int)]; /* Padding for libc5 */ -}; - -int -sys_linux_madvise(struct linux_madvise_args *args) -{ - return 0; -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_sysinfo(struct linux_sysinfo_args *args) -{ - struct l_sysinfo sysinfo; - struct timespec ts; - int error; - int i; - int n; - - /* Uptime is copied out of print_uptime() in kern_shutdown.c */ - getnanouptime(&ts); - i = 0; - if (ts.tv_sec >= 86400) { - ts.tv_sec %= 86400; - i = 1; - } - if (i || ts.tv_sec >= 3600) { - ts.tv_sec %= 3600; - i = 1; - } - if (i || ts.tv_sec >= 60) { - ts.tv_sec %= 60; - i = 1; - } - - bzero(&sysinfo, sizeof(sysinfo)); - sysinfo.uptime=ts.tv_sec; - - /* Use the information from the mib to get our load averages */ - for (i = 0; i < 3; i++) - sysinfo.loads[i] = averunnable.ldavg[i]; - - sysinfo.totalram = Maxmem * PAGE_SIZE; - sysinfo.freeram = sysinfo.totalram - vmstats.v_wire_count * PAGE_SIZE; - sysinfo.sharedram = 0; - - for (n = 0; n < ncpus; ++n) { - globaldata_t gd = globaldata_find(n); - - sysinfo.sharedram += gd->gd_vmtotal.t_avmshr; - } - sysinfo.sharedram *= PAGE_SIZE; - sysinfo.bufferram = 0; - - if (swapblist == NULL) { - sysinfo.totalswap= 0; - sysinfo.freeswap = 0; - } else { - sysinfo.totalswap = swapblist->bl_blocks * 1024; - sysinfo.freeswap = swapblist->bl_root->u.bmu_avail * PAGE_SIZE; - } - - sysinfo.procs = nprocs; - sysinfo.totalhigh = 0; - sysinfo.freehigh = 0; - sysinfo.mem_unit = 1; /* Set the basic mem unit to 1 */ - - error = copyout(&sysinfo, (caddr_t)args->info, sizeof(sysinfo)); - return (error); -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_alarm(struct linux_alarm_args *args) -{ - struct thread *td = curthread; - struct proc *p = td->td_proc; - struct itimerval it, old_it; - struct timeval tv; - -#ifdef DEBUG - if (ldebug(alarm)) - kprintf(ARGS(alarm, "%u"), args->secs); -#endif - - if (args->secs > 100000000) - return EINVAL; - - it.it_value.tv_sec = (long)args->secs; - it.it_value.tv_usec = 0; - it.it_interval.tv_sec = 0; - it.it_interval.tv_usec = 0; - get_mplock(); - crit_enter(); - old_it = p->p_realtimer; - getmicrouptime(&tv); - if (timevalisset(&old_it.it_value)) - callout_stop(&p->p_ithandle); - if (it.it_value.tv_sec != 0) { - callout_reset(&p->p_ithandle, tvtohz_high(&it.it_value), - realitexpire, p); - timevaladd(&it.it_value, &tv); - } - p->p_realtimer = it; - crit_exit(); - rel_mplock(); - if (timevalcmp(&old_it.it_value, &tv, >)) { - timevalsub(&old_it.it_value, &tv); - if (old_it.it_value.tv_usec != 0) - old_it.it_value.tv_sec++; - args->sysmsg_result = old_it.it_value.tv_sec; - } - return 0; -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_brk(struct linux_brk_args *args) -{ - struct thread *td = curthread; - struct proc *p = td->td_proc; - struct vmspace *vm; - vm_offset_t new, old; - struct obreak_args bsd_args; - - get_mplock(); - vm = p->p_vmspace; -#ifdef DEBUG - if (ldebug(brk)) - kprintf(ARGS(brk, "%p"), (void *)args->dsend); -#endif - old = (vm_offset_t)vm->vm_daddr + ctob(vm->vm_dsize); - new = (vm_offset_t)args->dsend; - bsd_args.sysmsg_result = 0; - bsd_args.nsize = (char *) new; - bsd_args.sysmsg_result = 0; - if (((caddr_t)new > vm->vm_daddr) && !sys_obreak(&bsd_args)) - args->sysmsg_result = (long)new; - else - args->sysmsg_result = (long)old; - rel_mplock(); - - return 0; -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_uselib(struct linux_uselib_args *args) -{ - struct thread *td = curthread; - struct proc *p; - struct nlookupdata nd; - struct vnode *vp; - struct exec *a_out; - struct vattr attr; - vm_offset_t vmaddr; - unsigned long file_offset; - vm_offset_t buffer; - unsigned long bss_size; - int error; - int locked; - char *path; - - p = td->td_proc; - - error = linux_copyin_path(args->library, &path, LINUX_PATH_EXISTS); - if (error) - return (error); -#ifdef DEBUG - if (ldebug(uselib)) - kprintf(ARGS(uselib, "%s"), path); -#endif - - a_out = NULL; - locked = 0; - vp = NULL; - - get_mplock(); - error = nlookup_init(&nd, path, UIO_SYSSPACE, NLC_FOLLOW); - nd.nl_flags |= NLC_EXEC; - if (error == 0) - error = nlookup(&nd); - if (error == 0) - error = cache_vget(&nd.nl_nch, nd.nl_cred, LK_EXCLUSIVE, &vp); - if (error) - goto cleanup; - /* - * From here on down, we have a locked vnode that must be unlocked. - */ - locked = 1; - - /* Writable? */ - if (vp->v_writecount) { - error = ETXTBSY; - goto cleanup; - } - - /* Executable? */ - error = VOP_GETATTR(vp, &attr); - if (error) - goto cleanup; - - if ((vp->v_mount->mnt_flag & MNT_NOEXEC) || - ((attr.va_mode & 0111) == 0) || (attr.va_type != VREG)) { - error = ENOEXEC; - goto cleanup; - } - - /* Sensible size? */ - if (attr.va_size == 0) { - error = ENOEXEC; - goto cleanup; - } - - error = VOP_OPEN(vp, FREAD, td->td_ucred, NULL); - if (error) - goto cleanup; - - /* - * Lock no longer needed - */ - vn_unlock(vp); - locked = 0; - - /* Pull in executable header into kernel_map */ - error = vm_mmap(&kernel_map, (vm_offset_t *)&a_out, PAGE_SIZE, - VM_PROT_READ, VM_PROT_READ, 0, (caddr_t)vp, 0); - if (error) - goto cleanup; - - /* Is it a Linux binary ? */ - if (((a_out->a_magic >> 16) & 0xff) != 0x64) { - error = ENOEXEC; - goto cleanup; - } - - /* - * While we are here, we should REALLY do some more checks - */ - - /* Set file/virtual offset based on a.out variant. */ - switch ((int)(a_out->a_magic & 0xffff)) { - case 0413: /* ZMAGIC */ - file_offset = 1024; - break; - case 0314: /* QMAGIC */ - file_offset = 0; - break; - default: - error = ENOEXEC; - goto cleanup; - } - - bss_size = round_page(a_out->a_bss); - - /* Check various fields in header for validity/bounds. */ - if (a_out->a_text & PAGE_MASK || a_out->a_data & PAGE_MASK) { - error = ENOEXEC; - goto cleanup; - } - - /* text + data can't exceed file size */ - if (a_out->a_data + a_out->a_text > attr.va_size) { - error = EFAULT; - goto cleanup; - } - - /* - * text/data/bss must not exceed limits - * XXX - this is not complete. it should check current usage PLUS - * the resources needed by this library. - */ - if (a_out->a_text > maxtsiz || - a_out->a_data + bss_size > p->p_rlimit[RLIMIT_DATA].rlim_cur) { - error = ENOMEM; - goto cleanup; - } - - /* prevent more writers */ - vsetflags(vp, VTEXT); - - /* - * Check if file_offset page aligned. Currently we cannot handle - * misalinged file offsets, and so we read in the entire image - * (what a waste). - */ - if (file_offset & PAGE_MASK) { -#ifdef DEBUG - kprintf("uselib: Non page aligned binary %lu\n", file_offset); -#endif - /* Map text+data read/write/execute */ - - /* a_entry is the load address and is page aligned */ - vmaddr = trunc_page(a_out->a_entry); - - /* get anon user mapping, read+write+execute */ - error = vm_map_find(&p->p_vmspace->vm_map, NULL, NULL, - 0, &vmaddr, a_out->a_text + a_out->a_data, - PAGE_SIZE, - FALSE, VM_MAPTYPE_NORMAL, - VM_PROT_ALL, VM_PROT_ALL, 0); - if (error) - goto cleanup; - - /* map file into kernel_map */ - error = vm_mmap(&kernel_map, &buffer, - round_page(a_out->a_text + a_out->a_data + file_offset), - VM_PROT_READ, VM_PROT_READ, 0, (caddr_t)vp, - trunc_page(file_offset)); - if (error) - goto cleanup; - - /* copy from kernel VM space to user space */ - error = copyout((caddr_t)(uintptr_t)(buffer + file_offset), - (caddr_t)vmaddr, a_out->a_text + a_out->a_data); - - /* release temporary kernel space */ - vm_map_remove(&kernel_map, buffer, buffer + - round_page(a_out->a_text + a_out->a_data + file_offset)); - - if (error) - goto cleanup; - } else { -#ifdef DEBUG - kprintf("uselib: Page aligned binary %lu\n", file_offset); -#endif - /* - * for QMAGIC, a_entry is 20 bytes beyond the load address - * to skip the executable header - */ - vmaddr = trunc_page(a_out->a_entry); - - /* - * Map it all into the process's space as a single - * copy-on-write "data" segment. - */ - error = vm_mmap(&p->p_vmspace->vm_map, &vmaddr, - a_out->a_text + a_out->a_data, VM_PROT_ALL, VM_PROT_ALL, - MAP_PRIVATE | MAP_FIXED, (caddr_t)vp, file_offset); - if (error) - goto cleanup; - } -#ifdef DEBUG - kprintf("mem=%08lx = %08lx %08lx\n", (long)vmaddr, ((long*)vmaddr)[0], - ((long*)vmaddr)[1]); -#endif - if (bss_size != 0) { - /* Calculate BSS start address */ - vmaddr = trunc_page(a_out->a_entry) + a_out->a_text + - a_out->a_data; - - /* allocate some 'anon' space */ - error = vm_map_find(&p->p_vmspace->vm_map, NULL, NULL, - 0, &vmaddr, bss_size, - PAGE_SIZE, - FALSE, VM_MAPTYPE_NORMAL, - VM_PROT_ALL, VM_PROT_ALL, 0); - if (error) - goto cleanup; - } - -cleanup: - /* Unlock/release vnode */ - if (vp) { - if (locked) - vn_unlock(vp); - vrele(vp); - } - /* Release the kernel mapping. */ - if (a_out) { - vm_map_remove(&kernel_map, (vm_offset_t)a_out, - (vm_offset_t)a_out + PAGE_SIZE); - } - nlookup_done(&nd); - rel_mplock(); - linux_free_path(&path); - return (error); -} - -/* - * MPSAFE - */ -int -sys_linux_select(struct linux_select_args *args) -{ - struct select_args bsa; - struct timeval tv0, tv1, utv, *tvp; - caddr_t sg; - int error; - -#ifdef DEBUG - if (ldebug(select)) - kprintf(ARGS(select, "%d, %p, %p, %p, %p"), args->nfds, - (void *)args->readfds, (void *)args->writefds, - (void *)args->exceptfds, (void *)args->timeout); -#endif - - error = 0; - bsa.sysmsg_result = 0; - bsa.nd = args->nfds; - bsa.in = args->readfds; - bsa.ou = args->writefds; - bsa.ex = args->exceptfds; - bsa.tv = (struct timeval *)args->timeout; - - /* - * Store current time for computation of the amount of - * time left. - */ - if (args->timeout) { - if ((error = copyin((caddr_t)args->timeout, &utv, - sizeof(utv)))) - goto select_out; -#ifdef DEBUG - if (ldebug(select)) - kprintf(LMSG("incoming timeout (%ld/%ld)"), - utv.tv_sec, utv.tv_usec); -#endif - - if (itimerfix(&utv)) { - /* - * The timeval was invalid. Convert it to something - * valid that will act as it does under Linux. - */ - sg = stackgap_init(); - tvp = stackgap_alloc(&sg, sizeof(utv)); - utv.tv_sec += utv.tv_usec / 1000000; - utv.tv_usec %= 1000000; - if (utv.tv_usec < 0) { - utv.tv_sec -= 1; - utv.tv_usec += 1000000; - } - if (utv.tv_sec < 0) - timevalclear(&utv); - if ((error = copyout(&utv, tvp, sizeof(utv)))) - goto select_out; - bsa.tv = tvp; - } - microtime(&tv0); - } - - error = sys_select(&bsa); - args->sysmsg_result = bsa.sysmsg_result; -#ifdef DEBUG - if (ldebug(select)) - kprintf(LMSG("real select returns %d"), error); -#endif - if (error) { - /* - * See fs/select.c in the Linux kernel. Without this, - * Maelstrom doesn't work. - */ - if (error == ERESTART) - error = EINTR; - goto select_out; - } - - if (args->timeout) { - if (args->sysmsg_result) { - /* - * Compute how much time was left of the timeout, - * by subtracting the current time and the time - * before we started the call, and subtracting - * that result from the user-supplied value. - */ - microtime(&tv1); - timevalsub(&tv1, &tv0); - timevalsub(&utv, &tv1); - if (utv.tv_sec < 0) - timevalclear(&utv); - } else - timevalclear(&utv); -#ifdef DEBUG - if (ldebug(select)) - kprintf(LMSG("outgoing timeout (%ld/%ld)"), - utv.tv_sec, utv.tv_usec); -#endif - if ((error = copyout(&utv, (caddr_t)args->timeout, - sizeof(utv)))) - goto select_out; - } - -select_out: -#ifdef DEBUG - if (ldebug(select)) - kprintf(LMSG("select_out -> %d"), error); -#endif - return error; -} - -/* - * MPSAFE - */ -int -sys_linux_mremap(struct linux_mremap_args *args) -{ - struct munmap_args bsd_args; - int error = 0; - -#ifdef DEBUG - if (ldebug(mremap)) - kprintf(ARGS(mremap, "%p, %08lx, %08lx, %08lx"), - (void *)args->addr, - (unsigned long)args->old_len, - (unsigned long)args->new_len, - (unsigned long)args->flags); -#endif - if (args->flags & ~(LINUX_MREMAP_FIXED | LINUX_MREMAP_MAYMOVE)) { - args->sysmsg_resultp = NULL; - return (EINVAL); - } - - /* - * Check for the page alignment. - * Linux defines PAGE_MASK to be FreeBSD ~PAGE_MASK. - */ - if (args->addr & PAGE_MASK) { - args->sysmsg_resultp = NULL; - return (EINVAL); - } - - args->new_len = round_page(args->new_len); - args->old_len = round_page(args->old_len); - - if (args->new_len > args->old_len) { - args->sysmsg_result = 0; - return ENOMEM; - } - - if (args->new_len < args->old_len) { - bsd_args.sysmsg_result = 0; - bsd_args.addr = (caddr_t)(args->addr + args->new_len); - bsd_args.len = args->old_len - args->new_len; - error = sys_munmap(&bsd_args); - } - - args->sysmsg_resultp = error ? NULL : (void *)args->addr; - return error; -} - -#define LINUX_MS_ASYNC 0x0001 -#define LINUX_MS_INVALIDATE 0x0002 -#define LINUX_MS_SYNC 0x0004 - -/* - * MPSAFE - */ -int -sys_linux_msync(struct linux_msync_args *args) -{ - struct msync_args bsd_args; - int error; - - bsd_args.addr = (caddr_t)args->addr; - bsd_args.len = args->len; - bsd_args.flags = args->fl & ~LINUX_MS_SYNC; - bsd_args.sysmsg_result = 0; - - error = sys_msync(&bsd_args); - args->sysmsg_result = bsd_args.sysmsg_result; - return(error); -} - -/* - * MPSAFE - */ -int -sys_linux_time(struct linux_time_args *args) -{ - struct timeval tv; - l_time_t tm; - int error; - -#ifdef DEBUG - if (ldebug(time)) - kprintf(ARGS(time, "*")); -#endif - - microtime(&tv); - tm = tv.tv_sec; - if (args->tm && (error = copyout(&tm, (caddr_t)args->tm, sizeof(tm)))) - return error; - args->sysmsg_lresult = tm; - return 0; -} - -struct l_times_argv { - l_long tms_utime; - l_long tms_stime; - l_long tms_cutime; - l_long tms_cstime; -}; - -#define CLK_TCK 100 /* Linux uses 100 */ - -#define CONVTCK(r) (r.tv_sec * CLK_TCK + r.tv_usec / (1000000 / CLK_TCK)) - -/* - * MPALMOSTSAFE - */ -int -sys_linux_times(struct linux_times_args *args) -{ - struct thread *td = curthread; - struct proc *p = td->td_proc; - struct timeval tv; - struct l_times_argv tms; - struct rusage ru; - int error; - -#ifdef DEBUG - if (ldebug(times)) - kprintf(ARGS(times, "*")); -#endif - - get_mplock(); - calcru_proc(p, &ru); - rel_mplock(); - - tms.tms_utime = CONVTCK(ru.ru_utime); - tms.tms_stime = CONVTCK(ru.ru_stime); - - tms.tms_cutime = CONVTCK(p->p_cru.ru_utime); - tms.tms_cstime = CONVTCK(p->p_cru.ru_stime); - - if ((error = copyout(&tms, (caddr_t)args->buf, sizeof(tms)))) - return error; - - microuptime(&tv); - args->sysmsg_result = (int)CONVTCK(tv); - return 0; -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_newuname(struct linux_newuname_args *args) -{ - struct thread *td = curthread; - struct l_new_utsname utsname; - char *osrelease, *osname; - -#ifdef DEBUG - if (ldebug(newuname)) - kprintf(ARGS(newuname, "*")); -#endif - - get_mplock(); - osname = linux_get_osname(td); - osrelease = linux_get_osrelease(td); - - bzero(&utsname, sizeof(utsname)); - strncpy(utsname.sysname, osname, LINUX_MAX_UTSNAME-1); - strncpy(utsname.nodename, hostname, LINUX_MAX_UTSNAME-1); - strncpy(utsname.release, osrelease, LINUX_MAX_UTSNAME-1); - strncpy(utsname.version, version, LINUX_MAX_UTSNAME-1); - strncpy(utsname.machine, machine, LINUX_MAX_UTSNAME-1); - strncpy(utsname.domainname, domainname, LINUX_MAX_UTSNAME-1); - rel_mplock(); - - return (copyout(&utsname, (caddr_t)args->buf, sizeof(utsname))); -} - -/* XXX: why would this be i386-only? most of these are wrong! */ -#if defined(__i386__) -struct l_utimbuf { - l_time_t l_actime; - l_time_t l_modtime; -}; - -/* - * MPALMOSTSAFE - */ -int -sys_linux_utime(struct linux_utime_args *args) -{ - struct timeval tv[2]; - struct l_utimbuf lut; - struct nlookupdata nd; - char *path; - int error; - - error = linux_copyin_path(args->fname, &path, LINUX_PATH_EXISTS); - if (error) - return (error); -#ifdef DEBUG - if (ldebug(utime)) - kprintf(ARGS(utime, "%s, *"), path); -#endif - - if (args->times) { - error = copyin(args->times, &lut, sizeof(lut)); - if (error) - goto cleanup; - tv[0].tv_sec = lut.l_actime; - tv[0].tv_usec = 0; - tv[1].tv_sec = lut.l_modtime; - tv[1].tv_usec = 0; - } - get_mplock(); - error = nlookup_init(&nd, path, UIO_SYSSPACE, NLC_FOLLOW); - if (error == 0) - error = kern_utimes(&nd, args->times ? tv : NULL); - nlookup_done(&nd); - rel_mplock(); -cleanup: - linux_free_path(&path); - return (error); -} - -int -sys_linux_utimes(struct linux_utimes_args *args) -{ - l_timeval ltv[2]; - struct timeval tv[2], *tvp = NULL; - struct nlookupdata nd; - char *path; - int error; - - error = linux_copyin_path(args->fname, &path, LINUX_PATH_EXISTS); - if (error) - return (error); -#ifdef DEBUG - if (ldebug(utimes)) - kprintf(ARGS(utimes, "%s, *"), path); -#endif - - if (args->tptr) { - error = copyin(args->tptr, ltv, sizeof(ltv)); - if (error) - goto cleanup; - tv[0].tv_sec = ltv[0].tv_sec; - tv[0].tv_usec = ltv[0].tv_usec; - tv[1].tv_sec = ltv[1].tv_sec; - tv[1].tv_usec = ltv[1].tv_usec; - tvp = tv; - } - get_mplock(); - error = nlookup_init(&nd, path, UIO_SYSSPACE, NLC_FOLLOW); - if (error == 0) - error = kern_utimes(&nd, tvp); - nlookup_done(&nd); - rel_mplock(); -cleanup: - linux_free_path(&path); - return (error); -} - -int -sys_linux_futimesat(struct linux_futimesat_args *args) -{ - l_timeval ltv[2]; - struct timeval tv[2], *tvp = NULL; - struct file *fp; - struct nlookupdata nd; - char *path; - int dfd,error; - - error = linux_copyin_path(args->fname, &path, LINUX_PATH_EXISTS); - if (error) - return (error); -#ifdef DEBUG - if (ldebug(futimesat)) - kprintf(ARGS(futimesat, "%s, *"), path); -#endif - if (args->tptr) { - error = copyin(args->tptr, ltv, sizeof(ltv)); - if (error) - goto cleanup; - tv[0].tv_sec = ltv[0].tv_sec; - tv[0].tv_usec = ltv[0].tv_usec; - tv[1].tv_sec = ltv[1].tv_sec; - tv[1].tv_usec = ltv[1].tv_usec; - tvp = tv; - } - dfd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->dfd; - get_mplock(); - error = nlookup_init_at(&nd, &fp, dfd, path, UIO_SYSSPACE, NLC_FOLLOW); - if (error == 0) - error = kern_utimes(&nd, tvp); - nlookup_done_at(&nd, fp); - rel_mplock(); -cleanup: - linux_free_path(&path); - return (error); -} - - -int -sys_linux_utimensat(struct linux_utimensat_args *args) -{ - struct l_timespec ltv[2]; - struct timeval tv[2], *tvp = NULL; - struct file *fp; - struct nlookupdata nd; - char *path; - int dfd, flags, error = 0; - - if (args->flag & ~LINUX_AT_SYMLINK_NOFOLLOW) - return (EINVAL); - - if (args->dfd == LINUX_AT_FDCWD && args->fname == NULL) - return (EINVAL); - - if (args->fname) { - error = linux_copyin_path(args->fname, &path, LINUX_PATH_EXISTS); - if (error) - return (error); - } -#ifdef DEBUG - if (ldebug(utimensat)) - kprintf(ARGS(utimensat, "%s, *"), path); -#endif - if (args->tptr) { - error = copyin(args->tptr, ltv, sizeof(ltv)); - if (error) - goto cleanup; - - if (ltv[0].tv_sec == LINUX_UTIME_NOW) { - microtime(&tv[0]); - } else if (ltv[0].tv_sec == LINUX_UTIME_OMIT) { - /* XXX: this is not right, but will do for now */ - microtime(&tv[0]); - } else { - tv[0].tv_sec = ltv[0].tv_sec; - /* XXX: we lose precision here, as we don't have ns */ - tv[0].tv_usec = ltv[0].tv_nsec/1000; - } - if (ltv[1].tv_sec == LINUX_UTIME_NOW) { - microtime(&tv[1]); - } else if (ltv[1].tv_sec == LINUX_UTIME_OMIT) { - /* XXX: this is not right, but will do for now */ - microtime(&tv[1]); - } else { - tv[1].tv_sec = ltv[1].tv_sec; - /* XXX: we lose precision here, as we don't have ns */ - tv[1].tv_usec = ltv[1].tv_nsec/1000; - } - tvp = tv; - } - - dfd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->dfd; - flags = (args->flag & LINUX_AT_SYMLINK_NOFOLLOW) ? 0 : NLC_FOLLOW; - - get_mplock(); - if (args->fname) { - error = nlookup_init_at(&nd, &fp, dfd, path, UIO_SYSSPACE, flags); - if (error == 0) - error = kern_utimes(&nd, tvp); - nlookup_done_at(&nd, fp); - } else { - /* Thank you, Linux, for another non-standard "feature" */ - KKASSERT(dfd != AT_FDCWD); - error = kern_futimes(dfd, tvp); - } - rel_mplock(); -cleanup: - if (args->fname) - linux_free_path(&path); - - return (error); -} -#endif /* __i386__ */ - -#define __WCLONE 0x80000000 - -/* - * MPALMOSTSAFE - */ -int -sys_linux_waitpid(struct linux_waitpid_args *args) -{ - int error, options, status; - -#ifdef DEBUG - if (ldebug(waitpid)) - kprintf(ARGS(waitpid, "%d, %p, %d"), - args->pid, (void *)args->status, args->options); -#endif - options = args->options & (WNOHANG | WUNTRACED); - /* WLINUXCLONE should be equal to __WCLONE, but we make sure */ - if (args->options & __WCLONE) - options |= WLINUXCLONE; - - error = kern_wait(args->pid, args->status ? &status : NULL, options, - NULL, &args->sysmsg_result); - - if (error == 0 && args->status) { - status &= 0xffff; - if (WIFSIGNALED(status)) - status = (status & 0xffffff80) | - BSD_TO_LINUX_SIGNAL(WTERMSIG(status)); - else if (WIFSTOPPED(status)) - status = (status & 0xffff00ff) | - (BSD_TO_LINUX_SIGNAL(WSTOPSIG(status)) << 8); - error = copyout(&status, args->status, sizeof(status)); - } - - return (error); -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_wait4(struct linux_wait4_args *args) -{ - struct thread *td = curthread; - struct lwp *lp = td->td_lwp; - struct rusage rusage; - int error, options, status; - -#ifdef DEBUG - if (ldebug(wait4)) - kprintf(ARGS(wait4, "%d, %p, %d, %p"), - args->pid, (void *)args->status, args->options, - (void *)args->rusage); -#endif - options = args->options & (WNOHANG | WUNTRACED); - /* WLINUXCLONE should be equal to __WCLONE, but we make sure */ - if (args->options & __WCLONE) - options |= WLINUXCLONE; - - error = kern_wait(args->pid, args->status ? &status : NULL, options, - args->rusage ? &rusage : NULL, &args->sysmsg_result); - - if (error == 0) { - spin_lock(&lp->lwp_spin); - lwp_delsig(lp, SIGCHLD); - spin_unlock(&lp->lwp_spin); - } - - if (error == 0 && args->status) { - status &= 0xffff; - if (WIFSIGNALED(status)) - status = (status & 0xffffff80) | - BSD_TO_LINUX_SIGNAL(WTERMSIG(status)); - else if (WIFSTOPPED(status)) - status = (status & 0xffff00ff) | - (BSD_TO_LINUX_SIGNAL(WSTOPSIG(status)) << 8); - error = copyout(&status, args->status, sizeof(status)); - } - if (error == 0 && args->rusage) - error = copyout(&rusage, args->rusage, sizeof(rusage)); - - return (error); -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_mknod(struct linux_mknod_args *args) -{ - struct nlookupdata nd; - char *path; - int error; - - error = linux_copyin_path(args->path, &path, LINUX_PATH_CREATE); - if (error) - return (error); -#ifdef DEBUG - if (ldebug(mknod)) - kprintf(ARGS(mknod, "%s, %d, %d"), - path, args->mode, args->dev); -#endif - get_mplock(); - error = nlookup_init(&nd, path, UIO_SYSSPACE, 0); - if (error == 0) { - if (args->mode & S_IFIFO) { - error = kern_mkfifo(&nd, args->mode); - } else { - error = kern_mknod(&nd, args->mode, - umajor(args->dev), - uminor(args->dev)); - } - } - nlookup_done(&nd); - rel_mplock(); - - linux_free_path(&path); - return(error); -} - -int -sys_linux_mknodat(struct linux_mknodat_args *args) -{ - struct nlookupdata nd; - struct file *fp; - char *path; - int dfd, error; - - error = linux_copyin_path(args->path, &path, LINUX_PATH_CREATE); - if (error) - return (error); -#ifdef DEBUG - if (ldebug(mknod)) - kprintf(ARGS(mknod, "%s, %d, %d"), - path, args->mode, args->dev); -#endif - get_mplock(); - dfd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->dfd; - error = nlookup_init_at(&nd, &fp, dfd, path, UIO_SYSSPACE, 0); - if (error == 0) { - if (args->mode & S_IFIFO) { - error = kern_mkfifo(&nd, args->mode); - } else { - error = kern_mknod(&nd, args->mode, - umajor(args->dev), - uminor(args->dev)); - } - } - nlookup_done_at(&nd, fp); - rel_mplock(); - - linux_free_path(&path); - return(error); -} - -/* - * UGH! This is just about the dumbest idea I've ever heard!! - * - * MPSAFE - */ -int -sys_linux_personality(struct linux_personality_args *args) -{ -#ifdef DEBUG - if (ldebug(personality)) - kprintf(ARGS(personality, "%d"), args->per); -#endif - if (args->per != 0) - return EINVAL; - - /* Yes Jim, it's still a Linux... */ - args->sysmsg_result = 0; - return 0; -} - -/* - * Wrappers for get/setitimer for debugging.. - * - * MPSAFE - */ -int -sys_linux_setitimer(struct linux_setitimer_args *args) -{ - struct setitimer_args bsa; - struct itimerval foo; - int error; - -#ifdef DEBUG - if (ldebug(setitimer)) - kprintf(ARGS(setitimer, "%p, %p"), - (void *)args->itv, (void *)args->oitv); -#endif - bsa.which = args->which; - bsa.itv = (struct itimerval *)args->itv; - bsa.oitv = (struct itimerval *)args->oitv; - bsa.sysmsg_result = 0; - if (args->itv) { - if ((error = copyin((caddr_t)args->itv, &foo, sizeof(foo)))) - return error; -#ifdef DEBUG - if (ldebug(setitimer)) { - kprintf("setitimer: value: sec: %ld, usec: %ld\n", - foo.it_value.tv_sec, foo.it_value.tv_usec); - kprintf("setitimer: interval: sec: %ld, usec: %ld\n", - foo.it_interval.tv_sec, foo.it_interval.tv_usec); - } -#endif - } - error = sys_setitimer(&bsa); - args->sysmsg_result = bsa.sysmsg_result; - return(error); -} - -/* - * MPSAFE - */ -int -sys_linux_getitimer(struct linux_getitimer_args *args) -{ - struct getitimer_args bsa; - int error; -#ifdef DEBUG - if (ldebug(getitimer)) - kprintf(ARGS(getitimer, "%p"), (void *)args->itv); -#endif - bsa.which = args->which; - bsa.itv = (struct itimerval *)args->itv; - bsa.sysmsg_result = 0; - error = sys_getitimer(&bsa); - args->sysmsg_result = bsa.sysmsg_result; - return(error); -} - -/* - * MPSAFE - */ -int -sys_linux_nice(struct linux_nice_args *args) -{ - struct setpriority_args bsd_args; - int error; - - bsd_args.which = PRIO_PROCESS; - bsd_args.who = 0; /* current process */ - bsd_args.prio = args->inc; - bsd_args.sysmsg_result = 0; - error = sys_setpriority(&bsd_args); - args->sysmsg_result = bsd_args.sysmsg_result; - return(error); -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_setgroups(struct linux_setgroups_args *args) -{ - struct thread *td = curthread; - struct proc *p = td->td_proc; - struct ucred *newcred, *oldcred; - l_gid_t linux_gidset[NGROUPS]; - gid_t *bsd_gidset; - int ngrp, error; - - ngrp = args->gidsetsize; - oldcred = td->td_ucred; - - /* - * cr_groups[0] holds egid. Setting the whole set from - * the supplied set will cause egid to be changed too. - * Keep cr_groups[0] unchanged to prevent that. - */ - - if ((error = priv_check_cred(oldcred, PRIV_CRED_SETGROUPS, 0)) != 0) - return (error); - - if ((u_int)ngrp >= NGROUPS) - return (EINVAL); - - get_mplock(); - newcred = crdup(oldcred); - if (ngrp > 0) { - error = copyin((caddr_t)args->grouplist, linux_gidset, - ngrp * sizeof(l_gid_t)); - if (error) { - crfree(newcred); - rel_mplock(); - return (error); - } - - newcred->cr_ngroups = ngrp + 1; - - bsd_gidset = newcred->cr_groups; - ngrp--; - while (ngrp >= 0) { - bsd_gidset[ngrp + 1] = linux_gidset[ngrp]; - ngrp--; - } - } else { - newcred->cr_ngroups = 1; - } - - setsugid(); - oldcred = p->p_ucred; /* reload, deal with threads race */ - p->p_ucred = newcred; - crfree(oldcred); - rel_mplock(); - return (0); -} - -/* - * MPSAFE - */ -int -sys_linux_getgroups(struct linux_getgroups_args *args) -{ - struct thread *td = curthread; - struct ucred *cred; - l_gid_t linux_gidset[NGROUPS]; - gid_t *bsd_gidset; - int bsd_gidsetsz, ngrp, error; - - cred = td->td_ucred; - bsd_gidset = cred->cr_groups; - bsd_gidsetsz = cred->cr_ngroups - 1; - - /* - * cr_groups[0] holds egid. Returning the whole set - * here will cause a duplicate. Exclude cr_groups[0] - * to prevent that. - */ - - if ((ngrp = args->gidsetsize) == 0) { - args->sysmsg_result = bsd_gidsetsz; - return (0); - } - - if ((u_int)ngrp < bsd_gidsetsz) - return (EINVAL); - - ngrp = 0; - while (ngrp < bsd_gidsetsz) { - linux_gidset[ngrp] = bsd_gidset[ngrp + 1]; - ngrp++; - } - - if ((error = copyout(linux_gidset, args->grouplist, - ngrp * sizeof(l_gid_t)))) { - return (error); - } - - args->sysmsg_result = ngrp; - return (0); -} - -/* - * MPSAFE - */ -int -sys_linux_setrlimit(struct linux_setrlimit_args *args) -{ - struct l_rlimit linux_rlim; - struct rlimit rlim; - u_int which; - int error; - -#ifdef DEBUG - if (ldebug(setrlimit)) - kprintf(ARGS(setrlimit, "%d, %p"), - args->resource, (void *)args->rlim); -#endif - if (args->resource >= LINUX_RLIM_NLIMITS) - return (EINVAL); - which = linux_to_bsd_resource[args->resource]; - if (which == -1) - return (EINVAL); - - error = copyin(args->rlim, &linux_rlim, sizeof(linux_rlim)); - if (error) - return (error); - rlim.rlim_cur = (rlim_t)linux_rlim.rlim_cur; - rlim.rlim_max = (rlim_t)linux_rlim.rlim_max; - - error = kern_setrlimit(which, &rlim); - - return(error); -} - -/* - * MPSAFE - */ -int -sys_linux_old_getrlimit(struct linux_old_getrlimit_args *args) -{ - struct l_rlimit linux_rlim; - struct rlimit rlim; - u_int which; - int error; - -#ifdef DEBUG - if (ldebug(old_getrlimit)) - kprintf(ARGS(old_getrlimit, "%d, %p"), - args->resource, (void *)args->rlim); -#endif - if (args->resource >= LINUX_RLIM_NLIMITS) - return (EINVAL); - which = linux_to_bsd_resource[args->resource]; - if (which == -1) - return (EINVAL); - - error = kern_getrlimit(which, &rlim); - - if (error == 0) { - linux_rlim.rlim_cur = (l_ulong)rlim.rlim_cur; - if (linux_rlim.rlim_cur == ULONG_MAX) - linux_rlim.rlim_cur = LONG_MAX; - linux_rlim.rlim_max = (l_ulong)rlim.rlim_max; - if (linux_rlim.rlim_max == ULONG_MAX) - linux_rlim.rlim_max = LONG_MAX; - error = copyout(&linux_rlim, args->rlim, sizeof(linux_rlim)); - } - return (error); -} - -/* - * MPSAFE - */ -int -sys_linux_getrlimit(struct linux_getrlimit_args *args) -{ - struct l_rlimit linux_rlim; - struct rlimit rlim; - u_int which; - int error; - -#ifdef DEBUG - if (ldebug(getrlimit)) - kprintf(ARGS(getrlimit, "%d, %p"), - args->resource, (void *)args->rlim); -#endif - if (args->resource >= LINUX_RLIM_NLIMITS) - return (EINVAL); - which = linux_to_bsd_resource[args->resource]; - if (which == -1) - return (EINVAL); - - error = kern_getrlimit(which, &rlim); - - if (error == 0) { - linux_rlim.rlim_cur = (l_ulong)rlim.rlim_cur; - linux_rlim.rlim_max = (l_ulong)rlim.rlim_max; - error = copyout(&linux_rlim, args->rlim, sizeof(linux_rlim)); - } - return (error); -} - -/* - * MPSAFE - */ -int -sys_linux_sched_setscheduler(struct linux_sched_setscheduler_args *args) -{ - struct sched_setscheduler_args bsd; - int error; - -#ifdef DEBUG - if (ldebug(sched_setscheduler)) - kprintf(ARGS(sched_setscheduler, "%d, %d, %p"), - args->pid, args->policy, (const void *)args->param); -#endif - - switch (args->policy) { - case LINUX_SCHED_OTHER: - bsd.policy = SCHED_OTHER; - break; - case LINUX_SCHED_FIFO: - bsd.policy = SCHED_FIFO; - break; - case LINUX_SCHED_RR: - bsd.policy = SCHED_RR; - break; - default: - return EINVAL; - } - - bsd.pid = args->pid; - bsd.param = (struct sched_param *)args->param; - bsd.sysmsg_result = 0; - - error = sys_sched_setscheduler(&bsd); - args->sysmsg_result = bsd.sysmsg_result; - return(error); -} - -/* - * MPSAFE - */ -int -sys_linux_sched_getscheduler(struct linux_sched_getscheduler_args *args) -{ - struct sched_getscheduler_args bsd; - int error; - -#ifdef DEBUG - if (ldebug(sched_getscheduler)) - kprintf(ARGS(sched_getscheduler, "%d"), args->pid); -#endif - - bsd.sysmsg_result = 0; - bsd.pid = args->pid; - error = sys_sched_getscheduler(&bsd); - args->sysmsg_result = bsd.sysmsg_result; - - switch (args->sysmsg_result) { - case SCHED_OTHER: - args->sysmsg_result = LINUX_SCHED_OTHER; - break; - case SCHED_FIFO: - args->sysmsg_result = LINUX_SCHED_FIFO; - break; - case SCHED_RR: - args->sysmsg_result = LINUX_SCHED_RR; - break; - } - return error; -} - -/* - * MPSAFE - */ -int -sys_linux_sched_get_priority_max(struct linux_sched_get_priority_max_args *args) -{ - struct sched_get_priority_max_args bsd; - int error; - -#ifdef DEBUG - if (ldebug(sched_get_priority_max)) - kprintf(ARGS(sched_get_priority_max, "%d"), args->policy); -#endif - - switch (args->policy) { - case LINUX_SCHED_OTHER: - bsd.policy = SCHED_OTHER; - break; - case LINUX_SCHED_FIFO: - bsd.policy = SCHED_FIFO; - break; - case LINUX_SCHED_RR: - bsd.policy = SCHED_RR; - break; - default: - return EINVAL; - } - bsd.sysmsg_result = 0; - - error = sys_sched_get_priority_max(&bsd); - args->sysmsg_result = bsd.sysmsg_result; - return(error); -} - -/* - * MPSAFE - */ -int -sys_linux_sched_get_priority_min(struct linux_sched_get_priority_min_args *args) -{ - struct sched_get_priority_min_args bsd; - int error; - -#ifdef DEBUG - if (ldebug(sched_get_priority_min)) - kprintf(ARGS(sched_get_priority_min, "%d"), args->policy); -#endif - - switch (args->policy) { - case LINUX_SCHED_OTHER: - bsd.policy = SCHED_OTHER; - break; - case LINUX_SCHED_FIFO: - bsd.policy = SCHED_FIFO; - break; - case LINUX_SCHED_RR: - bsd.policy = SCHED_RR; - break; - default: - return EINVAL; - } - bsd.sysmsg_result = 0; - - error = sys_sched_get_priority_min(&bsd); - args->sysmsg_result = bsd.sysmsg_result; - return(error); -} - -#define REBOOT_CAD_ON 0x89abcdef -#define REBOOT_CAD_OFF 0 -#define REBOOT_HALT 0xcdef0123 -#define REBOOT_RESTART 0x01234567 -#define REBOOT_RESTART2 0xA1B2C3D4 -#define REBOOT_POWEROFF 0x4321FEDC -#define REBOOT_MAGIC1 0xfee1dead -#define REBOOT_MAGIC2 0x28121969 -#define REBOOT_MAGIC2A 0x05121996 -#define REBOOT_MAGIC2B 0x16041998 - -/* - * MPSAFE - */ -int -sys_linux_reboot(struct linux_reboot_args *args) -{ - struct reboot_args bsd_args; - int error; - -#ifdef DEBUG - if (ldebug(reboot)) - kprintf(ARGS(reboot, "0x%x"), args->cmd); -#endif - - if ((args->magic1 != REBOOT_MAGIC1) || - ((args->magic2 != REBOOT_MAGIC2) && - (args->magic2 != REBOOT_MAGIC2A) && - (args->magic2 != REBOOT_MAGIC2B))) - return EINVAL; - - switch (args->cmd) { - case REBOOT_CAD_ON: - case REBOOT_CAD_OFF: - return (priv_check(curthread, PRIV_REBOOT)); - /* NOTREACHED */ - case REBOOT_HALT: - bsd_args.opt = RB_HALT; - break; - case REBOOT_RESTART: - case REBOOT_RESTART2: - bsd_args.opt = 0; - break; - case REBOOT_POWEROFF: - bsd_args.opt = RB_POWEROFF; - break; - default: - return EINVAL; - /* NOTREACHED */ - } - - bsd_args.sysmsg_result = 0; - - error = sys_reboot(&bsd_args); - args->sysmsg_result = bsd_args.sysmsg_result; - return(error); -} - -/* - * The FreeBSD native getpid(2), getgid(2) and getuid(2) also modify - * p->p_retval[1] when COMPAT_43 is defined. This - * globbers registers that are assumed to be preserved. The following - * lightweight syscalls fixes this. See also linux_getgid16() and - * linux_getuid16() in linux_uid16.c. - * - * linux_getpid() - MP SAFE - * linux_getgid() - MP SAFE - * linux_getuid() - MP SAFE - */ - -/* - * MPALMOSTSAFE - */ -int -sys_linux_getpid(struct linux_getpid_args *args) -{ - struct linux_emuldata *em; - struct proc *p = curproc; - - - EMUL_LOCK(); - em = emuldata_get(p); - if (em == NULL) /* this should never happen */ - args->sysmsg_result = p->p_pid; - else - args->sysmsg_result = em->s->group_pid; - EMUL_UNLOCK(); - - return (0); -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_getppid(struct linux_getppid_args *args) -{ - struct linux_emuldata *em; - struct proc *parent; - struct proc *p; - pid_t group_pid; - - EMUL_LOCK(); - em = emuldata_get(curproc); - KKASSERT(em != NULL); - group_pid = em->s->group_pid; - EMUL_UNLOCK(); - - p = pfind(group_pid); - /* We are not allowed to fail */ - if (p == NULL) - goto out; - - parent = p->p_pptr; - if (parent->p_sysent == &elf_linux_sysvec) { - EMUL_LOCK(); - em = emuldata_get(parent); - args->sysmsg_result = em->s->group_pid; - EMUL_UNLOCK(); - } else { - args->sysmsg_result = parent->p_pid; - } - PRELE(p); - -out: - return (0); -} - -/* - * MPSAFE - */ -int -sys_linux_getgid(struct linux_getgid_args *args) -{ - struct thread *td = curthread; - - args->sysmsg_result = td->td_ucred->cr_rgid; - return (0); -} - -/* - * MPSAFE - */ -int -sys_linux_getuid(struct linux_getuid_args *args) -{ - struct thread *td = curthread; - - args->sysmsg_result = td->td_ucred->cr_ruid; - return (0); -} - -/* - * MPSAFE - */ -int -sys_linux_getsid(struct linux_getsid_args *args) -{ - struct getsid_args bsd; - int error; - - bsd.sysmsg_result = 0; - bsd.pid = args->pid; - error = sys_getsid(&bsd); - args->sysmsg_result = bsd.sysmsg_result; - return(error); -} - -/* - * MPSAFE - */ -int -linux_nosys(struct nosys_args *args) -{ - /* XXX */ - return (ENOSYS); -} - -int -sys_linux_mq_open(struct linux_mq_open_args *args) -{ - struct mq_open_args moa; - int error, oflag; - - oflag = 0; - if (args->oflag & LINUX_O_RDONLY) - oflag |= O_RDONLY; - if (args->oflag & LINUX_O_WRONLY) - oflag |= O_WRONLY; - if (args->oflag & LINUX_O_RDWR) - oflag |= O_RDWR; - - if (args->oflag & LINUX_O_NONBLOCK) - oflag |= O_NONBLOCK; - if (args->oflag & LINUX_O_CREAT) - oflag |= O_CREAT; - if (args->oflag & LINUX_O_EXCL) - oflag |= O_EXCL; - - moa.name = args->name; - moa.oflag = oflag; - moa.mode = args->mode; - moa.attr = args->attr; - - error = sys_mq_open(&moa); - - return (error); -} - -int -sys_linux_mq_getsetattr(struct linux_mq_getsetattr_args *args) -{ - struct mq_getattr_args gaa; - struct mq_setattr_args saa; - int error; - - gaa.mqdes = args->mqd; - gaa.mqstat = args->oattr; - - saa.mqdes = args->mqd; - saa.mqstat = args->attr; - saa.mqstat = args->oattr; - - if (args->attr != NULL) { - error = sys_mq_setattr(&saa); - } else { - error = sys_mq_getattr(&gaa); - } - - return error; -} - -/* - * Get affinity of a process. - */ -int -sys_linux_sched_getaffinity(struct linux_sched_getaffinity_args *args) -{ - cpumask_t mask; - struct proc *p; - struct lwp *lp; - int error = 0; - -#ifdef DEBUG - if (ldebug(sched_getaffinity)) - kprintf(ARGS(sched_getaffinity, "%d, %d, *"), args->pid, - args->len); -#endif - if (args->len < sizeof(cpumask_t)) - return (EINVAL); -#if 0 - if ((error = priv_check(curthread, PRIV_SCHED_CPUSET)) != 0) - return (EPERM); -#endif - /* Get the mplock to ensure that the proc is not running */ - get_mplock(); - if (args->pid == 0) { - p = curproc; - PHOLD(p); - } else { - p = pfind(args->pid); - if (p == NULL) { - error = ESRCH; - goto done; - } - } - - lp = FIRST_LWP_IN_PROC(p); - /* - * XXX: if lwp_cpumask is ever changed to support more than - * 32 processors, this needs to be changed to a bcopy. - */ - mask = lp->lwp_cpumask; - if ((error = copyout(&mask, args->user_mask_ptr, sizeof(cpumask_t)))) - error = EFAULT; -done: - rel_mplock(); -#if 0 - if (error == 0) - args->sysmsg_iresult = sizeof(cpumask_t); -#endif - if (p) - PRELE(p); - return (error); -} - -/* - * Set affinity of a process. - */ -int -sys_linux_sched_setaffinity(struct linux_sched_setaffinity_args *args) -{ -#ifdef DEBUG - if (ldebug(sched_setaffinity)) - kprintf(ARGS(sched_setaffinity, "%d, %d, *"), args->pid, - args->len); -#endif - /* - * From Linux man page: - * sched_setaffinity() sets the CPU affinity mask of the process - * whose ID is pid to the value specified by mask. If pid is zero, - * then the calling process is used. The argument cpusetsize is - * the length (in bytes) of the data pointed to by mask. Normally - * this argument would be specified as sizeof(cpu_set_t). - * - * If the process specified by pid is not currently running on one - * of the CPUs specified in mask, then that process is migrated to - * one of the CPUs specified in mask. - */ - /* - * About our implementation: I don't think that it is too important - * to have a working implementation, but if it was ever needed, - * the best approach would be to implement the whole mechanism - * properly in kern_usched. - * The idea has to be to change the affinity mask AND migrate the - * lwp to one of the new valid CPUs for the lwp, in case the current - * CPU isn't anymore in the affinity mask passed in. - * For now, we'll just signal success even if we didn't do anything. - */ - return 0; -} - -int -sys_linux_gettid(struct linux_gettid_args *args) -{ - args->sysmsg_iresult = curproc->p_pid; - return 0; -} - -int -sys_linux_getcpu(struct linux_getcpu_args *args) -{ - struct globaldata *gd; - l_uint node = 0; - int error; - - gd = mycpu; - error = copyout(&gd->gd_cpuid, args->pcpu, sizeof(gd->gd_cpuid)); - if (error) - return (error); - /* - * XXX: this should be the NUMA node, but since we don't implement it, - * just return 0 for it. - */ - error = copyout(&node, args->pnode, sizeof(node)); - return (error); -} - -int -sys_linux_sethostname(struct linux_sethostname_args *uap) -{ - struct thread *td = curthread; - size_t len; - char *hostname; - int name[2]; - int error; - - name[0] = CTL_KERN; - name[1] = KERN_HOSTNAME; - error = priv_check_cred(td->td_ucred, PRIV_SETHOSTNAME, 0); - if (error) - return (error); - len = MIN(uap->len, MAXHOSTNAMELEN); - hostname = kmalloc(MAXHOSTNAMELEN, M_TEMP, M_WAITOK); - - error = copyin(uap->hostname, hostname, len); - if (error) { - kfree(hostname, M_TEMP); - return (error); - } - - get_mplock(); - error = kernel_sysctl(name, 2, NULL, 0, hostname, len, NULL); - rel_mplock(); - - kfree(hostname, M_TEMP); - return (error); -} diff --git a/sys/emulation/linux/linux_signal.c b/sys/emulation/linux/linux_signal.c deleted file mode 100644 index 8c4c83c74c..0000000000 --- a/sys/emulation/linux/linux_signal.c +++ /dev/null @@ -1,468 +0,0 @@ -/*- - * Copyright (c) 1994-1995 Søren Schmidt - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer - * in this position and unchanged. - * 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 - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD: src/sys/compat/linux/linux_signal.c,v 1.23.2.3 2001/11/05 19:08:23 marcel Exp $ - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include "linux_emuldata.h" -#include "linux_signal.h" -#include "linux_util.h" - -void -linux_to_bsd_sigset(l_sigset_t *lss, sigset_t *bss) -{ - int b, l; - - SIGEMPTYSET(*bss); - bss->__bits[0] = lss->__bits[0] & ~((1U << LINUX_SIGTBLSZ) - 1); - bss->__bits[1] = lss->__bits[1]; - for (l = 1; l <= LINUX_SIGTBLSZ; l++) { - if (LINUX_SIGISMEMBER(*lss, l)) { - b = linux_to_bsd_signal[_SIG_IDX(l)]; - if (b) - SIGADDSET(*bss, b); - } - } -} - -void -bsd_to_linux_sigset(sigset_t *bss, l_sigset_t *lss) -{ - int b, l; - - LINUX_SIGEMPTYSET(*lss); - lss->__bits[0] = bss->__bits[0] & ~((1U << LINUX_SIGTBLSZ) - 1); - lss->__bits[1] = bss->__bits[1]; - for (b = 1; b <= LINUX_SIGTBLSZ; b++) { - if (SIGISMEMBER(*bss, b)) { - l = bsd_to_linux_signal[_SIG_IDX(b)]; - if (l) - LINUX_SIGADDSET(*lss, l); - } - } -} - -void -linux_to_bsd_sigaction(l_sigaction_t *lsa, struct sigaction *bsa) -{ - - linux_to_bsd_sigset(&lsa->lsa_mask, &bsa->sa_mask); - bsa->sa_handler = lsa->lsa_handler; - bsa->sa_flags = 0; - if (lsa->lsa_flags & LINUX_SA_NOCLDSTOP) - bsa->sa_flags |= SA_NOCLDSTOP; - if (lsa->lsa_flags & LINUX_SA_NOCLDWAIT) - bsa->sa_flags |= SA_NOCLDWAIT; - if (lsa->lsa_flags & LINUX_SA_SIGINFO) - bsa->sa_flags |= SA_SIGINFO; - if (lsa->lsa_flags & LINUX_SA_ONSTACK) - bsa->sa_flags |= SA_ONSTACK; - if (lsa->lsa_flags & LINUX_SA_RESTART) - bsa->sa_flags |= SA_RESTART; - if (lsa->lsa_flags & LINUX_SA_ONESHOT) - bsa->sa_flags |= SA_RESETHAND; - if (lsa->lsa_flags & LINUX_SA_NOMASK) - bsa->sa_flags |= SA_NODEFER; -} - -void -bsd_to_linux_sigaction(struct sigaction *bsa, l_sigaction_t *lsa) -{ - - bsd_to_linux_sigset(&bsa->sa_mask, &lsa->lsa_mask); - lsa->lsa_handler = bsa->sa_handler; - lsa->lsa_restorer = NULL; /* unsupported */ - lsa->lsa_flags = 0; - if (bsa->sa_flags & SA_NOCLDSTOP) - lsa->lsa_flags |= LINUX_SA_NOCLDSTOP; - if (bsa->sa_flags & SA_NOCLDWAIT) - lsa->lsa_flags |= LINUX_SA_NOCLDWAIT; - if (bsa->sa_flags & SA_SIGINFO) - lsa->lsa_flags |= LINUX_SA_SIGINFO; - if (bsa->sa_flags & SA_ONSTACK) - lsa->lsa_flags |= LINUX_SA_ONSTACK; - if (bsa->sa_flags & SA_RESTART) - lsa->lsa_flags |= LINUX_SA_RESTART; - if (bsa->sa_flags & SA_RESETHAND) - lsa->lsa_flags |= LINUX_SA_ONESHOT; - if (bsa->sa_flags & SA_NODEFER) - lsa->lsa_flags |= LINUX_SA_NOMASK; -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_signal(struct linux_signal_args *args) -{ - l_sigaction_t linux_nsa, linux_osa; - struct sigaction nsa, osa; - int error, sig; - -#ifdef DEBUG - if (ldebug(signal)) - kprintf(ARGS(signal, "%d, %p"), - args->sig, (void *)args->handler); -#endif - linux_nsa.lsa_handler = args->handler; - linux_nsa.lsa_flags = LINUX_SA_ONESHOT | LINUX_SA_NOMASK; - LINUX_SIGEMPTYSET(linux_nsa.lsa_mask); - linux_to_bsd_sigaction(&linux_nsa, &nsa); - if (args->sig <= LINUX_SIGTBLSZ) { - sig = linux_to_bsd_signal[_SIG_IDX(args->sig)]; - } else { - sig = args->sig; - } - - error = kern_sigaction(sig, &nsa, &osa); - - bsd_to_linux_sigaction(&osa, &linux_osa); - args->sysmsg_result = (int) linux_osa.lsa_handler; - return (error); -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_rt_sigaction(struct linux_rt_sigaction_args *args) -{ - l_sigaction_t linux_nsa, linux_osa; - struct sigaction nsa, osa; - int error, sig; - -#ifdef DEBUG - if (ldebug(rt_sigaction)) - kprintf(ARGS(rt_sigaction, "%ld, %p, %p, %ld"), - (long)args->sig, (void *)args->act, - (void *)args->oact, (long)args->sigsetsize); -#endif - if (args->sigsetsize != sizeof(l_sigset_t)) - return (EINVAL); - - if (args->act) { - error = copyin(args->act, &linux_nsa, sizeof(linux_nsa)); - if (error) - return (error); - linux_to_bsd_sigaction(&linux_nsa, &nsa); - } - if (args->sig <= LINUX_SIGTBLSZ) { - sig = linux_to_bsd_signal[_SIG_IDX(args->sig)]; - } else { - sig = args->sig; - } - - error = kern_sigaction(sig, args->act ? &nsa : NULL, - args->oact ? &osa : NULL); - - if (error == 0 && args->oact) { - bsd_to_linux_sigaction(&osa, &linux_osa); - error = copyout(&linux_osa, args->oact, sizeof(linux_osa)); - } - - return (error); -} - -static int -linux_to_bsd_sigprocmask(int how) -{ - switch (how) { - case LINUX_SIG_BLOCK: - return SIG_BLOCK; - case LINUX_SIG_UNBLOCK: - return SIG_UNBLOCK; - case LINUX_SIG_SETMASK: - return SIG_SETMASK; - default: - return (-1); - } -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_sigprocmask(struct linux_sigprocmask_args *args) -{ - l_osigset_t mask; - l_sigset_t linux_set, linux_oset; - sigset_t set, oset; - int error, how; - -#ifdef DEBUG - if (ldebug(sigprocmask)) - kprintf(ARGS(sigprocmask, "%d, *, *"), args->how); -#endif - - if (args->mask) { - error = copyin(args->mask, &mask, sizeof(l_osigset_t)); - if (error) - return (error); - LINUX_SIGEMPTYSET(linux_set); - linux_set.__bits[0] = mask; - linux_to_bsd_sigset(&linux_set, &set); - } - how = linux_to_bsd_sigprocmask(args->how); - - error = kern_sigprocmask(how, args->mask ? &set : NULL, - args->omask ? &oset : NULL); - - if (error == 0 && args->omask) { - bsd_to_linux_sigset(&oset, &linux_oset); - mask = linux_oset.__bits[0]; - error = copyout(&mask, args->omask, sizeof(l_osigset_t)); - } - return (error); -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_rt_sigprocmask(struct linux_rt_sigprocmask_args *args) -{ - l_sigset_t linux_set, linux_oset; - sigset_t set, oset; - int error, how; - -#ifdef DEBUG - if (ldebug(rt_sigprocmask)) - kprintf(ARGS(rt_sigprocmask, "%d, %p, %p, %ld"), - args->how, (void *)args->mask, - (void *)args->omask, (long)args->sigsetsize); -#endif - - if (args->sigsetsize != sizeof(l_sigset_t)) - return EINVAL; - - if (args->mask) { - error = copyin(args->mask, &linux_set, sizeof(l_sigset_t)); - if (error) - return (error); - linux_to_bsd_sigset(&linux_set, &set); - } - how = linux_to_bsd_sigprocmask(args->how); - - error = kern_sigprocmask(how, args->mask ? &set : NULL, - args->omask ? &oset : NULL); - - if (error == 0 && args->omask) { - bsd_to_linux_sigset(&oset, &linux_oset); - error = copyout(&linux_oset, args->omask, sizeof(l_sigset_t)); - } - - return (error); -} - -/* - * MPSAFE - */ -int -sys_linux_sgetmask(struct linux_sgetmask_args *args) -{ - struct lwp *lp = curthread->td_lwp; - l_sigset_t mask; - -#ifdef DEBUG - if (ldebug(sgetmask)) - kprintf(ARGS(sgetmask, "")); -#endif - - bsd_to_linux_sigset(&lp->lwp_sigmask, &mask); - args->sysmsg_result = mask.__bits[0]; - return (0); -} - -/* - * MPSAFE - */ -int -sys_linux_ssetmask(struct linux_ssetmask_args *args) -{ - struct lwp *lp = curthread->td_lwp; - l_sigset_t lset; - sigset_t bset; - -#ifdef DEBUG - if (ldebug(ssetmask)) - kprintf(ARGS(ssetmask, "%08lx"), (unsigned long)args->mask); -#endif - - bsd_to_linux_sigset(&lp->lwp_sigmask, &lset); - args->sysmsg_result = lset.__bits[0]; - LINUX_SIGEMPTYSET(lset); - lset.__bits[0] = args->mask; - linux_to_bsd_sigset(&lset, &bset); - crit_enter(); - lp->lwp_sigmask = bset; - SIG_CANTMASK(lp->lwp_sigmask); - crit_exit(); - return (0); -} - -/* - * MPSAFE - */ -int -sys_linux_sigpending(struct linux_sigpending_args *args) -{ - struct thread *td = curthread; - struct lwp *lp = td->td_lwp; - sigset_t set; - l_sigset_t linux_set; - l_osigset_t mask; - int error; - -#ifdef DEBUG - if (ldebug(sigpending)) - kprintf(ARGS(sigpending, "*")); -#endif - - error = kern_sigpending(&set); - - if (error == 0) { - SIGSETAND(set, lp->lwp_sigmask); - bsd_to_linux_sigset(&set, &linux_set); - mask = linux_set.__bits[0]; - error = copyout(&mask, args->mask, sizeof(mask)); - } - return (error); -} - -int -sys_linux_kill(struct linux_kill_args *args) -{ - int error, sig; - -#ifdef DEBUG - if (ldebug(kill)) - kprintf(ARGS(kill, "%d, %d"), args->pid, args->signum); -#endif - /* - * Allow signal 0 as a means to check for privileges - */ - if (args->signum < 0 || args->signum > LINUX_NSIG) - return EINVAL; - - if (args->signum > 0 && args->signum <= LINUX_SIGTBLSZ) - sig = linux_to_bsd_signal[_SIG_IDX(args->signum)]; - else - sig = args->signum; - - error = kern_kill(sig, args->pid, -1); - - return(error); -} - - -static int -linux_do_tkill(l_int tgid, l_int pid, l_int sig) -{ - struct linux_emuldata *em; - struct proc *p; - int error = 0; - - /* - * Allow signal 0 as a means to check for privileges - */ - if (sig < 0 || sig > LINUX_NSIG) - return (EINVAL); - - if (sig > 0 && sig <= LINUX_SIGTBLSZ) - sig = linux_to_bsd_signal[_SIG_IDX(sig)]; - - if ((p = pfind(pid)) == NULL) { - if ((p = zpfind(pid)) == NULL) { - error = ESRCH; - goto done2; - } - } - - EMUL_LOCK(); - em = emuldata_get(p); - - if (em == NULL) { - EMUL_UNLOCK(); - error = ESRCH; - goto done1; - } - - if (tgid > 0 && em->s->group_pid != tgid) { - EMUL_UNLOCK(); - error = ESRCH; - goto done1; - } - EMUL_UNLOCK(); - - error = kern_kill(sig, pid, -1); - -done1: - PRELE(p); -done2: - return (error); -} - -int -sys_linux_tgkill(struct linux_tgkill_args *args) -{ - -#ifdef DEBUG - if (ldebug(tgkill)) - kprintf(ARGS(tgkill, "%d, %d, %d"), args->tgid, args->pid, args->sig); -#endif - if (args->pid <= 0 || args->tgid <= 0) - return (EINVAL); - - return (linux_do_tkill(args->tgid, args->pid, args->sig)); -} - -int -sys_linux_tkill(struct linux_tkill_args *args) -{ -#ifdef DEBUG - if (ldebug(tkill)) - kprintf(ARGS(tkill, "%i, %i"), args->tid, args->sig); -#endif - if (args->tid <= 0) - return (EINVAL); - - return (linux_do_tkill(0, args->tid, args->sig)); -} - diff --git a/sys/emulation/linux/linux_signal.h b/sys/emulation/linux/linux_signal.h deleted file mode 100644 index f850c9c6e9..0000000000 --- a/sys/emulation/linux/linux_signal.h +++ /dev/null @@ -1,40 +0,0 @@ -/*- - * Copyright (c) 2000 Marcel Moolenaar - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer - * in this position and unchanged. - * 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 - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD: src/sys/compat/linux/linux_signal.h,v 1.2.2.3 2001/11/05 19:08:23 marcel Exp $ - * $DragonFly: src/sys/emulation/linux/linux_signal.h,v 1.6 2003/10/24 14:10:45 daver Exp $ - */ - -#ifndef _LINUX_SIGNAL_H_ -#define _LINUX_SIGNAL_H_ - -void linux_to_bsd_sigset (l_sigset_t *, sigset_t *); -void bsd_to_linux_sigset (sigset_t *, l_sigset_t *); -void linux_to_bsd_sigaction(l_sigaction_t *, struct sigaction *); -void bsd_to_linux_sigaction(struct sigaction *, l_sigaction_t *); - -#endif /* _LINUX_SIGNAL_H_ */ diff --git a/sys/emulation/linux/linux_socket.c b/sys/emulation/linux/linux_socket.c deleted file mode 100644 index 8f699e38d4..0000000000 --- a/sys/emulation/linux/linux_socket.c +++ /dev/null @@ -1,1364 +0,0 @@ -/*- - * Copyright (c) 1995 Søren Schmidt - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer - * in this position and unchanged. - * 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 - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD: src/sys/compat/linux/linux_socket.c,v 1.19.2.8 2001/11/07 20:33:55 marcel Exp $ - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include "linux_socket.h" -#include "linux_util.h" - -/* - * Copyin a sockaddr structure provided by a Linux binary. Linux uses - * the 4.3BSD sockaddr structure which has no sa_len field. We must - * pass 4.4BSD sockaddr structures when we call native functions in the - * BSD kernel. This function does the conversion for us. - * - * Also, our socket calls require the sockaddr structure length to agree - * with the address family. Linux does not, so we must force it. - * - * This function should only need to be called from linux_connect() - * and linux_bind(). - */ -static int -linux_getsockaddr(struct sockaddr **namp, struct sockaddr *uaddr, size_t len) -{ - struct sockaddr *sa; - uint16_t family; /* XXX: must match Linux sockaddr */ - int error; - int sa_len; - - *namp = NULL; - - if (len > SOCK_MAXADDRLEN) - return ENAMETOOLONG; - error = copyin(uaddr, &family, sizeof(family)); - if (error) - return (error); - - /* - * Force the sa_len field to match the address family. - */ - switch (family) { - case AF_INET: - sa_len = sizeof(struct sockaddr_in); - break; - case AF_INET6: - sa_len = sizeof(struct sockaddr_in6); - break; - default: - /* - * This is the default behavior of the old - * linux_to_bsd_namelen() function. NOTE! The - * minimum length we allocate must cover sa->sa_len and - * sa->sa_family. - */ - sa_len = offsetof(struct sockaddr, sa_data[0]); - if (sa_len < len) - sa_len = len; - break; - } - - sa = kmalloc(sa_len, M_SONAME, M_WAITOK); - error = copyin(uaddr, sa, sa_len); - if (error) { - kfree(sa, M_SONAME); - } else { - /* - * Convert to the 4.4BSD sockaddr structure. - */ - sa->sa_family = *(sa_family_t *)sa; - sa->sa_len = sa_len; - *namp = sa; - } - - return (error); -} - -/* - * Transform a 4.4BSD sockaddr structure into a Linux sockaddr structure - * and copy it out to a user address. - */ -static int -linux_copyout_sockaddr(struct sockaddr *sa, struct sockaddr *uaddr, int sa_len) -{ - int error; - - if (sa_len < (int)sizeof(u_short)) - return (EINVAL); - - *(u_short *)sa = sa->sa_family; - error = copyout(sa, uaddr, sa_len); - - return (error); -} - -static int -linux_to_bsd_domain(int domain) -{ - - switch (domain) { - case LINUX_AF_UNSPEC: - return (AF_UNSPEC); - case LINUX_AF_UNIX: - return (AF_LOCAL); - case LINUX_AF_INET: - return (AF_INET); - case LINUX_AF_AX25: - return (AF_CCITT); - case LINUX_AF_IPX: - return (AF_IPX); - } - return (-1); -} - -static int -linux_to_bsd_sockopt_level(int level) -{ - - switch (level) { - case LINUX_SOL_SOCKET: - return (SOL_SOCKET); - } - return (level); -} - -static int -linux_to_bsd_ip_sockopt(int opt) -{ - - switch (opt) { - case LINUX_IP_TOS: - return (IP_TOS); - case LINUX_IP_TTL: - return (IP_TTL); - case LINUX_IP_OPTIONS: - return (IP_OPTIONS); - case LINUX_IP_MULTICAST_IF: - return (IP_MULTICAST_IF); - case LINUX_IP_MULTICAST_TTL: - return (IP_MULTICAST_TTL); - case LINUX_IP_MULTICAST_LOOP: - return (IP_MULTICAST_LOOP); - case LINUX_IP_ADD_MEMBERSHIP: - return (IP_ADD_MEMBERSHIP); - case LINUX_IP_DROP_MEMBERSHIP: - return (IP_DROP_MEMBERSHIP); - case LINUX_IP_HDRINCL: - return (IP_HDRINCL); - } - return (-1); -} - -static int -linux_to_bsd_so_sockopt(int opt) -{ - - switch (opt) { - case LINUX_SO_DEBUG: - return (SO_DEBUG); - case LINUX_SO_REUSEADDR: - return (SO_REUSEADDR); - case LINUX_SO_TYPE: - return (SO_TYPE); - case LINUX_SO_ERROR: - return (SO_ERROR); - case LINUX_SO_DONTROUTE: - return (SO_DONTROUTE); - case LINUX_SO_BROADCAST: - return (SO_BROADCAST); - case LINUX_SO_SNDBUF: - return (SO_SNDBUF); - case LINUX_SO_RCVBUF: - return (SO_RCVBUF); - case LINUX_SO_KEEPALIVE: - return (SO_KEEPALIVE); - case LINUX_SO_OOBINLINE: - return (SO_OOBINLINE); - case LINUX_SO_LINGER: - return (SO_LINGER); - case LINUX_SO_PEERCRED: - return (LOCAL_PEERCRED); - } - return (-1); -} - -static int -linux_to_bsd_msg_flags(int flags) -{ - int ret_flags = 0; - - if (flags & LINUX_MSG_OOB) - ret_flags |= MSG_OOB; - if (flags & LINUX_MSG_PEEK) - ret_flags |= MSG_PEEK; - if (flags & LINUX_MSG_DONTROUTE) - ret_flags |= MSG_DONTROUTE; - if (flags & LINUX_MSG_CTRUNC) - ret_flags |= MSG_CTRUNC; - if (flags & LINUX_MSG_TRUNC) - ret_flags |= MSG_TRUNC; - if (flags & LINUX_MSG_DONTWAIT) - ret_flags |= MSG_DONTWAIT; - if (flags & LINUX_MSG_EOR) - ret_flags |= MSG_EOR; - if (flags & LINUX_MSG_WAITALL) - ret_flags |= MSG_WAITALL; -#if 0 /* not handled */ - if (flags & LINUX_MSG_PROXY) - ; - if (flags & LINUX_MSG_FIN) - ; - if (flags & LINUX_MSG_SYN) - ; - if (flags & LINUX_MSG_CONFIRM) - ; - if (flags & LINUX_MSG_RST) - ; - if (flags & LINUX_MSG_ERRQUEUE) - ; - if (flags & LINUX_MSG_NOSIGNAL) - ; -#endif - return ret_flags; -} - -struct linux_socket_args { - int domain; - int type; - int protocol; -}; - -static int -linux_socket(struct linux_socket_args *args, int *res) -{ - struct linux_socket_args linux_args; - struct sockopt sopt; - int error, domain, optval; - - error = copyin(args, &linux_args, sizeof(linux_args)); - if (error) - return (error); - - domain = linux_to_bsd_domain(linux_args.domain); - if (domain == -1) - return (EINVAL); - - error = kern_socket(domain, linux_args.type, linux_args.protocol, res); - - /* Copy back the return value from socket() */ - if (error == 0 && linux_args.type == SOCK_RAW && - (linux_args.protocol == IPPROTO_RAW || linux_args.protocol == 0) && - linux_args.domain == AF_INET) { - /* It's a raw IP socket: set the IP_HDRINCL option. */ - optval = 1; - sopt.sopt_dir = SOPT_SET; - sopt.sopt_level = IPPROTO_IP; - sopt.sopt_name = IP_HDRINCL; - sopt.sopt_val = &optval; - sopt.sopt_valsize = sizeof(optval); - sopt.sopt_td = NULL; - - /* We ignore any error returned by setsockopt() */ - kern_setsockopt(*res, &sopt); - } - - return (error); -} - -struct linux_bind_args { - int s; - struct sockaddr *name; - int namelen; -}; - -static int -linux_bind(struct linux_bind_args *args, int *res) -{ - struct linux_bind_args linux_args; - struct sockaddr *sa; - int error; - - error = copyin(args, &linux_args, sizeof(linux_args)); - if (error) - return (error); - error = linux_getsockaddr(&sa, linux_args.name, linux_args.namelen); - if (error) - return (error); - - error = kern_bind(linux_args.s, sa); - kfree(sa, M_SONAME); - - return (error); -} - -struct linux_connect_args { - int s; - struct sockaddr * name; - int namelen; -}; - -static int -linux_connect(struct linux_connect_args *args, int *res) -{ - struct thread *td = curthread; /* XXX */ - struct proc *p = td->td_proc; - struct linux_connect_args linux_args; - struct sockaddr *sa; - struct socket *so; - struct file *fp; - int error; - - KKASSERT(p); - - error = copyin(args, &linux_args, sizeof(linux_args)); - if (error) - return (error); - error = linux_getsockaddr(&sa, linux_args.name, linux_args.namelen); - if (error) - return (error); - - error = kern_connect(linux_args.s, 0, sa); - kfree(sa, M_SONAME); - - if (error != EISCONN) - return (error); - - /* - * Linux doesn't return EISCONN the first time it occurs, - * when on a non-blocking socket. Instead it returns the - * error getsockopt(SOL_SOCKET, SO_ERROR) would return on BSD. - */ - error = holdsock(p->p_fd, linux_args.s, &fp); - if (error) - return (error); - error = EISCONN; - if (fp->f_flag & FNONBLOCK) { - so = (struct socket *)fp->f_data; - if (so->so_emuldata == 0) - error = so->so_error; - so->so_emuldata = (void *)1; - } - fdrop(fp); - return (error); -} - -struct linux_listen_args { - int s; - int backlog; -}; - -static int -linux_listen(struct linux_listen_args *args, int *res) -{ - struct linux_listen_args linux_args; - int error; - - error = copyin(args, &linux_args, sizeof(linux_args)); - if (error) - return (error); - - error = kern_listen(linux_args.s, linux_args.backlog); - - return(error); -} - -struct linux_accept_args { - int s; - struct sockaddr *addr; - int *namelen; -}; - -static int -linux_accept(struct linux_accept_args *args, int *res) -{ - struct thread *td = curthread; - struct linux_accept_args linux_args; - struct sockaddr *sa = NULL; - union fcntl_dat dat = { 0 }; - int error, sa_len; - - error = copyin(args, &linux_args, sizeof(linux_args)); - if (error) - return (error); - - if (linux_args.addr) { - error = copyin(linux_args.namelen, &sa_len, sizeof(sa_len)); - if (error) - return (error); - - error = kern_accept(linux_args.s, 0, &sa, &sa_len, res, - SOCK_KERN_NOINHERIT); - - if (error) { - /* - * Return a namelen of zero for older code which - * might ignore the return value from accept(). - */ - sa_len = 0; - copyout(&sa_len, linux_args.namelen, - sizeof(*linux_args.namelen)); - } else { - error = linux_copyout_sockaddr(sa, linux_args.addr, - sa_len); - if (error == 0) { - error = copyout(&sa_len, linux_args.namelen, - sizeof(*linux_args.namelen)); - } - } - if (sa) - kfree(sa, M_SONAME); - } else { - error = kern_accept(linux_args.s, 0, NULL, 0, res); - } - - if (error) - return (error); - - /* - * linux appears not to copy flags from the parent socket to the - * accepted one, so we must clear the flags in the new descriptor. - * Ignore any errors, because we already have an open fd. - */ - kern_fcntl(*res, F_SETFL, &dat, td->td_ucred); - return (0); -} - -struct linux_getsockname_args { - int s; - struct sockaddr *addr; - int *namelen; -}; - -static int -linux_getsockname(struct linux_getsockname_args *args, int *res) -{ - struct linux_getsockname_args linux_args; - struct sockaddr *sa = NULL; - int error, sa_len; - - - error = copyin(args, &linux_args, sizeof(linux_args)); - if (error) - return (error); - error = copyin(linux_args.namelen, &sa_len, sizeof(sa_len)); - if (error) - return (error); - - error = kern_getsockname(linux_args.s, &sa, &sa_len); - - if (error == 0) - error = linux_copyout_sockaddr(sa, linux_args.addr, sa_len); - if (error == 0) - error = copyout(&sa_len, linux_args.namelen, - sizeof(*linux_args.namelen)); - if (sa) - kfree(sa, M_SONAME); - return(error); -} - -struct linux_getpeername_args { - int s; - struct sockaddr *addr; - int *namelen; -}; - -static int -linux_getpeername(struct linux_getpeername_args *args, int *res) -{ - struct linux_getpeername_args linux_args; - struct sockaddr *sa = NULL; - int error, sa_len; - - error = copyin(args, &linux_args, sizeof(linux_args)); - if (error) - return (error); - error = copyin(linux_args.namelen, &sa_len, sizeof(sa_len)); - if (error) - return (error); - - error = kern_getpeername(linux_args.s, &sa, &sa_len); - - if (error == 0) - error = linux_copyout_sockaddr(sa, linux_args.addr, sa_len); - if (error == 0) - error = copyout(&sa_len, linux_args.namelen, - sizeof(*linux_args.namelen)); - if (sa) - kfree(sa, M_SONAME); - return(error); -} - -struct linux_socketpair_args { - int domain; - int type; - int protocol; - int *rsv; -}; - -static int -linux_socketpair(struct linux_socketpair_args *args, int *res) -{ - struct linux_socketpair_args linux_args; - int error, domain, sockv[2]; - - error = copyin(args, &linux_args, sizeof(linux_args)); - if (error) - return (error); - - domain = linux_to_bsd_domain(linux_args.domain); - if (domain == -1) - return (EINVAL); - error = kern_socketpair(domain, linux_args.type, linux_args.protocol, - sockv); - - if (error == 0) - error = copyout(sockv, linux_args.rsv, sizeof(sockv)); - return(error); -} - -struct linux_send_args { - int s; - void *msg; - int len; - int flags; -}; - -static int -linux_send(struct linux_send_args *args, size_t *res) -{ - struct linux_send_args linux_args; - struct thread *td = curthread; - struct uio auio; - struct iovec aiov; - int error; - - error = copyin(args, &linux_args, sizeof(linux_args)); - if (error) - return (error); - - aiov.iov_base = linux_args.msg; - aiov.iov_len = linux_args.len; - auio.uio_iov = &aiov; - auio.uio_iovcnt = 1; - auio.uio_offset = 0; - auio.uio_resid = linux_args.len; - auio.uio_segflg = UIO_USERSPACE; - auio.uio_rw = UIO_WRITE; - auio.uio_td = td; - - error = kern_sendmsg(linux_args.s, NULL, &auio, NULL, - linux_args.flags, res); - - return(error); -} - -struct linux_recv_args { - int s; - void *msg; - int len; - int flags; -}; - -static int -linux_recv(struct linux_recv_args *args, size_t *res) -{ - struct linux_recv_args linux_args; - struct thread *td = curthread; - struct uio auio; - struct iovec aiov; - int error; - - error = copyin(args, &linux_args, sizeof(linux_args)); - if (error) - return (error); - - aiov.iov_base = linux_args.msg; - aiov.iov_len = linux_args.len; - auio.uio_iov = &aiov; - auio.uio_iovcnt = 1; - auio.uio_offset = 0; - auio.uio_resid = linux_args.len; - auio.uio_segflg = UIO_USERSPACE; - auio.uio_rw = UIO_READ; - auio.uio_td = td; - - error = kern_recvmsg(linux_args.s, NULL, &auio, NULL, - &linux_args.flags, res); - - return(error); -} - -struct linux_sendto_args { - int s; - void *msg; - int len; - int flags; - struct sockaddr *to; - int tolen; -}; - -static int -linux_sendto(struct linux_sendto_args *args, size_t *res) -{ - struct linux_sendto_args linux_args; - struct thread *td = curthread; - struct uio auio; - struct iovec aiov; - struct sockopt sopt; - struct sockaddr *sa = NULL; - caddr_t msg = NULL; - int error, optval; - - error = copyin(args, &linux_args, sizeof(linux_args)); - if (error) - return (error); - - if (linux_args.to) { - error = linux_getsockaddr(&sa, linux_args.to, - linux_args.tolen); - if (error) - return (error); - } - - /* - * Check to see if the IP_HDRINCL option is set. - */ - sopt.sopt_dir = SOPT_GET; - sopt.sopt_level = IPPROTO_IP; - sopt.sopt_name = IP_HDRINCL; - sopt.sopt_val = &optval; - sopt.sopt_valsize = sizeof(optval); - sopt.sopt_td = NULL; - - if (kern_getsockopt(linux_args.s, &sopt) != 0) - optval = 0; - - if (optval == 0) { - /* - * IP_HDRINCL is not set. Package the message as usual. - */ - aiov.iov_base = linux_args.msg; - aiov.iov_len = linux_args.len; - auio.uio_iov = &aiov; - auio.uio_iovcnt = 1; - auio.uio_offset = 0; - auio.uio_resid = linux_args.len; - auio.uio_segflg = UIO_USERSPACE; - auio.uio_rw = UIO_WRITE; - auio.uio_td = td; - } else { - /* - * IP_HDRINCL is set. We must convert the beginning of - * the packet header so we can feed it to the BSD kernel. - */ - - /* - * Check that the packet header is long enough to contain - * the fields of interest. This relies on the fact that - * the fragment offset field comes after the length field. - */ - if (linux_args.len < offsetof(struct ip, ip_off)) - return (EINVAL); - - msg = kmalloc(linux_args.len, M_LINUX, M_WAITOK); - error = copyin(linux_args.msg, msg, linux_args.len); - if (error) - goto cleanup; - - /* Fix the ip_len and ip_off fields. */ - ((struct ip *)msg)->ip_len = linux_args.len; - ((struct ip *)msg)->ip_off = ntohs(((struct ip *)msg)->ip_off); - - aiov.iov_base = msg; - aiov.iov_len = linux_args.len; - auio.uio_iov = &aiov; - auio.uio_iovcnt = 1; - auio.uio_offset = 0; - auio.uio_resid = linux_args.len; - auio.uio_segflg = UIO_SYSSPACE; - auio.uio_rw = UIO_WRITE; - auio.uio_td = td; - } - - error = kern_sendmsg(linux_args.s, sa, &auio, NULL, - linux_args.flags, res); - -cleanup: - if (sa) - kfree(sa, M_SONAME); - if (msg) - kfree(msg, M_LINUX); - return(error); -} - -struct linux_recvfrom_args { - int s; - void *buf; - int len; - int flags; - struct sockaddr *from; - int *fromlen; -}; - -static int -linux_recvfrom(struct linux_recvfrom_args *args, size_t *res) -{ - struct linux_recvfrom_args linux_args; - struct thread *td = curthread; - struct uio auio; - struct iovec aiov; - struct sockaddr *sa = NULL; - int error, fromlen, flags; - - error = copyin(args, &linux_args, sizeof(linux_args)); - if (error) - return (error); - - if (linux_args.from && linux_args.fromlen) { - error = copyin(linux_args.fromlen, &fromlen, sizeof(fromlen)); - if (error) - return (error); - if (fromlen < 0) - return (EINVAL); - } else { - fromlen = 0; - } - aiov.iov_base = linux_args.buf; - aiov.iov_len = linux_args.len; - auio.uio_iov = &aiov; - auio.uio_iovcnt = 1; - auio.uio_offset = 0; - auio.uio_resid = linux_args.len; - auio.uio_segflg = UIO_USERSPACE; - auio.uio_rw = UIO_READ; - auio.uio_td = td; - - flags = linux_to_bsd_msg_flags(linux_args.flags); - - error = kern_recvmsg(linux_args.s, linux_args.from ? &sa : NULL, &auio, - NULL, &flags, res); - - if (error == 0 && linux_args.from) { - if (sa != NULL) { - fromlen = MIN(fromlen, sa->sa_len); - error = linux_copyout_sockaddr(sa, linux_args.from, - fromlen); - } else - fromlen = 0; - if (error == 0) - copyout(&fromlen, linux_args.fromlen, - sizeof(fromlen)); - } - if (sa) - kfree(sa, M_SONAME); - - return(error); -} - -struct linux_sendmsg_args { - int s; - struct msghdr *msg; - int flags; -}; - -static int -linux_sendmsg(struct linux_sendmsg_args *args, size_t *res) -{ - struct linux_sendmsg_args linux_args; - struct thread *td = curthread; - struct msghdr msg; - struct uio auio; - struct iovec aiov[UIO_SMALLIOV], *iov = NULL; - struct sockaddr *sa = NULL; - struct mbuf *control = NULL; - int error; - - error = copyin(args, &linux_args, sizeof(linux_args)); - if (error) - return (error); - - error = copyin(linux_args.msg, &msg, sizeof(msg)); - if (error) - return (error); - - /* - * XXX: I'm not sure atm how this relates to dragonfly, but - * just in case, I put it in. - * Ping on linux does pass 0 in controllen which is forbidden - * by FreeBSD but seems to be ok on Linux. This needs some - * checking but now it lets ping work. - */ - if (msg.msg_control && msg.msg_controllen == 0) - msg.msg_control = NULL; - - /* - * Conditionally copyin msg.msg_name. - */ - if (msg.msg_name) { - error = linux_getsockaddr(&sa, msg.msg_name, msg.msg_namelen); - if (error) - return (error); - } - - /* - * Populate auio. - */ - error = iovec_copyin(msg.msg_iov, &iov, aiov, msg.msg_iovlen, - &auio.uio_resid); - if (error) - goto cleanup2; - auio.uio_iov = iov; - auio.uio_iovcnt = msg.msg_iovlen; - auio.uio_offset = 0; - auio.uio_segflg = UIO_USERSPACE; - auio.uio_rw = UIO_WRITE; - auio.uio_td = td; - - /* - * Conditionally copyin msg.msg_control. - */ - if (msg.msg_control) { - if (msg.msg_controllen < sizeof(struct cmsghdr) || - msg.msg_controllen > MLEN) { - error = EINVAL; - goto cleanup; - } - control = m_get(M_WAITOK, MT_CONTROL); - if (control == NULL) { - error = ENOBUFS; - goto cleanup; - } - control->m_len = msg.msg_controllen; - error = copyin(msg.msg_control, mtod(control, caddr_t), - msg.msg_controllen); - if (error) { - m_free(control); - goto cleanup; - } - /* - * Linux and BSD both support SCM_RIGHTS. If a linux binary - * wants anything else with an option level of SOL_SOCKET, - * we don't support it. - */ - if (mtod(control, struct cmsghdr *)->cmsg_level == - SOL_SOCKET && - mtod(control, struct cmsghdr *)->cmsg_type != - SCM_RIGHTS) { - m_free(control); - error = EINVAL; - goto cleanup; - } - } - - error = kern_sendmsg(linux_args.s, sa, &auio, control, - linux_args.flags, res); - -cleanup: - iovec_free(&iov, aiov); -cleanup2: - if (sa) - kfree(sa, M_SONAME); - return (error); -} - -struct linux_recvmsg_args { - int s; - struct msghdr *msg; - int flags; -}; - -static int -linux_recvmsg(struct linux_recvmsg_args *args, size_t *res) -{ - struct linux_recvmsg_args linux_args; - struct thread *td = curthread; - struct msghdr msg; - struct uio auio; - struct iovec aiov[UIO_SMALLIOV], *iov = NULL; - struct mbuf *m, *control = NULL; - struct sockaddr *sa = NULL; - caddr_t ctlbuf; - socklen_t *ufromlenp, *ucontrollenp; - int error, fromlen, controllen, len, flags, *uflagsp; - - error = copyin(args, &linux_args, sizeof(linux_args)); - if (error) - return (error); - - error = copyin(linux_args.msg, &msg, sizeof(struct msghdr)); - if (error) - return (error); - - if (msg.msg_name && msg.msg_namelen < 0) - return (EINVAL); - if (msg.msg_control && msg.msg_controllen < 0) - return (EINVAL); - - ufromlenp = (socklen_t *)((caddr_t)linux_args.msg + - offsetof(struct msghdr, msg_namelen)); - ucontrollenp = (socklen_t *)((caddr_t)linux_args.msg + - offsetof(struct msghdr, msg_controllen)); - uflagsp = (int *)((caddr_t)linux_args.msg + - offsetof(struct msghdr, msg_flags)); - - /* - * Populate auio. - */ - error = iovec_copyin(msg.msg_iov, &iov, aiov, msg.msg_iovlen, - &auio.uio_resid); - if (error) - return (error); - auio.uio_iov = iov; - auio.uio_iovcnt = msg.msg_iovlen; - auio.uio_offset = 0; - auio.uio_segflg = UIO_USERSPACE; - auio.uio_rw = UIO_READ; - auio.uio_td = td; - - flags = linux_to_bsd_msg_flags(linux_args.flags); - - error = kern_recvmsg(linux_args.s, msg.msg_name ? &sa : NULL, &auio, - msg.msg_control ? &control : NULL, &flags, res); - - /* - * Copyout msg.msg_name and msg.msg_namelen. - */ - if (error == 0 && msg.msg_name) { - if (sa != NULL) { - fromlen = MIN(msg.msg_namelen, sa->sa_len); - error = linux_copyout_sockaddr(sa, msg.msg_name, - fromlen); - } else - fromlen = 0; - if (error == 0) - error = copyout(&fromlen, ufromlenp, - sizeof(*ufromlenp)); - } - - /* - * Copyout msg.msg_control and msg.msg_controllen. - */ - if (error == 0 && msg.msg_control) { - /* - * Linux and BSD both support SCM_RIGHTS. If a linux binary - * wants anything else with an option level of SOL_SOCKET, - * we don't support it. - */ - if (mtod((struct mbuf *)msg.msg_control, - struct cmsghdr *)->cmsg_level == SOL_SOCKET && - mtod((struct mbuf *)msg.msg_control, - struct cmsghdr *)->cmsg_type != SCM_RIGHTS) { - error = EINVAL; - goto cleanup; - } - - len = msg.msg_controllen; - m = control; - ctlbuf = (caddr_t)msg.msg_control; - - while (m && len > 0) { - unsigned int tocopy; - - if (len >= m->m_len) { - tocopy = m->m_len; - } else { - msg.msg_flags |= MSG_CTRUNC; - tocopy = len; - } - - error = copyout(mtod(m, caddr_t), ctlbuf, - tocopy); - if (error) - goto cleanup; - - ctlbuf += tocopy; - len -= tocopy; - m = m->m_next; - } - controllen = ctlbuf - (caddr_t)msg.msg_control; - error = copyout(&controllen, ucontrollenp, - sizeof(*ucontrollenp)); - } - - if (error == 0) - error = copyout(&flags, uflagsp, sizeof(*uflagsp)); - -cleanup: - if (sa) - kfree(sa, M_SONAME); - iovec_free(&iov, aiov); - if (control) - m_freem(control); - return (error); -} - -struct linux_shutdown_args { - int s; - int how; -}; - -static int -linux_shutdown(struct linux_shutdown_args *args, int *res) -{ - struct linux_shutdown_args linux_args; - int error; - - error = copyin(args, &linux_args, sizeof(linux_args)); - if (error) - return (error); - - error = kern_shutdown(linux_args.s, linux_args.how); - - return (error); -} - -struct linux_setsockopt_args { - int s; - int level; - int optname; - void *optval; - int optlen; -}; - -static int -linux_setsockopt(struct linux_setsockopt_args *args, int *res) -{ - struct linux_setsockopt_args linux_args; - struct thread *td = curthread; - struct sockopt sopt; - l_timeval linux_tv; - struct timeval tv; - int error, name, level; - - error = copyin(args, &linux_args, sizeof(linux_args)); - if (error) - return (error); - - level = linux_to_bsd_sockopt_level(linux_args.level); - switch (level) { - case SOL_SOCKET: - name = linux_to_bsd_so_sockopt(linux_args.optname); - switch (name) { - case SO_RCVTIMEO: - /* FALLTHROUGH */ - case SO_SNDTIMEO: - error = copyin(linux_args.optval, &linux_tv, - sizeof(linux_tv)); - if (error) - return (error); - tv.tv_sec = linux_tv.tv_sec; - tv.tv_usec = linux_tv.tv_usec; - sopt.sopt_dir = SOPT_SET; - sopt.sopt_level = level; - sopt.sopt_name = name; - sopt.sopt_valsize = sizeof(tv); - sopt.sopt_val = &tv; - sopt.sopt_td = td; - return (kern_setsockopt(linux_args.s, &sopt)); - /* NOTREACHED */ - break; - default: - break; - } - break; - case IPPROTO_IP: - name = linux_to_bsd_ip_sockopt(linux_args.optname); - break; - case IPPROTO_TCP: - /* Linux TCP option values match BSD's */ - name = linux_args.optname; - break; - default: - name = -1; - break; - } - if (name == -1) - return (ENOPROTOOPT); - - if (linux_args.optlen < 0 || linux_args.optlen > SOMAXOPT_SIZE) - return (EINVAL); - if (linux_args.optval != NULL && linux_args.optlen == 0) - return (EINVAL); - if (linux_args.optval == NULL && linux_args.optlen != 0) - return (EFAULT); - - sopt.sopt_dir = SOPT_SET; - sopt.sopt_level = level; - sopt.sopt_name = name; - sopt.sopt_valsize = linux_args.optlen; - sopt.sopt_td = td; - - if (linux_args.optval) { - sopt.sopt_val = kmalloc(sopt.sopt_valsize, M_TEMP, M_WAITOK); - error = copyin(linux_args.optval, sopt.sopt_val, sopt.sopt_valsize); - if (error) - goto out; - } else { - sopt.sopt_val = NULL; - } - error = kern_setsockopt(linux_args.s, &sopt); - if (error) - goto out; - if (linux_args.optval) - error = copyout(sopt.sopt_val, linux_args.optval, - sopt.sopt_valsize); -out: - if (linux_args.optval) - kfree(sopt.sopt_val, M_TEMP); - return(error); -} - -struct linux_getsockopt_args { - int s; - int level; - int optname; - void *optval; - int *optlen; -}; - -static int -linux_getsockopt(struct linux_getsockopt_args *args, int *res) -{ - struct linux_getsockopt_args linux_args; - struct thread *td = curthread; - struct sockopt sopt; - l_timeval linux_tv; - struct timeval tv; - struct xucred xu; - struct l_ucred lxu; - int error, name, valsize, level; - - error = copyin(args, &linux_args, sizeof(linux_args)); - if (error) - return (error); - - if (linux_args.optlen) { - error = copyin(linux_args.optlen, &valsize, sizeof(valsize)); - if (error) - return (error); - } else { - valsize = 0; - } - - if (valsize < 0 || valsize > SOMAXOPT_SIZE) - return (EINVAL); - if (linux_args.optval != NULL && valsize == 0) - return (EFAULT); - if (linux_args.optval == NULL && valsize != 0) - return (EFAULT); - - level = linux_to_bsd_sockopt_level(linux_args.level); - switch (level) { - case SOL_SOCKET: - name = linux_to_bsd_so_sockopt(linux_args.optname); - switch (name) { - case SO_RCVTIMEO: - /* FALLTHROUGH */ - case SO_SNDTIMEO: - sopt.sopt_dir = SOPT_GET; - sopt.sopt_level = level; - sopt.sopt_name = name; - sopt.sopt_valsize = sizeof(tv); - sopt.sopt_td = td; - sopt.sopt_val = &tv; - error = kern_getsockopt(linux_args.s, &sopt); - if (error) - return (error); - linux_tv.tv_sec = tv.tv_sec; - linux_tv.tv_usec = tv.tv_usec; - return (copyout(&linux_tv, linux_args.optval, - sizeof(linux_tv))); - /* NOTREACHED */ - break; - case LOCAL_PEERCRED: - if (valsize != sizeof(lxu)) - return (EINVAL); - sopt.sopt_dir = SOPT_GET; - sopt.sopt_level = level; - sopt.sopt_name = name; - sopt.sopt_valsize = sizeof(xu); - sopt.sopt_td = td; - sopt.sopt_val = &xu; - error = kern_getsockopt(linux_args.s, &sopt); - if (error) - return (error); - /* - * XXX Use 0 for pid as the FreeBSD does not cache peer pid. - */ - lxu.pid = 0; - lxu.uid = xu.cr_uid; - lxu.gid = xu.cr_gid; - return (copyout(&lxu, linux_args.optval, sizeof(lxu))); - /* NOTREACHED */ - break; - default: - break; - } - break; - case IPPROTO_IP: - name = linux_to_bsd_ip_sockopt(linux_args.optname); - break; - case IPPROTO_TCP: - /* Linux TCP option values match BSD's */ - name = linux_args.optname; - break; - default: - name = -1; - break; - } - if (name == -1) - return (EOPNOTSUPP); - - - - sopt.sopt_dir = SOPT_GET; - sopt.sopt_level = level; - sopt.sopt_name = name; - sopt.sopt_valsize = valsize; - sopt.sopt_td = td; - - if (linux_args.optval) { - sopt.sopt_val = kmalloc(sopt.sopt_valsize, M_TEMP, M_WAITOK); - error = copyin(linux_args.optval, sopt.sopt_val, sopt.sopt_valsize); - if (error) - goto out; - } else { - sopt.sopt_val = NULL; - } - error = kern_getsockopt(linux_args.s, &sopt); - if (error) { - if (error == EINVAL) - error = ENOPROTOOPT; - goto out; - } - valsize = sopt.sopt_valsize; - error = copyout(&valsize, linux_args.optlen, sizeof(valsize)); - if (error) - goto out; - if (linux_args.optval) - error = copyout(sopt.sopt_val, linux_args.optval, sopt.sopt_valsize); -out: - if (linux_args.optval) - kfree(sopt.sopt_val, M_TEMP); - return(error); -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_socketcall(struct linux_socketcall_args *args) -{ - void *arg = (void *)args->args; - int error; - - get_mplock(); - - switch (args->what) { - case LINUX_SOCKET: - error = linux_socket(arg, &args->sysmsg_result); - break; - case LINUX_BIND: - error = linux_bind(arg, &args->sysmsg_result); - break; - case LINUX_CONNECT: - error = linux_connect(arg, &args->sysmsg_result); - break; - case LINUX_LISTEN: - error = linux_listen(arg, &args->sysmsg_result); - break; - case LINUX_ACCEPT: - error = linux_accept(arg, &args->sysmsg_result); - break; - case LINUX_GETSOCKNAME: - error = linux_getsockname(arg, &args->sysmsg_result); - break; - case LINUX_GETPEERNAME: - error = linux_getpeername(arg, &args->sysmsg_result); - break; - case LINUX_SOCKETPAIR: - error = linux_socketpair(arg, &args->sysmsg_result); - break; - case LINUX_SEND: - error = linux_send(arg, &args->sysmsg_szresult); - break; - case LINUX_RECV: - error = linux_recv(arg, &args->sysmsg_szresult); - break; - case LINUX_SENDTO: - error = linux_sendto(arg, &args->sysmsg_szresult); - break; - case LINUX_RECVFROM: - error = linux_recvfrom(arg, &args->sysmsg_szresult); - break; - case LINUX_SHUTDOWN: - error = linux_shutdown(arg, &args->sysmsg_result); - break; - case LINUX_SETSOCKOPT: - error = linux_setsockopt(arg, &args->sysmsg_result); - break; - case LINUX_GETSOCKOPT: - error = linux_getsockopt(arg, &args->sysmsg_result); - break; - case LINUX_SENDMSG: - error = linux_sendmsg(arg, &args->sysmsg_szresult); - break; - case LINUX_RECVMSG: - error = linux_recvmsg(arg, &args->sysmsg_szresult); - break; - default: - uprintf("LINUX: 'socket' typ=%d not implemented\n", - args->what); - error = ENOSYS; - break; - } - rel_mplock(); - - return (error); -} diff --git a/sys/emulation/linux/linux_socket.h b/sys/emulation/linux/linux_socket.h deleted file mode 100644 index 48e2c1aea3..0000000000 --- a/sys/emulation/linux/linux_socket.h +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * Copyright (c) 2000 Assar Westerlund - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer - * in this position and unchanged. - * 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 - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD: src/sys/compat/linux/linux_socket.h,v 1.1.2.1 2001/03/04 08:38:20 assar Exp $ - * $DragonFly: src/sys/emulation/linux/linux_socket.h,v 1.2 2003/06/17 04:28:19 dillon Exp $ - */ - -#ifndef _LINUX_SOCKET_H_ -#define _LINUX_SOCKET_H_ - -/* msg flags in recvfrom/recvmsg */ - -#define LINUX_MSG_OOB 0x01 -#define LINUX_MSG_PEEK 0x02 -#define LINUX_MSG_DONTROUTE 0x04 -#define LINUX_MSG_CTRUNC 0x08 -#define LINUX_MSG_PROXY 0x10 -#define LINUX_MSG_TRUNC 0x20 -#define LINUX_MSG_DONTWAIT 0x40 -#define LINUX_MSG_EOR 0x80 -#define LINUX_MSG_WAITALL 0x100 -#define LINUX_MSG_FIN 0x200 -#define LINUX_MSG_SYN 0x400 -#define LINUX_MSG_CONFIRM 0x800 -#define LINUX_MSG_RST 0x1000 -#define LINUX_MSG_ERRQUEUE 0x2000 -#define LINUX_MSG_NOSIGNAL 0x4000 - -struct l_ucred { - uint32_t pid; - uint32_t uid; - uint32_t gid; -}; - -#endif /* _LINUX_SOCKET_H_ */ diff --git a/sys/emulation/linux/linux_stats.c b/sys/emulation/linux/linux_stats.c deleted file mode 100644 index f6ae2f5c78..0000000000 --- a/sys/emulation/linux/linux_stats.c +++ /dev/null @@ -1,574 +0,0 @@ -/*- - * Copyright (c) 1994-1995 Søren Schmidt - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer - * in this position and unchanged. - * 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 - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD: src/sys/compat/linux/linux_stats.c,v 1.22.2.3 2001/11/05 19:08:23 marcel Exp $ - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include "linux_util.h" - -static int -newstat_copyout(struct stat *buf, void *ubuf) -{ - struct l_newstat tbuf; - int error; - - bzero(&tbuf, sizeof(tbuf)); - tbuf.st_dev = uminor(buf->st_dev) | (umajor(buf->st_dev) << 8); - tbuf.st_ino = INO64TO32(buf->st_ino); - tbuf.st_mode = buf->st_mode; - tbuf.st_nlink = buf->st_nlink; - tbuf.st_uid = buf->st_uid; - tbuf.st_gid = buf->st_gid; - tbuf.st_rdev = buf->st_rdev; - tbuf.st_size = buf->st_size; - tbuf.st_atime = buf->st_atime; - tbuf.st_mtime = buf->st_mtime; - tbuf.st_ctime = buf->st_ctime; - tbuf.st_blksize = buf->st_blksize; - tbuf.st_blocks = buf->st_blocks; - - error = copyout(&tbuf, ubuf, sizeof(tbuf)); - return (error); -} - -static int -ostat_copyout(struct stat *st, struct ostat *uaddr) -{ - struct ostat ost; - int error; - - ost.st_dev = st->st_dev; - ost.st_ino = st->st_ino; - ost.st_mode = st->st_mode; - ost.st_nlink = st->st_nlink; - ost.st_uid = st->st_uid; - ost.st_gid = st->st_gid; - ost.st_rdev = st->st_rdev; - if (st->st_size < (quad_t)1 << 32) - ost.st_size = st->st_size; - else - ost.st_size = -2; - ost.st_atime = st->st_atime; - ost.st_mtime = st->st_mtime; - ost.st_ctime = st->st_ctime; - ost.st_blksize = st->st_blksize; - ost.st_blocks = st->st_blocks; - ost.st_flags = st->st_flags; - ost.st_gen = st->st_gen; - - error = copyout(&ost, uaddr, sizeof(ost)); - return (error); -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_newstat(struct linux_newstat_args *args) -{ - struct stat buf; - struct nlookupdata nd; - char *path; - int error; - - error = linux_copyin_path(args->path, &path, LINUX_PATH_EXISTS); - if (error) - return (error); -#ifdef DEBUG - if (ldebug(newstat)) - kprintf(ARGS(newstat, "%s, *"), path); -#endif - get_mplock(); - error = nlookup_init(&nd, path, UIO_SYSSPACE, NLC_FOLLOW); - if (error == 0) { - error = kern_stat(&nd, &buf); - if (error == 0) - error = newstat_copyout(&buf, args->buf); - nlookup_done(&nd); - } - rel_mplock(); - linux_free_path(&path); - return (error); -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_newlstat(struct linux_newlstat_args *args) -{ - struct stat sb; - struct nlookupdata nd; - char *path; - int error; - - error = linux_copyin_path(args->path, &path, LINUX_PATH_EXISTS); - if (error) - return (error); -#ifdef DEBUG - if (ldebug(newlstat)) - kprintf(ARGS(newlstat, "%s, *"), path); -#endif - get_mplock(); - error = nlookup_init(&nd, path, UIO_SYSSPACE, 0); - if (error == 0) { - error = kern_stat(&nd, &sb); - if (error == 0) - error = newstat_copyout(&sb, args->buf); - nlookup_done(&nd); - } - rel_mplock(); - linux_free_path(&path); - return (error); -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_newfstat(struct linux_newfstat_args *args) -{ - struct stat buf; - int error; - -#ifdef DEBUG - if (ldebug(newfstat)) - kprintf(ARGS(newfstat, "%d, *"), args->fd); -#endif - get_mplock(); - error = kern_fstat(args->fd, &buf); - rel_mplock(); - - if (error == 0) - error = newstat_copyout(&buf, args->buf); - return (error); -} - -/* XXX - All fields of type l_int are defined as l_long on i386 */ -struct l_statfs { - l_int f_type; - l_int f_bsize; - l_int f_blocks; - l_int f_bfree; - l_int f_bavail; - l_int f_files; - l_int f_ffree; - l_fsid_t f_fsid; - l_int f_namelen; - l_int f_spare[6]; -}; - -#define LINUX_CODA_SUPER_MAGIC 0x73757245L -#define LINUX_EXT2_SUPER_MAGIC 0xEF53L -#define LINUX_HPFS_SUPER_MAGIC 0xf995e849L -#define LINUX_ISOFS_SUPER_MAGIC 0x9660L -#define LINUX_MSDOS_SUPER_MAGIC 0x4d44L -#define LINUX_NCP_SUPER_MAGIC 0x564cL -#define LINUX_NFS_SUPER_MAGIC 0x6969L -#define LINUX_NTFS_SUPER_MAGIC 0x5346544EL -#define LINUX_PROC_SUPER_MAGIC 0x9fa0L -#define LINUX_UFS_SUPER_MAGIC 0x00011954L /* XXX - UFS_MAGIC in Linux */ - -static long -bsd_to_linux_ftype(const char *fstypename) -{ - int i; - static struct {const char *bsd_name; long linux_type;} b2l_tbl[] = { - {"ufs", LINUX_UFS_SUPER_MAGIC}, - {"cd9660", LINUX_ISOFS_SUPER_MAGIC}, - {"nfs", LINUX_NFS_SUPER_MAGIC}, - {"ext2fs", LINUX_EXT2_SUPER_MAGIC}, - {"procfs", LINUX_PROC_SUPER_MAGIC}, - {"msdosfs", LINUX_MSDOS_SUPER_MAGIC}, - {"ntfs", LINUX_NTFS_SUPER_MAGIC}, - {"hpfs", LINUX_HPFS_SUPER_MAGIC}, - {NULL, 0L}}; - - for (i = 0; b2l_tbl[i].bsd_name != NULL; i++) - if (strcmp(b2l_tbl[i].bsd_name, fstypename) == 0) - return (b2l_tbl[i].linux_type); - - return (0L); -} - -static int -statfs_copyout(struct statfs *statfs, struct l_statfs_buf *buf, l_int namelen) -{ - struct l_statfs linux_statfs; - int error; - - linux_statfs.f_type = bsd_to_linux_ftype(statfs->f_fstypename); - linux_statfs.f_bsize = statfs->f_bsize; - linux_statfs.f_blocks = statfs->f_blocks; - linux_statfs.f_bfree = statfs->f_bfree; - linux_statfs.f_bavail = statfs->f_bavail; - linux_statfs.f_ffree = statfs->f_ffree; - linux_statfs.f_files = statfs->f_files; - linux_statfs.f_fsid.val[0] = statfs->f_fsid.val[0]; - linux_statfs.f_fsid.val[1] = statfs->f_fsid.val[1]; - linux_statfs.f_namelen = namelen; - - error = copyout(&linux_statfs, buf, sizeof(linux_statfs)); - return (error); -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_statfs(struct linux_statfs_args *args) -{ - struct statfs statfs; - struct nlookupdata nd; - char *path; - int error, namelen; - - error = linux_copyin_path(args->path, &path, LINUX_PATH_EXISTS); - if (error) - return (error); -#ifdef DEBUG - if (ldebug(statfs)) - kprintf(ARGS(statfs, "%s, *"), path); -#endif - get_mplock(); - error = nlookup_init(&nd, path, UIO_SYSSPACE, NLC_FOLLOW); - if (error == 0) - error = kern_statfs(&nd, &statfs); - if (error == 0) { - if (nd.nl_nch.ncp->nc_vp != NULL) - error = vn_get_namelen(nd.nl_nch.ncp->nc_vp, &namelen); - else - error = EINVAL; - } - nlookup_done(&nd); - rel_mplock(); - if (error == 0) - error = statfs_copyout(&statfs, args->buf, (l_int)namelen); - linux_free_path(&path); - return (error); -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_fstatfs(struct linux_fstatfs_args *args) -{ - struct proc *p = curthread->td_proc; - struct file *fp; - struct statfs statfs; - int error, namelen; - -#ifdef DEBUG - if (ldebug(fstatfs)) - kprintf(ARGS(fstatfs, "%d, *"), args->fd); -#endif - get_mplock(); - if ((error = kern_fstatfs(args->fd, &statfs)) != 0) { - rel_mplock(); - return (error); - } - if ((error = holdvnode(p->p_fd, args->fd, &fp)) != 0) { - rel_mplock(); - return (error); - } - error = vn_get_namelen((struct vnode *)fp->f_data, &namelen); - rel_mplock(); - fdrop(fp); - if (error == 0) - error = statfs_copyout(&statfs, args->buf, (l_int)namelen); - return (error); -} - -struct l_ustat -{ - l_daddr_t f_tfree; - l_ino_t f_tinode; - char f_fname[6]; - char f_fpack[6]; -}; - -/* - * MPALMOSTSAFE - */ -int -sys_linux_ustat(struct linux_ustat_args *args) -{ - struct thread *td = curthread; - struct l_ustat lu; - cdev_t dev; - struct vnode *vp; - struct statfs *stat; - int error; - -#ifdef DEBUG - if (ldebug(ustat)) - kprintf(ARGS(ustat, "%d, *"), args->dev); -#endif - - /* - * lu.f_fname and lu.f_fpack are not used. They are always zeroed. - * lu.f_tinode and lu.f_tfree are set from the device's super block. - */ - bzero(&lu, sizeof(lu)); - - /* - * XXX - Don't return an error if we can't find a vnode for the - * device. Our cdev_t is 32-bits whereas Linux only has a 16-bits - * cdev_t. The dev_t that is used now may as well be a truncated - * cdev_t returned from previous syscalls. Just return a bzeroed - * ustat in that case. - */ - get_mplock(); - dev = udev2dev(makeudev(args->dev >> 8, args->dev & 0xFF), 0); - if (dev != NULL && vfinddev(dev, VCHR, &vp)) { - if (vp->v_mount == NULL) { - vrele(vp); - error = EINVAL; - goto done; - } - stat = &(vp->v_mount->mnt_stat); - error = VFS_STATFS(vp->v_mount, stat, td->td_ucred); - vrele(vp); - if (error == 0) { - lu.f_tfree = stat->f_bfree; - lu.f_tinode = stat->f_ffree; - } - } else { - error = 0; - } -done: - rel_mplock(); - if (error == 0) - error = copyout(&lu, args->ubuf, sizeof(lu)); - return (error); -} - -#if defined(__i386__) - -static int -stat64_copyout(struct stat *buf, void *ubuf) -{ - struct l_stat64 lbuf; - int error; - - bzero(&lbuf, sizeof(lbuf)); - lbuf.st_dev = uminor(buf->st_dev) | (umajor(buf->st_dev) << 8); - lbuf.st_ino = INO64TO32(buf->st_ino); - lbuf.st_mode = buf->st_mode; - lbuf.st_nlink = buf->st_nlink; - lbuf.st_uid = buf->st_uid; - lbuf.st_gid = buf->st_gid; - lbuf.st_rdev = buf->st_rdev; - lbuf.st_size = buf->st_size; - lbuf.st_atime = buf->st_atime; - lbuf.st_mtime = buf->st_mtime; - lbuf.st_ctime = buf->st_ctime; - lbuf.st_blksize = buf->st_blksize; - lbuf.st_blocks = buf->st_blocks; - - /* - * The __st_ino field makes all the difference. In the Linux kernel - * it is conditionally compiled based on STAT64_HAS_BROKEN_ST_INO, - * but without the assignment to __st_ino the runtime linker refuses - * to mmap(2) any shared libraries. I guess it's broken alright :-) - */ - lbuf.__st_ino = INO64TO32(buf->st_ino); - - error = copyout(&lbuf, ubuf, sizeof(lbuf)); - return (error); -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_stat64(struct linux_stat64_args *args) -{ - struct nlookupdata nd; - struct stat buf; - char *path; - int error; - - error = linux_copyin_path(args->filename, &path, LINUX_PATH_EXISTS); - if (error) - return (error); -#ifdef DEBUG - if (ldebug(stat64)) - kprintf(ARGS(stat64, "%s, *"), path); -#endif - get_mplock(); - error = nlookup_init(&nd, path, UIO_SYSSPACE, NLC_FOLLOW); - if (error == 0) { - error = kern_stat(&nd, &buf); - nlookup_done(&nd); - } - rel_mplock(); - if (error == 0) - error = stat64_copyout(&buf, args->statbuf); - linux_free_path(&path); - return (error); -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_lstat64(struct linux_lstat64_args *args) -{ - struct nlookupdata nd; - struct stat sb; - char *path; - int error; - - error = linux_copyin_path(args->filename, &path, LINUX_PATH_EXISTS); - if (error) - return (error); -#ifdef DEBUG - if (ldebug(lstat64)) - kprintf(ARGS(lstat64, "%s, *"), path); -#endif - get_mplock(); - error = nlookup_init(&nd, path, UIO_SYSSPACE, 0); - if (error == 0) { - error = kern_stat(&nd, &sb); - nlookup_done(&nd); - } - rel_mplock(); - if (error == 0) - error = stat64_copyout(&sb, args->statbuf); - linux_free_path(&path); - return (error); -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_fstat64(struct linux_fstat64_args *args) -{ - struct stat buf; - int error; - -#ifdef DEBUG - if (ldebug(fstat64)) - kprintf(ARGS(fstat64, "%d, *"), args->fd); -#endif - get_mplock(); - error = kern_fstat(args->fd, &buf); - rel_mplock(); - - if (error == 0) - error = stat64_copyout(&buf, args->statbuf); - return (error); -} - -int -sys_linux_fstatat64(struct linux_fstatat64_args *args) -{ - struct nlookupdata nd; - struct file *fp; - struct stat st; - char *path; - int error, flags, dfd; - - if (args->flag & ~LINUX_AT_SYMLINK_NOFOLLOW) - return (EINVAL); - - error = linux_copyin_path(args->path, &path, LINUX_PATH_EXISTS); - if (error) - return (error); -#ifdef DEBUG - if (ldebug(fstatat64)) - kprintf(ARGS(fstatat64, "%s"), path); -#endif - dfd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->dfd; - flags = (args->flag & LINUX_AT_SYMLINK_NOFOLLOW) ? 0 : NLC_FOLLOW; - - error = nlookup_init_at(&nd, &fp, dfd, path, UIO_SYSSPACE, flags); - if (error == 0) { - error = kern_stat(&nd, &st); - if (error == 0) - error = stat64_copyout(&st, args->statbuf); - } - nlookup_done_at(&nd, fp); - linux_free_path(&path); - return (error); -} - -int -sys_linux_ostat(struct linux_ostat_args *args) -{ - struct nlookupdata nd; - struct stat buf; - char *path; - int error; - - error = linux_copyin_path(args->path, &path, LINUX_PATH_EXISTS); - if (error) - return (error); -#ifdef DEBUG - if (ldebug(ostat)) - kprintf(ARGS(ostat, "%s, *"), path); -#endif - get_mplock(); - error = nlookup_init(&nd, path, UIO_SYSSPACE, NLC_FOLLOW); - if (error == 0) { - error = kern_stat(&nd, &buf); - nlookup_done(&nd); - } - rel_mplock(); - if (error == 0) - error = ostat_copyout(&buf, args->statbuf); - linux_free_path(&path); - return (error); -} - -#endif /* __i386__ */ diff --git a/sys/emulation/linux/linux_sysctl.c b/sys/emulation/linux/linux_sysctl.c deleted file mode 100644 index 66e3c4ba19..0000000000 --- a/sys/emulation/linux/linux_sysctl.c +++ /dev/null @@ -1,137 +0,0 @@ -/*- - * Copyright (c) 2001 Marcel Moolenaar - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer - * in this position and unchanged. - * 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 - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD: src/sys/compat/linux/linux_sysctl.c,v 1.2.2.1 2001/10/21 03:57:35 marcel Exp $ - * $DragonFly: src/sys/emulation/linux/linux_sysctl.c,v 1.9 2006/12/23 00:27:02 swildner Exp $ - */ - -#include "opt_compat.h" - -#include -#include -#include -#include - -#include - -#include -#include -#include "linux_util.h" - -#define LINUX_CTL_KERN 1 -#define LINUX_CTL_VM 2 -#define LINUX_CTL_NET 3 -#define LINUX_CTL_PROC 4 -#define LINUX_CTL_FS 5 -#define LINUX_CTL_DEBUG 6 -#define LINUX_CTL_DEV 7 -#define LINUX_CTL_BUS 8 - -/* CTL_KERN names */ -#define LINUX_KERN_OSTYPE 1 -#define LINUX_KERN_OSRELEASE 2 -#define LINUX_KERN_OSREV 3 -#define LINUX_KERN_VERSION 4 - -static int -handle_string(struct l___sysctl_args *la, char *value) -{ - int error; - - if (la->oldval != NULL) { - l_int len = strlen(value); - error = copyout(value, la->oldval, len + 1); - if (!error && la->oldlenp != NULL) - error = copyout(&len, la->oldlenp, sizeof(len)); - if (error) - return (error); - } - - if (la->newval != NULL) - return (ENOTDIR); - - return (0); -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_sysctl(struct linux_sysctl_args *args) -{ - struct l___sysctl_args la; - l_int *mib; - int error, i; - - error = copyin((caddr_t)args->args, &la, sizeof(la)); - if (error) - return (error); - - if (la.nlen <= 0 || la.nlen > LINUX_CTL_MAXNAME) - return (ENOTDIR); - - mib = kmalloc(la.nlen * sizeof(l_int), M_TEMP, M_WAITOK); - error = copyin(la.name, mib, la.nlen * sizeof(l_int)); - if (error) { - kfree(mib, M_TEMP); - return (error); - } - - get_mplock(); - - switch (mib[0]) { - case LINUX_CTL_KERN: - if (la.nlen < 2) { - error = ENOTDIR; - break; - } - - switch (mib[1]) { - case LINUX_KERN_VERSION: - error = handle_string(&la, version); - break; - default: - error = ENOTDIR; - break; - } - break; - default: - error = ENOTDIR; - break; - } - rel_mplock(); - - if (error == ENOTDIR && mib) { - kprintf("linux: sysctl: unhandled name="); - for (i = 0; i < la.nlen; i++) - kprintf("%c%d", (i) ? ',' : '{', mib[i]); - kprintf("}\n"); - } - if (mib) - kfree(mib, M_TEMP); - return (error); -} diff --git a/sys/emulation/linux/linux_sysproto.h b/sys/emulation/linux/linux_sysproto.h deleted file mode 100644 index 384e631e8c..0000000000 --- a/sys/emulation/linux/linux_sysproto.h +++ /dev/null @@ -1,8 +0,0 @@ -/* $DragonFly: src/sys/emulation/linux/linux_sysproto.h,v 1.1 2005/10/08 11:41:11 corecode Exp $ */ - -#ifndef LINUX_SYSPROTO -#define LINUX_SYSPROTO - -int linux_nosys(struct nosys_args *); - -#endif diff --git a/sys/emulation/linux/linux_time.c b/sys/emulation/linux/linux_time.c deleted file mode 100644 index 7dcb619697..0000000000 --- a/sys/emulation/linux/linux_time.c +++ /dev/null @@ -1,231 +0,0 @@ -/* $NetBSD: linux_time.c,v 1.14 2006/05/14 03:40:54 christos Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Emmanuel Dreyfus. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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. - */ -#include "opt_compat.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#ifdef __i386__ -#include -#endif - -#include - -#include -#include -#include -#include "linux_mib.h" -#include "linux_util.h" - -static void native_to_linux_timespec(struct l_timespec *, - struct timespec *); -static int linux_to_native_timespec(struct timespec *, - struct l_timespec *); -static int linux_to_native_clockid(clockid_t *, clockid_t); - -static void -native_to_linux_timespec(struct l_timespec *ltp, struct timespec *ntp) -{ - ltp->tv_sec = ntp->tv_sec; - ltp->tv_nsec = ntp->tv_nsec; -} - -static int -linux_to_native_timespec(struct timespec *ntp, struct l_timespec *ltp) -{ - if (ltp->tv_sec < 0 || ltp->tv_nsec > (l_long)999999999L) - return (EINVAL); - ntp->tv_sec = ltp->tv_sec; - ntp->tv_nsec = ltp->tv_nsec; - - return (0); -} - -static int -linux_to_native_clockid(clockid_t *n, clockid_t l) -{ - switch (l) { - case LINUX_CLOCK_REALTIME: - *n = CLOCK_REALTIME; - break; - case LINUX_CLOCK_MONOTONIC: - *n = CLOCK_MONOTONIC; - break; - case LINUX_CLOCK_PROCESS_CPUTIME_ID: - case LINUX_CLOCK_THREAD_CPUTIME_ID: - case LINUX_CLOCK_REALTIME_HR: - case LINUX_CLOCK_MONOTONIC_HR: - default: - return (EINVAL); - break; - } - - return (0); -} - -int -sys_linux_clock_gettime(struct linux_clock_gettime_args *args) -{ - struct l_timespec lts; - int error; - clockid_t nwhich = 0; /* XXX: GCC */ - struct timespec tp; - - error = linux_to_native_clockid(&nwhich, args->which); - if (error != 0) - return (error); - error = kern_clock_gettime(nwhich, &tp); - if (error != 0) - return (error); - native_to_linux_timespec(<s, &tp); - - return (copyout(<s, args->tp, sizeof lts)); -} - -int -sys_linux_clock_settime(struct linux_clock_settime_args *args) -{ - struct timespec ts; - struct l_timespec lts; - int error; - clockid_t nwhich = 0; /* XXX: GCC */ - - error = linux_to_native_clockid(&nwhich, args->which); - if (error != 0) - return (error); - error = copyin(args->tp, <s, sizeof lts); - if (error != 0) - return (error); - error = linux_to_native_timespec(&ts, <s); - if (error != 0) - return (error); - - return (kern_clock_settime(nwhich, &ts)); -} - -int -sys_linux_clock_getres(struct linux_clock_getres_args *args) -{ - struct timespec ts; - struct l_timespec lts; - int error; - clockid_t nwhich = 0; /* XXX: GCC */ - - if (args->tp == NULL) - return (0); - - error = linux_to_native_clockid(&nwhich, args->which); - if (error != 0) - return (error); - error = kern_clock_getres(nwhich, &ts); - if (error != 0) - return (error); - native_to_linux_timespec(<s, &ts); - - return (copyout(<s, args->tp, sizeof lts)); -} - -int -sys_linux_clock_nanosleep(struct linux_clock_nanosleep_args *args) -{ - struct timespec *rmtp; - struct l_timespec lrqts, lrmts; - struct timespec rqts, rmts; - int error; - - if (args->flags != 0) - return (EINVAL); /* XXX deal with TIMER_ABSTIME */ - - if (args->which != LINUX_CLOCK_REALTIME) - return (EINVAL); - - error = copyin(args->rqtp, &lrqts, sizeof lrqts); - if (error != 0) - return (error); - - if (args->rmtp != NULL) - rmtp = &rmts; - else - rmtp = NULL; - - error = linux_to_native_timespec(&rqts, &lrqts); - if (error != 0) - return (error); - error = nanosleep1(&rqts, rmtp); - if (error != 0) - return (error); - - if (args->rmtp != NULL) { - native_to_linux_timespec(&lrmts, rmtp); - error = copyout(&lrmts, args->rmtp, sizeof lrmts ); - if (error != 0) - return (error); - } - - return (0); -} diff --git a/sys/emulation/linux/linux_uid16.c b/sys/emulation/linux/linux_uid16.c deleted file mode 100644 index f1c0bb93bf..0000000000 --- a/sys/emulation/linux/linux_uid16.c +++ /dev/null @@ -1,402 +0,0 @@ -/*- - * Copyright (c) 2001 The FreeBSD Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 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. - * - * $FreeBSD: src/sys/compat/linux/linux_uid16.c,v 1.4.2.1 2001/10/21 03:57:35 marcel Exp $ - */ - -#include "opt_compat.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include "linux_util.h" - -DUMMY(setfsuid16); -DUMMY(setfsgid16); -DUMMY(getresuid16); -DUMMY(getresgid16); - -#define CAST_NOCHG(x) ((x == 0xFFFF) ? -1 : x) - -/* - * MPALMOSTSAFE - */ -int -sys_linux_chown16(struct linux_chown16_args *args) -{ - struct nlookupdata nd; - char *path; - int error; - - error = linux_copyin_path(args->path, &path, LINUX_PATH_EXISTS); - if (error) - return (error); -#ifdef DEBUG - if (ldebug(chown16)) - kprintf(ARGS(chown16, "%s, %d, %d"), path, args->uid, - args->gid); -#endif - get_mplock(); - error = nlookup_init(&nd, path, UIO_SYSSPACE, NLC_FOLLOW); - if (error == 0) { - error = kern_chown(&nd, CAST_NOCHG(args->uid), - CAST_NOCHG(args->gid)); - } - nlookup_done(&nd); - rel_mplock(); - linux_free_path(&path); - return(error); -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_lchown16(struct linux_lchown16_args *args) -{ - struct nlookupdata nd; - char *path; - int error; - - error = linux_copyin_path(args->path, &path, LINUX_PATH_EXISTS); - if (error) - return (error); -#ifdef DEBUG - if (ldebug(lchown16)) - kprintf(ARGS(lchown16, "%s, %d, %d"), path, args->uid, - args->gid); -#endif - get_mplock(); - error = nlookup_init(&nd, path, UIO_SYSSPACE, 0); - if (error == 0) { - error = kern_chown(&nd, CAST_NOCHG(args->uid), - CAST_NOCHG(args->gid)); - } - nlookup_done(&nd); - rel_mplock(); - linux_free_path(&path); - return(error); -} - -/* - * MPALMOSTSAFE - */ -int -sys_linux_setgroups16(struct linux_setgroups16_args *args) -{ - struct thread *td = curthread; - struct proc *p = td->td_proc; - struct ucred *newcred, *oldcred; - l_gid16_t linux_gidset[NGROUPS]; - gid_t *bsd_gidset; - int ngrp, error; - -#ifdef DEBUG - if (ldebug(setgroups16)) - kprintf(ARGS(setgroups16, "%d, *"), args->gidsetsize); -#endif - - ngrp = args->gidsetsize; - oldcred = td->td_ucred; - - /* - * cr_groups[0] holds egid. Setting the whole set from - * the supplied set will cause egid to be changed too. - * Keep cr_groups[0] unchanged to prevent that. - */ - - if ((error = priv_check_cred(oldcred, PRIV_CRED_SETGROUPS, 0)) != 0) - return (error); - - if ((u_int)ngrp >= NGROUPS) - return (EINVAL); - - get_mplock(); - newcred = crdup(oldcred); - if (ngrp > 0) { - error = copyin((caddr_t)args->gidset, linux_gidset, - ngrp * sizeof(l_gid16_t)); - if (error) { - crfree(newcred); - goto done; - } - - newcred->cr_ngroups = ngrp + 1; - - bsd_gidset = newcred->cr_groups; - ngrp--; - while (ngrp >= 0) { - bsd_gidset[ngrp + 1] = linux_gidset[ngrp]; - ngrp--; - } - } else { - newcred->cr_ngroups = 1; - } - - setsugid(); - oldcred = p->p_ucred; /* deal with threads race */ - p->p_ucred = newcred; - crfree(oldcred); - error = 0; -done: - rel_mplock(); - return (error); -} - -/* - * MPSAFE - */ -int -sys_linux_getgroups16(struct linux_getgroups16_args *args) -{ - struct proc *p = curproc; - struct ucred *cred; - l_gid16_t linux_gidset[NGROUPS]; - gid_t *bsd_gidset; - int bsd_gidsetsz, ngrp, error; - -#ifdef DEBUG - if (ldebug(getgroups16)) - kprintf(ARGS(getgroups16, "%d, *"), args->gidsetsize); -#endif - - cred = p->p_ucred; - bsd_gidset = cred->cr_groups; - bsd_gidsetsz = cred->cr_ngroups - 1; - - /* - * cr_groups[0] holds egid. Returning the whole set - * here will cause a duplicate. Exclude cr_groups[0] - * to prevent that. - */ - - if ((ngrp = args->gidsetsize) == 0) { - args->sysmsg_result = bsd_gidsetsz; - return (0); - } - - if ((u_int)ngrp < (u_int)bsd_gidsetsz) - return (EINVAL); - - ngrp = 0; - while (ngrp < bsd_gidsetsz) { - linux_gidset[ngrp] = bsd_gidset[ngrp + 1]; - ngrp++; - } - - error = copyout(linux_gidset, (caddr_t)args->gidset, - ngrp * sizeof(l_gid16_t)); - if (error) - return (error); - - args->sysmsg_result = ngrp; - return (0); -} - -/* - * The FreeBSD native getgid(2) and getuid(2) also modify p->p_retval[1] - * when COMPAT_43 is defined. This globbers registers that - * are assumed to be preserved. The following lightweight syscalls fixes - * this. See also linux_getpid(2), linux_getgid(2) and linux_getuid(2) in - * linux_misc.c - * - * linux_getgid16() - MP SAFE - * linux_getuid16() - MP SAFE - */ - -/* - * MPSAFE - */ -int -sys_linux_getgid16(struct linux_getgid16_args *args) -{ - struct proc *p = curproc; - - args->sysmsg_result = p->p_ucred->cr_rgid; - return (0); -} - -/* - * MPSAFE - */ -int -sys_linux_getuid16(struct linux_getuid16_args *args) -{ - struct proc *p = curproc; - - args->sysmsg_result = p->p_ucred->cr_ruid; - return (0); -} - -/* - * MPSAFE - */ -int -sys_linux_getegid16(struct linux_getegid16_args *args) -{ - struct getegid_args bsd; - int error; - - bsd.sysmsg_result = 0; - - error = sys_getegid(&bsd); - args->sysmsg_result = bsd.sysmsg_result; - return(error); -} - -/* - * MPSAFE - */ -int -sys_linux_geteuid16(struct linux_geteuid16_args *args) -{ - struct geteuid_args bsd; - int error; - - bsd.sysmsg_result = 0; - - error = sys_geteuid(&bsd); - args->sysmsg_result = bsd.sysmsg_result; - return(error); -} - -/* - * MPSAFE - */ -int -sys_linux_setgid16(struct linux_setgid16_args *args) -{ - struct setgid_args bsd; - int error; - - bsd.gid = args->gid; - bsd.sysmsg_result = 0; - - error = sys_setgid(&bsd); - args->sysmsg_result = bsd.sysmsg_result; - return(error); -} - -/* - * MPSAFE - */ -int -sys_linux_setuid16(struct linux_setuid16_args *args) -{ - struct setuid_args bsd; - int error; - - bsd.uid = args->uid; - bsd.sysmsg_result = 0; - - error = sys_setuid(&bsd); - args->sysmsg_result = bsd.sysmsg_result; - return(error); -} - -/* - * MPSAFE - */ -int -sys_linux_setregid16(struct linux_setregid16_args *args) -{ - struct setregid_args bsd; - int error; - - bsd.rgid = CAST_NOCHG(args->rgid); - bsd.egid = CAST_NOCHG(args->egid); - bsd.sysmsg_result = 0; - - error = sys_setregid(&bsd); - args->sysmsg_result = bsd.sysmsg_result; - return(error); -} - -/* - * MPSAFE - */ -int -sys_linux_setreuid16(struct linux_setreuid16_args *args) -{ - struct setreuid_args bsd; - int error; - - bsd.ruid = CAST_NOCHG(args->ruid); - bsd.euid = CAST_NOCHG(args->euid); - bsd.sysmsg_result = 0; - - error = sys_setreuid(&bsd); - args->sysmsg_result = bsd.sysmsg_result; - return(error); -} - -/* - * MPSAFE - */ -int -sys_linux_setresgid16(struct linux_setresgid16_args *args) -{ - struct setresgid_args bsd; - int error; - - bsd.rgid = CAST_NOCHG(args->rgid); - bsd.egid = CAST_NOCHG(args->egid); - bsd.sgid = CAST_NOCHG(args->sgid); - bsd.sysmsg_result = 0; - - error = sys_setresgid(&bsd); - args->sysmsg_result = bsd.sysmsg_result; - return(error); -} - -/* - * MPSAFE - */ -int -sys_linux_setresuid16(struct linux_setresuid16_args *args) -{ - struct setresuid_args bsd; - int error; - - bsd.ruid = CAST_NOCHG(args->ruid); - bsd.euid = CAST_NOCHG(args->euid); - bsd.suid = CAST_NOCHG(args->suid); - bsd.sysmsg_result = 0; - - error = sys_setresuid(&bsd); - args->sysmsg_result = bsd.sysmsg_result; - return(error); -} - diff --git a/sys/emulation/linux/linux_util.c b/sys/emulation/linux/linux_util.c deleted file mode 100644 index cdf850750c..0000000000 --- a/sys/emulation/linux/linux_util.c +++ /dev/null @@ -1,219 +0,0 @@ -/* - * Copyright (c) 1994 Christos Zoulas - * Copyright (c) 1995 Frank van der Linden - * Copyright (c) 1995 Scott Bartram - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * from: svr4_util.c,v 1.5 1995/01/22 23:44:50 christos Exp - * $FreeBSD: src/sys/compat/linux/linux_util.c,v 1.12.2.2 2001/11/05 19:08:23 marcel Exp $ - * $DragonFly: src/sys/emulation/linux/linux_util.c,v 1.14 2006/10/27 04:56:28 dillon Exp $ - */ - -#include -#include -#include -#include -#include -#include - -#include "linux_util.h" - -const char linux_emul_path[] = "/compat/linux"; - -/* - * Search for an alternate path before passing pathname arguments on - * to system calls. - * - * Only signal an error if something really bad happens. In most cases - * we can just return the untranslated path, eg. name lookup failures. - */ -int -linux_copyin_path(char *uname, char **kname, int flags) -{ - struct nlookupdata nd, ndroot; - struct vattr vat, vatroot; - struct vnode *vp, *vproot; - char *buf, *cp; - int error, length, dummy, byte; - - buf = (char *) kmalloc(MAXPATHLEN, M_TEMP, M_WAITOK); - *kname = buf; - - /* - * Read a byte and see if uname is a valid address. if not, EFAULT. - */ - byte = fubyte(uname); - if (byte == -1) { - error = EFAULT; - goto done; - } - /* - * Don't bother trying to translate if the path is relative. - */ - if (byte != '/') - goto dont_translate; - - /* - * The path is absolute. Prepend the buffer with the emulation - * path and copy in. - */ - length = strlen(linux_emul_path); - bcopy(linux_emul_path, buf, length); - error = copyinstr(uname, buf + length, MAXPATHLEN - length, &dummy); - if (error) - goto done; - - switch (flags) { - case LINUX_PATH_CREATE: - /* - * Check to see if the parent directory exists in the - * emulation tree. Walk the string backwards to find - * the last '/'. - */ - cp = buf + strlen(buf); - while (--cp >= buf) { - if (*cp == '/') - break; - } - if (cp < buf) - goto dont_translate; - *cp = 0; - - error = nlookup_init(&nd, buf, UIO_SYSSPACE, NLC_FOLLOW); - if (error == 0) - error = nlookup(&nd); - nlookup_done(&nd); - if (error) - goto dont_translate; - *cp = '/'; - return (0); - case LINUX_PATH_EXISTS: - error = nlookup_init(&nd, buf, UIO_SYSSPACE, NLC_FOLLOW); - if (error == 0) - error = nlookup(&nd); - vp = NULL; - if (error == 0) - error = cache_vref(&nd.nl_nch, nd.nl_cred, &vp); - nlookup_done(&nd); - if (error) - goto dont_translate; - - /* - * We now compare the vnode of the linux_root to the one - * vnode asked. If they resolve to be the same, then we - * ignore the match so that the real root gets used. - * This avoids the problem of traversing "../.." to find the - * root directory and never finding it, because "/" resolves - * to the emulation root directory. This is expensive :-( - * - * The next three function calls should not return errors. - * If they do something is seriously wrong, eg. the - * emulation subtree does not exist. Cross our fingers - * and return the untranslated path if something happens. - */ - error = nlookup_init(&ndroot, linux_emul_path, UIO_SYSSPACE, - NLC_FOLLOW); - if (error == 0) - error = nlookup(&ndroot); - vproot = NULL; - if (error == 0) { - error = cache_vref(&ndroot.nl_nch, ndroot.nl_cred, - &vproot); - } - nlookup_done(&ndroot); - if (error) { - vrele(vp); - goto dont_translate; - } - - error = VOP_GETATTR(vp, &vat); - if (error == 0) { - error = VOP_GETATTR(vproot, &vatroot); - if (error == 0) { - if (vat.va_fsid == vatroot.va_fsid && - vat.va_fileid == vatroot.va_fileid) - error = ENOENT; - } - } - vrele(vp); - vrele(vproot); - if (error) - goto dont_translate; - return (0); - default: - error = EINVAL; - goto done; - } - -dont_translate: - error = copyinstr(uname, buf, MAXPATHLEN, &dummy); -done: - if (error) - linux_free_path(kname); - return (error); -} - -/* - * Smaller version of the above for translating in kernel buffers. Only - * used in exec_linux_imgact_try(). Only check is path exists. - */ -int -linux_translate_path(char *path, int size) -{ - struct nlookupdata nd; - char *buf; - int error, length, dummy; - - buf = (char *) kmalloc(MAXPATHLEN, M_TEMP, M_WAITOK); - length = strlen(linux_emul_path); - bcopy(linux_emul_path, buf, length); - error = copystr(path, buf + length, MAXPATHLEN - length, &dummy); - if (error) - goto cleanup; - - /* - * If this errors, then the path probably doesn't exist. - */ - error = nlookup_init(&nd, buf, UIO_SYSSPACE, NLC_FOLLOW); - if (error == 0) - error = nlookup(&nd); - nlookup_done(&nd); - if (error) { - error = 0; - goto cleanup; - } - - /* - * The alternate path does exist. Return it in the buffer if - * it fits. - */ - if (strlen(buf) + 1 <= size) - error = copystr(buf, path, size, &dummy); - -cleanup: - - kfree(buf, M_TEMP); - return (error); -} diff --git a/sys/emulation/linux/linux_util.h b/sys/emulation/linux/linux_util.h deleted file mode 100644 index 8d1e0fb627..0000000000 --- a/sys/emulation/linux/linux_util.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 1994 Christos Zoulas - * Copyright (c) 1995 Frank van der Linden - * Copyright (c) 1995 Scott Bartram - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * 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 - * $FreeBSD: src/sys/compat/linux/linux_util.h,v 1.12.2.2 2000/11/02 23:31:28 obrien Exp $ - * $DragonFly: src/sys/emulation/linux/linux_util.h,v 1.12 2008/09/28 05:08:16 dillon Exp $ - */ - -/* - * This file is pretty much the same as Christos' svr4_util.h - * (for now). - */ - -#ifndef _LINUX_UTIL_H_ -#define _LINUX_UTIL_H_ - -#include -#include -#include -#include -#include -#include -#include - -#define LINUX_PATH_CREATE 1 -#define LINUX_PATH_EXISTS 2 - -int linux_translate_path(char *, int); -int linux_copyin_path(char *, char **, int); - -static __inline void -linux_free_path(char **kname) { - if (*kname) { - kfree(*kname, M_TEMP); - *kname = NULL; - } -} - -static __inline caddr_t stackgap_init(void); -static __inline void *stackgap_alloc(caddr_t *, size_t); - -#define szsigcode(p) (*((p)->p_sysent->sv_szsigcode)) - -static __inline caddr_t -stackgap_init(void) -{ - return (caddr_t)(PS_STRINGS - szsigcode(curproc) - SPARE_USRSPACE); -} - -static __inline void * -stackgap_alloc(caddr_t *sgp, size_t sz) -{ - void *p = (void *) *sgp; - - sz = ALIGN(sz); - if (*sgp + sz > (caddr_t)(PS_STRINGS - szsigcode(curproc))) - return NULL; - *sgp += sz; - return p; -} - -#define DUMMY(s) \ -int \ -sys_linux_ ## s(struct linux_ ## s ## _args *args) \ -{ \ - return (unsupported_msg(#s)); \ -} \ -struct __hack - -static __inline int -unsupported_msg(const char *fname) -{ - struct thread *td = curthread; - if (td->td_proc) { - kprintf( - "linux: syscall %s is obsoleted or not implemented (pid=%d)\n", - fname, (int)td->td_proc->p_pid - ); - } else { - kprintf( - "linux: syscall %s is obsoleted or not implemented (td=%p)\n", - fname, td - ); - } - return (ENOSYS); -} - -#define INO64TO32(v64) ((l_ulong)(v64) ^ (l_ulong)((v64) >> 32)) - -#endif /* !_LINUX_UTIL_H_ */ diff --git a/usr.bin/truss/Makefile b/usr.bin/truss/Makefile index 23536579af..37e02ccd0f 100644 --- a/usr.bin/truss/Makefile +++ b/usr.bin/truss/Makefile @@ -2,26 +2,15 @@ PROG= truss SRCS= main.c setup.c syscalls.c syscalls.h ioctl.c ${MACHINE_ARCH}-fbsd.c -.if (${MACHINE_ARCH} == "i386") -SRCS+= i386-linux.c linux_syscalls.h -.endif CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../../sys CFLAGS+= -I${.CURDIR}/../../sys/dev/drm/include -I. CFLAGS+= -I${.CURDIR}/../../sys/contrib/dev/acpica/source/include -CLEANFILES+=i386l-syscalls.master syscalls.master linux_syscalls.h \ - syscalls.h ioctl.c +CLEANFILES+=syscalls.master syscalls.h ioctl.c .SUFFIXES: .master -i386l-syscalls.master: ${.CURDIR}/../../sys/emulation/linux/i386/syscalls.master - cp ${.ALLSRC} i386l-syscalls.master - -linux_syscalls.h: i386l-syscalls.master - /bin/sh ${.CURDIR}/../../sys/kern/makesyscalls.sh i386l-syscalls.master \ - ${.CURDIR}/i386linux.conf - syscalls.master: ${.CURDIR}/../../sys/kern/syscalls.master cp ${.ALLSRC} syscalls.master diff --git a/usr.bin/truss/extern.h b/usr.bin/truss/extern.h index 12f33d2d92..4f6359ed13 100644 --- a/usr.bin/truss/extern.h +++ b/usr.bin/truss/extern.h @@ -43,12 +43,6 @@ extern int setup_and_wait(char **); extern int start_tracing(int, int); extern void restore_proc(int); extern const char *ioctlname(register_t val); -#ifdef __i386__ -extern void i386_syscall_entry(struct trussinfo *, int); -extern int i386_syscall_exit(struct trussinfo *, int); -extern void i386_linux_syscall_entry(struct trussinfo *, int); -extern int i386_linux_syscall_exit(struct trussinfo *, int); -#endif #ifdef __x86_64__ extern void x86_64_syscall_entry(struct trussinfo *, int); extern int x86_64_syscall_exit(struct trussinfo *, int); diff --git a/usr.bin/truss/i386-linux.c b/usr.bin/truss/i386-linux.c deleted file mode 100644 index 535a29bbd9..0000000000 --- a/usr.bin/truss/i386-linux.c +++ /dev/null @@ -1,260 +0,0 @@ -/* - * Copryight 1997 Sean Eric Fagan - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Sean Eric Fagan - * 4. Neither the name of the author may be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * 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. - * - * $FreeBSD: src/usr.bin/truss/i386-linux.c,v 1.7.2.4 2002/02/15 11:43:51 des Exp $ - * $DragonFly: src/usr.bin/truss/i386-linux.c,v 1.5 2007/12/27 00:59:25 nth Exp $ - */ - -/* - * Linux/i386-specific system call handling. Given how much of this code - * is taken from the freebsd equivalent, I can probably put even more of - * it in support routines that can be used by any personality support. - */ - -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "truss.h" -#include "extern.h" -#include "syscall.h" - -static int fd = -1; -static int cpid = -1; - -#include "linux_syscalls.h" - -static int nsyscalls = - sizeof(linux_syscallnames) / sizeof(linux_syscallnames[0]); - -/* See the comment in i386-fbsd.c about this structure. */ -static struct linux_syscall { - struct syscall *sc; - const char *name; - int number; - unsigned long args[5]; - int nargs; /* number of arguments -- *not* number of words! */ - char **s_args; /* the printable arguments */ -} lsc; - -static inline void -clear_lsc(void) { - if (lsc.s_args) { - int i; - for (i = 0; i < lsc.nargs; i++) - if (lsc.s_args[i]) - free(lsc.s_args[i]); - free(lsc.s_args); - } - memset(&lsc, 0, sizeof(lsc)); -} - -void -i386_linux_syscall_entry(struct trussinfo *trussinfo, int nargs) { - char *buf; - struct reg regs = { .r_err = 0 }; - int syscall_num; - int i; - struct syscall *sc; - - if (fd == -1 || trussinfo->pid != cpid) { - asprintf(&buf, "%s/%d/regs", procfs_path, trussinfo->pid); - if (buf == NULL) - err(1, "Out of memory"); - fd = open(buf, O_RDWR); - free(buf); - if (fd == -1) { - fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n"); - return; - } - cpid = trussinfo->pid; - } - - clear_lsc(); - lseek(fd, 0L, 0); - i = read(fd, ®s, sizeof(regs)); - syscall_num = regs.r_eax; - - lsc.number = syscall_num; - lsc.name = - (syscall_num < 0 || syscall_num >= nsyscalls) ? NULL : linux_syscallnames[syscall_num]; - if (!lsc.name) { - fprintf (trussinfo->outfile, "-- UNKNOWN SYSCALL %d\n", syscall_num); - } - - if (nargs == 0) - return; - - /* - * Linux passes syscall arguments in registers, not - * on the stack. Fortunately, we've got access to the - * register set. Note that we don't bother checking the - * number of arguments. And what does linux do for syscalls - * that have more than five arguments? - */ - - lsc.args[0] = regs.r_ebx; - lsc.args[1] = regs.r_ecx; - lsc.args[2] = regs.r_edx; - lsc.args[3] = regs.r_esi; - lsc.args[4] = regs.r_edi; - - sc = get_syscall(lsc.name); - if (sc) { - lsc.nargs = sc->nargs; - } else { -#ifdef DEBUG - fprintf(trussinfo->outfile, "unknown syscall %s -- setting args to %d\n", - lsc.name, nargs); -#endif - lsc.nargs = nargs; - } - - lsc.s_args = malloc((1+lsc.nargs) * sizeof(char*)); - memset(lsc.s_args, 0, lsc.nargs * sizeof(char*)); - lsc.sc = sc; - - if (lsc.name) { - -#ifdef DEBUG - fprintf(stderr, "syscall %s(", lsc.name); -#endif - for (i = 0; i < lsc.nargs ; i++) { -#ifdef DEBUG - fprintf(stderr, "0x%x%s", - sc ? - lsc.args[sc->args[i].offset] - : lsc.args[i], - i < (lsc.nargs - 1) ? "," : ""); -#endif - if (sc && !(sc->args[i].type & OUT)) { - lsc.s_args[i] = print_arg(Procfd, &sc->args[i], lsc.args); - } - } -#ifdef DEBUG - fprintf(stderr, ")\n"); -#endif - } - - if (!strcmp(lsc.name, "linux_execve") || !strcmp(lsc.name, "exit")) { - print_syscall(trussinfo, lsc.name, lsc.nargs, lsc.s_args); - } - - return; -} - -/* - * Linux syscalls return negative errno's, we do positive and map them - */ -const int bsd_to_linux_errno[] = { - -0, -1, -2, -3, -4, -5, -6, -7, -8, -9, - -10, -35, -12, -13, -14, -15, -16, -17, -18, -19, - -20, -21, -22, -23, -24, -25, -26, -27, -28, -29, - -30, -31, -32, -33, -34, -11,-115,-114, -88, -89, - -90, -91, -92, -93, -94, -95, -96, -97, -98, -99, - -100,-101,-102,-103,-104,-105,-106,-107,-108,-109, - -110,-111, -40, -36,-112,-113, -39, -11, -87,-122, - -116, -66, -6, -6, -6, -6, -6, -37, -38, -9, - -6, -}; - -int -i386_linux_syscall_exit(struct trussinfo *trussinfo, int syscall_num __unused) { - char *buf; - struct reg regs; - int retval; - int i; - int errorp; - struct syscall *sc; - - if (fd == -1 || trussinfo->pid != cpid) { - asprintf(&buf, "%s/%d/regs", procfs_path, trussinfo->pid); - if (buf == NULL) - err(1, "Out of memory"); - fd = open(buf, O_RDONLY); - free(buf); - if (fd == -1) { - fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n"); - return 0; - } - cpid = trussinfo->pid; - } - - lseek(fd, 0L, 0); - if (read(fd, ®s, sizeof(regs)) != sizeof(regs)) { - fprintf(trussinfo->outfile, "\n"); - return 0; - } - - retval = regs.r_eax; - errorp = !!(regs.r_eflags & PSL_C); - - sc = lsc.sc; - if (!sc) { - for (i = 0; i < lsc.nargs; i++) { - lsc.s_args[i] = malloc(12); - sprintf(lsc.s_args[i], "0x%lx", lsc.args[i]); - } - } else { - for (i = 0; i < sc->nargs; i++) { - char *temp; - if (sc->args[i].type & OUT) { - if (errorp) { - temp = malloc(12); - sprintf(temp, "0x%lx", lsc.args[sc->args[i].offset]); - } else { - temp = print_arg(Procfd, &sc->args[i], lsc.args); - } - lsc.s_args[i] = temp; - } - } - } - if (errorp) { - for (i = 0; i < (int)(sizeof(bsd_to_linux_errno) / sizeof(int)); i++) - if (retval == bsd_to_linux_errno[i]) - break; - } - print_syscall_ret(trussinfo, lsc.name, lsc.nargs, lsc.s_args, errorp, - errorp ? i : retval); - clear_lsc(); - return (retval); -} diff --git a/usr.bin/truss/i386linux.conf b/usr.bin/truss/i386linux.conf deleted file mode 100644 index 4f66bbe7dd..0000000000 --- a/usr.bin/truss/i386linux.conf +++ /dev/null @@ -1,12 +0,0 @@ -sysnames="linux_syscalls.h" -sysproto="/dev/null" -sysunion="/dev/null" -sysproto_h="/dev/null" -syshdr="/dev/null" -sysmk="/dev/null" -syssw="/dev/null" -sysargs="/dev/null" -syscallprefix="SYS_" -switchname="sysent" -namesname="linux_syscallnames" - diff --git a/usr.bin/truss/syscalls.c b/usr.bin/truss/syscalls.c index 96448e621b..451c004a6f 100644 --- a/usr.bin/truss/syscalls.c +++ b/usr.bin/truss/syscalls.c @@ -67,8 +67,6 @@ struct syscall syscalls[] = { { { Hex, 0 }, {Int, 1}, {Hex, 2}, {Hex, 3}, {Int, 4}, {Quad, 6}}}, { "open", 1, 3, { { String | IN, 0} , { Hex, 1}, {Octal, 2}}}, - { "linux_open", 1, 3, - { { String, 0 }, { Hex, 1}, { Octal, 2 }}}, { "close", 1, 1, { { Int, 0 } } }, { "fstat", 1, 2, { { Int, 0}, {Ptr | OUT , 1 }}}, @@ -76,10 +74,6 @@ struct syscall syscalls[] = { { { String | IN, 0 }, { Ptr | OUT, 1 }}}, { "lstat", 1, 2, { { String | IN, 0 }, { Ptr | OUT, 1 }}}, - { "linux_newstat", 1, 2, - { { String | IN, 0 }, { Ptr | OUT, 1 }}}, - { "linux_newfstat", 1, 2, - { { Int, 0 }, { Ptr | OUT, 1 }}}, { "write", 1, 3, { { Int, 0}, { Ptr | IN, 1 }, { Int, 2 }}}, { "ioctl", 1, 3, -- 2.11.4.GIT