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