diff options
author | marcel <marcel@FreeBSD.org> | 1999-08-11 13:34:31 +0000 |
---|---|---|
committer | marcel <marcel@FreeBSD.org> | 1999-08-11 13:34:31 +0000 |
commit | be49f50ba7be1e1be51185bcb3705faef02d77f6 (patch) | |
tree | a904f328efafcd3524e191098da170b09e3cfbf7 /sys/i386 | |
parent | 948efc5df127915f75fbdb4f28bd48a60d0e5e7b (diff) | |
download | FreeBSD-src-be49f50ba7be1e1be51185bcb3705faef02d77f6.zip FreeBSD-src-be49f50ba7be1e1be51185bcb3705faef02d77f6.tar.gz |
Do not map {s|g}etrlimit onto FreeBSD syscalls. The arguments don't match.
The linux syscalls translate the arguments first before invoking the
FreeBSD native syscalls.
PR: kern/9591
Originator: John Plevyak <jplevyak@inktomi.com>
Diffstat (limited to 'sys/i386')
-rw-r--r-- | sys/i386/linux/linux.h | 16 | ||||
-rw-r--r-- | sys/i386/linux/linux_misc.c | 53 | ||||
-rw-r--r-- | sys/i386/linux/linux_proto.h | 12 | ||||
-rw-r--r-- | sys/i386/linux/linux_syscall.h | 6 | ||||
-rw-r--r-- | sys/i386/linux/linux_sysent.c | 6 |
5 files changed, 84 insertions, 9 deletions
diff --git a/sys/i386/linux/linux.h b/sys/i386/linux/linux.h index 235e541..405b6e0 100644 --- a/sys/i386/linux/linux.h +++ b/sys/i386/linux/linux.h @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: linux.h,v 1.29 1999/07/08 16:15:18 marcel Exp $ + * $Id: linux.h,v 1.30 1999/07/17 08:24:57 marcel Exp $ */ #ifndef _I386_LINUX_LINUX_H_ @@ -165,6 +165,20 @@ struct trapframe; #define LINUX_SIG_UNBLOCK 1 #define LINUX_SIG_SETMASK 2 +/* resource limits */ +#define LINUX_RLIMIT_CPU 0 +#define LINUX_RLIMIT_FSIZE 1 +#define LINUX_RLIMIT_DATA 2 +#define LINUX_RLIMIT_STACK 3 +#define LINUX_RLIMIT_CORE 4 +#define LINUX_RLIMIT_RSS 5 +#define LINUX_RLIMIT_NPROC 6 +#define LINUX_RLIMIT_NOFILE 7 +#define LINUX_RLIMIT_MEMLOCK 8 +#define LINUX_RLIMIT_AS 9 /* address space limit */ + +#define LINUX_RLIM_NLIMITS 10 + /* keyboard defines */ #define LINUX_KIOCSOUND 0x4B2F #define LINUX_KDMKTONE 0x4B30 diff --git a/sys/i386/linux/linux_misc.c b/sys/i386/linux/linux_misc.c index 4efbf2e..a822beb 100644 --- a/sys/i386/linux/linux_misc.c +++ b/sys/i386/linux/linux_misc.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: linux_misc.c,v 1.59 1999/07/05 19:18:03 marcel Exp $ + * $Id: linux_misc.c,v 1.60 1999/08/08 11:26:46 marcel Exp $ */ #include <sys/param.h> @@ -60,6 +60,15 @@ #include <i386/linux/linux_proto.h> #include <i386/linux/linux_util.h> +int osetrlimit __P((struct proc*, struct linux_setrlimit_args*)); +int ogetrlimit __P((struct proc*, struct linux_getrlimit_args*)); + +static unsigned int linux_to_bsd_resource[LINUX_RLIM_NLIMITS] = +{ RLIMIT_CPU, RLIMIT_FSIZE, RLIMIT_DATA, RLIMIT_STACK, + RLIMIT_CORE, RLIMIT_RSS, RLIMIT_NPROC, RLIMIT_NOFILE, + RLIMIT_MEMLOCK, -1 +}; + int linux_alarm(struct proc *p, struct linux_alarm_args *args) { @@ -1198,3 +1207,45 @@ linux_getgroups(p, uap) p->p_retval[0] = ngrp; return (0); } + +int +linux_setrlimit(p, uap) + struct proc *p; + struct linux_setrlimit_args *uap; +{ +#ifdef DEBUG + printf("Linux-emul(%ld): setrlimit(%d, %p)\n", + (long)p->p_pid, uap->resource, (void *)uap->rlim); +#endif + + if (uap->resource >= LINUX_RLIM_NLIMITS) + return EINVAL; + + uap->resource = linux_to_bsd_resource[uap->resource]; + + if (uap->resource == -1) + return EINVAL; + + return osetrlimit(p, uap); +} + +int +linux_getrlimit(p, uap) + struct proc *p; + struct linux_getrlimit_args *uap; +{ +#ifdef DEBUG + printf("Linux-emul(%ld): getrlimit(%d, %p)\n", + (long)p->p_pid, uap->resource, (void *)uap->rlim); +#endif + + if (uap->resource >= LINUX_RLIM_NLIMITS) + return EINVAL; + + uap->resource = linux_to_bsd_resource[uap->resource]; + + if (uap->resource == -1) + return EINVAL; + + return ogetrlimit(p, uap); +} diff --git a/sys/i386/linux/linux_proto.h b/sys/i386/linux/linux_proto.h index cda56c2..0cf00373 100644 --- a/sys/i386/linux/linux_proto.h +++ b/sys/i386/linux/linux_proto.h @@ -2,7 +2,7 @@ * System call prototypes. * * DO NOT EDIT-- this file is automatically generated. - * created from Id: syscalls.master,v 1.16 1998/12/30 20:58:28 sos Exp + * created from Id: syscalls.master,v 1.17 1999/08/11 13:29:48 marcel Exp */ #ifndef _LINUX_SYSPROTO_H_ @@ -195,6 +195,14 @@ struct linux_sigsuspend_args { struct linux_sigpending_args { linux_sigset_t * mask; char mask_[PAD_(linux_sigset_t *)]; }; +struct linux_setrlimit_args { + u_int resource; char resource_[PAD_(u_int)]; + struct ogetrlimit * rlim; char rlim_[PAD_(struct ogetrlimit *)]; +}; +struct linux_getrlimit_args { + u_int resource; char resource_[PAD_(u_int)]; + struct ogetrlimit * rlim; char rlim_[PAD_(struct ogetrlimit *)]; +}; struct linux_getgroups_args { u_int gidsetsize; char gidsetsize_[PAD_(u_int)]; linux_gid_t * gidset; char gidset_[PAD_(linux_gid_t *)]; @@ -437,6 +445,8 @@ int linux_siggetmask __P((struct proc *, struct linux_siggetmask_args *)); int linux_sigsetmask __P((struct proc *, struct linux_sigsetmask_args *)); int linux_sigsuspend __P((struct proc *, struct linux_sigsuspend_args *)); int linux_sigpending __P((struct proc *, struct linux_sigpending_args *)); +int linux_setrlimit __P((struct proc *, struct linux_setrlimit_args *)); +int linux_getrlimit __P((struct proc *, struct linux_getrlimit_args *)); int linux_getgroups __P((struct proc *, struct linux_getgroups_args *)); int linux_setgroups __P((struct proc *, struct linux_setgroups_args *)); int linux_select __P((struct proc *, struct linux_select_args *)); diff --git a/sys/i386/linux/linux_syscall.h b/sys/i386/linux/linux_syscall.h index e30d836..100288d 100644 --- a/sys/i386/linux/linux_syscall.h +++ b/sys/i386/linux/linux_syscall.h @@ -2,7 +2,7 @@ * System call numbers. * * DO NOT EDIT-- this file is automatically generated. - * created from Id: syscalls.master,v 1.16 1998/12/30 20:58:28 sos Exp + * created from Id: syscalls.master,v 1.17 1999/08/11 13:29:48 marcel Exp */ #define LINUX_SYS_linux_setup 0 @@ -80,8 +80,8 @@ #define LINUX_SYS_linux_sigsuspend 72 #define LINUX_SYS_linux_sigpending 73 #define LINUX_SYS_osethostname 74 -#define LINUX_SYS_osetrlimit 75 -#define LINUX_SYS_ogetrlimit 76 +#define LINUX_SYS_linux_setrlimit 75 +#define LINUX_SYS_linux_getrlimit 76 #define LINUX_SYS_getrusage 77 #define LINUX_SYS_gettimeofday 78 #define LINUX_SYS_settimeofday 79 diff --git a/sys/i386/linux/linux_sysent.c b/sys/i386/linux/linux_sysent.c index a5e8bdb..fa39fd1 100644 --- a/sys/i386/linux/linux_sysent.c +++ b/sys/i386/linux/linux_sysent.c @@ -2,7 +2,7 @@ * System call switch table. * * DO NOT EDIT-- this file is automatically generated. - * created from Id: syscalls.master,v 1.16 1998/12/30 20:58:28 sos Exp + * created from Id: syscalls.master,v 1.17 1999/08/11 13:29:48 marcel Exp */ #include "opt_compat.h" @@ -89,8 +89,8 @@ struct sysent linux_sysent[] = { { 3, (sy_call_t *)linux_sigsuspend }, /* 72 = linux_sigsuspend */ { 1, (sy_call_t *)linux_sigpending }, /* 73 = linux_sigpending */ { 2, (sy_call_t *)osethostname }, /* 74 = osethostname */ - { 2, (sy_call_t *)osetrlimit }, /* 75 = osetrlimit */ - { 2, (sy_call_t *)ogetrlimit }, /* 76 = ogetrlimit */ + { 2, (sy_call_t *)linux_setrlimit }, /* 75 = linux_setrlimit */ + { 2, (sy_call_t *)linux_getrlimit }, /* 76 = linux_getrlimit */ { 2, (sy_call_t *)getrusage }, /* 77 = getrusage */ { 2, (sy_call_t *)gettimeofday }, /* 78 = gettimeofday */ { 2, (sy_call_t *)settimeofday }, /* 79 = settimeofday */ |