--- /dev/null
+.PHONY: clear
+EXTRA = -m64
+
+#TEST_CASES := $(wildcard test*.c)
+
+#TEST_TARGETS := $(wildcard (test*).c)
+
+all: devfile_hc.o test_preload devfile_host.ko libdevfile_hcall.a devfile_preload.so
+
+libdevfile_hcall.a: devfile_hc.o
+ ar ruv libdevfile_hcall.a devfile_hc.o
+
+devfile_hc.o: devfile_hc.c devfile_hc.h hcall.h
+ gcc $(EXTRA) -g -static -fPIC -S devfile_hc.c -o devfile_hc.s
+ gcc $(EXTRA) -g -static -fPIC -c devfile_hc.c -o devfile_hc.o
+
+devfile_preload.so: devfile_preload.c libdevfile_hcall.a
+ gcc $(EXTRA) -Wall -O2 -fPIC -shared -I/usr/include devfile_preload.c -L. -ldevfile_hcall -ldl -lc -o devfile_preload.so
+
+EXTRA_CFLAGS += -I$(PWD)/../../../palacios/include
+
+obj-m += devfile_host.o
+
+devfile_host.ko: devfile_host.c
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
+
+test_preload: test_preload.c
+ gcc $(EXTRA) -Wall -g test_preload.c -o test_preload
+
+clean:
+ rm *.o *.so *.a *.ko test_preload *.out *.symvers *.mod.c *.s *.order
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
+
+clear:
+ rm test_ld_lib *.o *.mod.o *.out *.symvers *.mod.c *.s *.order
--- /dev/null
+Device File Palacios Extension
+
+Akhil Guliani and William Gross
+(Advised by Peter Dinda)
+Northwestern University
+
+What Is This?
+
+This is a proof-of-concept implementation of device file
+virtualization in the spirit of the Paradice system. Unlike Paradice,
+it is implemented using only a preload library in the guest (no guest
+modifications) and a kernel module in the host (no kernel
+modifications). Also, there are no modifications to the Palacios
+VMM either, as the core mechanisms used are the host hypercall
+interface and the user-level guest memory access capabilities
+implemented within Palacios.
+
+Note that it is a proof of concept. It does not do many of the things
+that Paradice can do. For example, a hypercall currently involves a
+hard stop of the guest core. Address space integration in the shadow
+process is page granularity only. Pointer detection for system call
+forwarding is done at a coarse granularity, meaning that ioctls would
+need ot be hand coded. Select across guest and host fds is
+completely ignored.
+
+Theory of Operation
+
+The basic idea is that we introduce a preload library into a guest
+process. This library hijacks system calls. When you open a /dev
+device that is in the list of devices we are proxying, the libraryio
+handles the open by converting it to a hypercall, and binding the
+result of the "open" hypercall and the fd returned. On subsequent
+system calls involving the fd, the system calls are also converted to
+hypercalls. The preload library merges fds/syscalls handled by the
+guest and those handled by the host. The preload library also assures
+that any data accessed is touched (page table entry exists), and could
+pin it (currently does not). It also limits any pointer argument to
+point to an block that fits within one page (e.g., read(1K offset,
+4K length) turns into read(1K offset, 3K length).
+
+The hypercall is directed to the second component, a kernel module.
+The kernel module swizzles pointers involved in the system call from
+their GVAs to their GPAs. It then queues them for interaction with
+host user space process called the shadow process. The kernel module
+and the shadow share a page used to transfer the system call arguments
+and the return value and errno. The kernel module signals the shadow
+that a new swizzled system call is available by letting a poll/select
+complete. The shadow signals the kernel module that it is finished
+with the system call via an ioctl.
+
+The shadow process maps the guest's physical memory into its address
+space using the guest memory access mechanisms. It then goes into a
+select waiting for the kernel module. When it receives a system call
+from the kernel module, it swizzles any pointer arguments in the
+system call from their GPAs (provided by the kernel module) to their
+corresponding HVAs (where the guest is mapped). It then issues the
+system call, and writes back on the shared page both the return code
+and the current errno value. It then signals completion via the
+ioctl.
+
+The kernel module then returns from the hypercall to palacios, which
+returns to the guest preload library, which copies out the relevant
+results so that it appears that a system call has completed (on the
+guest).
+
+Note that this model can be potentailly also be used as a general
+system call forwarding mechanism.
+
+What's Here and There
+
+In this directory (palacios/gears/services/devfile) you will find the
+prelaod library and the kernel module. There is also a simple test
+program for the guest.. In the palacios user space directory
+(palacios/linux_usr), you will find the shadow process code. The
+latter is separate as it has dependencies on the guest memory access
+library and build config.
+
+In palacios/gears/services/devfile/scripts, you will find scripts
+which may help to evaluate the system.
+
+
+General Setup
+
+[root@v-test-r415-3 linux_usr]# ./v3_devfile_shadow
+v3_devfile_shadow <vm_device>
+
+Shadow process to support device file-level virtualization
+in the spirit of Paradice.
+
+This operates with the devfile_host.ko kernel module
+in the host and devfile_preload.so preload library in
+the guest. These can be found, along with example scripts
+in palacios/gears/services/devfile.
+
+The general steps are:
+ 1. insmod kernel module into host
+ 2. copy preload library into guest
+ 3. instantiate guest
+ 4. use v3_hypercall to bind the devfile hypercall (99993)
+ to the kernel module for your guest
+ 5. run v3_devfile_shadow
+ 6. run process in guest that uses preload library
+
+
+****Scripts and More Detail Below****
+
+Setup:
+
+Copy the patched_start_guest, patched_mem_script,
+patched_insert_hypercall, and patched_view_console to the top of the
+palacios directory then cd to the to top of the directory so that you
+are at path/to/palacios/ and the scripts are at
+path/to/palacios/patched_*
+
+
+
+Guest Requirements:
+
+For this system to work, the guest needs a couple things. It needs to
+be configured with a CGA console (to get v3_console to work). It needs
+to have sufficient memory (1024kb seems to work). It needs to accept
+an LD_PRELOAD library. It needs to be an x86_64 architecture OS. It
+needs to be running a Linux kernel. It needs a second drive set up as
+a CD-ROM. Once that second drive is set up, replace the backing file
+with a handmade loopback file system (perhaps using dd). For our
+scripts to work exactly, this handmade file system should be called
+littlefs.dat and an empty directory (for mounting) should be present
+in the guest folder called tmp. The scripts are short and few, so the
+relevant paths in them can be modified as necessary to fit your setup.
+
+
+
+Start Guest with Device File Forwarding:
+
+in that terminal source patched_mem_script in other terminal go to the
+same position and source insert_hypercall if the terminal doesn't open
+into the guest, resize your terminal appropriately and then source
+patched_view_console and then from the guest do the following
+
+mkdir mnt
+mount /dev/hdb mnt
+cd /mnt/dev_file
+source load_lib_in_guest
+./test_preload
+EXAMPLE: ./test_preload r 10 /dev/urandom
+
+This will attempt to read 10 bytes from /dev/urandom, where /dev/urandom
+is a host device.
+
+If that last argument (/dev/urandom)is present in the
+devfile_preload.c library, then the system will access the host
+version of that device, if not it will just perform the regular system
+calls on the guest's version of that device if it is present.
+
+
+Close Running Guest with Device File Forwarding:
+
+To shut down smoothly kill the shadow process run from the first
+terminal (patched_mem_script) make sure the second terminal has left
+the guest by pressing \ then in either terminal source
+patched_close_guest
+
+
+Adding Host Devices in /dev to the list of Supported Devices:
+
+go to path/to/palacios/gears/services/devfile
+edit guest_devices.txt
+then run from the command line 'python guest_device_setup.py'
+
+this will update the dev_file_ld_lib.c file, which can be made from
+that directory the object file is copied over to the guests /dev/hdb
+drive within the patched_mem_script NOTE: Adding devices requires the
+preload library (devfile_preload.c) to be made and copied to the guest
+so, they cannot be added while a guest is running with this
+feature. Close the guest first, add the new device changes, run the
+python script, make the /gears/services/dev_file directory, start the
+guest.
+
+
+
+Extending the System Call Interface:
+
+devfile_preload.c is the LD_PRELOAD library for the guest that hijacks
+some basic system calls to see if they should be forwarded to the
+host. To support a broader range of devices, this basic set can be
+added to. Any addition should follow a similar structure to the read
+or write system call in there. The things to make sure are that all
+pointer arguments get pinned into memory and that the file descriptor
+argument is checked against the set of active fds in the dtrack struct
+(also in the library file).
--- /dev/null
+/*
+ Device File Virtualization Guest Preload Library Helpers
+
+ (c) Akhil Guliani and William Gross, 2015
+
+ Adapted from MPI module (c) 2012 Peter Dinda
+
+*/
+
+#define MAX_DEV_NAME_LENGTH 80
+#define MAX_DEVICES 100
+
+//PYTHONSCRIPTBREAK1
+#define DEV_COUNT 9
+//PYTHONSCRIPTBREAK2
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <errno.h>
+
+
+
+#define MIN(a,b) \
+ ({ __typeof__ (a) _a = (a); \
+ __typeof__ (b) _b = (b); \
+ _a < _b ? _a : _b; })
+
+
+char *strcpy(char *dest, const char *src)
+{
+ unsigned i;
+ for (i=0; src[i] != '\0'; ++i)
+ dest[i] = src[i];
+ dest[i] = '\0';
+ return dest;
+}
+
+size_t strlen(const char * str)
+{
+ const char *s;
+ for (s = str; *s; ++s) {}
+ return(s - str);
+}
+
+
+//taken from: https://stuff.mit.edu/afs/sipb/project/tcl80/src/tcl8.0/compat/strstr.c
+char* strstr(const char* string,char* substring)
+ // register char *string; /* String to search. */
+ // char *substring; /* Substring to try to find in string. */
+{
+ register char *a, *b;
+
+ /* First scan quickly through the two strings looking for a
+ * * single-character match. When it's found, then compare the
+ * * rest of the substring.
+ * */
+
+ b = substring;
+ if (*b == 0) {
+ return (char*)string;
+ }
+ for ( ; *string != 0; string += 1) {
+ if (*string != *b) {
+ continue;
+ }
+ a = (char*)string;
+ while (1) {
+ if (*b == 0) {
+ return (char*)string;
+ }
+ if (*a++ != *b++) {
+ break;
+ }
+ }
+ b = substring;
+ }
+ return (char *) 0;
+}
+
+
+//Used to keep track of the active file descriptor for the supported devices
+//Initially the fd is -1 to indicate that the device has not yet been opened
+typedef struct dev_file_fd_tracker {
+ char devName[MAX_DEV_NAME_LENGTH];
+ int devFD;
+} dev_tracker;
+
+
+dev_tracker dtrack[] = {
+//PYTHONSCRIPTBREAK3
+{"/dev/urandom",-1},
+{"/dev/input/mouse0",-1},
+{"/dev/input/event0",-1},
+{"/dev/input/event1",-1},
+{"/dev/ttyS0",-1},
+{"/dev/ttyS1",-1},
+{"/dev/ttyS2",-1},
+{"/dev/ttyS3",-1},
+{"/dev/newDevice",-1}
+//PYTHONSCRIPTBREAK4
+
+};
+
+//returns -1, means no match is found
+//other than -1, is the index in the dtracker array of the match
+int check_name(const char* path, dev_tracker tracker[]){
+ int i;
+ for(i=0; i<DEV_COUNT; i++){
+ if (strstr(path,tracker[i].devName)!=NULL){
+ return i;
+ }
+ }
+ return -1;
+}
+//returns -1, means no match found
+//other than -1, is the index in the dtracker array of the match
+int check_fd(int fd, dev_tracker tracker[]){
+ int i;
+ for(i=0; i<DEV_COUNT; i++){
+ if(tracker[i].devFD == fd){
+ return i;
+ }
+ }
+ return -1;
+}
+
+
+
--- /dev/null
+/*
+ Device File Virtualization Guest Preload Library Helpers
+
+ (c) Akhil Guliani and William Gross, 2015
+
+ Adapted from MPI module (c) 2012 Peter Dinda
+
+*/
+
+#ifndef __x86_64__
+#define __x86_64__
+#endif
+
+#include <stdio.h>
+#include "hcall.h"
+#include "devfile_hc.h"
+
+
+#include "sys_point_arr.h"
+
+int dev_file_syscall_hcall(long long sys_code,
+ long long a1, long long a2, long long a3, long long a4,
+ long long a5, long long a6, long long *sys_errno)
+{
+ long long rc;
+ long long cmd = DEV_FILE_HCALL;
+ long long bit_vec = sys_pointer_arr[sys_code];
+ // Here, IOCTL needs to be handled specially because what
+ // arguments are pointes, etc, depends on the device
+ DEBUG_PRINT("Initiate syscall hypercall, code: %llu\n",sys_code);
+ HCALL(rc,cmd,sys_code,a1,a2,a3,a4,a5,a6,bit_vec);
+ *sys_errno = cmd;
+ DEBUG_PRINT("Syscall Hypercall done: rc = %llx errno = %llx\n",rc, *sys_errno);
+ return rc;
+}
--- /dev/null
+/*
+ Device File Virtualization Guest Preload Library Helpers
+
+ (c) Akhil Guliani and William Gross, 2015
+
+ Adapted from MPI module (c) 2012 Peter Dinda
+
+*/
+
+#define DEV_FILE_HCALL 99993
+
+#include "syscall_ref.h"
+
+#ifndef __KERNEL__
+
+#define DEBUG 1
+#if DEBUG
+#define DEBUG_PRINT(fmt,args...) fprintf(stderr,(fmt),##args)
+#else
+#define DEBUG_PRINT(fmt,args...)
+#endif
+
+
+int dev_file_syscall_hcall(long long syscode,
+ long long a1, long long a2, long long a3, long long a4,
+ long long a5, long long a6, long long *sys_errno);
+
+#endif // KERNEL
--- /dev/null
+/*
+ Device File Virtualization Host Module
+
+ (c) Akhil Guliani and William Gross, 2015
+
+ Adapted from MPI module (c) 2012 Peter Dinda
+
+ */
+#include <linux/fs.h>
+#include <linux/namei.h>
+#include <linux/version.h>
+#include <linux/file.h>
+#include <linux/spinlock.h>
+#include <linux/uaccess.h>
+#include <linux/module.h>
+
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/mm.h>
+#include <linux/sched.h>
+
+#include <linux/syscalls.h>
+#include <linux/init.h>
+#include <linux/kmod.h>
+#include <linux/delay.h>
+#include <linux/wait.h>
+#include <linux/poll.h>
+
+#include <linux/file.h>
+#include <linux/fcntl.h>
+#include <linux/device.h>
+#include <linux/cdev.h>
+
+#include <asm/uaccess.h>
+
+#include <asm/page.h>
+
+#include <palacios/vm_guest_mem.h>
+#include <interfaces/vmm_host_hypercall.h>
+
+
+#include "devfile_hc.h"
+
+
+#define DEEP_DEBUG 1
+#define SHALLOW_DEBUG 1
+
+#if DEEP_DEBUG
+#define DEEP_DEBUG_PRINT(fmt, args...) printk(("devfile: " fmt), ##args)
+#else
+#define DEEP_DEBUG_PRINT(fmt, args...)
+#endif
+
+#if SHALLOW_DEBUG
+#define SHALLOW_DEBUG_PRINT(fmt, args...) printk(("devfile: " fmt), ##args)
+#else
+#define SHALLOW_DEBUG_PRINT(fmt, args...)
+#endif
+
+
+#define ERROR(fmt, args...) printk(("devfile: " fmt), ##args)
+#define INFO(fmt, args...) printk(("devfile: " fmt), ##args)
+
+#define PRINT_CONSOLE(fmt,args...) printf(("devfile: " fmt),##args)
+
+
+
+
+// Added to make unique id's for IOCTL
+#define MY_MACIG 'G'
+#define INIT_IOCTL _IOR(MY_MACIG, 0, int)
+#define SHADOW_SYSCALL_DONE _IOW(MY_MACIG, 2, int)
+
+#define DEVFILE_NAME "v3-devfile"
+
+static int devfile_major_num = 0;
+static struct class *devfile_class = 0;
+static struct cdev devfile_dev;
+
+
+
+struct devfile_state {
+ void *shared_mem_va;
+ uint64_t shared_mem_uva;
+ uint64_t shared_mem_pa;
+ uint64_t returned_fd;
+
+ wait_queue_head_t user_wait_queue;
+ wait_queue_head_t host_wait_queue;
+
+ enum { WAIT_FOR_INIT, WAIT_ON_GUEST, WAIT_ON_SHADOW} state;
+} ;
+
+// Currently this proof of concept supports a single userland/VM binding
+// and is serially reusable
+static struct devfile_state *state=0;
+
+static inline struct devfile_state *find_matching_state(palacios_core_t core) { return state; }
+
+
+/* Hypercall helpers */
+
+static void get_args_64(palacios_core_t core,
+ struct guest_accessors *acc,
+ uint64_t *a1,
+ uint64_t *a2,
+ uint64_t *a3,
+ uint64_t *a4,
+ uint64_t *a5,
+ uint64_t *a6,
+ uint64_t *a7,
+ uint64_t *a8)
+{
+ *a1 = acc->get_rcx(core);
+ *a2 = acc->get_rdx(core);
+ *a3 = acc->get_rsi(core);
+ *a4 = acc->get_rdi(core);
+ *a5 = acc->get_r8(core);
+ *a6 = acc->get_r9(core);
+ *a7 = acc->get_r10(core);
+ *a8 = acc->get_r11(core);
+}
+
+static void get_args_32(palacios_core_t core,
+ struct guest_accessors *acc,
+ uint64_t *a1,
+ uint64_t *a2,
+ uint64_t *a3,
+ uint64_t *a4,
+ uint64_t *a5,
+ uint64_t *a6,
+ uint64_t *a7,
+ uint64_t *a8)
+{
+ uint64_t rsp;
+ uint32_t temp;
+
+
+ rsp = acc->get_rsp(core);
+
+ acc->read_gva(core,rsp,4,&temp); *a1=temp;
+ acc->read_gva(core,rsp+4,4,&temp); *a2=temp;
+ acc->read_gva(core,rsp+8,4,&temp); *a3=temp;
+ acc->read_gva(core,rsp+12,4,&temp); *a4=temp;
+ acc->read_gva(core,rsp+16,4,&temp); *a5=temp;
+ acc->read_gva(core,rsp+20,4,&temp); *a6=temp;
+ acc->read_gva(core,rsp+24,4,&temp); *a7=temp;
+ acc->read_gva(core,rsp+28,4,&temp); *a8=temp;
+}
+
+static void get_args(palacios_core_t core,
+ struct guest_accessors *acc,
+ uint64_t *a1,
+ uint64_t *a2,
+ uint64_t *a3,
+ uint64_t *a4,
+ uint64_t *a5,
+ uint64_t *a6,
+ uint64_t *a7,
+ uint64_t *a8)
+{
+ uint64_t rbx;
+ uint32_t ebx;
+
+ rbx=acc->get_rbx(core);
+ ebx=rbx&0xffffffff;
+
+ switch (ebx) {
+ case 0x64646464:
+ DEEP_DEBUG_PRINT("64 bit hcall\n");
+ return get_args_64(core,acc,a1,a2,a3,a4,a5,a6,a7,a8);
+ break;
+ case 0x32323232:
+ DEEP_DEBUG_PRINT("32 bit hcall\n");
+ return get_args_32(core,acc,a1,a2,a3,a4,a5,a6,a7,a8);
+ break;
+ default:
+ ERROR("UNKNOWN hcall calling convention\n");
+ break;
+ }
+}
+
+static void put_return(palacios_core_t core,
+ struct guest_accessors *acc,
+ uint64_t rc,
+ uint64_t errno)
+{
+ acc->set_rax(core,rc);
+ acc->set_rbx(core,rc);
+}
+
+/*
+ Convert all hypercall pointer arguments from GVAs to GPAs
+ The host userland is responsible for converting from
+ GVAs to HVAs.
+
+ The assumption here is that any pointer argument
+ points to a structure that does NOT span a page
+ boundary. The guest userland is responsible for
+ assuring that this is the case.
+*/
+static int deref_args(palacios_core_t core,
+ struct guest_accessors *acc,
+ uint64_t* a1, uint64_t* a2, uint64_t* a3, uint64_t* a4, uint64_t* a5,
+ uint64_t* a6, uint64_t bvec)
+{
+ if (bvec & 1){
+ uint64_t a1tmp = *a1;
+ acc->gva_to_gpa(core,a1tmp,a1);
+ }
+ if (bvec & 2){
+ uint64_t a2tmp = *a2;
+ acc->gva_to_gpa(core,a2tmp,a2);
+ }
+ if (bvec & 4){
+ uint64_t a3tmp = *a3;
+ acc->gva_to_gpa(core,a3tmp,a3);
+ }
+ if (bvec & 8){
+ uint64_t a4tmp = *a4;
+ acc->gva_to_gpa(core,a4tmp,a4);
+ }
+ if (bvec & 16){
+ uint64_t a5tmp = *a5;
+ acc->gva_to_gpa(core,a5tmp,a5);
+ }
+ if (bvec & 32){
+ uint64_t a6tmp = *a6;
+ acc->gva_to_gpa(core,a6tmp,a6);
+ }
+ return 0;
+}
+
+
+#if 0
+/* Create /dev/v3-devfile in the host */
+
+// User mode helper call to create module private chardev for ioctls
+static int setup_mknod_call(int major_num)
+{
+ //www.ibm.com/developerworks/library/l-user-space-apps/
+ struct subprocess_info *sub_info;
+ char buf[20];
+
+ snprintf(buf,20,"%d",major_num);
+
+ const char *argv[] = { "/bin/mknod", "/dev/" DEVFILE_NAME,"c", buf, "0", NULL };
+ static char *envp[] = { "HOME=/", "TERM=linux", "PATH=/sbin:/bin:/usr/sbin:/usr/bin", NULL };
+
+ sub_info = call_usermodehelper_setup( (char*)argv[0], (char**)argv, envp, GFP_ATOMIC );
+
+ if (sub_info == NULL) {
+ ERROR("failed to create %s\n",DEVFILE_PATH);
+ return -ENOMEM;
+ }
+
+ SHALLOW_DEBUG_PRINT("set up usermode call\n");
+
+ return call_usermodehelper_exec( sub_info, UMH_WAIT_PROC );
+}
+
+#endif
+
+static uint64_t devfile_syscall_return(struct devfile_state *s, uint64_t *errno)
+{
+ uint64_t rc;
+ uint64_t *shared_page = (uint64_t*)(s->shared_mem_va);
+
+ s->state=WAIT_ON_SHADOW;
+
+ // kick the the user if needed
+ //!! IDEA: We can add Usermode Helper to start shadow process instead
+ // and wait for it to send us an ioctl to wake up the module.
+ wake_up_interruptible(&(s->user_wait_queue));
+ // goto sleep until we see a message received
+ // part of a separate ioctl
+ SHALLOW_DEBUG_PRINT("waiting For Shadow Process\n");
+ while (wait_event_interruptible(s->host_wait_queue, (s->state==WAIT_ON_GUEST)) != 0) {}
+ SHALLOW_DEBUG_PRINT("waiting done\n");
+ // Get the returned value and errno
+ rc = *(shared_page +8);
+ *errno = *(shared_page +9);
+
+ SHALLOW_DEBUG_PRINT("waiting done %016llu (errno %016llu)\n",rc,*errno);
+ return rc;
+}
+
+
+static int devfile_syscall_hcall(struct devfile_state *s,
+ palacios_core_t core,
+ uint64_t sys_code,
+ uint64_t a1, uint64_t a2,uint64_t a3,
+ uint64_t a4, uint64_t a5, uint64_t a6,
+ uint64_t bit_vec,
+ uint64_t *errno)
+{
+ //Using shared memory page
+ uint64_t ret;
+ uint64_t *shared_page = (uint64_t*)(s->shared_mem_va);
+
+ *(shared_page +0) = sys_code;
+ *(shared_page +1) = a1;
+ *(shared_page +2) = a2;
+ *(shared_page +3) = a3;
+ *(shared_page +4) = a4;
+ *(shared_page +5) = a5;
+ *(shared_page +6) = a6;
+ *(shared_page +7) = bit_vec;
+
+ SHALLOW_DEBUG_PRINT("Host Module to wait on shadow\n");
+
+ //Now wait for rc and errno to be written to the shared page
+ ret = devfile_syscall_return(s, errno);
+
+ SHALLOW_DEBUG_PRINT("SYSCALL HCALL %016llu (errno %016llu)\n",ret,*errno);
+
+ return ret;
+}
+
+
+
+// The main Interface for Hypercalls
+int devfile_hypercall(palacios_core_t *core,
+ unsigned int hid,
+ struct guest_accessors *acc,
+ void *p)
+{
+ uint64_t a1,a2,a3,a4,a5,a6,bit_vec,sys_code;
+ uint64_t rc;
+ uint64_t errno;
+
+ struct devfile_state *s = find_matching_state(core);
+
+ if (s->state == WAIT_FOR_INIT){
+ SHALLOW_DEBUG_PRINT("Shared Memory Not Yet Initialized, returning syscall hypercall\n");
+ return -1;
+ }
+
+ sys_code = 0;
+ bit_vec = 0;
+
+ DEEP_DEBUG_PRINT("devfile_hypercall(%p,0x%x,%p,%p)\n",
+ core,hid,acc,p);
+
+ get_args(core,acc,&sys_code,&a1,&a2,&a3,&a4,&a5,&a6,&bit_vec);
+
+ DEEP_DEBUG_PRINT("original arguments: %016llu, %016llu, %016llu, %016llu, %016llu, %016llu, %016llu, %016llu\n",
+ sys_code,a1,a2,a3,a4,a5,a6,bit_vec);
+
+ // Convert any pointer arguments from GVAs to GPAs
+ deref_args(core,acc,&a1,&a2,&a3,&a4,&a5,&a6,bit_vec);
+
+ DEEP_DEBUG_PRINT("derefed arguments: %016llu, %016llu, %016llu, %016llu, %016llu, %016llu, %016llu, %016llu\n",
+ sys_code,a1,a2,a3,a4,a5,a6,bit_vec);
+
+ rc = devfile_syscall_hcall(s,core,sys_code,a1,a2,a3,a4,a5,a6,bit_vec,&errno);
+
+ SHALLOW_DEBUG_PRINT("Syscall rc: %016llu errno=%016llu\n",rc,errno);
+
+ put_return(core,acc,rc,errno);
+
+ return 0;
+
+}
+
+
+static int devfile_open(struct inode * inode, struct file * filp)
+{
+ struct devfile_state *s = state;
+
+ if (s) {
+ ERROR("attempting to open devfile that is already open\n");
+ return -EINVAL;
+ }
+
+ s=(struct devfile_state*)kmalloc(sizeof(struct devfile_state),GFP_KERNEL);
+
+ if (!s) {
+ ERROR("Failed to allocate space for open\n");
+ return -EINVAL;
+ }
+
+ // This hideousness is here because in this POC we
+ // are simply allowing a single userland to be tied to
+ // a single VM. At the same time, we are making
+ // the rest of the code more flexible for the future
+ state = s;
+
+ memset(s,0,sizeof(*s));
+
+ init_waitqueue_head(&s->user_wait_queue);
+ init_waitqueue_head(&s->host_wait_queue);
+
+ s->state = WAIT_FOR_INIT;
+
+ filp->private_data = (void*) s;
+
+ return 0;
+}
+
+static int devfile_close(struct inode * inode, struct file * filp)
+{
+ struct devfile_state *s = filp->private_data;
+
+ if (s) {
+ if (s->state==WAIT_ON_SHADOW) {
+ ERROR("Odd, userland is closing devfile while we are waiting for it\n");
+ }
+ kfree(s);
+ state=0;
+ }
+
+ return 0;
+
+}
+
+
+static long devfile_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
+{
+ struct devfile_state *s = filp->private_data;
+
+ switch(cmd) {
+ case INIT_IOCTL:
+ s->shared_mem_pa = (uint64_t)arg;
+ s->shared_mem_va = __va(s->shared_mem_pa);
+ SHALLOW_DEBUG_PRINT("Shared Memory Physical Address: %016llu\n",s->shared_mem_pa);
+ SHALLOW_DEBUG_PRINT("Shared Memory Kernel VA: %p\n",s->shared_mem_va);
+ //Change State to wait on guest
+ s->state = WAIT_ON_GUEST;
+ break;
+
+ case SHADOW_SYSCALL_DONE:
+ s->state = WAIT_ON_GUEST;
+ wake_up_interruptible(&(s->host_wait_queue));
+ break;
+
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+
+}
+
+
+static unsigned int devfile_poll(struct file * filp,
+ struct poll_table_struct * poll_tb)
+{
+ struct devfile_state *s = filp->private_data;
+
+ SHALLOW_DEBUG_PRINT("poll\n");
+
+ // register ourselves on the user wait queue
+ poll_wait(filp, &(s->user_wait_queue), poll_tb);
+
+ if (s->state==WAIT_ON_SHADOW) {
+ // Yes, we have a request if you want it!
+ DEEP_DEBUG_PRINT("poll done immediate\n");
+ return POLLIN | POLLRDNORM;
+ }
+ // No request yet, so we need to wait for one to show up.
+ DEEP_DEBUG_PRINT("poll delayed\n");
+ // We will get called again when that queue is woken up
+
+ return 0;
+}
+
+static struct file_operations devfile_fops = {
+ .open = devfile_open,
+ .release = devfile_close,
+ .poll = devfile_poll,
+ .unlocked_ioctl = devfile_ioctl,
+ .compat_ioctl = devfile_ioctl
+};
+
+EXPORT_SYMBOL(devfile_hypercall);
+
+int init_module(void)
+{
+ dev_t dev;
+
+ SHALLOW_DEBUG_PRINT("INIT\n");
+
+ devfile_class = class_create(THIS_MODULE,"devfile");
+ if (!devfile_class || IS_ERR(devfile_class)) {
+ ERROR("Cannot register devfile device class\n");
+ return PTR_ERR(devfile_class);
+ }
+
+ dev = MKDEV(0,0);
+
+ if (alloc_chrdev_region(&dev,0,1,"devfile")<0) {
+ ERROR("Failed to alloc chrdev region\n");
+ return -1;
+ }
+
+ devfile_major_num = MAJOR(dev);
+
+ dev = MKDEV(devfile_major_num,1);
+
+ cdev_init(&devfile_dev, &devfile_fops);
+ devfile_dev.owner = THIS_MODULE;
+ devfile_dev.ops = &devfile_fops;
+ cdev_add(&devfile_dev, dev, 1);
+
+ device_create(devfile_class, NULL, dev, NULL, "v3-devfile");
+
+#if 0
+ // Setup chardev for IOCTL
+ major = register_chrdev(0,"dfvDev", &fops);
+ if(major < 0){
+ SHALLOW_DEBUG_PRINT("registering dfvDev char device failed with %d\n", major);
+ return major;
+ }
+ SHALLOW_DEBUG_PRINT("assigned major: %d\n", major);
+ SHALLOW_DEBUG_PRINT("creating node with mknod %s c %d 0\n", DEVFILE_PATH, major);
+
+ // Call Helper API function to setup chardev
+ rc = setup_mknod_call(major);
+ SHALLOW_DEBUG_PRINT("UMH api mknod %s c %d 0 -- ret: %d\n\n", DEVFILE_PATH, major,rc);
+
+#endif
+
+ INFO("inited\n");
+
+ return 0;
+}
+
+void cleanup_module(void)
+{
+ dev_t dev = MKDEV(devfile_major_num,1);
+
+ unregister_chrdev_region(MKDEV(devfile_major_num,0),1);
+ cdev_del(&devfile_dev);
+ device_destroy(devfile_class,dev);
+ class_destroy(devfile_class);
+
+#if 0
+ unregister_chrdev(major, "dfvDev");
+#endif
+ if (state) {
+ kfree(state);
+ }
+
+ INFO("deinited\n");
+}
--- /dev/null
+/*
+ Device File Virtualization Guest Preload Library
+
+ (c) Akhil Guliani and William Gross, 2015
+
+ Adapted from MPI module (c) 2012 Peter Dinda
+
+*/
+
+#define _GNU_SOURCE
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <errno.h>
+
+
+
+#include "devfile_hc.h"
+#include "devfile_guest_fd_tracker.h"
+
+static int __LocalFD = 0;
+static int __last_open_index = -1;
+
+
+unsigned long long syscall();
+
+int touch_ptr(volatile char* ptr, int size)
+{
+ int i;
+ for(i=0;i<size;i+=4096){
+ ptr[i] = ptr[i];
+ }
+ return 0;
+}
+
+int open(const char *path, int flags, mode_t mode)
+{
+
+ DEBUG_PRINT("path %s %d %d\n", path, flags, mode);
+
+ __last_open_index = check_name(path,dtrack);
+
+ if (__last_open_index>=0) {
+ DEBUG_PRINT("In our file, \n");
+ __LocalFD = dtrack[__last_open_index].devFD;
+ if(__LocalFD >= 0) {
+ return __LocalFD;
+ } else {
+ // Execute open hypercall here
+ char buf[8192];
+ char* my_path;
+ int path_length = strlen(path)+1;
+ //check if path is across a page boundary
+ //if so try to copy into a local buffer, that doesn't cross a page boundary
+ //if its greater than 4k, fail
+ if (path_length > 4096){
+ DEBUG_PRINT("Path greater than 4k, failing open\n");
+ return -1;
+ }
+ //forcing path to be in a single page
+ my_path = (char*)((((unsigned long long)buf+4096)/4096)*4096);
+ strcpy(my_path,path); // my_path is touched via this
+ long long sys_errno;
+ int rcFD = dev_file_syscall_hcall(SYS64_OPEN,(long long)my_path,flags,0 ,0,0,0,&sys_errno);
+ DEBUG_PRINT(" ReturnFD : %d; \n", rcFD);
+ __LocalFD = rcFD;
+ // set global errno so caller can see
+ errno=sys_errno;
+ return rcFD;
+ }
+ } else {
+ DEBUG_PRINT("performing original open\n");
+
+ return syscall(SYS64_OPEN, path, flags, mode);
+ }
+}
+
+size_t read(int fd, void *buf, size_t count)
+{
+ //does buf+count extend pass page boundary?
+ //if so, only do up to page boundary
+ // if( (buf%4096)+count <= 4096)
+ // normal
+
+ if (fd == __LocalFD || (check_fd(fd,dtrack)>=0)){
+ long long sys_errno;
+ //Need to handle only up to a page boundary, can't handle contiguous pages right now
+ count = MIN(count,4096-((unsigned long long)buf%4096));
+ touch_ptr(buf,count);
+ int ret = dev_file_syscall_hcall(SYS64_READ,fd,(long long)buf,count,0,0,0,&sys_errno);
+ DEBUG_PRINT("Read of %lu bytes returned %d (errno %lld)\n",count,ret,sys_errno);
+ errno = sys_errno;
+ return ret;
+ } else {
+ DEBUG_PRINT("performing original read\n");
+ return syscall(SYS64_READ,fd, buf, count);
+ }
+}
+
+ssize_t write(int fd, const void *buf, size_t count)
+{
+ if (fd == __LocalFD || (check_fd(fd,dtrack)>=0)) {
+ long long sys_errno;
+ //Need to handle only up to a page boundary, can't handle contiguous pages right now
+ count = MIN(count,4096-((unsigned long long)buf%4096));
+ touch_ptr((char*)buf,count);
+ int ret = dev_file_syscall_hcall(SYS64_WRITE,fd, (long long)buf,count,0,0,0,&sys_errno);
+ DEBUG_PRINT("Write of %lu bytes returned %d (errno %lld)\n",count,ret,sys_errno);
+ errno=sys_errno;
+ return ret;
+ } else {
+ DEBUG_PRINT("performing original write\n");
+ return syscall(SYS64_WRITE,fd, buf, count);
+ }
+}
+
+int close(int fd)
+{
+ int index = check_fd(fd,dtrack);
+ if (fd == __LocalFD || (index>=0)) {
+ long long sys_errno;
+ int ret = dev_file_syscall_hcall(SYS64_CLOSE,fd,0,0,0,0,0,&sys_errno);
+ if (ret >=0) {
+ dtrack[index].devFD = -1;
+ __LocalFD = -1;
+ }
+ DEBUG_PRINT("Close returned %d (errno %lld)\n",ret, sys_errno);
+ errno=sys_errno;
+ return ret;
+ } else {
+ DEBUG_PRINT("performing original close\n");
+ return syscall(SYS64_CLOSE,fd);
+ }
+}
+
+
+int ioctl(int fd, int request, void* data) {
+ //int sign_post;
+ int index = check_fd(fd,dtrack);
+
+ // this is where a careful, device-specific decode is needed
+ // to figure out whether the argument or anything it points
+ // is a pointer.
+ if (fd == __LocalFD || (index>=0)) {
+ long long sys_errno=0;
+ int ret;
+ // First cut for just the data pointer:
+ // if (data > &sign_post){
+ //probably on stack
+ // }
+ // if (data < brk()
+ ret = dev_file_syscall_hcall(SYS64_IOCTL,fd,request,(unsigned long long)data,0,0,0,&sys_errno);
+
+ DEBUG_PRINT("ioctl(%d) returned %d (errno %lld)\n",request,ret, sys_errno);
+ errno=sys_errno;
+ return ret;
+ }
+ else{
+ return syscall(SYS64_IOCTL,fd,request,data);
+ }
+ return -1;
+
+}
+
--- /dev/null
+
+
+def main():
+ ff = open("guest_devices.txt",'r')
+
+ count = 0
+ out = ''
+ for line in ff:
+ count+=1
+ this_line = '{\"'+line.strip('\n')+'\",-1},\n'
+ out += this_line
+ out = out.rstrip('\n,')
+ out+="\n"
+ top = "#define DEV_COUNT "+str(count)+"\n"
+
+ ff.close()
+
+ writeable = open("dev_file_guest_fd_tracker.h",'r');
+ lst = writeable.readlines()
+ writeable.close()
+ count = 0
+ for line in lst:
+ count+=1
+ if 'PYTHONSCRIPTBREAK1' in line:
+ index1 = count
+ if 'PYTHONSCRIPTBREAK3' in line:
+ index2 = count
+ if 'PYTHONSCRIPTBREAK4' in line:
+ index3 = count
+
+ lst.pop(index1)
+ lst.insert(index1,top)
+ subcount = index3-2
+ while(subcount>= index2):
+ lst.pop(subcount)
+ subcount-=1
+ lst.insert(index2,out)
+ writeable = open("dev_file_guest_fd_tracker.h",'w');
+ writeable.write(''.join(lst))
+ writeable.close()
+ return
+
+
+if __name__ == "__main__":
+ main()
\ No newline at end of file
--- /dev/null
+/dev/urandom
+/dev/input/mouse0
+/dev/input/event0
+/dev/input/event1
+/dev/ttyS0
+/dev/ttyS1
+/dev/ttyS2
+/dev/ttyS3
+/dev/newDevice
--- /dev/null
+/*
+ Device File Virtualization Guest Preload Library Helpers
+
+ (c) Akhil Guliani and William Gross, 2015
+
+ Adapted from MPI module (c) 2012 Peter Dinda
+
+ Note that the calling convention here is a bit different
+ since we need to return errno
+
+
+*/
+
+#ifndef __HCALL__
+#define __HCALL__
+
+/*
+ Calling convention:
+
+64 bit:
+ rax = hcall number
+ rbx = 0x6464646464646464...
+ rcx = 1st arg
+ rdx = 2nd arg
+ rsi = 3rd arg
+ rdi = 4th arg
+ r8 = 5th arg
+ r9 = 6th arg
+ r10 = 7th arg
+ r11 = 8th arg
+
+32 bit:
+ eax = hcall number
+ ebx = 0x32323232
+ arguments on stack in C order (first argument is TOS)
+ arguments are also 32 bit
+
+In this convention,
+ RAX is assumed to be the return code from the system call
+ RBX is assumed to be the errno set by the system call
+
+ RAX comes back via rc
+ RBX comes back via overwrite of id
+*/
+#define HCALL64(rc,id,a,b,c,d,e,f,g,h) \
+ asm volatile ("movq %1, %%rax; " \
+ "pushq %%rbx; " \
+ "movq $0x6464646464646464, %%rbx; " \
+ "movq %2, %%rcx; " \
+ "movq %3, %%rdx; " \
+ "movq %4, %%rsi; " \
+ "movq %5, %%rdi; " \
+ "movq %6, %%r8 ; " \
+ "movq %7, %%r9 ; " \
+ "movq %8, %%r10; " \
+ "movq %9, %%r11; " \
+ "vmmcall ; " \
+ "movq %%rax, %0; " \
+ "movq %%rbx, %1; " \
+ "popq %%rbx; " \
+ : "=m"(rc),"=m"(id) \
+ : "m"(a), "m"(b), "m"(c), "m"(d), \
+ "m"(e), "m"(f), "m"(g), "m"(h) \
+ : "%rax","%rcx","%rdx","%rsi","%rdi", \
+ "%r8","%r9","%r10","%r11" \
+ )
+
+#define HCALL32(rc,id,a,b,c,d,e,f,g,h) \
+ asm volatile ("movl %1, %%eax; " \
+ "pushl %%ebx; " \
+ "movl $0x32323232, %%ebx; " \
+ "pushl %9;" \
+ "pushl %8;" \
+ "pushl %7;" \
+ "pushl %6;" \
+ "pushl %5;" \
+ "pushl %4;" \
+ "pushl %3;" \
+ "pushl %2;" \
+ "vmmcall ; " \
+ "movl %%eax, %0; " \
+ "movl %%ebx, %1; " \
+ "addl $32, %%esp; " \
+ "popl %%ebx; " \
+ : "=m"(rc), "=m"(id) \
+ : "m"(a), "m"(b), "m"(c), "m"(d), \
+ "m"(e), "m"(f), "m"(g), "m"(h) \
+ : "%eax" \
+ )
+
+#ifdef __x86_64__
+#define HCALL(rc,id,a,b,c,d,e,f,g,h) HCALL64(rc,id,a,b,c,d,e,f,g,h)
+#else
+#define HCALL(rc,id,a,b,c,d,e,f,g,h) HCALL32(rc,id,a,b,c,d,e,f,g,h)
+#endif
+
+#endif
--- /dev/null
+#!/bin/sh
+v3_hypercall /dev/v3-vm0 remove 99993 devfile_hypercall
+v3_stop /dev/v3-vm0
+v3_free 0
+rmmod devfile_host.ko
--- /dev/null
+cd ~/akbill/palacios/guest7/
+mount littlefs.dat tmp
+cp -u ~/akbill/palacios/gears/services/devfile/test_preload tmp/dev_file/.
+cp -u ~/akbill/palacios/gears/services/devfile/devfile_preload.so tmp/dev_file/.
+cp -u ~/akbill/palacios/gears/services/devfile/scripts/load_lib_in_guest tmp/dev_file/.
+echo "Copy done"
+umount tmp
+cd ~/akbill/palacios
--- /dev/null
+#!/bin/sh
+source ENV
+cd ~/akbill/palacios/
+v3_hypercall /dev/v3-vm0 add 99993 devfile_hypercall
+v3_launch /dev/v3-vm0
+v3_console /dev/v3-vm0
--- /dev/null
+#copy the missing library over to correct path
+cd /lib64
+cp /mnt/libtest/libdl.so.2 .
+
+#set LD_PRELOAD correctly
+export LD_PRELOAD=/mnt/dev_file/devfile_preload.so
+
+
+#check if the loader is able to load the LD_library
+./ld-linux-x86-64.so.2 --list /mnt/dev_file/devfile_preload.so
+
+#check if test program gets the ld preload loaded
+./ld-linux-x86-64.so.2 --list /mnt/dev_file/test_preload
+
+# run test program
+cd /mnt/dev_file/
+#./test_preload r 24 /dev/urandom
--- /dev/null
+jobs -p | xargs kill -9
+./close_guest
+./v3_deinit
+cd ~/akbill/palacios/linux_usr
+make clean
+make
+cd ..
+make clean
+make -j 8
+source ENV
+source copy_to_guest
+./v3_init
+cd ~/akbill/palacios/gears/services/dev_file/
+make
+insmod devfile_host.ko
+cd scripts
+source start_guest_persistent
+jobs -l
--- /dev/null
+#!/bin/sh
+v3_hypercall /dev/v3-vm0 remove 99993 devfile_hypercall
+v3_stop /dev/v3-vm0
+v3_free 0
+rmmod devfile_host.ko
--- /dev/null
+cd dev_file_guest
+mount littlefs.dat tmp
+cp -u ../gears/services/devfile/scripts/load_lib_in_guest tmp/dev_file/.
+cp -u ../gears/services/devfile/test_prelaod tmp/dev_file/.
+cp -u ../gears/services/devfile/devfile_preload.so tmp/dev_file/.
+echo "Copy done"
+umount tmp
+cd ..
--- /dev/null
+#!/bin/sh
+source ENV
+v3_hypercall /dev/v3-vm0 add 99993 devfile_hypercall
+v3_launch /dev/v3-vm0
+v3_console /dev/v3-vm0
--- /dev/null
+jobs -p | xargs kill -9
+source patched_close_guest
+./v3_deinit
+cd linux_usr
+make clean
+make
+cd ..
+make clean
+make -j 8
+source ENV
+source gears/services/devfile/scripts/patched_copy_to_guest
+./v3_init
+cd gears/services/devfile/
+make
+insmod devfile_host.ko
+cd ../../..
+source gears/services/dev_ile/patched_start_guest
+jobs -l
--- /dev/null
+cd dev_file_guest
+v3_create -b guest.pal gg
+dev_file_shadow /dev/v3-vm0
+cd ..
--- /dev/null
+#!/bin/sh
+cd guest7
+v3_create -b -u guest7.pal gg
+cd ../dev_file/
+insmod devfile_host.ko
+v3_hypercall /dev/v3-vm0 add 99993 devfile_hypercall
+v3_launch /dev/v3-vm0
+v3_console /dev/v3-vm0
+cd ..
--- /dev/null
+cd guest7
+v3_create -b guest7.pal gg
+v3_devfile_shadow /dev/v3-vm0
+cd ..
--- /dev/null
+int sys_pointer_arr[323] = {
+0,
+0,
+-1,
+0,
+-1,
+0,
+-1,
+1,
+0,
+4,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+0,
+0,
+0,
+0,
+0,
+-1,
+-1,
+3,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+1,
+-1,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+-1,
+0,
+0,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+0,
+0,
+0,
+0,
+-1,
+0,
+0,
+-1,
+-1,
+0,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+0,
+-1,
+0,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+0,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+0,
+-1,
+-1,
+0,
+-1,
+-1,
+0,
+-1,
+-1,
+0,
+-1,
+-1,
+0,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+0,
+-1,
+-1,
+-1,
+0,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+0,
+2,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+0,
+0,
+-1,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+2,
+2,
+1,
+0,
+0,
+0,
+3,
+1,
+-1,
+-1,
+-1,
+2,
+1,
+0,
+0,
+-1,
+0,
+0,
+0,
+-1,
+-1,
+0,
+0,
+0,
+0,
+0,
+-1,
+-1,
+1,
+-1,
+-1,
+0,
+0,
+-1,
+3,
+0,
+-1,
+3,
+-1,
+0,
+0,
+-1,
+0,
+0,
+0,
+-1,
+-1,
+-1,
+-1,
+0,
+-1,
+-1,
+2,
+-1,
+-1,
+-1,
+1,
+-1,
+0
+};
--- /dev/null
+import bs4
+
+#http://blog.rchapman.org/post/36801038863/linux-system-call-table-for-x86-64
+
+def fd_arr():
+ ff = open('syscalltable.txt','r')
+ soup = bs4.BeautifulSoup(ff.read())
+ ff.close()
+ ff = open('sys_fd_arr.h','w')
+
+ len_list = len(list(soup.find_all('tr')))
+ ff.write('int sys_pointer_arr[323] = {\n')
+ for (i,row) in enumerate(list(soup.find_all('tr'))):
+ print str(row.find('td'))[4:len(str(row.find('td')))-5]
+
+ if len(list(row.find_all('td')))>0:
+ candidate = -1
+ for (j,ele) in enumerate(list(row.find_all('td'))[2::]):
+ inner = str(ele)[4:len(str(ele))-5]
+ inner_split = inner.split()
+ for inn in inner_split:
+ if 'fd' in inn:
+ print inner
+ candidate = j
+ if i>=len_list-1:
+ ff.write(str(candidate)+'\n')
+ else:
+ ff.write(str(candidate)+',\n')
+ ff.write('};\n')
+ ff.close()
+ return
+
+def main():
+ ff = open('syscalltable.txt','r')
+ soup = bs4.BeautifulSoup(ff.read())
+ ff.close()
+ ff = open('sys_point_arr.h','w')
+
+ len_list = len(list(soup.find_all('tr')))
+ ff.write('int sys_pointer_arr[323] = {\n')
+ for (i,row) in enumerate(list(soup.find_all('tr'))):
+ print str(row.find('td'))[4:len(str(row.find('td')))-5]
+ bit_vec = ''
+ if len(list(row.find_all('td')))>0:
+ for ele in list(row.find_all('td'))[2::]:
+ inner = str(ele)[4:len(str(ele))-5]
+ if '*' in inner:
+ bit_vec+= '1'
+ elif '' == inner:
+ bit_vec+= '0'
+ else:
+ bit_vec+= '0'
+ bit_vec+='00'
+ print bit_vec[::-1]
+ print int(bit_vec[::-1],2)
+ if i>=len_list-1:
+ ff.write(str(int(bit_vec[::-1],2))+'\n')
+ else:
+ ff.write(str(int(bit_vec[::-1],2))+',\n')
+ ff.write('};\n')
+ ff.close()
+ return
+
+
+if __name__ == "__main__":
+ main()
\ No newline at end of file
--- /dev/null
+<table border=""><tbody><tr><th align="left">%rax</th><th align="left">System call</th><th align="left">%rdi</th><th align="left">%rsi</th><th align="left">%rdx</th><th align="left">%r10</th><th align="left">%r8</th><th align="left">%r9</th></tr><tr><td>0</td><td>sys_read</td><td>unsigned int fd</td><td>char *buf</td><td>size_t count</td><td></td><td></td><td></td></tr><tr><td>1</td><td>sys_write</td><td>unsigned int fd</td><td>const char *buf</td><td>size_t count</td><td></td><td></td><td></td></tr><tr><td>2</td><td>sys_open</td><td>const char *filename</td><td>int flags</td><td>int mode</td><td></td><td></td><td></td></tr><tr><td>3</td><td>sys_close</td><td>unsigned int fd</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>4</td><td>sys_stat</td><td>const char *filename</td><td>struct stat *statbuf</td><td></td><td></td><td></td><td></td></tr><tr><td>5</td><td>sys_fstat</td><td>unsigned int fd</td><td>struct stat *statbuf</td><td></td><td></td><td></td><td></td></tr><tr><td>6</td><td>sys_lstat</td><td>fconst char *filename</td><td>struct stat *statbuf</td><td></td><td></td><td></td><td></td></tr><tr><td>7</td><td>sys_poll</td><td>struct poll_fd *ufds</td><td>unsigned int nfds</td><td>long timeout_msecs</td><td></td><td></td><td></td></tr><tr><td>8</td><td>sys_lseek</td><td>unsigned int fd</td><td>off_t offset</td><td>unsigned int origin</td><td></td><td></td><td></td></tr><tr><td>9</td><td>sys_mmap</td><td>unsigned long addr</td><td>unsigned long len</td><td>unsigned long prot</td><td>unsigned long flags</td><td>unsigned long fd</td><td>unsigned long off</td></tr><tr><td>10</td><td>sys_mprotect</td><td>unsigned long start</td><td>size_t len</td><td>unsigned long prot</td><td></td><td></td><td></td></tr><tr><td>11</td><td>sys_munmap</td><td>unsigned long addr</td><td>size_t len</td><td></td><td></td><td></td><td></td></tr><tr><td>12</td><td>sys_brk</td><td>unsigned long brk</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>13</td><td>sys_rt_sigaction</td><td>int sig</td><td>const struct sigaction *act</td><td>struct sigaction *oact</td><td>size_t sigsetsize</td><td></td><td></td></tr><tr><td>14</td><td>sys_rt_sigprocmask</td><td>int how</td><td>sigset_t *nset</td><td>sigset_t *oset</td><td>size_t sigsetsize</td><td></td><td></td></tr><tr><td>15</td><td>sys_rt_sigreturn</td><td>unsigned long __unused</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>16</td><td>sys_ioctl</td><td>unsigned int fd</td><td>unsigned int cmd</td><td>unsigned long arg</td><td></td><td></td><td></td></tr><tr><td>17</td><td>sys_pread64</td><td>unsigned long fd</td><td>char *buf</td><td>size_t count</td><td>loff_t pos</td><td></td><td></td></tr><tr><td>18</td><td>sys_pwrite64</td><td>unsigned int fd</td><td>const char *buf</td><td>size_t count</td><td>loff_t pos</td><td></td><td></td></tr><tr><td>19</td><td>sys_readv</td><td>unsigned long fd</td><td>const struct iovec *vec</td><td>unsigned long vlen</td><td></td><td></td><td></td></tr><tr><td>20</td><td>sys_writev</td><td>unsigned long fd</td><td>const struct iovec *vec</td><td>unsigned long vlen</td><td></td><td></td><td></td></tr><tr><td>21</td><td>sys_access</td><td>const char *filename</td><td>int mode</td><td></td><td></td><td></td><td></td></tr><tr><td>22</td><td>sys_pipe</td><td>int *filedes</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>23</td><td>sys_select</td><td>int n</td><td>fd_set *inp</td><td>fd_set *outp</td><td>fd_set*exp</td><td>struct timeval *tvp</td><td></td></tr><tr><td>24</td><td>sys_sched_yield</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>25</td><td>sys_mremap</td><td>unsigned long addr</td><td>unsigned long old_len</td><td>unsigned long new_len</td><td>unsigned long flags</td><td>unsigned long new_addr</td><td></td></tr><tr><td>26</td><td>sys_msync</td><td>unsigned long start</td><td>size_t len</td><td>int flags</td><td></td><td></td><td></td></tr><tr><td>27</td><td>sys_mincore</td><td>unsigned long start</td><td>size_t len</td><td>unsigned char *vec</td><td></td><td></td><td></td></tr><tr><td>28</td><td>sys_madvise</td><td>unsigned long start</td><td>size_t len_in</td><td>int behavior</td><td></td><td></td><td></td></tr><tr><td>29</td><td>sys_shmget</td><td>key_t key</td><td>size_t size</td><td>int shmflg</td><td></td><td></td><td></td></tr><tr><td>30</td><td>sys_shmat</td><td>int shmid</td><td>char *shmaddr</td><td>int shmflg</td><td></td><td></td><td></td></tr><tr><td>31</td><td>sys_shmctl</td><td>int shmid</td><td>int cmd</td><td>struct shmid_ds *buf</td><td></td><td></td><td></td></tr><tr><td>32</td><td>sys_dup</td><td>unsigned int fildes</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>33</td><td>sys_dup2</td><td>unsigned int oldfd</td><td>unsigned int newfd</td><td></td><td></td><td></td><td></td></tr><tr><td>34</td><td>sys_pause</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>35</td><td>sys_nanosleep</td><td>struct timespec *rqtp</td><td>struct timespec *rmtp</td><td></td><td></td><td></td><td></td></tr><tr><td>36</td><td>sys_getitimer</td><td>int which</td><td>struct itimerval *value</td><td></td><td></td><td></td><td></td></tr><tr><td>37</td><td>sys_alarm</td><td>unsigned int seconds</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>38</td><td>sys_setitimer</td><td>int which</td><td>struct itimerval *value</td><td>struct itimerval *ovalue</td><td></td><td></td><td></td></tr><tr><td>39</td><td>sys_getpid</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>40</td><td>sys_sendfile</td><td>int out_fd</td><td>int in_fd</td><td>off_t *offset</td><td>size_t count</td><td></td><td></td></tr><tr><td>41</td><td>sys_socket</td><td>int family</td><td>int type</td><td>int protocol</td><td></td><td></td><td></td></tr><tr><td>42</td><td>sys_connect</td><td>int fd</td><td>struct sockaddr *uservaddr</td><td>int addrlen</td><td></td><td></td><td></td></tr><tr><td>43</td><td>sys_accept</td><td>int fd</td><td>struct sockaddr *upeer_sockaddr</td><td>int *upeer_addrlen</td><td></td><td></td><td></td></tr><tr><td>44</td><td>sys_sendto</td><td>int fd</td><td>void *buff</td><td>size_t len</td><td>unsigned flags</td><td>struct sockaddr *addr</td><td>int addr_len</td></tr><tr><td>45</td><td>sys_recvfrom</td><td>int fd</td><td>void *ubuf</td><td>size_t size</td><td>unsigned flags</td><td>struct sockaddr *addr</td><td>int *addr_len</td></tr><tr><td>46</td><td>sys_sendmsg</td><td>int fd</td><td>struct msghdr *msg</td><td>unsigned flags</td><td></td><td></td><td></td></tr><tr><td>47</td><td>sys_recvmsg</td><td>int fd</td><td>struct msghdr *msg</td><td>unsigned int flags</td><td></td><td></td><td></td></tr><tr><td>48</td><td>sys_shutdown</td><td>int fd</td><td>int how</td><td></td><td></td><td></td><td></td></tr><tr><td>49</td><td>sys_bind</td><td>int fd</td><td>struct sokaddr *umyaddr</td><td>int addrlen</td><td></td><td></td><td></td></tr><tr><td>50</td><td>sys_listen</td><td>int fd</td><td>int backlog</td><td></td><td></td><td></td><td></td></tr><tr><td>51</td><td>sys_getsockname</td><td>int fd</td><td>struct sockaddr *usockaddr</td><td>int *usockaddr_len</td><td></td><td></td><td></td></tr><tr><td>52</td><td>sys_getpeername</td><td>int fd</td><td>struct sockaddr *usockaddr</td><td>int *usockaddr_len</td><td></td><td></td><td></td></tr><tr><td>53</td><td>sys_socketpair</td><td>int family</td><td>int type</td><td>int protocol</td><td>int *usockvec</td><td></td><td></td></tr><tr><td>54</td><td>sys_setsockopt</td><td>int fd</td><td>int level</td><td>int optname</td><td>char *optval</td><td>int optlen</td><td></td></tr><tr><td>55</td><td>sys_getsockopt</td><td>int fd</td><td>int level</td><td>int optname</td><td>char *optval</td><td>int *optlen</td><td></td></tr><tr><td>56</td><td>sys_clone</td><td>unsigned long clone_flags</td><td>unsigned long newsp</td><td>void *parent_tid</td><td>void *child_tid</td><td></td><td></td></tr><tr><td>57</td><td>sys_fork</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>58</td><td>sys_vfork</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>59</td><td>sys_execve</td><td>const char *filename</td><td>const char *const argv[]</td><td>const char *const envp[]</td><td></td><td></td><td></td></tr><tr><td>60</td><td>sys_exit</td><td>int error_code</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>61</td><td>sys_wait4</td><td>pid_t upid</td><td>int *stat_addr</td><td>int options</td><td>struct rusage *ru</td><td></td><td></td></tr><tr><td>62</td><td>sys_kill</td><td>pid_t pid</td><td>int sig</td><td></td><td></td><td></td><td></td></tr><tr><td>63</td><td>sys_uname</td><td>struct old_utsname *name</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>64</td><td>sys_semget</td><td>key_t key</td><td>int nsems</td><td>int semflg</td><td></td><td></td><td></td></tr><tr><td>65</td><td>sys_semop</td><td>int semid</td><td>struct sembuf *tsops</td><td>unsigned nsops</td><td></td><td></td><td></td></tr><tr><td>66</td><td>sys_semctl</td><td>int semid</td><td>int semnum</td><td>int cmd</td><td>union semun arg</td><td></td><td></td></tr><tr><td>67</td><td>sys_shmdt</td><td>char *shmaddr</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>68</td><td>sys_msgget</td><td>key_t key</td><td>int msgflg</td><td></td><td></td><td></td><td></td></tr><tr><td>69</td><td>sys_msgsnd</td><td>int msqid</td><td>struct msgbuf *msgp</td><td>size_t msgsz</td><td>int msgflg</td><td></td><td></td></tr><tr><td>70</td><td>sys_msgrcv</td><td>int msqid</td><td>struct msgbuf *msgp</td><td>size_t msgsz</td><td>long msgtyp</td><td>int msgflg</td><td></td></tr><tr><td>71</td><td>sys_msgctl</td><td>int msqid</td><td>int cmd</td><td>struct msqid_ds *buf</td><td></td><td></td><td></td></tr><tr><td>72</td><td>sys_fcntl</td><td>unsigned int fd</td><td>unsigned int cmd</td><td>unsigned long arg</td><td></td><td></td><td></td></tr><tr><td>73</td><td>sys_flock</td><td>unsigned int fd</td><td>unsigned int cmd</td><td></td><td></td><td></td><td></td></tr><tr><td>74</td><td>sys_fsync</td><td>unsigned int fd</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>75</td><td>sys_fdatasync</td><td>unsigned int fd</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>76</td><td>sys_truncate</td><td>const char *path</td><td>long length</td><td></td><td></td><td></td><td></td></tr><tr><td>77</td><td>sys_ftruncate</td><td>unsigned int fd</td><td>unsigned long length</td><td></td><td></td><td></td><td></td></tr><tr><td>78</td><td>sys_getdents</td><td>unsigned int fd</td><td>struct linux_dirent *dirent</td><td>unsigned int count</td><td></td><td></td><td></td></tr><tr><td>79</td><td>sys_getcwd</td><td>char *buf</td><td>unsigned long size</td><td></td><td></td><td></td><td></td></tr><tr><td>80</td><td>sys_chdir</td><td>const char *filename</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>81</td><td>sys_fchdir</td><td>unsigned int fd</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>82</td><td>sys_rename</td><td>const char *oldname</td><td>const char *newname</td><td></td><td></td><td></td><td></td></tr><tr><td>83</td><td>sys_mkdir</td><td>const char *pathname</td><td>int mode</td><td></td><td></td><td></td><td></td></tr><tr><td>84</td><td>sys_rmdir</td><td>const char *pathname</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>85</td><td>sys_creat</td><td>const char *pathname</td><td>int mode</td><td></td><td></td><td></td><td></td></tr><tr><td>86</td><td>sys_link</td><td>const char *oldname</td><td>const char *newname</td><td></td><td></td><td></td><td></td></tr><tr><td>87</td><td>sys_unlink</td><td>const char *pathname</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>88</td><td>sys_symlink</td><td>const char *oldname</td><td>const char *newname</td><td></td><td></td><td></td><td></td></tr><tr><td>89</td><td>sys_readlink</td><td>const char *path</td><td>char *buf</td><td>int bufsiz</td><td></td><td></td><td></td></tr><tr><td>90</td><td>sys_chmod</td><td>const char *filename</td><td>mode_t mode</td><td></td><td></td><td></td><td></td></tr><tr><td>91</td><td>sys_fchmod</td><td>unsigned int fd</td><td>mode_t mode</td><td></td><td></td><td></td><td></td></tr><tr><td>92</td><td>sys_chown</td><td>const char *filename</td><td>uid_t user</td><td>git_t group</td><td></td><td></td><td></td></tr><tr><td>93</td><td>sys_fchown</td><td>unsigned int fd</td><td>uid_t user</td><td>git_t group</td><td></td><td></td><td></td></tr><tr><td>94</td><td>sys_lchown</td><td>const char *filename</td><td>uid_t user</td><td>git_t group</td><td></td><td></td><td></td></tr><tr><td>95</td><td>sys_umask</td><td>int mask</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>96</td><td>sys_gettimeofday</td><td>struct timeval *tv</td><td>struct timezone *tz</td><td></td><td></td><td></td><td></td></tr><tr><td>97</td><td>sys_getrlimit</td><td>unsigned int resource</td><td>struct rlimit *rlim</td><td></td><td></td><td></td><td></td></tr><tr><td>98</td><td>sys_getrusage</td><td>int who</td><td>struct rusage *ru</td><td></td><td></td><td></td><td></td></tr><tr><td>99</td><td>sys_sysinfo</td><td>struct sysinfo *info</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>100</td><td>sys_times</td><td>struct sysinfo *info</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>101</td><td>sys_ptrace</td><td>long request</td><td>long pid</td><td>unsigned long addr</td><td>unsigned long data</td><td></td><td></td></tr><tr><td>102</td><td>sys_getuid</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>103</td><td>sys_syslog</td><td>int type</td><td>char *buf</td><td>int len</td><td></td><td></td><td></td></tr><tr><td>104</td><td>sys_getgid</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>105</td><td>sys_setuid</td><td>uid_t uid</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>106</td><td>sys_setgid</td><td>git_t gid</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>107</td><td>sys_geteuid</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>108</td><td>sys_getegid</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>109</td><td>sys_setpgid</td><td>pid_t pid</td><td>pid_t pgid</td><td></td><td></td><td></td><td></td></tr><tr><td>110</td><td>sys_getppid</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>111</td><td>sys_getpgrp</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>112</td><td>sys_setsid</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>113</td><td>sys_setreuid</td><td>uid_t ruid</td><td>uid_t euid</td><td></td><td></td><td></td><td></td></tr><tr><td>114</td><td>sys_setregid</td><td>git_t rgid</td><td>gid_t egid</td><td></td><td></td><td></td><td></td></tr><tr><td>115</td><td>sys_getgroups</td><td>int gidsetsize</td><td>gid_t *grouplist</td><td></td><td></td><td></td><td></td></tr><tr><td>116</td><td>sys_setgroups</td><td>int gidsetsize</td><td>gid_t *grouplist</td><td></td><td></td><td></td><td></td></tr><tr><td>117</td><td>sys_setresuid</td><td>uid_t *ruid</td><td>uid_t *euid</td><td>uid_t *suid</td><td></td><td></td><td></td></tr><tr><td>118</td><td>sys_getresuid</td><td>uid_t *ruid</td><td>uid_t *euid</td><td>uid_t *suid</td><td></td><td></td><td></td></tr><tr><td>119</td><td>sys_setresgid</td><td>gid_t rgid</td><td>gid_t egid</td><td>gid_t sgid</td><td></td><td></td><td></td></tr><tr><td>120</td><td>sys_getresgid</td><td>git_t *rgid</td><td>git_t *egid</td><td>git_t *sgid</td><td></td><td></td><td></td></tr><tr><td>121</td><td>sys_getpgid</td><td>pid_t pid</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>122</td><td>sys_setfsuid</td><td>uid_t uid</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>123</td><td>sys_setfsgid</td><td>gid_t gid</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>124</td><td>sys_getsid</td><td>pid_t pid</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>125</td><td>sys_capget</td><td>cap_user_header_t header</td><td>cap_user_data_t dataptr</td><td></td><td></td><td></td><td></td></tr><tr><td>126</td><td>sys_capset</td><td>cap_user_header_t header</td><td>const cap_user_data_t data</td><td></td><td></td><td></td><td></td></tr><tr><td>127</td><td>sys_rt_sigpending</td><td>sigset_t *set</td><td>size_t sigsetsize</td><td></td><td></td><td></td><td></td></tr><tr><td>128</td><td>sys_rt_sigtimedwait</td><td>const sigset_t *uthese</td><td>siginfo_t *uinfo</td><td>const struct timespec *uts</td><td>size_t sigsetsize</td><td></td><td></td></tr><tr><td>129</td><td>sys_rt_sigqueueinfo</td><td>pid_t pid</td><td>int sig</td><td>siginfo_t *uinfo</td><td></td><td></td><td></td></tr><tr><td>130</td><td>sys_rt_sigsuspend</td><td>sigset_t *unewset</td><td>size_t sigsetsize</td><td></td><td></td><td></td><td></td></tr><tr><td>131</td><td>sys_sigaltstack</td><td>const stack_t *uss</td><td>stack_t *uoss</td><td></td><td></td><td></td><td></td></tr><tr><td>132</td><td>sys_utime</td><td>char *filename</td><td>struct utimbuf *times</td><td></td><td></td><td></td><td></td></tr><tr><td>133</td><td>sys_mknod</td><td>const char *filename</td><td>int mode</td><td>unsigned dev</td><td></td><td></td><td></td></tr><tr><td>134</td><td>sys_uselib</td><td>NOT IMPLEMENTED</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>135</td><td>sys_personality</td><td>unsigned int personality</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>136</td><td>sys_ustat</td><td>unsigned dev</td><td>struct ustat *ubuf</td><td></td><td></td><td></td><td></td></tr><tr><td>137</td><td>sys_statfs</td><td>const char *pathname</td><td>struct statfs *buf</td><td></td><td></td><td></td><td></td></tr><tr><td>138</td><td>sys_fstatfs</td><td>unsigned int fd</td><td>struct statfs *buf</td><td></td><td></td><td></td><td></td></tr><tr><td>139</td><td>sys_sysfs</td><td>int option</td><td>unsigned long arg1</td><td>unsigned long arg2</td><td></td><td></td><td></td></tr><tr><td>140</td><td>sys_getpriority</td><td>int which</td><td>int who</td><td></td><td></td><td></td><td></td></tr><tr><td>141</td><td>sys_setpriority</td><td>int which</td><td>int who</td><td>int niceval</td><td></td><td></td><td></td></tr><tr><td>142</td><td>sys_sched_setparam</td><td>pid_t pid</td><td>struct sched_param *param</td><td></td><td></td><td></td><td></td></tr><tr><td>143</td><td>sys_sched_getparam</td><td>pid_t pid</td><td>struct sched_param *param</td><td></td><td></td><td></td><td></td></tr><tr><td>144</td><td>sys_sched_setscheduler</td><td>pid_t pid</td><td>int policy</td><td>struct sched_param *param</td><td></td><td></td><td></td></tr><tr><td>145</td><td>sys_sched_getscheduler</td><td>pid_t pid</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>146</td><td>sys_sched_get_priority_max</td><td>int policy</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>147</td><td>sys_sched_get_priority_min</td><td>int policy</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>148</td><td>sys_sched_rr_get_interval</td><td>pid_t pid</td><td>struct timespec *interval</td><td></td><td></td><td></td><td></td></tr><tr><td>149</td><td>sys_mlock</td><td>unsigned long start</td><td>size_t len</td><td></td><td></td><td></td><td></td></tr><tr><td>150</td><td>sys_munlock</td><td>unsigned long start</td><td>size_t len</td><td></td><td></td><td></td><td></td></tr><tr><td>151</td><td>sys_mlockall</td><td>int flags</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>152</td><td>sys_munlockall</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>153</td><td>sys_vhangup</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>154</td><td>sys_modify_ldt</td><td>int func</td><td>void *ptr</td><td>unsigned long bytecount</td><td></td><td></td><td></td></tr><tr><td>155</td><td>sys_pivot_root</td><td>const char *new_root</td><td>const char *put_old</td><td></td><td></td><td></td><td></td></tr><tr><td>156</td><td>sys__sysctl</td><td>struct __sysctl_args *args</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>157</td><td>sys_prctl</td><td>int option</td><td>unsigned long arg2</td><td>unsigned long arg3</td><td>unsigned long arg4</td><td></td><td>unsigned long arg5</td></tr><tr><td>158</td><td>sys_arch_prctl</td><td>struct task_struct *task</td><td>int code</td><td>unsigned long *addr</td><td></td><td></td><td></td></tr><tr><td>159</td><td>sys_adjtimex</td><td>struct timex *txc_p</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>160</td><td>sys_setrlimit</td><td>unsigned int resource</td><td>struct rlimit *rlim</td><td></td><td></td><td></td><td></td></tr><tr><td>161</td><td>sys_chroot</td><td>const char *filename</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>162</td><td>sys_sync</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>163</td><td>sys_acct</td><td>const char *name</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>164</td><td>sys_settimeofday</td><td>struct timeval *tv</td><td>struct timezone *tz</td><td></td><td></td><td></td><td></td></tr><tr><td>165</td><td>sys_mount</td><td>char *dev_name</td><td>char *dir_name</td><td>char *type</td><td>unsigned long flags</td><td>void *data</td><td></td></tr><tr><td>166</td><td>sys_umount2</td><td>const char *target</td><td>int flags</td><td></td><td></td><td></td><td></td></tr><tr><td>167</td><td>sys_swapon</td><td>const char *specialfile</td><td>int swap_flags</td><td></td><td></td><td></td><td></td></tr><tr><td>168</td><td>sys_swapoff</td><td>const char *specialfile</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>169</td><td>sys_reboot</td><td>int magic1</td><td>int magic2</td><td>unsigned int cmd</td><td>void *arg</td><td></td><td></td></tr><tr><td>170</td><td>sys_sethostname</td><td>char *name</td><td>int len</td><td></td><td></td><td></td><td></td></tr><tr><td>171</td><td>sys_setdomainname</td><td>char *name</td><td>int len</td><td></td><td></td><td></td><td></td></tr><tr><td>172</td><td>sys_iopl</td><td>unsigned int level</td><td>struct pt_regs *regs</td><td></td><td></td><td></td><td></td></tr><tr><td>173</td><td>sys_ioperm</td><td>unsigned long from</td><td>unsigned long num</td><td>int turn_on</td><td></td><td></td><td></td></tr><tr><td>174</td><td>sys_create_module</td><td>REMOVED IN Linux 2.6</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>175</td><td>sys_init_module</td><td>void *umod</td><td>unsigned long len</td><td>const char *uargs</td><td></td><td></td><td></td></tr><tr><td>176</td><td>sys_delete_module</td><td>const chat *name_user</td><td>unsigned int flags</td><td></td><td></td><td></td><td></td></tr><tr><td>177</td><td>sys_get_kernel_syms</td><td>REMOVED IN Linux 2.6</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>178</td><td>sys_query_module</td><td>REMOVED IN Linux 2.6</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>179</td><td>sys_quotactl</td><td>unsigned int cmd</td><td>const char *special</td><td>qid_t id</td><td>void *addr</td><td></td><td></td></tr><tr><td>180</td><td>sys_nfsservctl</td><td>NOT IMPLEMENTED</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>181</td><td>sys_getpmsg</td><td>NOT IMPLEMENTED</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>182</td><td>sys_putpmsg</td><td>NOT IMPLEMENTED</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>183</td><td>sys_afs_syscall</td><td>NOT IMPLEMENTED</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>184</td><td>sys_tuxcall</td><td>NOT IMPLEMENTED</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>185</td><td>sys_security</td><td>NOT IMPLEMENTED</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>186</td><td>sys_gettid</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>187</td><td>sys_readahead</td><td>int fd</td><td>loff_t offset</td><td>size_t count</td><td></td><td></td><td></td></tr><tr><td>188</td><td>sys_setxattr</td><td>const char *pathname</td><td>const char *name</td><td>const void *value</td><td>size_t size</td><td>int flags</td><td></td></tr><tr><td>189</td><td>sys_lsetxattr</td><td>const char *pathname</td><td>const char *name</td><td>const void *value</td><td>size_t size</td><td>int flags</td><td></td></tr><tr><td>190</td><td>sys_fsetxattr</td><td>int fd</td><td>const char *name</td><td>const void *value</td><td>size_t size</td><td>int flags</td><td></td></tr><tr><td>191</td><td>sys_getxattr</td><td>const char *pathname</td><td>const char *name</td><td>void *value</td><td>size_t size</td><td></td><td></td></tr><tr><td>192</td><td>sys_lgetxattr</td><td>const char *pathname</td><td>const char *name</td><td>void *value</td><td>size_t size</td><td></td><td></td></tr><tr><td>193</td><td>sys_fgetxattr</td><td>int fd</td><td>const har *name</td><td>void *value</td><td>size_t size</td><td></td><td></td></tr><tr><td>194</td><td>sys_listxattr</td><td>const char *pathname</td><td>char *list</td><td>size_t size</td><td></td><td></td><td></td></tr><tr><td>195</td><td>sys_llistxattr</td><td>const char *pathname</td><td>char *list</td><td>size_t size</td><td></td><td></td><td></td></tr><tr><td>196</td><td>sys_flistxattr</td><td>int fd</td><td>char *list</td><td>size_t size</td><td></td><td></td><td></td></tr><tr><td>197</td><td>sys_removexattr</td><td>const char *pathname</td><td>const char *name</td><td></td><td></td><td></td><td></td></tr><tr><td>198</td><td>sys_lremovexattr</td><td>const char *pathname</td><td>const char *name</td><td></td><td></td><td></td><td></td></tr><tr><td>199</td><td>sys_fremovexattr</td><td>int fd</td><td>const char *name</td><td></td><td></td><td></td><td></td></tr><tr><td>200</td><td>sys_tkill</td><td>pid_t pid</td><td>ing sig</td><td></td><td></td><td></td><td></td></tr><tr><td>201</td><td>sys_time</td><td>time_t *tloc</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>202</td><td>sys_futex</td><td>u32 *uaddr</td><td>int op</td><td>u32 val</td><td>struct timespec *utime</td><td>u32 *uaddr2</td><td>u32 val3</td></tr><tr><td>203</td><td>sys_sched_setaffinity</td><td>pid_t pid</td><td>unsigned int len</td><td>unsigned long *user_mask_ptr</td><td></td><td></td><td></td></tr><tr><td>204</td><td>sys_sched_getaffinity</td><td>pid_t pid</td><td>unsigned int len</td><td>unsigned long *user_mask_ptr</td><td></td><td></td><td></td></tr><tr><td>205</td><td>sys_set_thread_area</td><td>NOT IMPLEMENTED. Use arch_prctl</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>206</td><td>sys_io_setup</td><td>unsigned nr_events</td><td>aio_context_t *ctxp</td><td></td><td></td><td></td><td></td></tr><tr><td>207</td><td>sys_io_destroy</td><td>aio_context_t ctx</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>208</td><td>sys_io_getevents</td><td>aio_context_t ctx_id</td><td>long min_nr</td><td>long nr</td><td>struct io_event *events</td><td></td><td></td></tr><tr><td>209</td><td>sys_io_submit</td><td>aio_context_t ctx_id</td><td>long nr</td><td>struct iocb **iocbpp</td><td></td><td></td><td></td></tr><tr><td>210</td><td>sys_io_cancel</td><td>aio_context_t ctx_id</td><td>struct iocb *iocb</td><td>struct io_event *result</td><td></td><td></td><td></td></tr><tr><td>211</td><td>sys_get_thread_area</td><td>NOT IMPLEMENTED. Use arch_prctl</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>212</td><td>sys_lookup_dcookie</td><td>u64 cookie64</td><td>long buf</td><td>long len</td><td></td><td></td><td></td></tr><tr><td>213</td><td>sys_epoll_create</td><td>int size</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>214</td><td>sys_epoll_ctl_old</td><td>NOT IMPLEMENTED</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>215</td><td>sys_epoll_wait_old</td><td>NOT IMPLEMENTED</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>216</td><td>sys_remap_file_pages</td><td>unsigned long start</td><td>unsigned long size</td><td>unsigned long prot</td><td>unsigned long pgoff</td><td>unsigned long flags</td><td></td></tr><tr><td>217</td><td>sys_getdents64</td><td>unsigned int fd</td><td>struct linux_dirent64 *dirent</td><td>unsigned int count</td><td></td><td></td><td></td></tr><tr><td>218</td><td>sys_set_tid_address</td><td>int *tidptr</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>219</td><td>sys_restart_syscall</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>220</td><td>sys_semtimedop</td><td>int semid</td><td>struct sembuf *tsops</td><td>unsigned nsops</td><td>const struct timespec *timeout</td><td></td><td></td></tr><tr><td>221</td><td>sys_fadvise64</td><td>int fd</td><td>loff_t offset</td><td>size_t len</td><td>int advice</td><td></td><td></td></tr><tr><td>222</td><td>sys_timer_create</td><td>const clockid_t which_clock</td><td>struct sigevent *timer_event_spec</td><td>timer_t *created_timer_id</td><td></td><td></td><td></td></tr><tr><td>223</td><td>sys_timer_settime</td><td>timer_t timer_id</td><td>int flags</td><td>const struct itimerspec *new_setting</td><td>struct itimerspec *old_setting</td><td></td><td></td></tr><tr><td>224</td><td>sys_timer_gettime</td><td>timer_t timer_id</td><td>struct itimerspec *setting</td><td></td><td></td><td></td><td></td></tr><tr><td>225</td><td>sys_timer_getoverrun</td><td>timer_t timer_id</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>226</td><td>sys_timer_delete</td><td>timer_t timer_id</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>227</td><td>sys_clock_settime</td><td>const clockid_t which_clock</td><td>const struct timespec *tp</td><td></td><td></td><td></td><td></td></tr><tr><td>228</td><td>sys_clock_gettime</td><td>const clockid_t which_clock</td><td>struct timespec *tp</td><td></td><td></td><td></td><td></td></tr><tr><td>229</td><td>sys_clock_getres</td><td>const clockid_t which_clock</td><td>struct timespec *tp</td><td></td><td></td><td></td><td></td></tr><tr><td>230</td><td>sys_clock_nanosleep</td><td>const clockid_t which_clock</td><td>int flags</td><td>const struct timespec *rqtp</td><td>struct timespec *rmtp</td><td></td><td></td></tr><tr><td>231</td><td>sys_exit_group</td><td>int error_code</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>232</td><td>sys_epoll_wait</td><td>int epfd</td><td>struct epoll_event *events</td><td>int maxevents</td><td>int timeout</td><td></td><td></td></tr><tr><td>233</td><td>sys_epoll_ctl</td><td>int epfd</td><td>int op</td><td>int fd</td><td>struct epoll_event *event</td><td></td><td></td></tr><tr><td>234</td><td>sys_tgkill</td><td>pid_t tgid</td><td>pid_t pid</td><td>int sig</td><td></td><td></td><td></td></tr><tr><td>235</td><td>sys_utimes</td><td>char *filename</td><td>struct timeval *utimes</td><td></td><td></td><td></td><td></td></tr><tr><td>236</td><td>sys_vserver</td><td>NOT IMPLEMENTED</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>237</td><td>sys_mbind</td><td>unsigned long start</td><td>unsigned long len</td><td>unsigned long mode</td><td>unsigned long *nmask</td><td>unsigned long maxnode</td><td>unsigned flags</td></tr><tr><td>238</td><td>sys_set_mempolicy</td><td>int mode</td><td>unsigned long *nmask</td><td>unsigned long maxnode</td><td></td><td></td><td></td></tr><tr><td>239</td><td>sys_get_mempolicy</td><td>int *policy</td><td>unsigned long *nmask</td><td>unsigned long maxnode</td><td>unsigned long addr</td><td>unsigned long flags</td><td></td></tr><tr><td>240</td><td>sys_mq_open</td><td>const char *u_name</td><td>int oflag</td><td>mode_t mode</td><td>struct mq_attr *u_attr</td><td></td><td></td></tr><tr><td>241</td><td>sys_mq_unlink</td><td>const char *u_name</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>242</td><td>sys_mq_timedsend</td><td>mqd_t mqdes</td><td>const char *u_msg_ptr</td><td>size_t msg_len</td><td>unsigned int msg_prio</td><td>const stuct timespec *u_abs_timeout</td><td></td></tr><tr><td>243</td><td>sys_mq_timedreceive</td><td>mqd_t mqdes</td><td>char *u_msg_ptr</td><td>size_t msg_len</td><td>unsigned int *u_msg_prio</td><td>const struct timespec *u_abs_timeout</td><td></td></tr><tr><td>244</td><td>sys_mq_notify</td><td>mqd_t mqdes</td><td>const struct sigevent *u_notification</td><td></td><td></td><td></td><td></td></tr><tr><td>245</td><td>sys_mq_getsetattr</td><td>mqd_t mqdes</td><td>const struct mq_attr *u_mqstat</td><td>struct mq_attr *u_omqstat</td><td></td><td></td><td></td></tr><tr><td>246</td><td>sys_kexec_load</td><td>unsigned long entry</td><td>unsigned long nr_segments</td><td>struct kexec_segment *segments</td><td>unsigned long flags</td><td></td><td></td></tr><tr><td>247</td><td>sys_waitid</td><td>int which</td><td>pid_t upid</td><td>struct siginfo *infop</td><td>int options</td><td>struct rusage *ru</td><td></td></tr><tr><td>248</td><td>sys_add_key</td><td>const char *_type</td><td>const char *_description</td><td>const void *_payload</td><td>size_t plen</td><td></td><td></td></tr><tr><td>249</td><td>sys_request_key</td><td>const char *_type</td><td>const char *_description</td><td>const char *_callout_info</td><td>key_serial_t destringid</td><td></td><td></td></tr><tr><td>250</td><td>sys_keyctl</td><td>int option</td><td>unsigned long arg2</td><td>unsigned long arg3</td><td>unsigned long arg4</td><td>unsigned long arg5</td><td></td></tr><tr><td>251</td><td>sys_ioprio_set</td><td>int which</td><td>int who</td><td>int ioprio</td><td></td><td></td><td></td></tr><tr><td>252</td><td>sys_ioprio_get</td><td>int which</td><td>int who</td><td></td><td></td><td></td><td></td></tr><tr><td>253</td><td>sys_inotify_init</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>254</td><td>sys_inotify_add_watch</td><td>int fd</td><td>const char *pathname</td><td>u32 mask</td><td></td><td></td><td></td></tr><tr><td>255</td><td>sys_inotify_rm_watch</td><td>int fd</td><td>__s32 wd</td><td></td><td></td><td></td><td></td></tr><tr><td>256</td><td>sys_migrate_pages</td><td>pid_t pid</td><td>unsigned long maxnode</td><td>const unsigned long *old_nodes</td><td>const unsigned long *new_nodes</td><td></td><td></td></tr><tr><td>257</td><td>sys_openat</td><td>int dfd</td><td>const char *filename</td><td>int flags</td><td>int mode</td><td></td><td></td></tr><tr><td>258</td><td>sys_mkdirat</td><td>int dfd</td><td>const char *pathname</td><td>int mode</td><td></td><td></td><td></td></tr><tr><td>259</td><td>sys_mknodat</td><td>int dfd</td><td>const char *filename</td><td>int mode</td><td>unsigned dev</td><td></td><td></td></tr><tr><td>260</td><td>sys_fchownat</td><td>int dfd</td><td>const char *filename</td><td>uid_t user</td><td>gid_t group</td><td>int flag</td><td></td></tr><tr><td>261</td><td>sys_futimesat</td><td>int dfd</td><td>const char *filename</td><td>struct timeval *utimes</td><td></td><td></td><td></td></tr><tr><td>262</td><td>sys_newfstatat</td><td>int dfd</td><td>const char *filename</td><td>struct stat *statbuf</td><td>int flag</td><td></td><td></td></tr><tr><td>263</td><td>sys_unlinkat</td><td>int dfd</td><td>const char *pathname</td><td>int flag</td><td></td><td></td><td></td></tr><tr><td>264</td><td>sys_renameat</td><td>int oldfd</td><td>const char *oldname</td><td>int newfd</td><td>const char *newname</td><td></td><td></td></tr><tr><td>265</td><td>sys_linkat</td><td>int oldfd</td><td>const char *oldname</td><td>int newfd</td><td>const char *newname</td><td>int flags</td><td></td></tr><tr><td>266</td><td>sys_symlinkat</td><td>const char *oldname</td><td>int newfd</td><td>const char *newname</td><td></td><td></td><td></td></tr><tr><td>267</td><td>sys_readlinkat</td><td>int dfd</td><td>const char *pathname</td><td>char *buf</td><td>int bufsiz</td><td></td><td></td></tr><tr><td>268</td><td>sys_fchmodat</td><td>int dfd</td><td>const char *filename</td><td>mode_t mode</td><td></td><td></td><td></td></tr><tr><td>269</td><td>sys_faccessat</td><td>int dfd</td><td>const char *filename</td><td>int mode</td><td></td><td></td><td></td></tr><tr><td>270</td><td>sys_pselect6</td><td>int n</td><td>fd_set *inp</td><td>fd_set *outp</td><td>fd_set *exp</td><td>struct timespec *tsp</td><td>void *sig</td></tr><tr><td>271</td><td>sys_ppoll</td><td>struct pollfd *ufds</td><td>unsigned int nfds</td><td>struct timespec *tsp</td><td>const sigset_t *sigmask</td><td>size_t sigsetsize</td><td></td></tr><tr><td>272</td><td>sys_unshare</td><td>unsigned long unshare_flags</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>273</td><td>sys_set_robust_list</td><td>struct robust_list_head *head</td><td>size_t len</td><td></td><td></td><td></td><td></td></tr><tr><td>274</td><td>sys_get_robust_list</td><td>int pid</td><td>struct robust_list_head **head_ptr</td><td>size_t *len_ptr</td><td></td><td></td><td></td></tr><tr><td>275</td><td>sys_splice</td><td>int fd_in</td><td>loff_t *off_in</td><td>int fd_out</td><td>loff_t *off_out</td><td>size_t len</td><td>unsigned int flags</td></tr><tr><td>276</td><td>sys_tee</td><td>int fdin</td><td>int fdout</td><td>size_t len</td><td>unsigned int flags</td><td></td><td></td></tr><tr><td>277</td><td>sys_sync_file_range</td><td>long fd</td><td>loff_t offset</td><td>loff_t bytes</td><td>long flags</td><td></td><td></td></tr><tr><td>278</td><td>sys_vmsplice</td><td>int fd</td><td>const struct iovec *iov</td><td>unsigned long nr_segs</td><td>unsigned int flags</td><td></td><td></td></tr><tr><td>279</td><td>sys_move_pages</td><td>pid_t pid</td><td>unsigned long nr_pages</td><td>const void **pages</td><td>const int *nodes</td><td>int *status</td><td>int flags</td></tr><tr><td>280</td><td>sys_utimensat</td><td>int dfd</td><td>const char *filename</td><td>struct timespec *utimes</td><td>int flags</td><td></td><td></td></tr><tr><td>281</td><td>sys_epoll_pwait</td><td>int epfd</td><td>struct epoll_event *events</td><td>int maxevents</td><td>int timeout</td><td>const sigset_t *sigmask</td><td>size_t sigsetsize</td></tr><tr><td>282</td><td>sys_signalfd</td><td>int ufd</td><td>sigset_t *user_mask</td><td>size_t sizemask</td><td></td><td></td><td></td></tr><tr><td>283</td><td>sys_timerfd_create</td><td>int clockid</td><td>int flags</td><td></td><td></td><td></td><td></td></tr><tr><td>284</td><td>sys_eventfd</td><td>unsigned int count</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>285</td><td>sys_fallocate</td><td>long fd</td><td>long mode</td><td>loff_t offset</td><td>loff_t len</td><td></td><td></td></tr><tr><td>286</td><td>sys_timerfd_settime</td><td>int ufd</td><td>int flags</td><td>const struct itimerspec *utmr</td><td>struct itimerspec *otmr</td><td></td><td></td></tr><tr><td>287</td><td>sys_timerfd_gettime</td><td>int ufd</td><td>struct itimerspec *otmr</td><td></td><td></td><td></td><td></td></tr><tr><td>288</td><td>sys_accept4</td><td>int fd</td><td>struct sockaddr *upeer_sockaddr</td><td>int *upeer_addrlen</td><td>int flags</td><td></td><td></td></tr><tr><td>289</td><td>sys_signalfd4</td><td>int ufd</td><td>sigset_t *user_mask</td><td>size_t sizemask</td><td>int flags</td><td></td><td></td></tr><tr><td>290</td><td>sys_eventfd2</td><td>unsigned int count</td><td>int flags</td><td></td><td></td><td></td><td></td></tr><tr><td>291</td><td>sys_epoll_create1</td><td>int flags</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>292</td><td>sys_dup3</td><td>unsigned int oldfd</td><td>unsigned int newfd</td><td>int flags</td><td></td><td></td><td></td></tr><tr><td>293</td><td>sys_pipe2</td><td>int *filedes</td><td>int flags</td><td></td><td></td><td></td><td></td></tr><tr><td>294</td><td>sys_inotify_init1</td><td>int flags</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>295</td><td>sys_preadv</td><td>unsigned long fd</td><td>const struct iovec *vec</td><td>unsigned long vlen</td><td>unsigned long pos_l</td><td>unsigned long pos_h</td><td></td></tr><tr><td>296</td><td>sys_pwritev</td><td>unsigned long fd</td><td>const struct iovec *vec</td><td>unsigned long vlen</td><td>unsigned long pos_l</td><td>unsigned long pos_h</td><td></td></tr><tr><td>297</td><td>sys_rt_tgsigqueueinfo</td><td>pid_t tgid</td><td>pid_t pid</td><td>int sig</td><td>siginfo_t *uinfo</td><td></td><td></td></tr><tr><td>298</td><td>sys_perf_event_open</td><td>struct perf_event_attr *attr_uptr</td><td>pid_t pid</td><td>int cpu</td><td>int group_fd</td><td>unsigned long flags</td><td></td></tr><tr><td>299</td><td>sys_recvmmsg</td><td>int fd</td><td>struct msghdr *mmsg</td><td>unsigned int vlen</td><td>unsigned int flags</td><td>struct timespec *timeout</td><td></td></tr><tr><td>300</td><td>sys_fanotify_init</td><td>unsigned int flags</td><td>unsigned int event_f_flags</td><td></td><td></td><td></td><td></td></tr><tr><td>301</td><td>sys_fanotify_mark</td><td>long fanotify_fd</td><td>long flags</td><td>__u64 mask</td><td>long dfd</td><td>long pathname</td><td></td></tr><tr><td>302</td><td>sys_prlimit64</td><td>pid_t pid</td><td>unsigned int resource</td><td>const struct rlimit64 *new_rlim</td><td>struct rlimit64 *old_rlim</td><td></td><td></td></tr><tr><td>303</td><td>sys_name_to_handle_at</td><td>int dfd</td><td>const char *name</td><td>struct file_handle *handle</td><td>int *mnt_id</td><td>int flag</td><td></td></tr><tr><td>304</td><td>sys_open_by_handle_at</td><td>int dfd</td><td>const char *name</td><td>struct file_handle *handle</td><td>int *mnt_id</td><td>int flags</td><td></td></tr><tr><td>305</td><td>sys_clock_adjtime</td><td>clockid_t which_clock</td><td>struct timex *tx</td><td></td><td></td><td></td><td></td></tr><tr><td>306</td><td>sys_syncfs</td><td>int fd</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>307</td><td>sys_sendmmsg</td><td>int fd</td><td>struct mmsghdr *mmsg</td><td>unsigned int vlen</td><td>unsigned int flags</td><td></td><td></td></tr><tr><td>308</td><td>sys_setns</td><td>int fd</td><td>int nstype</td><td></td><td></td><td></td><td></td></tr><tr><td>309</td><td>sys_getcpu</td><td>unsigned *cpup</td><td>unsigned *nodep</td><td>struct getcpu_cache *unused</td><td></td><td></td><td></td></tr><tr><td>310</td><td>sys_process_vm_readv</td><td>pid_t pid</td><td>const struct iovec *lvec</td><td>unsigned long liovcnt</td><td>const struct iovec *rvec</td><td>unsigned long riovcnt</td><td>unsigned long flags</td></tr><tr><td>311</td><td>sys_process_vm_writev</td><td>pid_t pid</td><td>const struct iovec *lvec</td><td>unsigned long liovcnt</td><td>const struct iovcc *rvec</td><td>unsigned long riovcnt</td><td>unsigned long flags</td></tr><tr><td>312</td><td>sys_kcmp</td><td>pid_t pid1</td><td>pid_t pid2</td><td>int type</td><td>unsigned long idx1</td><td>unsigned long idx2</td><td></td></tr><tr><td>313</td><td>sys_finit_module</td><td>int fd</td><td>const char __user *uargs</td><td>int flags</td><td></td><td></td><td></td></tr><tr><td>314</td><td>sys_sched_setattr</td><td>pid_t pid</td><td>struct sched_attr __user *attr</td><td>unsigned int flags</td><td></td><td></td><td></td></tr><tr><td>315</td><td>sys_sched_getattr</td><td>pid_t pid</td><td>struct sched_attr __user *attr</td><td>unsigned int size</td><td>unsigned int flags</td><td></td><td></td></tr><tr><td>316</td><td>sys_renameat2</td><td>int olddfd</td><td>const char __user *oldname</td><td>int newdfd, const char __user *newname</td><td>unsigned int flags</td><td></td><td></td></tr><tr><td>317</td><td>sys_seccomp</td><td>unsigned int op</td><td>unsigned int flags</td><td>const char __user *uargs</td><td></td><td></td><td></td></tr><tr><td>318</td><td>sys_getrandom</td><td>char __user *buf</td><td>size_t count</td><td>unsigned int flags</td><td></td><td></td><td></td></tr><tr><td>319</td><td>sys_memfd_create</td><td>const char __user *uname_ptr</td><td>unsigned
+int flags</td><td></td><td></td><td></td><td></td></tr><tr><td>320</td><td>sys_kexec_file_load</td><td>int kernel_fd</td><td>int initrd_fd</td><td>unsigned long cmdline_len</td><td>const char __user *cmdline_ptr</td><td>unsigned long flags</td><td></td></tr><tr><td>321</td><td>sys_bpf</td><td>int cmd</td><td>union bpf_attr *attr</td><td>unsigned int size</td><td></td><td></td><td></td></tr><tr><td>322</td><td>stub_execveat</td><td>int dfd</td><td>const char __user *filename</td><td>const char __user *const __user *argv</td><td>const char __user *const __user *envp</td><td>int flags</td><td></td></tr></tbody></table>
\ No newline at end of file
--- /dev/null
+/*
+ Device File Virtualization Guest Preload Library Helpers
+
+ (c) Akhil Guliani and William Gross, 2015
+
+ Adapted from MPI module (c) 2012 Peter Dinda
+
+*/
+
+/*
+ This is a mapping between system call number (64 bit Linux)
+ and a bit vector whose set bits indicate which of the arguments
+ to the givien system call are pointer arguments, and thus need
+ to be swizzled by the devfile implementation.
+
+*/
+
+long long sys_pointer_arr[323] = {
+2,
+2,
+1,
+0,
+3,
+2,
+3,
+1,
+0,
+0,
+0,
+0,
+0,
+6,
+6,
+0,
+4,
+2,
+2,
+2,
+2,
+1,
+1,
+30,
+0,
+0,
+0,
+4,
+0,
+0,
+2,
+4,
+0,
+0,
+0,
+3,
+2,
+0,
+6,
+0,
+4,
+0,
+2,
+6,
+18,
+50,
+2,
+2,
+0,
+2,
+0,
+6,
+6,
+8,
+8,
+24,
+12,
+0,
+0,
+7,
+0,
+10,
+0,
+1,
+0,
+2,
+0,
+1,
+0,
+2,
+2,
+4,
+0,
+0,
+0,
+0,
+1,
+0,
+2,
+1,
+1,
+0,
+3,
+1,
+1,
+1,
+3,
+1,
+3,
+3,
+1,
+0,
+1,
+0,
+1,
+0,
+3,
+2,
+2,
+1,
+1,
+0,
+0,
+2,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+2,
+2,
+7,
+7,
+0,
+7,
+0,
+0,
+0,
+0,
+0,
+0,
+1,
+7,
+4,
+1,
+3,
+3,
+1,
+0,
+0,
+2,
+3,
+2,
+0,
+0,
+0,
+2,
+2,
+4,
+0,
+0,
+0,
+2,
+0,
+0,
+0,
+0,
+0,
+2,
+3,
+1,
+0,
+5,
+1,
+2,
+1,
+0,
+1,
+3,
+23,
+1,
+1,
+1,
+8,
+1,
+1,
+2,
+0,
+0,
+5,
+1,
+0,
+0,
+10,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+7,
+7,
+6,
+7,
+7,
+6,
+3,
+3,
+2,
+3,
+3,
+2,
+0,
+1,
+25,
+4,
+4,
+0,
+2,
+0,
+8,
+4,
+6,
+0,
+0,
+0,
+0,
+0,
+0,
+2,
+1,
+0,
+10,
+0,
+6,
+12,
+2,
+0,
+0,
+2,
+2,
+2,
+12,
+0,
+2,
+8,
+0,
+3,
+0,
+8,
+2,
+3,
+9,
+1,
+18,
+26,
+2,
+6,
+4,
+20,
+7,
+7,
+0,
+0,
+0,
+0,
+2,
+0,
+12,
+2,
+2,
+2,
+2,
+6,
+6,
+2,
+10,
+10,
+5,
+6,
+2,
+2,
+62,
+13,
+0,
+1,
+6,
+10,
+0,
+0,
+2,
+28,
+6,
+18,
+2,
+0,
+0,
+0,
+12,
+2,
+6,
+2,
+0,
+0,
+0,
+1,
+0,
+2,
+2,
+8,
+1,
+18,
+0,
+0,
+12,
+14,
+14,
+2,
+0,
+2,
+0,
+7,
+10,
+10,
+0,
+2,
+2,
+2,
+6,
+4,
+1,
+1,
+8,
+2,
+14
+};
+
--- /dev/null
+/*
+ * This file is part of the Palacios Virtual Machine Monitor developed
+ * by the V3VEE Project with funding from the United States National
+ * Science Foundation and the Department of Energy.
+ *
+ * The V3VEE Project is a joint project between Northwestern University
+ * and the University of New Mexico. You can find out more at
+ * http://www.v3vee.org
+ *
+ * Copyright (c) 2011, Kyle C. Hale <kh@u.northwestern.edu>
+ * Copyright (c) 2011, The V3VEE Project <http://www.v3vee.org>
+ * All rights reserved.
+ *
+ * Author: Kyle C. Hale <kh@u.northwestern.edu>
+ *
+ * This is free software. You are permitted to use,
+ * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
+ */
+
+#ifndef __SYSCALL_REF_H__
+#define __SYSCALL_REF_H__
+
+
+
+/* 32bit syscalls */
+#define SYS32_RESTART_SYSCALL 0
+#define SYS32_EXIT 1
+#define SYS32_FORK 2
+#define SYS32_READ 3
+#define SYS32_WRITE 4
+#define SYS32_OPEN 5
+#define SYS32_CLOSE 6
+#define SYS32_WAITPID 7
+#define SYS32_CREAT 8
+#define SYS32_LINK 9
+#define SYS32_UNLINK 10
+#define SYS32_EXECVE 11
+#define SYS32_CHDIR 12
+#define SYS32_TIME 13
+#define SYS32_MKNOD 14
+#define SYS32_CHMOD 15
+#define SYS32_LCHOWN 16
+#define SYS32_BREAK 17
+#define SYS32_OLDSTAT 18
+#define SYS32_LSEEK 19
+#define SYS32_GETPID 20
+#define SYS32_MOUNT 21
+#define SYS32_UMOUNT 22
+#define SYS32_SETUID 23
+#define SYS32_GETUID 24
+#define SYS32_STIME 25
+#define SYS32_PTRACE 26
+#define SYS32_ALARM 27
+#define SYS32_OLDFSTAT 28
+#define SYS32_PAUSE 29
+#define SYS32_UTIME 30
+#define SYS32_STTY 31
+#define SYS32_GTTY 32
+#define SYS32_ACCESS 33
+#define SYS32_NICE 34
+#define SYS32_FTIME 35
+#define SYS32_SYNC 36
+#define SYS32_KILL 37
+#define SYS32_RENAME 38
+#define SYS32_MKDIR 39
+#define SYS32_RMDIR 40
+#define SYS32_DUP 41
+#define SYS32_PIPE 42
+#define SYS32_TIMES 43
+#define SYS32_PROF 44
+#define SYS32_BRK 45
+#define SYS32_SETGID 46
+#define SYS32_GETGID 47
+#define SYS32_SIGNAL 48
+#define SYS32_GETEUID 49
+#define SYS32_GETEGID 50
+#define SYS32_ACCT 51
+#define SYS32_UMOUNT2 52
+#define SYS32_LOCK 53
+#define SYS32_IOCTL 54
+#define SYS32_FCNTL 55
+#define SYS32_MPX 56
+#define SYS32_SETPGID 57
+#define SYS32_ULIMIT 58
+#define SYS32_OLDOLDUNAME 59
+#define SYS32_UMASK 60
+#define SYS32_CHROOT 61
+#define SYS32_USTAT 62
+#define SYS32_DUP2 63
+#define SYS32_GETPPID 64
+#define SYS32_GETPGRP 65
+#define SYS32_SETSID 66
+#define SYS32_SIGACTION 67
+#define SYS32_SGETMASK 68
+#define SYS32_SSETMASK 69
+#define SYS32_SETREUID 70
+#define SYS32_SETREGID 71
+#define SYS32_SIGSUSPEND 72
+#define SYS32_SIGPENDING 73
+#define SYS32_SETHOSTNAME 74
+#define SYS32_SETRLIMIT 75
+#define SYS32_GETRLIMIT 76
+#define SYS32_GETRUSAGE 77
+#define SYS32_GETTIMEOFDAY 78
+#define SYS32_SETTIMEOFDAY 79
+#define SYS32_GETGROUPS 80
+#define SYS32_SETGROUPS 81
+#define SYS32_SELECT 82
+#define SYS32_SYMLINK 83
+#define SYS32_OLDLSTAT 84
+#define SYS32_READLINK 85
+#define SYS32_USELIB 86
+#define SYS32_SWAPON 87
+#define SYS32_REBOOT 88
+#define SYS32_READDIR 89
+#define SYS32_MMAP 90
+#define SYS32_MUNMAP 91
+#define SYS32_TRUNCATE 92
+#define SYS32_FTRUNCATE 93
+#define SYS32_FCHMOD 94
+#define SYS32_FCHOWN 95
+#define SYS32_GETPRIORITY 96
+#define SYS32_SETPRIORITY 97
+#define SYS32_PROFIL 98
+#define SYS32_STATFS 99
+#define SYS32_FSTATFS 100
+#define SYS32_IOPERM 101
+#define SYS32_SOCKETCALL 102
+#define SYS32_SYSLOG 103
+#define SYS32_SETITIMER 104
+#define SYS32_GETITIMER 105
+#define SYS32_STAT 106
+#define SYS32_LSTAT 107
+#define SYS32_FSTAT 108
+#define SYS32_OLDUNAME 109
+#define SYS32_IOPL 110
+#define SYS32_VHANGUP 111
+#define SYS32_IDLE 112
+#define SYS32_VM86OLD 113
+#define SYS32_WAIT4 114
+#define SYS32_SWAPOFF 115
+#define SYS32_SYSINFO 116
+#define SYS32_IPC 117
+#define SYS32_FSYNC 118
+#define SYS32_SIGRETURN 119
+#define SYS32_CLONE 120
+#define SYS32_SETDOMAINNAME 121
+#define SYS32_UNAME 122
+#define SYS32_MODIFY_LDT 123
+#define SYS32_ADJTIMEX 124
+#define SYS32_MPROTECT 125
+#define SYS32_SIGPROCMASK 126
+#define SYS32_CREATE_MODULE 127
+#define SYS32_INIT_MODULE 128
+#define SYS32_DELETE_MODULE 129
+#define SYS32_GET_KERNEL_SYMS 130
+#define SYS32_QUOTACTL 131
+#define SYS32_GETPGID 132
+#define SYS32_FCHDIR 133
+#define SYS32_BDFLUSH 134
+#define SYS32_SYSFS 135
+#define SYS32_PERSONALITY 136
+#define SYS32_AFS_SYSCALL 137
+#define SYS32_SETFSUID 138
+#define SYS32_SETFSGID 139
+#define SYS32__LLSEEK 140
+#define SYS32_GETDENTS 141
+#define SYS32__NEWSELECT 142
+#define SYS32_FLOCK 143
+#define SYS32_MSYNC 144
+#define SYS32_READV 145
+#define SYS32_WRITEV 146
+#define SYS32_GETSID 147
+#define SYS32_FDATASYNC 148
+#define SYS32__SYSCTL 149
+#define SYS32_MLOCK 150
+#define SYS32_MUNLOCK 151
+#define SYS32_MLOCKALL 152
+#define SYS32_MUNLOCKALL 153
+#define SYS32_SCHED_SETPARAM 154
+#define SYS32_SCHED_GETPARAM 155
+#define SYS32_SCHED_SETSCHEDULER 156
+#define SYS32_SCHED_GETSCHEDULER 157
+#define SYS32_SCHED_YIELD 158
+#define SYS32_SCHED_GET_PRIORITY_MAX 159
+#define SYS32_SCHED_GET_PRIORITY_MIN 160
+#define SYS32_SCHED_RR_GET_INTERVAL 161
+#define SYS32_NANOSLEEP 162
+#define SYS32_MREMAP 163
+#define SYS32_SETRESUID 164
+#define SYS32_GETRESUID 165
+#define SYS32_VM86 166
+#define SYS32_QUERY_MODULE 167
+#define SYS32_POLL 168
+#define SYS32_NFSSERVCTL 169
+#define SYS32_SETRESGID 170
+#define SYS32_GETRESGID 171
+#define SYS32_PRCTL 172
+#define SYS32_RT_SIGRETURN 173
+#define SYS32_RT_SIGACTION 174
+#define SYS32_RT_SIGPROCMASK 175
+#define SYS32_RT_SIGPENDING 176
+#define SYS32_RT_SIGTIMEDWAIT 177
+#define SYS32_RT_SIGQUEUEINFO 178
+#define SYS32_RT_SIGSUSPEND 179
+#define SYS32_PREAD64 180
+#define SYS32_PWRITE64 181
+#define SYS32_CHOWN 182
+#define SYS32_GETCWD 183
+#define SYS32_CAPGET 184
+#define SYS32_CAPSET 185
+#define SYS32_SIGALTSTACK 186
+#define SYS32_SENDFILE 187
+#define SYS32_GETPMSG 188
+#define SYS32_PUTPMSG 189
+#define SYS32_VFORK 190
+#define SYS32_UGETRLIMIT 191
+#define SYS32_MMAP2 192
+#define SYS32_TRUNCATE64 193
+#define SYS32_FTRUNCATE64 194
+#define SYS32_STAT64 195
+#define SYS32_LSTAT64 196
+#define SYS32_FSTAT64 197
+#define SYS32_LCHOWN32 198
+#define SYS32_GETUID32 199
+#define SYS32_GETGID32 200
+#define SYS32_GETEUID32 201
+#define SYS32_GETEGID32 202
+#define SYS32_SETREUID32 203
+#define SYS32_SETREGID32 204
+#define SYS32_GETGROUPS32 205
+#define SYS32_SETGROUPS32 206
+#define SYS32_FCHOWN32 207
+#define SYS32_SETRESUID32 208
+#define SYS32_GETRESUID32 209
+#define SYS32_SETRESGID32 210
+#define SYS32_GETRESGID32 211
+#define SYS32_CHOWN32 212
+#define SYS32_SETUID32 213
+#define SYS32_SETGID32 214
+#define SYS32_SETFSUID32 215
+#define SYS32_SETFSGID32 216
+#define SYS32_PIVOT_ROOT 217
+#define SYS32_MINCORE 218
+#define SYS32_MADVISE1 219
+#define SYS32_GETDENTS64 220
+#define SYS32_FCNTL64 221
+#define SYS32_GETTID 224
+#define SYS32_READAHEAD 225
+#define SYS32_SETXATTR 226
+#define SYS32_LSETXATTR 227
+#define SYS32_FSETXATTR 228
+#define SYS32_GETXATTR 229
+#define SYS32_LGETXATTR 230
+#define SYS32_FGETXATTR 231
+#define SYS32_LISTXATTR 232
+#define SYS32_LLISTXATTR 233
+#define SYS32_FLISTXATTR 234
+#define SYS32_REMOVEXATTR 235
+#define SYS32_LREMOVEXATTR 236
+#define SYS32_FREMOVEXATTR 237
+#define SYS32_TKILL 238
+#define SYS32_SENDFILE64 239
+#define SYS32_FUTEX 240
+#define SYS32_SCHED_SETAFFINITY 241
+#define SYS32_SCHED_GETAFFINITY 242
+#define SYS32_SET_THREAD_AREA 243
+#define SYS32_GET_THREAD_AREA 244
+#define SYS32_IO_SETUP 245
+#define SYS32_IO_DESTROY 246
+#define SYS32_IO_GETEVENTS 247
+#define SYS32_IO_SUBMIT 248
+#define SYS32_IO_CANCEL 249
+#define SYS32_FADVISE64 250
+#define SYS32_EXIT_GROUP 252
+#define SYS32_LOOKUP_DCOOKIE 253
+#define SYS32_EPOLL_CREATE 254
+#define SYS32_EPOLL_CTL 255
+#define SYS32_EPOLL_WAIT 256
+#define SYS32_REMAP_FILE_PAGES 257
+#define SYS32_SET_TID_ADDRESS 258
+#define SYS32_TIMER_CREATE 259
+#define SYS32_TIMER_SETTIME 260
+#define SYS32_TIMER_GETTIME 261
+#define SYS32_TIMER_GETOVERRUN 262
+#define SYS32_TIMER_DELETE 263
+#define SYS32_CLOCK_SETTIME 264
+#define SYS32_CLOCK_GETTIME 265
+#define SYS32_CLOCK_GETRES 266
+#define SYS32_CLOCK_NANOSLEEP 267
+#define SYS32_STATFS64 268
+#define SYS32_FSTATFS64 269
+#define SYS32_TGKILL 270
+#define SYS32_UTIMES 271
+#define SYS32_FADVISE64_64 272
+#define SYS32_VSERVER 273
+#define SYS32_MBIND 274
+#define SYS32_GET_MEMPOLICY 275
+#define SYS32_SET_MEMPOLICY 276
+#define SYS32_MQ_OPEN 277
+#define SYS32_MQ_UNLINK 278
+#define SYS32_MQ_TIMEDSEND 279
+#define SYS32_MQ_TIMEDRECEIVE 280
+#define SYS32_MQ_NOTIFY 281
+#define SYS32_MQ_GETSETATTR 282
+#define SYS32_KEXEC_LOAD 283
+#define SYS32_WAITID 284
+#define SYS32_SYS32_SETALTROOT 285
+#define SYS32_ADD_KEY 286
+#define SYS32_REQUEST_KEY 287
+#define SYS32_KEYCTL 288
+#define SYS32_IOPRIO_SET 289
+#define SYS32_IOPRIO_GET 290
+#define SYS32_INOTIFY_INIT 291
+#define SYS32_INOTIFY_ADD_WATCH 292
+#define SYS32_INOTIFY_RM_WATCH 293
+#define SYS32_MIGRATE_PAGES 294
+#define SYS32_OPENAT 295
+#define SYS32_MKDIRAT 296
+#define SYS32_MKNODAT 297
+#define SYS32_FCHOWNAT 298
+#define SYS32_FUTIMESAT 299
+#define SYS32_FSTATAT64 300
+#define SYS32_UNLINKAT 301
+#define SYS32_RENAMEAT 302
+#define SYS32_LINKAT 303
+#define SYS32_SYMLINKAT 304
+#define SYS32_READLINKAT 305
+#define SYS32_FCHMODAT 306
+#define SYS32_FACCESSAT 307
+#define SYS32_PSELECT6 308
+#define SYS32_PPOLL 309
+#define SYS32_UNSHARE 310
+#define SYS32_SET_ROBUST_LIST 311
+#define SYS32_GET_ROBUST_LIST 312
+#define SYS32_SPLICE 313
+#define SYS32_SYNC_FILE_RANGE 314
+#define SYS32_TEE 315
+#define SYS32_VMSPLICE 316
+#define SYS32_MOVE_PAGES 317
+#define SYS32_GETCPU 318
+#define SYS32_EPOLL_PWAIT 319
+#define SYS32_UTIMENSAT 320
+#define SYS32_SIGNALFD 321
+#define SYS32_TIMERFD_CREATE 322
+#define SYS32_EVENTFD 323
+#define SYS32_FALLOCATE 324
+#define SYS32_TIMERFD_SETTIME 325
+#define SYS32_TIMERFD_GETTIME 326
+#define SYS32_SIGNALFD4 327
+#define SYS32_EVENTFD2 328
+#define SYS32_EPOLL_CREATE1 329
+#define SYS32_DUP3 330
+#define SYS32_PIPE2 331
+#define SYS32_INOTIFY_INIT1 332
+#define SYS32_PREADV 333
+#define SYS32_PWRITEV 334
+#define SYS32_RT_TGSIGQUEUEINFO 335
+#define SYS32_PERF_EVENT_OPEN 336
+
+/* 64bit syscalls */
+#define SYS64_READ 0
+#define SYS64_WRITE 1
+#define SYS64_OPEN 2
+#define SYS64_CLOSE 3
+#define SYS64_STAT 4
+#define SYS64_FSTAT 5
+#define SYS64_LSTAT 6
+#define SYS64_POLL 7
+#define SYS64_LSEEK 8
+#define SYS64_MMAP 9
+#define SYS64_MPROTECT 10
+#define SYS64_MUNMAP 11
+#define SYS64_BRK 12
+#define SYS64_RT_SIGACTION 13
+#define SYS64_RT_SIGPROCMASK 14
+#define SYS64_RT_SIGRETURN 15
+#define SYS64_IOCTL 16
+#define SYS64_PREAD64 17
+#define SYS64_PWRITE64 18
+#define SYS64_READV 19
+#define SYS64_WRITEV 20
+#define SYS64_ACCESS 21
+#define SYS64_PIPE 22
+#define SYS64_SELECT 23
+#define SYS64_SCHED_YIELD 24
+#define SYS64_MREMAP 25
+#define SYS64_MSYNC 26
+#define SYS64_MINCORE 27
+#define SYS64_MADVISE 28
+#define SYS64_SHMGET 29
+#define SYS64_SHMAT 30
+#define SYS64_SHMCTL 31
+#define SYS64_DUP 32
+#define SYS64_DUP2 33
+#define SYS64_PAUSE 34
+#define SYS64_NANOSLEEP 35
+#define SYS64_GETITIMER 36
+#define SYS64_ALARM 37
+#define SYS64_SETITIMER 38
+#define SYS64_GETPID 39
+#define SYS64_SENDFILE 40
+#define SYS64_SOCKET 41
+#define SYS64_CONNECT 42
+#define SYS64_ACCEPT 43
+#define SYS64_SENDTO 44
+#define SYS64_RECVFROM 45
+#define SYS64_SENDMSG 46
+#define SYS64_RECVMSG 47
+#define SYS64_SHUTDOWN 48
+#define SYS64_BIND 49
+#define SYS64_LISTEN 50
+#define SYS64_GETSOCKNAME 51
+#define SYS64_GETPEERNAME 52
+#define SYS64_SOCKETPAIR 53
+#define SYS64_SETSOCKOPT 54
+#define SYS64_GETSOCKOPT 55
+#define SYS64_CLONE 56
+#define SYS64_FORK 57
+#define SYS64_VFORK 58
+#define SYS64_EXECVE 59
+#define SYS64_EXIT 60
+#define SYS64_WAIT4 61
+#define SYS64_KILL 62
+#define SYS64_UNAME 63
+#define SYS64_SEMGET 64
+#define SYS64_SEMOP 65
+#define SYS64_SEMCTL 66
+#define SYS64_SHMDT 67
+#define SYS64_MSGGET 68
+#define SYS64_MSGSND 69
+#define SYS64_MSGRCV 70
+#define SYS64_MSGCTL 71
+#define SYS64_FCNTL 72
+#define SYS64_FLOCK 73
+#define SYS64_FSYNC 74
+#define SYS64_FDATASYNC 75
+#define SYS64_TRUNCATE 76
+#define SYS64_FTRUNCATE 77
+#define SYS64_GETDENTS 78
+#define SYS64_GETCWD 79
+#define SYS64_CHDIR 80
+#define SYS64_FCHDIR 81
+#define SYS64_RENAME 82
+#define SYS64_MKDIR 83
+#define SYS64_RMDIR 84
+#define SYS64_CREAT 85
+#define SYS64_LINK 86
+#define SYS64_UNLINK 87
+#define SYS64_SYMLINK 88
+#define SYS64_READLINK 89
+#define SYS64_CHMOD 90
+#define SYS64_FCHMOD 91
+#define SYS64_CHOWN 92
+#define SYS64_FCHOWN 93
+#define SYS64_LCHOWN 94
+#define SYS64_UMASK 95
+#define SYS64_GETTIMEOFDAY 96
+#define SYS64_GETRLIMIT 97
+#define SYS64_GETRUSAGE 98
+#define SYS64_SYSINFO 99
+#define SYS64_TIMES 100
+#define SYS64_PTRACE 101
+#define SYS64_GETUID 102
+#define SYS64_SYSLOG 103
+#define SYS64_GETGID 104
+#define SYS64_SETUID 105
+#define SYS64_SETGID 106
+#define SYS64_GETEUID 107
+#define SYS64_GETEGID 108
+#define SYS64_SETPGID 109
+#define SYS64_GETPPID 110
+#define SYS64_GETPGRP 111
+#define SYS64_SETSID 112
+#define SYS64_SETREUID 113
+#define SYS64_SETREGID 114
+#define SYS64_GETGROUPS 115
+#define SYS64_SETGROUPS 116
+#define SYS64_SETRESUID 117
+#define SYS64_GETRESUID 118
+#define SYS64_SETRESGID 119
+#define SYS64_GETRESGID 120
+#define SYS64_GETPGID 121
+#define SYS64_SETFSUID 122
+#define SYS64_SETFSGID 123
+#define SYS64_GETSID 124
+#define SYS64_CAPGET 125
+#define SYS64_CAPSET 126
+#define SYS64_RT_SIGPENDING 127
+#define SYS64_RT_SIGTIMEDWAIT 128
+#define SYS64_RT_SIGQUEUEINFO 129
+#define SYS64_RT_SIGSUSPEND 130
+#define SYS64_SIGALTSTACK 131
+#define SYS64_UTIME 132
+#define SYS64_MKNOD 133
+#define SYS64_USELIB 134
+#define SYS64_PERSONALITY 135
+#define SYS64_USTAT 136
+#define SYS64_STATFS 137
+#define SYS64_FSTATFS 138
+#define SYS64_SYSFS 139
+#define SYS64_GETPRIORITY 140
+#define SYS64_SETPRIORITY 141
+#define SYS64_SCHED_SETPARAM 142
+#define SYS64_SCHED_GETPARAM 143
+#define SYS64_SCHED_SETSCHEDULER 144
+#define SYS64_SCHED_GETSCHEDULER 145
+#define SYS64_SCHED_GET_PRIORITY_MAX 146
+#define SYS64_SCHED_GET_PRIORITY_MIN 147
+#define SYS64_SCHED_RR_GET_INTERVAL 148
+#define SYS64_MLOCK 149
+#define SYS64_MUNLOCK 150
+#define SYS64_MLOCKALL 151
+#define SYS64_MUNLOCKALL 152
+#define SYS64_VHANGUP 153
+#define SYS64_MODIFY_LDT 154
+#define SYS64_PIVOT_ROOT 155
+#define SYS64__SYSCTL 156
+#define SYS64_PRCTL 157
+#define SYS64_ARCH_PRCTL 158
+#define SYS64_ADJTIMEX 159
+#define SYS64_SETRLIMIT 160
+#define SYS64_CHROOT 161
+#define SYS64_SYNC 162
+#define SYS64_ACCT 163
+#define SYS64_SETTIMEOFDAY 164
+#define SYS64_MOUNT 165
+#define SYS64_UMOUNT2 166
+#define SYS64_SWAPON 167
+#define SYS64_SWAPOFF 168
+#define SYS64_REBOOT 169
+#define SYS64_SETHOSTNAME 170
+#define SYS64_SETDOMAINNAME 171
+#define SYS64_IOPL 172
+#define SYS64_IOPERM 173
+#define SYS64_CREATE_MODULE 174
+#define SYS64_INIT_MODULE 175
+#define SYS64_DELETE_MODULE 176
+#define SYS64_GET_KERNEL_SYMS 177
+#define SYS64_QUERY_MODULE 178
+#define SYS64_QUOTACTL 179
+#define SYS64_NFSSERVCTL 180
+#define SYS64_GETPMSG 181
+#define SYS64_PUTPMSG 182
+#define SYS64_AFS_SYSCALL 183
+#define SYS64_TUXCALL 184
+#define SYS64_SECURITY 185
+#define SYS64_GETTID 186
+#define SYS64_READAHEAD 187
+#define SYS64_SETXATTR 188
+#define SYS64_LSETXATTR 189
+#define SYS64_FSETXATTR 190
+#define SYS64_GETXATTR 191
+#define SYS64_LGETXATTR 192
+#define SYS64_FGETXATTR 193
+#define SYS64_LISTXATTR 194
+#define SYS64_LLISTXATTR 195
+#define SYS64_FLISTXATTR 196
+#define SYS64_REMOVEXATTR 197
+#define SYS64_LREMOVEXATTR 198
+#define SYS64_FREMOVEXATTR 199
+#define SYS64_TKILL 200
+#define SYS64_TIME 201
+#define SYS64_FUTEX 202
+#define SYS64_SCHED_SETAFFINITY 203
+#define SYS64_SCHED_GETAFFINITY 204
+#define SYS64_SET_THREAD_AREA 205
+#define SYS64_IO_SETUP 206
+#define SYS64_IO_DESTROY 207
+#define SYS64_IO_GETEVENTS 208
+#define SYS64_IO_SUBMIT 209
+#define SYS64_IO_CANCEL 210
+#define SYS64_GET_THREAD_AREA 211
+#define SYS64_LOOKUP_DCOOKIE 212
+#define SYS64_EPOLL_CREATE 213
+#define SYS64_EPOLL_CTL_OLD 214
+#define SYS64_EPOLL_WAIT_OLD 215
+#define SYS64_REMAP_FILE_PAGES 216
+#define SYS64_GETDENTS64 217
+#define SYS64_SET_TID_ADDRESS 218
+#define SYS64_RESTART_SYSCALL 219
+#define SYS64_SEMTIMEDOP 220
+#define SYS64_FADVISE64 221
+#define SYS64_TIMER_CREATE 222
+#define SYS64_TIMER_SETTIME 223
+#define SYS64_TIMER_GETTIME 224
+#define SYS64_TIMER_GETOVERRUN 225
+#define SYS64_TIMER_DELETE 226
+#define SYS64_CLOCK_SETTIME 227
+#define SYS64_CLOCK_GETTIME 228
+#define SYS64_CLOCK_GETRES 229
+#define SYS64_CLOCK_NANOSLEEP 230
+#define SYS64_EXIT_GROUP 231
+#define SYS64_EPOLL_WAIT 232
+#define SYS64_EPOLL_CTL 233
+#define SYS64_TGKILL 234
+#define SYS64_UTIMES 235
+#define SYS64_VSERVER 236
+#define SYS64_MBIND 237
+#define SYS64_SET_MEMPOLICY 238
+#define SYS64_GET_MEMPOLICY 239
+#define SYS64_MQ_OPEN 240
+#define SYS64_MQ_UNLINK 241
+#define SYS64_MQ_TIMEDSEND 242
+#define SYS64_MQ_TIMEDRECEIVE 243
+#define SYS64_MQ_NOTIFY 244
+#define SYS64_MQ_GETSETATTR 245
+#define SYS64_KEXEC_LOAD 246
+#define SYS64_WAITID 247
+#define SYS64_ADD_KEY 248
+#define SYS64_REQUEST_KEY 249
+#define SYS64_KEYCTL 250
+#define SYS64_IOPRIO_SET 251
+#define SYS64_IOPRIO_GET 252
+#define SYS64_INOTIFY_INIT 253
+#define SYS64_INOTIFY_ADD_WATCH 254
+#define SYS64_INOTIFY_RM_WATCH 255
+#define SYS64_MIGRATE_PAGES 256
+#define SYS64_OPENAT 257
+#define SYS64_MKDIRAT 258
+#define SYS64_MKNODAT 259
+#define SYS64_FCHOWNAT 260
+#define SYS64_FUTIMESAT 261
+#define SYS64_NEWFSTATAT 262
+#define SYS64_UNLINKAT 263
+#define SYS64_RENAMEAT 264
+#define SYS64_LINKAT 265
+#define SYS64_SYMLINKAT 266
+#define SYS64_READLINKAT 267
+#define SYS64_FCHMODAT 268
+#define SYS64_FACCESSAT 269
+#define SYS64_PSELECT6 270
+#define SYS64_PPOLL 271
+#define SYS64_UNSHARE 272
+#define SYS64_SET_ROBUST_LIST 273
+#define SYS64_GET_ROBUST_LIST 274
+#define SYS64_SPLICE 275
+#define SYS64_TEE 276
+#define SYS64_SYNC_FILE_RANGE 277
+#define SYS64_VMSPLICE 278
+#define SYS64_MOVE_PAGES 279
+#define SYS64_UTIMENSAT 280
+#define SYS64_EPOLL_PWAIT 281
+#define SYS64_SIGNALFD 282
+#define SYS64_TIMERFD_CREATE 283
+#define SYS64_EVENTFD 284
+#define SYS64_FALLOCATE 285
+#define SYS64_TIMERFD_SETTIME 286
+#define SYS64_TIMERFD_GETTIME 287
+#define SYS64_ACCEPT4 288
+#define SYS64_SIGNALFD4 289
+#define SYS64_EVENTFD2 290
+#define SYS64_EPOLL_CREATE1 291
+#define SYS64_DUP3 292
+#define SYS64_PIPE2 293
+#define SYS64_INOTIFY_INIT1 294
+#define SYS64_PREADV 295
+#define SYS64_PWRITEV 296
+#define SYS64_RT_TGSIGQUEUEINFO 297
+#define SYS64_PERF_EVENT_OPEN 298
+
+
+#endif
--- /dev/null
+/*
+ Device File Virtualization Guest Preload Library
+ Test Program
+
+ (c) Akhil Guliani and William Gross, 2015
+
+ Adapted from MPI module (c) 2012 Peter Dinda
+
+*/
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <malloc.h>
+
+#include <sys/mman.h>
+#include "devfile_hc.h"
+
+
+int read_all(int fd, char *data, int numbytes)
+{
+ int i;
+ int rc;
+
+ for (i=0;i<numbytes;) {
+ rc = read(fd,data+i,(numbytes-i));
+ if (rc<=0) {
+ return -1;
+ } else {
+ i+=rc;
+ }
+ }
+ return numbytes;
+}
+
+int write_all(int fd, char *data, int numbytes)
+{
+ int i;
+ int rc;
+
+ for (i=0;i<numbytes;) {
+ rc = write(fd,data+i,(numbytes-i));
+ if (rc<=0) {
+ return -1;
+ } else {
+ i+=rc;
+ }
+ }
+ return numbytes;
+}
+
+
+int main(int argc, char * argv[])
+{
+ int fd, bytes, count, flags, mode;
+ char *buff;
+ char *path;
+ char *what;
+
+ if (argc!=4) {
+ fprintf(stderr,"test_preload r <count> <path-to-file> > output\n");
+ fprintf(stderr,"test_preload w <count> <path-to-file> < input\n");
+ return -1;
+ }
+
+ what = argv[1];
+ count = atoi(argv[2]);
+ path = argv[3];
+
+ fprintf(stderr,"what: %s\n",what);
+ fprintf(stderr,"path: %s\n",path);
+ fprintf(stderr,"count: %d\n",count);
+
+ if (*what=='w') {
+ flags = O_RDWR;
+ mode = 0; // we are not doing a file creation
+ } else if (*what=='r') {
+ flags = O_RDONLY;
+ mode = 0; // we are not doing a file creation
+ } else {
+ fprintf(stderr,"Don't know how to %s\n",what);
+ return -1;
+ }
+
+ fprintf(stderr,"flags: %d, mode: %d\n",flags,mode);
+
+ if ((fd = open(path, flags, mode)) < 0) {
+ fprintf(stderr,"Failed to open file %s\n",argv[3]);
+ return -1;
+ }
+
+ fprintf(stderr,"Open Done, fd : %d\n",fd);
+
+ buff = (char*)malloc(count);
+
+ if (!buff) {
+ perror("Can't allocate\n");
+ return -1;
+ }
+
+ if (*what=='r') {
+ fprintf(stderr,"READ: fd: %d, buff: %p, bytes: %d \n", fd, buff, count);
+
+ bytes = read_all(fd,buff,count);
+
+ if (bytes < 0) {
+ fprintf(stderr,"Failed to read file %s\n",path);
+ free(buff);
+ close(fd);
+ return -1;
+ }
+
+ fprintf(stderr,"WRITE: fd: %d, buff: %p, bytes: %d \n", 1, buff, count);
+
+ bytes = write_all(1,buff,count);
+
+ if (bytes<0) {
+ fprintf(stderr,"Failed to write stdout\n");
+ free(buff);
+ close(fd);
+ return -1;
+ }
+
+ } else if (*what=='w') {
+
+ fprintf(stderr,"READ: fd: %d, buff: %p, bytes: %d \n", 0, buff, count);
+
+ bytes = read_all(0,buff,count);
+
+ if (bytes < 0) {
+ fprintf(stderr,"Failed to read stdin\n");
+ free(buff);
+ close(fd);
+ return -1;
+ }
+
+ fprintf(stderr,"WRITE: fd: %d, buff: %p, bytes: %d \n", fd, buff, count);
+
+ bytes = write_all(fd,buff,count);
+
+ if (bytes<0) {
+ fprintf(stderr,"Failed to write stdout\n");
+ free(buff);
+ close(fd);
+ return -1;
+ }
+
+ }
+
+ free(buff);
+ close(fd);
+ fprintf(stderr,"Close done\n");
+ return 0;
+}