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