udf_vfsops.c revision 1.38 1 1.38 reinoud /* $NetBSD: udf_vfsops.c,v 1.38 2008/05/14 16:49:48 reinoud Exp $ */
2 1.1 reinoud
3 1.1 reinoud /*
4 1.38 reinoud * Copyright (c) 2006, 2008 Reinoud Zandijk
5 1.1 reinoud * All rights reserved.
6 1.1 reinoud *
7 1.1 reinoud * Redistribution and use in source and binary forms, with or without
8 1.1 reinoud * modification, are permitted provided that the following conditions
9 1.1 reinoud * are met:
10 1.1 reinoud * 1. Redistributions of source code must retain the above copyright
11 1.1 reinoud * notice, this list of conditions and the following disclaimer.
12 1.1 reinoud * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 reinoud * notice, this list of conditions and the following disclaimer in the
14 1.1 reinoud * documentation and/or other materials provided with the distribution.
15 1.1 reinoud *
16 1.1 reinoud * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 1.1 reinoud * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 1.1 reinoud * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 1.1 reinoud * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 1.1 reinoud * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 1.1 reinoud * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 1.1 reinoud * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 1.1 reinoud * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 1.1 reinoud * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 1.1 reinoud * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 1.1 reinoud *
27 1.1 reinoud */
28 1.1 reinoud
29 1.1 reinoud #include <sys/cdefs.h>
30 1.1 reinoud #ifndef lint
31 1.38 reinoud __KERNEL_RCSID(0, "$NetBSD: udf_vfsops.c,v 1.38 2008/05/14 16:49:48 reinoud Exp $");
32 1.1 reinoud #endif /* not lint */
33 1.1 reinoud
34 1.1 reinoud
35 1.1 reinoud #if defined(_KERNEL_OPT)
36 1.1 reinoud #include "opt_quota.h"
37 1.1 reinoud #include "opt_compat_netbsd.h"
38 1.38 reinoud #include "opt_udf.h"
39 1.1 reinoud #endif
40 1.1 reinoud
41 1.1 reinoud #include <sys/param.h>
42 1.1 reinoud #include <sys/systm.h>
43 1.1 reinoud #include <sys/sysctl.h>
44 1.1 reinoud #include <sys/namei.h>
45 1.1 reinoud #include <sys/proc.h>
46 1.1 reinoud #include <sys/kernel.h>
47 1.1 reinoud #include <sys/vnode.h>
48 1.35 dholland #include <miscfs/genfs/genfs.h>
49 1.1 reinoud #include <miscfs/specfs/specdev.h>
50 1.1 reinoud #include <sys/mount.h>
51 1.1 reinoud #include <sys/buf.h>
52 1.1 reinoud #include <sys/file.h>
53 1.1 reinoud #include <sys/device.h>
54 1.1 reinoud #include <sys/disklabel.h>
55 1.1 reinoud #include <sys/ioctl.h>
56 1.1 reinoud #include <sys/malloc.h>
57 1.1 reinoud #include <sys/dirent.h>
58 1.1 reinoud #include <sys/stat.h>
59 1.1 reinoud #include <sys/conf.h>
60 1.5 christos #include <sys/kauth.h>
61 1.37 rumble #include <sys/module.h>
62 1.1 reinoud
63 1.1 reinoud #include <fs/udf/ecma167-udf.h>
64 1.1 reinoud #include <fs/udf/udf_mount.h>
65 1.1 reinoud
66 1.1 reinoud #include "udf.h"
67 1.1 reinoud #include "udf_subr.h"
68 1.1 reinoud #include "udf_bswap.h"
69 1.1 reinoud
70 1.37 rumble MODULE(MODULE_CLASS_VFS, udf, NULL);
71 1.1 reinoud
72 1.38 reinoud #define VTOI(vnode) ((struct udf_node *) vnode->v_data)
73 1.38 reinoud
74 1.1 reinoud /* verbose levels of the udf filingsystem */
75 1.1 reinoud int udf_verbose = UDF_DEBUGGING;
76 1.1 reinoud
77 1.1 reinoud /* malloc regions */
78 1.25 pooka MALLOC_JUSTDEFINE(M_UDFMNT, "UDF mount", "UDF mount structures");
79 1.25 pooka MALLOC_JUSTDEFINE(M_UDFVOLD, "UDF volspace", "UDF volume space descriptors");
80 1.25 pooka MALLOC_JUSTDEFINE(M_UDFTEMP, "UDF temp", "UDF scrap space");
81 1.1 reinoud struct pool udf_node_pool;
82 1.1 reinoud
83 1.1 reinoud /* supported functions predefined */
84 1.29 pooka VFS_PROTOS(udf);
85 1.1 reinoud
86 1.1 reinoud
87 1.1 reinoud /* internal functions */
88 1.1 reinoud static int udf_mountfs(struct vnode *, struct mount *, struct lwp *, struct udf_args *);
89 1.1 reinoud
90 1.1 reinoud
91 1.1 reinoud /* --------------------------------------------------------------------- */
92 1.1 reinoud
93 1.1 reinoud /* predefine vnode-op list descriptor */
94 1.1 reinoud extern const struct vnodeopv_desc udf_vnodeop_opv_desc;
95 1.1 reinoud
96 1.1 reinoud const struct vnodeopv_desc * const udf_vnodeopv_descs[] = {
97 1.1 reinoud &udf_vnodeop_opv_desc,
98 1.1 reinoud NULL,
99 1.1 reinoud };
100 1.1 reinoud
101 1.1 reinoud
102 1.1 reinoud /* vfsops descriptor linked in as anchor point for the filingsystem */
103 1.1 reinoud struct vfsops udf_vfsops = {
104 1.1 reinoud MOUNT_UDF, /* vfs_name */
105 1.26 dsl sizeof (struct udf_args),
106 1.1 reinoud udf_mount,
107 1.1 reinoud udf_start,
108 1.1 reinoud udf_unmount,
109 1.1 reinoud udf_root,
110 1.31 pooka (void *)eopnotsupp, /* vfs_quotactl */
111 1.1 reinoud udf_statvfs,
112 1.1 reinoud udf_sync,
113 1.1 reinoud udf_vget,
114 1.1 reinoud udf_fhtovp,
115 1.1 reinoud udf_vptofh,
116 1.1 reinoud udf_init,
117 1.1 reinoud udf_reinit,
118 1.1 reinoud udf_done,
119 1.1 reinoud udf_mountroot,
120 1.1 reinoud udf_snapshot,
121 1.1 reinoud vfs_stdextattrctl,
122 1.28 pooka (void *)eopnotsupp, /* vfs_suspendctl */
123 1.35 dholland genfs_renamelock_enter,
124 1.35 dholland genfs_renamelock_exit,
125 1.36 ad (void *)eopnotsupp,
126 1.1 reinoud udf_vnodeopv_descs,
127 1.12 christos 0, /* int vfs_refcount */
128 1.12 christos { NULL, NULL, }, /* LIST_ENTRY(vfsops) */
129 1.1 reinoud };
130 1.1 reinoud
131 1.1 reinoud /* --------------------------------------------------------------------- */
132 1.1 reinoud
133 1.1 reinoud /* file system starts here */
134 1.1 reinoud void
135 1.1 reinoud udf_init(void)
136 1.1 reinoud {
137 1.1 reinoud size_t size;
138 1.1 reinoud
139 1.1 reinoud malloc_type_attach(M_UDFMNT);
140 1.1 reinoud malloc_type_attach(M_UDFVOLD);
141 1.1 reinoud malloc_type_attach(M_UDFTEMP);
142 1.1 reinoud
143 1.1 reinoud /* init hashtables and pools */
144 1.1 reinoud size = sizeof(struct udf_node);
145 1.23 ad pool_init(&udf_node_pool, size, 0, 0, 0, "udf_node_pool", NULL,
146 1.23 ad IPL_NONE);
147 1.1 reinoud }
148 1.1 reinoud
149 1.1 reinoud
150 1.1 reinoud void
151 1.1 reinoud udf_reinit(void)
152 1.1 reinoud {
153 1.1 reinoud /* recreate hashtables */
154 1.1 reinoud /* reinit pool? */
155 1.1 reinoud }
156 1.1 reinoud
157 1.1 reinoud
158 1.1 reinoud void
159 1.1 reinoud udf_done(void)
160 1.1 reinoud {
161 1.1 reinoud /* remove hashtables and pools */
162 1.1 reinoud pool_destroy(&udf_node_pool);
163 1.1 reinoud
164 1.1 reinoud malloc_type_detach(M_UDFMNT);
165 1.1 reinoud malloc_type_detach(M_UDFVOLD);
166 1.1 reinoud malloc_type_detach(M_UDFTEMP);
167 1.1 reinoud }
168 1.1 reinoud
169 1.38 reinoud
170 1.38 reinoud static int
171 1.38 reinoud udf_modcmd(modcmd_t cmd, void *arg)
172 1.38 reinoud {
173 1.38 reinoud
174 1.38 reinoud switch (cmd) {
175 1.38 reinoud case MODULE_CMD_INIT:
176 1.38 reinoud return vfs_attach(&udf_vfsops);
177 1.38 reinoud case MODULE_CMD_FINI:
178 1.38 reinoud return vfs_detach(&udf_vfsops);
179 1.38 reinoud default:
180 1.38 reinoud return ENOTTY;
181 1.38 reinoud }
182 1.38 reinoud }
183 1.38 reinoud
184 1.1 reinoud /* --------------------------------------------------------------------- */
185 1.1 reinoud
186 1.1 reinoud int
187 1.1 reinoud udf_mountroot(void)
188 1.1 reinoud {
189 1.1 reinoud return EOPNOTSUPP;
190 1.1 reinoud }
191 1.1 reinoud
192 1.1 reinoud /* --------------------------------------------------------------------- */
193 1.1 reinoud
194 1.1 reinoud #define MPFREE(a, lst) \
195 1.1 reinoud if ((a)) free((a), lst);
196 1.1 reinoud static void
197 1.1 reinoud free_udf_mountinfo(struct mount *mp)
198 1.1 reinoud {
199 1.1 reinoud struct udf_mount *ump;
200 1.1 reinoud int i;
201 1.1 reinoud
202 1.15 reinoud if (!mp)
203 1.15 reinoud return;
204 1.15 reinoud
205 1.1 reinoud ump = VFSTOUDF(mp);
206 1.1 reinoud if (ump) {
207 1.10 reinoud /* clear our data */
208 1.1 reinoud for (i = 0; i < UDF_ANCHORS; i++)
209 1.1 reinoud MPFREE(ump->anchors[i], M_UDFVOLD);
210 1.1 reinoud MPFREE(ump->primary_vol, M_UDFVOLD);
211 1.1 reinoud MPFREE(ump->logical_vol, M_UDFVOLD);
212 1.1 reinoud MPFREE(ump->unallocated, M_UDFVOLD);
213 1.1 reinoud MPFREE(ump->implementation, M_UDFVOLD);
214 1.1 reinoud MPFREE(ump->logvol_integrity, M_UDFVOLD);
215 1.38 reinoud for (i = 0; i < UDF_PARTITIONS; i++) {
216 1.1 reinoud MPFREE(ump->partitions[i], M_UDFVOLD);
217 1.38 reinoud MPFREE(ump->part_unalloc_dscr[i], M_UDFVOLD);
218 1.38 reinoud MPFREE(ump->part_freed_dscr[i], M_UDFVOLD);
219 1.38 reinoud }
220 1.1 reinoud MPFREE(ump->fileset_desc, M_UDFVOLD);
221 1.1 reinoud MPFREE(ump->sparing_table, M_UDFVOLD);
222 1.38 reinoud MPFREE(ump->metadata_bitmap.bits, M_UDFVOLD);
223 1.38 reinoud
224 1.38 reinoud MPFREE(ump->la_node_ad_cpy, M_UDFMNT);
225 1.38 reinoud MPFREE(ump->la_pmapping, M_TEMP);
226 1.38 reinoud MPFREE(ump->la_lmapping, M_TEMP);
227 1.1 reinoud
228 1.30 ad mutex_destroy(&ump->ihash_lock);
229 1.30 ad mutex_destroy(&ump->get_node_lock);
230 1.38 reinoud
231 1.38 reinoud mutex_destroy(&ump->allocate_mutex);
232 1.38 reinoud MPFREE(ump->vat_table, M_UDFVOLD);
233 1.38 reinoud
234 1.1 reinoud free(ump, M_UDFMNT);
235 1.6 christos }
236 1.1 reinoud }
237 1.1 reinoud #undef MPFREE
238 1.1 reinoud
239 1.1 reinoud /* --------------------------------------------------------------------- */
240 1.1 reinoud
241 1.38 reinoud /* if the system nodes exist, release them */
242 1.38 reinoud static void
243 1.38 reinoud udf_release_system_nodes(struct mount *mp)
244 1.38 reinoud {
245 1.38 reinoud struct udf_mount *ump = VFSTOUDF(mp);
246 1.38 reinoud int error;
247 1.38 reinoud
248 1.38 reinoud /* if we haven't even got an ump, dont bother */
249 1.38 reinoud if (!ump)
250 1.38 reinoud return;
251 1.38 reinoud
252 1.38 reinoud /* VAT partition support */
253 1.38 reinoud if (ump->vat_node)
254 1.38 reinoud vrele(ump->vat_node->vnode);
255 1.38 reinoud
256 1.38 reinoud /* Metadata partition support */
257 1.38 reinoud if (ump->metadata_node)
258 1.38 reinoud vrele(ump->metadata_node->vnode);
259 1.38 reinoud if (ump->metadatamirror_node)
260 1.38 reinoud vrele(ump->metadatamirror_node->vnode);
261 1.38 reinoud if (ump->metadatabitmap_node)
262 1.38 reinoud vrele(ump->metadatabitmap_node->vnode);
263 1.38 reinoud
264 1.38 reinoud /* This flush should NOT write anything nor allow any node to remain */
265 1.38 reinoud if ((error = vflush(ump->vfs_mountp, NULLVP, 0)) != 0)
266 1.38 reinoud panic("Failure to flush UDF system vnodes\n");
267 1.38 reinoud }
268 1.38 reinoud
269 1.38 reinoud
270 1.1 reinoud int
271 1.1 reinoud udf_mount(struct mount *mp, const char *path,
272 1.31 pooka void *data, size_t *data_len)
273 1.1 reinoud {
274 1.31 pooka struct lwp *l = curlwp;
275 1.29 pooka struct nameidata nd;
276 1.26 dsl struct udf_args *args = data;
277 1.1 reinoud struct udf_mount *ump;
278 1.1 reinoud struct vnode *devvp;
279 1.1 reinoud int openflags, accessmode, error;
280 1.1 reinoud
281 1.1 reinoud DPRINTF(CALL, ("udf_mount called\n"));
282 1.1 reinoud
283 1.26 dsl if (*data_len < sizeof *args)
284 1.26 dsl return EINVAL;
285 1.26 dsl
286 1.1 reinoud if (mp->mnt_flag & MNT_GETARGS) {
287 1.1 reinoud /* request for the mount arguments */
288 1.1 reinoud ump = VFSTOUDF(mp);
289 1.1 reinoud if (ump == NULL)
290 1.1 reinoud return EINVAL;
291 1.26 dsl *args = ump->mount_args;
292 1.26 dsl *data_len = sizeof *args;
293 1.26 dsl return 0;
294 1.6 christos }
295 1.1 reinoud
296 1.1 reinoud /* handle request for updating mount parameters */
297 1.1 reinoud /* TODO can't update my mountpoint yet */
298 1.1 reinoud if (mp->mnt_flag & MNT_UPDATE) {
299 1.1 reinoud return EOPNOTSUPP;
300 1.6 christos }
301 1.1 reinoud
302 1.15 reinoud /* OK, so we are asked to mount the device */
303 1.1 reinoud
304 1.1 reinoud /* check/translate struct version */
305 1.1 reinoud /* TODO sanity checking other mount arguments */
306 1.26 dsl if (args->version != 1) {
307 1.1 reinoud printf("mount_udf: unrecognized argument structure version\n");
308 1.1 reinoud return EINVAL;
309 1.6 christos }
310 1.1 reinoud
311 1.1 reinoud /* lookup name to get its vnode */
312 1.32 pooka NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, args->fspec);
313 1.29 pooka error = namei(&nd);
314 1.1 reinoud if (error)
315 1.1 reinoud return error;
316 1.29 pooka devvp = nd.ni_vp;
317 1.1 reinoud
318 1.1 reinoud #ifdef DEBUG
319 1.1 reinoud if (udf_verbose & UDF_DEBUG_VOLUMES)
320 1.1 reinoud vprint("UDF mount, trying to mount \n", devvp);
321 1.1 reinoud #endif
322 1.1 reinoud
323 1.1 reinoud /* check if its a block device specified */
324 1.1 reinoud if (devvp->v_type != VBLK) {
325 1.1 reinoud vrele(devvp);
326 1.1 reinoud return ENOTBLK;
327 1.1 reinoud }
328 1.1 reinoud if (bdevsw_lookup(devvp->v_rdev) == NULL) {
329 1.1 reinoud vrele(devvp);
330 1.1 reinoud return ENXIO;
331 1.1 reinoud }
332 1.1 reinoud
333 1.38 reinoud #ifndef UDF_READWRITE
334 1.1 reinoud /* force read-only for now */
335 1.38 reinoud if ((mp->mnt_flag & MNT_RDONLY) == 0) {
336 1.38 reinoud printf("Enable kernel option UDF_READWRITE for writing\n");
337 1.38 reinoud vrele(devvp);
338 1.38 reinoud return EROFS;
339 1.38 reinoud }
340 1.38 reinoud #endif
341 1.1 reinoud
342 1.1 reinoud /*
343 1.1 reinoud * If mount by non-root, then verify that user has necessary
344 1.1 reinoud * permissions on the device.
345 1.1 reinoud */
346 1.20 elad if (kauth_authorize_generic(l->l_cred, KAUTH_GENERIC_ISSUSER, NULL)) {
347 1.1 reinoud accessmode = VREAD;
348 1.1 reinoud if ((mp->mnt_flag & MNT_RDONLY) == 0)
349 1.1 reinoud accessmode |= VWRITE;
350 1.13 reinoud vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
351 1.31 pooka error = VOP_ACCESS(devvp, accessmode, l->l_cred);
352 1.13 reinoud VOP_UNLOCK(devvp, 0);
353 1.1 reinoud if (error) {
354 1.13 reinoud vrele(devvp);
355 1.13 reinoud return error;
356 1.1 reinoud }
357 1.1 reinoud }
358 1.1 reinoud
359 1.1 reinoud /*
360 1.1 reinoud * Open device and try to mount it!
361 1.1 reinoud */
362 1.1 reinoud if (mp->mnt_flag & MNT_RDONLY) {
363 1.1 reinoud openflags = FREAD;
364 1.1 reinoud } else {
365 1.1 reinoud openflags = FREAD | FWRITE;
366 1.6 christos }
367 1.31 pooka error = VOP_OPEN(devvp, openflags, FSCRED);
368 1.1 reinoud if (error == 0) {
369 1.1 reinoud /* opened ok, try mounting */
370 1.26 dsl error = udf_mountfs(devvp, mp, l, args);
371 1.1 reinoud if (error) {
372 1.38 reinoud udf_release_system_nodes(mp);
373 1.38 reinoud /* cleanup */
374 1.38 reinoud udf_discstrat_finish(VFSTOUDF(mp));
375 1.1 reinoud free_udf_mountinfo(mp);
376 1.13 reinoud vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
377 1.31 pooka (void) VOP_CLOSE(devvp, openflags, NOCRED);
378 1.13 reinoud VOP_UNLOCK(devvp, 0);
379 1.6 christos }
380 1.6 christos }
381 1.1 reinoud if (error) {
382 1.1 reinoud /* devvp is still locked */
383 1.13 reinoud vrele(devvp);
384 1.1 reinoud return error;
385 1.6 christos }
386 1.1 reinoud
387 1.1 reinoud /* register our mountpoint being on this device */
388 1.1 reinoud devvp->v_specmountpoint = mp;
389 1.1 reinoud
390 1.1 reinoud /* successfully mounted */
391 1.1 reinoud DPRINTF(VOLUMES, ("udf_mount() successfull\n"));
392 1.1 reinoud
393 1.38 reinoud error = set_statvfs_info(path, UIO_USERSPACE, args->fspec, UIO_USERSPACE,
394 1.27 pooka mp->mnt_op->vfs_name, mp, l);
395 1.38 reinoud if (error)
396 1.38 reinoud return error;
397 1.38 reinoud
398 1.38 reinoud /* If we're not opened read-only, open its logical volume */
399 1.38 reinoud if ((mp->mnt_flag & MNT_RDONLY) == 0) {
400 1.38 reinoud if ((error = udf_open_logvol(VFSTOUDF(mp))) != 0) {
401 1.38 reinoud printf( "mount_udf: can't open logical volume for "
402 1.38 reinoud "writing,downgrading access to read-only\n");
403 1.38 reinoud mp->mnt_flag |= MNT_RDONLY;
404 1.38 reinoud /* FIXME we can't return error now on open failure */
405 1.38 reinoud return 0;
406 1.38 reinoud }
407 1.38 reinoud }
408 1.38 reinoud
409 1.38 reinoud return 0;
410 1.1 reinoud }
411 1.1 reinoud
412 1.1 reinoud /* --------------------------------------------------------------------- */
413 1.1 reinoud
414 1.1 reinoud #ifdef DEBUG
415 1.1 reinoud static void
416 1.1 reinoud udf_unmount_sanity_check(struct mount *mp)
417 1.1 reinoud {
418 1.1 reinoud struct vnode *vp;
419 1.1 reinoud
420 1.1 reinoud printf("On unmount, i found the following nodes:\n");
421 1.17 reinoud TAILQ_FOREACH(vp, &mp->mnt_vnodelist, v_mntvnodes) {
422 1.1 reinoud vprint("", vp);
423 1.1 reinoud if (VOP_ISLOCKED(vp) == LK_EXCLUSIVE) {
424 1.1 reinoud printf(" is locked\n");
425 1.6 christos }
426 1.1 reinoud if (vp->v_usecount > 1)
427 1.1 reinoud printf(" more than one usecount %d\n", vp->v_usecount);
428 1.6 christos }
429 1.1 reinoud }
430 1.1 reinoud #endif
431 1.1 reinoud
432 1.1 reinoud
433 1.1 reinoud int
434 1.31 pooka udf_unmount(struct mount *mp, int mntflags)
435 1.1 reinoud {
436 1.1 reinoud struct udf_mount *ump;
437 1.1 reinoud int error, flags, closeflags;
438 1.1 reinoud
439 1.1 reinoud DPRINTF(CALL, ("udf_umount called\n"));
440 1.1 reinoud
441 1.1 reinoud ump = VFSTOUDF(mp);
442 1.1 reinoud if (!ump)
443 1.1 reinoud panic("UDF unmount: empty ump\n");
444 1.1 reinoud
445 1.19 reinoud flags = (mntflags & MNT_FORCE) ? FORCECLOSE : 0;
446 1.1 reinoud /* TODO remove these paranoid functions */
447 1.1 reinoud #ifdef DEBUG
448 1.1 reinoud if (udf_verbose & UDF_DEBUG_LOCKING)
449 1.1 reinoud udf_unmount_sanity_check(mp);
450 1.1 reinoud #endif
451 1.1 reinoud
452 1.19 reinoud /*
453 1.30 ad * By specifying SKIPSYSTEM we can skip vnodes marked with VV_SYSTEM.
454 1.19 reinoud * This hardly documented feature allows us to exempt certain files
455 1.19 reinoud * from being flushed.
456 1.19 reinoud */
457 1.30 ad if ((error = vflush(mp, NULLVP, flags | SKIPSYSTEM)) != 0)
458 1.1 reinoud return error;
459 1.1 reinoud
460 1.38 reinoud /* update nodes and wait for completion of writeout of system nodes */
461 1.38 reinoud udf_sync(mp, FSYNC_WAIT, NOCRED);
462 1.38 reinoud
463 1.1 reinoud #ifdef DEBUG
464 1.1 reinoud if (udf_verbose & UDF_DEBUG_LOCKING)
465 1.1 reinoud udf_unmount_sanity_check(mp);
466 1.1 reinoud #endif
467 1.1 reinoud
468 1.38 reinoud /* flush again, to check if we are still busy for something else */
469 1.38 reinoud if ((error = vflush(ump->vfs_mountp, NULLVP, flags | SKIPSYSTEM)) != 0)
470 1.38 reinoud return error;
471 1.38 reinoud
472 1.38 reinoud DPRINTF(VOLUMES, ("flush OK on unmount\n"));
473 1.1 reinoud
474 1.38 reinoud /* close logical volume and close session if requested */
475 1.38 reinoud if ((error = udf_close_logvol(ump, mntflags)) != 0)
476 1.38 reinoud return error;
477 1.38 reinoud
478 1.38 reinoud #ifdef DEBUG
479 1.38 reinoud DPRINTF(VOLUMES, ("FINAL sanity check\n"));
480 1.38 reinoud if (udf_verbose & UDF_DEBUG_LOCKING)
481 1.38 reinoud udf_unmount_sanity_check(mp);
482 1.38 reinoud #endif
483 1.38 reinoud
484 1.38 reinoud /* NOTE release system nodes should NOT write anything */
485 1.38 reinoud udf_release_system_nodes(mp);
486 1.38 reinoud
487 1.38 reinoud /* finalise disc strategy */
488 1.38 reinoud udf_discstrat_finish(ump);
489 1.38 reinoud
490 1.38 reinoud /* synchronise device caches */
491 1.38 reinoud (void) udf_synchronise_caches(ump);
492 1.1 reinoud
493 1.1 reinoud /* close device */
494 1.1 reinoud DPRINTF(VOLUMES, ("closing device\n"));
495 1.1 reinoud if (mp->mnt_flag & MNT_RDONLY) {
496 1.1 reinoud closeflags = FREAD;
497 1.1 reinoud } else {
498 1.1 reinoud closeflags = FREAD | FWRITE;
499 1.6 christos }
500 1.1 reinoud
501 1.1 reinoud /* devvp is still locked by us */
502 1.1 reinoud vn_lock(ump->devvp, LK_EXCLUSIVE | LK_RETRY);
503 1.31 pooka error = VOP_CLOSE(ump->devvp, closeflags, NOCRED);
504 1.1 reinoud if (error)
505 1.1 reinoud printf("Error during closure of device! error %d, "
506 1.1 reinoud "device might stay locked\n", error);
507 1.1 reinoud DPRINTF(VOLUMES, ("device close ok\n"));
508 1.1 reinoud
509 1.1 reinoud /* clear our mount reference and release device node */
510 1.1 reinoud ump->devvp->v_specmountpoint = NULL;
511 1.1 reinoud vput(ump->devvp);
512 1.1 reinoud
513 1.38 reinoud /* free our ump */
514 1.15 reinoud free_udf_mountinfo(mp);
515 1.15 reinoud
516 1.38 reinoud /* free ump struct references */
517 1.1 reinoud mp->mnt_data = NULL;
518 1.1 reinoud mp->mnt_flag &= ~MNT_LOCAL;
519 1.1 reinoud
520 1.1 reinoud DPRINTF(VOLUMES, ("Fin unmount\n"));
521 1.1 reinoud return error;
522 1.1 reinoud }
523 1.1 reinoud
524 1.1 reinoud /* --------------------------------------------------------------------- */
525 1.1 reinoud
526 1.1 reinoud /*
527 1.1 reinoud * Helper function of udf_mount() that actually mounts the disc.
528 1.1 reinoud */
529 1.1 reinoud
530 1.1 reinoud static int
531 1.1 reinoud udf_mountfs(struct vnode *devvp, struct mount *mp,
532 1.1 reinoud struct lwp *l, struct udf_args *args)
533 1.1 reinoud {
534 1.1 reinoud struct udf_mount *ump;
535 1.1 reinoud uint32_t sector_size, lb_size, bshift;
536 1.38 reinoud uint32_t logvol_integrity;
537 1.1 reinoud int num_anchors, error, lst;
538 1.1 reinoud
539 1.1 reinoud /* flush out any old buffers remaining from a previous use. */
540 1.9 reinoud if ((error = vinvalbuf(devvp, V_SAVE, l->l_cred, l, 0, 0)))
541 1.1 reinoud return error;
542 1.1 reinoud
543 1.38 reinoud /* setup basic mount information */
544 1.38 reinoud mp->mnt_data = NULL;
545 1.38 reinoud mp->mnt_stat.f_fsidx.__fsid_val[0] = (uint32_t) devvp->v_rdev;
546 1.38 reinoud mp->mnt_stat.f_fsidx.__fsid_val[1] = makefstype(MOUNT_UDF);
547 1.38 reinoud mp->mnt_stat.f_fsid = mp->mnt_stat.f_fsidx.__fsid_val[0];
548 1.38 reinoud mp->mnt_stat.f_namemax = UDF_MAX_NAMELEN;
549 1.38 reinoud mp->mnt_flag |= MNT_LOCAL;
550 1.38 reinoud
551 1.24 msaitoh /* allocate udf part of mount structure; malloc always succeeds */
552 1.30 ad ump = malloc(sizeof(struct udf_mount), M_UDFMNT, M_WAITOK | M_ZERO);
553 1.1 reinoud
554 1.1 reinoud /* init locks */
555 1.38 reinoud mutex_init(&ump->logvol_mutex, MUTEX_DEFAULT, IPL_NONE);
556 1.30 ad mutex_init(&ump->ihash_lock, MUTEX_DEFAULT, IPL_NONE);
557 1.30 ad mutex_init(&ump->get_node_lock, MUTEX_DEFAULT, IPL_NONE);
558 1.38 reinoud mutex_init(&ump->allocate_mutex, MUTEX_DEFAULT, IPL_NONE);
559 1.38 reinoud cv_init(&ump->dirtynodes_cv, "udfsync2");
560 1.1 reinoud
561 1.38 reinoud /* init `ino_t' to udf_node hash table and other lists */
562 1.1 reinoud for (lst = 0; lst < UDF_INODE_HASHSIZE; lst++) {
563 1.1 reinoud LIST_INIT(&ump->udf_nodes[lst]);
564 1.6 christos }
565 1.1 reinoud
566 1.1 reinoud /* set up linkage */
567 1.1 reinoud mp->mnt_data = ump;
568 1.1 reinoud ump->vfs_mountp = mp;
569 1.1 reinoud
570 1.1 reinoud /* set up arguments and device */
571 1.1 reinoud ump->mount_args = *args;
572 1.1 reinoud ump->devvp = devvp;
573 1.9 reinoud if ((error = udf_update_discinfo(ump))) {
574 1.1 reinoud printf("UDF mount: error inspecting fs node\n");
575 1.1 reinoud return error;
576 1.6 christos }
577 1.1 reinoud
578 1.1 reinoud /* inspect sector size */
579 1.1 reinoud sector_size = ump->discinfo.sector_size;
580 1.1 reinoud bshift = 1;
581 1.1 reinoud while ((1 << bshift) < sector_size)
582 1.1 reinoud bshift++;
583 1.1 reinoud if ((1 << bshift) != sector_size) {
584 1.1 reinoud printf("UDF mount: "
585 1.1 reinoud "hit NetBSD implementation fence on sector size\n");
586 1.1 reinoud return EIO;
587 1.6 christos }
588 1.1 reinoud
589 1.38 reinoud /*
590 1.38 reinoud * Inspect if we're asked to mount read-write on a non recordable or
591 1.38 reinoud * closed sequential disc.
592 1.38 reinoud */
593 1.38 reinoud if ((mp->mnt_flag & MNT_RDONLY) == 0) {
594 1.38 reinoud if ((ump->discinfo.mmc_cur & MMC_CAP_RECORDABLE) == 0) {
595 1.38 reinoud printf("UDF mount: disc is not recordable\n");
596 1.38 reinoud return EROFS;
597 1.38 reinoud }
598 1.38 reinoud /*
599 1.38 reinoud * TODO if on sequential media and last session is closed,
600 1.38 reinoud * check for enough space to open/close new session
601 1.38 reinoud */
602 1.38 reinoud }
603 1.38 reinoud
604 1.38 reinoud /* initialise bootstrap disc strategy */
605 1.38 reinoud ump->strategy = &udf_strat_bootstrap;
606 1.38 reinoud udf_discstrat_init(ump);
607 1.38 reinoud
608 1.1 reinoud /* read all anchors to get volume descriptor sequence */
609 1.38 reinoud num_anchors = udf_read_anchors(ump);
610 1.1 reinoud if (num_anchors == 0)
611 1.38 reinoud return EINVAL;
612 1.1 reinoud
613 1.1 reinoud DPRINTF(VOLUMES, ("Read %d anchors on this disc, session %d\n",
614 1.1 reinoud num_anchors, args->sessionnr));
615 1.1 reinoud
616 1.1 reinoud /* read in volume descriptor sequence */
617 1.9 reinoud if ((error = udf_read_vds_space(ump))) {
618 1.1 reinoud printf("UDF mount: error reading volume space\n");
619 1.9 reinoud return error;
620 1.9 reinoud }
621 1.1 reinoud
622 1.38 reinoud /* close down (direct) disc strategy */
623 1.38 reinoud udf_discstrat_finish(ump);
624 1.38 reinoud
625 1.1 reinoud /* check consistency and completeness */
626 1.38 reinoud if ((error = udf_process_vds(ump))) {
627 1.19 reinoud printf( "UDF mount: disc not properly formatted"
628 1.19 reinoud "(bad VDS)\n");
629 1.9 reinoud return error;
630 1.6 christos }
631 1.1 reinoud
632 1.38 reinoud /* switch to new disc strategy */
633 1.38 reinoud KASSERT(ump->strategy != &udf_strat_bootstrap);
634 1.38 reinoud udf_discstrat_init(ump);
635 1.38 reinoud
636 1.38 reinoud /* initialise late allocation administration space */
637 1.38 reinoud ump->la_lmapping = malloc(sizeof(uint64_t) * UDF_MAX_MAPPINGS,
638 1.38 reinoud M_TEMP, M_WAITOK);
639 1.38 reinoud ump->la_pmapping = malloc(sizeof(uint64_t) * UDF_MAX_MAPPINGS,
640 1.38 reinoud M_TEMP, M_WAITOK);
641 1.38 reinoud
642 1.38 reinoud /* setup node cleanup extents copy space */
643 1.1 reinoud lb_size = udf_rw32(ump->logical_vol->lb_size);
644 1.38 reinoud ump->la_node_ad_cpy = malloc(lb_size * UDF_MAX_ALLOC_EXTENTS,
645 1.38 reinoud M_UDFMNT, M_WAITOK);
646 1.38 reinoud memset(ump->la_node_ad_cpy, 0, lb_size * UDF_MAX_ALLOC_EXTENTS);
647 1.38 reinoud
648 1.38 reinoud /* setup rest of mount information */
649 1.38 reinoud mp->mnt_data = ump;
650 1.38 reinoud
651 1.38 reinoud /* bshift is allways equal to disc sector size */
652 1.38 reinoud mp->mnt_dev_bshift = bshift;
653 1.38 reinoud mp->mnt_fs_bshift = bshift;
654 1.1 reinoud
655 1.38 reinoud /* note that the mp info needs to be initialised for reading! */
656 1.1 reinoud /* read vds support tables like VAT, sparable etc. */
657 1.38 reinoud if ((error = udf_read_vds_tables(ump))) {
658 1.19 reinoud printf( "UDF mount: error in format or damaged disc "
659 1.19 reinoud "(VDS tables failing)\n");
660 1.9 reinoud return error;
661 1.6 christos }
662 1.9 reinoud
663 1.38 reinoud /* check if volume integrity is closed otherwise its dirty */
664 1.38 reinoud logvol_integrity = udf_rw32(ump->logvol_integrity->integrity_type);
665 1.38 reinoud if (logvol_integrity != UDF_INTEGRITY_CLOSED) {
666 1.38 reinoud printf("UDF mount: file system is not clean; ");
667 1.38 reinoud printf("please fsck(8)\n");
668 1.38 reinoud return EPERM;
669 1.38 reinoud }
670 1.38 reinoud
671 1.38 reinoud /* read root directory */
672 1.38 reinoud if ((error = udf_read_rootdirs(ump))) {
673 1.19 reinoud printf( "UDF mount: "
674 1.19 reinoud "disc not properly formatted or damaged disc "
675 1.19 reinoud "(rootdirs failing)\n");
676 1.1 reinoud return error;
677 1.9 reinoud }
678 1.1 reinoud
679 1.1 reinoud /* do we have to set this? */
680 1.1 reinoud devvp->v_specmountpoint = mp;
681 1.1 reinoud
682 1.1 reinoud /* success! */
683 1.1 reinoud return 0;
684 1.1 reinoud }
685 1.1 reinoud
686 1.1 reinoud /* --------------------------------------------------------------------- */
687 1.1 reinoud
688 1.1 reinoud int
689 1.31 pooka udf_start(struct mount *mp, int flags)
690 1.1 reinoud {
691 1.1 reinoud /* do we have to do something here? */
692 1.1 reinoud return 0;
693 1.1 reinoud }
694 1.1 reinoud
695 1.1 reinoud /* --------------------------------------------------------------------- */
696 1.1 reinoud
697 1.1 reinoud int
698 1.1 reinoud udf_root(struct mount *mp, struct vnode **vpp)
699 1.1 reinoud {
700 1.1 reinoud struct vnode *vp;
701 1.1 reinoud struct long_ad *dir_loc;
702 1.1 reinoud struct udf_mount *ump = VFSTOUDF(mp);
703 1.1 reinoud struct udf_node *root_dir;
704 1.1 reinoud int error;
705 1.1 reinoud
706 1.1 reinoud DPRINTF(CALL, ("udf_root called\n"));
707 1.1 reinoud
708 1.1 reinoud dir_loc = &ump->fileset_desc->rootdir_icb;
709 1.1 reinoud error = udf_get_node(ump, dir_loc, &root_dir);
710 1.1 reinoud
711 1.1 reinoud if (!root_dir)
712 1.1 reinoud error = ENOENT;
713 1.1 reinoud if (error)
714 1.1 reinoud return error;
715 1.1 reinoud
716 1.1 reinoud vp = root_dir->vnode;
717 1.30 ad root_dir->vnode->v_vflag |= VV_ROOT;
718 1.1 reinoud
719 1.1 reinoud *vpp = vp;
720 1.1 reinoud return 0;
721 1.1 reinoud }
722 1.1 reinoud
723 1.1 reinoud /* --------------------------------------------------------------------- */
724 1.1 reinoud
725 1.1 reinoud int
726 1.31 pooka udf_statvfs(struct mount *mp, struct statvfs *sbp)
727 1.1 reinoud {
728 1.1 reinoud struct udf_mount *ump = VFSTOUDF(mp);
729 1.1 reinoud struct logvol_int_desc *lvid;
730 1.1 reinoud struct udf_logvol_info *impl;
731 1.1 reinoud uint64_t freeblks, sizeblks;
732 1.1 reinoud uint32_t *pos1, *pos2;
733 1.1 reinoud int part, num_part;
734 1.1 reinoud
735 1.1 reinoud DPRINTF(CALL, ("udf_statvfs called\n"));
736 1.1 reinoud sbp->f_flag = mp->mnt_flag;
737 1.1 reinoud sbp->f_bsize = ump->discinfo.sector_size;
738 1.1 reinoud sbp->f_frsize = ump->discinfo.sector_size;
739 1.1 reinoud sbp->f_iosize = ump->discinfo.sector_size;
740 1.1 reinoud
741 1.38 reinoud mutex_enter(&ump->allocate_mutex);
742 1.1 reinoud lvid = ump->logvol_integrity;
743 1.38 reinoud freeblks = sizeblks = 0;
744 1.1 reinoud
745 1.38 reinoud /* Sequentials report free space directly (CD/DVD/BD-R) */
746 1.38 reinoud KASSERT(lvid);
747 1.38 reinoud num_part = udf_rw32(lvid->num_part);
748 1.38 reinoud impl = (struct udf_logvol_info *) (lvid->tables + 2*num_part);
749 1.38 reinoud
750 1.38 reinoud if (ump->discinfo.mmc_cur & MMC_CAP_SEQUENTIAL) {
751 1.38 reinoud /* XXX assumption at most two tracks open */
752 1.38 reinoud freeblks = ump->data_track.free_blocks;
753 1.38 reinoud if (ump->data_track.tracknr != ump->metadata_track.tracknr)
754 1.38 reinoud freeblks += ump->metadata_track.free_blocks;
755 1.38 reinoud sizeblks = ump->discinfo.last_possible_lba;
756 1.38 reinoud } else {
757 1.38 reinoud /* free and used space for mountpoint based on logvol integrity */
758 1.1 reinoud for (part=0; part < num_part; part++) {
759 1.1 reinoud pos1 = &lvid->tables[0] + part;
760 1.1 reinoud pos2 = &lvid->tables[0] + num_part + part;
761 1.1 reinoud if (udf_rw32(*pos1) != (uint32_t) -1) {
762 1.1 reinoud freeblks += udf_rw32(*pos1);
763 1.1 reinoud sizeblks += udf_rw32(*pos2);
764 1.6 christos }
765 1.6 christos }
766 1.38 reinoud }
767 1.38 reinoud freeblks -= ump->uncomitted_lb;
768 1.38 reinoud
769 1.38 reinoud sbp->f_blocks = sizeblks;
770 1.38 reinoud sbp->f_bfree = freeblks;
771 1.38 reinoud sbp->f_files = 0;
772 1.38 reinoud if (impl) {
773 1.1 reinoud sbp->f_files = udf_rw32(impl->num_files);
774 1.1 reinoud sbp->f_files += udf_rw32(impl->num_directories);
775 1.38 reinoud }
776 1.38 reinoud
777 1.38 reinoud /* XXX read only for now XXX */
778 1.38 reinoud sbp->f_bavail = 0;
779 1.38 reinoud sbp->f_bresvd = 0;
780 1.38 reinoud
781 1.38 reinoud /* tricky, next only aplies to ffs i think, so set to zero */
782 1.38 reinoud sbp->f_ffree = 0;
783 1.38 reinoud sbp->f_favail = 0;
784 1.38 reinoud sbp->f_fresvd = 0;
785 1.1 reinoud
786 1.38 reinoud mutex_exit(&ump->allocate_mutex);
787 1.1 reinoud
788 1.1 reinoud copy_statvfs_info(sbp, mp);
789 1.1 reinoud return 0;
790 1.1 reinoud }
791 1.1 reinoud
792 1.1 reinoud /* --------------------------------------------------------------------- */
793 1.1 reinoud
794 1.38 reinoud /*
795 1.38 reinoud * TODO what about writing out free space maps, lvid etc? only on `waitfor'
796 1.38 reinoud * i.e. explicit syncing by the user?
797 1.38 reinoud */
798 1.38 reinoud
799 1.1 reinoud int
800 1.38 reinoud udf_sync(struct mount *mp, int waitfor, kauth_cred_t cred)
801 1.1 reinoud {
802 1.38 reinoud struct udf_mount *ump = VFSTOUDF(mp);
803 1.38 reinoud int error;
804 1.38 reinoud
805 1.1 reinoud DPRINTF(CALL, ("udf_sync called\n"));
806 1.38 reinoud /* if called when mounted readonly, just ignore */
807 1.38 reinoud if (mp->mnt_flag & MNT_RDONLY)
808 1.38 reinoud return 0;
809 1.38 reinoud
810 1.38 reinoud if (ump->syncing && !waitfor) {
811 1.38 reinoud printf("UDF: skipping autosync\n");
812 1.38 reinoud return 0;
813 1.38 reinoud }
814 1.38 reinoud
815 1.38 reinoud /* get sync lock */
816 1.38 reinoud ump->syncing = 1;
817 1.38 reinoud
818 1.38 reinoud udf_do_sync(ump, cred, waitfor);
819 1.38 reinoud
820 1.38 reinoud if (waitfor == MNT_WAIT) {
821 1.38 reinoud /* XXX lock for VAT en bitmaps? */
822 1.38 reinoud /* metadata nodes are written synchronous */
823 1.38 reinoud DPRINTF(CALL, ("udf_sync: syncing metadata\n"));
824 1.38 reinoud if (ump->lvclose & UDF_WRITE_VAT)
825 1.38 reinoud udf_writeout_vat(ump);
826 1.38 reinoud if (ump->lvclose & UDF_WRITE_PART_BITMAPS) {
827 1.38 reinoud error = udf_write_partition_spacetables(ump, waitfor);
828 1.38 reinoud if (error) {
829 1.38 reinoud printf( "udf_close_logvol: writeout of space "
830 1.38 reinoud "tables failed\n");
831 1.38 reinoud }
832 1.38 reinoud ump->lvclose &= ~UDF_WRITE_PART_BITMAPS;
833 1.38 reinoud }
834 1.38 reinoud
835 1.38 reinoud }
836 1.38 reinoud DPRINTF(CALL, ("end of udf_sync()\n"));
837 1.38 reinoud ump->syncing = 0;
838 1.38 reinoud
839 1.1 reinoud return 0;
840 1.1 reinoud }
841 1.1 reinoud
842 1.1 reinoud /* --------------------------------------------------------------------- */
843 1.1 reinoud
844 1.1 reinoud /*
845 1.1 reinoud * Get vnode for the file system type specific file id ino for the fs. Its
846 1.1 reinoud * used for reference to files by unique ID and for NFSv3.
847 1.1 reinoud * (optional) TODO lookup why some sources state NFSv3
848 1.1 reinoud */
849 1.1 reinoud int
850 1.18 christos udf_vget(struct mount *mp, ino_t ino,
851 1.18 christos struct vnode **vpp)
852 1.1 reinoud {
853 1.1 reinoud DPRINTF(NOTIMPL, ("udf_vget called\n"));
854 1.1 reinoud return EOPNOTSUPP;
855 1.1 reinoud }
856 1.1 reinoud
857 1.1 reinoud /* --------------------------------------------------------------------- */
858 1.1 reinoud
859 1.1 reinoud /*
860 1.1 reinoud * Lookup vnode for file handle specified
861 1.1 reinoud */
862 1.1 reinoud int
863 1.18 christos udf_fhtovp(struct mount *mp, struct fid *fhp,
864 1.18 christos struct vnode **vpp)
865 1.1 reinoud {
866 1.1 reinoud DPRINTF(NOTIMPL, ("udf_fhtovp called\n"));
867 1.1 reinoud return EOPNOTSUPP;
868 1.1 reinoud }
869 1.1 reinoud
870 1.1 reinoud /* --------------------------------------------------------------------- */
871 1.1 reinoud
872 1.1 reinoud /*
873 1.1 reinoud * Create an unique file handle. Its structure is opaque and won't be used by
874 1.1 reinoud * other subsystems. It should uniquely identify the file in the filingsystem
875 1.1 reinoud * and enough information to know if a file has been removed and/or resources
876 1.1 reinoud * have been recycled.
877 1.1 reinoud */
878 1.1 reinoud int
879 1.18 christos udf_vptofh(struct vnode *vp, struct fid *fid,
880 1.18 christos size_t *fh_size)
881 1.1 reinoud {
882 1.1 reinoud DPRINTF(NOTIMPL, ("udf_vptofh called\n"));
883 1.1 reinoud return EOPNOTSUPP;
884 1.1 reinoud }
885 1.1 reinoud
886 1.1 reinoud /* --------------------------------------------------------------------- */
887 1.1 reinoud
888 1.1 reinoud /*
889 1.1 reinoud * Create a filingsystem snapshot at the specified timestamp. Could be
890 1.1 reinoud * implemented by explicitly creating a new session or with spare room in the
891 1.1 reinoud * integrity descriptor space
892 1.1 reinoud */
893 1.1 reinoud int
894 1.18 christos udf_snapshot(struct mount *mp, struct vnode *vp,
895 1.18 christos struct timespec *tm)
896 1.1 reinoud {
897 1.1 reinoud DPRINTF(NOTIMPL, ("udf_snapshot called\n"));
898 1.1 reinoud return EOPNOTSUPP;
899 1.1 reinoud }
900 1.14 reinoud
901 1.14 reinoud /* --------------------------------------------------------------------- */
902 1.14 reinoud
903 1.14 reinoud /*
904 1.14 reinoud * If running a DEBUG kernel, provide an easy way to set the debug flags when
905 1.14 reinoud * running into a problem.
906 1.14 reinoud */
907 1.14 reinoud
908 1.14 reinoud #ifdef DEBUG
909 1.14 reinoud #define UDF_VERBOSE_SYSCTLOPT 1
910 1.14 reinoud
911 1.14 reinoud SYSCTL_SETUP(sysctl_vfs_udf_setup, "sysctl vfs.udf subtree setup")
912 1.14 reinoud {
913 1.14 reinoud /*
914 1.14 reinoud * XXX the "24" below could be dynamic, thereby eliminating one
915 1.14 reinoud * more instance of the "number to vfs" mapping problem, but
916 1.14 reinoud * "24" is the order as taken from sys/mount.h
917 1.14 reinoud */
918 1.14 reinoud
919 1.14 reinoud sysctl_createv(clog, 0, NULL, NULL,
920 1.14 reinoud CTLFLAG_PERMANENT,
921 1.14 reinoud CTLTYPE_NODE, "vfs", NULL,
922 1.14 reinoud NULL, 0, NULL, 0,
923 1.14 reinoud CTL_VFS, CTL_EOL);
924 1.14 reinoud sysctl_createv(clog, 0, NULL, NULL,
925 1.14 reinoud CTLFLAG_PERMANENT,
926 1.14 reinoud CTLTYPE_NODE, "udf",
927 1.14 reinoud SYSCTL_DESCR("OSTA Universal File System"),
928 1.14 reinoud NULL, 0, NULL, 0,
929 1.14 reinoud CTL_VFS, 24, CTL_EOL);
930 1.14 reinoud
931 1.14 reinoud sysctl_createv(clog, 0, NULL, NULL,
932 1.14 reinoud CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
933 1.14 reinoud CTLTYPE_INT, "verbose",
934 1.14 reinoud SYSCTL_DESCR("Bitmask for filesystem debugging"),
935 1.14 reinoud NULL, 0, &udf_verbose, 0,
936 1.14 reinoud CTL_VFS, 24, UDF_VERBOSE_SYSCTLOPT, CTL_EOL);
937 1.14 reinoud }
938 1.14 reinoud
939 1.14 reinoud #endif /* DEBUG */
940 1.14 reinoud
941