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