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