Date: Tue, 29 May 2001 18:02:42 -0700 (PDT) From: Jim.Pirzyk@disney.com To: FreeBSD-gnats-submit@freebsd.org Subject: kern/27759: linux module does not support sysinfo system call Message-ID: <200105300102.f4U12gc11399@snoopy.fan.fa.disney.com>
next in thread | raw e-mail | index | archive | help
>Number: 27759 >Category: kern >Synopsis: linux sysinfo system call is needed for maya batch mode to work. >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue May 29 18:10:00 PDT 2001 >Closed-Date: >Last-Modified: >Originator: >Release: FreeBSD 4.3-RELEASE i386 >Organization: >Environment: System: FreeBSD snoopy 4.3-RELEASE FreeBSD 4.3-RELEASE #6: Tue May 29 10:01:46 PDT 2001 root@snoopy:/auto/roy/dist/pub/FreeBSD/4.3-RELEASE/sys/compile/UP_WORKSTATION i386 >Description: The maya batch mode renderer uses sysinfo from the linux kernel to get information about memory & etc from the system. The linux kernel module does not have this system call. >How-To-Repeat: Run a maya render and you get error messages of the following... linux: syscall %s is obsoleted or not implemented (pid=%ld) >Fix: This patch was sent to me by Charles Henrich <henrich@sigbus.com> *** ./sys/i386/linux/linux_dummy.c.orig Wed Jul 19 22:31:56 2000 --- ./sys/i386/linux/linux_dummy.c Fri Dec 1 08:51:52 2000 *************** *** 74,80 **** DUMMY(idle); DUMMY(vm86old); DUMMY(swapoff); - DUMMY(sysinfo); DUMMY(adjtimex); DUMMY(create_module); DUMMY(init_module); --- 74,79 ---- *************** *** 109,112 **** DUMMY(ftruncate64); DUMMY(stat64); DUMMY(lstat64); - DUMMY(fstat64); --- 108,110 ---- *** ./sys/i386/linux/linux_sysent.c.orig Tue Aug 8 16:28:16 2000 --- ./sys/i386/linux/linux_sysent.c Thu Nov 30 17:42:29 2000 *************** *** 133,139 **** { 0, (sy_call_t *)linux_vm86old }, /* 113 = linux_vm86old */ { AS(linux_wait4_args), (sy_call_t *)linux_wait4 }, /* 114 = linux_wait4 */ { 0, (sy_call_t *)linux_swapoff }, /* 115 = linux_swapoff */ ! { 0, (sy_call_t *)linux_sysinfo }, /* 116 = linux_sysinfo */ { AS(linux_ipc_args), (sy_call_t *)linux_ipc }, /* 117 = linux_ipc */ { AS(fsync_args), (sy_call_t *)fsync }, /* 118 = fsync */ { AS(linux_sigreturn_args), (sy_call_t *)linux_sigreturn }, /* 119 = linux_sigreturn */ --- 133,139 ---- { 0, (sy_call_t *)linux_vm86old }, /* 113 = linux_vm86old */ { AS(linux_wait4_args), (sy_call_t *)linux_wait4 }, /* 114 = linux_wait4 */ { 0, (sy_call_t *)linux_swapoff }, /* 115 = linux_swapoff */ ! { AS(linux_sysinfo_args), (sy_call_t *)linux_sysinfo }, /* 116 = linux_sysinfo */ { AS(linux_ipc_args), (sy_call_t *)linux_ipc }, /* 117 = linux_ipc */ { AS(fsync_args), (sy_call_t *)fsync }, /* 118 = fsync */ { AS(linux_sigreturn_args), (sy_call_t *)linux_sigreturn }, /* 119 = linux_sigreturn */ *** ./sys/i386/linux/linux_proto.h.orig Tue Aug 8 16:28:16 2000 --- ./sys/i386/linux/linux_proto.h Thu Nov 30 17:41:12 2000 *************** *** 312,318 **** register_t dummy; }; struct linux_sysinfo_args { ! register_t dummy; }; struct linux_ipc_args { int what; char what_[PAD_(int)]; --- 312,318 ---- register_t dummy; }; struct linux_sysinfo_args { ! struct linux_sysinfo * buf; char buf_[PAD_(struct linux_sysinfo *)]; }; struct linux_ipc_args { int what; char what_[PAD_(int)]; *** ./sys/compat/linux/linux_misc.c.orig Tue Mar 27 18:33:47 2001 --- ./sys/compat/linux/linux_misc.c Fri May 4 15:53:46 2001 *************** *** 40,45 **** --- 40,46 ---- #include <sys/imgact_aout.h> #include <sys/mount.h> #include <sys/namei.h> + #include <sys/resource.h> #include <sys/resourcevar.h> #include <sys/stat.h> #include <sys/sysctl.h> *************** *** 48,59 **** --- 49,64 ---- #include <sys/wait.h> #include <sys/time.h> #include <sys/signalvar.h> + #include <sys/blist.h> + #include <sys/vmmeter.h> #include <vm/vm.h> #include <vm/pmap.h> #include <vm/vm_kern.h> #include <vm/vm_map.h> #include <vm/vm_extern.h> + #include <vm/vm_object.h> + #include <vm/swap_pager.h> #include <machine/frame.h> #include <machine/limits.h> *************** *** 93,98 **** --- 98,176 ---- RLIMIT_MEMLOCK, -1 }; #endif /*!__alpha__*/ + + struct linux_sysinfo { + long uptime; /* Seconds since boot */ + unsigned long loads[3]; /* 1, 5, and 15 minute load averages */ + unsigned long totalram; /* Total usable main memory size */ + unsigned long freeram; /* Available memory size */ + unsigned long sharedram; /* Amount of shared memory */ + unsigned long bufferram; /* Memory used by buffers */ + unsigned long totalswap; /* Total swap space size */ + unsigned long freeswap; /* swap space still available */ + unsigned short procs; /* Number of current processes */ + char _f[22]; /* Pads structure to 64 bytes */ + }; + + int + linux_sysinfo(struct proc *p, struct linux_sysinfo_args *args) + { + struct linux_sysinfo sysinfo; + vm_object_t object; + int i; + struct timespec ts; + + /* Uptime is copied out of print_uptime() procedure in kern_shutdown.c */ + getnanouptime(&ts); + i = 0; + if (ts.tv_sec >= 86400) { + printf("%ldd", ts.tv_sec / 86400); + ts.tv_sec %= 86400; + i = 1; + } + if (i || ts.tv_sec >= 3600) { + printf("%ldh", ts.tv_sec / 3600); + ts.tv_sec %= 3600; + i = 1; + } + if (i || ts.tv_sec >= 60) { + printf("%ldm", ts.tv_sec / 60); + ts.tv_sec %= 60; + i = 1; + } + sysinfo.uptime=ts.tv_sec; + + /* Use the information from the mib to get our load averages */ + for (i = 0; i < 3; i++) + sysinfo.loads[i] = (double) averunnable.ldavg[i] / averunnable.fscale; + + sysinfo.totalram = physmem * PAGE_SIZE; + sysinfo.freeram = sysinfo.totalram - cnt.v_wire_count * PAGE_SIZE; + + sysinfo.sharedram = 0; + for (object = TAILQ_FIRST(&vm_object_list); object != NULL; + object = TAILQ_NEXT(object, object_list)) + if (object->shadow_count > 1) + sysinfo.sharedram += object->resident_page_count; + + sysinfo.sharedram *= PAGE_SIZE; + + sysinfo.bufferram = 0; + + if (swapblist == NULL) { + sysinfo.totalswap= 0; + sysinfo.freeswap = 0; + } else { + sysinfo.totalswap = swapblist->bl_blocks * 1024; + sysinfo.freeswap = swapblist->bl_root->u.bmu_avail * PAGE_SIZE; + } + + sysinfo.procs = 20; /* Hack */ + + return copyout((caddr_t)&sysinfo, (caddr_t)args->buf, + sizeof(struct linux_sysinfo)); + } + #ifndef __alpha__ int >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200105300102.f4U12gc11399>