Home | History | Annotate | Line # | Download | only in msdosfs
msdosfs_vfsops.c revision 1.127
      1  1.127   hannken /*	$NetBSD: msdosfs_vfsops.c,v 1.127 2017/04/17 08:32:00 hannken Exp $	*/
      2    1.1  jdolecek 
      3    1.1  jdolecek /*-
      4    1.1  jdolecek  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
      5    1.1  jdolecek  * Copyright (C) 1994, 1995, 1997 TooLs GmbH.
      6    1.1  jdolecek  * All rights reserved.
      7    1.1  jdolecek  * Original code by Paul Popelka (paulp (at) uts.amdahl.com) (see below).
      8    1.1  jdolecek  *
      9    1.1  jdolecek  * Redistribution and use in source and binary forms, with or without
     10    1.1  jdolecek  * modification, are permitted provided that the following conditions
     11    1.1  jdolecek  * are met:
     12    1.1  jdolecek  * 1. Redistributions of source code must retain the above copyright
     13    1.1  jdolecek  *    notice, this list of conditions and the following disclaimer.
     14    1.1  jdolecek  * 2. Redistributions in binary form must reproduce the above copyright
     15    1.1  jdolecek  *    notice, this list of conditions and the following disclaimer in the
     16    1.1  jdolecek  *    documentation and/or other materials provided with the distribution.
     17    1.1  jdolecek  * 3. All advertising materials mentioning features or use of this software
     18    1.1  jdolecek  *    must display the following acknowledgement:
     19    1.1  jdolecek  *	This product includes software developed by TooLs GmbH.
     20    1.1  jdolecek  * 4. The name of TooLs GmbH may not be used to endorse or promote products
     21    1.1  jdolecek  *    derived from this software without specific prior written permission.
     22    1.1  jdolecek  *
     23    1.1  jdolecek  * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
     24    1.1  jdolecek  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     25    1.1  jdolecek  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     26    1.1  jdolecek  * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     27    1.1  jdolecek  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     28    1.1  jdolecek  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     29    1.1  jdolecek  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     30    1.1  jdolecek  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     31    1.1  jdolecek  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
     32    1.1  jdolecek  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     33    1.1  jdolecek  */
     34    1.1  jdolecek /*
     35    1.1  jdolecek  * Written by Paul Popelka (paulp (at) uts.amdahl.com)
     36    1.1  jdolecek  *
     37    1.1  jdolecek  * You can do anything you want with this software, just don't say you wrote
     38    1.1  jdolecek  * it, and don't remove this notice.
     39    1.1  jdolecek  *
     40    1.1  jdolecek  * This software is provided "as is".
     41    1.1  jdolecek  *
     42    1.1  jdolecek  * The author supplies this software to be publicly redistributed on the
     43    1.1  jdolecek  * understanding that the author is not responsible for the correct
     44    1.1  jdolecek  * functioning of this software in any circumstances and is not liable for
     45    1.1  jdolecek  * any damages caused by this software.
     46    1.1  jdolecek  *
     47    1.1  jdolecek  * October 1992
     48    1.1  jdolecek  */
     49    1.1  jdolecek 
     50    1.1  jdolecek #include <sys/cdefs.h>
     51  1.127   hannken __KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.127 2017/04/17 08:32:00 hannken Exp $");
     52    1.1  jdolecek 
     53    1.1  jdolecek #if defined(_KERNEL_OPT)
     54    1.1  jdolecek #include "opt_compat_netbsd.h"
     55    1.1  jdolecek #endif
     56    1.1  jdolecek 
     57    1.1  jdolecek #include <sys/param.h>
     58    1.1  jdolecek #include <sys/systm.h>
     59   1.12    atatat #include <sys/sysctl.h>
     60    1.1  jdolecek #include <sys/namei.h>
     61    1.1  jdolecek #include <sys/proc.h>
     62    1.1  jdolecek #include <sys/kernel.h>
     63    1.1  jdolecek #include <sys/vnode.h>
     64   1.60  dholland #include <miscfs/genfs/genfs.h>
     65    1.1  jdolecek #include <miscfs/specfs/specdev.h> /* XXX */	/* defines v_rdev */
     66    1.1  jdolecek #include <sys/mount.h>
     67    1.1  jdolecek #include <sys/buf.h>
     68    1.1  jdolecek #include <sys/file.h>
     69    1.1  jdolecek #include <sys/device.h>
     70    1.1  jdolecek #include <sys/disklabel.h>
     71   1.42  christos #include <sys/disk.h>
     72    1.1  jdolecek #include <sys/ioctl.h>
     73    1.1  jdolecek #include <sys/malloc.h>
     74    1.1  jdolecek #include <sys/dirent.h>
     75    1.1  jdolecek #include <sys/stat.h>
     76    1.1  jdolecek #include <sys/conf.h>
     77   1.31      elad #include <sys/kauth.h>
     78   1.66    rumble #include <sys/module.h>
     79    1.1  jdolecek 
     80    1.1  jdolecek #include <fs/msdosfs/bpb.h>
     81    1.1  jdolecek #include <fs/msdosfs/bootsect.h>
     82    1.1  jdolecek #include <fs/msdosfs/direntry.h>
     83    1.1  jdolecek #include <fs/msdosfs/denode.h>
     84    1.1  jdolecek #include <fs/msdosfs/msdosfsmount.h>
     85    1.1  jdolecek #include <fs/msdosfs/fat.h>
     86    1.1  jdolecek 
     87   1.82     pooka MODULE(MODULE_CLASS_VFS, msdos, NULL);
     88   1.66    rumble 
     89   1.42  christos #ifdef MSDOSFS_DEBUG
     90  1.115      maxv #define DPRINTF(fmt, ...) uprintf("%s(): " fmt "\n", __func__, ##__VA_ARGS__)
     91   1.42  christos #else
     92  1.115      maxv #define DPRINTF(fmt, ...)
     93   1.42  christos #endif
     94   1.42  christos 
     95  1.110      maxv #define GEMDOSFS_BSIZE	512
     96  1.110      maxv 
     97   1.20  jdolecek #define MSDOSFS_NAMEMAX(pmp) \
     98   1.20  jdolecek 	(pmp)->pm_flags & MSDOSFSMNT_LONGNAME ? WIN_MAXLEN : 12
     99   1.20  jdolecek 
    100   1.29  christos int msdosfs_mountfs(struct vnode *, struct mount *, struct lwp *,
    101   1.26   xtraeme     struct msdosfs_args *);
    102    1.1  jdolecek 
    103   1.26   xtraeme static int update_mp(struct mount *, struct msdosfs_args *);
    104    1.2   thorpej 
    105   1.45     pooka MALLOC_JUSTDEFINE(M_MSDOSFSMNT, "MSDOSFS mount", "MSDOS FS mount structure");
    106  1.100  jakllsch MALLOC_JUSTDEFINE(M_MSDOSFSFAT, "MSDOSFS FAT", "MSDOS FS FAT table");
    107   1.51    rumble MALLOC_JUSTDEFINE(M_MSDOSFSTMP, "MSDOSFS temp", "MSDOS FS temp. structures");
    108    1.1  jdolecek 
    109   1.68    rumble static struct sysctllog *msdosfs_sysctl_log;
    110   1.68    rumble 
    111    1.1  jdolecek extern const struct vnodeopv_desc msdosfs_vnodeop_opv_desc;
    112    1.1  jdolecek 
    113    1.1  jdolecek const struct vnodeopv_desc * const msdosfs_vnodeopv_descs[] = {
    114    1.1  jdolecek 	&msdosfs_vnodeop_opv_desc,
    115    1.1  jdolecek 	NULL,
    116    1.1  jdolecek };
    117    1.1  jdolecek 
    118    1.1  jdolecek struct vfsops msdosfs_vfsops = {
    119  1.106   hannken 	.vfs_name = MOUNT_MSDOS,
    120  1.106   hannken 	.vfs_min_mount_data = sizeof (struct msdosfs_args),
    121  1.106   hannken 	.vfs_mount = msdosfs_mount,
    122  1.106   hannken 	.vfs_start = msdosfs_start,
    123  1.106   hannken 	.vfs_unmount = msdosfs_unmount,
    124  1.106   hannken 	.vfs_root = msdosfs_root,
    125  1.106   hannken 	.vfs_quotactl = (void *)eopnotsupp,
    126  1.106   hannken 	.vfs_statvfs = msdosfs_statvfs,
    127  1.106   hannken 	.vfs_sync = msdosfs_sync,
    128  1.106   hannken 	.vfs_vget = msdosfs_vget,
    129  1.109   hannken 	.vfs_loadvnode = msdosfs_loadvnode,
    130  1.106   hannken 	.vfs_fhtovp = msdosfs_fhtovp,
    131  1.106   hannken 	.vfs_vptofh = msdosfs_vptofh,
    132  1.106   hannken 	.vfs_init = msdosfs_init,
    133  1.106   hannken 	.vfs_reinit = msdosfs_reinit,
    134  1.106   hannken 	.vfs_done = msdosfs_done,
    135  1.106   hannken 	.vfs_mountroot = msdosfs_mountroot,
    136  1.106   hannken 	.vfs_snapshot = (void *)eopnotsupp,
    137  1.106   hannken 	.vfs_extattrctl = vfs_stdextattrctl,
    138  1.122   hannken 	.vfs_suspendctl = genfs_suspendctl,
    139  1.106   hannken 	.vfs_renamelock_enter = genfs_renamelock_enter,
    140  1.106   hannken 	.vfs_renamelock_exit = genfs_renamelock_exit,
    141  1.106   hannken 	.vfs_fsync = (void *)eopnotsupp,
    142  1.106   hannken 	.vfs_opv_descs = msdosfs_vnodeopv_descs
    143    1.1  jdolecek };
    144   1.66    rumble 
    145   1.66    rumble static int
    146   1.83   mlelstv msdos_modcmd(modcmd_t cmd, void *arg)
    147   1.66    rumble {
    148   1.68    rumble 	int error;
    149   1.66    rumble 
    150   1.66    rumble 	switch (cmd) {
    151   1.66    rumble 	case MODULE_CMD_INIT:
    152   1.68    rumble 		error = vfs_attach(&msdosfs_vfsops);
    153   1.68    rumble 		if (error != 0)
    154   1.68    rumble 			break;
    155   1.68    rumble 		sysctl_createv(&msdosfs_sysctl_log, 0, NULL, NULL,
    156   1.68    rumble 			       CTLFLAG_PERMANENT,
    157   1.68    rumble 			       CTLTYPE_NODE, "msdosfs",
    158   1.68    rumble 			       SYSCTL_DESCR("MS-DOS file system"),
    159   1.68    rumble 			       NULL, 0, NULL, 0,
    160   1.68    rumble 			       CTL_VFS, 4, CTL_EOL);
    161   1.68    rumble 		/*
    162   1.68    rumble 		 * XXX the "4" above could be dynamic, thereby eliminating one
    163   1.68    rumble 		 * more instance of the "number to vfs" mapping problem, but
    164   1.68    rumble 		 * "4" is the order as taken from sys/mount.h
    165   1.68    rumble 		 */
    166   1.68    rumble 		break;
    167   1.66    rumble 	case MODULE_CMD_FINI:
    168   1.68    rumble 		error = vfs_detach(&msdosfs_vfsops);
    169   1.68    rumble 		if (error != 0)
    170   1.68    rumble 			break;
    171   1.68    rumble 		sysctl_teardown(&msdosfs_sysctl_log);
    172   1.68    rumble 		break;
    173   1.66    rumble 	default:
    174   1.68    rumble 		error = ENOTTY;
    175   1.68    rumble 		break;
    176   1.66    rumble 	}
    177   1.68    rumble 
    178   1.68    rumble 	return (error);
    179   1.66    rumble }
    180    1.1  jdolecek 
    181    1.1  jdolecek static int
    182   1.72       dsl update_mp(struct mount *mp, struct msdosfs_args *argp)
    183    1.1  jdolecek {
    184    1.1  jdolecek 	struct msdosfsmount *pmp = VFSTOMSDOSFS(mp);
    185    1.1  jdolecek 	int error;
    186    1.1  jdolecek 
    187    1.1  jdolecek 	pmp->pm_gid = argp->gid;
    188    1.1  jdolecek 	pmp->pm_uid = argp->uid;
    189    1.1  jdolecek 	pmp->pm_mask = argp->mask & ALLPERMS;
    190    1.8  jdolecek 	pmp->pm_dirmask = argp->dirmask & ALLPERMS;
    191    1.9    itojun 	pmp->pm_gmtoff = argp->gmtoff;
    192    1.1  jdolecek 	pmp->pm_flags |= argp->flags & MSDOSFSMNT_MNTOPT;
    193    1.1  jdolecek 
    194    1.1  jdolecek 	/*
    195   1.71       abs 	 * GEMDOS knows nothing about win95 long filenames
    196    1.1  jdolecek 	 */
    197    1.1  jdolecek 	if (pmp->pm_flags & MSDOSFSMNT_GEMDOSFS)
    198    1.1  jdolecek 		pmp->pm_flags |= MSDOSFSMNT_NOWIN95;
    199    1.1  jdolecek 
    200    1.1  jdolecek 	if (pmp->pm_flags & MSDOSFSMNT_NOWIN95)
    201    1.1  jdolecek 		pmp->pm_flags |= MSDOSFSMNT_SHORTNAME;
    202    1.1  jdolecek 	else if (!(pmp->pm_flags &
    203    1.1  jdolecek 	    (MSDOSFSMNT_SHORTNAME | MSDOSFSMNT_LONGNAME))) {
    204   1.24  christos 		struct vnode *rtvp;
    205    1.1  jdolecek 
    206    1.1  jdolecek 		/*
    207    1.1  jdolecek 		 * Try to divine whether to support Win'95 long filenames
    208    1.1  jdolecek 		 */
    209    1.1  jdolecek 		if (FAT32(pmp))
    210    1.1  jdolecek 			pmp->pm_flags |= MSDOSFSMNT_LONGNAME;
    211    1.1  jdolecek 		else {
    212   1.24  christos 			if ((error = msdosfs_root(mp, &rtvp)) != 0)
    213    1.1  jdolecek 				return error;
    214   1.24  christos 			pmp->pm_flags |= findwin95(VTODE(rtvp))
    215    1.1  jdolecek 				? MSDOSFSMNT_LONGNAME
    216    1.1  jdolecek 					: MSDOSFSMNT_SHORTNAME;
    217   1.24  christos 			vput(rtvp);
    218    1.1  jdolecek 		}
    219    1.1  jdolecek 	}
    220   1.20  jdolecek 
    221   1.20  jdolecek 	mp->mnt_stat.f_namemax = MSDOSFS_NAMEMAX(pmp);
    222   1.20  jdolecek 
    223    1.1  jdolecek 	return 0;
    224    1.1  jdolecek }
    225    1.1  jdolecek 
    226    1.1  jdolecek int
    227   1.73    cegger msdosfs_mountroot(void)
    228    1.1  jdolecek {
    229    1.1  jdolecek 	struct mount *mp;
    230   1.29  christos 	struct lwp *l = curlwp;	/* XXX */
    231    1.1  jdolecek 	int error;
    232    1.1  jdolecek 	struct msdosfs_args args;
    233    1.1  jdolecek 
    234   1.30   thorpej 	if (device_class(root_device) != DV_DISK)
    235    1.1  jdolecek 		return (ENODEV);
    236    1.1  jdolecek 
    237    1.1  jdolecek 	if ((error = vfs_rootmountalloc(MOUNT_MSDOS, "root_device", &mp))) {
    238    1.1  jdolecek 		vrele(rootvp);
    239    1.1  jdolecek 		return (error);
    240    1.1  jdolecek 	}
    241    1.1  jdolecek 
    242    1.8  jdolecek 	args.flags = MSDOSFSMNT_VERSIONED;
    243    1.1  jdolecek 	args.uid = 0;
    244    1.1  jdolecek 	args.gid = 0;
    245    1.1  jdolecek 	args.mask = 0777;
    246    1.8  jdolecek 	args.version = MSDOSFSMNT_VERSION;
    247    1.8  jdolecek 	args.dirmask = 0777;
    248    1.1  jdolecek 
    249   1.29  christos 	if ((error = msdosfs_mountfs(rootvp, mp, l, &args)) != 0) {
    250  1.127   hannken 		vfs_unbusy(mp);
    251  1.126   hannken 		vfs_rele(mp);
    252    1.1  jdolecek 		return (error);
    253    1.1  jdolecek 	}
    254    1.1  jdolecek 
    255    1.6   thorpej 	if ((error = update_mp(mp, &args)) != 0) {
    256   1.54     pooka 		(void)msdosfs_unmount(mp, 0);
    257  1.127   hannken 		vfs_unbusy(mp);
    258  1.126   hannken 		vfs_rele(mp);
    259    1.1  jdolecek 		vrele(rootvp);
    260    1.1  jdolecek 		return (error);
    261    1.1  jdolecek 	}
    262    1.1  jdolecek 
    263  1.103  christos 	mountlist_append(mp);
    264   1.54     pooka 	(void)msdosfs_statvfs(mp, &mp->mnt_stat);
    265  1.127   hannken 	vfs_unbusy(mp);
    266    1.1  jdolecek 	return (0);
    267    1.1  jdolecek }
    268    1.1  jdolecek 
    269    1.1  jdolecek /*
    270    1.1  jdolecek  * mp - path - addr in user space of mount point (ie /usr or whatever)
    271    1.1  jdolecek  * data - addr in user space of mount params including the name of the block
    272    1.1  jdolecek  * special file to treat as a filesystem.
    273    1.1  jdolecek  */
    274    1.1  jdolecek int
    275   1.72       dsl msdosfs_mount(struct mount *mp, const char *path, void *data, size_t *data_len)
    276    1.1  jdolecek {
    277   1.54     pooka 	struct lwp *l = curlwp;
    278    1.1  jdolecek 	struct vnode *devvp;	  /* vnode for blk device to mount */
    279   1.46       dsl 	struct msdosfs_args *args = data; /* holds data from mount request */
    280    1.1  jdolecek 	/* msdosfs specific mount control block */
    281    1.1  jdolecek 	struct msdosfsmount *pmp = NULL;
    282    1.1  jdolecek 	int error, flags;
    283    1.1  jdolecek 	mode_t accessmode;
    284    1.1  jdolecek 
    285  1.107      maxv 	if (args == NULL)
    286  1.107      maxv 		return EINVAL;
    287   1.46       dsl 	if (*data_len < sizeof *args)
    288   1.46       dsl 		return EINVAL;
    289   1.46       dsl 
    290    1.1  jdolecek 	if (mp->mnt_flag & MNT_GETARGS) {
    291    1.1  jdolecek 		pmp = VFSTOMSDOSFS(mp);
    292    1.1  jdolecek 		if (pmp == NULL)
    293    1.1  jdolecek 			return EIO;
    294   1.46       dsl 		args->fspec = NULL;
    295   1.46       dsl 		args->uid = pmp->pm_uid;
    296   1.46       dsl 		args->gid = pmp->pm_gid;
    297   1.46       dsl 		args->mask = pmp->pm_mask;
    298   1.46       dsl 		args->flags = pmp->pm_flags;
    299   1.46       dsl 		args->version = MSDOSFSMNT_VERSION;
    300   1.46       dsl 		args->dirmask = pmp->pm_dirmask;
    301   1.46       dsl 		args->gmtoff = pmp->pm_gmtoff;
    302   1.46       dsl 		*data_len = sizeof *args;
    303   1.46       dsl 		return 0;
    304   1.42  christos 	}
    305    1.8  jdolecek 
    306    1.8  jdolecek 	/*
    307    1.8  jdolecek 	 * If not versioned (i.e. using old mount_msdos(8)), fill in
    308    1.8  jdolecek 	 * the additional structure items with suitable defaults.
    309    1.8  jdolecek 	 */
    310   1.46       dsl 	if ((args->flags & MSDOSFSMNT_VERSIONED) == 0) {
    311   1.46       dsl 		args->version = 1;
    312   1.46       dsl 		args->dirmask = args->mask;
    313    1.8  jdolecek 	}
    314    1.8  jdolecek 
    315    1.1  jdolecek 	/*
    316   1.15  jdolecek 	 * Reset GMT offset for pre-v3 mount structure args.
    317   1.15  jdolecek 	 */
    318   1.46       dsl 	if (args->version < 3)
    319   1.46       dsl 		args->gmtoff = 0;
    320   1.15  jdolecek 
    321   1.15  jdolecek 	/*
    322    1.1  jdolecek 	 * If updating, check whether changing from read-only to
    323    1.1  jdolecek 	 * read/write; if there is no device name, that's all we do.
    324    1.1  jdolecek 	 */
    325    1.1  jdolecek 	if (mp->mnt_flag & MNT_UPDATE) {
    326    1.1  jdolecek 		pmp = VFSTOMSDOSFS(mp);
    327    1.1  jdolecek 		error = 0;
    328   1.75      elad 		if (!(pmp->pm_flags & MSDOSFSMNT_RONLY) &&
    329   1.75      elad 		    (mp->mnt_flag & MNT_RDONLY)) {
    330    1.1  jdolecek 			flags = WRITECLOSE;
    331    1.1  jdolecek 			if (mp->mnt_flag & MNT_FORCE)
    332    1.1  jdolecek 				flags |= FORCECLOSE;
    333    1.1  jdolecek 			error = vflush(mp, NULLVP, flags);
    334    1.1  jdolecek 		}
    335    1.1  jdolecek 		if (!error && (mp->mnt_flag & MNT_RELOAD))
    336    1.1  jdolecek 			/* not yet implemented */
    337    1.1  jdolecek 			error = EOPNOTSUPP;
    338   1.42  christos 		if (error) {
    339  1.115      maxv 			DPRINTF("vflush %d", error);
    340    1.1  jdolecek 			return (error);
    341   1.42  christos 		}
    342   1.75      elad 		if ((pmp->pm_flags & MSDOSFSMNT_RONLY) &&
    343   1.75      elad 		    (mp->mnt_iflag & IMNT_WANTRDWR)) {
    344    1.1  jdolecek 			/*
    345    1.1  jdolecek 			 * If upgrade to read-write by non-root, then verify
    346    1.1  jdolecek 			 * that user has necessary permissions on the device.
    347   1.74      elad 			 *
    348   1.75      elad 			 * Permission to update a mount is checked higher, so
    349   1.75      elad 			 * here we presume updating the mount is okay (for
    350   1.75      elad 			 * example, as far as securelevel goes) which leaves us
    351   1.75      elad 			 * with the normal check.
    352    1.1  jdolecek 			 */
    353   1.74      elad 			devvp = pmp->pm_devvp;
    354   1.74      elad 			vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
    355   1.94      elad 			error = kauth_authorize_system(l->l_cred,
    356   1.94      elad 			    KAUTH_SYSTEM_MOUNT, KAUTH_REQ_SYSTEM_MOUNT_DEVICE,
    357   1.94      elad 			    mp, devvp, KAUTH_ARG(VREAD | VWRITE));
    358   1.86   hannken 			VOP_UNLOCK(devvp);
    359  1.115      maxv 			DPRINTF("KAUTH_REQ_SYSTEM_MOUNT_DEVICE %d", error);
    360   1.74      elad 			if (error)
    361   1.74      elad 				return (error);
    362   1.74      elad 
    363    1.1  jdolecek 			pmp->pm_flags &= ~MSDOSFSMNT_RONLY;
    364    1.1  jdolecek 		}
    365   1.46       dsl 		if (args->fspec == NULL) {
    366  1.115      maxv 			DPRINTF("missing fspec");
    367   1.28      jmmv 			return EINVAL;
    368   1.42  christos 		}
    369    1.1  jdolecek 	}
    370    1.1  jdolecek 	/*
    371    1.1  jdolecek 	 * Not an update, or updating the name: look up the name
    372    1.1  jdolecek 	 * and verify that it refers to a sensible block device.
    373    1.1  jdolecek 	 */
    374   1.76  dholland 	error = namei_simple_user(args->fspec,
    375   1.76  dholland 				NSM_FOLLOW_NOEMULROOT, &devvp);
    376   1.76  dholland 	if (error != 0) {
    377  1.115      maxv 		DPRINTF("namei %d", error);
    378    1.1  jdolecek 		return (error);
    379   1.42  christos 	}
    380    1.1  jdolecek 
    381    1.1  jdolecek 	if (devvp->v_type != VBLK) {
    382  1.115      maxv 		DPRINTF("not block");
    383    1.1  jdolecek 		vrele(devvp);
    384    1.1  jdolecek 		return (ENOTBLK);
    385    1.1  jdolecek 	}
    386    1.1  jdolecek 	if (bdevsw_lookup(devvp->v_rdev) == NULL) {
    387  1.115      maxv 		DPRINTF("no block switch");
    388    1.1  jdolecek 		vrele(devvp);
    389    1.1  jdolecek 		return (ENXIO);
    390    1.1  jdolecek 	}
    391    1.1  jdolecek 	/*
    392    1.1  jdolecek 	 * If mount by non-root, then verify that user has necessary
    393    1.1  jdolecek 	 * permissions on the device.
    394    1.1  jdolecek 	 */
    395   1.74      elad 	accessmode = VREAD;
    396   1.74      elad 	if ((mp->mnt_flag & MNT_RDONLY) == 0)
    397   1.74      elad 		accessmode |= VWRITE;
    398   1.74      elad 	vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
    399   1.94      elad 	error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_MOUNT,
    400   1.94      elad 	    KAUTH_REQ_SYSTEM_MOUNT_DEVICE, mp, devvp, KAUTH_ARG(accessmode));
    401   1.86   hannken 	VOP_UNLOCK(devvp);
    402   1.74      elad 	if (error) {
    403  1.115      maxv 		DPRINTF("KAUTH_REQ_SYSTEM_MOUNT_DEVICE %d", error);
    404   1.74      elad 		vrele(devvp);
    405   1.74      elad 		return (error);
    406    1.1  jdolecek 	}
    407    1.1  jdolecek 	if ((mp->mnt_flag & MNT_UPDATE) == 0) {
    408   1.24  christos 		int xflags;
    409   1.22   mycroft 
    410   1.22   mycroft 		if (mp->mnt_flag & MNT_RDONLY)
    411   1.24  christos 			xflags = FREAD;
    412   1.22   mycroft 		else
    413   1.24  christos 			xflags = FREAD|FWRITE;
    414   1.93   hannken 		vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
    415   1.54     pooka 		error = VOP_OPEN(devvp, xflags, FSCRED);
    416   1.93   hannken 		VOP_UNLOCK(devvp);
    417   1.42  christos 		if (error) {
    418  1.115      maxv 			DPRINTF("VOP_OPEN %d", error);
    419   1.22   mycroft 			goto fail;
    420   1.42  christos 		}
    421   1.46       dsl 		error = msdosfs_mountfs(devvp, mp, l, args);
    422   1.22   mycroft 		if (error) {
    423  1.115      maxv 			DPRINTF("msdosfs_mountfs %d", error);
    424   1.22   mycroft 			vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
    425   1.54     pooka 			(void) VOP_CLOSE(devvp, xflags, NOCRED);
    426   1.86   hannken 			VOP_UNLOCK(devvp);
    427   1.22   mycroft 			goto fail;
    428   1.22   mycroft 		}
    429    1.1  jdolecek #ifdef MSDOSFS_DEBUG		/* only needed for the printf below */
    430    1.1  jdolecek 		pmp = VFSTOMSDOSFS(mp);
    431    1.1  jdolecek #endif
    432    1.1  jdolecek 	} else {
    433   1.22   mycroft 		vrele(devvp);
    434   1.42  christos 		if (devvp != pmp->pm_devvp) {
    435  1.115      maxv 			DPRINTF("devvp %p pmp %p", devvp, pmp->pm_devvp);
    436   1.22   mycroft 			return (EINVAL);	/* needs translation */
    437   1.42  christos 		}
    438    1.1  jdolecek 	}
    439   1.46       dsl 	if ((error = update_mp(mp, args)) != 0) {
    440   1.54     pooka 		msdosfs_unmount(mp, MNT_FORCE);
    441  1.115      maxv 		DPRINTF("update_mp %d", error);
    442    1.1  jdolecek 		return error;
    443    1.1  jdolecek 	}
    444    1.1  jdolecek 
    445    1.1  jdolecek #ifdef MSDOSFS_DEBUG
    446    1.1  jdolecek 	printf("msdosfs_mount(): mp %p, pmp %p, inusemap %p\n", mp, pmp, pmp->pm_inusemap);
    447    1.1  jdolecek #endif
    448   1.46       dsl 	return set_statvfs_info(path, UIO_USERSPACE, args->fspec, UIO_USERSPACE,
    449   1.47     pooka 	    mp->mnt_op->vfs_name, mp, l);
    450   1.22   mycroft 
    451   1.22   mycroft fail:
    452   1.22   mycroft 	vrele(devvp);
    453   1.22   mycroft 	return (error);
    454    1.1  jdolecek }
    455    1.1  jdolecek 
    456    1.1  jdolecek int
    457   1.72       dsl msdosfs_mountfs(struct vnode *devvp, struct mount *mp, struct lwp *l, struct msdosfs_args *argp)
    458    1.1  jdolecek {
    459    1.1  jdolecek 	struct msdosfsmount *pmp;
    460    1.1  jdolecek 	struct buf *bp;
    461    1.1  jdolecek 	dev_t dev = devvp->v_rdev;
    462    1.1  jdolecek 	union bootsector *bsp;
    463    1.1  jdolecek 	struct byte_bpb33 *b33;
    464    1.1  jdolecek 	struct byte_bpb50 *b50;
    465    1.1  jdolecek 	struct byte_bpb710 *b710;
    466   1.79   mlelstv 	uint8_t SecPerClust;
    467  1.110      maxv 	int	ronly, error, BlkPerSec;
    468   1.79   mlelstv 	uint64_t psize;
    469   1.79   mlelstv 	unsigned secsize;
    470    1.1  jdolecek 
    471   1.22   mycroft 	/* Flush out any old buffers remaining from a previous use. */
    472   1.33        ad 	if ((error = vinvalbuf(devvp, V_SAVE, l->l_cred, l, 0, 0)) != 0)
    473    1.1  jdolecek 		return (error);
    474    1.1  jdolecek 
    475    1.1  jdolecek 	ronly = (mp->mnt_flag & MNT_RDONLY) != 0;
    476    1.1  jdolecek 
    477    1.1  jdolecek 	bp  = NULL; /* both used in error_exit */
    478    1.1  jdolecek 	pmp = NULL;
    479    1.1  jdolecek 
    480   1.79   mlelstv 	error = getdisksize(devvp, &psize, &secsize);
    481   1.96   tsutsui 	if (error) {
    482   1.84     pooka 		if (argp->flags & MSDOSFSMNT_GEMDOSFS)
    483   1.84     pooka 			goto error_exit;
    484   1.85     pooka 
    485   1.85     pooka 		/* ok, so it failed.  we most likely don't need the info */
    486   1.84     pooka 		secsize = DEV_BSIZE;
    487   1.84     pooka 		psize = 0;
    488   1.85     pooka 		error = 0;
    489   1.84     pooka 	}
    490  1.114      maxv 	if (secsize < DEV_BSIZE) {
    491  1.115      maxv 		DPRINTF("Invalid block secsize (%d < DEV_BSIZE)", secsize);
    492  1.114      maxv 		error = EINVAL;
    493  1.114      maxv 		goto error_exit;
    494  1.114      maxv 	}
    495   1.79   mlelstv 
    496    1.1  jdolecek 	if (argp->flags & MSDOSFSMNT_GEMDOSFS) {
    497  1.110      maxv 		if (secsize != GEMDOSFS_BSIZE) {
    498  1.115      maxv 			DPRINTF("Invalid block secsize %d for GEMDOS", secsize);
    499    1.1  jdolecek 			error = EINVAL;
    500    1.1  jdolecek 			goto error_exit;
    501    1.1  jdolecek 		}
    502  1.110      maxv 	}
    503    1.1  jdolecek 
    504    1.1  jdolecek 	/*
    505    1.1  jdolecek 	 * Read the boot sector of the filesystem, and then check the
    506    1.1  jdolecek 	 * boot signature.  If not a dos boot sector then error out.
    507    1.1  jdolecek 	 */
    508  1.116  christos 	if (secsize < sizeof(*b50)) {
    509  1.117  christos 		DPRINTF("50 bootsec %u\n", secsize);
    510  1.116  christos 		error = EINVAL;
    511  1.116  christos 		goto error_exit;
    512  1.116  christos 	}
    513  1.118      maxv 	if ((error = bread(devvp, 0, secsize, 0, &bp)) != 0)
    514    1.1  jdolecek 		goto error_exit;
    515    1.1  jdolecek 	bsp = (union bootsector *)bp->b_data;
    516    1.1  jdolecek 	b33 = (struct byte_bpb33 *)bsp->bs33.bsBPB;
    517    1.1  jdolecek 	b50 = (struct byte_bpb50 *)bsp->bs50.bsBPB;
    518   1.10     lukem 	b710 = (struct byte_bpb710 *)bsp->bs710.bsBPB;
    519    1.1  jdolecek 
    520    1.1  jdolecek 	if (!(argp->flags & MSDOSFSMNT_GEMDOSFS)) {
    521    1.1  jdolecek 		if (bsp->bs50.bsBootSectSig0 != BOOTSIG0
    522    1.1  jdolecek 		    || bsp->bs50.bsBootSectSig1 != BOOTSIG1) {
    523  1.115      maxv 			DPRINTF("bootsig0 %d bootsig1 %d",
    524   1.42  christos 			    bsp->bs50.bsBootSectSig0,
    525  1.115      maxv 			    bsp->bs50.bsBootSectSig1);
    526    1.1  jdolecek 			error = EINVAL;
    527    1.1  jdolecek 			goto error_exit;
    528    1.1  jdolecek 		}
    529    1.1  jdolecek 	}
    530    1.1  jdolecek 
    531  1.112      maxv 	pmp = malloc(sizeof(*pmp), M_MSDOSFSMNT, M_WAITOK|M_ZERO);
    532    1.1  jdolecek 	pmp->pm_mountp = mp;
    533    1.1  jdolecek 
    534    1.1  jdolecek 	/*
    535    1.1  jdolecek 	 * Compute several useful quantities from the bpb in the
    536    1.1  jdolecek 	 * bootsector.  Copy in the dos 5 variant of the bpb then fix up
    537    1.1  jdolecek 	 * the fields that are different between dos 5 and dos 3.3.
    538    1.1  jdolecek 	 */
    539    1.1  jdolecek 	SecPerClust = b50->bpbSecPerClust;
    540    1.1  jdolecek 	pmp->pm_BytesPerSec = getushort(b50->bpbBytesPerSec);
    541    1.1  jdolecek 	pmp->pm_ResSectors = getushort(b50->bpbResSectors);
    542    1.1  jdolecek 	pmp->pm_FATs = b50->bpbFATs;
    543    1.1  jdolecek 	pmp->pm_RootDirEnts = getushort(b50->bpbRootDirEnts);
    544    1.1  jdolecek 	pmp->pm_Sectors = getushort(b50->bpbSectors);
    545    1.1  jdolecek 	pmp->pm_FATsecs = getushort(b50->bpbFATsecs);
    546    1.1  jdolecek 	pmp->pm_SecPerTrack = getushort(b50->bpbSecPerTrack);
    547    1.1  jdolecek 	pmp->pm_Heads = getushort(b50->bpbHeads);
    548    1.1  jdolecek 	pmp->pm_Media = b50->bpbMedia;
    549    1.1  jdolecek 
    550    1.1  jdolecek 	if (pmp->pm_Sectors == 0) {
    551    1.1  jdolecek 		pmp->pm_HiddenSects = getulong(b50->bpbHiddenSecs);
    552    1.1  jdolecek 		pmp->pm_HugeSectors = getulong(b50->bpbHugeSectors);
    553    1.1  jdolecek 	} else {
    554  1.116  christos 		if (secsize < sizeof(*b33)) {
    555  1.117  christos 			DPRINTF("33 bootsec %u\n", secsize);
    556  1.116  christos 			error = EINVAL;
    557  1.116  christos 			goto error_exit;
    558  1.116  christos 		}
    559    1.1  jdolecek 		pmp->pm_HiddenSects = getushort(b33->bpbHiddenSecs);
    560    1.1  jdolecek 		pmp->pm_HugeSectors = pmp->pm_Sectors;
    561    1.1  jdolecek 	}
    562    1.1  jdolecek 
    563  1.110      maxv 	/*
    564  1.110      maxv 	 * Sanity checks, from the FAT specification:
    565  1.110      maxv 	 * - sectors per cluster: >= 1, power of 2
    566  1.110      maxv 	 * - logical sector size: >= 1, power of 2
    567  1.110      maxv 	 * - cluster size:        <= max FS block size
    568  1.110      maxv 	 * - number of sectors:   >= 1
    569  1.110      maxv 	 */
    570  1.110      maxv 	if ((SecPerClust == 0) || !powerof2(SecPerClust) ||
    571  1.110      maxv 	    (pmp->pm_BytesPerSec == 0) || !powerof2(pmp->pm_BytesPerSec) ||
    572  1.110      maxv 	    (SecPerClust * pmp->pm_BytesPerSec > MAXBSIZE) ||
    573  1.110      maxv 	    (pmp->pm_HugeSectors == 0)) {
    574  1.115      maxv 		DPRINTF("consistency checks");
    575  1.110      maxv 		error = EINVAL;
    576  1.110      maxv 		goto error_exit;
    577  1.110      maxv 	}
    578  1.110      maxv 
    579  1.110      maxv 	if (!(argp->flags & MSDOSFSMNT_GEMDOSFS) &&
    580  1.110      maxv 	    (pmp->pm_SecPerTrack > 63)) {
    581  1.115      maxv 		DPRINTF("SecPerTrack %d", pmp->pm_SecPerTrack);
    582  1.110      maxv 		error = EINVAL;
    583  1.110      maxv 		goto error_exit;
    584  1.110      maxv 	}
    585  1.110      maxv 
    586    1.1  jdolecek 	if (pmp->pm_RootDirEnts == 0) {
    587  1.116  christos 		if (secsize < sizeof(*b710)) {
    588  1.117  christos 			DPRINTF("710 bootsec %u\n", secsize);
    589  1.116  christos 			error = EINVAL;
    590  1.116  christos 			goto error_exit;
    591  1.116  christos 		}
    592  1.112      maxv 		unsigned short FSVers = getushort(b710->bpbFSVers);
    593  1.112      maxv 		unsigned short ExtFlags = getushort(b710->bpbExtFlags);
    594   1.34       gdt 		/*
    595   1.34       gdt 		 * Some say that bsBootSectSig[23] must be zero, but
    596   1.34       gdt 		 * Windows does not require this and some digital cameras
    597   1.34       gdt 		 * do not set these to zero.  Therefore, do not insist.
    598   1.34       gdt 		 */
    599  1.112      maxv 		if (pmp->pm_Sectors || pmp->pm_FATsecs || FSVers) {
    600  1.115      maxv 			DPRINTF("Sectors %d FATsecs %lu FSVers %d",
    601  1.115      maxv 			    pmp->pm_Sectors, pmp->pm_FATsecs, FSVers);
    602    1.1  jdolecek 			error = EINVAL;
    603    1.1  jdolecek 			goto error_exit;
    604    1.1  jdolecek 		}
    605    1.1  jdolecek 		pmp->pm_fatmask = FAT32_MASK;
    606    1.1  jdolecek 		pmp->pm_fatmult = 4;
    607    1.1  jdolecek 		pmp->pm_fatdiv = 1;
    608    1.1  jdolecek 		pmp->pm_FATsecs = getulong(b710->bpbBigFATsecs);
    609    1.1  jdolecek 
    610  1.112      maxv 		/* Mirroring is enabled if the FATMIRROR bit is not set. */
    611  1.112      maxv 		if ((ExtFlags & FATMIRROR) == 0)
    612    1.1  jdolecek 			pmp->pm_flags |= MSDOSFS_FATMIRROR;
    613    1.1  jdolecek 		else
    614  1.112      maxv 			pmp->pm_curfat = ExtFlags & FATNUM;
    615    1.1  jdolecek 	} else
    616    1.1  jdolecek 		pmp->pm_flags |= MSDOSFS_FATMIRROR;
    617    1.1  jdolecek 
    618    1.1  jdolecek 	if (argp->flags & MSDOSFSMNT_GEMDOSFS) {
    619    1.1  jdolecek 		if (FAT32(pmp)) {
    620  1.112      maxv 			/* GEMDOS doesn't know FAT32. */
    621  1.115      maxv 			DPRINTF("FAT32 for GEMDOS");
    622    1.1  jdolecek 			error = EINVAL;
    623    1.1  jdolecek 			goto error_exit;
    624    1.1  jdolecek 		}
    625    1.1  jdolecek 
    626    1.1  jdolecek 		/*
    627    1.1  jdolecek 		 * Check a few values (could do some more):
    628  1.110      maxv 		 * - logical sector size: >= block size
    629  1.110      maxv 		 * - number of sectors:   <= size of partition
    630    1.1  jdolecek 		 */
    631  1.110      maxv 		if ((pmp->pm_BytesPerSec < GEMDOSFS_BSIZE) ||
    632  1.110      maxv 		    (pmp->pm_HugeSectors *
    633  1.110      maxv 		     (pmp->pm_BytesPerSec / GEMDOSFS_BSIZE) > psize)) {
    634  1.115      maxv 			DPRINTF("consistency checks for GEMDOS");
    635    1.1  jdolecek 			error = EINVAL;
    636    1.1  jdolecek 			goto error_exit;
    637    1.1  jdolecek 		}
    638    1.1  jdolecek 		/*
    639  1.100  jakllsch 		 * XXX - Many parts of the msdosfs driver seem to assume that
    640    1.1  jdolecek 		 * the number of bytes per logical sector (BytesPerSec) will
    641    1.1  jdolecek 		 * always be the same as the number of bytes per disk block
    642    1.1  jdolecek 		 * Let's pretend it is.
    643    1.1  jdolecek 		 */
    644  1.110      maxv 		BlkPerSec = pmp->pm_BytesPerSec / GEMDOSFS_BSIZE;
    645  1.110      maxv 		pmp->pm_BytesPerSec  = GEMDOSFS_BSIZE;
    646  1.110      maxv 		pmp->pm_HugeSectors *= BlkPerSec;
    647  1.110      maxv 		pmp->pm_HiddenSects *= BlkPerSec;
    648  1.110      maxv 		pmp->pm_ResSectors  *= BlkPerSec;
    649  1.110      maxv 		pmp->pm_Sectors     *= BlkPerSec;
    650  1.110      maxv 		pmp->pm_FATsecs     *= BlkPerSec;
    651  1.110      maxv 		SecPerClust         *= BlkPerSec;
    652    1.1  jdolecek 	}
    653   1.58     pooka 
    654   1.58     pooka 	/* Check that fs has nonzero FAT size */
    655   1.58     pooka 	if (pmp->pm_FATsecs == 0) {
    656  1.115      maxv 		DPRINTF("FATsecs is 0");
    657   1.58     pooka 		error = EINVAL;
    658   1.58     pooka 		goto error_exit;
    659   1.58     pooka 	}
    660   1.58     pooka 
    661    1.1  jdolecek 	pmp->pm_fatblk = pmp->pm_ResSectors;
    662    1.1  jdolecek 	if (FAT32(pmp)) {
    663  1.116  christos 		if (secsize < sizeof(*b710)) {
    664  1.117  christos 			DPRINTF("710 bootsec %u\n", secsize);
    665  1.116  christos 			error = EINVAL;
    666  1.116  christos 			goto error_exit;
    667  1.116  christos 		}
    668    1.1  jdolecek 		pmp->pm_rootdirblk = getulong(b710->bpbRootClust);
    669    1.1  jdolecek 		pmp->pm_firstcluster = pmp->pm_fatblk
    670    1.1  jdolecek 			+ (pmp->pm_FATs * pmp->pm_FATsecs);
    671    1.1  jdolecek 		pmp->pm_fsinfo = getushort(b710->bpbFSInfo);
    672    1.1  jdolecek 	} else {
    673    1.1  jdolecek 		pmp->pm_rootdirblk = pmp->pm_fatblk +
    674    1.1  jdolecek 			(pmp->pm_FATs * pmp->pm_FATsecs);
    675    1.1  jdolecek 		pmp->pm_rootdirsize = (pmp->pm_RootDirEnts * sizeof(struct direntry)
    676    1.1  jdolecek 				       + pmp->pm_BytesPerSec - 1)
    677    1.1  jdolecek 			/ pmp->pm_BytesPerSec;/* in sectors */
    678    1.1  jdolecek 		pmp->pm_firstcluster = pmp->pm_rootdirblk + pmp->pm_rootdirsize;
    679    1.1  jdolecek 	}
    680    1.1  jdolecek 
    681    1.1  jdolecek 	pmp->pm_nmbrofclusters = (pmp->pm_HugeSectors - pmp->pm_firstcluster) /
    682    1.1  jdolecek 	    SecPerClust;
    683    1.1  jdolecek 	pmp->pm_maxcluster = pmp->pm_nmbrofclusters + 1;
    684    1.1  jdolecek 	pmp->pm_fatsize = pmp->pm_FATsecs * pmp->pm_BytesPerSec;
    685    1.1  jdolecek 
    686    1.1  jdolecek 	if (argp->flags & MSDOSFSMNT_GEMDOSFS) {
    687   1.78   mlelstv 		if (pmp->pm_nmbrofclusters <= (0xff0 - 2)) {
    688    1.1  jdolecek 			pmp->pm_fatmask = FAT12_MASK;
    689    1.1  jdolecek 			pmp->pm_fatmult = 3;
    690    1.1  jdolecek 			pmp->pm_fatdiv = 2;
    691    1.1  jdolecek 		} else {
    692    1.1  jdolecek 			pmp->pm_fatmask = FAT16_MASK;
    693    1.1  jdolecek 			pmp->pm_fatmult = 2;
    694    1.1  jdolecek 			pmp->pm_fatdiv = 1;
    695    1.1  jdolecek 		}
    696    1.1  jdolecek 	} else if (pmp->pm_fatmask == 0) {
    697    1.1  jdolecek 		if (pmp->pm_maxcluster
    698    1.1  jdolecek 		    <= ((CLUST_RSRVD - CLUST_FIRST) & FAT12_MASK)) {
    699    1.1  jdolecek 			/*
    700    1.1  jdolecek 			 * This will usually be a floppy disk. This size makes
    701  1.100  jakllsch 			 * sure that one FAT entry will not be split across
    702    1.1  jdolecek 			 * multiple blocks.
    703    1.1  jdolecek 			 */
    704    1.1  jdolecek 			pmp->pm_fatmask = FAT12_MASK;
    705    1.1  jdolecek 			pmp->pm_fatmult = 3;
    706    1.1  jdolecek 			pmp->pm_fatdiv = 2;
    707    1.1  jdolecek 		} else {
    708    1.1  jdolecek 			pmp->pm_fatmask = FAT16_MASK;
    709    1.1  jdolecek 			pmp->pm_fatmult = 2;
    710    1.1  jdolecek 			pmp->pm_fatdiv = 1;
    711    1.1  jdolecek 		}
    712    1.1  jdolecek 	}
    713    1.1  jdolecek 	if (FAT12(pmp))
    714    1.1  jdolecek 		pmp->pm_fatblocksize = 3 * pmp->pm_BytesPerSec;
    715    1.1  jdolecek 	else
    716    1.1  jdolecek 		pmp->pm_fatblocksize = MAXBSIZE;
    717    1.1  jdolecek 
    718    1.1  jdolecek 	pmp->pm_fatblocksec = pmp->pm_fatblocksize / pmp->pm_BytesPerSec;
    719    1.1  jdolecek 	pmp->pm_bnshift = ffs(pmp->pm_BytesPerSec) - 1;
    720    1.1  jdolecek 
    721    1.1  jdolecek 	/*
    722    1.1  jdolecek 	 * Compute mask and shift value for isolating cluster relative byte
    723    1.1  jdolecek 	 * offsets and cluster numbers from a file offset.
    724    1.1  jdolecek 	 */
    725    1.1  jdolecek 	pmp->pm_bpcluster = SecPerClust * pmp->pm_BytesPerSec;
    726    1.1  jdolecek 	pmp->pm_crbomask = pmp->pm_bpcluster - 1;
    727    1.1  jdolecek 	pmp->pm_cnshift = ffs(pmp->pm_bpcluster) - 1;
    728    1.1  jdolecek 
    729    1.1  jdolecek 	/*
    730    1.1  jdolecek 	 * Check for valid cluster size
    731    1.1  jdolecek 	 * must be a power of 2
    732    1.1  jdolecek 	 */
    733    1.1  jdolecek 	if (pmp->pm_bpcluster ^ (1 << pmp->pm_cnshift)) {
    734  1.115      maxv 		DPRINTF("bpcluster %lu cnshift %lu", pmp->pm_bpcluster,
    735  1.115      maxv 		    pmp->pm_cnshift);
    736    1.1  jdolecek 		error = EINVAL;
    737    1.1  jdolecek 		goto error_exit;
    738    1.1  jdolecek 	}
    739    1.1  jdolecek 
    740    1.1  jdolecek 	/*
    741  1.101  jakllsch 	 * Cluster size must be within limit of MAXBSIZE.
    742  1.101  jakllsch 	 * Many FAT filesystems will not have clusters larger than
    743  1.101  jakllsch 	 * 32KiB due to limits in Windows versions before Vista.
    744  1.101  jakllsch 	 */
    745  1.101  jakllsch 	if (pmp->pm_bpcluster > MAXBSIZE) {
    746  1.115      maxv 		DPRINTF("bpcluster %lu > MAXBSIZE %d",
    747  1.115      maxv 		    pmp->pm_bpcluster, MAXBSIZE);
    748  1.101  jakllsch 		error = EINVAL;
    749  1.101  jakllsch 		goto error_exit;
    750  1.101  jakllsch 	}
    751  1.101  jakllsch 
    752  1.101  jakllsch 	/*
    753    1.1  jdolecek 	 * Release the bootsector buffer.
    754    1.1  jdolecek 	 */
    755   1.52        ad 	brelse(bp, BC_AGE);
    756    1.1  jdolecek 	bp = NULL;
    757    1.1  jdolecek 
    758    1.1  jdolecek 	/*
    759    1.1  jdolecek 	 * Check FSInfo.
    760    1.1  jdolecek 	 */
    761    1.1  jdolecek 	if (pmp->pm_fsinfo) {
    762    1.1  jdolecek 		struct fsinfo *fp;
    763  1.113  christos 		const int rdsz = roundup(sizeof(*fp), pmp->pm_BytesPerSec);
    764    1.1  jdolecek 
    765   1.40       scw 		/*
    766   1.40       scw 		 * XXX	If the fsinfo block is stored on media with
    767   1.40       scw 		 *	2KB or larger sectors, is the fsinfo structure
    768   1.40       scw 		 *	padded at the end or in the middle?
    769   1.40       scw 		 */
    770   1.40       scw 		if ((error = bread(devvp, de_bn2kb(pmp, pmp->pm_fsinfo),
    771  1.118      maxv 		    rdsz, 0, &bp)) != 0)
    772    1.1  jdolecek 			goto error_exit;
    773    1.1  jdolecek 		fp = (struct fsinfo *)bp->b_data;
    774    1.1  jdolecek 		if (!memcmp(fp->fsisig1, "RRaA", 4)
    775    1.1  jdolecek 		    && !memcmp(fp->fsisig2, "rrAa", 4)
    776    1.1  jdolecek 		    && !memcmp(fp->fsisig3, "\0\0\125\252", 4)
    777    1.1  jdolecek 		    && !memcmp(fp->fsisig4, "\0\0\125\252", 4))
    778    1.1  jdolecek 			pmp->pm_nxtfree = getulong(fp->fsinxtfree);
    779    1.1  jdolecek 		else
    780    1.1  jdolecek 			pmp->pm_fsinfo = 0;
    781   1.52        ad 		brelse(bp, 0);
    782    1.1  jdolecek 		bp = NULL;
    783    1.1  jdolecek 	}
    784    1.1  jdolecek 
    785    1.1  jdolecek 	/*
    786    1.1  jdolecek 	 * Check and validate (or perhaps invalidate?) the fsinfo structure?
    787    1.1  jdolecek 	 * XXX
    788    1.1  jdolecek 	 */
    789    1.1  jdolecek 	if (pmp->pm_fsinfo) {
    790   1.99  jakllsch 		if ((pmp->pm_nxtfree == 0xffffffffUL) ||
    791   1.99  jakllsch 		    (pmp->pm_nxtfree > pmp->pm_maxcluster))
    792    1.1  jdolecek 			pmp->pm_fsinfo = 0;
    793    1.1  jdolecek 	}
    794    1.1  jdolecek 
    795    1.1  jdolecek 	/*
    796    1.1  jdolecek 	 * Allocate memory for the bitmap of allocated clusters, and then
    797    1.1  jdolecek 	 * fill it in.
    798    1.1  jdolecek 	 */
    799   1.97  jakllsch 	pmp->pm_inusemap = malloc(((pmp->pm_maxcluster + N_INUSEBITS)
    800    1.1  jdolecek 				   / N_INUSEBITS)
    801    1.1  jdolecek 				  * sizeof(*pmp->pm_inusemap),
    802    1.1  jdolecek 				  M_MSDOSFSFAT, M_WAITOK);
    803    1.1  jdolecek 
    804    1.1  jdolecek 	/*
    805    1.1  jdolecek 	 * fillinusemap() needs pm_devvp.
    806    1.1  jdolecek 	 */
    807    1.1  jdolecek 	pmp->pm_dev = dev;
    808    1.1  jdolecek 	pmp->pm_devvp = devvp;
    809    1.1  jdolecek 
    810    1.1  jdolecek 	/*
    811    1.1  jdolecek 	 * Have the inuse map filled in.
    812    1.1  jdolecek 	 */
    813   1.42  christos 	if ((error = fillinusemap(pmp)) != 0) {
    814  1.115      maxv 		DPRINTF("fillinusemap %d", error);
    815    1.1  jdolecek 		goto error_exit;
    816   1.42  christos 	}
    817    1.1  jdolecek 
    818    1.1  jdolecek 	/*
    819  1.100  jakllsch 	 * If they want FAT updates to be synchronous then let them suffer
    820    1.1  jdolecek 	 * the performance degradation in exchange for the on disk copy of
    821  1.100  jakllsch 	 * the FAT being correct just about all the time.  I suppose this
    822    1.1  jdolecek 	 * would be a good thing to turn on if the kernel is still flakey.
    823    1.1  jdolecek 	 */
    824    1.1  jdolecek 	if (mp->mnt_flag & MNT_SYNCHRONOUS)
    825    1.1  jdolecek 		pmp->pm_flags |= MSDOSFSMNT_WAITONFAT;
    826    1.1  jdolecek 
    827    1.1  jdolecek 	/*
    828    1.1  jdolecek 	 * Finish up.
    829    1.1  jdolecek 	 */
    830    1.1  jdolecek 	if (ronly)
    831    1.1  jdolecek 		pmp->pm_flags |= MSDOSFSMNT_RONLY;
    832    1.1  jdolecek 	else
    833    1.1  jdolecek 		pmp->pm_fmod = 1;
    834    1.1  jdolecek 	mp->mnt_data = pmp;
    835   1.20  jdolecek 	mp->mnt_stat.f_fsidx.__fsid_val[0] = (long)dev;
    836   1.20  jdolecek 	mp->mnt_stat.f_fsidx.__fsid_val[1] = makefstype(MOUNT_MSDOS);
    837   1.20  jdolecek 	mp->mnt_stat.f_fsid = mp->mnt_stat.f_fsidx.__fsid_val[0];
    838   1.20  jdolecek 	mp->mnt_stat.f_namemax = MSDOSFS_NAMEMAX(pmp);
    839    1.1  jdolecek 	mp->mnt_flag |= MNT_LOCAL;
    840    1.1  jdolecek 	mp->mnt_dev_bshift = pmp->pm_bnshift;
    841    1.1  jdolecek 	mp->mnt_fs_bshift = pmp->pm_cnshift;
    842    1.1  jdolecek 
    843    1.1  jdolecek 	/*
    844    1.1  jdolecek 	 * If we ever do quotas for DOS filesystems this would be a place
    845    1.1  jdolecek 	 * to fill in the info in the msdosfsmount structure. You dolt,
    846    1.1  jdolecek 	 * quotas on dos filesystems make no sense because files have no
    847    1.1  jdolecek 	 * owners on dos filesystems. of course there is some empty space
    848    1.1  jdolecek 	 * in the directory entry where we could put uid's and gid's.
    849    1.1  jdolecek 	 */
    850   1.69     pooka 
    851  1.102   hannken 	spec_node_setmountedfs(devvp, mp);
    852    1.1  jdolecek 
    853    1.1  jdolecek 	return (0);
    854    1.1  jdolecek 
    855   1.80     pooka error_exit:
    856    1.1  jdolecek 	if (bp)
    857   1.52        ad 		brelse(bp, BC_AGE);
    858    1.1  jdolecek 	if (pmp) {
    859    1.1  jdolecek 		if (pmp->pm_inusemap)
    860    1.1  jdolecek 			free(pmp->pm_inusemap, M_MSDOSFSFAT);
    861    1.1  jdolecek 		free(pmp, M_MSDOSFSMNT);
    862    1.1  jdolecek 		mp->mnt_data = NULL;
    863    1.1  jdolecek 	}
    864    1.1  jdolecek 	return (error);
    865    1.1  jdolecek }
    866    1.1  jdolecek 
    867    1.1  jdolecek int
    868   1.54     pooka msdosfs_start(struct mount *mp, int flags)
    869    1.1  jdolecek {
    870    1.1  jdolecek 
    871    1.1  jdolecek 	return (0);
    872    1.1  jdolecek }
    873    1.1  jdolecek 
    874    1.1  jdolecek /*
    875    1.1  jdolecek  * Unmount the filesystem described by mp.
    876    1.1  jdolecek  */
    877    1.1  jdolecek int
    878   1.72       dsl msdosfs_unmount(struct mount *mp, int mntflags)
    879    1.1  jdolecek {
    880    1.1  jdolecek 	struct msdosfsmount *pmp;
    881    1.1  jdolecek 	int error, flags;
    882    1.1  jdolecek 
    883    1.1  jdolecek 	flags = 0;
    884    1.1  jdolecek 	if (mntflags & MNT_FORCE)
    885    1.1  jdolecek 		flags |= FORCECLOSE;
    886    1.1  jdolecek 	if ((error = vflush(mp, NULLVP, flags)) != 0)
    887    1.1  jdolecek 		return (error);
    888    1.1  jdolecek 	pmp = VFSTOMSDOSFS(mp);
    889    1.1  jdolecek 	if (pmp->pm_devvp->v_type != VBAD)
    890  1.102   hannken 		spec_node_setmountedfs(pmp->pm_devvp, NULL);
    891    1.1  jdolecek #ifdef MSDOSFS_DEBUG
    892    1.1  jdolecek 	{
    893    1.1  jdolecek 		struct vnode *vp = pmp->pm_devvp;
    894    1.1  jdolecek 
    895    1.1  jdolecek 		printf("msdosfs_umount(): just before calling VOP_CLOSE()\n");
    896   1.64        ad 		printf("flag %08x, usecount %d, writecount %d, holdcnt %d\n",
    897   1.53        ad 		    vp->v_vflag | vp->v_iflag | vp->v_uflag, vp->v_usecount,
    898   1.53        ad 		    vp->v_writecount, vp->v_holdcnt);
    899   1.25      jmmv 		printf("mount %p, op %p\n",
    900   1.25      jmmv 		    vp->v_mount, vp->v_op);
    901    1.1  jdolecek 		printf("cleanblkhd %p, dirtyblkhd %p, numoutput %d, type %d\n",
    902    1.1  jdolecek 		    vp->v_cleanblkhd.lh_first,
    903    1.1  jdolecek 		    vp->v_dirtyblkhd.lh_first,
    904    1.1  jdolecek 		    vp->v_numoutput, vp->v_type);
    905    1.1  jdolecek 		printf("union %p, tag %d, data[0] %08x, data[1] %08x\n",
    906    1.1  jdolecek 		    vp->v_socket, vp->v_tag,
    907    1.1  jdolecek 		    ((u_int *)vp->v_data)[0],
    908    1.1  jdolecek 		    ((u_int *)vp->v_data)[1]);
    909    1.1  jdolecek 	}
    910    1.1  jdolecek #endif
    911    1.1  jdolecek 	vn_lock(pmp->pm_devvp, LK_EXCLUSIVE | LK_RETRY);
    912   1.80     pooka 	(void) VOP_CLOSE(pmp->pm_devvp,
    913   1.54     pooka 	    pmp->pm_flags & MSDOSFSMNT_RONLY ? FREAD : FREAD|FWRITE, NOCRED);
    914    1.1  jdolecek 	vput(pmp->pm_devvp);
    915   1.90   hannken 	msdosfs_fh_destroy(pmp);
    916    1.1  jdolecek 	free(pmp->pm_inusemap, M_MSDOSFSFAT);
    917    1.1  jdolecek 	free(pmp, M_MSDOSFSMNT);
    918    1.1  jdolecek 	mp->mnt_data = NULL;
    919    1.1  jdolecek 	mp->mnt_flag &= ~MNT_LOCAL;
    920   1.80     pooka 	return (0);
    921    1.1  jdolecek }
    922    1.1  jdolecek 
    923    1.1  jdolecek int
    924   1.72       dsl msdosfs_root(struct mount *mp, struct vnode **vpp)
    925    1.1  jdolecek {
    926    1.1  jdolecek 	struct msdosfsmount *pmp = VFSTOMSDOSFS(mp);
    927    1.1  jdolecek 	int error;
    928    1.1  jdolecek 
    929    1.1  jdolecek #ifdef MSDOSFS_DEBUG
    930    1.1  jdolecek 	printf("msdosfs_root(); mp %p, pmp %p\n", mp, pmp);
    931    1.1  jdolecek #endif
    932  1.109   hannken 	if ((error = deget(pmp, MSDOSFSROOT, MSDOSFSROOT_OFS, vpp)) != 0)
    933  1.109   hannken 		return error;
    934  1.109   hannken 	error = vn_lock(*vpp, LK_EXCLUSIVE);
    935  1.109   hannken 	if (error) {
    936  1.109   hannken 		vrele(*vpp);
    937  1.109   hannken 		*vpp = NULL;
    938  1.109   hannken 		return error;
    939  1.109   hannken 	}
    940  1.109   hannken 	return 0;
    941    1.1  jdolecek }
    942    1.1  jdolecek 
    943    1.1  jdolecek int
    944   1.54     pooka msdosfs_statvfs(struct mount *mp, struct statvfs *sbp)
    945    1.1  jdolecek {
    946    1.1  jdolecek 	struct msdosfsmount *pmp;
    947    1.1  jdolecek 
    948    1.1  jdolecek 	pmp = VFSTOMSDOSFS(mp);
    949    1.1  jdolecek 	sbp->f_bsize = pmp->pm_bpcluster;
    950   1.14  christos 	sbp->f_frsize = sbp->f_bsize;
    951    1.1  jdolecek 	sbp->f_iosize = pmp->pm_bpcluster;
    952    1.1  jdolecek 	sbp->f_blocks = pmp->pm_nmbrofclusters;
    953    1.1  jdolecek 	sbp->f_bfree = pmp->pm_freeclustercount;
    954    1.1  jdolecek 	sbp->f_bavail = pmp->pm_freeclustercount;
    955   1.14  christos 	sbp->f_bresvd = 0;
    956    1.1  jdolecek 	sbp->f_files = pmp->pm_RootDirEnts;			/* XXX */
    957    1.1  jdolecek 	sbp->f_ffree = 0;	/* what to put in here? */
    958   1.14  christos 	sbp->f_favail = 0;	/* what to put in here? */
    959   1.14  christos 	sbp->f_fresvd = 0;
    960   1.14  christos 	copy_statvfs_info(sbp, mp);
    961    1.1  jdolecek 	return (0);
    962    1.1  jdolecek }
    963    1.1  jdolecek 
    964  1.108  christos struct msdosfs_sync_ctx {
    965  1.108  christos 	int waitfor;
    966  1.108  christos };
    967  1.108  christos 
    968  1.108  christos static bool
    969  1.108  christos msdosfs_sync_selector(void *cl, struct vnode *vp)
    970  1.108  christos {
    971  1.108  christos 	struct msdosfs_sync_ctx *c = cl;
    972  1.108  christos 	struct denode *dep;
    973  1.108  christos 
    974  1.125  riastrad 	KASSERT(mutex_owned(vp->v_interlock));
    975  1.125  riastrad 
    976  1.108  christos 	dep = VTODE(vp);
    977  1.108  christos 	if (c->waitfor == MNT_LAZY || vp->v_type == VNON ||
    978  1.108  christos 	    dep == NULL || (((dep->de_flag &
    979  1.108  christos 	    (DE_ACCESS | DE_CREATE | DE_UPDATE | DE_MODIFIED)) == 0) &&
    980  1.108  christos 	     (LIST_EMPTY(&vp->v_dirtyblkhd) &&
    981  1.108  christos 	      UVM_OBJ_IS_CLEAN(&vp->v_uobj))))
    982  1.108  christos 		return false;
    983  1.108  christos 	return true;
    984  1.108  christos }
    985  1.108  christos 
    986    1.1  jdolecek int
    987   1.72       dsl msdosfs_sync(struct mount *mp, int waitfor, kauth_cred_t cred)
    988    1.1  jdolecek {
    989  1.105   hannken 	struct vnode *vp;
    990  1.105   hannken 	struct vnode_iterator *marker;
    991    1.1  jdolecek 	struct msdosfsmount *pmp = VFSTOMSDOSFS(mp);
    992   1.89   hannken 	int error, allerror = 0;
    993  1.108  christos 	struct msdosfs_sync_ctx ctx;
    994    1.1  jdolecek 
    995    1.1  jdolecek 	/*
    996  1.100  jakllsch 	 * If we ever switch to not updating all of the FATs all the time,
    997    1.1  jdolecek 	 * this would be the place to update them from the first one.
    998    1.1  jdolecek 	 */
    999    1.1  jdolecek 	if (pmp->pm_fmod != 0) {
   1000    1.1  jdolecek 		if (pmp->pm_flags & MSDOSFSMNT_RONLY)
   1001    1.1  jdolecek 			panic("msdosfs_sync: rofs mod");
   1002    1.1  jdolecek 		else {
   1003  1.100  jakllsch 			/* update FATs here */
   1004    1.1  jdolecek 		}
   1005    1.1  jdolecek 	}
   1006    1.1  jdolecek 	/*
   1007    1.1  jdolecek 	 * Write back each (modified) denode.
   1008    1.1  jdolecek 	 */
   1009  1.105   hannken 	vfs_vnode_iterator_init(mp, &marker);
   1010  1.108  christos 	ctx.waitfor = waitfor;
   1011  1.108  christos 	while ((vp = vfs_vnode_iterator_next(marker, msdosfs_sync_selector,
   1012  1.108  christos 	    &ctx)))
   1013  1.108  christos 	{
   1014  1.105   hannken 		error = vn_lock(vp, LK_EXCLUSIVE);
   1015  1.105   hannken 		if (error) {
   1016  1.105   hannken 			vrele(vp);
   1017   1.56        ad 			continue;
   1018  1.105   hannken 		}
   1019    1.1  jdolecek 		if ((error = VOP_FSYNC(vp, cred,
   1020   1.54     pooka 		    waitfor == MNT_WAIT ? FSYNC_WAIT : 0, 0, 0)) != 0)
   1021    1.1  jdolecek 			allerror = error;
   1022   1.89   hannken 		vput(vp);
   1023    1.1  jdolecek 	}
   1024  1.105   hannken 	vfs_vnode_iterator_destroy(marker);
   1025   1.56        ad 
   1026    1.1  jdolecek 	/*
   1027    1.1  jdolecek 	 * Force stale file system control information to be flushed.
   1028    1.1  jdolecek 	 */
   1029  1.120   hannken 	vn_lock(pmp->pm_devvp, LK_EXCLUSIVE | LK_RETRY);
   1030    1.1  jdolecek 	if ((error = VOP_FSYNC(pmp->pm_devvp, cred,
   1031   1.54     pooka 	    waitfor == MNT_WAIT ? FSYNC_WAIT : 0, 0, 0)) != 0)
   1032    1.1  jdolecek 		allerror = error;
   1033  1.120   hannken 	VOP_UNLOCK(pmp->pm_devvp);
   1034    1.1  jdolecek 	return (allerror);
   1035    1.1  jdolecek }
   1036    1.1  jdolecek 
   1037    1.1  jdolecek int
   1038   1.72       dsl msdosfs_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp)
   1039    1.1  jdolecek {
   1040    1.1  jdolecek 	struct msdosfsmount *pmp = VFSTOMSDOSFS(mp);
   1041   1.32    martin 	struct defid defh;
   1042   1.90   hannken 	uint32_t gen;
   1043    1.1  jdolecek 	int error;
   1044    1.1  jdolecek 
   1045   1.42  christos 	if (fhp->fid_len != sizeof(struct defid)) {
   1046  1.115      maxv 		DPRINTF("fid_len %d %zd", fhp->fid_len, sizeof(struct defid));
   1047   1.32    martin 		return EINVAL;
   1048   1.42  christos 	}
   1049   1.32    martin 	memcpy(&defh, fhp, sizeof(defh));
   1050   1.90   hannken 	error = msdosfs_fh_lookup(pmp, defh.defid_dirclust, defh.defid_dirofs,
   1051   1.90   hannken 	    &gen);
   1052   1.90   hannken 	if (error == 0 && gen != defh.defid_gen)
   1053   1.90   hannken 		error = ESTALE;
   1054   1.90   hannken 	if (error) {
   1055   1.90   hannken 		*vpp = NULLVP;
   1056   1.90   hannken 		return error;
   1057   1.90   hannken 	}
   1058  1.109   hannken 	error = deget(pmp, defh.defid_dirclust, defh.defid_dirofs, vpp);
   1059    1.1  jdolecek 	if (error) {
   1060  1.115      maxv 		DPRINTF("deget %d", error);
   1061    1.1  jdolecek 		*vpp = NULLVP;
   1062  1.109   hannken 		return error;
   1063  1.109   hannken 	}
   1064  1.109   hannken 	error = vn_lock(*vpp, LK_EXCLUSIVE);
   1065  1.109   hannken 	if (error) {
   1066  1.109   hannken 		vrele(*vpp);
   1067  1.109   hannken 		*vpp = NULLVP;
   1068  1.109   hannken 		return error;
   1069    1.1  jdolecek 	}
   1070  1.109   hannken 	return 0;
   1071    1.1  jdolecek }
   1072    1.1  jdolecek 
   1073    1.1  jdolecek int
   1074   1.72       dsl msdosfs_vptofh(struct vnode *vp, struct fid *fhp, size_t *fh_size)
   1075    1.1  jdolecek {
   1076   1.90   hannken 	struct msdosfsmount *pmp = VFSTOMSDOSFS(vp->v_mount);
   1077    1.1  jdolecek 	struct denode *dep;
   1078   1.32    martin 	struct defid defh;
   1079   1.90   hannken 	int error;
   1080    1.1  jdolecek 
   1081   1.32    martin 	if (*fh_size < sizeof(struct defid)) {
   1082   1.32    martin 		*fh_size = sizeof(struct defid);
   1083   1.32    martin 		return E2BIG;
   1084   1.32    martin 	}
   1085   1.32    martin 	*fh_size = sizeof(struct defid);
   1086    1.1  jdolecek 	dep = VTODE(vp);
   1087   1.32    martin 	memset(&defh, 0, sizeof(defh));
   1088   1.32    martin 	defh.defid_len = sizeof(struct defid);
   1089   1.32    martin 	defh.defid_dirclust = dep->de_dirclust;
   1090   1.32    martin 	defh.defid_dirofs = dep->de_diroffset;
   1091   1.90   hannken 	error = msdosfs_fh_enter(pmp, dep->de_dirclust, dep->de_diroffset,
   1092   1.90   hannken 	     &defh.defid_gen);
   1093   1.90   hannken 	if (error == 0)
   1094   1.90   hannken 		memcpy(fhp, &defh, sizeof(defh));
   1095   1.90   hannken 	return error;
   1096    1.1  jdolecek }
   1097    1.1  jdolecek 
   1098    1.1  jdolecek int
   1099   1.39  christos msdosfs_vget(struct mount *mp, ino_t ino,
   1100   1.39  christos     struct vnode **vpp)
   1101    1.1  jdolecek {
   1102    1.1  jdolecek 
   1103    1.1  jdolecek 	return (EOPNOTSUPP);
   1104    1.1  jdolecek }
   1105