udf_vfsops.c revision 1.25 1 /* $NetBSD: udf_vfsops.c,v 1.25 2007/06/30 09:37:57 pooka Exp $ */
2
3 /*
4 * Copyright (c) 2006 Reinoud Zandijk
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed for the
18 * NetBSD Project. See http://www.NetBSD.org/ for
19 * information about NetBSD.
20 * 4. The name of the author may not be used to endorse or promote products
21 * derived from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 */
35
36
37 #include <sys/cdefs.h>
38 #ifndef lint
39 __RCSID("$NetBSD: udf_vfsops.c,v 1.25 2007/06/30 09:37:57 pooka Exp $");
40 #endif /* not lint */
41
42
43 #if defined(_KERNEL_OPT)
44 #include "opt_quota.h"
45 #include "opt_compat_netbsd.h"
46 #endif
47
48 #include <sys/param.h>
49 #include <sys/systm.h>
50 #include <sys/sysctl.h>
51 #include <sys/namei.h>
52 #include <sys/proc.h>
53 #include <sys/kernel.h>
54 #include <sys/vnode.h>
55 #include <miscfs/specfs/specdev.h>
56 #include <sys/mount.h>
57 #include <sys/buf.h>
58 #include <sys/file.h>
59 #include <sys/device.h>
60 #include <sys/disklabel.h>
61 #include <sys/ioctl.h>
62 #include <sys/malloc.h>
63 #include <sys/dirent.h>
64 #include <sys/stat.h>
65 #include <sys/conf.h>
66 #include <sys/kauth.h>
67
68 #include <fs/udf/ecma167-udf.h>
69 #include <fs/udf/udf_mount.h>
70
71 #include "udf.h"
72 #include "udf_subr.h"
73 #include "udf_bswap.h"
74
75
76 /* verbose levels of the udf filingsystem */
77 int udf_verbose = UDF_DEBUGGING;
78
79 /* malloc regions */
80 MALLOC_JUSTDEFINE(M_UDFMNT, "UDF mount", "UDF mount structures");
81 MALLOC_JUSTDEFINE(M_UDFVOLD, "UDF volspace", "UDF volume space descriptors");
82 MALLOC_JUSTDEFINE(M_UDFTEMP, "UDF temp", "UDF scrap space");
83 struct pool udf_node_pool;
84
85 /* supported functions predefined */
86 int udf_mountroot(void);
87 int udf_mount(struct mount *, const char *, void *, struct nameidata *, struct lwp *);
88 int udf_start(struct mount *, int, struct lwp *);
89 int udf_unmount(struct mount *, int, struct lwp *);
90 int udf_root(struct mount *, struct vnode **);
91 int udf_quotactl(struct mount *, int, uid_t, void *, struct lwp *);
92 int udf_statvfs(struct mount *, struct statvfs *, struct lwp *);
93 int udf_sync(struct mount *, int, kauth_cred_t, struct lwp *);
94 int udf_vget(struct mount *, ino_t, struct vnode **);
95 int udf_fhtovp(struct mount *, struct fid *, struct vnode **);
96 int udf_checkexp(struct mount *, struct mbuf *, int *, kauth_cred_t *);
97 int udf_vptofh(struct vnode *, struct fid *, size_t *);
98 int udf_snapshot(struct mount *, struct vnode *, struct timespec *);
99
100 void udf_init(void);
101 void udf_reinit(void);
102 void udf_done(void);
103
104
105 /* internal functions */
106 static int udf_mountfs(struct vnode *, struct mount *, struct lwp *, struct udf_args *);
107 #if 0
108 static int update_mp(struct mount *, struct udf_args *);
109 #endif
110
111
112 /* handies */
113 #define VFSTOUDF(mp) ((struct udf_mount *)mp->mnt_data)
114
115
116 /* --------------------------------------------------------------------- */
117
118 /* predefine vnode-op list descriptor */
119 extern const struct vnodeopv_desc udf_vnodeop_opv_desc;
120
121 const struct vnodeopv_desc * const udf_vnodeopv_descs[] = {
122 &udf_vnodeop_opv_desc,
123 NULL,
124 };
125
126
127 /* vfsops descriptor linked in as anchor point for the filingsystem */
128 struct vfsops udf_vfsops = {
129 MOUNT_UDF, /* vfs_name */
130 udf_mount,
131 udf_start,
132 udf_unmount,
133 udf_root,
134 udf_quotactl,
135 udf_statvfs,
136 udf_sync,
137 udf_vget,
138 udf_fhtovp,
139 udf_vptofh,
140 udf_init,
141 udf_reinit,
142 udf_done,
143 udf_mountroot,
144 udf_snapshot,
145 vfs_stdextattrctl,
146 vfs_stdsuspendctl,
147 udf_vnodeopv_descs,
148 0, /* int vfs_refcount */
149 { NULL, NULL, }, /* LIST_ENTRY(vfsops) */
150 };
151 VFS_ATTACH(udf_vfsops);
152
153
154 /* --------------------------------------------------------------------- */
155
156 /* file system starts here */
157 void
158 udf_init(void)
159 {
160 size_t size;
161
162 malloc_type_attach(M_UDFMNT);
163 malloc_type_attach(M_UDFVOLD);
164 malloc_type_attach(M_UDFTEMP);
165
166 /* init hashtables and pools */
167 size = sizeof(struct udf_node);
168 pool_init(&udf_node_pool, size, 0, 0, 0, "udf_node_pool", NULL,
169 IPL_NONE);
170 }
171
172 /* --------------------------------------------------------------------- */
173
174 void
175 udf_reinit(void)
176 {
177 /* recreate hashtables */
178 /* reinit pool? */
179 }
180
181 /* --------------------------------------------------------------------- */
182
183 void
184 udf_done(void)
185 {
186 /* remove hashtables and pools */
187 pool_destroy(&udf_node_pool);
188
189 malloc_type_detach(M_UDFMNT);
190 malloc_type_detach(M_UDFVOLD);
191 malloc_type_detach(M_UDFTEMP);
192 }
193
194 /* --------------------------------------------------------------------- */
195
196 int
197 udf_mountroot(void)
198 {
199 return EOPNOTSUPP;
200 }
201
202 /* --------------------------------------------------------------------- */
203
204 #define MPFREE(a, lst) \
205 if ((a)) free((a), lst);
206 static void
207 free_udf_mountinfo(struct mount *mp)
208 {
209 struct udf_mount *ump;
210 int i;
211
212 if (!mp)
213 return;
214
215 ump = VFSTOUDF(mp);
216 if (ump) {
217 /* dereference all system nodes */
218 if (ump->metadata_file)
219 vrele(ump->metadata_file->vnode);
220 if (ump->metadatamirror_file)
221 vrele(ump->metadatamirror_file->vnode);
222 if (ump->metadatabitmap_file)
223 vrele(ump->metadatabitmap_file->vnode);
224
225 /* vflush all (system) nodes if any */
226 (void) vflush(mp, NULLVP, FORCECLOSE);
227
228 /* dispose of our descriptor pool */
229 if (ump->desc_pool) {
230 pool_destroy(ump->desc_pool);
231 free(ump->desc_pool, M_UDFMNT);
232 }
233
234 /* clear our data */
235 for (i = 0; i < UDF_ANCHORS; i++)
236 MPFREE(ump->anchors[i], M_UDFVOLD);
237 MPFREE(ump->primary_vol, M_UDFVOLD);
238 MPFREE(ump->logical_vol, M_UDFVOLD);
239 MPFREE(ump->unallocated, M_UDFVOLD);
240 MPFREE(ump->implementation, M_UDFVOLD);
241 MPFREE(ump->logvol_integrity, M_UDFVOLD);
242 for (i = 0; i < UDF_PARTITIONS; i++)
243 MPFREE(ump->partitions[i], M_UDFVOLD);
244 MPFREE(ump->fileset_desc, M_UDFVOLD);
245 MPFREE(ump->vat_table, M_UDFVOLD);
246 MPFREE(ump->sparing_table, M_UDFVOLD);
247
248 free(ump, M_UDFMNT);
249 }
250 }
251 #undef MPFREE
252
253 /* --------------------------------------------------------------------- */
254
255 int
256 udf_mount(struct mount *mp, const char *path,
257 void *data, struct nameidata *ndp, struct lwp *l)
258 {
259 struct udf_args args;
260 struct udf_mount *ump;
261 struct vnode *devvp;
262 int openflags, accessmode, error;
263
264 DPRINTF(CALL, ("udf_mount called\n"));
265
266 if (mp->mnt_flag & MNT_GETARGS) {
267 /* request for the mount arguments */
268 ump = VFSTOUDF(mp);
269 if (ump == NULL)
270 return EINVAL;
271 return copyout(&ump->mount_args, data, sizeof(args));
272 }
273
274 /* handle request for updating mount parameters */
275 /* TODO can't update my mountpoint yet */
276 if (mp->mnt_flag & MNT_UPDATE) {
277 return EOPNOTSUPP;
278 }
279
280 /* OK, so we are asked to mount the device */
281 error = copyin(data, &args, sizeof(struct udf_args));
282 if (error)
283 return error;
284
285 /* check/translate struct version */
286 /* TODO sanity checking other mount arguments */
287 if (args.version != 1) {
288 printf("mount_udf: unrecognized argument structure version\n");
289 return EINVAL;
290 }
291
292 /* lookup name to get its vnode */
293 NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, l);
294 error = namei(ndp);
295 if (error)
296 return error;
297 devvp = ndp->ni_vp;
298
299 #ifdef DEBUG
300 if (udf_verbose & UDF_DEBUG_VOLUMES)
301 vprint("UDF mount, trying to mount \n", devvp);
302 #endif
303
304 /* check if its a block device specified */
305 if (devvp->v_type != VBLK) {
306 vrele(devvp);
307 return ENOTBLK;
308 }
309 if (bdevsw_lookup(devvp->v_rdev) == NULL) {
310 vrele(devvp);
311 return ENXIO;
312 }
313
314 /* force read-only for now */
315 mp->mnt_flag |= MNT_RDONLY;
316
317 /*
318 * If mount by non-root, then verify that user has necessary
319 * permissions on the device.
320 */
321 if (kauth_authorize_generic(l->l_cred, KAUTH_GENERIC_ISSUSER, NULL)) {
322 accessmode = VREAD;
323 if ((mp->mnt_flag & MNT_RDONLY) == 0)
324 accessmode |= VWRITE;
325 vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
326 error = VOP_ACCESS(devvp, accessmode, l->l_cred, l);
327 VOP_UNLOCK(devvp, 0);
328 if (error) {
329 vrele(devvp);
330 return error;
331 }
332 }
333
334 /*
335 * Disallow multiple mounts of the same device. Disallow mounting of
336 * a device that is currently in use (except for root, which might
337 * share swap device for miniroot).
338 */
339 error = vfs_mountedon(devvp);
340 if (error) {
341 vrele(devvp);
342 return error;
343 }
344 if ((vcount(devvp) > 1) && (devvp != rootvp)) {
345 vrele(devvp);
346 return EBUSY;
347 }
348
349 /*
350 * Open device and try to mount it!
351 */
352 if (mp->mnt_flag & MNT_RDONLY) {
353 openflags = FREAD;
354 } else {
355 openflags = FREAD | FWRITE;
356 }
357 error = VOP_OPEN(devvp, openflags, FSCRED, l);
358 if (error == 0) {
359 /* opened ok, try mounting */
360 error = udf_mountfs(devvp, mp, l, &args);
361 if (error) {
362 free_udf_mountinfo(mp);
363 vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
364 (void) VOP_CLOSE(devvp, openflags, NOCRED, l);
365 VOP_UNLOCK(devvp, 0);
366 }
367 }
368 if (error) {
369 /* devvp is still locked */
370 vrele(devvp);
371 return error;
372 }
373
374 /* register our mountpoint being on this device */
375 devvp->v_specmountpoint = mp;
376
377 /* successfully mounted */
378 DPRINTF(VOLUMES, ("udf_mount() successfull\n"));
379
380 return set_statvfs_info(path, UIO_USERSPACE, args.fspec, UIO_USERSPACE,
381 mp, l);
382 }
383
384 /* --------------------------------------------------------------------- */
385
386 #ifdef DEBUG
387 static void
388 udf_unmount_sanity_check(struct mount *mp)
389 {
390 struct vnode *vp;
391
392 printf("On unmount, i found the following nodes:\n");
393 TAILQ_FOREACH(vp, &mp->mnt_vnodelist, v_mntvnodes) {
394 vprint("", vp);
395 if (VOP_ISLOCKED(vp) == LK_EXCLUSIVE) {
396 printf(" is locked\n");
397 }
398 if (vp->v_usecount > 1)
399 printf(" more than one usecount %d\n", vp->v_usecount);
400 }
401 }
402 #endif
403
404
405 int
406 udf_unmount(struct mount *mp, int mntflags, struct lwp *l)
407 {
408 struct udf_mount *ump;
409 int error, flags, closeflags;
410
411 DPRINTF(CALL, ("udf_umount called\n"));
412
413 ump = VFSTOUDF(mp);
414 if (!ump)
415 panic("UDF unmount: empty ump\n");
416
417 flags = (mntflags & MNT_FORCE) ? FORCECLOSE : 0;
418 /* TODO remove these paranoid functions */
419 #ifdef DEBUG
420 if (udf_verbose & UDF_DEBUG_LOCKING)
421 udf_unmount_sanity_check(mp);
422 #endif
423
424 /*
425 * By specifying SKIPSYSTEM we can skip vnodes marked with VSYSTEM.
426 * This hardly documented feature allows us to exempt certain files
427 * from being flushed.
428 */
429 if ((error = vflush(mp, NULLVP, flags | VSYSTEM)) != 0)
430 return error;
431
432 #ifdef DEBUG
433 if (udf_verbose & UDF_DEBUG_LOCKING)
434 udf_unmount_sanity_check(mp);
435 #endif
436
437 DPRINTF(VOLUMES, ("flush OK\n"));
438
439 /*
440 * TODO close logical volume and close session if requested.
441 */
442
443 /* close device */
444 DPRINTF(VOLUMES, ("closing device\n"));
445 if (mp->mnt_flag & MNT_RDONLY) {
446 closeflags = FREAD;
447 } else {
448 closeflags = FREAD | FWRITE;
449 }
450
451 /* devvp is still locked by us */
452 vn_lock(ump->devvp, LK_EXCLUSIVE | LK_RETRY);
453 error = VOP_CLOSE(ump->devvp, closeflags, NOCRED, l);
454 if (error)
455 printf("Error during closure of device! error %d, "
456 "device might stay locked\n", error);
457 DPRINTF(VOLUMES, ("device close ok\n"));
458
459 /* clear our mount reference and release device node */
460 ump->devvp->v_specmountpoint = NULL;
461 vput(ump->devvp);
462
463 /* free up umt structure */
464 free_udf_mountinfo(mp);
465
466 /* free ump struct reference */
467 mp->mnt_data = NULL;
468 mp->mnt_flag &= ~MNT_LOCAL;
469
470 DPRINTF(VOLUMES, ("Fin unmount\n"));
471 return error;
472 }
473
474 /* --------------------------------------------------------------------- */
475
476 /*
477 * Helper function of udf_mount() that actually mounts the disc.
478 */
479
480 static int
481 udf_mountfs(struct vnode *devvp, struct mount *mp,
482 struct lwp *l, struct udf_args *args)
483 {
484 struct udf_mount *ump;
485 uint32_t sector_size, lb_size, bshift;
486 int num_anchors, error, lst;
487
488 /* flush out any old buffers remaining from a previous use. */
489 if ((error = vinvalbuf(devvp, V_SAVE, l->l_cred, l, 0, 0)))
490 return error;
491
492 /* allocate udf part of mount structure; malloc always succeeds */
493 ump = malloc(sizeof(struct udf_mount), M_UDFMNT, M_WAITOK);
494 memset(ump, 0, sizeof(struct udf_mount));
495
496 /* init locks */
497 simple_lock_init(&ump->ihash_slock);
498 lockinit(&ump->get_node_lock, PINOD, "udf_getnode", 0, 0);
499
500 /* init `ino_t' to udf_node hash table */
501 for (lst = 0; lst < UDF_INODE_HASHSIZE; lst++) {
502 LIST_INIT(&ump->udf_nodes[lst]);
503 }
504
505 /* set up linkage */
506 mp->mnt_data = ump;
507 ump->vfs_mountp = mp;
508
509 /* set up arguments and device */
510 ump->mount_args = *args;
511 ump->devvp = devvp;
512 if ((error = udf_update_discinfo(ump))) {
513 printf("UDF mount: error inspecting fs node\n");
514 return error;
515 }
516
517 /* inspect sector size */
518 sector_size = ump->discinfo.sector_size;
519 bshift = 1;
520 while ((1 << bshift) < sector_size)
521 bshift++;
522 if ((1 << bshift) != sector_size) {
523 printf("UDF mount: "
524 "hit NetBSD implementation fence on sector size\n");
525 return EIO;
526 }
527
528 /* read all anchors to get volume descriptor sequence */
529 num_anchors = udf_read_anchors(ump, args);
530 if (num_anchors == 0)
531 return ENOENT;
532
533 DPRINTF(VOLUMES, ("Read %d anchors on this disc, session %d\n",
534 num_anchors, args->sessionnr));
535
536 /* read in volume descriptor sequence */
537 if ((error = udf_read_vds_space(ump))) {
538 printf("UDF mount: error reading volume space\n");
539 return error;
540 }
541
542 /* check consistency and completeness */
543 if ((error = udf_process_vds(ump, args))) {
544 printf( "UDF mount: disc not properly formatted"
545 "(bad VDS)\n");
546 return error;
547 }
548
549 /*
550 * Initialise pool for descriptors associated with nodes. This is done
551 * in lb_size units though currently lb_size is dictated to be
552 * sector_size.
553 */
554 lb_size = udf_rw32(ump->logical_vol->lb_size);
555 ump->desc_pool = malloc(sizeof(struct pool), M_UDFMNT, M_WAITOK);
556 memset(ump->desc_pool, 0, sizeof(struct pool));
557 pool_init(ump->desc_pool, lb_size, 0, 0, 0, "udf_desc_pool", NULL,
558 IPL_NONE);
559
560 /* read vds support tables like VAT, sparable etc. */
561 if ((error = udf_read_vds_tables(ump, args))) {
562 printf( "UDF mount: error in format or damaged disc "
563 "(VDS tables failing)\n");
564 return error;
565 }
566
567 if ((error = udf_read_rootdirs(ump, args))) {
568 printf( "UDF mount: "
569 "disc not properly formatted or damaged disc "
570 "(rootdirs failing)\n");
571 return error;
572 }
573
574 /* setup rest of mount information */
575 mp->mnt_data = ump;
576 mp->mnt_stat.f_fsidx.__fsid_val[0] = (uint32_t) devvp->v_rdev;
577 mp->mnt_stat.f_fsidx.__fsid_val[1] = makefstype(MOUNT_UDF);
578 mp->mnt_stat.f_fsid = mp->mnt_stat.f_fsidx.__fsid_val[0];
579 mp->mnt_stat.f_namemax = UDF_MAX_NAMELEN;
580 mp->mnt_flag |= MNT_LOCAL;
581
582 /* bshift is always equal to disc sector size */
583 mp->mnt_dev_bshift = bshift;
584 mp->mnt_fs_bshift = bshift;
585
586 /* do we have to set this? */
587 devvp->v_specmountpoint = mp;
588
589 /* success! */
590 return 0;
591 }
592
593 /* --------------------------------------------------------------------- */
594
595 int
596 udf_start(struct mount *mp, int flags, struct lwp *l)
597 {
598 /* do we have to do something here? */
599 return 0;
600 }
601
602 /* --------------------------------------------------------------------- */
603
604 int
605 udf_root(struct mount *mp, struct vnode **vpp)
606 {
607 struct vnode *vp;
608 struct long_ad *dir_loc;
609 struct udf_mount *ump = VFSTOUDF(mp);
610 struct udf_node *root_dir;
611 int error;
612
613 DPRINTF(CALL, ("udf_root called\n"));
614
615 dir_loc = &ump->fileset_desc->rootdir_icb;
616 error = udf_get_node(ump, dir_loc, &root_dir);
617
618 if (!root_dir)
619 error = ENOENT;
620 if (error)
621 return error;
622
623 vp = root_dir->vnode;
624 simple_lock(&vp->v_interlock);
625 root_dir->vnode->v_flag |= VROOT;
626 simple_unlock(&vp->v_interlock);
627
628 *vpp = vp;
629 return 0;
630 }
631
632 /* --------------------------------------------------------------------- */
633
634 int
635 udf_quotactl(struct mount *mp, int cmds, uid_t uid,
636 void *arg, struct lwp *l)
637 {
638 DPRINTF(NOTIMPL, ("udf_quotactl called\n"));
639 return EOPNOTSUPP;
640 }
641
642 /* --------------------------------------------------------------------- */
643
644 int
645 udf_statvfs(struct mount *mp, struct statvfs *sbp, struct lwp *l)
646 {
647 struct udf_mount *ump = VFSTOUDF(mp);
648 struct logvol_int_desc *lvid;
649 struct udf_logvol_info *impl;
650 uint64_t freeblks, sizeblks;
651 uint32_t *pos1, *pos2;
652 int part, num_part;
653
654 DPRINTF(CALL, ("udf_statvfs called\n"));
655 sbp->f_flag = mp->mnt_flag;
656 sbp->f_bsize = ump->discinfo.sector_size;
657 sbp->f_frsize = ump->discinfo.sector_size;
658 sbp->f_iosize = ump->discinfo.sector_size;
659
660 /* TODO integrity locking */
661 /* free and used space for mountpoint based on logvol integrity */
662 lvid = ump->logvol_integrity;
663 if (lvid) {
664 num_part = udf_rw32(lvid->num_part);
665 impl = (struct udf_logvol_info *) (lvid->tables + 2*num_part);
666
667 freeblks = sizeblks = 0;
668 for (part=0; part < num_part; part++) {
669 pos1 = &lvid->tables[0] + part;
670 pos2 = &lvid->tables[0] + num_part + part;
671 if (udf_rw32(*pos1) != (uint32_t) -1) {
672 freeblks += udf_rw32(*pos1);
673 sizeblks += udf_rw32(*pos2);
674 }
675 }
676 sbp->f_blocks = sizeblks;
677 sbp->f_bfree = freeblks;
678 sbp->f_files = udf_rw32(impl->num_files);
679 sbp->f_files += udf_rw32(impl->num_directories);
680
681 /* XXX read only for now XXX */
682 sbp->f_bavail = 0;
683 sbp->f_bresvd = 0;
684
685 /* tricky, next only aplies to ffs i think, so set to zero */
686 sbp->f_ffree = 0;
687 sbp->f_favail = 0;
688 sbp->f_fresvd = 0;
689 }
690
691 copy_statvfs_info(sbp, mp);
692 return 0;
693 }
694
695 /* --------------------------------------------------------------------- */
696
697 int
698 udf_sync(struct mount *mp, int waitfor,
699 kauth_cred_t cred, struct lwp *p)
700 {
701 DPRINTF(CALL, ("udf_sync called\n"));
702 /* nothing to be done as upto now read-only */
703 return 0;
704 }
705
706 /* --------------------------------------------------------------------- */
707
708 /*
709 * Get vnode for the file system type specific file id ino for the fs. Its
710 * used for reference to files by unique ID and for NFSv3.
711 * (optional) TODO lookup why some sources state NFSv3
712 */
713 int
714 udf_vget(struct mount *mp, ino_t ino,
715 struct vnode **vpp)
716 {
717 DPRINTF(NOTIMPL, ("udf_vget called\n"));
718 return EOPNOTSUPP;
719 }
720
721 /* --------------------------------------------------------------------- */
722
723 /*
724 * Lookup vnode for file handle specified
725 */
726 int
727 udf_fhtovp(struct mount *mp, struct fid *fhp,
728 struct vnode **vpp)
729 {
730 DPRINTF(NOTIMPL, ("udf_fhtovp called\n"));
731 return EOPNOTSUPP;
732 }
733
734 /* --------------------------------------------------------------------- */
735
736 /*
737 * Create an unique file handle. Its structure is opaque and won't be used by
738 * other subsystems. It should uniquely identify the file in the filingsystem
739 * and enough information to know if a file has been removed and/or resources
740 * have been recycled.
741 */
742 int
743 udf_vptofh(struct vnode *vp, struct fid *fid,
744 size_t *fh_size)
745 {
746 DPRINTF(NOTIMPL, ("udf_vptofh called\n"));
747 return EOPNOTSUPP;
748 }
749
750 /* --------------------------------------------------------------------- */
751
752 /*
753 * Create a filingsystem snapshot at the specified timestamp. Could be
754 * implemented by explicitly creating a new session or with spare room in the
755 * integrity descriptor space
756 */
757 int
758 udf_snapshot(struct mount *mp, struct vnode *vp,
759 struct timespec *tm)
760 {
761 DPRINTF(NOTIMPL, ("udf_snapshot called\n"));
762 return EOPNOTSUPP;
763 }
764
765 /* --------------------------------------------------------------------- */
766
767 /*
768 * If running a DEBUG kernel, provide an easy way to set the debug flags when
769 * running into a problem.
770 */
771
772 #ifdef DEBUG
773 #define UDF_VERBOSE_SYSCTLOPT 1
774
775 SYSCTL_SETUP(sysctl_vfs_udf_setup, "sysctl vfs.udf subtree setup")
776 {
777 /*
778 * XXX the "24" below could be dynamic, thereby eliminating one
779 * more instance of the "number to vfs" mapping problem, but
780 * "24" is the order as taken from sys/mount.h
781 */
782
783 sysctl_createv(clog, 0, NULL, NULL,
784 CTLFLAG_PERMANENT,
785 CTLTYPE_NODE, "vfs", NULL,
786 NULL, 0, NULL, 0,
787 CTL_VFS, CTL_EOL);
788 sysctl_createv(clog, 0, NULL, NULL,
789 CTLFLAG_PERMANENT,
790 CTLTYPE_NODE, "udf",
791 SYSCTL_DESCR("OSTA Universal File System"),
792 NULL, 0, NULL, 0,
793 CTL_VFS, 24, CTL_EOL);
794
795 sysctl_createv(clog, 0, NULL, NULL,
796 CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
797 CTLTYPE_INT, "verbose",
798 SYSCTL_DESCR("Bitmask for filesystem debugging"),
799 NULL, 0, &udf_verbose, 0,
800 CTL_VFS, 24, UDF_VERBOSE_SYSCTLOPT, CTL_EOL);
801 }
802
803 #endif /* DEBUG */
804
805