1 /* $NetBSD: linux32_misc.c,v 1.11 2008/06/16 19:57:43 christos Exp $ */
4 * Copyright (c) 1995, 1998, 1999 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Frank van der Linden and Eric Haszlakiewicz; by Jason R. Thorpe
9 * of the Numerical Aerospace Simulation Facility, NASA Ames Research Center;
10 * by Edgar Fu\ss, Mathematisches Institut der Uni Bonn.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
21 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
34 #include <sys/cdefs.h>
35 __KERNEL_RCSID(0, "$NetBSD: linux32_misc.c,v 1.11 2008/06/16 19:57:43 christos Exp $");
37 #if defined(_KERNEL_OPT)
38 #include "opt_ptrace.h"
41 #include <sys/param.h>
44 #include <sys/types.h>
45 #include <sys/malloc.h>
46 #include <sys/fstypes.h>
47 #include <sys/vfs_syscalls.h>
48 #include <sys/ptrace.h>
50 #include <compat/netbsd32/netbsd32.h>
51 #include <compat/netbsd32/netbsd32_syscallargs.h>
53 #include <compat/linux32/common/linux32_types.h>
54 #include <compat/linux32/common/linux32_signal.h>
55 #include <compat/linux32/linux32_syscallargs.h>
57 #include <compat/linux/common/linux_ptrace.h>
58 #include <compat/linux/common/linux_types.h>
59 #include <compat/linux/common/linux_signal.h>
60 #include <compat/linux/common/linux_misc.h>
61 #include <compat/linux/common/linux_statfs.h>
62 #include <compat/linux/linux_syscallargs.h>
64 extern const struct linux_mnttypes linux_fstypes
[];
65 extern const int linux_fstypes_cnt
;
69 * Implement the fs stat functions. Straightforward.
72 linux32_sys_statfs(struct lwp
*l
, const struct linux32_sys_statfs_args
*uap
, register_t
*retval
)
75 syscallarg(const netbsd32_charp char) path;
76 syscallarg(linux32_statfsp) sp;
79 struct linux_statfs ltmp
;
82 sb
= STATVFSBUF_GET();
83 error
= do_sys_pstatvfs(l
, SCARG_P32(uap
, path
), ST_WAIT
, sb
);
85 bsd_to_linux_statfs(sb
, <mp
);
86 error
= copyout(<mp
, SCARG_P32(uap
, sp
), sizeof ltmp
);
93 extern const int linux_ptrace_request_map
[];
96 linux32_sys_ptrace(struct lwp
*l
, const struct linux32_sys_ptrace_args
*uap
, register_t
*retval
)
99 i386, m68k, powerpc: T=int
101 syscallarg(T) request;
106 #if defined(PTRACE) || defined(_LKM)
111 ptr
= linux_ptrace_request_map
;
112 request
= SCARG(uap
, request
);
114 if (*ptr
++ == request
) {
115 struct sys_ptrace_args pta
;
117 SCARG(&pta
, req
) = *ptr
;
118 SCARG(&pta
, pid
) = SCARG(uap
, pid
);
119 SCARG(&pta
, addr
) = NETBSD32IPTR64(SCARG(uap
, addr
));
120 SCARG(&pta
, data
) = SCARG(uap
, data
);
123 * Linux ptrace(PTRACE_CONT, pid, 0, 0) means actually
124 * to continue where the process left off previously.
125 * The same thing is achieved by addr == (void *) 1
126 * on NetBSD, so rewrite 'addr' appropriately.
128 if (request
== LINUX_PTRACE_CONT
&& SCARG(uap
, addr
)==0)
129 SCARG(&pta
, addr
) = (void *) 1;
131 error
= sys_ptrace(l
, &pta
, retval
);
135 case LINUX_PTRACE_PEEKTEXT
:
136 case LINUX_PTRACE_PEEKDATA
:
137 error
= copyout (retval
,
138 NETBSD32IPTR64(SCARG(uap
, data
)),
140 *retval
= SCARG(uap
, data
);
153 #endif /* PTRACE || _LKM */