linux_file.c revision 1.24 1 1.24 christos /* $NetBSD: linux_file.c,v 1.24 1998/10/03 20:17:41 christos Exp $ */
2 1.23 erh
3 1.23 erh /*-
4 1.23 erh * Copyright (c) 1998 The NetBSD Foundation, Inc.
5 1.23 erh * All rights reserved.
6 1.23 erh *
7 1.23 erh * This code is derived from software contributed to The NetBSD Foundation
8 1.23 erh * by Eric Haszlakiewicz.
9 1.23 erh *
10 1.23 erh * Redistribution and use in source and binary forms, with or without
11 1.23 erh * modification, are permitted provided that the following conditions
12 1.23 erh * are met:
13 1.23 erh * 1. Redistributions of source code must retain the above copyright
14 1.23 erh * notice, this list of conditions and the following disclaimer.
15 1.23 erh * 2. Redistributions in binary form must reproduce the above copyright
16 1.23 erh * notice, this list of conditions and the following disclaimer in the
17 1.23 erh * documentation and/or other materials provided with the distribution.
18 1.23 erh * 3. All advertising materials mentioning features or use of this software
19 1.23 erh * must display the following acknowledgement:
20 1.23 erh * This product includes software developed by the NetBSD
21 1.23 erh * Foundation, Inc. and its contributors.
22 1.23 erh * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.23 erh * contributors may be used to endorse or promote products derived
24 1.23 erh * from this software without specific prior written permission.
25 1.23 erh *
26 1.23 erh * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.23 erh * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.23 erh * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.23 erh * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.23 erh * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.23 erh * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.23 erh * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.23 erh * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.23 erh * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.23 erh * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.23 erh * POSSIBILITY OF SUCH DAMAGE.
37 1.23 erh */
38 1.1 fvdl
39 1.1 fvdl /*
40 1.1 fvdl * Copyright (c) 1995 Frank van der Linden
41 1.1 fvdl * All rights reserved.
42 1.1 fvdl *
43 1.1 fvdl * Redistribution and use in source and binary forms, with or without
44 1.1 fvdl * modification, are permitted provided that the following conditions
45 1.1 fvdl * are met:
46 1.1 fvdl * 1. Redistributions of source code must retain the above copyright
47 1.1 fvdl * notice, this list of conditions and the following disclaimer.
48 1.1 fvdl * 2. Redistributions in binary form must reproduce the above copyright
49 1.1 fvdl * notice, this list of conditions and the following disclaimer in the
50 1.1 fvdl * documentation and/or other materials provided with the distribution.
51 1.1 fvdl * 3. All advertising materials mentioning features or use of this software
52 1.1 fvdl * must display the following acknowledgement:
53 1.1 fvdl * This product includes software developed for the NetBSD Project
54 1.1 fvdl * by Frank van der Linden
55 1.1 fvdl * 4. The name of the author may not be used to endorse or promote products
56 1.1 fvdl * derived from this software without specific prior written permission
57 1.1 fvdl *
58 1.1 fvdl * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
59 1.1 fvdl * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
60 1.1 fvdl * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
61 1.1 fvdl * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
62 1.1 fvdl * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
63 1.1 fvdl * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
64 1.1 fvdl * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
65 1.1 fvdl * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
66 1.1 fvdl * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
67 1.1 fvdl * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
68 1.1 fvdl */
69 1.1 fvdl
70 1.23 erh /*
71 1.23 erh * Functions in multiarch:
72 1.23 erh * linux_sys_llseek : linux_llseek.c
73 1.23 erh */
74 1.23 erh
75 1.1 fvdl #include <sys/param.h>
76 1.1 fvdl #include <sys/systm.h>
77 1.1 fvdl #include <sys/namei.h>
78 1.1 fvdl #include <sys/proc.h>
79 1.1 fvdl #include <sys/file.h>
80 1.1 fvdl #include <sys/stat.h>
81 1.1 fvdl #include <sys/filedesc.h>
82 1.1 fvdl #include <sys/ioctl.h>
83 1.1 fvdl #include <sys/kernel.h>
84 1.1 fvdl #include <sys/mount.h>
85 1.1 fvdl #include <sys/malloc.h>
86 1.13 fvdl #include <sys/vnode.h>
87 1.13 fvdl #include <sys/tty.h>
88 1.13 fvdl #include <sys/conf.h>
89 1.1 fvdl
90 1.1 fvdl #include <sys/syscallargs.h>
91 1.1 fvdl
92 1.24 christos #include <compat/linux/common/linux_types.h>
93 1.24 christos #include <compat/linux/common/linux_signal.h>
94 1.24 christos #include <compat/linux/common/linux_siginfo.h>
95 1.24 christos #include <compat/linux/common/linux_fcntl.h>
96 1.24 christos #include <compat/linux/common/linux_util.h>
97 1.24 christos #include <compat/linux/common/linux_machdep.h>
98 1.24 christos
99 1.1 fvdl #include <compat/linux/linux_syscallargs.h>
100 1.14 christos
101 1.14 christos static int linux_to_bsd_ioflags __P((int));
102 1.14 christos static int bsd_to_linux_ioflags __P((int));
103 1.14 christos static void bsd_to_linux_flock __P((struct flock *, struct linux_flock *));
104 1.14 christos static void linux_to_bsd_flock __P((struct linux_flock *, struct flock *));
105 1.14 christos static void bsd_to_linux_stat __P((struct stat *, struct linux_stat *));
106 1.14 christos static int linux_stat1 __P((struct proc *, void *, register_t *, int));
107 1.14 christos
108 1.1 fvdl /*
109 1.1 fvdl * Some file-related calls are handled here. The usual flag conversion
110 1.1 fvdl * an structure conversion is done, and alternate emul path searching.
111 1.1 fvdl */
112 1.1 fvdl
113 1.1 fvdl /*
114 1.1 fvdl * The next two functions convert between the Linux and NetBSD values
115 1.1 fvdl * of the flags used in open(2) and fcntl(2).
116 1.1 fvdl */
117 1.1 fvdl static int
118 1.14 christos linux_to_bsd_ioflags(lflags)
119 1.14 christos int lflags;
120 1.1 fvdl {
121 1.1 fvdl int res = 0;
122 1.1 fvdl
123 1.1 fvdl res |= cvtto_bsd_mask(lflags, LINUX_O_WRONLY, O_WRONLY);
124 1.1 fvdl res |= cvtto_bsd_mask(lflags, LINUX_O_RDONLY, O_RDONLY);
125 1.1 fvdl res |= cvtto_bsd_mask(lflags, LINUX_O_RDWR, O_RDWR);
126 1.1 fvdl res |= cvtto_bsd_mask(lflags, LINUX_O_CREAT, O_CREAT);
127 1.1 fvdl res |= cvtto_bsd_mask(lflags, LINUX_O_EXCL, O_EXCL);
128 1.1 fvdl res |= cvtto_bsd_mask(lflags, LINUX_O_NOCTTY, O_NOCTTY);
129 1.1 fvdl res |= cvtto_bsd_mask(lflags, LINUX_O_TRUNC, O_TRUNC);
130 1.1 fvdl res |= cvtto_bsd_mask(lflags, LINUX_O_NDELAY, O_NDELAY);
131 1.1 fvdl res |= cvtto_bsd_mask(lflags, LINUX_O_SYNC, O_FSYNC);
132 1.1 fvdl res |= cvtto_bsd_mask(lflags, LINUX_FASYNC, O_ASYNC);
133 1.1 fvdl res |= cvtto_bsd_mask(lflags, LINUX_O_APPEND, O_APPEND);
134 1.1 fvdl
135 1.1 fvdl return res;
136 1.1 fvdl }
137 1.1 fvdl
138 1.1 fvdl static int
139 1.14 christos bsd_to_linux_ioflags(bflags)
140 1.14 christos int bflags;
141 1.1 fvdl {
142 1.1 fvdl int res = 0;
143 1.1 fvdl
144 1.1 fvdl res |= cvtto_linux_mask(bflags, O_WRONLY, LINUX_O_WRONLY);
145 1.1 fvdl res |= cvtto_linux_mask(bflags, O_RDONLY, LINUX_O_RDONLY);
146 1.1 fvdl res |= cvtto_linux_mask(bflags, O_RDWR, LINUX_O_RDWR);
147 1.1 fvdl res |= cvtto_linux_mask(bflags, O_CREAT, LINUX_O_CREAT);
148 1.1 fvdl res |= cvtto_linux_mask(bflags, O_EXCL, LINUX_O_EXCL);
149 1.1 fvdl res |= cvtto_linux_mask(bflags, O_NOCTTY, LINUX_O_NOCTTY);
150 1.1 fvdl res |= cvtto_linux_mask(bflags, O_TRUNC, LINUX_O_TRUNC);
151 1.1 fvdl res |= cvtto_linux_mask(bflags, O_NDELAY, LINUX_O_NDELAY);
152 1.1 fvdl res |= cvtto_linux_mask(bflags, O_FSYNC, LINUX_O_SYNC);
153 1.1 fvdl res |= cvtto_linux_mask(bflags, O_ASYNC, LINUX_FASYNC);
154 1.1 fvdl res |= cvtto_linux_mask(bflags, O_APPEND, LINUX_O_APPEND);
155 1.1 fvdl
156 1.1 fvdl return res;
157 1.1 fvdl }
158 1.1 fvdl
159 1.1 fvdl /*
160 1.1 fvdl * creat(2) is an obsolete function, but it's present as a Linux
161 1.1 fvdl * system call, so let's deal with it.
162 1.1 fvdl *
163 1.23 erh * Note: On the Alpha this doesn't really exist in Linux, but it's defined
164 1.23 erh * in syscalls.master anyway so this doesn't have to be special cased.
165 1.23 erh *
166 1.1 fvdl * Just call open(2) with the TRUNC, CREAT and WRONLY flags.
167 1.1 fvdl */
168 1.1 fvdl int
169 1.12 mycroft linux_sys_creat(p, v, retval)
170 1.1 fvdl struct proc *p;
171 1.11 thorpej void *v;
172 1.11 thorpej register_t *retval;
173 1.11 thorpej {
174 1.12 mycroft struct linux_sys_creat_args /* {
175 1.1 fvdl syscallarg(char *) path;
176 1.1 fvdl syscallarg(int) mode;
177 1.11 thorpej } */ *uap = v;
178 1.12 mycroft struct sys_open_args oa;
179 1.1 fvdl caddr_t sg;
180 1.1 fvdl
181 1.5 christos sg = stackgap_init(p->p_emul);
182 1.5 christos LINUX_CHECK_ALT_CREAT(p, &sg, SCARG(uap, path));
183 1.1 fvdl
184 1.1 fvdl SCARG(&oa, path) = SCARG(uap, path);
185 1.1 fvdl SCARG(&oa, flags) = O_CREAT | O_TRUNC | O_WRONLY;
186 1.1 fvdl SCARG(&oa, mode) = SCARG(uap, mode);
187 1.12 mycroft
188 1.12 mycroft return sys_open(p, &oa, retval);
189 1.1 fvdl }
190 1.1 fvdl
191 1.1 fvdl /*
192 1.1 fvdl * open(2). Take care of the different flag values, and let the
193 1.1 fvdl * NetBSD syscall do the real work. See if this operation
194 1.1 fvdl * gives the current process a controlling terminal.
195 1.1 fvdl * (XXX is this necessary?)
196 1.1 fvdl */
197 1.1 fvdl int
198 1.12 mycroft linux_sys_open(p, v, retval)
199 1.1 fvdl struct proc *p;
200 1.11 thorpej void *v;
201 1.11 thorpej register_t *retval;
202 1.11 thorpej {
203 1.12 mycroft struct linux_sys_open_args /* {
204 1.1 fvdl syscallarg(char *) path;
205 1.1 fvdl syscallarg(int) flags;
206 1.1 fvdl syscallarg(int) mode;
207 1.11 thorpej } */ *uap = v;
208 1.1 fvdl int error, fl;
209 1.12 mycroft struct sys_open_args boa;
210 1.1 fvdl caddr_t sg;
211 1.1 fvdl
212 1.5 christos sg = stackgap_init(p->p_emul);
213 1.1 fvdl
214 1.2 fvdl fl = linux_to_bsd_ioflags(SCARG(uap, flags));
215 1.1 fvdl
216 1.2 fvdl if (fl & O_CREAT)
217 1.5 christos LINUX_CHECK_ALT_CREAT(p, &sg, SCARG(uap, path));
218 1.2 fvdl else
219 1.5 christos LINUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
220 1.1 fvdl
221 1.1 fvdl SCARG(&boa, path) = SCARG(uap, path);
222 1.1 fvdl SCARG(&boa, flags) = fl;
223 1.1 fvdl SCARG(&boa, mode) = SCARG(uap, mode);
224 1.2 fvdl
225 1.12 mycroft if ((error = sys_open(p, &boa, retval)))
226 1.1 fvdl return error;
227 1.1 fvdl
228 1.1 fvdl /*
229 1.1 fvdl * this bit from sunos_misc.c (and svr4_fcntl.c).
230 1.1 fvdl * If we are a session leader, and we don't have a controlling
231 1.1 fvdl * terminal yet, and the O_NOCTTY flag is not set, try to make
232 1.1 fvdl * this the controlling terminal.
233 1.1 fvdl */
234 1.1 fvdl if (!(fl & O_NOCTTY) && SESS_LEADER(p) && !(p->p_flag & P_CONTROLT)) {
235 1.1 fvdl struct filedesc *fdp = p->p_fd;
236 1.1 fvdl struct file *fp = fdp->fd_ofiles[*retval];
237 1.1 fvdl
238 1.1 fvdl /* ignore any error, just give it a try */
239 1.1 fvdl if (fp->f_type == DTYPE_VNODE)
240 1.1 fvdl (fp->f_ops->fo_ioctl) (fp, TIOCSCTTY, (caddr_t) 0, p);
241 1.1 fvdl }
242 1.1 fvdl return 0;
243 1.1 fvdl }
244 1.1 fvdl
245 1.1 fvdl /*
246 1.1 fvdl * The next two functions take care of converting the flock
247 1.1 fvdl * structure back and forth between Linux and NetBSD format.
248 1.1 fvdl * The only difference in the structures is the order of
249 1.1 fvdl * the fields, and the 'whence' value.
250 1.1 fvdl */
251 1.1 fvdl static void
252 1.1 fvdl bsd_to_linux_flock(bfp, lfp)
253 1.1 fvdl struct flock *bfp;
254 1.1 fvdl struct linux_flock *lfp;
255 1.1 fvdl {
256 1.12 mycroft
257 1.1 fvdl lfp->l_start = bfp->l_start;
258 1.1 fvdl lfp->l_len = bfp->l_len;
259 1.1 fvdl lfp->l_pid = bfp->l_pid;
260 1.3 mycroft lfp->l_whence = bfp->l_whence;
261 1.3 mycroft switch (bfp->l_type) {
262 1.1 fvdl case F_RDLCK:
263 1.3 mycroft lfp->l_type = LINUX_F_RDLCK;
264 1.1 fvdl break;
265 1.1 fvdl case F_UNLCK:
266 1.3 mycroft lfp->l_type = LINUX_F_UNLCK;
267 1.1 fvdl break;
268 1.1 fvdl case F_WRLCK:
269 1.3 mycroft lfp->l_type = LINUX_F_WRLCK;
270 1.1 fvdl break;
271 1.1 fvdl }
272 1.1 fvdl }
273 1.1 fvdl
274 1.1 fvdl static void
275 1.1 fvdl linux_to_bsd_flock(lfp, bfp)
276 1.1 fvdl struct linux_flock *lfp;
277 1.1 fvdl struct flock *bfp;
278 1.1 fvdl {
279 1.12 mycroft
280 1.1 fvdl bfp->l_start = lfp->l_start;
281 1.1 fvdl bfp->l_len = lfp->l_len;
282 1.1 fvdl bfp->l_pid = lfp->l_pid;
283 1.3 mycroft bfp->l_whence = lfp->l_whence;
284 1.3 mycroft switch (lfp->l_type) {
285 1.1 fvdl case LINUX_F_RDLCK:
286 1.3 mycroft bfp->l_type = F_RDLCK;
287 1.1 fvdl break;
288 1.1 fvdl case LINUX_F_UNLCK:
289 1.3 mycroft bfp->l_type = F_UNLCK;
290 1.1 fvdl break;
291 1.1 fvdl case LINUX_F_WRLCK:
292 1.3 mycroft bfp->l_type = F_WRLCK;
293 1.1 fvdl break;
294 1.1 fvdl }
295 1.1 fvdl }
296 1.1 fvdl
297 1.1 fvdl /*
298 1.1 fvdl * Most actions in the fcntl() call are straightforward; simply
299 1.1 fvdl * pass control to the NetBSD system call. A few commands need
300 1.1 fvdl * conversions after the actual system call has done its work,
301 1.1 fvdl * because the flag values and lock structure are different.
302 1.1 fvdl */
303 1.1 fvdl int
304 1.12 mycroft linux_sys_fcntl(p, v, retval)
305 1.1 fvdl struct proc *p;
306 1.11 thorpej void *v;
307 1.11 thorpej register_t *retval;
308 1.11 thorpej {
309 1.12 mycroft struct linux_sys_fcntl_args /* {
310 1.1 fvdl syscallarg(int) fd;
311 1.1 fvdl syscallarg(int) cmd;
312 1.1 fvdl syscallarg(void *) arg;
313 1.11 thorpej } */ *uap = v;
314 1.23 erh int fd, cmd, error;
315 1.23 erh u_long val;
316 1.1 fvdl caddr_t arg, sg;
317 1.1 fvdl struct linux_flock lfl;
318 1.1 fvdl struct flock *bfp, bfl;
319 1.12 mycroft struct sys_fcntl_args fca;
320 1.13 fvdl struct filedesc *fdp;
321 1.13 fvdl struct file *fp;
322 1.13 fvdl struct vnode *vp;
323 1.13 fvdl struct vattr va;
324 1.13 fvdl long pgid;
325 1.13 fvdl struct pgrp *pgrp;
326 1.13 fvdl struct tty *tp, *(*d_tty) __P((dev_t));
327 1.1 fvdl
328 1.1 fvdl fd = SCARG(uap, fd);
329 1.1 fvdl cmd = SCARG(uap, cmd);
330 1.1 fvdl arg = (caddr_t) SCARG(uap, arg);
331 1.1 fvdl
332 1.1 fvdl switch (cmd) {
333 1.1 fvdl case LINUX_F_DUPFD:
334 1.1 fvdl cmd = F_DUPFD;
335 1.1 fvdl break;
336 1.1 fvdl case LINUX_F_GETFD:
337 1.1 fvdl cmd = F_GETFD;
338 1.1 fvdl break;
339 1.1 fvdl case LINUX_F_SETFD:
340 1.1 fvdl cmd = F_SETFD;
341 1.1 fvdl break;
342 1.1 fvdl case LINUX_F_GETFL:
343 1.1 fvdl SCARG(&fca, fd) = fd;
344 1.1 fvdl SCARG(&fca, cmd) = F_GETFL;
345 1.1 fvdl SCARG(&fca, arg) = arg;
346 1.12 mycroft if ((error = sys_fcntl(p, &fca, retval)))
347 1.1 fvdl return error;
348 1.1 fvdl retval[0] = bsd_to_linux_ioflags(retval[0]);
349 1.1 fvdl return 0;
350 1.1 fvdl case LINUX_F_SETFL:
351 1.23 erh val = linux_to_bsd_ioflags((unsigned long)SCARG(uap, arg));
352 1.1 fvdl SCARG(&fca, fd) = fd;
353 1.1 fvdl SCARG(&fca, cmd) = F_SETFL;
354 1.6 fvdl SCARG(&fca, arg) = (caddr_t) val;
355 1.12 mycroft return sys_fcntl(p, &fca, retval);
356 1.1 fvdl case LINUX_F_GETLK:
357 1.5 christos sg = stackgap_init(p->p_emul);
358 1.1 fvdl bfp = (struct flock *) stackgap_alloc(&sg, sizeof *bfp);
359 1.18 kleink if ((error = copyin(arg, &lfl, sizeof lfl)))
360 1.18 kleink return error;
361 1.18 kleink linux_to_bsd_flock(&lfl, &bfl);
362 1.18 kleink if ((error = copyout(&bfl, bfp, sizeof bfl)))
363 1.18 kleink return error;
364 1.1 fvdl SCARG(&fca, fd) = fd;
365 1.1 fvdl SCARG(&fca, cmd) = F_GETLK;
366 1.1 fvdl SCARG(&fca, arg) = bfp;
367 1.12 mycroft if ((error = sys_fcntl(p, &fca, retval)))
368 1.1 fvdl return error;
369 1.1 fvdl if ((error = copyin(bfp, &bfl, sizeof bfl)))
370 1.1 fvdl return error;
371 1.1 fvdl bsd_to_linux_flock(&bfl, &lfl);
372 1.1 fvdl return copyout(&lfl, arg, sizeof lfl);
373 1.1 fvdl break;
374 1.1 fvdl case LINUX_F_SETLK:
375 1.1 fvdl case LINUX_F_SETLKW:
376 1.1 fvdl cmd = (cmd == LINUX_F_SETLK ? F_SETLK : F_SETLKW);
377 1.1 fvdl if ((error = copyin(arg, &lfl, sizeof lfl)))
378 1.1 fvdl return error;
379 1.1 fvdl linux_to_bsd_flock(&lfl, &bfl);
380 1.5 christos sg = stackgap_init(p->p_emul);
381 1.1 fvdl bfp = (struct flock *) stackgap_alloc(&sg, sizeof *bfp);
382 1.1 fvdl if ((error = copyout(&bfl, bfp, sizeof bfl)))
383 1.1 fvdl return error;
384 1.1 fvdl SCARG(&fca, fd) = fd;
385 1.1 fvdl SCARG(&fca, cmd) = cmd;
386 1.1 fvdl SCARG(&fca, arg) = bfp;
387 1.12 mycroft return sys_fcntl(p, &fca, retval);
388 1.1 fvdl break;
389 1.1 fvdl case LINUX_F_SETOWN:
390 1.13 fvdl case LINUX_F_GETOWN:
391 1.13 fvdl /*
392 1.13 fvdl * We need to route around the normal fcntl() for these calls,
393 1.13 fvdl * since it uses TIOC{G,S}PGRP, which is too restrictive for
394 1.13 fvdl * Linux F_{G,S}ETOWN semantics. For sockets, this problem
395 1.13 fvdl * does not exist.
396 1.13 fvdl */
397 1.13 fvdl fdp = p->p_fd;
398 1.13 fvdl if ((u_int)fd >= fdp->fd_nfiles ||
399 1.13 fvdl (fp = fdp->fd_ofiles[fd]) == NULL)
400 1.13 fvdl return EBADF;
401 1.13 fvdl if (fp->f_type == DTYPE_SOCKET) {
402 1.13 fvdl cmd = cmd == LINUX_F_SETOWN ? F_SETOWN : F_GETOWN;
403 1.13 fvdl break;
404 1.13 fvdl }
405 1.13 fvdl vp = (struct vnode *)fp->f_data;
406 1.13 fvdl if (vp->v_type != VCHR)
407 1.13 fvdl return EINVAL;
408 1.13 fvdl if ((error = VOP_GETATTR(vp, &va, p->p_ucred, p)))
409 1.13 fvdl return error;
410 1.13 fvdl d_tty = cdevsw[major(va.va_rdev)].d_tty;
411 1.13 fvdl if (!d_tty || (!(tp = (*d_tty)(va.va_rdev))))
412 1.13 fvdl return EINVAL;
413 1.13 fvdl if (cmd == LINUX_F_GETOWN) {
414 1.13 fvdl retval[0] = tp->t_pgrp ? tp->t_pgrp->pg_id : NO_PID;
415 1.13 fvdl return 0;
416 1.13 fvdl }
417 1.13 fvdl if ((long)arg <= 0) {
418 1.13 fvdl pgid = -(long)arg;
419 1.13 fvdl } else {
420 1.13 fvdl struct proc *p1 = pfind((long)arg);
421 1.13 fvdl if (p1 == 0)
422 1.13 fvdl return (ESRCH);
423 1.13 fvdl pgid = (long)p1->p_pgrp->pg_id;
424 1.13 fvdl }
425 1.13 fvdl pgrp = pgfind(pgid);
426 1.13 fvdl if (pgrp == NULL || pgrp->pg_session != p->p_session)
427 1.13 fvdl return EPERM;
428 1.13 fvdl tp->t_pgrp = pgrp;
429 1.13 fvdl return 0;
430 1.1 fvdl default:
431 1.1 fvdl return EOPNOTSUPP;
432 1.1 fvdl }
433 1.1 fvdl
434 1.1 fvdl SCARG(&fca, fd) = fd;
435 1.1 fvdl SCARG(&fca, cmd) = cmd;
436 1.1 fvdl SCARG(&fca, arg) = arg;
437 1.12 mycroft
438 1.12 mycroft return sys_fcntl(p, &fca, retval);
439 1.1 fvdl }
440 1.1 fvdl
441 1.1 fvdl /*
442 1.1 fvdl * Convert a NetBSD stat structure to a Linux stat structure.
443 1.1 fvdl * Only the order of the fields and the padding in the structure
444 1.9 fvdl * is different. linux_fakedev is a machine-dependent function
445 1.9 fvdl * which optionally converts device driver major/minor numbers
446 1.9 fvdl * (XXX horrible, but what can you do against code that compares
447 1.9 fvdl * things against constant major device numbers? sigh)
448 1.1 fvdl */
449 1.1 fvdl static void
450 1.1 fvdl bsd_to_linux_stat(bsp, lsp)
451 1.1 fvdl struct stat *bsp;
452 1.1 fvdl struct linux_stat *lsp;
453 1.1 fvdl {
454 1.12 mycroft
455 1.1 fvdl lsp->lst_dev = bsp->st_dev;
456 1.1 fvdl lsp->lst_ino = bsp->st_ino;
457 1.19 christos lsp->lst_mode = (linux_mode_t)bsp->st_mode;
458 1.19 christos if (bsp->st_nlink >= (1 << 15))
459 1.19 christos lsp->lst_nlink = (1 << 15) - 1;
460 1.19 christos else
461 1.19 christos lsp->lst_nlink = (linux_nlink_t)bsp->st_nlink;
462 1.1 fvdl lsp->lst_uid = bsp->st_uid;
463 1.1 fvdl lsp->lst_gid = bsp->st_gid;
464 1.9 fvdl lsp->lst_rdev = linux_fakedev(bsp->st_rdev);
465 1.1 fvdl lsp->lst_size = bsp->st_size;
466 1.1 fvdl lsp->lst_blksize = bsp->st_blksize;
467 1.1 fvdl lsp->lst_blocks = bsp->st_blocks;
468 1.1 fvdl lsp->lst_atime = bsp->st_atime;
469 1.1 fvdl lsp->lst_mtime = bsp->st_mtime;
470 1.1 fvdl lsp->lst_ctime = bsp->st_ctime;
471 1.1 fvdl }
472 1.1 fvdl
473 1.1 fvdl /*
474 1.1 fvdl * The stat functions below are plain sailing. stat and lstat are handled
475 1.1 fvdl * by one function to avoid code duplication.
476 1.1 fvdl */
477 1.1 fvdl int
478 1.12 mycroft linux_sys_fstat(p, v, retval)
479 1.1 fvdl struct proc *p;
480 1.11 thorpej void *v;
481 1.11 thorpej register_t *retval;
482 1.11 thorpej {
483 1.12 mycroft struct linux_sys_fstat_args /* {
484 1.1 fvdl syscallarg(int) fd;
485 1.1 fvdl syscallarg(linux_stat *) sp;
486 1.11 thorpej } */ *uap = v;
487 1.21 thorpej struct sys___fstat13_args fsa;
488 1.1 fvdl struct linux_stat tmplst;
489 1.1 fvdl struct stat *st,tmpst;
490 1.1 fvdl caddr_t sg;
491 1.1 fvdl int error;
492 1.1 fvdl
493 1.5 christos sg = stackgap_init(p->p_emul);
494 1.1 fvdl
495 1.1 fvdl st = stackgap_alloc(&sg, sizeof (struct stat));
496 1.1 fvdl
497 1.1 fvdl SCARG(&fsa, fd) = SCARG(uap, fd);
498 1.1 fvdl SCARG(&fsa, sb) = st;
499 1.1 fvdl
500 1.21 thorpej if ((error = sys___fstat13(p, &fsa, retval)))
501 1.1 fvdl return error;
502 1.1 fvdl
503 1.1 fvdl if ((error = copyin(st, &tmpst, sizeof tmpst)))
504 1.1 fvdl return error;
505 1.1 fvdl
506 1.1 fvdl bsd_to_linux_stat(&tmpst, &tmplst);
507 1.1 fvdl
508 1.1 fvdl if ((error = copyout(&tmplst, SCARG(uap, sp), sizeof tmplst)))
509 1.1 fvdl return error;
510 1.1 fvdl
511 1.1 fvdl return 0;
512 1.1 fvdl }
513 1.1 fvdl
514 1.1 fvdl static int
515 1.14 christos linux_stat1(p, v, retval, dolstat)
516 1.1 fvdl struct proc *p;
517 1.14 christos void *v;
518 1.1 fvdl register_t *retval;
519 1.1 fvdl int dolstat;
520 1.1 fvdl {
521 1.21 thorpej struct sys___stat13_args sa;
522 1.1 fvdl struct linux_stat tmplst;
523 1.1 fvdl struct stat *st, tmpst;
524 1.1 fvdl caddr_t sg;
525 1.1 fvdl int error;
526 1.14 christos struct linux_sys_stat_args *uap = v;
527 1.1 fvdl
528 1.5 christos sg = stackgap_init(p->p_emul);
529 1.1 fvdl
530 1.5 christos LINUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
531 1.1 fvdl
532 1.1 fvdl st = stackgap_alloc(&sg, sizeof (struct stat));
533 1.1 fvdl SCARG(&sa, ub) = st;
534 1.1 fvdl SCARG(&sa, path) = SCARG(uap, path);
535 1.1 fvdl
536 1.21 thorpej if ((error = (dolstat ? sys___lstat13(p, &sa, retval) :
537 1.21 thorpej sys___stat13(p, &sa, retval))))
538 1.1 fvdl return error;
539 1.1 fvdl
540 1.1 fvdl if ((error = copyin(st, &tmpst, sizeof tmpst)))
541 1.1 fvdl return error;
542 1.1 fvdl
543 1.1 fvdl bsd_to_linux_stat(&tmpst, &tmplst);
544 1.1 fvdl
545 1.1 fvdl if ((error = copyout(&tmplst, SCARG(uap, sp), sizeof tmplst)))
546 1.1 fvdl return error;
547 1.1 fvdl
548 1.1 fvdl return 0;
549 1.1 fvdl }
550 1.1 fvdl
551 1.1 fvdl int
552 1.12 mycroft linux_sys_stat(p, v, retval)
553 1.1 fvdl struct proc *p;
554 1.11 thorpej void *v;
555 1.11 thorpej register_t *retval;
556 1.11 thorpej {
557 1.12 mycroft struct linux_sys_stat_args /* {
558 1.1 fvdl syscallarg(char *) path;
559 1.1 fvdl syscallarg(struct linux_stat *) sp;
560 1.11 thorpej } */ *uap = v;
561 1.11 thorpej
562 1.1 fvdl return linux_stat1(p, uap, retval, 0);
563 1.1 fvdl }
564 1.1 fvdl
565 1.23 erh /* Note: this is "newlstat" in the Linux sources */
566 1.23 erh /* (we don't bother with the old lstat currently) */
567 1.1 fvdl int
568 1.12 mycroft linux_sys_lstat(p, v, retval)
569 1.1 fvdl struct proc *p;
570 1.11 thorpej void *v;
571 1.11 thorpej register_t *retval;
572 1.11 thorpej {
573 1.12 mycroft struct linux_sys_lstat_args /* {
574 1.1 fvdl syscallarg(char *) path;
575 1.1 fvdl syscallarg(struct linux_stat *) sp;
576 1.11 thorpej } */ *uap = v;
577 1.11 thorpej
578 1.1 fvdl return linux_stat1(p, uap, retval, 1);
579 1.1 fvdl }
580 1.1 fvdl
581 1.1 fvdl /*
582 1.10 fvdl * The following syscalls are mostly here because of the alternate path check.
583 1.1 fvdl */
584 1.1 fvdl int
585 1.12 mycroft linux_sys_access(p, v, retval)
586 1.1 fvdl struct proc *p;
587 1.11 thorpej void *v;
588 1.11 thorpej register_t *retval;
589 1.11 thorpej {
590 1.12 mycroft struct linux_sys_access_args /* {
591 1.1 fvdl syscallarg(char *) path;
592 1.1 fvdl syscallarg(int) flags;
593 1.11 thorpej } */ *uap = v;
594 1.5 christos caddr_t sg = stackgap_init(p->p_emul);
595 1.1 fvdl
596 1.5 christos LINUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
597 1.1 fvdl
598 1.12 mycroft return sys_access(p, uap, retval);
599 1.2 fvdl }
600 1.2 fvdl
601 1.2 fvdl int
602 1.12 mycroft linux_sys_unlink(p, v, retval)
603 1.2 fvdl struct proc *p;
604 1.11 thorpej void *v;
605 1.2 fvdl register_t *retval;
606 1.2 fvdl
607 1.2 fvdl {
608 1.12 mycroft struct linux_sys_unlink_args /* {
609 1.11 thorpej syscallarg(char *) path;
610 1.11 thorpej } */ *uap = v;
611 1.5 christos caddr_t sg = stackgap_init(p->p_emul);
612 1.2 fvdl
613 1.5 christos LINUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
614 1.2 fvdl
615 1.12 mycroft return sys_unlink(p, uap, retval);
616 1.2 fvdl }
617 1.2 fvdl
618 1.10 fvdl int
619 1.12 mycroft linux_sys_chdir(p, v, retval)
620 1.2 fvdl struct proc *p;
621 1.11 thorpej void *v;
622 1.11 thorpej register_t *retval;
623 1.11 thorpej {
624 1.12 mycroft struct linux_sys_chdir_args /* {
625 1.2 fvdl syscallarg(char *) path;
626 1.11 thorpej } */ *uap = v;
627 1.5 christos caddr_t sg = stackgap_init(p->p_emul);
628 1.2 fvdl
629 1.5 christos LINUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
630 1.2 fvdl
631 1.12 mycroft return sys_chdir(p, uap, retval);
632 1.2 fvdl }
633 1.2 fvdl
634 1.2 fvdl int
635 1.12 mycroft linux_sys_mknod(p, v, retval)
636 1.2 fvdl struct proc *p;
637 1.11 thorpej void *v;
638 1.11 thorpej register_t *retval;
639 1.11 thorpej {
640 1.12 mycroft struct linux_sys_mknod_args /* {
641 1.2 fvdl syscallarg(char *) path;
642 1.2 fvdl syscallarg(int) mode;
643 1.2 fvdl syscallarg(int) dev;
644 1.11 thorpej } */ *uap = v;
645 1.5 christos caddr_t sg = stackgap_init(p->p_emul);
646 1.21 thorpej struct sys_mkfifo_args bma;
647 1.2 fvdl
648 1.5 christos LINUX_CHECK_ALT_CREAT(p, &sg, SCARG(uap, path));
649 1.2 fvdl
650 1.10 fvdl /*
651 1.10 fvdl * BSD handles FIFOs seperately
652 1.10 fvdl */
653 1.21 thorpej if (SCARG(uap, mode) & S_IFIFO) {
654 1.21 thorpej SCARG(&bma, path) = SCARG(uap, path);
655 1.21 thorpej SCARG(&bma, mode) = SCARG(uap, mode);
656 1.21 thorpej return sys_mkfifo(p, uap, retval);
657 1.21 thorpej } else
658 1.21 thorpej return sys_mknod(p, uap, retval);
659 1.2 fvdl }
660 1.2 fvdl
661 1.2 fvdl int
662 1.12 mycroft linux_sys_chmod(p, v, retval)
663 1.2 fvdl struct proc *p;
664 1.11 thorpej void *v;
665 1.11 thorpej register_t *retval;
666 1.11 thorpej {
667 1.12 mycroft struct linux_sys_chmod_args /* {
668 1.2 fvdl syscallarg(char *) path;
669 1.2 fvdl syscallarg(int) mode;
670 1.11 thorpej } */ *uap = v;
671 1.5 christos caddr_t sg = stackgap_init(p->p_emul);
672 1.2 fvdl
673 1.5 christos LINUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
674 1.2 fvdl
675 1.12 mycroft return sys_chmod(p, uap, retval);
676 1.2 fvdl }
677 1.2 fvdl
678 1.2 fvdl int
679 1.12 mycroft linux_sys_chown(p, v, retval)
680 1.2 fvdl struct proc *p;
681 1.11 thorpej void *v;
682 1.11 thorpej register_t *retval;
683 1.11 thorpej {
684 1.12 mycroft struct linux_sys_chown_args /* {
685 1.2 fvdl syscallarg(char *) path;
686 1.2 fvdl syscallarg(int) uid;
687 1.2 fvdl syscallarg(int) gid;
688 1.11 thorpej } */ *uap = v;
689 1.22 kleink struct sys___posix_chown_args bca;
690 1.5 christos caddr_t sg = stackgap_init(p->p_emul);
691 1.2 fvdl
692 1.5 christos LINUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
693 1.2 fvdl
694 1.10 fvdl SCARG(&bca, path) = SCARG(uap, path);
695 1.10 fvdl SCARG(&bca, uid) = ((linux_uid_t)SCARG(uap, uid) == (linux_uid_t)-1) ?
696 1.10 fvdl (uid_t)-1 : SCARG(uap, uid);
697 1.10 fvdl SCARG(&bca, gid) = ((linux_gid_t)SCARG(uap, gid) == (linux_gid_t)-1) ?
698 1.10 fvdl (gid_t)-1 : SCARG(uap, gid);
699 1.10 fvdl
700 1.22 kleink return sys___posix_chown(p, &bca, retval);
701 1.10 fvdl }
702 1.10 fvdl
703 1.10 fvdl int
704 1.12 mycroft linux_sys_fchown(p, v, retval)
705 1.10 fvdl struct proc *p;
706 1.11 thorpej void *v;
707 1.11 thorpej register_t *retval;
708 1.11 thorpej {
709 1.12 mycroft struct linux_sys_fchown_args /* {
710 1.10 fvdl syscallarg(int) fd;
711 1.10 fvdl syscallarg(int) uid;
712 1.10 fvdl syscallarg(int) gid;
713 1.11 thorpej } */ *uap = v;
714 1.22 kleink struct sys___posix_fchown_args bfa;
715 1.10 fvdl
716 1.10 fvdl SCARG(&bfa, fd) = SCARG(uap, fd);
717 1.10 fvdl SCARG(&bfa, uid) = ((linux_uid_t)SCARG(uap, uid) == (linux_uid_t)-1) ?
718 1.10 fvdl (uid_t)-1 : SCARG(uap, uid);
719 1.10 fvdl SCARG(&bfa, gid) = ((linux_gid_t)SCARG(uap, gid) == (linux_gid_t)-1) ?
720 1.10 fvdl (gid_t)-1 : SCARG(uap, gid);
721 1.10 fvdl
722 1.22 kleink return sys___posix_fchown(p, &bfa, retval);
723 1.2 fvdl }
724 1.2 fvdl
725 1.2 fvdl int
726 1.23 erh linux_sys_lchown(p, v, retval)
727 1.23 erh struct proc *p;
728 1.23 erh void *v;
729 1.23 erh register_t *retval;
730 1.23 erh {
731 1.23 erh struct linux_sys_lchown_args /* {
732 1.23 erh syscallarg(char *) path;
733 1.23 erh syscallarg(int) uid;
734 1.23 erh syscallarg(int) gid;
735 1.23 erh } */ *uap = v;
736 1.23 erh struct sys___posix_lchown_args bla;
737 1.23 erh
738 1.23 erh SCARG(&bla, path) = SCARG(uap, path);
739 1.23 erh SCARG(&bla, uid) = ((linux_uid_t)SCARG(uap, uid) == (linux_uid_t)-1) ?
740 1.23 erh (uid_t)-1 : SCARG(uap, uid);
741 1.23 erh SCARG(&bla, gid) = ((linux_gid_t)SCARG(uap, gid) == (linux_gid_t)-1) ?
742 1.23 erh (gid_t)-1 : SCARG(uap, gid);
743 1.23 erh
744 1.23 erh return sys___posix_lchown(p, &bla, retval);
745 1.23 erh }
746 1.23 erh
747 1.23 erh int
748 1.12 mycroft linux_sys_rename(p, v, retval)
749 1.2 fvdl struct proc *p;
750 1.11 thorpej void *v;
751 1.11 thorpej register_t *retval;
752 1.11 thorpej {
753 1.12 mycroft struct linux_sys_rename_args /* {
754 1.2 fvdl syscallarg(char *) from;
755 1.2 fvdl syscallarg(char *) to;
756 1.11 thorpej } */ *uap = v;
757 1.5 christos caddr_t sg = stackgap_init(p->p_emul);
758 1.2 fvdl
759 1.5 christos LINUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, from));
760 1.5 christos LINUX_CHECK_ALT_CREAT(p, &sg, SCARG(uap, to));
761 1.2 fvdl
762 1.22 kleink return sys___posix_rename(p, uap, retval);
763 1.2 fvdl }
764 1.2 fvdl
765 1.2 fvdl int
766 1.12 mycroft linux_sys_mkdir(p, v, retval)
767 1.2 fvdl struct proc *p;
768 1.11 thorpej void *v;
769 1.11 thorpej register_t *retval;
770 1.11 thorpej {
771 1.12 mycroft struct linux_sys_mkdir_args /* {
772 1.2 fvdl syscallarg(char *) path;
773 1.7 fvdl syscallarg(int) mode;
774 1.11 thorpej } */ *uap = v;
775 1.5 christos caddr_t sg = stackgap_init(p->p_emul);
776 1.2 fvdl
777 1.5 christos LINUX_CHECK_ALT_CREAT(p, &sg, SCARG(uap, path));
778 1.12 mycroft
779 1.12 mycroft return sys_mkdir(p, uap, retval);
780 1.2 fvdl }
781 1.2 fvdl
782 1.2 fvdl int
783 1.12 mycroft linux_sys_rmdir(p, v, retval)
784 1.2 fvdl struct proc *p;
785 1.11 thorpej void *v;
786 1.11 thorpej register_t *retval;
787 1.11 thorpej {
788 1.12 mycroft struct linux_sys_rmdir_args /* {
789 1.2 fvdl syscallarg(char *) path;
790 1.11 thorpej } */ *uap = v;
791 1.5 christos caddr_t sg = stackgap_init(p->p_emul);
792 1.2 fvdl
793 1.5 christos LINUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
794 1.12 mycroft
795 1.12 mycroft return sys_rmdir(p, uap, retval);
796 1.2 fvdl }
797 1.2 fvdl
798 1.2 fvdl int
799 1.12 mycroft linux_sys_symlink(p, v, retval)
800 1.2 fvdl struct proc *p;
801 1.11 thorpej void *v;
802 1.11 thorpej register_t *retval;
803 1.11 thorpej {
804 1.12 mycroft struct linux_sys_symlink_args /* {
805 1.2 fvdl syscallarg(char *) path;
806 1.2 fvdl syscallarg(char *) to;
807 1.11 thorpej } */ *uap = v;
808 1.5 christos caddr_t sg = stackgap_init(p->p_emul);
809 1.2 fvdl
810 1.5 christos LINUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
811 1.5 christos LINUX_CHECK_ALT_CREAT(p, &sg, SCARG(uap, to));
812 1.2 fvdl
813 1.12 mycroft return sys_symlink(p, uap, retval);
814 1.2 fvdl }
815 1.2 fvdl
816 1.2 fvdl int
817 1.12 mycroft linux_sys_readlink(p, v, retval)
818 1.2 fvdl struct proc *p;
819 1.11 thorpej void *v;
820 1.11 thorpej register_t *retval;
821 1.11 thorpej {
822 1.12 mycroft struct linux_sys_readlink_args /* {
823 1.2 fvdl syscallarg(char *) name;
824 1.2 fvdl syscallarg(char *) buf;
825 1.2 fvdl syscallarg(int) count;
826 1.11 thorpej } */ *uap = v;
827 1.5 christos caddr_t sg = stackgap_init(p->p_emul);
828 1.2 fvdl
829 1.5 christos LINUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, name));
830 1.12 mycroft
831 1.12 mycroft return sys_readlink(p, uap, retval);
832 1.2 fvdl }
833 1.2 fvdl
834 1.2 fvdl int
835 1.12 mycroft linux_sys_truncate(p, v, retval)
836 1.2 fvdl struct proc *p;
837 1.11 thorpej void *v;
838 1.11 thorpej register_t *retval;
839 1.11 thorpej {
840 1.12 mycroft struct linux_sys_truncate_args /* {
841 1.2 fvdl syscallarg(char *) path;
842 1.2 fvdl syscallarg(long) length;
843 1.11 thorpej } */ *uap = v;
844 1.5 christos caddr_t sg = stackgap_init(p->p_emul);
845 1.2 fvdl
846 1.5 christos LINUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
847 1.12 mycroft
848 1.12 mycroft return compat_43_sys_truncate(p, uap, retval);
849 1.15 fvdl }
850 1.15 fvdl
851 1.15 fvdl /*
852 1.15 fvdl * This is just fsync() for now (just as it is in the Linux kernel)
853 1.23 erh * Note: this is not implemented under Linux on Alpha and Arm
854 1.23 erh * but should still be defined in our syscalls.master.
855 1.23 erh * (syscall #148 on the arm)
856 1.15 fvdl */
857 1.15 fvdl int
858 1.15 fvdl linux_sys_fdatasync(p, v, retval)
859 1.15 fvdl struct proc *p;
860 1.15 fvdl void *v;
861 1.15 fvdl register_t *retval;
862 1.15 fvdl {
863 1.16 christos #ifdef notdef
864 1.15 fvdl struct linux_sys_fdatasync_args /* {
865 1.15 fvdl syscallarg(int) fd;
866 1.15 fvdl } */ *uap = v;
867 1.16 christos #endif
868 1.15 fvdl return sys_fsync(p, v, retval);
869 1.1 fvdl }
870