vfs_syscalls_12.c revision 1.1 1 1.1 fvdl /* $NetBSD: vfs_syscalls_12.c,v 1.1 1997/10/10 01:47:02 fvdl Exp $ */
2 1.1 fvdl
3 1.1 fvdl /*
4 1.1 fvdl * Copyright (c) 1989, 1993
5 1.1 fvdl * The Regents of the University of California. All rights reserved.
6 1.1 fvdl * (c) UNIX System Laboratories, Inc.
7 1.1 fvdl * All or some portions of this file are derived from material licensed
8 1.1 fvdl * to the University of California by American Telephone and Telegraph
9 1.1 fvdl * Co. or Unix System Laboratories, Inc. and are reproduced herein with
10 1.1 fvdl * the permission of UNIX System Laboratories, Inc.
11 1.1 fvdl *
12 1.1 fvdl * Redistribution and use in source and binary forms, with or without
13 1.1 fvdl * modification, are permitted provided that the following conditions
14 1.1 fvdl * are met:
15 1.1 fvdl * 1. Redistributions of source code must retain the above copyright
16 1.1 fvdl * notice, this list of conditions and the following disclaimer.
17 1.1 fvdl * 2. Redistributions in binary form must reproduce the above copyright
18 1.1 fvdl * notice, this list of conditions and the following disclaimer in the
19 1.1 fvdl * documentation and/or other materials provided with the distribution.
20 1.1 fvdl * 3. All advertising materials mentioning features or use of this software
21 1.1 fvdl * must display the following acknowledgement:
22 1.1 fvdl * This product includes software developed by the University of
23 1.1 fvdl * California, Berkeley and its contributors.
24 1.1 fvdl * 4. Neither the name of the University nor the names of its contributors
25 1.1 fvdl * may be used to endorse or promote products derived from this software
26 1.1 fvdl * without specific prior written permission.
27 1.1 fvdl *
28 1.1 fvdl * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
29 1.1 fvdl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 1.1 fvdl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 1.1 fvdl * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32 1.1 fvdl * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 1.1 fvdl * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 1.1 fvdl * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 1.1 fvdl * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 1.1 fvdl * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37 1.1 fvdl * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 1.1 fvdl * SUCH DAMAGE.
39 1.1 fvdl *
40 1.1 fvdl * From: @(#)vfs_syscalls.c 8.28 (Berkeley) 12/10/94
41 1.1 fvdl */
42 1.1 fvdl
43 1.1 fvdl #include <sys/param.h>
44 1.1 fvdl #include <sys/systm.h>
45 1.1 fvdl #include <sys/namei.h>
46 1.1 fvdl #include <sys/filedesc.h>
47 1.1 fvdl #include <sys/kernel.h>
48 1.1 fvdl #include <sys/file.h>
49 1.1 fvdl #include <sys/stat.h>
50 1.1 fvdl #include <sys/vnode.h>
51 1.1 fvdl #include <sys/mount.h>
52 1.1 fvdl #include <sys/proc.h>
53 1.1 fvdl #include <sys/uio.h>
54 1.1 fvdl #include <sys/malloc.h>
55 1.1 fvdl #include <sys/dirent.h>
56 1.1 fvdl
57 1.1 fvdl #include <sys/syscallargs.h>
58 1.1 fvdl
59 1.1 fvdl /*
60 1.1 fvdl * Read a block of directory entries in a file system independent format.
61 1.1 fvdl */
62 1.1 fvdl int
63 1.1 fvdl compat_12_sys_getdirentries(p, v, retval)
64 1.1 fvdl struct proc *p;
65 1.1 fvdl void *v;
66 1.1 fvdl register_t *retval;
67 1.1 fvdl {
68 1.1 fvdl register struct compat_12_sys_getdirentries_args /* {
69 1.1 fvdl syscallarg(int) fd;
70 1.1 fvdl syscallarg(char *) buf;
71 1.1 fvdl syscallarg(u_int) count;
72 1.1 fvdl syscallarg(long *) basep;
73 1.1 fvdl } */ *uap = v;
74 1.1 fvdl struct file *fp;
75 1.1 fvdl int error, done;
76 1.1 fvdl long loff;
77 1.1 fvdl
78 1.1 fvdl if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
79 1.1 fvdl return error;
80 1.1 fvdl if ((fp->f_flag & FREAD) == 0)
81 1.1 fvdl return (EBADF);
82 1.1 fvdl
83 1.1 fvdl loff = fp->f_offset;
84 1.1 fvdl
85 1.1 fvdl error = vn_readdir(fp, SCARG(uap, buf), UIO_USERSPACE,
86 1.1 fvdl SCARG(uap, count), &done, p, 0, 0);
87 1.1 fvdl
88 1.1 fvdl error = copyout(&loff, SCARG(uap, basep), sizeof(long));
89 1.1 fvdl *retval = done;
90 1.1 fvdl return error;
91 1.1 fvdl }
92