linux_file64.c revision 1.43 1 1.43 dsl /* $NetBSD: linux_file64.c,v 1.43 2007/12/08 18:36:07 dsl Exp $ */
2 1.1 jdolecek
3 1.1 jdolecek /*-
4 1.1 jdolecek * Copyright (c) 1995, 1998, 2000 The NetBSD Foundation, Inc.
5 1.1 jdolecek * All rights reserved.
6 1.1 jdolecek *
7 1.1 jdolecek * This code is derived from software contributed to The NetBSD Foundation
8 1.1 jdolecek * by Frank van der Linden and Eric Haszlakiewicz.
9 1.1 jdolecek *
10 1.1 jdolecek * Redistribution and use in source and binary forms, with or without
11 1.1 jdolecek * modification, are permitted provided that the following conditions
12 1.1 jdolecek * are met:
13 1.1 jdolecek * 1. Redistributions of source code must retain the above copyright
14 1.1 jdolecek * notice, this list of conditions and the following disclaimer.
15 1.1 jdolecek * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 jdolecek * notice, this list of conditions and the following disclaimer in the
17 1.1 jdolecek * documentation and/or other materials provided with the distribution.
18 1.1 jdolecek * 3. All advertising materials mentioning features or use of this software
19 1.1 jdolecek * must display the following acknowledgement:
20 1.1 jdolecek * This product includes software developed by the NetBSD
21 1.1 jdolecek * Foundation, Inc. and its contributors.
22 1.1 jdolecek * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1 jdolecek * contributors may be used to endorse or promote products derived
24 1.1 jdolecek * from this software without specific prior written permission.
25 1.1 jdolecek *
26 1.1 jdolecek * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1 jdolecek * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1 jdolecek * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1 jdolecek * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.1 jdolecek * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1 jdolecek * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1 jdolecek * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1 jdolecek * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1 jdolecek * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1 jdolecek * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1 jdolecek * POSSIBILITY OF SUCH DAMAGE.
37 1.1 jdolecek */
38 1.1 jdolecek
39 1.1 jdolecek /*
40 1.1 jdolecek * Linux 64bit filesystem calls. Used on 32bit archs, not used on 64bit ones.
41 1.1 jdolecek */
42 1.6 lukem
43 1.6 lukem #include <sys/cdefs.h>
44 1.43 dsl __KERNEL_RCSID(0, "$NetBSD: linux_file64.c,v 1.43 2007/12/08 18:36:07 dsl Exp $");
45 1.1 jdolecek
46 1.1 jdolecek #include <sys/param.h>
47 1.1 jdolecek #include <sys/systm.h>
48 1.1 jdolecek #include <sys/namei.h>
49 1.1 jdolecek #include <sys/proc.h>
50 1.11 tron #include <sys/dirent.h>
51 1.1 jdolecek #include <sys/file.h>
52 1.1 jdolecek #include <sys/stat.h>
53 1.1 jdolecek #include <sys/filedesc.h>
54 1.1 jdolecek #include <sys/ioctl.h>
55 1.1 jdolecek #include <sys/kernel.h>
56 1.1 jdolecek #include <sys/mount.h>
57 1.1 jdolecek #include <sys/malloc.h>
58 1.37 dsl #include <sys/namei.h>
59 1.37 dsl #include <sys/vfs_syscalls.h>
60 1.1 jdolecek #include <sys/vnode.h>
61 1.1 jdolecek #include <sys/tty.h>
62 1.1 jdolecek #include <sys/conf.h>
63 1.1 jdolecek
64 1.1 jdolecek #include <sys/syscallargs.h>
65 1.1 jdolecek
66 1.1 jdolecek #include <compat/linux/common/linux_types.h>
67 1.1 jdolecek #include <compat/linux/common/linux_signal.h>
68 1.1 jdolecek #include <compat/linux/common/linux_fcntl.h>
69 1.1 jdolecek #include <compat/linux/common/linux_util.h>
70 1.1 jdolecek #include <compat/linux/common/linux_machdep.h>
71 1.11 tron #include <compat/linux/common/linux_dirent.h>
72 1.40 njoly #include <compat/linux/common/linux_ipc.h>
73 1.40 njoly #include <compat/linux/common/linux_sem.h>
74 1.1 jdolecek
75 1.1 jdolecek #include <compat/linux/linux_syscallargs.h>
76 1.1 jdolecek
77 1.15 matt #ifndef alpha
78 1.15 matt
79 1.31 manu # ifndef COMPAT_LINUX32
80 1.31 manu
81 1.42 dsl static void bsd_to_linux_stat(struct stat *, struct linux_stat64 *);
82 1.42 dsl static int linux_do_stat64(struct lwp *, void *, register_t *, int);
83 1.1 jdolecek
84 1.1 jdolecek /*
85 1.1 jdolecek * Convert a NetBSD stat structure to a Linux stat structure.
86 1.1 jdolecek * Only the order of the fields and the padding in the structure
87 1.1 jdolecek * is different. linux_fakedev is a machine-dependent function
88 1.1 jdolecek * which optionally converts device driver major/minor numbers
89 1.1 jdolecek * (XXX horrible, but what can you do against code that compares
90 1.1 jdolecek * things against constant major device numbers? sigh)
91 1.1 jdolecek */
92 1.1 jdolecek static void
93 1.43 dsl bsd_to_linux_stat(struct stat *bsp, struct linux_stat64 *lsp)
94 1.1 jdolecek {
95 1.7 christos lsp->lst_dev = linux_fakedev(bsp->st_dev, 0);
96 1.1 jdolecek lsp->lst_ino = bsp->st_ino;
97 1.1 jdolecek lsp->lst_mode = (linux_mode_t)bsp->st_mode;
98 1.1 jdolecek if (bsp->st_nlink >= (1 << 15))
99 1.1 jdolecek lsp->lst_nlink = (1 << 15) - 1;
100 1.1 jdolecek else
101 1.1 jdolecek lsp->lst_nlink = (linux_nlink_t)bsp->st_nlink;
102 1.1 jdolecek lsp->lst_uid = bsp->st_uid;
103 1.1 jdolecek lsp->lst_gid = bsp->st_gid;
104 1.7 christos lsp->lst_rdev = linux_fakedev(bsp->st_rdev, 1);
105 1.1 jdolecek lsp->lst_size = bsp->st_size;
106 1.1 jdolecek lsp->lst_blksize = bsp->st_blksize;
107 1.1 jdolecek lsp->lst_blocks = bsp->st_blocks;
108 1.1 jdolecek lsp->lst_atime = bsp->st_atime;
109 1.1 jdolecek lsp->lst_mtime = bsp->st_mtime;
110 1.1 jdolecek lsp->lst_ctime = bsp->st_ctime;
111 1.31 manu # ifdef LINUX_STAT64_HAS_NSEC
112 1.25 christos lsp->lst_atime_nsec = bsp->st_atimensec;
113 1.25 christos lsp->lst_mtime_nsec = bsp->st_mtimensec;
114 1.25 christos lsp->lst_ctime_nsec = bsp->st_ctimensec;
115 1.31 manu # endif
116 1.31 manu # if LINUX_STAT64_HAS_BROKEN_ST_INO
117 1.16 jdolecek lsp->__lst_ino = (linux_ino_t) bsp->st_ino;
118 1.31 manu # endif
119 1.1 jdolecek }
120 1.1 jdolecek
121 1.1 jdolecek /*
122 1.1 jdolecek * The stat functions below are plain sailing. stat and lstat are handled
123 1.1 jdolecek * by one function to avoid code duplication.
124 1.1 jdolecek */
125 1.1 jdolecek int
126 1.43 dsl linux_sys_fstat64(struct lwp *l, void *v, register_t *retval)
127 1.1 jdolecek {
128 1.1 jdolecek struct linux_sys_fstat64_args /* {
129 1.1 jdolecek syscallarg(int) fd;
130 1.5 manu syscallarg(struct linux_stat64 *) sp;
131 1.1 jdolecek } */ *uap = v;
132 1.1 jdolecek struct linux_stat64 tmplst;
133 1.37 dsl struct stat tmpst;
134 1.1 jdolecek int error;
135 1.1 jdolecek
136 1.37 dsl error = do_sys_fstat(l, SCARG(uap, fd), &tmpst);
137 1.37 dsl if (error != 0)
138 1.1 jdolecek return error;
139 1.1 jdolecek
140 1.1 jdolecek bsd_to_linux_stat(&tmpst, &tmplst);
141 1.1 jdolecek
142 1.37 dsl return copyout(&tmplst, SCARG(uap, sp), sizeof tmplst);
143 1.1 jdolecek }
144 1.1 jdolecek
145 1.1 jdolecek static int
146 1.43 dsl linux_do_stat64(struct lwp *l, void *v, register_t *retval, int flags)
147 1.1 jdolecek {
148 1.1 jdolecek struct linux_stat64 tmplst;
149 1.37 dsl struct stat tmpst;
150 1.1 jdolecek int error;
151 1.1 jdolecek struct linux_sys_stat64_args *uap = v;
152 1.1 jdolecek
153 1.37 dsl error = do_sys_stat(l, SCARG(uap, path), flags, &tmpst);
154 1.37 dsl if (error != 0)
155 1.1 jdolecek return error;
156 1.1 jdolecek
157 1.1 jdolecek bsd_to_linux_stat(&tmpst, &tmplst);
158 1.1 jdolecek
159 1.37 dsl return copyout(&tmplst, SCARG(uap, sp), sizeof tmplst);
160 1.1 jdolecek }
161 1.1 jdolecek
162 1.1 jdolecek int
163 1.43 dsl linux_sys_stat64(struct lwp *l, void *v, register_t *retval)
164 1.1 jdolecek {
165 1.1 jdolecek struct linux_sys_stat64_args /* {
166 1.1 jdolecek syscallarg(const char *) path;
167 1.1 jdolecek syscallarg(struct linux_stat64 *) sp;
168 1.1 jdolecek } */ *uap = v;
169 1.1 jdolecek
170 1.37 dsl return linux_do_stat64(l, uap, retval, FOLLOW);
171 1.1 jdolecek }
172 1.1 jdolecek
173 1.1 jdolecek int
174 1.43 dsl linux_sys_lstat64(struct lwp *l, void *v, register_t *retval)
175 1.1 jdolecek {
176 1.1 jdolecek struct linux_sys_lstat64_args /* {
177 1.1 jdolecek syscallarg(const char *) path;
178 1.1 jdolecek syscallarg(struct linux_stat64 *) sp;
179 1.1 jdolecek } */ *uap = v;
180 1.1 jdolecek
181 1.37 dsl return linux_do_stat64(l, uap, retval, NOFOLLOW);
182 1.2 jdolecek }
183 1.2 jdolecek
184 1.2 jdolecek int
185 1.43 dsl linux_sys_truncate64(struct lwp *l, void *v, register_t *retval)
186 1.2 jdolecek {
187 1.2 jdolecek struct linux_sys_truncate64_args /* {
188 1.2 jdolecek syscallarg(const char *) path;
189 1.2 jdolecek syscallarg(off_t) length;
190 1.2 jdolecek } */ *uap = v;
191 1.22 jdolecek struct sys_truncate_args ta;
192 1.2 jdolecek
193 1.22 jdolecek /* Linux doesn't have the 'pad' pseudo-parameter */
194 1.22 jdolecek SCARG(&ta, path) = SCARG(uap, path);
195 1.22 jdolecek SCARG(&ta, pad) = 0;
196 1.22 jdolecek SCARG(&ta, length) = SCARG(uap, length);
197 1.22 jdolecek
198 1.22 jdolecek return sys_truncate(l, &ta, retval);
199 1.22 jdolecek }
200 1.22 jdolecek
201 1.22 jdolecek int
202 1.43 dsl linux_sys_ftruncate64(struct lwp *l, void *v, register_t *retval)
203 1.22 jdolecek {
204 1.22 jdolecek struct linux_sys_ftruncate64_args /* {
205 1.22 jdolecek syscallarg(unsigned int) fd;
206 1.22 jdolecek syscallarg(off_t) length;
207 1.22 jdolecek } */ *uap = v;
208 1.22 jdolecek struct sys_ftruncate_args ta;
209 1.22 jdolecek
210 1.22 jdolecek /* Linux doesn't have the 'pad' pseudo-parameter */
211 1.22 jdolecek SCARG(&ta, fd) = SCARG(uap, fd);
212 1.22 jdolecek SCARG(&ta, pad) = 0;
213 1.22 jdolecek SCARG(&ta, length) = SCARG(uap, length);
214 1.22 jdolecek
215 1.22 jdolecek return sys_ftruncate(l, &ta, retval);
216 1.1 jdolecek }
217 1.31 manu # endif /* !COMPAT_LINUX32 */
218 1.3 manu
219 1.31 manu # if !defined(__m68k__) && (!defined(__amd64__) || defined(COMPAT_LINUX32))
220 1.42 dsl static void bsd_to_linux_flock64(struct linux_flock64 *,
221 1.42 dsl const struct flock *);
222 1.42 dsl static void linux_to_bsd_flock64(struct flock *,
223 1.42 dsl const struct linux_flock64 *);
224 1.9 christos
225 1.9 christos static void
226 1.43 dsl bsd_to_linux_flock64(struct linux_flock64 *lfp, const struct flock *bfp)
227 1.9 christos {
228 1.9 christos
229 1.9 christos lfp->l_start = bfp->l_start;
230 1.9 christos lfp->l_len = bfp->l_len;
231 1.9 christos lfp->l_pid = bfp->l_pid;
232 1.9 christos lfp->l_whence = bfp->l_whence;
233 1.9 christos switch (bfp->l_type) {
234 1.9 christos case F_RDLCK:
235 1.9 christos lfp->l_type = LINUX_F_RDLCK;
236 1.9 christos break;
237 1.9 christos case F_UNLCK:
238 1.9 christos lfp->l_type = LINUX_F_UNLCK;
239 1.9 christos break;
240 1.9 christos case F_WRLCK:
241 1.9 christos lfp->l_type = LINUX_F_WRLCK;
242 1.9 christos break;
243 1.9 christos }
244 1.9 christos }
245 1.9 christos
246 1.9 christos static void
247 1.43 dsl linux_to_bsd_flock64(struct flock *bfp, const struct linux_flock64 *lfp)
248 1.9 christos {
249 1.9 christos
250 1.9 christos bfp->l_start = lfp->l_start;
251 1.9 christos bfp->l_len = lfp->l_len;
252 1.9 christos bfp->l_pid = lfp->l_pid;
253 1.9 christos bfp->l_whence = lfp->l_whence;
254 1.9 christos switch (lfp->l_type) {
255 1.9 christos case LINUX_F_RDLCK:
256 1.9 christos bfp->l_type = F_RDLCK;
257 1.9 christos break;
258 1.9 christos case LINUX_F_UNLCK:
259 1.9 christos bfp->l_type = F_UNLCK;
260 1.9 christos break;
261 1.9 christos case LINUX_F_WRLCK:
262 1.9 christos bfp->l_type = F_WRLCK;
263 1.9 christos break;
264 1.9 christos }
265 1.9 christos }
266 1.13 jdolecek
267 1.3 manu int
268 1.43 dsl linux_sys_fcntl64(struct lwp *l, void *v, register_t *retval)
269 1.3 manu {
270 1.3 manu struct linux_sys_fcntl64_args /* {
271 1.9 christos syscallarg(int) fd;
272 1.9 christos syscallarg(int) cmd;
273 1.9 christos syscallarg(void *) arg;
274 1.3 manu } */ *uap = v;
275 1.9 christos struct linux_flock64 lfl;
276 1.39 dsl struct flock bfl;
277 1.3 manu int error;
278 1.9 christos void *arg = SCARG(uap, arg);
279 1.9 christos int cmd = SCARG(uap, cmd);
280 1.9 christos int fd = SCARG(uap, fd);
281 1.3 manu
282 1.3 manu switch (cmd) {
283 1.9 christos case LINUX_F_GETLK64:
284 1.9 christos if ((error = copyin(arg, &lfl, sizeof lfl)) != 0)
285 1.9 christos return error;
286 1.9 christos linux_to_bsd_flock64(&bfl, &lfl);
287 1.39 dsl error = do_fcntl_lock(l, fd, F_GETLK, &bfl);
288 1.39 dsl if (error != 0)
289 1.9 christos return error;
290 1.9 christos bsd_to_linux_flock64(&lfl, &bfl);
291 1.9 christos return copyout(&lfl, arg, sizeof lfl);
292 1.9 christos case LINUX_F_SETLK64:
293 1.9 christos case LINUX_F_SETLKW64:
294 1.9 christos cmd = (cmd == LINUX_F_SETLK64 ? F_SETLK : F_SETLKW);
295 1.9 christos if ((error = copyin(arg, &lfl, sizeof lfl)) != 0)
296 1.9 christos return error;
297 1.9 christos linux_to_bsd_flock64(&bfl, &lfl);
298 1.39 dsl return do_fcntl_lock(l, fd, cmd, &bfl);
299 1.9 christos default:
300 1.19 thorpej return linux_sys_fcntl(l, v, retval);
301 1.3 manu }
302 1.11 tron }
303 1.31 manu # endif /* !m69k && !amd64 && !COMPAT_LINUX32 */
304 1.15 matt
305 1.15 matt #endif /* !alpha */
306 1.11 tron
307 1.11 tron /*
308 1.11 tron * Linux 'readdir' call. This code is mostly taken from the
309 1.11 tron * SunOS getdents call (see compat/sunos/sunos_misc.c), though
310 1.18 jdolecek * an attempt has been made to keep it a little cleaner.
311 1.11 tron *
312 1.18 jdolecek * The d_off field contains the offset of the next valid entry,
313 1.18 jdolecek * unless the older Linux getdents(2), which used to have it set
314 1.18 jdolecek * to the offset of the entry itself. This function also doesn't
315 1.18 jdolecek * need to deal with the old count == 1 glibc problem.
316 1.11 tron *
317 1.11 tron * Read in BSD-style entries, convert them, and copy them out.
318 1.11 tron *
319 1.11 tron * Note that this doesn't handle union-mounted filesystems.
320 1.11 tron */
321 1.31 manu #ifndef COMPAT_LINUX32
322 1.11 tron int
323 1.43 dsl linux_sys_getdents64(struct lwp *l, void *v, register_t *retval)
324 1.11 tron {
325 1.11 tron struct linux_sys_getdents_args /* {
326 1.11 tron syscallarg(int) fd;
327 1.11 tron syscallarg(struct linux_dirent64 *) dent;
328 1.11 tron syscallarg(unsigned int) count;
329 1.11 tron } */ *uap = v;
330 1.11 tron struct dirent *bdp;
331 1.11 tron struct vnode *vp;
332 1.36 christos char *inp, *tbuf; /* BSD-format */
333 1.11 tron int len, reclen; /* BSD-format */
334 1.36 christos char *outp; /* Linux-format */
335 1.11 tron int resid, linux_reclen = 0; /* Linux-format */
336 1.11 tron struct file *fp;
337 1.11 tron struct uio auio;
338 1.11 tron struct iovec aiov;
339 1.11 tron struct linux_dirent64 idb;
340 1.11 tron off_t off; /* true file offset */
341 1.18 jdolecek int buflen, error, eofflag, nbytes;
342 1.11 tron struct vattr va;
343 1.11 tron off_t *cookiebuf = NULL, *cookie;
344 1.11 tron int ncookies;
345 1.11 tron
346 1.11 tron /* getvnode() will use the descriptor for us */
347 1.34 ad if ((error = getvnode(l->l_proc->p_fd, SCARG(uap, fd), &fp)) != 0)
348 1.11 tron return (error);
349 1.11 tron
350 1.11 tron if ((fp->f_flag & FREAD) == 0) {
351 1.11 tron error = EBADF;
352 1.11 tron goto out1;
353 1.11 tron }
354 1.11 tron
355 1.11 tron vp = (struct vnode *)fp->f_data;
356 1.11 tron if (vp->v_type != VDIR) {
357 1.11 tron error = EINVAL;
358 1.11 tron goto out1;
359 1.11 tron }
360 1.11 tron
361 1.41 pooka if ((error = VOP_GETATTR(vp, &va, l->l_cred)))
362 1.11 tron goto out1;
363 1.11 tron
364 1.11 tron nbytes = SCARG(uap, count);
365 1.18 jdolecek buflen = min(MAXBSIZE, nbytes);
366 1.18 jdolecek if (buflen < va.va_blocksize)
367 1.18 jdolecek buflen = va.va_blocksize;
368 1.28 christos tbuf = malloc(buflen, M_TEMP, M_WAITOK);
369 1.11 tron
370 1.11 tron vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
371 1.11 tron off = fp->f_offset;
372 1.11 tron again:
373 1.28 christos aiov.iov_base = tbuf;
374 1.11 tron aiov.iov_len = buflen;
375 1.11 tron auio.uio_iov = &aiov;
376 1.11 tron auio.uio_iovcnt = 1;
377 1.11 tron auio.uio_rw = UIO_READ;
378 1.11 tron auio.uio_resid = buflen;
379 1.11 tron auio.uio_offset = off;
380 1.32 yamt UIO_SETUP_SYSSPACE(&auio);
381 1.11 tron /*
382 1.11 tron * First we read into the malloc'ed buffer, then
383 1.11 tron * we massage it into user space, one record at a time.
384 1.11 tron */
385 1.11 tron error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, &cookiebuf,
386 1.11 tron &ncookies);
387 1.11 tron if (error)
388 1.11 tron goto out;
389 1.11 tron
390 1.28 christos inp = tbuf;
391 1.36 christos outp = (void *)SCARG(uap, dent);
392 1.11 tron resid = nbytes;
393 1.11 tron if ((len = buflen - auio.uio_resid) == 0)
394 1.11 tron goto eof;
395 1.11 tron
396 1.11 tron for (cookie = cookiebuf; len > 0; len -= reclen) {
397 1.11 tron bdp = (struct dirent *)inp;
398 1.11 tron reclen = bdp->d_reclen;
399 1.11 tron if (reclen & 3)
400 1.11 tron panic("linux_readdir");
401 1.11 tron if (bdp->d_fileno == 0) {
402 1.11 tron inp += reclen; /* it is a hole; squish it out */
403 1.26 christos if (cookie)
404 1.26 christos off = *cookie++;
405 1.26 christos else
406 1.26 christos off += reclen;
407 1.11 tron continue;
408 1.11 tron }
409 1.11 tron linux_reclen = LINUX_RECLEN(&idb, bdp->d_namlen);
410 1.11 tron if (reclen > len || resid < linux_reclen) {
411 1.11 tron /* entry too big for buffer, so just stop */
412 1.11 tron outp++;
413 1.11 tron break;
414 1.11 tron }
415 1.26 christos if (cookie)
416 1.26 christos off = *cookie++; /* each entry points to next */
417 1.26 christos else
418 1.26 christos off += reclen;
419 1.11 tron /*
420 1.11 tron * Massage in place to make a Linux-shaped dirent (otherwise
421 1.11 tron * we have to worry about touching user memory outside of
422 1.11 tron * the copyout() call).
423 1.11 tron */
424 1.11 tron idb.d_ino = bdp->d_fileno;
425 1.11 tron idb.d_type = bdp->d_type;
426 1.18 jdolecek idb.d_off = off;
427 1.18 jdolecek idb.d_reclen = (u_short)linux_reclen;
428 1.11 tron strcpy(idb.d_name, bdp->d_name);
429 1.36 christos if ((error = copyout((void *)&idb, outp, linux_reclen)))
430 1.11 tron goto out;
431 1.11 tron /* advance past this real entry */
432 1.11 tron inp += reclen;
433 1.11 tron /* advance output past Linux-shaped entry */
434 1.11 tron outp += linux_reclen;
435 1.11 tron resid -= linux_reclen;
436 1.11 tron }
437 1.11 tron
438 1.11 tron /* if we squished out the whole block, try again */
439 1.36 christos if (outp == (void *)SCARG(uap, dent))
440 1.11 tron goto again;
441 1.11 tron fp->f_offset = off; /* update the vnode offset */
442 1.11 tron
443 1.11 tron eof:
444 1.11 tron *retval = nbytes - resid;
445 1.11 tron out:
446 1.11 tron VOP_UNLOCK(vp, 0);
447 1.11 tron if (cookiebuf)
448 1.11 tron free(cookiebuf, M_TEMP);
449 1.28 christos free(tbuf, M_TEMP);
450 1.11 tron out1:
451 1.30 christos FILE_UNUSE(fp, l);
452 1.3 manu return error;
453 1.3 manu }
454 1.31 manu #endif /* !COMPAT_LINUX32 */
455