1 /* $NetBSD: darwin_stat.c,v 1.15 2009/01/11 02:45:47 christos Exp $ */
4 * Copyright (c) 2003, 2008 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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>
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>
59 darwin_sys_stat(struct lwp
*l
, const struct darwin_sys_stat_args
*uap
, register_t
*retval
)
62 syscallarg(char *) path;
63 syscallarg(struct stat12 *) ub;
69 error
= do_sys_stat(SCARG(uap
, path
), FOLLOW
, &sb
);
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
));
81 darwin_sys_fstat(struct lwp
*l
, const struct darwin_sys_fstat_args
*uap
, register_t
*retval
)
85 syscallarg(struct stat12 *) sb;
91 error
= do_sys_fstat(SCARG(uap
, fd
), &sb
);
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
)
106 syscallarg(char *) path;
107 syscallarg(struct stat12 *) ub;
113 error
= do_sys_stat(SCARG(uap
, path
), NOFOLLOW
, &sb
);
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
)
128 syscallarg(char) path;
129 syscallarg(mode_t) mode;
130 syscallarg(darwin_dev_t) dev:
133 return do_sys_mknod(l
, SCARG(uap
, path
), SCARG(uap
, mode
),
134 darwin_to_native_dev(SCARG(uap
, dev
)), retval
, UIO_USERSPACE
);