Cleanup. Kill a few netbsd32_caddr_t in syscalls argument types.
[netbsd-mini2440.git] / sys / compat / netbsd32 / netbsd32_compat_12.c
blob30edeb642a2de72974f9ec0478c01e7a1d10bd02
1 /* $NetBSD: netbsd32_compat_12.c,v 1.31 2008/05/29 14:51:26 mrg Exp $ */
3 /*
4 * Copyright (c) 1998, 2001 Matthew R. Green
5 * All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
29 #include <sys/cdefs.h>
30 __KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_12.c,v 1.31 2008/05/29 14:51:26 mrg Exp $");
32 #if defined(_KERNEL_OPT)
33 #include "opt_compat_netbsd.h"
34 #endif
36 #include <sys/param.h>
37 #include <sys/systm.h>
38 #include <sys/mount.h>
39 #include <sys/mman.h>
40 #include <sys/proc.h>
41 #include <sys/stat.h>
42 #include <sys/swap.h>
43 #include <sys/syscallargs.h>
45 #include <compat/sys/stat.h>
47 #include <compat/netbsd32/netbsd32.h>
48 #include <compat/netbsd32/netbsd32_syscallargs.h>
50 static void netbsd32_stat12_to_netbsd32(struct stat12 *,
51 struct netbsd32_stat12 *);
53 /* for use with {,fl}stat() */
54 static void
55 netbsd32_stat12_to_netbsd32(struct stat12 *sp12, struct netbsd32_stat12 *sp32)
58 sp32->st_dev = sp12->st_dev;
59 sp32->st_ino = sp12->st_ino;
60 sp32->st_mode = sp12->st_mode;
61 sp32->st_nlink = sp12->st_nlink;
62 sp32->st_uid = sp12->st_uid;
63 sp32->st_gid = sp12->st_gid;
64 sp32->st_rdev = sp12->st_rdev;
65 if (sp12->st_size < (quad_t)1 << 32)
66 sp32->st_size = sp12->st_size;
67 else
68 sp32->st_size = -2;
69 sp32->st_atimespec.tv_sec = sp12->st_atimespec.tv_sec;
70 sp32->st_atimespec.tv_nsec = sp12->st_atimespec.tv_nsec;
71 sp32->st_mtimespec.tv_sec = sp12->st_mtimespec.tv_sec;
72 sp32->st_mtimespec.tv_nsec = sp12->st_mtimespec.tv_nsec;
73 sp32->st_ctimespec.tv_sec = sp12->st_ctimespec.tv_sec;
74 sp32->st_ctimespec.tv_nsec = sp12->st_ctimespec.tv_nsec;
75 sp32->st_blocks = sp12->st_blocks;
76 sp32->st_blksize = sp12->st_blksize;
77 sp32->st_flags = sp12->st_flags;
78 sp32->st_gen = sp12->st_gen;
81 int
82 compat_12_netbsd32_reboot(struct lwp *l, const struct compat_12_netbsd32_reboot_args *uap, register_t *retval)
84 /* {
85 syscallarg(int) opt;
86 } */
87 struct compat_12_sys_reboot_args ua;
89 NETBSD32TO64_UAP(opt);
90 return (compat_12_sys_reboot(l, &ua, retval));
93 int
94 compat_12_netbsd32_msync(struct lwp *l, const struct compat_12_netbsd32_msync_args *uap, register_t *retval)
96 /* {
97 syscallarg(netbsd32_voidp) addr;
98 syscallarg(netbsd32_size_t) len;
99 } */
100 struct sys___msync13_args ua;
102 NETBSD32TOP_UAP(addr, void *);
103 NETBSD32TOX_UAP(len, size_t);
104 SCARG(&ua, flags) = MS_SYNC | MS_INVALIDATE;
105 return (sys___msync13(l, &ua, retval));
109 compat_12_netbsd32_oswapon(struct lwp *l, const struct compat_12_netbsd32_oswapon_args *uap, register_t *retval)
111 /* {
112 syscallarg(const netbsd32_charp) name;
113 } */
114 struct sys_swapctl_args ua;
116 SCARG(&ua, cmd) = SWAP_ON;
117 SCARG(&ua, arg) = SCARG_P32(uap, name);
118 SCARG(&ua, misc) = 0; /* priority */
119 return (sys_swapctl(l, &ua, retval));
123 compat_12_netbsd32_stat12(struct lwp *l, const struct compat_12_netbsd32_stat12_args *uap, register_t *retval)
125 /* {
126 syscallarg(const netbsd32_charp) path;
127 syscallarg(netbsd32_stat12p_t) ub;
128 } */
129 struct netbsd32_stat12 *sp32, sb32;
130 struct stat12 sb12;
131 struct stat12 *sp12 = &sb12;
132 struct compat_12_sys_stat_args ua;
133 int rv;
135 NETBSD32TOP_UAP(path, const char);
136 SCARG(&ua, ub) = &sb12;
138 rv = compat_12_sys_stat(l, &ua, retval);
139 if (rv)
140 return (rv);
142 sp32 = SCARG_P32(uap, ub);
143 netbsd32_stat12_to_netbsd32(sp12, &sb32);
145 return (copyout(&sb32, sp32, sizeof sb32));
149 compat_12_netbsd32_fstat12(struct lwp *l, const struct compat_12_netbsd32_fstat12_args *uap, register_t *retval)
151 /* {
152 syscallarg(int) fd;
153 syscallarg(netbsd32_stat12p_t) sb;
154 } */
155 struct netbsd32_stat12 *sp32, sb32;
156 struct stat12 sb12;
157 struct stat12 *sp12 = &sb12;
158 struct compat_12_sys_fstat_args ua;
159 int rv;
161 NETBSD32TO64_UAP(fd);
162 SCARG(&ua, sb) = &sb12;
163 rv = compat_12_sys_fstat(l, &ua, retval);
164 if (rv)
165 return (rv);
167 sp32 = SCARG_P32(uap, sb);
168 netbsd32_stat12_to_netbsd32(sp12, &sb32);
170 return (copyout(&sb32, sp32, sizeof sb32));
174 compat_12_netbsd32_lstat12(struct lwp *l, const struct compat_12_netbsd32_lstat12_args *uap, register_t *retval)
176 /* {
177 syscallarg(const netbsd32_charp) path;
178 syscallarg(netbsd32_stat12p_t) ub;
179 } */
180 struct netbsd32_stat12 *sp32, sb32;
181 struct stat12 sb12;
182 struct stat12 *sp12 = &sb12;
183 struct compat_12_sys_lstat_args ua;
184 int rv;
186 NETBSD32TOP_UAP(path, const char);
187 SCARG(&ua, ub) = &sb12;
189 rv = compat_12_sys_lstat(l, &ua, retval);
190 if (rv)
191 return (rv);
193 sp32 = SCARG_P32(uap, ub);
194 netbsd32_stat12_to_netbsd32(sp12, &sb32);
196 return (copyout(&sb32, sp32, sizeof sb32));
200 compat_12_netbsd32_getdirentries(struct lwp *l, const struct compat_12_netbsd32_getdirentries_args *uap, register_t *retval)
202 /* {
203 syscallarg(int) fd;
204 syscallarg(netbsd32_charp) buf;
205 syscallarg(u_int) count;
206 syscallarg(netbsd32_longp) basep;
207 } */
208 struct compat_12_sys_getdirentries_args ua;
210 NETBSD32TO64_UAP(fd);
211 NETBSD32TOP_UAP(buf, char);
212 NETBSD32TO64_UAP(count);
213 NETBSD32TOP_UAP(basep, long);
215 return (compat_12_sys_getdirentries(l, &ua, retval));