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