vfs_syscalls_90.c revision 1.1 1 1.1 christos /* $NetBSD: vfs_syscalls_90.c,v 1.1 2019/09/22 22:59:38 christos Exp $ */
2 1.1 christos
3 1.1 christos /*-
4 1.1 christos * Copyright (c) 2005, 2008 The NetBSD Foundation, Inc.
5 1.1 christos * All rights reserved.
6 1.1 christos *
7 1.1 christos * This code is derived from software contributed to The NetBSD Foundation
8 1.1 christos * by Christos Zoulas.
9 1.1 christos *
10 1.1 christos * Redistribution and use in source and binary forms, with or without
11 1.1 christos * modification, are permitted provided that the following conditions
12 1.1 christos * are met:
13 1.1 christos * 1. Redistributions of source code must retain the above copyright
14 1.1 christos * notice, this list of conditions and the following disclaimer.
15 1.1 christos * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 christos * notice, this list of conditions and the following disclaimer in the
17 1.1 christos * documentation and/or other materials provided with the distribution.
18 1.1 christos *
19 1.1 christos * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.1 christos * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.1 christos * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.1 christos * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.1 christos * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.1 christos * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.1 christos * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.1 christos * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.1 christos * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.1 christos * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.1 christos * POSSIBILITY OF SUCH DAMAGE.
30 1.1 christos */
31 1.1 christos #include <sys/cdefs.h>
32 1.1 christos __KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_90.c,v 1.1 2019/09/22 22:59:38 christos Exp $");
33 1.1 christos
34 1.1 christos #if defined(_KERNEL_OPT)
35 1.1 christos #include "opt_compat_netbsd.h"
36 1.1 christos #endif
37 1.1 christos
38 1.1 christos #include <sys/param.h>
39 1.1 christos #include <sys/systm.h>
40 1.1 christos #include <sys/namei.h>
41 1.1 christos #include <sys/filedesc.h>
42 1.1 christos #include <sys/kernel.h>
43 1.1 christos #include <sys/file.h>
44 1.1 christos #include <sys/stat.h>
45 1.1 christos #include <sys/socketvar.h>
46 1.1 christos #include <sys/vnode.h>
47 1.1 christos #include <sys/mount.h>
48 1.1 christos #include <sys/proc.h>
49 1.1 christos #include <sys/uio.h>
50 1.1 christos #include <sys/dirent.h>
51 1.1 christos #include <sys/malloc.h>
52 1.1 christos #include <sys/kauth.h>
53 1.1 christos #include <sys/vfs_syscalls.h>
54 1.1 christos #include <sys/syscall.h>
55 1.1 christos #include <sys/syscallvar.h>
56 1.1 christos #include <sys/syscallargs.h>
57 1.1 christos
58 1.1 christos #include <compat/common/compat_mod.h>
59 1.1 christos #include <compat/common/compat_util.h>
60 1.1 christos #include <compat/sys/statvfs.h>
61 1.1 christos
62 1.1 christos static const struct syscall_package vfs_syscalls_90_syscalls[] = {
63 1.1 christos { SYS_compat_90_getvfsstat, 0, (sy_call_t *)compat_90_sys_getvfsstat },
64 1.1 christos { SYS_compat_90_statvfs1, 0, (sy_call_t *)compat_90_sys_statvfs1 },
65 1.1 christos { SYS_compat_90_fstatvfs1, 0, (sy_call_t *)compat_90_sys_fstatvfs1 },
66 1.1 christos { SYS_compat_90_fhstatvfs1, 0, (sy_call_t *)compat_90_sys_fhstatvfs1 },
67 1.1 christos { 0,0, NULL }
68 1.1 christos };
69 1.1 christos
70 1.1 christos
71 1.1 christos int
72 1.1 christos compat_90_sys_getvfsstat(struct lwp *l,
73 1.1 christos const struct compat_90_sys_getvfsstat_args *uap, register_t *retval)
74 1.1 christos {
75 1.1 christos /* {
76 1.1 christos syscallarg(struct statvfs90 *) buf;
77 1.1 christos syscallarg(size_t) bufsize;
78 1.1 christos syscallarg(int) flags;
79 1.1 christos } */
80 1.1 christos
81 1.1 christos return do_sys_getvfsstat(l, SCARG(uap, buf), SCARG(uap, bufsize),
82 1.1 christos SCARG(uap, flags), statvfs_to_statvfs90_copy,
83 1.1 christos sizeof(struct statvfs90), retval);
84 1.1 christos }
85 1.1 christos
86 1.1 christos int
87 1.1 christos compat_90_sys_statvfs1(struct lwp *l,
88 1.1 christos const struct compat_90_sys_statvfs1_args *uap, register_t *retval)
89 1.1 christos {
90 1.1 christos /* {
91 1.1 christos syscallarg(const char *) path;
92 1.1 christos syscallarg(struct statvfs90 *) buf;
93 1.1 christos syscallarg(int) flags;
94 1.1 christos } */
95 1.1 christos
96 1.1 christos struct statvfs *sb = STATVFSBUF_GET();
97 1.1 christos int error = do_sys_pstatvfs(l, SCARG(uap, path), SCARG(uap, flags), sb);
98 1.1 christos
99 1.1 christos if (!error)
100 1.1 christos error = statvfs_to_statvfs90_copy(sb, SCARG(uap, buf),
101 1.1 christos sizeof(struct statvfs90));
102 1.1 christos
103 1.1 christos STATVFSBUF_PUT(sb);
104 1.1 christos return error;
105 1.1 christos }
106 1.1 christos
107 1.1 christos int
108 1.1 christos compat_90_sys_fstatvfs1(struct lwp *l,
109 1.1 christos const struct compat_90_sys_fstatvfs1_args *uap, register_t *retval)
110 1.1 christos {
111 1.1 christos /* {
112 1.1 christos syscallarg(int) fd;
113 1.1 christos syscallarg(struct statvfs90 *) buf;
114 1.1 christos syscallarg(int) flags;
115 1.1 christos } */
116 1.1 christos
117 1.1 christos struct statvfs *sb = STATVFSBUF_GET();
118 1.1 christos int error = do_sys_fstatvfs(l, SCARG(uap, fd), SCARG(uap, flags), sb);
119 1.1 christos
120 1.1 christos if (!error)
121 1.1 christos error = statvfs_to_statvfs90_copy(sb, SCARG(uap, buf),
122 1.1 christos sizeof(struct statvfs90));
123 1.1 christos
124 1.1 christos STATVFSBUF_PUT(sb);
125 1.1 christos return error;
126 1.1 christos }
127 1.1 christos
128 1.1 christos int
129 1.1 christos compat_90_sys_fhstatvfs1(struct lwp *l,
130 1.1 christos const struct compat_90_sys_fhstatvfs1_args *uap, register_t *retval)
131 1.1 christos {
132 1.1 christos /* {
133 1.1 christos syscallarg(const void *) fhp;
134 1.1 christos syscallarg(size_t) fh_size;
135 1.1 christos syscallarg(struct statvfs90 *) buf;
136 1.1 christos syscallarg(int) flags;
137 1.1 christos } */
138 1.1 christos
139 1.1 christos struct statvfs *sb = STATVFSBUF_GET();
140 1.1 christos int error = do_fhstatvfs(l, SCARG(uap, fhp), SCARG(uap, fh_size),
141 1.1 christos sb, SCARG(uap, flags));
142 1.1 christos
143 1.1 christos if (!error)
144 1.1 christos error = statvfs_to_statvfs90_copy(sb, SCARG(uap, buf),
145 1.1 christos sizeof(struct statvfs90));
146 1.1 christos
147 1.1 christos STATVFSBUF_PUT(sb);
148 1.1 christos return error;
149 1.1 christos }
150 1.1 christos
151 1.1 christos int
152 1.1 christos vfs_syscalls_90_init(void)
153 1.1 christos {
154 1.1 christos
155 1.1 christos return syscall_establish(NULL, vfs_syscalls_90_syscalls);
156 1.1 christos }
157 1.1 christos
158 1.1 christos int
159 1.1 christos vfs_syscalls_90_fini(void)
160 1.1 christos {
161 1.1 christos
162 1.1 christos return syscall_disestablish(NULL, vfs_syscalls_90_syscalls);
163 1.1 christos }
164