Print this page
7127 remove -Wno-missing-braces from Makefile.uts
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/fs/objfs/objfs_vfs.c
+++ new/usr/src/uts/common/fs/objfs/objfs_vfs.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 * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
23 23 */
24 24
25 25 #include <sys/atomic.h>
26 26 #include <sys/cmn_err.h>
27 27 #include <sys/errno.h>
28 28 #include <sys/mount.h>
29 29 #include <sys/objfs.h>
30 30 #include <sys/objfs_impl.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 /*
38 38 * Kernel object filesystem.
39 39 *
40 40 * This is a pseudo filesystem which exports information about currently loaded
41 41 * kernel objects. The root directory contains one directory for each loaded
42 42 * object, indexed by module name. Within each object directory is an ELF file,
43 43 * 'object', that contains information about the currently loaded module.
44 44 *
45 45 * This file contains functions that interact with the VFS layer. Each
46 46 * filesystem element is represented by a a different node.
47 47 *
48 48 * / objfs_rootnode_t objfs_root.c
49 49 * /<obj> objfs_odirnode_t objfs_odir.c
50 50 * /<obj>/object objfs_datanode_t objfs_data.c
51 51 *
52 52 * In addition, some common routines are found in the 'objfs_common.c' file.
53 53 */
54 54
55 55 vnodeops_t *objfs_ops_root;
56 56 vnodeops_t *objfs_ops_odir;
57 57 vnodeops_t *objfs_ops_data;
58 58
59 59 static const fs_operation_def_t objfs_vfstops[];
60 60 static gfs_opsvec_t objfs_opsvec[];
61 61
62 62 static int objfs_init(int, char *);
63 63
64 64 /*
65 65 * Module linkage
66 66 */
67 67 static mntopts_t objfs_mntopts = {
68 68 0,
69 69 NULL
70 70 };
71 71
72 72 static vfsdef_t vfw = {
73 73 VFSDEF_VERSION,
74 74 "objfs",
75 75 objfs_init,
76 76 VSW_HASPROTO | VSW_ZMOUNT,
↓ open down ↓ |
76 lines elided |
↑ open up ↑ |
77 77 &objfs_mntopts,
78 78 };
79 79
80 80 extern struct mod_ops mod_fsops;
81 81
82 82 static struct modlfs modlfs = {
83 83 &mod_fsops, "kernel object filesystem", &vfw
84 84 };
85 85
86 86 static struct modlinkage modlinkage = {
87 - MODREV_1, (void *)&modlfs, NULL
87 + MODREV_1, { (void *)&modlfs, NULL }
88 88 };
89 89
90 90 int
91 91 _init(void)
92 92 {
93 93 return (mod_install(&modlinkage));
94 94 }
95 95
96 96 int
97 97 _info(struct modinfo *modinfop)
98 98 {
99 99 return (mod_info(&modlinkage, modinfop));
100 100 }
101 101
102 102 int
103 103 _fini(void)
104 104 {
105 105 /*
106 106 * The object filesystem cannot be unloaded.
107 107 */
108 108 return (EBUSY);
109 109 }
110 110
111 111 /*
112 112 * Filesystem initialization.
113 113 */
114 114
115 115 static int objfs_fstype;
116 116 static major_t objfs_major;
117 117 static minor_t objfs_minor;
118 118
119 119 static gfs_opsvec_t objfs_opsvec[] = {
120 120 { "objfs root directory", objfs_tops_root, &objfs_ops_root },
121 121 { "objfs object directory", objfs_tops_odir, &objfs_ops_odir },
122 122 { "objfs data file", objfs_tops_data, &objfs_ops_data },
123 123 { NULL }
124 124 };
125 125
126 126 /* ARGSUSED */
127 127 static int
128 128 objfs_init(int fstype, char *name)
129 129 {
130 130 vfsops_t *vfsops;
131 131 int error;
132 132
133 133 objfs_fstype = fstype;
134 134 if (error = vfs_setfsops(fstype, objfs_vfstops, &vfsops)) {
135 135 cmn_err(CE_WARN, "objfs_init: bad vfs ops template");
136 136 return (error);
137 137 }
138 138
139 139 if (error = gfs_make_opsvec(objfs_opsvec)) {
140 140 (void) vfs_freevfsops(vfsops);
141 141 return (error);
142 142 }
143 143
144 144 if ((objfs_major = getudev()) == (major_t)-1) {
145 145 cmn_err(CE_WARN, "objfs_init: can't get unique device number");
146 146 objfs_major = 0;
147 147 }
148 148
149 149 objfs_data_init();
150 150
151 151 return (0);
152 152 }
153 153
154 154 /*
155 155 * VFS entry points
156 156 */
157 157 static int
158 158 objfs_mount(vfs_t *vfsp, vnode_t *mvp, struct mounta *uap, cred_t *cr)
159 159 {
160 160 objfs_vfs_t *data;
161 161 dev_t dev;
162 162
163 163 if (secpolicy_fs_mount(cr, mvp, vfsp) != 0)
164 164 return (EPERM);
165 165
166 166 if (mvp->v_type != VDIR)
167 167 return (ENOTDIR);
168 168
169 169 if ((uap->flags & MS_OVERLAY) == 0 &&
170 170 (mvp->v_count > 1 || (mvp->v_flag & VROOT)))
171 171 return (EBUSY);
172 172
173 173 data = kmem_alloc(sizeof (objfs_vfs_t), KM_SLEEP);
174 174
175 175 /*
176 176 * Initialize vfs fields
177 177 */
178 178 vfsp->vfs_bsize = DEV_BSIZE;
179 179 vfsp->vfs_fstype = objfs_fstype;
180 180 do {
181 181 dev = makedevice(objfs_major,
182 182 atomic_inc_32_nv(&objfs_minor) & L_MAXMIN32);
183 183 } while (vfs_devismounted(dev));
184 184 vfs_make_fsid(&vfsp->vfs_fsid, dev, objfs_fstype);
185 185 vfsp->vfs_data = data;
186 186 vfsp->vfs_dev = dev;
187 187
188 188 /*
189 189 * Create root
190 190 */
191 191 data->objfs_vfs_root = objfs_create_root(vfsp);
192 192
193 193 return (0);
194 194 }
195 195
196 196 static int
197 197 objfs_unmount(vfs_t *vfsp, int flag, struct cred *cr)
198 198 {
199 199 objfs_vfs_t *data;
200 200
201 201 if (secpolicy_fs_unmount(cr, vfsp) != 0)
202 202 return (EPERM);
203 203
204 204 /*
205 205 * We do not currently support forced unmounts
206 206 */
207 207 if (flag & MS_FORCE)
208 208 return (ENOTSUP);
209 209
210 210 /*
211 211 * We should never have a reference count of less than 2: one for the
212 212 * caller, one for the root vnode.
213 213 */
214 214 ASSERT(vfsp->vfs_count >= 2);
215 215
216 216 /*
217 217 * Any active vnodes will result in a hold on the root vnode
218 218 */
219 219 data = vfsp->vfs_data;
220 220 if (data->objfs_vfs_root->v_count > 1)
221 221 return (EBUSY);
222 222
223 223 /*
224 224 * Release the last hold on the root vnode
225 225 */
226 226 VN_RELE(data->objfs_vfs_root);
227 227
228 228 kmem_free(data, sizeof (objfs_vfs_t));
229 229
230 230 return (0);
231 231 }
232 232
233 233 static int
234 234 objfs_root(vfs_t *vfsp, vnode_t **vpp)
235 235 {
236 236 objfs_vfs_t *data = vfsp->vfs_data;
237 237
238 238 *vpp = data->objfs_vfs_root;
239 239 VN_HOLD(*vpp);
240 240
241 241 return (0);
242 242 }
243 243
244 244 static int
245 245 objfs_statvfs(vfs_t *vfsp, statvfs64_t *sp)
246 246 {
247 247 dev32_t d32;
248 248 int total = objfs_nobjs();
249 249
250 250 bzero(sp, sizeof (*sp));
251 251 sp->f_bsize = DEV_BSIZE;
252 252 sp->f_frsize = DEV_BSIZE;
253 253 sp->f_files = total;
254 254 sp->f_ffree = sp->f_favail = INT_MAX - total;
255 255 (void) cmpldev(&d32, vfsp->vfs_dev);
256 256 sp->f_fsid = d32;
257 257 (void) strlcpy(sp->f_basetype, vfssw[vfsp->vfs_fstype].vsw_name,
258 258 sizeof (sp->f_basetype));
259 259 sp->f_flag = vf_to_stf(vfsp->vfs_flag);
260 260 sp->f_namemax = OBJFS_NAME_MAX;
261 261 (void) strlcpy(sp->f_fstr, "object", sizeof (sp->f_fstr));
262 262
263 263 return (0);
264 264 }
265 265
266 266 static const fs_operation_def_t objfs_vfstops[] = {
267 267 { VFSNAME_MOUNT, { .vfs_mount = objfs_mount } },
268 268 { VFSNAME_UNMOUNT, { .vfs_unmount = objfs_unmount } },
269 269 { VFSNAME_ROOT, { .vfs_root = objfs_root } },
270 270 { VFSNAME_STATVFS, { .vfs_statvfs = objfs_statvfs } },
271 271 { NULL }
272 272 };
↓ open down ↓ |
175 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX