version 1.193.6.4, 2009/01/17 13:28:44 |
version 1.194, 2008/03/21 21:54:58 |
|
|
* 2. Redistributions in binary form must reproduce the above copyright |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 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 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
|
|
#include <sys/cdefs.h> |
#include <sys/cdefs.h> |
__KERNEL_RCSID(0, "$NetBSD$"); |
__KERNEL_RCSID(0, "$NetBSD$"); |
|
|
|
#if defined(_KERNEL_OPT) |
|
#include "opt_ptrace.h" |
|
#endif |
|
|
#include <sys/param.h> |
#include <sys/param.h> |
#include <sys/systm.h> |
#include <sys/systm.h> |
#include <sys/namei.h> |
#include <sys/namei.h> |
Line 162 const struct linux_mnttypes linux_fstype |
|
Line 173 const struct linux_mnttypes linux_fstype |
|
{ MOUNT_NTFS, LINUX_DEFAULT_SUPER_MAGIC }, |
{ MOUNT_NTFS, LINUX_DEFAULT_SUPER_MAGIC }, |
{ MOUNT_SMBFS, LINUX_SMB_SUPER_MAGIC }, |
{ MOUNT_SMBFS, LINUX_SMB_SUPER_MAGIC }, |
{ MOUNT_PTYFS, LINUX_DEVPTS_SUPER_MAGIC }, |
{ MOUNT_PTYFS, LINUX_DEVPTS_SUPER_MAGIC }, |
{ MOUNT_TMPFS, LINUX_TMPFS_SUPER_MAGIC } |
{ MOUNT_TMPFS, LINUX_DEFAULT_SUPER_MAGIC } |
}; |
}; |
const int linux_fstypes_cnt = sizeof(linux_fstypes) / sizeof(linux_fstypes[0]); |
const int linux_fstypes_cnt = sizeof(linux_fstypes) / sizeof(linux_fstypes[0]); |
|
|
Line 220 linux_sys_wait4(struct lwp *l, const str |
|
Line 231 linux_sys_wait4(struct lwp *l, const str |
|
int error, status, options, linux_options, was_zombie; |
int error, status, options, linux_options, was_zombie; |
struct rusage ru; |
struct rusage ru; |
int pid = SCARG(uap, pid); |
int pid = SCARG(uap, pid); |
proc_t *p; |
|
|
|
linux_options = SCARG(uap, options); |
linux_options = SCARG(uap, options); |
options = WOPTSCHECKED; |
options = WOPTSCHECKED; |
Line 250 linux_sys_wait4(struct lwp *l, const str |
|
Line 260 linux_sys_wait4(struct lwp *l, const str |
|
if (pid == 0) |
if (pid == 0) |
return error; |
return error; |
|
|
p = curproc; |
sigdelset(&l->l_proc->p_sigpend.sp_set, SIGCHLD); /* XXXAD ksiginfo leak */ |
mutex_enter(p->p_lock); |
|
sigdelset(&p->p_sigpend.sp_set, SIGCHLD); /* XXXAD ksiginfo leak */ |
|
mutex_exit(p->p_lock); |
|
|
|
if (SCARG(uap, rusage) != NULL) |
if (SCARG(uap, rusage) != NULL) |
error = copyout(&ru, SCARG(uap, rusage), sizeof(ru)); |
error = copyout(&ru, SCARG(uap, rusage), sizeof(ru)); |
|
|
} |
} |
|
|
int |
int |
|
linux_sys_msync(struct lwp *l, const struct linux_sys_msync_args *uap, register_t *retval) |
|
{ |
|
/* { |
|
syscallarg(void *) addr; |
|
syscallarg(int) len; |
|
syscallarg(int) fl; |
|
} */ |
|
|
|
struct sys___msync13_args bma; |
|
|
|
/* flags are ignored */ |
|
SCARG(&bma, addr) = SCARG(uap, addr); |
|
SCARG(&bma, len) = SCARG(uap, len); |
|
SCARG(&bma, flags) = SCARG(uap, fl); |
|
|
|
return sys___msync13(l, &bma, retval); |
|
} |
|
|
|
int |
linux_sys_mprotect(struct lwp *l, const struct linux_sys_mprotect_args *uap, register_t *retval) |
linux_sys_mprotect(struct lwp *l, const struct linux_sys_mprotect_args *uap, register_t *retval) |
{ |
{ |
/* { |
/* { |
Line 628 linux_sys_times(struct lwp *l, const str |
|
Line 654 linux_sys_times(struct lwp *l, const str |
|
struct linux_tms ltms; |
struct linux_tms ltms; |
struct rusage ru; |
struct rusage ru; |
|
|
mutex_enter(p->p_lock); |
mutex_enter(&p->p_smutex); |
calcru(p, &ru.ru_utime, &ru.ru_stime, NULL, NULL); |
calcru(p, &ru.ru_utime, &ru.ru_stime, NULL, NULL); |
ltms.ltms_utime = CONVTCK(ru.ru_utime); |
ltms.ltms_utime = CONVTCK(ru.ru_utime); |
ltms.ltms_stime = CONVTCK(ru.ru_stime); |
ltms.ltms_stime = CONVTCK(ru.ru_stime); |
ltms.ltms_cutime = CONVTCK(p->p_stats->p_cru.ru_utime); |
ltms.ltms_cutime = CONVTCK(p->p_stats->p_cru.ru_utime); |
ltms.ltms_cstime = CONVTCK(p->p_stats->p_cru.ru_stime); |
ltms.ltms_cstime = CONVTCK(p->p_stats->p_cru.ru_stime); |
mutex_exit(p->p_lock); |
mutex_exit(&p->p_smutex); |
|
|
if ((error = copyout(<ms, SCARG(uap, tms), sizeof ltms))) |
if ((error = copyout(<ms, SCARG(uap, tms), sizeof ltms))) |
return error; |
return error; |
Line 686 linux_sys_getdents(struct lwp *l, const |
|
Line 712 linux_sys_getdents(struct lwp *l, const |
|
off_t *cookiebuf = NULL, *cookie; |
off_t *cookiebuf = NULL, *cookie; |
int ncookies; |
int ncookies; |
|
|
/* fd_getvnode() will use the descriptor for us */ |
/* getvnode() will use the descriptor for us */ |
if ((error = fd_getvnode(SCARG(uap, fd), &fp)) != 0) |
if ((error = getvnode(SCARG(uap, fd), &fp)) != 0) |
return (error); |
return (error); |
|
|
if ((fp->f_flag & FREAD) == 0) { |
if ((fp->f_flag & FREAD) == 0) { |
Line 832 linux_sys_select(struct lwp *l, const st |
|
Line 858 linux_sys_select(struct lwp *l, const st |
|
syscallarg(fd_set *) readfds; |
syscallarg(fd_set *) readfds; |
syscallarg(fd_set *) writefds; |
syscallarg(fd_set *) writefds; |
syscallarg(fd_set *) exceptfds; |
syscallarg(fd_set *) exceptfds; |
syscallarg(struct timeval50 *) timeout; |
syscallarg(struct timeval *) timeout; |
} */ |
} */ |
|
|
return linux_select1(l, retval, SCARG(uap, nfds), SCARG(uap, readfds), |
return linux_select1(l, retval, SCARG(uap, nfds), SCARG(uap, readfds), |
SCARG(uap, writefds), SCARG(uap, exceptfds), |
SCARG(uap, writefds), SCARG(uap, exceptfds), SCARG(uap, timeout)); |
(struct linux_timeval *)SCARG(uap, timeout)); |
|
} |
} |
|
|
/* |
/* |
Line 852 linux_select1(l, retval, nfds, readfds, |
|
Line 877 linux_select1(l, retval, nfds, readfds, |
|
register_t *retval; |
register_t *retval; |
int nfds; |
int nfds; |
fd_set *readfds, *writefds, *exceptfds; |
fd_set *readfds, *writefds, *exceptfds; |
struct linux_timeval *timeout; |
struct timeval *timeout; |
{ |
{ |
struct timeval tv0, tv1, utv, *tv = NULL; |
struct timeval tv0, tv1, utv, *tv = NULL; |
struct linux_timeval ltv; |
|
int error; |
int error; |
|
|
/* |
/* |
Line 863 linux_select1(l, retval, nfds, readfds, |
|
Line 887 linux_select1(l, retval, nfds, readfds, |
|
* time left. |
* time left. |
*/ |
*/ |
if (timeout) { |
if (timeout) { |
if ((error = copyin(timeout, <v, sizeof(ltv)))) |
if ((error = copyin(timeout, &utv, sizeof(utv)))) |
return error; |
return error; |
utv.tv_sec = ltv.tv_sec; |
|
utv.tv_usec = ltv.tv_usec; |
|
if (itimerfix(&utv)) { |
if (itimerfix(&utv)) { |
/* |
/* |
* The timeval was invalid. Convert it to something |
* The timeval was invalid. Convert it to something |
Line 913 linux_select1(l, retval, nfds, readfds, |
|
Line 935 linux_select1(l, retval, nfds, readfds, |
|
timerclear(&utv); |
timerclear(&utv); |
} else |
} else |
timerclear(&utv); |
timerclear(&utv); |
ltv.tv_sec = utv.tv_sec; |
if ((error = copyout(&utv, timeout, sizeof(utv)))) |
ltv.tv_usec = utv.tv_usec; |
|
if ((error = copyout(<v, timeout, sizeof(ltv)))) |
|
return error; |
return error; |
} |
} |
|
|
Line 1042 linux_sys_ptrace(struct lwp *l, const st |
|
Line 1062 linux_sys_ptrace(struct lwp *l, const st |
|
syscallarg(T) addr; |
syscallarg(T) addr; |
syscallarg(T) data; |
syscallarg(T) data; |
} */ |
} */ |
|
#if defined(PTRACE) || defined(_LKM) |
const int *ptr; |
const int *ptr; |
int request; |
int request; |
int error; |
int error; |
|
#ifdef _LKM |
|
#define sys_ptrace (*sysent[SYS_ptrace].sy_call) |
|
#endif |
|
|
ptr = linux_ptrace_request_map; |
ptr = linux_ptrace_request_map; |
request = SCARG(uap, request); |
request = SCARG(uap, request); |
Line 1060 linux_sys_ptrace(struct lwp *l, const st |
|
Line 1084 linux_sys_ptrace(struct lwp *l, const st |
|
/* |
/* |
* Linux ptrace(PTRACE_CONT, pid, 0, 0) means actually |
* Linux ptrace(PTRACE_CONT, pid, 0, 0) means actually |
* to continue where the process left off previously. |
* to continue where the process left off previously. |
* The same thing is achieved by addr == (void *) 1 |
* The same thing is achieved by addr == (void *) 1 |
* on NetBSD, so rewrite 'addr' appropriately. |
* on NetBSD, so rewrite 'addr' appropriately. |
*/ |
*/ |
if (request == LINUX_PTRACE_CONT && SCARG(uap, addr)==0) |
if (request == LINUX_PTRACE_CONT && SCARG(uap, addr)==0) |
SCARG(&pta, addr) = (void *) 1; |
SCARG(&pta, addr) = (void *) 1; |
|
|
error = sysent[SYS_ptrace].sy_call(l, &pta, retval); |
error = sys_ptrace(l, &pta, retval); |
if (error) |
if (error) |
return error; |
return error; |
switch (request) { |
switch (request) { |
Line 1086 linux_sys_ptrace(struct lwp *l, const st |
|
Line 1110 linux_sys_ptrace(struct lwp *l, const st |
|
ptr++; |
ptr++; |
|
|
return LINUX_SYS_PTRACE_ARCH(l, uap, retval); |
return LINUX_SYS_PTRACE_ARCH(l, uap, retval); |
|
#else |
|
return ENOSYS; |
|
#endif /* PTRACE || _LKM */ |
} |
} |
|
|
int |
int |
Line 1114 linux_sys_reboot(struct lwp *l, const st |
|
Line 1141 linux_sys_reboot(struct lwp *l, const st |
|
SCARG(uap, magic2) != LINUX_REBOOT_MAGIC2B) |
SCARG(uap, magic2) != LINUX_REBOOT_MAGIC2B) |
return(EINVAL); |
return(EINVAL); |
|
|
switch ((unsigned long)SCARG(uap, cmd)) { |
switch (SCARG(uap, cmd)) { |
case LINUX_REBOOT_CMD_RESTART: |
case LINUX_REBOOT_CMD_RESTART: |
SCARG(&sra, opt) = RB_AUTOBOOT; |
SCARG(&sra, opt) = RB_AUTOBOOT; |
break; |
break; |