Print this page
7127 remove -Wno-missing-braces from Makefile.uts
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/fs/sharefs/sharefs_vfsops.c
+++ new/usr/src/uts/common/fs/sharefs/sharefs_vfsops.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24 24 */
25 25
26 26 #include <sys/atomic.h>
27 27 #include <sys/cmn_err.h>
28 28 #include <sys/errno.h>
29 29 #include <sys/mount.h>
30 30 #include <sharefs/sharefs.h>
31 31 #include <sys/vfs_opreg.h>
32 32 #include <sys/policy.h>
33 33 #include <sys/sunddi.h>
34 34 #include <sys/sysmacros.h>
35 35 #include <sys/systm.h>
36 36
37 37 #include <sys/mntent.h>
38 38 #include <sys/vfs.h>
39 39
40 40 /*
41 41 * Kernel sharetab filesystem.
42 42 *
43 43 * This is a pseudo filesystem which exports information about shares currently
44 44 * in kernel memory. The only element of the pseudo filesystem is a file.
45 45 *
46 46 * This file contains functions that interact with the VFS layer.
47 47 *
48 48 * sharetab sharefs_datanode_t sharefs.c
49 49 *
50 50 */
51 51
52 52 vnodeops_t *sharefs_ops_data;
53 53
54 54 static const fs_operation_def_t sharefs_vfstops[];
55 55 static gfs_opsvec_t sharefs_opsvec[];
56 56
57 57 static int sharefs_init(int, char *);
58 58
59 59 /*
60 60 * The sharefs system call.
61 61 */
62 62 static struct sysent sharefs_sysent = {
63 63 3,
64 64 SE_32RVAL1 | SE_ARGC | SE_NOUNLOAD,
65 65 sharefs
66 66 };
67 67
68 68 static struct modlsys modlsys = {
69 69 &mod_syscallops,
70 70 "sharefs syscall",
71 71 &sharefs_sysent
72 72 };
73 73
74 74 #ifdef _SYSCALL32_IMPL
75 75 static struct modlsys modlsys32 = {
76 76 &mod_syscallops32,
77 77 "sharefs syscall (32-bit)",
78 78 &sharefs_sysent
79 79 };
80 80 #endif /* _SYSCALL32_IMPL */
81 81
82 82 /*
83 83 * Module linkage
84 84 */
85 85 static mntopts_t sharefs_mntopts = {
86 86 0,
87 87 NULL
88 88 };
89 89
90 90 static vfsdef_t vfw = {
91 91 VFSDEF_VERSION,
92 92 "sharefs",
93 93 sharefs_init,
94 94 VSW_HASPROTO | VSW_ZMOUNT,
95 95 &sharefs_mntopts,
96 96 };
97 97
↓ open down ↓ |
97 lines elided |
↑ open up ↑ |
98 98 extern struct mod_ops mod_fsops;
99 99
100 100 static struct modlfs modlfs = {
101 101 &mod_fsops,
102 102 "sharetab filesystem",
103 103 &vfw
104 104 };
105 105
106 106 static struct modlinkage modlinkage = {
107 107 MODREV_1,
108 - &modlfs,
109 - &modlsys,
108 + { &modlfs,
109 + &modlsys,
110 110 #ifdef _SYSCALL32_IMPL
111 - &modlsys32,
111 + &modlsys32,
112 112 #endif
113 - NULL
113 + NULL
114 + }
114 115 };
115 116
116 117 int
117 118 _init(void)
118 119 {
119 120 return (mod_install(&modlinkage));
120 121 }
121 122
122 123 int
123 124 _info(struct modinfo *modinfop)
124 125 {
125 126 return (mod_info(&modlinkage, modinfop));
126 127 }
127 128
128 129 int
129 130 _fini(void)
130 131 {
131 132 /*
132 133 * The sharetab filesystem cannot be unloaded.
133 134 */
134 135 return (EBUSY);
135 136 }
136 137
137 138 /*
138 139 * Filesystem initialization.
139 140 */
140 141
141 142 static int sharefs_fstype;
142 143 static major_t sharefs_major;
143 144 static minor_t sharefs_minor;
144 145
145 146 static gfs_opsvec_t sharefs_opsvec[] = {
146 147 { "sharefs sharetab file", sharefs_tops_data, &sharefs_ops_data },
147 148 { NULL }
148 149 };
149 150
150 151 /* ARGSUSED */
151 152 static int
152 153 sharefs_init(int fstype, char *name)
153 154 {
154 155 vfsops_t *vfsops;
155 156 int error;
156 157
157 158 sharefs_fstype = fstype;
158 159 if (error = vfs_setfsops(fstype, sharefs_vfstops, &vfsops)) {
159 160 cmn_err(CE_WARN, "sharefs_init: bad vfs ops template");
160 161 return (error);
161 162 }
162 163
163 164 if (error = gfs_make_opsvec(sharefs_opsvec)) {
164 165 (void) vfs_freevfsops(vfsops);
165 166 return (error);
166 167 }
167 168
168 169 if ((sharefs_major = getudev()) == (major_t)-1) {
169 170 cmn_err(CE_WARN,
170 171 "sharefs_init: can't get unique device number");
171 172 sharefs_major = 0;
172 173 }
173 174
174 175 sharefs_sharetab_init();
175 176
176 177 return (0);
177 178 }
178 179
179 180 /*
180 181 * VFS entry points
181 182 */
182 183 static int
183 184 sharefs_mount(vfs_t *vfsp, vnode_t *mvp, struct mounta *uap, cred_t *cr)
184 185 {
185 186 sharefs_vfs_t *data;
186 187 dev_t dev;
187 188
188 189 if (secpolicy_fs_mount(cr, mvp, vfsp) != 0)
189 190 return (EPERM);
190 191
191 192 if ((uap->flags & MS_OVERLAY) == 0 &&
192 193 (mvp->v_count > 1 || (mvp->v_flag & VROOT)))
193 194 return (EBUSY);
194 195
195 196 data = kmem_alloc(sizeof (sharefs_vfs_t), KM_SLEEP);
196 197
197 198 /*
198 199 * Initialize vfs fields
199 200 */
200 201 vfsp->vfs_bsize = DEV_BSIZE;
201 202 vfsp->vfs_fstype = sharefs_fstype;
202 203 do {
203 204 dev = makedevice(sharefs_major,
204 205 atomic_inc_32_nv(&sharefs_minor) & L_MAXMIN32);
205 206 } while (vfs_devismounted(dev));
206 207 vfs_make_fsid(&vfsp->vfs_fsid, dev, sharefs_fstype);
207 208 vfsp->vfs_data = data;
208 209 vfsp->vfs_dev = dev;
209 210
210 211 /*
211 212 * Create root
212 213 */
213 214 data->sharefs_vfs_root = sharefs_create_root_file(vfsp);
214 215
215 216 return (0);
216 217 }
217 218
218 219 static int
219 220 sharefs_unmount(vfs_t *vfsp, int flag, struct cred *cr)
220 221 {
221 222 sharefs_vfs_t *data;
222 223
223 224 if (secpolicy_fs_unmount(cr, vfsp) != 0)
224 225 return (EPERM);
225 226
226 227 /*
227 228 * We do not currently support forced unmounts
228 229 */
229 230 if (flag & MS_FORCE)
230 231 return (ENOTSUP);
231 232
232 233 /*
233 234 * We should never have a reference count of less than 2: one for the
234 235 * caller, one for the root vnode.
235 236 */
236 237 ASSERT(vfsp->vfs_count >= 2);
237 238
238 239 /*
239 240 * Any active vnodes will result in a hold on the root vnode
240 241 */
241 242 data = vfsp->vfs_data;
242 243 if (data->sharefs_vfs_root->v_count > 1)
243 244 return (EBUSY);
244 245
245 246 /*
246 247 * Only allow an unmount iff there are no entries in memory.
247 248 */
248 249 rw_enter(&sharetab_lock, RW_READER);
249 250 if (sharetab_size != 0) {
250 251 rw_exit(&sharetab_lock);
251 252 return (EBUSY);
252 253 }
253 254 rw_exit(&sharetab_lock);
254 255
255 256 /*
256 257 * Release the last hold on the root vnode
257 258 */
258 259 VN_RELE(data->sharefs_vfs_root);
259 260
260 261 kmem_free(data, sizeof (sharefs_vfs_t));
261 262
262 263 return (0);
263 264 }
264 265
265 266 static int
266 267 sharefs_root(vfs_t *vfsp, vnode_t **vpp)
267 268 {
268 269 sharefs_vfs_t *data = vfsp->vfs_data;
269 270
270 271 *vpp = data->sharefs_vfs_root;
271 272 VN_HOLD(*vpp);
272 273
273 274 return (0);
274 275 }
275 276
276 277 static int
277 278 sharefs_statvfs(vfs_t *vfsp, statvfs64_t *sp)
278 279 {
279 280 dev32_t d32;
280 281 int total = 1;
281 282
282 283 bzero(sp, sizeof (*sp));
283 284 sp->f_bsize = DEV_BSIZE;
284 285 sp->f_frsize = DEV_BSIZE;
285 286 sp->f_files = total;
286 287 sp->f_ffree = sp->f_favail = INT_MAX - total;
287 288 (void) cmpldev(&d32, vfsp->vfs_dev);
288 289 sp->f_fsid = d32;
289 290 (void) strlcpy(sp->f_basetype, vfssw[vfsp->vfs_fstype].vsw_name,
290 291 sizeof (sp->f_basetype));
291 292 sp->f_flag = vf_to_stf(vfsp->vfs_flag);
292 293 sp->f_namemax = SHAREFS_NAME_MAX;
293 294 (void) strlcpy(sp->f_fstr, "sharefs", sizeof (sp->f_fstr));
294 295
295 296 return (0);
296 297 }
297 298
298 299 static const fs_operation_def_t sharefs_vfstops[] = {
299 300 { VFSNAME_MOUNT, { .vfs_mount = sharefs_mount } },
300 301 { VFSNAME_UNMOUNT, { .vfs_unmount = sharefs_unmount } },
301 302 { VFSNAME_ROOT, { .vfs_root = sharefs_root } },
302 303 { VFSNAME_STATVFS, { .vfs_statvfs = sharefs_statvfs } },
303 304 { NULL }
304 305 };
↓ open down ↓ |
181 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX