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