diff options
| author | manu <manu@NetBSD.org> | 2006-09-13 19:55:49 +0000 |
|---|---|---|
| committer | manu <manu@NetBSD.org> | 2006-09-13 19:55:49 +0000 |
| commit | 717102f4bb9e8c8b09f23b93cdf07c4e9de56db1 (patch) | |
| tree | 4a308b227f66e814d3a5570536fe6b7f832a2325 /sys/compat/linux32 | |
| parent | 99bb1b27be46d5da4604db5bff5671318d10746e (diff) | |
Jumbo COMPAT_LINUX/COMPAT_LINUX32 bugfix, with the help of Nicolas Joly
- Fix shmat return value on amd64: it uses no black magic with retval[0]
- Fix integer overflows in sysinfo
- Implement sysinfo, mmap2, sched_getparam, sched_getscheduler, mremap,
and madvise in COMPAT_LINUX32
- Fix improper types used in setgroups16/getgroups16
- Implement mmap2 for COMPAT_LINUX32
- Ifdef debug messages by DEBUG_LINUX
Diffstat (limited to 'sys/compat/linux32')
| -rw-r--r-- | sys/compat/linux32/arch/amd64/linux32_missing.h | 19 | ||||
| -rw-r--r-- | sys/compat/linux32/arch/amd64/linux32_syscall.h | 22 | ||||
| -rw-r--r-- | sys/compat/linux32/arch/amd64/linux32_syscallargs.h | 41 | ||||
| -rw-r--r-- | sys/compat/linux32/arch/amd64/linux32_syscalls.c | 18 | ||||
| -rw-r--r-- | sys/compat/linux32/arch/amd64/linux32_sysent.c | 30 | ||||
| -rw-r--r-- | sys/compat/linux32/arch/amd64/linux32_types.h | 3 | ||||
| -rw-r--r-- | sys/compat/linux32/arch/amd64/syscalls.master | 20 | ||||
| -rw-r--r-- | sys/compat/linux32/common/linux32_ioctl.c | 6 | ||||
| -rw-r--r-- | sys/compat/linux32/common/linux32_mman.c | 52 | ||||
| -rw-r--r-- | sys/compat/linux32/common/linux32_sched.c | 23 | ||||
| -rw-r--r-- | sys/compat/linux32/common/linux32_socket.c | 6 | ||||
| -rw-r--r-- | sys/compat/linux32/common/linux32_sysinfo.c | 95 | ||||
| -rw-r--r-- | sys/compat/linux32/common/linux32_types.h | 19 | ||||
| -rw-r--r-- | sys/compat/linux32/common/linux32_unistd.c | 8 | ||||
| -rw-r--r-- | sys/compat/linux32/files.linux32 | 3 |
15 files changed, 312 insertions, 53 deletions
diff --git a/sys/compat/linux32/arch/amd64/linux32_missing.h b/sys/compat/linux32/arch/amd64/linux32_missing.h index 10fe740b811..f6da118acf3 100644 --- a/sys/compat/linux32/arch/amd64/linux32_missing.h +++ b/sys/compat/linux32/arch/amd64/linux32_missing.h @@ -1,4 +1,4 @@ -/* $NetBSD: linux32_missing.h,v 1.1 2006/02/09 19:18:57 manu Exp $ */ +/* $NetBSD: linux32_missing.h,v 1.2 2006/09/13 19:55:49 manu Exp $ */ /*- * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved. @@ -33,6 +33,9 @@ #ifndef _I386_LINUX32_MISSING_H #define _I386_LINUX32_MISSING_H +#include <compat/netbsd32/netbsd32.h> +#include <compat/linux/common/linux_types.h> + /* * system calls not defined for COMPAT_LINUX/amd64 * but needed for COMPAT_LINUX32 @@ -75,12 +78,21 @@ struct linux_sys_nice_args { struct linux_sys_getgroups16_args { syscallarg(int) gidsetsize; - syscallarg(linux32_gid_t *) gidset; + syscallarg(linux_gid_t *) gidset; }; struct linux_sys_setgroups16_args { syscallarg(int) gidsetsize; - syscallarg(linux32_gid_t *) gidset; + syscallarg(linux_gid_t *) gidset; +}; + +struct linux_sys_mmap2_args { + syscallarg(unsigned long) addr; + syscallarg(size_t) len; + syscallarg(int) prot; + syscallarg(int) flags; + syscallarg(int) fd; + syscallarg(linux_off_t) offset; }; #ifdef _KERNEL @@ -94,6 +106,7 @@ int linux_sys_setresgid16(struct lwp *, void *, register_t *); int linux_sys_nice(struct lwp *, void *, register_t *); int linux_sys_getgroups16(struct lwp *, void *, register_t *); int linux_sys_setgroups16(struct lwp *, void *, register_t *); +int linux_sys_mmap2(struct lwp *, void *, register_t *); __END_DECLS #endif /* !_KERNEL */ diff --git a/sys/compat/linux32/arch/amd64/linux32_syscall.h b/sys/compat/linux32/arch/amd64/linux32_syscall.h index e68cef5c0d7..ea17c9c1750 100644 --- a/sys/compat/linux32/arch/amd64/linux32_syscall.h +++ b/sys/compat/linux32/arch/amd64/linux32_syscall.h @@ -1,10 +1,10 @@ -/* $NetBSD: linux32_syscall.h,v 1.9 2006/09/06 12:01:23 manu Exp $ */ +/* $NetBSD: linux32_syscall.h,v 1.10 2006/09/13 19:55:49 manu Exp $ */ /* * System call numbers. * * DO NOT EDIT-- this file is automatically generated. - * created from NetBSD: syscalls.master,v 1.5 2006/09/06 08:32:00 manu Exp + * created from NetBSD: syscalls.master,v 1.6 2006/09/06 12:01:23 manu Exp */ #ifndef _LINUX32_SYS_SYSCALL_H_ @@ -266,6 +266,9 @@ /* syscall: "swapoff" ret: "int" args: "const netbsd32_charp" */ #define LINUX32_SYS_swapoff 115 +/* syscall: "sysinfo" ret: "int" args: "linux32_sysinfop_t" */ +#define LINUX32_SYS_sysinfo 116 + /* syscall: "fsync" ret: "int" args: "int" */ #define LINUX32_SYS_fsync 118 @@ -317,12 +320,21 @@ /* syscall: "munlockall" ret: "int" args: */ #define LINUX32_SYS_munlockall 153 +/* syscall: "sched_getparam" ret: "int" args: "pid_t" "linux32_sched_paramp_t" */ +#define LINUX32_SYS_sched_getparam 155 + /* syscall: "sched_setscheduler" ret: "int" args: "pid_t" "int" "const linux32_sched_paramp_t" */ #define LINUX32_SYS_sched_setscheduler 156 +/* syscall: "sched_getscheduler" ret: "int" args: "pid_t" */ +#define LINUX32_SYS_sched_getscheduler 157 + /* syscall: "nanosleep" ret: "int" args: "const netbsd32_timespecp_t rqtp netbsd32_timespecp_t" */ #define LINUX32_SYS_nanosleep 162 +/* syscall: "mremap" ret: "int" args: "netbsd32_voidp" "netbsd32_size_t" "netbsd32_size_t" "netbsd32_u_long" */ +#define LINUX32_SYS_mremap 163 + /* syscall: "setresuid16" ret: "int" args: "uid_t" "uid_t" "uid_t" */ #define LINUX32_SYS_setresuid16 164 @@ -353,6 +365,9 @@ /* syscall: "ugetrlimit" ret: "int" args: "int" "netbsd32_orlimitp_t" */ #define LINUX32_SYS_ugetrlimit 191 +/* syscall: "mmap2" ret: "linux32_off_t" args: "netbsd32_u_long" "netbsd32_size_t" "int" "int" "int" "linux32_off_t" */ +#define LINUX32_SYS_mmap2 192 + /* syscall: "stat64" ret: "int" args: "const netbsd32_charp" "linux32_stat64p" */ #define LINUX32_SYS_stat64 195 @@ -401,6 +416,9 @@ /* syscall: "setgid" ret: "int" args: "gid_t" */ #define LINUX32_SYS_setgid 214 +/* syscall: "netbsd32_madvise" ret: "int" args: "netbsd32_voidp" "netbsd32_size_t" "int" */ +#define LINUX32_SYS_netbsd32_madvise 219 + /* syscall: "getdents64" ret: "int" args: "int" "linux32_dirent64p_t" "unsigned int" */ #define LINUX32_SYS_getdents64 220 diff --git a/sys/compat/linux32/arch/amd64/linux32_syscallargs.h b/sys/compat/linux32/arch/amd64/linux32_syscallargs.h index a3a69618549..2fc4d823211 100644 --- a/sys/compat/linux32/arch/amd64/linux32_syscallargs.h +++ b/sys/compat/linux32/arch/amd64/linux32_syscallargs.h @@ -1,10 +1,10 @@ -/* $NetBSD: linux32_syscallargs.h,v 1.9 2006/09/06 12:01:23 manu Exp $ */ +/* $NetBSD: linux32_syscallargs.h,v 1.10 2006/09/13 19:55:49 manu Exp $ */ /* * System call argument lists. * * DO NOT EDIT-- this file is automatically generated. - * created from NetBSD: syscalls.master,v 1.5 2006/09/06 08:32:00 manu Exp + * created from NetBSD: syscalls.master,v 1.6 2006/09/06 12:01:23 manu Exp */ #ifndef _LINUX32_SYS_SYSCALLARGS_H_ @@ -256,6 +256,10 @@ struct linux32_sys_swapoff_args { syscallarg(const netbsd32_charp) path; }; +struct linux32_sys_sysinfo_args { + syscallarg(linux32_sysinfop_t) arg; +}; + struct linux32_sys_sigreturn_args { syscallarg(linux32_sigcontextp_t) scp; }; @@ -301,12 +305,24 @@ struct linux32_sys___sysctl_args { syscallarg(linux32___sysctlp_t) lsp; }; +struct linux32_sys_sched_getparam_args { + syscallarg(pid_t) pid; + syscallarg(linux32_sched_paramp_t) sp; +}; + struct linux32_sys_sched_setscheduler_args { syscallarg(pid_t) pid; syscallarg(int) policy; syscallarg(const linux32_sched_paramp_t) sp; }; +struct linux32_sys_mremap_args { + syscallarg(netbsd32_voidp) old_address; + syscallarg(netbsd32_size_t) old_size; + syscallarg(netbsd32_size_t) new_size; + syscallarg(netbsd32_u_long) flags; +}; + struct linux32_sys_rt_sigreturn_args { syscallarg(linux32_ucontextp_t) ucp; }; @@ -335,6 +351,15 @@ struct linux32_sys_ugetrlimit_args { syscallarg(netbsd32_orlimitp_t) rlp; }; +struct linux32_sys_mmap2_args { + syscallarg(netbsd32_u_long) addr; + syscallarg(netbsd32_size_t) len; + syscallarg(int) prot; + syscallarg(int) flags; + syscallarg(int) fd; + syscallarg(linux32_off_t) offset; +}; + struct linux32_sys_stat64_args { syscallarg(const netbsd32_charp) path; syscallarg(linux32_stat64p) sp; @@ -542,6 +567,8 @@ int linux32_sys_wait4(struct lwp *, void *, register_t *); int linux32_sys_swapoff(struct lwp *, void *, register_t *); +int linux32_sys_sysinfo(struct lwp *, void *, register_t *); + int sys_fsync(struct lwp *, void *, register_t *); int linux32_sys_sigreturn(struct lwp *, void *, register_t *); @@ -576,10 +603,16 @@ int sys_mlockall(struct lwp *, void *, register_t *); int sys_munlockall(struct lwp *, void *, register_t *); +int linux32_sys_sched_getparam(struct lwp *, void *, register_t *); + int linux32_sys_sched_setscheduler(struct lwp *, void *, register_t *); +int linux_sys_sched_getscheduler(struct lwp *, void *, register_t *); + int netbsd32_nanosleep(struct lwp *, void *, register_t *); +int linux32_sys_mremap(struct lwp *, void *, register_t *); + int linux_sys_setresuid16(struct lwp *, void *, register_t *); int netbsd32_poll(struct lwp *, void *, register_t *); @@ -600,6 +633,8 @@ int sys___vfork14(struct lwp *, void *, register_t *); int linux32_sys_ugetrlimit(struct lwp *, void *, register_t *); +int linux32_sys_mmap2(struct lwp *, void *, register_t *); + int linux32_sys_stat64(struct lwp *, void *, register_t *); int linux32_sys_lstat64(struct lwp *, void *, register_t *); @@ -620,6 +655,8 @@ int linux32_sys_setresuid(struct lwp *, void *, register_t *); int linux32_sys_setresgid(struct lwp *, void *, register_t *); +int netbsd32_madvise(struct lwp *, void *, register_t *); + int linux32_sys_getdents64(struct lwp *, void *, register_t *); int linux32_sys_fcntl64(struct lwp *, void *, register_t *); diff --git a/sys/compat/linux32/arch/amd64/linux32_syscalls.c b/sys/compat/linux32/arch/amd64/linux32_syscalls.c index cf64d75a42d..4c726ab2c68 100644 --- a/sys/compat/linux32/arch/amd64/linux32_syscalls.c +++ b/sys/compat/linux32/arch/amd64/linux32_syscalls.c @@ -1,14 +1,14 @@ -/* $NetBSD: linux32_syscalls.c,v 1.9 2006/09/06 12:01:23 manu Exp $ */ +/* $NetBSD: linux32_syscalls.c,v 1.10 2006/09/13 19:55:49 manu Exp $ */ /* * System call names. * * DO NOT EDIT-- this file is automatically generated. - * created from NetBSD: syscalls.master,v 1.5 2006/09/06 08:32:00 manu Exp + * created from NetBSD: syscalls.master,v 1.6 2006/09/06 12:01:23 manu Exp */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux32_syscalls.c,v 1.9 2006/09/06 12:01:23 manu Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux32_syscalls.c,v 1.10 2006/09/13 19:55:49 manu Exp $"); #if defined(_KERNEL_OPT) #if defined(_KERNEL_OPT) @@ -153,7 +153,7 @@ const char *const linux32_syscallnames[] = { "#113 (unimplemented vm86old)", /* 113 = unimplemented vm86old */ "wait4", /* 114 = wait4 */ "swapoff", /* 115 = swapoff */ - "#116 (unimplemented sysinfo)", /* 116 = unimplemented sysinfo */ + "sysinfo", /* 116 = sysinfo */ "#117 (unimplemented ipc)", /* 117 = unimplemented ipc */ "fsync", /* 118 = fsync */ "sigreturn", /* 119 = sigreturn */ @@ -192,15 +192,15 @@ const char *const linux32_syscallnames[] = { "mlockall", /* 152 = mlockall */ "munlockall", /* 153 = munlockall */ "#154 (unimplemented sched_setparam)", /* 154 = unimplemented sched_setparam */ - "#155 (unimplemented sched_getparam)", /* 155 = unimplemented sched_getparam */ + "sched_getparam", /* 155 = sched_getparam */ "sched_setscheduler", /* 156 = sched_setscheduler */ - "#157 (unimplemented sched_getscheduler)", /* 157 = unimplemented sched_getscheduler */ + "sched_getscheduler", /* 157 = sched_getscheduler */ "#158 (unimplemented sched_yield)", /* 158 = unimplemented sched_yield */ "#159 (unimplemented sched_get_priority_max)", /* 159 = unimplemented sched_get_priority_max */ "#160 (unimplemented sched_get_priority_min)", /* 160 = unimplemented sched_get_priority_min */ "#161 (unimplemented sched_rr_get_interval)", /* 161 = unimplemented sched_rr_get_interval */ "nanosleep", /* 162 = nanosleep */ - "#163 (unimplemented * mremap)", /* 163 = unimplemented * mremap */ + "mremap", /* 163 = mremap */ "setresuid16", /* 164 = setresuid16 */ "#165 (unimplemented getresuid16)", /* 165 = unimplemented getresuid16 */ "#166 (unimplemented vm86)", /* 166 = unimplemented vm86 */ @@ -229,7 +229,7 @@ const char *const linux32_syscallnames[] = { "#189 (unimplemented putpmsg)", /* 189 = unimplemented putpmsg */ "__vfork14", /* 190 = __vfork14 */ "ugetrlimit", /* 191 = ugetrlimit */ - "#192 (unimplemented mmap2)", /* 192 = unimplemented mmap2 */ + "mmap2", /* 192 = mmap2 */ "#193 (unimplemented truncate64)", /* 193 = unimplemented truncate64 */ "#194 (unimplemented ftruncate64)", /* 194 = unimplemented ftruncate64 */ "stat64", /* 195 = stat64 */ @@ -256,7 +256,7 @@ const char *const linux32_syscallnames[] = { "#216 (unimplemented getfsuid)", /* 216 = unimplemented getfsuid */ "#217 (unimplemented pivot_root)", /* 217 = unimplemented pivot_root */ "#218 (unimplemented mincore)", /* 218 = unimplemented mincore */ - "#219 (unimplemented madvise)", /* 219 = unimplemented madvise */ + "netbsd32_madvise", /* 219 = netbsd32_madvise */ "getdents64", /* 220 = getdents64 */ "fcntl64", /* 221 = fcntl64 */ "#222 (unimplemented / * unused * /)", /* 222 = unimplemented / * unused * / */ diff --git a/sys/compat/linux32/arch/amd64/linux32_sysent.c b/sys/compat/linux32/arch/amd64/linux32_sysent.c index 1e2f995a935..714d2c726a7 100644 --- a/sys/compat/linux32/arch/amd64/linux32_sysent.c +++ b/sys/compat/linux32/arch/amd64/linux32_sysent.c @@ -1,14 +1,14 @@ -/* $NetBSD: linux32_sysent.c,v 1.9 2006/09/06 12:01:23 manu Exp $ */ +/* $NetBSD: linux32_sysent.c,v 1.10 2006/09/13 19:55:49 manu Exp $ */ /* * System call switch table. * * DO NOT EDIT-- this file is automatically generated. - * created from NetBSD: syscalls.master,v 1.5 2006/09/06 08:32:00 manu Exp + * created from NetBSD: syscalls.master,v 1.6 2006/09/06 12:01:23 manu Exp */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux32_sysent.c,v 1.9 2006/09/06 12:01:23 manu Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux32_sysent.c,v 1.10 2006/09/13 19:55:49 manu Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_43.h" @@ -269,8 +269,8 @@ struct sysent linux32_sysent[] = { linux32_sys_wait4 }, /* 114 = wait4 */ { 1, s(struct linux32_sys_swapoff_args), 0, linux32_sys_swapoff }, /* 115 = swapoff */ - { 0, 0, 0, - linux_sys_nosys }, /* 116 = unimplemented sysinfo */ + { 1, s(struct linux32_sys_sysinfo_args), 0, + linux32_sys_sysinfo }, /* 116 = sysinfo */ { 0, 0, 0, linux_sys_nosys }, /* 117 = unimplemented ipc */ { 1, s(struct sys_fsync_args), 0, @@ -347,12 +347,12 @@ struct sysent linux32_sysent[] = { sys_munlockall }, /* 153 = munlockall */ { 0, 0, 0, linux_sys_nosys }, /* 154 = unimplemented sched_setparam */ - { 0, 0, 0, - linux_sys_nosys }, /* 155 = unimplemented sched_getparam */ + { 2, s(struct linux32_sys_sched_getparam_args), 0, + linux32_sys_sched_getparam }, /* 155 = sched_getparam */ { 3, s(struct linux32_sys_sched_setscheduler_args), 0, linux32_sys_sched_setscheduler }, /* 156 = sched_setscheduler */ - { 0, 0, 0, - linux_sys_nosys }, /* 157 = unimplemented sched_getscheduler */ + { 1, s(struct linux_sys_sched_getscheduler_args), 0, + linux_sys_sched_getscheduler }, /* 157 = sched_getscheduler */ { 0, 0, 0, linux_sys_nosys }, /* 158 = unimplemented sched_yield */ { 0, 0, 0, @@ -363,8 +363,8 @@ struct sysent linux32_sysent[] = { linux_sys_nosys }, /* 161 = unimplemented sched_rr_get_interval */ { 1, s(struct netbsd32_nanosleep_args), 0, netbsd32_nanosleep }, /* 162 = nanosleep */ - { 0, 0, 0, - linux_sys_nosys }, /* 163 = unimplemented * mremap */ + { 4, s(struct linux32_sys_mremap_args), 0, + linux32_sys_mremap }, /* 163 = mremap */ { 3, s(struct linux_sys_setresuid16_args), 0, linux_sys_setresuid16 }, /* 164 = setresuid16 */ { 0, 0, 0, @@ -421,8 +421,8 @@ struct sysent linux32_sysent[] = { sys___vfork14 }, /* 190 = __vfork14 */ { 2, s(struct linux32_sys_ugetrlimit_args), 0, linux32_sys_ugetrlimit }, /* 191 = ugetrlimit */ - { 0, 0, 0, - linux_sys_nosys }, /* 192 = unimplemented mmap2 */ + { 6, s(struct linux32_sys_mmap2_args), 0, + linux32_sys_mmap2 }, /* 192 = mmap2 */ { 0, 0, 0, linux_sys_nosys }, /* 193 = unimplemented truncate64 */ { 0, 0, 0, @@ -475,8 +475,8 @@ struct sysent linux32_sysent[] = { linux_sys_nosys }, /* 217 = unimplemented pivot_root */ { 0, 0, 0, linux_sys_nosys }, /* 218 = unimplemented mincore */ - { 0, 0, 0, - linux_sys_nosys }, /* 219 = unimplemented madvise */ + { 3, s(struct netbsd32_madvise_args), 0, + netbsd32_madvise }, /* 219 = netbsd32_madvise */ { 3, s(struct linux32_sys_getdents64_args), 0, linux32_sys_getdents64 }, /* 220 = getdents64 */ { 3, s(struct linux32_sys_fcntl64_args), 0, diff --git a/sys/compat/linux32/arch/amd64/linux32_types.h b/sys/compat/linux32/arch/amd64/linux32_types.h index 11f462fa6c5..969ac8a18d5 100644 --- a/sys/compat/linux32/arch/amd64/linux32_types.h +++ b/sys/compat/linux32/arch/amd64/linux32_types.h @@ -1,4 +1,4 @@ -/* $NetBSD: linux32_types.h,v 1.1 2006/02/09 19:18:57 manu Exp $ */ +/* $NetBSD: linux32_types.h,v 1.2 2006/09/13 19:55:49 manu Exp $ */ /*- * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved. @@ -38,6 +38,7 @@ typedef unsigned short linux32_gid_t; typedef int linux32_pid_t; typedef int32_t linux32_clock_t; typedef int32_t linux32_time_t; +typedef int32_t linux32_off_t; #define LINUX_STAT64_HAS_NSEC 1 struct linux32_stat64 { diff --git a/sys/compat/linux32/arch/amd64/syscalls.master b/sys/compat/linux32/arch/amd64/syscalls.master index baf8ee6861c..69082e428ac 100644 --- a/sys/compat/linux32/arch/amd64/syscalls.master +++ b/sys/compat/linux32/arch/amd64/syscalls.master @@ -1,4 +1,4 @@ - $NetBSD: syscalls.master,v 1.6 2006/09/06 12:01:23 manu Exp $ + $NetBSD: syscalls.master,v 1.7 2006/09/13 19:55:49 manu Exp $ ; NetBSD i386 COMPAT_LINUX32 system call name/number "master" file. ; (See syscalls.conf to see what it is processed into.) @@ -211,7 +211,7 @@ 114 STD { int linux32_sys_wait4(int pid, netbsd32_intp status, \ int options, netbsd32_rusagep_t rusage); } 115 STD { int linux32_sys_swapoff(const netbsd32_charp path); } -116 UNIMPL sysinfo +116 STD { int linux32_sys_sysinfo(linux32_sysinfop_t arg); } 117 UNIMPL ipc 118 NOARGS { int sys_fsync(int fd); } 119 STD { int linux32_sys_sigreturn(linux32_sigcontextp_t scp); } @@ -259,10 +259,11 @@ 152 NOARGS { int sys_mlockall(int flags); } 153 NOARGS { int sys_munlockall(void); } 154 UNIMPL sched_setparam -155 UNIMPL sched_getparam +155 STD { int linux32_sys_sched_getparam(pid_t pid, \ + linux32_sched_paramp_t sp); } 156 STD { int linux32_sys_sched_setscheduler(pid_t pid, \ int policy, const linux32_sched_paramp_t sp); } -157 UNIMPL sched_getscheduler +157 NOARGS { int linux_sys_sched_getscheduler(pid_t pid); } 158 UNIMPL sched_yield 159 UNIMPL sched_get_priority_max 160 UNIMPL sched_get_priority_min @@ -270,7 +271,9 @@ 162 NOARGS nanosleep { int netbsd32_nanosleep(const \ netbsd32_timespecp_t rqtp \ netbsd32_timespecp_t rmtp); } -163 UNIMPL *mremap +163 STD { int linux32_sys_mremap(netbsd32_voidp old_address, \ + netbsd32_size_t old_size , netbsd32_size_t new_size, \ + netbsd32_u_long flags); } 164 NOARGS { int linux_sys_setresuid16(uid_t ruid, uid_t euid, \ uid_t suid); } 165 UNIMPL getresuid16 @@ -311,7 +314,9 @@ 190 NOARGS { int sys___vfork14(void); } 191 STD { int linux32_sys_ugetrlimit(int which, \ netbsd32_orlimitp_t rlp); } -192 UNIMPL mmap2 +192 STD { linux32_off_t linux32_sys_mmap2(netbsd32_u_long addr, \ + netbsd32_size_t len, int prot, int flags, int fd, \ + linux32_off_t offset); } 193 UNIMPL truncate64 194 UNIMPL ftruncate64 195 STD { int linux32_sys_stat64(const netbsd32_charp path, \ @@ -345,7 +350,8 @@ 216 UNIMPL getfsuid 217 UNIMPL pivot_root 218 UNIMPL mincore -219 UNIMPL madvise +219 NOARGS { int netbsd32_madvise(netbsd32_voidp addr, \ + netbsd32_size_t len, int behav); } 220 STD { int linux32_sys_getdents64(int fd, \ linux32_dirent64p_t dent, unsigned int count); } 221 STD { int linux32_sys_fcntl64(int fd, \ diff --git a/sys/compat/linux32/common/linux32_ioctl.c b/sys/compat/linux32/common/linux32_ioctl.c index 950d7a5b4f0..451aff9f7fe 100644 --- a/sys/compat/linux32/common/linux32_ioctl.c +++ b/sys/compat/linux32/common/linux32_ioctl.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux32_ioctl.c,v 1.3 2006/08/25 08:25:03 manu Exp $ */ +/* $NetBSD: linux32_ioctl.c,v 1.4 2006/09/13 19:55:49 manu Exp $ */ /*- * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved. @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux32_ioctl.c,v 1.3 2006/08/25 08:25:03 manu Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux32_ioctl.c,v 1.4 2006/09/13 19:55:49 manu Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -72,8 +72,10 @@ linux32_sys_ioctl(l, v, retval) group = LINUX32_IOCGROUP((int)SCARG(uap, com)); +#ifdef DEBUG_LINUX printf("linux32_sys_ioctl(%d, 0x%x/\'%c\', %p)\n", SCARG(uap, fd), SCARG(uap, com), (char)group, NETBSD32PTR64(SCARG(uap, data))); +#endif switch(group) { case 'T': diff --git a/sys/compat/linux32/common/linux32_mman.c b/sys/compat/linux32/common/linux32_mman.c index 17cbb1c70b9..3c76e816066 100644 --- a/sys/compat/linux32/common/linux32_mman.c +++ b/sys/compat/linux32/common/linux32_mman.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux32_mman.c,v 1.1 2006/02/09 19:18:57 manu Exp $ */ +/* $NetBSD: linux32_mman.c,v 1.2 2006/09/13 19:55:49 manu Exp $ */ /*- * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved. @@ -33,7 +33,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux32_mman.c,v 1.1 2006/02/09 19:18:57 manu Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux32_mman.c,v 1.2 2006/09/13 19:55:49 manu Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -105,3 +105,51 @@ linux32_sys_mprotect(l, v, retval) NETBSD32TO64_UAP(prot); return (linux_sys_mprotect(l, &ua, retval)); } + +int +linux32_sys_mremap(l, v, retval) + struct lwp *l; + void *v; + register_t *retval; +{ + struct linux32_sys_mremap_args /* { + syscallarg(netbsd32_voidp) old_address; + syscallarg(netbsd32_size_t) old_size; + syscallarg(netbsd32_size_t) new_size; + syscallarg(netbsd32_u_long) flags; + } */ *uap = v; + struct linux_sys_mremap_args ua; + + NETBSD32TOP_UAP(old_address, void); + NETBSD32TOX_UAP(old_size, size_t); + NETBSD32TOX_UAP(new_size, size_t); + NETBSD32TOX_UAP(flags, u_long); + + return linux_sys_mremap(l, &ua, retval); +} + +int +linux32_sys_mmap2(l, v, retval) + struct lwp *l; + void *v; + register_t *retval; +{ + struct linux32_sys_mmap2_args /* { + syscallarg(netbsd32_u_long) addr; + syscallarg(netbsd32_size_t) len; + syscallarg(int) prot; + syscallarg(int) flags; + syscallarg(int) fd; + syscallarg(linux32_off_t) offset; + } */ *uap = v; + struct linux_sys_mmap2_args ua; + + NETBSD32TOX64_UAP(addr, u_long); + NETBSD32TOX64_UAP(len, size_t); + NETBSD32TO64_UAP(prot); + NETBSD32TO64_UAP(flags); + NETBSD32TO64_UAP(fd); + NETBSD32TOX64_UAP(offset, linux_off_t); + + return linux_sys_mmap2(l, &ua, retval); +} diff --git a/sys/compat/linux32/common/linux32_sched.c b/sys/compat/linux32/common/linux32_sched.c index 9bea7b1d19b..41f1b6d9078 100644 --- a/sys/compat/linux32/common/linux32_sched.c +++ b/sys/compat/linux32/common/linux32_sched.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux32_sched.c,v 1.1 2006/02/09 19:18:57 manu Exp $ */ +/* $NetBSD: linux32_sched.c,v 1.2 2006/09/13 19:55:49 manu Exp $ */ /*- * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved. @@ -33,7 +33,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux32_sched.c,v 1.1 2006/02/09 19:18:57 manu Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux32_sched.c,v 1.2 2006/09/13 19:55:49 manu Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -111,3 +111,22 @@ linux32_sys_sched_setscheduler(l, v, retval) return linux_sys_sched_setscheduler(l, &ua, retval); } + +int +linux32_sys_sched_getparam(l, v, retval) + struct lwp *l; + void *v; + register_t *retval; +{ + struct linux32_sys_sched_getparam_args /* { + syscallarg(pid_t) pid; + syscallarg(linux32_sched_paramp_t *) sp; + } */ *uap = v; + struct linux_sys_sched_getparam_args ua; + + NETBSD32TO64_UAP(pid); + NETBSD32TOP_UAP(sp, struct linux_sched_param); + + return linux_sys_sched_getparam(l, &ua, retval); +} + diff --git a/sys/compat/linux32/common/linux32_socket.c b/sys/compat/linux32/common/linux32_socket.c index 4ad8305062c..3f1ac1a19e4 100644 --- a/sys/compat/linux32/common/linux32_socket.c +++ b/sys/compat/linux32/common/linux32_socket.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux32_socket.c,v 1.1 2006/02/09 19:18:57 manu Exp $ */ +/* $NetBSD: linux32_socket.c,v 1.2 2006/09/13 19:55:49 manu Exp $ */ /*- * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved. @@ -33,7 +33,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux32_socket.c,v 1.1 2006/02/09 19:18:57 manu Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux32_socket.c,v 1.2 2006/09/13 19:55:49 manu Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -251,8 +251,10 @@ linux32_sys_connect(l, v, retval) NETBSD32TOP_UAP(name, struct osockaddr) NETBSD32TO64_UAP(namelen); +#ifdef DEBUG_LINUX printf("linux32_sys_connect: s = %d, name = %p, namelen = %d\n", SCARG(&ua, s), SCARG(&ua, name), SCARG(&ua, namelen)); +#endif return linux_sys_connect(l, &ua, retval); } diff --git a/sys/compat/linux32/common/linux32_sysinfo.c b/sys/compat/linux32/common/linux32_sysinfo.c new file mode 100644 index 00000000000..5cf0608f1bb --- /dev/null +++ b/sys/compat/linux32/common/linux32_sysinfo.c @@ -0,0 +1,95 @@ +/* $NetBSD: linux32_sysinfo.c,v 1.1 2006/09/13 19:55:49 manu Exp $ */ + +/*- + * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Emmanuel Dreyfus + * 4. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE THE AUTHOR AND CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> + +__KERNEL_RCSID(0, "$NetBSD: linux32_sysinfo.c,v 1.1 2006/09/13 19:55:49 manu Exp $"); + +#include <sys/types.h> +#include <sys/param.h> +#include <sys/kernel.h> +#include <sys/sa.h> +#include <sys/dirent.h> + +#include <sys/syscallargs.h> + +#include <uvm/uvm_extern.h> + +#include <compat/netbsd32/netbsd32.h> +#include <compat/netbsd32/netbsd32_conv.h> +#include <compat/netbsd32/netbsd32_syscallargs.h> + +#include <compat/linux/common/linux_types.h> +#include <compat/linux/common/linux_signal.h> +#include <compat/linux/common/linux_misc.h> +#include <compat/linux/linux_syscallargs.h> + +#include <compat/linux32/common/linux32_types.h> +#include <compat/linux32/common/linux32_signal.h> +#include <compat/linux32/linux32_syscallargs.h> + +/* ARGSUSED */ +int +linux32_sys_sysinfo(l, v, retval) + struct lwp *l; + void *v; + register_t *retval; +{ + struct linux32_sys_sysinfo_args /* { + syscallarg(struct linux32_sysinfo *) arg; + } */ *uap = v; + struct linux32_sysinfo si; + struct loadavg *la; + + si.uptime = time_uptime; + la = &averunnable; + si.loads[0] = la->ldavg[0] * LINUX_SYSINFO_LOADS_SCALE / la->fscale; + si.loads[1] = la->ldavg[1] * LINUX_SYSINFO_LOADS_SCALE / la->fscale; + si.loads[2] = la->ldavg[2] * LINUX_SYSINFO_LOADS_SCALE / la->fscale; + si.totalram = ctob((u_long)physmem); + si.freeram = (u_long)uvmexp.free * uvmexp.pagesize; + si.sharedram = 0; /* XXX */ + si.bufferram = (u_long)uvmexp.filepages * uvmexp.pagesize; + si.totalswap = (u_long)uvmexp.swpages * uvmexp.pagesize; + si.freeswap = + (u_long)(uvmexp.swpages - uvmexp.swpginuse) * uvmexp.pagesize; + si.procs = nprocs; + + /* The following are only present in newer Linux kernels. */ + si.totalbig = 0; + si.freebig = 0; + si.mem_unit = 1; + + return (copyout(&si, NETBSD32PTR64(SCARG(uap, arg)), sizeof si)); +} + diff --git a/sys/compat/linux32/common/linux32_types.h b/sys/compat/linux32/common/linux32_types.h index c09a33fc446..9c58beac80e 100644 --- a/sys/compat/linux32/common/linux32_types.h +++ b/sys/compat/linux32/common/linux32_types.h @@ -1,4 +1,4 @@ -/* $NetBSD: linux32_types.h,v 1.1 2006/02/09 19:18:57 manu Exp $ */ +/* $NetBSD: linux32_types.h,v 1.2 2006/09/13 19:55:49 manu Exp $ */ /*- * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved. @@ -54,6 +54,7 @@ typedef netbsd32_pointer_t linux32_utimbufp_t; typedef netbsd32_pointer_t linux32_oldold_utsnamep_t; typedef netbsd32_pointer_t linux32_gidp_t; typedef netbsd32_pointer_t linux32_oldselectp_t; +typedef netbsd32_pointer_t linux32_sysinfop_t; struct linux32_sysctl { netbsd32_intp name; @@ -80,4 +81,20 @@ struct linux32_oldselect { netbsd32_timevalp_t timeout; }; +struct linux32_sysinfo { + netbsd32_long uptime; + netbsd32_u_long loads[3]; + netbsd32_u_long totalram; + netbsd32_u_long freeram; + netbsd32_u_long sharedram; + netbsd32_u_long bufferram; + netbsd32_u_long totalswap; + netbsd32_u_long freeswap; + unsigned short procs; + netbsd32_u_long totalbig; + netbsd32_u_long freebig; + unsigned int mem_unit; + char _f[20-2*sizeof(netbsd32_long)-sizeof(int)]; +}; + #endif /* !_LINUX32_TYPES_H */ diff --git a/sys/compat/linux32/common/linux32_unistd.c b/sys/compat/linux32/common/linux32_unistd.c index 4777bd44ffd..2f02389ded5 100644 --- a/sys/compat/linux32/common/linux32_unistd.c +++ b/sys/compat/linux32/common/linux32_unistd.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux32_unistd.c,v 1.3 2006/09/06 08:32:00 manu Exp $ */ +/* $NetBSD: linux32_unistd.c,v 1.4 2006/09/13 19:55:49 manu Exp $ */ /*- * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved. @@ -33,7 +33,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux32_unistd.c,v 1.3 2006/09/06 08:32:00 manu Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux32_unistd.c,v 1.4 2006/09/13 19:55:49 manu Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -549,7 +549,7 @@ linux32_sys_getgroups16(l, v, retval) struct linux_sys_getgroups16_args ua; NETBSD32TO64_UAP(gidsetsize); - NETBSD32TOP_UAP(gidset, linux32_gid_t); + NETBSD32TOP_UAP(gidset, linux_gid_t); return linux_sys_getgroups16(l, &ua, retval); } @@ -567,7 +567,7 @@ linux32_sys_setgroups16(l, v, retval) struct linux_sys_setgroups16_args ua; NETBSD32TO64_UAP(gidsetsize); - NETBSD32TOP_UAP(gidset, linux32_gid_t); + NETBSD32TOP_UAP(gidset, linux_gid_t); return linux_sys_setgroups16(l, &ua, retval); } diff --git a/sys/compat/linux32/files.linux32 b/sys/compat/linux32/files.linux32 index 5405e8cf930..7ece45aa25b 100644 --- a/sys/compat/linux32/files.linux32 +++ b/sys/compat/linux32/files.linux32 @@ -1,4 +1,4 @@ -# $NetBSD: files.linux32,v 1.2 2006/02/15 09:31:17 manu Exp $ +# $NetBSD: files.linux32,v 1.3 2006/09/13 19:55:49 manu Exp $ # # Config file description for machine-independent Linux 32 bit compat code. # Included by ports that need it. @@ -19,6 +19,7 @@ file compat/linux32/common/linux32_socket.c compat_linux32 file compat/linux32/common/linux32_socketcall.c compat_linux32 file compat/linux32/common/linux32_stat.c compat_linux32 file compat/linux32/common/linux32_sysctl.c compat_linux32 +file compat/linux32/common/linux32_sysinfo.c compat_linux32 file compat/linux32/common/linux32_time.c compat_linux32 file compat/linux32/common/linux32_termios.c compat_linux32 file compat/linux32/common/linux32_unistd.c compat_linux32 |
