version 1.61, 1999/10/05 09:22:04 |
version 1.61.2.5, 2001/03/27 15:31:47 |
|
|
#include <sys/mbuf.h> |
#include <sys/mbuf.h> |
#include <sys/mman.h> |
#include <sys/mman.h> |
#include <sys/mount.h> |
#include <sys/mount.h> |
#include <sys/ptrace.h> |
#include <sys/reboot.h> |
#include <sys/resource.h> |
#include <sys/resource.h> |
#include <sys/resourcevar.h> |
#include <sys/resourcevar.h> |
#include <sys/signal.h> |
#include <sys/signal.h> |
|
|
#include <sys/wait.h> |
#include <sys/wait.h> |
#include <sys/utsname.h> |
#include <sys/utsname.h> |
#include <sys/unistd.h> |
#include <sys/unistd.h> |
|
#include <sys/swap.h> /* for SWAP_ON */ |
|
#include <sys/sysctl.h> /* for KERN_DOMAINNAME */ |
|
|
#include <sys/syscallargs.h> |
#include <sys/ptrace.h> |
|
#include <machine/ptrace.h> |
|
|
#include <vm/vm.h> |
#include <sys/syscallargs.h> |
#include <vm/vm_param.h> |
|
|
|
#include <compat/linux/common/linux_types.h> |
#include <compat/linux/common/linux_types.h> |
#include <compat/linux/common/linux_signal.h> |
#include <compat/linux/common/linux_signal.h> |
|
|
#include <compat/linux/common/linux_dirent.h> |
#include <compat/linux/common/linux_dirent.h> |
#include <compat/linux/common/linux_util.h> |
#include <compat/linux/common/linux_util.h> |
#include <compat/linux/common/linux_misc.h> |
#include <compat/linux/common/linux_misc.h> |
|
#include <compat/linux/common/linux_ptrace.h> |
|
#include <compat/linux/common/linux_reboot.h> |
|
#include <compat/linux/common/linux_emuldata.h> |
|
|
|
const int linux_ptrace_request_map[] = { |
|
LINUX_PTRACE_TRACEME, PT_TRACE_ME, |
|
LINUX_PTRACE_PEEKTEXT, PT_READ_I, |
|
LINUX_PTRACE_PEEKDATA, PT_READ_D, |
|
LINUX_PTRACE_POKETEXT, PT_WRITE_I, |
|
LINUX_PTRACE_POKEDATA, PT_WRITE_D, |
|
LINUX_PTRACE_CONT, PT_CONTINUE, |
|
LINUX_PTRACE_KILL, PT_KILL, |
|
LINUX_PTRACE_ATTACH, PT_ATTACH, |
|
LINUX_PTRACE_DETACH, PT_DETACH, |
|
#ifdef PT_STEP |
|
LINUX_PTRACE_SINGLESTEP, PT_STEP, |
|
#endif |
|
-1 |
|
}; |
|
|
/* Local linux_misc.c functions: */ |
/* Local linux_misc.c functions: */ |
static void bsd_to_linux_statfs __P((struct statfs *, struct linux_statfs *)); |
static void bsd_to_linux_statfs __P((struct statfs *, struct linux_statfs *)); |
Line 180 linux_sys_wait4(p, v, retval) |
|
Line 200 linux_sys_wait4(p, v, retval) |
|
if ((error = sys_wait4(p, &w4a, retval))) |
if ((error = sys_wait4(p, &w4a, retval))) |
return error; |
return error; |
|
|
sigdelset(&p->p_siglist, SIGCHLD); |
sigdelset(&p->p_sigctx.ps_siglist, SIGCHLD); |
|
|
if (status != NULL) { |
if (status != NULL) { |
if ((error = copyin(status, &tstat, sizeof tstat))) |
if ((error = copyin(status, &tstat, sizeof tstat))) |
Line 209 linux_sys_brk(p, v, retval) |
|
Line 229 linux_sys_brk(p, v, retval) |
|
char *nbrk = SCARG(uap, nsize); |
char *nbrk = SCARG(uap, nsize); |
struct sys_obreak_args oba; |
struct sys_obreak_args oba; |
struct vmspace *vm = p->p_vmspace; |
struct vmspace *vm = p->p_vmspace; |
caddr_t oldbrk; |
struct linux_emuldata *ed = (struct linux_emuldata*)p->p_emuldata; |
|
|
oldbrk = vm->vm_daddr + ctob(vm->vm_dsize); |
|
/* |
|
* XXX inconsistent.. Linux always returns at least the old |
|
* brk value, but it will be page-aligned if this fails, |
|
* and possibly not page aligned if it succeeds (the user |
|
* supplied pointer is returned). |
|
*/ |
|
SCARG(&oba, nsize) = nbrk; |
SCARG(&oba, nsize) = nbrk; |
|
|
if ((caddr_t) nbrk > vm->vm_daddr && sys_obreak(p, &oba, retval) == 0) |
if ((caddr_t) nbrk > vm->vm_daddr && sys_obreak(p, &oba, retval) == 0) |
retval[0] = (register_t)nbrk; |
ed->p_break = (char*)nbrk; |
else |
else |
retval[0] = (register_t)oldbrk; |
nbrk = ed->p_break; |
|
|
|
retval[0] = (register_t)nbrk; |
|
|
return 0; |
return 0; |
} |
} |
Line 274 linux_sys_statfs(p, v, retval) |
|
Line 289 linux_sys_statfs(p, v, retval) |
|
sg = stackgap_init(p->p_emul); |
sg = stackgap_init(p->p_emul); |
bsp = (struct statfs *) stackgap_alloc(&sg, sizeof (struct statfs)); |
bsp = (struct statfs *) stackgap_alloc(&sg, sizeof (struct statfs)); |
|
|
LINUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); |
CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); |
|
|
SCARG(&bsa, path) = SCARG(uap, path); |
SCARG(&bsa, path) = SCARG(uap, path); |
SCARG(&bsa, buf) = bsp; |
SCARG(&bsa, buf) = bsp; |
Line 323 linux_sys_fstatfs(p, v, retval) |
|
Line 338 linux_sys_fstatfs(p, v, retval) |
|
return copyout((caddr_t) <mp, (caddr_t) SCARG(uap, sp), sizeof ltmp); |
return copyout((caddr_t) <mp, (caddr_t) SCARG(uap, sp), sizeof ltmp); |
} |
} |
|
|
|
char linux_sysname[] = "Linux"; |
|
char linux_release[] = "2.0.38"; |
|
char linux_version[] = "#0 Sun Apr 1 11:11:11 MET 2000"; |
|
|
/* |
/* |
* uname(). Just copy the info from the various strings stored in the |
* uname(). Just copy the info from the various strings stored in the |
* kernel, and put it in the Linux utsname structure. That structure |
* kernel, and put it in the Linux utsname structure. That structure |
Line 338 linux_sys_uname(p, v, retval) |
|
Line 357 linux_sys_uname(p, v, retval) |
|
struct linux_sys_uname_args /* { |
struct linux_sys_uname_args /* { |
syscallarg(struct linux_utsname *) up; |
syscallarg(struct linux_utsname *) up; |
} */ *uap = v; |
} */ *uap = v; |
extern char ostype[], hostname[], osrelease[], version[], machine[], |
|
domainname[]; |
|
struct linux_utsname luts; |
struct linux_utsname luts; |
int len; |
|
char *cp; |
|
|
|
strncpy(luts.l_sysname, ostype, sizeof(luts.l_sysname)); |
strncpy(luts.l_sysname, linux_sysname, sizeof(luts.l_sysname)); |
strncpy(luts.l_nodename, hostname, sizeof(luts.l_nodename)); |
strncpy(luts.l_nodename, hostname, sizeof(luts.l_nodename)); |
strncpy(luts.l_release, osrelease, sizeof(luts.l_release)); |
strncpy(luts.l_release, linux_release, sizeof(luts.l_release)); |
strncpy(luts.l_version, version, sizeof(luts.l_version)); |
strncpy(luts.l_version, linux_version, sizeof(luts.l_version)); |
strncpy(luts.l_machine, machine, sizeof(luts.l_machine)); |
strncpy(luts.l_machine, machine, sizeof(luts.l_machine)); |
strncpy(luts.l_domainname, domainname, sizeof(luts.l_domainname)); |
strncpy(luts.l_domainname, domainname, sizeof(luts.l_domainname)); |
|
|
/* This part taken from the the uname() in libc */ |
|
len = sizeof(luts.l_version); |
|
for (cp = luts.l_version; len--; ++cp) { |
|
if (*cp == '\n' || *cp == '\t') { |
|
if (len > 1) |
|
*cp = ' '; |
|
else |
|
*cp = '\0'; |
|
} |
|
} |
|
|
|
return copyout(&luts, SCARG(uap, up), sizeof(luts)); |
return copyout(&luts, SCARG(uap, up), sizeof(luts)); |
} |
} |
|
|
Line 402 linux_sys_mmap(p, v, retval) |
|
Line 406 linux_sys_mmap(p, v, retval) |
|
if (SCARG(&cma,prot) & VM_PROT_WRITE) /* XXX */ |
if (SCARG(&cma,prot) & VM_PROT_WRITE) /* XXX */ |
SCARG(&cma,prot) |= VM_PROT_READ; |
SCARG(&cma,prot) |= VM_PROT_READ; |
SCARG(&cma,flags) = flags; |
SCARG(&cma,flags) = flags; |
SCARG(&cma,fd) = SCARG(uap, fd); |
SCARG(&cma,fd) = flags & MAP_ANON ? -1 : SCARG(uap, fd); |
SCARG(&cma,pad) = 0; |
SCARG(&cma,pad) = 0; |
SCARG(&cma,pos) = SCARG(uap, offset); |
SCARG(&cma,pos) = SCARG(uap, offset); |
|
|
Line 548 linux_sys_getdents(p, v, retval) |
|
Line 552 linux_sys_getdents(p, v, retval) |
|
syscallarg(struct linux_dirent *) dent; |
syscallarg(struct linux_dirent *) dent; |
syscallarg(unsigned int) count; |
syscallarg(unsigned int) count; |
} */ *uap = v; |
} */ *uap = v; |
register struct dirent *bdp; |
struct dirent *bdp; |
struct vnode *vp; |
struct vnode *vp; |
caddr_t inp, buf; /* BSD-format */ |
caddr_t inp, buf; /* BSD-format */ |
int len, reclen; /* BSD-format */ |
int len, reclen; /* BSD-format */ |
Line 850 linux_sys_personality(p, v, retval) |
|
Line 854 linux_sys_personality(p, v, retval) |
|
return 0; |
return 0; |
} |
} |
|
|
|
#if defined(__i386__) || defined(__m68k__) |
/* |
/* |
* The calls are here because of type conversions. |
* The calls are here because of type conversions. |
*/ |
*/ |
int |
int |
linux_sys_setreuid(p, v, retval) |
linux_sys_setreuid16(p, v, retval) |
struct proc *p; |
struct proc *p; |
void *v; |
void *v; |
register_t *retval; |
register_t *retval; |
{ |
{ |
struct linux_sys_setreuid_args /* { |
struct linux_sys_setreuid16_args /* { |
syscallarg(int) ruid; |
syscallarg(int) ruid; |
syscallarg(int) euid; |
syscallarg(int) euid; |
} */ *uap = v; |
} */ *uap = v; |
Line 874 linux_sys_setreuid(p, v, retval) |
|
Line 879 linux_sys_setreuid(p, v, retval) |
|
} |
} |
|
|
int |
int |
linux_sys_setregid(p, v, retval) |
linux_sys_setregid16(p, v, retval) |
struct proc *p; |
struct proc *p; |
void *v; |
void *v; |
register_t *retval; |
register_t *retval; |
{ |
{ |
struct linux_sys_setregid_args /* { |
struct linux_sys_setregid16_args /* { |
syscallarg(int) rgid; |
syscallarg(int) rgid; |
syscallarg(int) egid; |
syscallarg(int) egid; |
} */ *uap = v; |
} */ *uap = v; |
Line 894 linux_sys_setregid(p, v, retval) |
|
Line 899 linux_sys_setregid(p, v, retval) |
|
} |
} |
|
|
int |
int |
|
linux_sys_setresuid16(p, v, retval) |
|
struct proc *p; |
|
void *v; |
|
register_t *retval; |
|
{ |
|
struct linux_sys_setresuid16_args /* { |
|
syscallarg(uid_t) ruid; |
|
syscallarg(uid_t) euid; |
|
syscallarg(uid_t) suid; |
|
} */ *uap = v; |
|
struct linux_sys_setresuid16_args lsa; |
|
|
|
SCARG(&lsa, ruid) = ((linux_uid_t)SCARG(uap, ruid) == (linux_uid_t)-1) ? |
|
(uid_t)-1 : SCARG(uap, ruid); |
|
SCARG(&lsa, euid) = ((linux_uid_t)SCARG(uap, euid) == (linux_uid_t)-1) ? |
|
(uid_t)-1 : SCARG(uap, euid); |
|
SCARG(&lsa, suid) = ((linux_uid_t)SCARG(uap, suid) == (linux_uid_t)-1) ? |
|
(uid_t)-1 : SCARG(uap, suid); |
|
|
|
return linux_sys_setresuid(p, &lsa, retval); |
|
} |
|
|
|
int |
|
linux_sys_setresgid16(p, v, retval) |
|
struct proc *p; |
|
void *v; |
|
register_t *retval; |
|
{ |
|
struct linux_sys_setresgid16_args /* { |
|
syscallarg(gid_t) rgid; |
|
syscallarg(gid_t) egid; |
|
syscallarg(gid_t) sgid; |
|
} */ *uap = v; |
|
struct linux_sys_setresgid16_args lsa; |
|
|
|
SCARG(&lsa, rgid) = ((linux_gid_t)SCARG(uap, rgid) == (linux_gid_t)-1) ? |
|
(gid_t)-1 : SCARG(uap, rgid); |
|
SCARG(&lsa, egid) = ((linux_gid_t)SCARG(uap, egid) == (linux_gid_t)-1) ? |
|
(gid_t)-1 : SCARG(uap, egid); |
|
SCARG(&lsa, sgid) = ((linux_gid_t)SCARG(uap, sgid) == (linux_gid_t)-1) ? |
|
(gid_t)-1 : SCARG(uap, sgid); |
|
|
|
return linux_sys_setresgid(p, &lsa, retval); |
|
} |
|
|
|
int |
|
linux_sys_getgroups16(p, v, retval) |
|
struct proc *p; |
|
void *v; |
|
register_t *retval; |
|
{ |
|
struct linux_sys_getgroups16_args /* { |
|
syscallarg(int) gidsetsize; |
|
syscallarg(linux_gid_t *) gidset; |
|
} */ *uap = v; |
|
caddr_t sg; |
|
int n, error, i; |
|
struct sys_getgroups_args bsa; |
|
gid_t *bset, *kbset; |
|
linux_gid_t *lset; |
|
struct pcred *pc = p->p_cred; |
|
|
|
n = SCARG(uap, gidsetsize); |
|
if (n < 0) |
|
return EINVAL; |
|
error = 0; |
|
bset = kbset = NULL; |
|
lset = NULL; |
|
if (n > 0) { |
|
n = min(pc->pc_ucred->cr_ngroups, n); |
|
sg = stackgap_init(p->p_emul); |
|
bset = stackgap_alloc(&sg, n * sizeof (gid_t)); |
|
kbset = malloc(n * sizeof (gid_t), M_TEMP, M_WAITOK); |
|
lset = malloc(n * sizeof (linux_gid_t), M_TEMP, M_WAITOK); |
|
if (bset == NULL || kbset == NULL || lset == NULL) |
|
return ENOMEM; |
|
SCARG(&bsa, gidsetsize) = n; |
|
SCARG(&bsa, gidset) = bset; |
|
error = sys_getgroups(p, &bsa, retval); |
|
if (error != 0) |
|
goto out; |
|
error = copyin(bset, kbset, n * sizeof (gid_t)); |
|
if (error != 0) |
|
goto out; |
|
for (i = 0; i < n; i++) |
|
lset[i] = (linux_gid_t)kbset[i]; |
|
error = copyout(lset, SCARG(uap, gidset), |
|
n * sizeof (linux_gid_t)); |
|
} else |
|
*retval = pc->pc_ucred->cr_ngroups; |
|
out: |
|
if (kbset != NULL) |
|
free(kbset, M_TEMP); |
|
if (lset != NULL) |
|
free(lset, M_TEMP); |
|
return error; |
|
} |
|
|
|
int |
|
linux_sys_setgroups16(p, v, retval) |
|
struct proc *p; |
|
void *v; |
|
register_t *retval; |
|
{ |
|
struct linux_sys_setgroups16_args /* { |
|
syscallarg(int) gidsetsize; |
|
syscallarg(linux_gid_t *) gidset; |
|
} */ *uap = v; |
|
caddr_t sg; |
|
int n; |
|
int error, i; |
|
struct sys_setgroups_args bsa; |
|
gid_t *bset, *kbset; |
|
linux_gid_t *lset; |
|
|
|
n = SCARG(uap, gidsetsize); |
|
if (n < 0 || n > NGROUPS) |
|
return EINVAL; |
|
sg = stackgap_init(p->p_emul); |
|
bset = stackgap_alloc(&sg, n * sizeof (gid_t)); |
|
lset = malloc(n * sizeof (linux_gid_t), M_TEMP, M_WAITOK); |
|
kbset = malloc(n * sizeof (linux_gid_t), M_TEMP, M_WAITOK); |
|
if (lset == NULL || bset == NULL) |
|
return ENOMEM; |
|
error = copyin(SCARG(uap, gidset), lset, n * sizeof (linux_gid_t)); |
|
if (error != 0) |
|
goto out; |
|
for (i = 0; i < n; i++) |
|
kbset[i] = (gid_t)lset[i]; |
|
error = copyout(kbset, bset, n * sizeof (gid_t)); |
|
if (error != 0) |
|
goto out; |
|
SCARG(&bsa, gidsetsize) = n; |
|
SCARG(&bsa, gidset) = bset; |
|
error = sys_setgroups(p, &bsa, retval); |
|
|
|
out: |
|
if (lset != NULL) |
|
free(lset, M_TEMP); |
|
if (kbset != NULL) |
|
free(kbset, M_TEMP); |
|
|
|
return error; |
|
} |
|
|
|
#endif /* __i386__ || __m68k__ */ |
|
|
|
/* |
|
* We have nonexistent fsuid equal to uid. |
|
* If modification is requested, refuse. |
|
*/ |
|
int |
|
linux_sys_setfsuid(p, v, retval) |
|
struct proc *p; |
|
void *v; |
|
register_t *retval; |
|
{ |
|
struct linux_sys_setfsuid_args /* { |
|
syscallarg(uid_t) uid; |
|
} */ *uap = v; |
|
uid_t uid; |
|
|
|
uid = SCARG(uap, uid); |
|
if (p->p_cred->p_ruid != uid) |
|
return sys_nosys(p, v, retval); |
|
else |
|
return (0); |
|
} |
|
|
|
/* XXX XXX XXX */ |
|
#ifndef alpha |
|
int |
|
linux_sys_getfsuid(p, v, retval) |
|
struct proc *p; |
|
void *v; |
|
register_t *retval; |
|
{ |
|
return sys_getuid(p, v, retval); |
|
} |
|
#endif |
|
|
|
int |
linux_sys___sysctl(p, v, retval) |
linux_sys___sysctl(p, v, retval) |
struct proc *p; |
struct proc *p; |
void *v; |
void *v; |
Line 1019 linux_sys_getresuid(p, v, retval) |
|
Line 1206 linux_sys_getresuid(p, v, retval) |
|
|
|
return (copyout(&pc->p_svuid, SCARG(uap, suid), sizeof(uid_t))); |
return (copyout(&pc->p_svuid, SCARG(uap, suid), sizeof(uid_t))); |
} |
} |
|
|
|
int |
|
linux_sys_ptrace(p, v, retval) |
|
struct proc *p; |
|
void *v; |
|
register_t *retval; |
|
{ |
|
struct linux_sys_ptrace_args /* { |
|
i386, m68k: T=int |
|
alpha: T=long |
|
syscallarg(T) request; |
|
syscallarg(T) pid; |
|
syscallarg(T) addr; |
|
syscallarg(T) data; |
|
} */ *uap = v; |
|
const int *ptr; |
|
int request; |
|
|
|
ptr = linux_ptrace_request_map; |
|
request = SCARG(uap, request); |
|
while (*ptr != -1) |
|
if (*ptr++ == request) { |
|
struct sys_ptrace_args pta; |
|
caddr_t sg; |
|
|
|
sg = stackgap_init(p->p_emul); |
|
|
|
SCARG(&pta, req) = *ptr; |
|
SCARG(&pta, pid) = SCARG(uap, pid); |
|
SCARG(&pta, addr) = (caddr_t)SCARG(uap, addr); |
|
SCARG(&pta, data) = SCARG(uap, data); |
|
|
|
/* |
|
* Linux ptrace(PTRACE_CONT, pid, 0, 0) means actually |
|
* to continue as the process left off previously, |
|
* i.e. same as if NetBSD ptrace called with |
|
* addr == (caddr_t) 1. |
|
*/ |
|
if (request == LINUX_PTRACE_CONT && SCARG(uap, addr)==0) |
|
SCARG(&pta, addr) = (caddr_t) 1; |
|
|
|
return sys_ptrace(p, &pta, retval); |
|
} |
|
else |
|
ptr++; |
|
|
|
return LINUX_SYS_PTRACE_ARCH(p, uap, retval); |
|
} |
|
|
|
int |
|
linux_sys_reboot(struct proc *p, void *v, register_t *retval) |
|
{ |
|
struct linux_sys_reboot_args /* { |
|
syscallarg(int) magic1; |
|
syscallarg(int) magic2; |
|
syscallarg(int) cmd; |
|
syscallarg(void *) arg; |
|
} */ *uap = v; |
|
struct sys_reboot_args /* { |
|
syscallarg(int) opt; |
|
syscallarg(char *) bootstr; |
|
} */ sra; |
|
int error; |
|
|
|
if ((error = suser(p->p_ucred, &p->p_acflag)) != 0) |
|
return(error); |
|
|
|
if (SCARG(uap, magic1) != LINUX_REBOOT_MAGIC1) |
|
return(EINVAL); |
|
if (SCARG(uap, magic2) != LINUX_REBOOT_MAGIC2 && |
|
SCARG(uap, magic2) != LINUX_REBOOT_MAGIC2A && |
|
SCARG(uap, magic2) != LINUX_REBOOT_MAGIC2B) |
|
return(EINVAL); |
|
|
|
switch (SCARG(uap, cmd)) { |
|
case LINUX_REBOOT_CMD_RESTART: |
|
SCARG(&sra, opt) = RB_AUTOBOOT; |
|
break; |
|
case LINUX_REBOOT_CMD_HALT: |
|
SCARG(&sra, opt) = RB_HALT; |
|
break; |
|
case LINUX_REBOOT_CMD_POWER_OFF: |
|
SCARG(&sra, opt) = RB_HALT|RB_POWERDOWN; |
|
break; |
|
case LINUX_REBOOT_CMD_RESTART2: |
|
/* Reboot with an argument. */ |
|
SCARG(&sra, opt) = RB_AUTOBOOT|RB_STRING; |
|
SCARG(&sra, bootstr) = SCARG(uap, arg); |
|
break; |
|
case LINUX_REBOOT_CMD_CAD_ON: |
|
return(EINVAL); /* We don't implement ctrl-alt-delete */ |
|
case LINUX_REBOOT_CMD_CAD_OFF: |
|
return(0); |
|
default: |
|
return(EINVAL); |
|
} |
|
|
|
return(sys_reboot(p, &sra, retval)); |
|
} |
|
|
|
/* |
|
* Copy of compat_12_sys_swapon(). |
|
*/ |
|
int |
|
linux_sys_swapon(p, v, retval) |
|
struct proc *p; |
|
void *v; |
|
register_t *retval; |
|
{ |
|
struct sys_swapctl_args ua; |
|
struct linux_sys_swapon_args /* { |
|
syscallarg(const char *) name; |
|
} */ *uap = v; |
|
|
|
SCARG(&ua, cmd) = SWAP_ON; |
|
SCARG(&ua, arg) = (void *)SCARG(uap, name); |
|
SCARG(&ua, misc) = 0; /* priority */ |
|
return (sys_swapctl(p, &ua, retval)); |
|
} |
|
|
|
/* |
|
* Stop swapping to the file or block device specified by path. |
|
*/ |
|
int |
|
linux_sys_swapoff(p, v, retval) |
|
struct proc *p; |
|
void *v; |
|
register_t *retval; |
|
{ |
|
struct sys_swapctl_args ua; |
|
struct linux_sys_swapoff_args /* { |
|
syscallarg(const char *) path; |
|
} */ *uap = v; |
|
|
|
SCARG(&ua, cmd) = SWAP_OFF; |
|
SCARG(&ua, arg) = (void *)SCARG(uap, path); |
|
return (sys_swapctl(p, &ua, retval)); |
|
} |
|
|
|
/* |
|
* Copy of compat_09_sys_setdomainname() |
|
*/ |
|
/* ARGSUSED */ |
|
int |
|
linux_sys_setdomainname(p, v, retval) |
|
struct proc *p; |
|
void *v; |
|
register_t *retval; |
|
{ |
|
struct linux_sys_setdomainname_args /* { |
|
syscallarg(char *) domainname; |
|
syscallarg(int) len; |
|
} */ *uap = v; |
|
int name; |
|
int error; |
|
|
|
if ((error = suser(p->p_ucred, &p->p_acflag)) != 0) |
|
return (error); |
|
name = KERN_DOMAINNAME; |
|
return (kern_sysctl(&name, 1, 0, 0, SCARG(uap, domainname), |
|
SCARG(uap, len), p)); |
|
} |
|
|
|
/* |
|
* 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 *) arg; |
|
} */ *uap = v; |
|
struct linux_sysinfo si; |
|
struct loadavg *la; |
|
|
|
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 = uvmexp.vnodepages * uvmexp.pagesize; |
|
si.totalswap = uvmexp.swpages * uvmexp.pagesize; |
|
si.freeswap = (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, SCARG(uap, arg), sizeof si)); |
|
} |