diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2003-07-23 17:42:10 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2003-07-23 17:42:10 +0000 |
commit | f4588d84ab7e59c8e7c9de64f7f0cb6669f0d859 (patch) | |
tree | df2c23f9a01f594084f71bde91f34354b15cde49 /sys/compat/linux | |
parent | b7d53f3d6f307063475beed5f27c182c727e1e04 (diff) |
add sys_sysinfo. from marius aamodt eriksen.
linux_misc.c: fvdl gave his copyright to tnf, adjust.
Diffstat (limited to 'sys/compat/linux')
-rw-r--r-- | sys/compat/linux/linux_dummy.c | 3 | ||||
-rw-r--r-- | sys/compat/linux/linux_misc.c | 79 | ||||
-rw-r--r-- | sys/compat/linux/linux_misc.h | 20 | ||||
-rw-r--r-- | sys/compat/linux/syscalls.master | 5 |
4 files changed, 85 insertions, 22 deletions
diff --git a/sys/compat/linux/linux_dummy.c b/sys/compat/linux/linux_dummy.c index 92bd64330e7..25f049bd26f 100644 --- a/sys/compat/linux/linux_dummy.c +++ b/sys/compat/linux/linux_dummy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: linux_dummy.c,v 1.11 2003/07/03 00:00:04 tedu Exp $ */ +/* $OpenBSD: linux_dummy.c,v 1.12 2003/07/23 17:42:09 tedu Exp $ */ /*- * Copyright (c) 1994-1995 Søren Schmidt @@ -81,7 +81,6 @@ DUMMY(vhangup); /* #111 */ DUMMY(idle); /* #112 */ DUMMY(vm86old); /* #113 */ DUMMY(swapoff); /* #115 */ -DUMMY(sysinfo); /* #116 */ #ifndef __i386__ DUMMY(modify_ldt); /* #123 */ #endif diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c index 26948383bc7..ce1475dcb27 100644 --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -1,10 +1,14 @@ -/* $OpenBSD: linux_misc.c,v 1.50 2003/07/03 00:00:04 tedu Exp $ */ +/* $OpenBSD: linux_misc.c,v 1.51 2003/07/23 17:42:09 tedu Exp $ */ /* $NetBSD: linux_misc.c,v 1.27 1996/05/20 01:59:21 fvdl Exp $ */ -/* - * Copyright (c) 1995 Frank van der Linden +/*- + * Copyright (c) 1995, 1998, 1999 The NetBSD Foundation, Inc. * All rights reserved. * + * This code is derived from software contributed to The NetBSD Foundation + * by Frank van der Linden and Eric Haszlakiewicz; by Jason R. Thorpe + * of the Numerical Aerospace Simulation Facility, NASA Ames Research Center. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -15,21 +19,23 @@ * 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 for the NetBSD Project - * by Frank van der Linden - * 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 product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE 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. + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ /* @@ -1492,3 +1498,42 @@ linux_sys_getgid(p, v, retval) *retval = p->p_cred->p_rgid; return (0); } + + +/* + * sysinfo() + */ +/* ARGSUSED */ +int +linux_sys_sysinfo(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct linux_sys_sysinfo_args /* { + syscallarg(struct linux_sysinfo *) sysinfo; + } */ *uap = v; + struct linux_sysinfo si; + struct loadavg *la; + extern int bufpages; + + + si.uptime = time.tv_sec - boottime.tv_sec; + 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(physmem); + si.freeram = uvmexp.free * uvmexp.pagesize; + si.sharedram = 0;/* XXX */ + si.bufferram = bufpages * PAGE_SIZE; + si.totalswap = uvmexp.swpages * PAGE_SIZE; + si.freeswap = (uvmexp.swpages - uvmexp.swpginuse) * PAGE_SIZE; + 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, SCARG(uap, sysinfo), sizeof(si))); +} diff --git a/sys/compat/linux/linux_misc.h b/sys/compat/linux/linux_misc.h index 3fbeb403251..28e1d5dd812 100644 --- a/sys/compat/linux/linux_misc.h +++ b/sys/compat/linux/linux_misc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: linux_misc.h,v 1.2 2002/03/14 01:26:50 millert Exp $ */ +/* $OpenBSD: linux_misc.h,v 1.3 2003/07/23 17:42:09 tedu Exp $ */ /* $NetBSD: linux_misc.h,v 1.3 1999/05/13 00:31:57 thorpej Exp $ */ /*- @@ -40,6 +40,24 @@ #ifndef _LINUX_MISC_H #define _LINUX_MISC_H +/* This looks very unportable to me, but this is how Linux defines it. */ +struct linux_sysinfo { + long uptime; + unsigned long loads[3]; +#define LINUX_SYSINFO_LOADS_SCALE 65536 + unsigned long totalram; + unsigned long freeram; + unsigned long sharedram; + unsigned long bufferram; + unsigned long totalswap; + unsigned long freeswap; + unsigned short procs; + unsigned long totalbig; + unsigned long freebig; + unsigned int mem_unit; + char _f[20-2*sizeof(long)-sizeof(int)]; +}; + /* * Options passed to the Linux wait4() system call. */ diff --git a/sys/compat/linux/syscalls.master b/sys/compat/linux/syscalls.master index 2e94b4397cc..226739eb780 100644 --- a/sys/compat/linux/syscalls.master +++ b/sys/compat/linux/syscalls.master @@ -1,4 +1,4 @@ - $OpenBSD: syscalls.master,v 1.38 2003/07/03 00:00:04 tedu Exp $ + $OpenBSD: syscalls.master,v 1.39 2003/07/23 17:42:09 tedu Exp $ ; $NetBSD: syscalls.master,v 1.15 1995/12/18 14:35:10 fvdl Exp $ ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93 @@ -40,6 +40,7 @@ #include <compat/linux/linux_types.h> #include <compat/linux/linux_signal.h> +#include <compat/linux/linux_misc.h> #include <compat/linux/linux_syscallargs.h> #include <machine/linux_machdep.h> @@ -202,7 +203,7 @@ 114 STD { int linux_sys_wait4(int pid, int *status, \ int options, struct rusage *rusage); } 115 STD { int linux_sys_swapoff(void); } -116 STD { int linux_sys_sysinfo(void); } +116 STD { int linux_sys_sysinfo(struct linux_sys_sysinfo_args *sysinfo); } 117 STD { int linux_sys_ipc(int what, int a1, int a2, int a3, \ caddr_t ptr); } 118 NOARGS { int sys_fsync(int fd); } |