Sync usage with man page.
[netbsd-mini2440.git] / sys / compat / darwin / darwin_stat.c
blob1436081bc31902e424b9f6a7aad8e84a56dbc889
1 /* $NetBSD: darwin_stat.c,v 1.15 2009/01/11 02:45:47 christos Exp $ */
3 /*-
4 * Copyright (c) 2003, 2008 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Emmanuel Dreyfus.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: darwin_stat.c,v 1.15 2009/01/11 02:45:47 christos Exp $");
35 #include <sys/types.h>
36 #include <sys/param.h>
37 #include <sys/systm.h>
38 #include <sys/filedesc.h>
39 #include <sys/mount.h>
40 #include <sys/namei.h>
41 #include <sys/proc.h>
42 #include <sys/stat.h>
43 #include <sys/syscallargs.h>
44 #include <sys/vfs_syscalls.h>
46 #include <compat/sys/signal.h>
47 #include <compat/sys/stat.h>
49 #include <compat/common/compat_util.h>
51 #include <compat/mach/mach_types.h>
52 #include <compat/mach/mach_vm.h>
54 #include <compat/darwin/darwin_types.h>
55 #include <compat/darwin/darwin_audit.h>
56 #include <compat/darwin/darwin_syscallargs.h>
58 int
59 darwin_sys_stat(struct lwp *l, const struct darwin_sys_stat_args *uap, register_t *retval)
61 /* {
62 syscallarg(char *) path;
63 syscallarg(struct stat12 *) ub;
64 } */
65 struct stat12 sb12;
66 struct stat sb;
67 int error;
69 error = do_sys_stat(SCARG(uap, path), FOLLOW, &sb);
70 if (error != 0)
71 return error;
73 compat_12_stat_conv(&sb, &sb12);
74 sb12.st_dev = native_to_darwin_dev(sb12.st_dev);
75 sb12.st_rdev = native_to_darwin_dev(sb12.st_rdev);
77 return copyout(&sb12, SCARG(uap, ub), sizeof(sb12));
80 int
81 darwin_sys_fstat(struct lwp *l, const struct darwin_sys_fstat_args *uap, register_t *retval)
83 /* {
84 syscallarg(int) fd;
85 syscallarg(struct stat12 *) sb;
86 } */
87 struct stat12 sb12;
88 struct stat sb;
89 int error;
91 error = do_sys_fstat(SCARG(uap, fd), &sb);
92 if (error != 0)
93 return error;
95 compat_12_stat_conv(&sb, &sb12);
96 sb12.st_dev = native_to_darwin_dev(sb12.st_dev);
97 sb12.st_rdev = native_to_darwin_dev(sb12.st_rdev);
99 return copyout(&sb12, SCARG(uap, sb), sizeof(sb12));
103 darwin_sys_lstat(struct lwp *l, const struct darwin_sys_lstat_args *uap, register_t *retval)
105 /* {
106 syscallarg(char *) path;
107 syscallarg(struct stat12 *) ub;
108 } */
109 struct stat12 sb12;
110 struct stat sb;
111 int error;
113 error = do_sys_stat(SCARG(uap, path), NOFOLLOW, &sb);
114 if (error != 0)
115 return error;
117 compat_12_stat_conv(&sb, &sb12);
118 sb12.st_dev = native_to_darwin_dev(sb12.st_dev);
119 sb12.st_rdev = native_to_darwin_dev(sb12.st_rdev);
121 return copyout(&sb12, SCARG(uap, ub), sizeof(sb12));
125 darwin_sys_mknod(struct lwp *l, const struct darwin_sys_mknod_args *uap, register_t *retval)
127 /* {
128 syscallarg(char) path;
129 syscallarg(mode_t) mode;
130 syscallarg(darwin_dev_t) dev:
131 } */
133 return do_sys_mknod(l, SCARG(uap, path), SCARG(uap, mode),
134 darwin_to_native_dev(SCARG(uap, dev)), retval, UIO_USERSPACE);