diff options
author | Niklas Hallqvist <niklas@cvs.openbsd.org> | 2000-06-07 13:35:03 +0000 |
---|---|---|
committer | Niklas Hallqvist <niklas@cvs.openbsd.org> | 2000-06-07 13:35:03 +0000 |
commit | 6068de15f5e9c8dd2178681c254cbf48a33161ab (patch) | |
tree | e9e9bf8ab75c51210c4d229f757e689a1a06566a /sys/compat/linux | |
parent | fdc7ea79b974a8ddbbe38db1e5891477cf53de61 (diff) |
Fix linux [gs]etrlimit emulation + add their latest ugetrlimit
Diffstat (limited to 'sys/compat/linux')
-rw-r--r-- | sys/compat/linux/files.linux | 7 | ||||
-rw-r--r-- | sys/compat/linux/linux_resource.c | 134 | ||||
-rw-r--r-- | sys/compat/linux/linux_resource.h | 60 | ||||
-rw-r--r-- | sys/compat/linux/syscalls.master | 12 |
4 files changed, 205 insertions, 8 deletions
diff --git a/sys/compat/linux/files.linux b/sys/compat/linux/files.linux index e907dffad6e..06fd0a59d0f 100644 --- a/sys/compat/linux/files.linux +++ b/sys/compat/linux/files.linux @@ -1,4 +1,4 @@ -# $OpenBSD: files.linux,v 1.8 2000/03/27 22:38:11 jasoni Exp $ +# $OpenBSD: files.linux,v 1.9 2000/06/07 13:35:01 niklas Exp $ # $NetBSD: files.linux,v 1.4 1996/03/08 04:55:59 mycroft Exp $ # # Config.new file description for machine-independent Linux compat code. @@ -11,13 +11,14 @@ file compat/linux/linux_cdrom.c compat_linux file compat/linux/linux_error.c compat_linux file compat/linux/linux_exec.c compat_linux file compat/linux/linux_file.c compat_linux +file compat/linux/linux_getcwd.c compat_linux file compat/linux/linux_ioctl.c compat_linux file compat/linux/linux_ipc.c compat_linux file compat/linux/linux_misc.c compat_linux +file compat/linux/linux_mount.c compat_linux +file compat/linux/linux_resource.c compat_linux file compat/linux/linux_signal.c compat_linux file compat/linux/linux_socket.c compat_linux file compat/linux/linux_syscalls.c compat_linux & syscall_debug file compat/linux/linux_sysent.c compat_linux file compat/linux/linux_termios.c compat_linux -file compat/linux/linux_mount.c compat_linux -file compat/linux/linux_getcwd.c compat_linux diff --git a/sys/compat/linux/linux_resource.c b/sys/compat/linux/linux_resource.c new file mode 100644 index 00000000000..3a6a9860a08 --- /dev/null +++ b/sys/compat/linux/linux_resource.c @@ -0,0 +1,134 @@ +/* $OpenBSD: linux_resource.c,v 1.1 2000/06/07 13:35:02 niklas Exp $ */ + +/* + * Copyright (c) 2000 Niklas Hallqvist + * 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 Niklas Hallqvist + * 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 AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Linux "resource" syscall emulation + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/mount.h> +#include <sys/proc.h> +#include <sys/resource.h> +#include <sys/resourcevar.h> +#include <sys/syscallargs.h> + +#include <compat/linux/linux_types.h> +#include <compat/linux/linux_resource.h> +#include <compat/linux/linux_signal.h> +#include <compat/linux/linux_syscallargs.h> + +#define MIN(a,b) (((a)<(b))?(a):(b)) + +/* linux_resource.c */ +int linux_to_bsd_rlimit __P((u_int)); +int linux_dogetrlimit __P((struct proc *, void *, register_t *, rlim_t)); + +static u_int linux_to_bsd_rlimit_map[] = { + RLIMIT_CPU, + RLIMIT_FSIZE, + RLIMIT_DATA, + RLIMIT_STACK, + RLIMIT_CORE, + RLIMIT_RSS, + RLIMIT_NPROC, + RLIMIT_NOFILE, + RLIMIT_MEMLOCK, + RLIM_NLIMITS /* LINUX_RLIMIT_AS not supported */ +}; + +int +linux_to_bsd_rlimit(which) + u_int which; +{ + if (which >= LINUX_RLIM_NLIMITS) + return (RLIM_NLIMITS); + return (linux_to_bsd_rlimit_map[which]); +} + +int +linux_sys_setrlimit(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct linux_sys_setrlimit_args /* { + syscallarg(u_int) which; + syscallarg(struct linux_rlimit *) rlp; + } */ *uap = v; + + SCARG(uap, which) = linux_to_bsd_rlimit(SCARG(uap, which)); + if (SCARG(uap, which) == RLIM_NLIMITS) + return (EINVAL); + return (compat_43_sys_setrlimit(p, v, retval)); +} + +int +linux_dogetrlimit(p, v, retval, max) + struct proc *p; + void *v; + register_t *retval; + rlim_t max; +{ + struct linux_sys_getrlimit_args /* { + syscallarg(u_int) which; + syscallarg(struct linux_rlimit *) rlp; + } */ *uap = v; + u_int which; + struct linux_rlimit rlim; + + which = linux_to_bsd_rlimit(SCARG(uap, which)); + if (which == RLIM_NLIMITS) + return (EINVAL); + + rlim.rlim_cur = MIN(p->p_rlimit[which].rlim_cur, max); + rlim.rlim_max = MIN(p->p_rlimit[which].rlim_max, max); + return (copyout(&rlim, SCARG(uap, rlp), sizeof rlim)); +} + +int +linux_sys_getrlimit(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + return (linux_dogetrlimit(p, v, retval, LINUX_OLD_RLIM_INFINITY)); +} + +int +linux_sys_ugetrlimit(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + return (linux_dogetrlimit(p, v, retval, LINUX_RLIM_INFINITY)); +} diff --git a/sys/compat/linux/linux_resource.h b/sys/compat/linux/linux_resource.h new file mode 100644 index 00000000000..19a953123b1 --- /dev/null +++ b/sys/compat/linux/linux_resource.h @@ -0,0 +1,60 @@ +/* $OpenBSD: linux_resource.h,v 1.1 2000/06/07 13:35:02 niklas Exp $ */ + +/* + * Copyright (c) 2000 Niklas Hallqvist + * 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 Niklas Hallqvist + * 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 AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _LINUX_RESOURCE_H_ +#define _LINUX_RESOURCE_H_ + +/* + * Resource limits + */ +#define LINUX_RLIMIT_CPU 0 /* cpu time in milliseconds */ +#define LINUX_RLIMIT_FSIZE 1 /* maximum file size */ +#define LINUX_RLIMIT_DATA 2 /* data size */ +#define LINUX_RLIMIT_STACK 3 /* stack size */ +#define LINUX_RLIMIT_CORE 4 /* core file size */ +#define LINUX_RLIMIT_RSS 5 /* resident set size */ +#define LINUX_RLIMIT_NPROC 6 /* number of processes */ +#define LINUX_RLIMIT_NOFILE 7 /* number of open files */ +#define LINUX_RLIMIT_MEMLOCK 8 /* locked-in-memory address space */ +#define LINUX_RLIMIT_AS 9 /* address space limit */ + +#define LINUX_RLIM_NLIMITS 10 /* number of resource limits */ + +#define LINUX_RLIM_INFINITY 0xFFFFFFFF +#define LINUX_OLD_RLIM_INFINITY 0x7FFFFFFF + +struct linux_rlimit { + u_long rlim_cur; + u_long rlim_max; +}; + +#endif /* !_LINUX_RESOURCE_H_ */ diff --git a/sys/compat/linux/syscalls.master b/sys/compat/linux/syscalls.master index 932f76f9fa5..abeefc2287a 100644 --- a/sys/compat/linux/syscalls.master +++ b/sys/compat/linux/syscalls.master @@ -1,4 +1,4 @@ - $OpenBSD: syscalls.master,v 1.22 2000/04/12 04:22:40 jasoni Exp $ + $OpenBSD: syscalls.master,v 1.23 2000/06/07 13:35:02 niklas Exp $ ; $NetBSD: syscalls.master,v 1.15 1995/12/18 14:35:10 fvdl Exp $ ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93 @@ -130,10 +130,10 @@ 73 STD { int linux_sys_sigpending(linux_old_sigset_t *mask); } 74 NOARGS { int compat_43_sys_sethostname(char *hostname, \ u_int len);} -75 NOARGS { int compat_43_sys_setrlimit(u_int which, \ - struct ogetrlimit *rlp); } -76 NOARGS { int compat_43_sys_getrlimit(u_int which, \ - struct ogetrlimit *rlp); } +75 STD { int linux_sys_setrlimit(u_int which, \ + struct linux_rlimit *rlp); } +76 STD { int linux_sys_getrlimit(u_int which, \ + struct linux_rlimit *rlp); } 77 NOARGS { int sys_getrusage(int who, struct rusage *rusage); } 78 NOARGS { int sys_gettimeofday(struct timeval *tp, \ struct timezone *tzp); } @@ -301,3 +301,5 @@ 188 UNIMPL getpmsg 189 UNIMPL putpmsg 190 STD { int sys_vfork(void); } +191 STD { int linux_sys_ugetrlimit(u_int which, \ + struct linux_rlimit *rlp); } |