141d2e3e0SPoul-Henning Kamp /* $Id: msdosfs_vfsops.c,v 1.48 1999/08/23 21:07:13 bde Exp $ */ 2952a6212SJordan K. Hubbard /* $NetBSD: msdosfs_vfsops.c,v 1.51 1997/11/17 15:36:58 ws Exp $ */ 327a0bc89SDoug Rabson 427a0bc89SDoug Rabson /*- 5952a6212SJordan K. Hubbard * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. 6952a6212SJordan K. Hubbard * Copyright (C) 1994, 1995, 1997 TooLs GmbH. 727a0bc89SDoug Rabson * All rights reserved. 827a0bc89SDoug Rabson * Original code by Paul Popelka (paulp@uts.amdahl.com) (see below). 927a0bc89SDoug Rabson * 1027a0bc89SDoug Rabson * Redistribution and use in source and binary forms, with or without 1127a0bc89SDoug Rabson * modification, are permitted provided that the following conditions 1227a0bc89SDoug Rabson * are met: 1327a0bc89SDoug Rabson * 1. Redistributions of source code must retain the above copyright 1427a0bc89SDoug Rabson * notice, this list of conditions and the following disclaimer. 1527a0bc89SDoug Rabson * 2. Redistributions in binary form must reproduce the above copyright 1627a0bc89SDoug Rabson * notice, this list of conditions and the following disclaimer in the 1727a0bc89SDoug Rabson * documentation and/or other materials provided with the distribution. 1827a0bc89SDoug Rabson * 3. All advertising materials mentioning features or use of this software 1927a0bc89SDoug Rabson * must display the following acknowledgement: 2027a0bc89SDoug Rabson * This product includes software developed by TooLs GmbH. 2127a0bc89SDoug Rabson * 4. The name of TooLs GmbH may not be used to endorse or promote products 2227a0bc89SDoug Rabson * derived from this software without specific prior written permission. 2327a0bc89SDoug Rabson * 2427a0bc89SDoug Rabson * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR 2527a0bc89SDoug Rabson * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 2627a0bc89SDoug Rabson * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2727a0bc89SDoug Rabson * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2827a0bc89SDoug Rabson * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 2927a0bc89SDoug Rabson * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 3027a0bc89SDoug Rabson * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 3127a0bc89SDoug Rabson * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 3227a0bc89SDoug Rabson * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 3327a0bc89SDoug Rabson * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3427a0bc89SDoug Rabson */ 3527a0bc89SDoug Rabson /* 3627a0bc89SDoug Rabson * Written by Paul Popelka (paulp@uts.amdahl.com) 3727a0bc89SDoug Rabson * 3827a0bc89SDoug Rabson * You can do anything you want with this software, just don't say you wrote 3927a0bc89SDoug Rabson * it, and don't remove this notice. 4027a0bc89SDoug Rabson * 4127a0bc89SDoug Rabson * This software is provided "as is". 4227a0bc89SDoug Rabson * 4327a0bc89SDoug Rabson * The author supplies this software to be publicly redistributed on the 4427a0bc89SDoug Rabson * understanding that the author is not responsible for the correct 4527a0bc89SDoug Rabson * functioning of this software in any circumstances and is not liable for 4627a0bc89SDoug Rabson * any damages caused by this software. 4727a0bc89SDoug Rabson * 4827a0bc89SDoug Rabson * October 1992 4927a0bc89SDoug Rabson */ 5027a0bc89SDoug Rabson 5127a0bc89SDoug Rabson #include <sys/param.h> 5227a0bc89SDoug Rabson #include <sys/systm.h> 5365baf8f0SBruce Evans #include <sys/conf.h> 5427a0bc89SDoug Rabson #include <sys/namei.h> 5527a0bc89SDoug Rabson #include <sys/proc.h> 5627a0bc89SDoug Rabson #include <sys/kernel.h> 5727a0bc89SDoug Rabson #include <sys/vnode.h> 5827a0bc89SDoug Rabson #include <sys/mount.h> 5927a0bc89SDoug Rabson #include <sys/buf.h> 603ac4d1efSBruce Evans #include <sys/fcntl.h> 6127a0bc89SDoug Rabson #include <sys/malloc.h> 62952a6212SJordan K. Hubbard #include <sys/stat.h> /* defines ALLPERMS */ 6327a0bc89SDoug Rabson 6427a0bc89SDoug Rabson #include <msdosfs/bpb.h> 6527a0bc89SDoug Rabson #include <msdosfs/bootsect.h> 6627a0bc89SDoug Rabson #include <msdosfs/direntry.h> 6727a0bc89SDoug Rabson #include <msdosfs/denode.h> 6827a0bc89SDoug Rabson #include <msdosfs/msdosfsmount.h> 6927a0bc89SDoug Rabson #include <msdosfs/fat.h> 7027a0bc89SDoug Rabson 71a1c995b6SPoul-Henning Kamp MALLOC_DEFINE(M_MSDOSFSMNT, "MSDOSFS mount", "MSDOSFS mount structure"); 72a1c995b6SPoul-Henning Kamp static MALLOC_DEFINE(M_MSDOSFSFAT, "MSDOSFS FAT", "MSDOSFS file allocation table"); 7355166637SPoul-Henning Kamp 74952a6212SJordan K. Hubbard static int update_mp __P((struct mount *mp, struct msdosfs_args *argp)); 75af482601SBruce Evans static int mountmsdosfs __P((struct vnode *devvp, struct mount *mp, 76952a6212SJordan K. Hubbard struct proc *p, struct msdosfs_args *argp)); 77af482601SBruce Evans static int msdosfs_fhtovp __P((struct mount *, struct fid *, 7857bf258eSGarrett Wollman struct sockaddr *, struct vnode **, int *, 79af482601SBruce Evans struct ucred **)); 80af482601SBruce Evans static int msdosfs_mount __P((struct mount *, char *, caddr_t, 81af482601SBruce Evans struct nameidata *, struct proc *)); 82af482601SBruce Evans static int msdosfs_quotactl __P((struct mount *, int, uid_t, caddr_t, 83af482601SBruce Evans struct proc *)); 84af482601SBruce Evans static int msdosfs_root __P((struct mount *, struct vnode **)); 85af482601SBruce Evans static int msdosfs_start __P((struct mount *, int, struct proc *)); 86af482601SBruce Evans static int msdosfs_statfs __P((struct mount *, struct statfs *, 87af482601SBruce Evans struct proc *)); 88af482601SBruce Evans static int msdosfs_sync __P((struct mount *, int, struct ucred *, 89af482601SBruce Evans struct proc *)); 90af482601SBruce Evans static int msdosfs_unmount __P((struct mount *, int, struct proc *)); 91af482601SBruce Evans static int msdosfs_vget __P((struct mount *mp, ino_t ino, 92af482601SBruce Evans struct vnode **vpp)); 93af482601SBruce Evans static int msdosfs_vptofh __P((struct vnode *, struct fid *)); 94af482601SBruce Evans 95952a6212SJordan K. Hubbard static int 96952a6212SJordan K. Hubbard update_mp(mp, argp) 97952a6212SJordan K. Hubbard struct mount *mp; 98952a6212SJordan K. Hubbard struct msdosfs_args *argp; 99952a6212SJordan K. Hubbard { 100952a6212SJordan K. Hubbard struct msdosfsmount *pmp = VFSTOMSDOSFS(mp); 101952a6212SJordan K. Hubbard int error; 102952a6212SJordan K. Hubbard 103952a6212SJordan K. Hubbard pmp->pm_gid = argp->gid; 104952a6212SJordan K. Hubbard pmp->pm_uid = argp->uid; 105952a6212SJordan K. Hubbard pmp->pm_mask = argp->mask & ALLPERMS; 106952a6212SJordan K. Hubbard pmp->pm_flags |= argp->flags & MSDOSFSMNT_MNTOPT; 1077391f611SAndrey A. Chernov if (pmp->pm_flags & MSDOSFSMNT_U2WTABLE) { 10813df76f2SAndrey A. Chernov bcopy(argp->u2w, pmp->pm_u2w, sizeof(pmp->pm_u2w)); 1097391f611SAndrey A. Chernov bcopy(argp->d2u, pmp->pm_d2u, sizeof(pmp->pm_d2u)); 1107391f611SAndrey A. Chernov bcopy(argp->u2d, pmp->pm_u2d, sizeof(pmp->pm_u2d)); 1117391f611SAndrey A. Chernov } 1127391f611SAndrey A. Chernov if (pmp->pm_flags & MSDOSFSMNT_ULTABLE) { 11364fb806cSAndrey A. Chernov bcopy(argp->ul, pmp->pm_ul, sizeof(pmp->pm_ul)); 1147391f611SAndrey A. Chernov bcopy(argp->lu, pmp->pm_lu, sizeof(pmp->pm_lu)); 1157391f611SAndrey A. Chernov } 116952a6212SJordan K. Hubbard 117952a6212SJordan K. Hubbard #ifndef __FreeBSD__ 118952a6212SJordan K. Hubbard /* 119952a6212SJordan K. Hubbard * GEMDOS knows nothing (yet) about win95 120952a6212SJordan K. Hubbard */ 121952a6212SJordan K. Hubbard if (pmp->pm_flags & MSDOSFSMNT_GEMDOSFS) 122952a6212SJordan K. Hubbard pmp->pm_flags |= MSDOSFSMNT_NOWIN95; 123952a6212SJordan K. Hubbard #endif 124952a6212SJordan K. Hubbard 125952a6212SJordan K. Hubbard if (pmp->pm_flags & MSDOSFSMNT_NOWIN95) 126952a6212SJordan K. Hubbard pmp->pm_flags |= MSDOSFSMNT_SHORTNAME; 127952a6212SJordan K. Hubbard else if (!(pmp->pm_flags & 128952a6212SJordan K. Hubbard (MSDOSFSMNT_SHORTNAME | MSDOSFSMNT_LONGNAME))) { 129952a6212SJordan K. Hubbard struct vnode *rootvp; 130952a6212SJordan K. Hubbard 131952a6212SJordan K. Hubbard /* 132952a6212SJordan K. Hubbard * Try to divine whether to support Win'95 long filenames 133952a6212SJordan K. Hubbard */ 134952a6212SJordan K. Hubbard if (FAT32(pmp)) 135952a6212SJordan K. Hubbard pmp->pm_flags |= MSDOSFSMNT_LONGNAME; 136952a6212SJordan K. Hubbard else { 137952a6212SJordan K. Hubbard if ((error = msdosfs_root(mp, &rootvp)) != 0) 138952a6212SJordan K. Hubbard return error; 139952a6212SJordan K. Hubbard pmp->pm_flags |= findwin95(VTODE(rootvp)) 140952a6212SJordan K. Hubbard ? MSDOSFSMNT_LONGNAME 141952a6212SJordan K. Hubbard : MSDOSFSMNT_SHORTNAME; 142952a6212SJordan K. Hubbard vput(rootvp); 143952a6212SJordan K. Hubbard } 144952a6212SJordan K. Hubbard } 145952a6212SJordan K. Hubbard return 0; 146952a6212SJordan K. Hubbard } 147952a6212SJordan K. Hubbard 148952a6212SJordan K. Hubbard #ifndef __FreeBSD__ 149952a6212SJordan K. Hubbard int 150952a6212SJordan K. Hubbard msdosfs_mountroot() 151952a6212SJordan K. Hubbard { 152952a6212SJordan K. Hubbard register struct mount *mp; 153952a6212SJordan K. Hubbard struct proc *p = curproc; /* XXX */ 154952a6212SJordan K. Hubbard size_t size; 155952a6212SJordan K. Hubbard int error; 156952a6212SJordan K. Hubbard struct msdosfs_args args; 157952a6212SJordan K. Hubbard 158952a6212SJordan K. Hubbard if (root_device->dv_class != DV_DISK) 159952a6212SJordan K. Hubbard return (ENODEV); 160952a6212SJordan K. Hubbard 161952a6212SJordan K. Hubbard /* 162952a6212SJordan K. Hubbard * Get vnodes for swapdev and rootdev. 163952a6212SJordan K. Hubbard */ 164952a6212SJordan K. Hubbard if (bdevvp(rootdev, &rootvp)) 165952a6212SJordan K. Hubbard panic("msdosfs_mountroot: can't setup rootvp"); 166952a6212SJordan K. Hubbard 167952a6212SJordan K. Hubbard mp = malloc((u_long)sizeof(struct mount), M_MOUNT, M_WAITOK); 168952a6212SJordan K. Hubbard bzero((char *)mp, (u_long)sizeof(struct mount)); 169952a6212SJordan K. Hubbard mp->mnt_op = &msdosfs_vfsops; 170952a6212SJordan K. Hubbard mp->mnt_flag = 0; 171952a6212SJordan K. Hubbard LIST_INIT(&mp->mnt_vnodelist); 172952a6212SJordan K. Hubbard 173952a6212SJordan K. Hubbard args.flags = 0; 174952a6212SJordan K. Hubbard args.uid = 0; 175952a6212SJordan K. Hubbard args.gid = 0; 176952a6212SJordan K. Hubbard args.mask = 0777; 177952a6212SJordan K. Hubbard 178952a6212SJordan K. Hubbard if ((error = mountmsdosfs(rootvp, mp, p, &args)) != 0) { 179952a6212SJordan K. Hubbard free(mp, M_MOUNT); 180952a6212SJordan K. Hubbard return (error); 181952a6212SJordan K. Hubbard } 182952a6212SJordan K. Hubbard 183952a6212SJordan K. Hubbard if ((error = update_mp(mp, &args)) != 0) { 184952a6212SJordan K. Hubbard (void)msdosfs_unmount(mp, 0, p); 185952a6212SJordan K. Hubbard free(mp, M_MOUNT); 186952a6212SJordan K. Hubbard return (error); 187952a6212SJordan K. Hubbard } 188952a6212SJordan K. Hubbard 189952a6212SJordan K. Hubbard if ((error = vfs_lock(mp)) != 0) { 190952a6212SJordan K. Hubbard (void)msdosfs_unmount(mp, 0, p); 191952a6212SJordan K. Hubbard free(mp, M_MOUNT); 192952a6212SJordan K. Hubbard return (error); 193952a6212SJordan K. Hubbard } 194952a6212SJordan K. Hubbard 195952a6212SJordan K. Hubbard CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list); 196952a6212SJordan K. Hubbard mp->mnt_vnodecovered = NULLVP; 197952a6212SJordan K. Hubbard (void) copystr("/", mp->mnt_stat.f_mntonname, MNAMELEN - 1, 198952a6212SJordan K. Hubbard &size); 199952a6212SJordan K. Hubbard bzero(mp->mnt_stat.f_mntonname + size, MNAMELEN - size); 200952a6212SJordan K. Hubbard (void) copystr(ROOTNAME, mp->mnt_stat.f_mntfromname, MNAMELEN - 1, 201952a6212SJordan K. Hubbard &size); 202952a6212SJordan K. Hubbard bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); 203952a6212SJordan K. Hubbard (void)msdosfs_statfs(mp, &mp->mnt_stat, p); 204952a6212SJordan K. Hubbard vfs_unlock(mp); 205952a6212SJordan K. Hubbard return (0); 206952a6212SJordan K. Hubbard } 207952a6212SJordan K. Hubbard #endif 208952a6212SJordan K. Hubbard 20927a0bc89SDoug Rabson /* 21027a0bc89SDoug Rabson * mp - path - addr in user space of mount point (ie /usr or whatever) 21127a0bc89SDoug Rabson * data - addr in user space of mount params including the name of the block 21227a0bc89SDoug Rabson * special file to treat as a filesystem. 21327a0bc89SDoug Rabson */ 2147fefffeeSPoul-Henning Kamp static int 21527a0bc89SDoug Rabson msdosfs_mount(mp, path, data, ndp, p) 21627a0bc89SDoug Rabson struct mount *mp; 21727a0bc89SDoug Rabson char *path; 21827a0bc89SDoug Rabson caddr_t data; 21927a0bc89SDoug Rabson struct nameidata *ndp; 22027a0bc89SDoug Rabson struct proc *p; 22127a0bc89SDoug Rabson { 22227a0bc89SDoug Rabson struct vnode *devvp; /* vnode for blk device to mount */ 22327a0bc89SDoug Rabson struct msdosfs_args args; /* will hold data from mount request */ 224952a6212SJordan K. Hubbard /* msdosfs specific mount control block */ 225952a6212SJordan K. Hubbard struct msdosfsmount *pmp = NULL; 226952a6212SJordan K. Hubbard size_t size; 22727a0bc89SDoug Rabson int error, flags; 228952a6212SJordan K. Hubbard mode_t accessmode; 22927a0bc89SDoug Rabson 230c3c6d51eSPoul-Henning Kamp error = copyin(data, (caddr_t)&args, sizeof(struct msdosfs_args)); 231c3c6d51eSPoul-Henning Kamp if (error) 232952a6212SJordan K. Hubbard return (error); 233206faeeeSDmitrij Tejblum if (args.magic != MSDOSFS_ARGSMAGIC) 234952a6212SJordan K. Hubbard args.flags = 0; 23527a0bc89SDoug Rabson /* 236952a6212SJordan K. Hubbard * If updating, check whether changing from read-only to 237952a6212SJordan K. Hubbard * read/write; if there is no device name, that's all we do. 23827a0bc89SDoug Rabson */ 23927a0bc89SDoug Rabson if (mp->mnt_flag & MNT_UPDATE) { 240952a6212SJordan K. Hubbard pmp = VFSTOMSDOSFS(mp); 24127a0bc89SDoug Rabson error = 0; 242952a6212SJordan K. Hubbard if (!(pmp->pm_flags & MSDOSFSMNT_RONLY) && (mp->mnt_flag & MNT_RDONLY)) { 24327a0bc89SDoug Rabson flags = WRITECLOSE; 24427a0bc89SDoug Rabson if (mp->mnt_flag & MNT_FORCE) 24527a0bc89SDoug Rabson flags |= FORCECLOSE; 24627a0bc89SDoug Rabson error = vflush(mp, NULLVP, flags); 24727a0bc89SDoug Rabson } 24827a0bc89SDoug Rabson if (!error && (mp->mnt_flag & MNT_RELOAD)) 24927a0bc89SDoug Rabson /* not yet implemented */ 250952a6212SJordan K. Hubbard error = EOPNOTSUPP; 25127a0bc89SDoug Rabson if (error) 252952a6212SJordan K. Hubbard return (error); 253952a6212SJordan K. Hubbard if ((pmp->pm_flags & MSDOSFSMNT_RONLY) && (mp->mnt_kern_flag & MNTK_WANTRDWR)) { 254952a6212SJordan K. Hubbard /* 255952a6212SJordan K. Hubbard * If upgrade to read-write by non-root, then verify 256952a6212SJordan K. Hubbard * that user has necessary permissions on the device. 257952a6212SJordan K. Hubbard */ 258952a6212SJordan K. Hubbard if (p->p_ucred->cr_uid != 0) { 259952a6212SJordan K. Hubbard devvp = pmp->pm_devvp; 260206faeeeSDmitrij Tejblum vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); 261952a6212SJordan K. Hubbard error = VOP_ACCESS(devvp, VREAD | VWRITE, 262952a6212SJordan K. Hubbard p->p_ucred, p); 263952a6212SJordan K. Hubbard if (error) { 264952a6212SJordan K. Hubbard VOP_UNLOCK(devvp, 0, p); 265952a6212SJordan K. Hubbard return (error); 266952a6212SJordan K. Hubbard } 267952a6212SJordan K. Hubbard VOP_UNLOCK(devvp, 0, p); 268952a6212SJordan K. Hubbard } 269952a6212SJordan K. Hubbard pmp->pm_flags &= ~MSDOSFSMNT_RONLY; 270952a6212SJordan K. Hubbard } 27127a0bc89SDoug Rabson if (args.fspec == 0) { 272952a6212SJordan K. Hubbard #ifdef __notyet__ /* doesn't work correctly with current mountd XXX */ 273952a6212SJordan K. Hubbard if (args.flags & MSDOSFSMNT_MNTOPT) { 274952a6212SJordan K. Hubbard pmp->pm_flags &= ~MSDOSFSMNT_MNTOPT; 275952a6212SJordan K. Hubbard pmp->pm_flags |= args.flags & MSDOSFSMNT_MNTOPT; 276952a6212SJordan K. Hubbard if (pmp->pm_flags & MSDOSFSMNT_NOWIN95) 277952a6212SJordan K. Hubbard pmp->pm_flags |= MSDOSFSMNT_SHORTNAME; 278952a6212SJordan K. Hubbard } 279952a6212SJordan K. Hubbard #endif 28027a0bc89SDoug Rabson /* 28127a0bc89SDoug Rabson * Process export requests. 28227a0bc89SDoug Rabson */ 283952a6212SJordan K. Hubbard return (vfs_export(mp, &pmp->pm_export, &args.export)); 28427a0bc89SDoug Rabson } 285952a6212SJordan K. Hubbard } 28627a0bc89SDoug Rabson /* 287952a6212SJordan K. Hubbard * Not an update, or updating the name: look up the name 288952a6212SJordan K. Hubbard * and verify that it refers to a sensible block device. 28927a0bc89SDoug Rabson */ 29027a0bc89SDoug Rabson NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, p); 29127a0bc89SDoug Rabson error = namei(ndp); 292952a6212SJordan K. Hubbard if (error) 293952a6212SJordan K. Hubbard return (error); 29427a0bc89SDoug Rabson devvp = ndp->ni_vp; 295952a6212SJordan K. Hubbard 29641d2e3e0SPoul-Henning Kamp if (!vn_isdisk(devvp)) { 29727a0bc89SDoug Rabson vrele(devvp); 298952a6212SJordan K. Hubbard return (ENOTBLK); 29927a0bc89SDoug Rabson } 30027a0bc89SDoug Rabson /* 301952a6212SJordan K. Hubbard * If mount by non-root, then verify that user has necessary 302952a6212SJordan K. Hubbard * permissions on the device. 30327a0bc89SDoug Rabson */ 304952a6212SJordan K. Hubbard if (p->p_ucred->cr_uid != 0) { 305952a6212SJordan K. Hubbard accessmode = VREAD; 306952a6212SJordan K. Hubbard if ((mp->mnt_flag & MNT_RDONLY) == 0) 307952a6212SJordan K. Hubbard accessmode |= VWRITE; 308952a6212SJordan K. Hubbard vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); 309952a6212SJordan K. Hubbard error = VOP_ACCESS(devvp, accessmode, p->p_ucred, p); 310952a6212SJordan K. Hubbard if (error) { 311952a6212SJordan K. Hubbard vput(devvp); 312952a6212SJordan K. Hubbard return (error); 313952a6212SJordan K. Hubbard } 314952a6212SJordan K. Hubbard VOP_UNLOCK(devvp, 0, p); 315952a6212SJordan K. Hubbard } 316952a6212SJordan K. Hubbard if ((mp->mnt_flag & MNT_UPDATE) == 0) { 317952a6212SJordan K. Hubbard error = mountmsdosfs(devvp, mp, p, &args); 318952a6212SJordan K. Hubbard #ifdef MSDOSFS_DEBUG /* only needed for the printf below */ 319952a6212SJordan K. Hubbard pmp = VFSTOMSDOSFS(mp); 320952a6212SJordan K. Hubbard #endif 321952a6212SJordan K. Hubbard } else { 32227a0bc89SDoug Rabson if (devvp != pmp->pm_devvp) 323952a6212SJordan K. Hubbard error = EINVAL; /* XXX needs translation */ 32427a0bc89SDoug Rabson else 32527a0bc89SDoug Rabson vrele(devvp); 32627a0bc89SDoug Rabson } 32727a0bc89SDoug Rabson if (error) { 32827a0bc89SDoug Rabson vrele(devvp); 329952a6212SJordan K. Hubbard return (error); 330952a6212SJordan K. Hubbard } 331952a6212SJordan K. Hubbard 332952a6212SJordan K. Hubbard error = update_mp(mp, &args); 333952a6212SJordan K. Hubbard if (error) { 334952a6212SJordan K. Hubbard msdosfs_unmount(mp, MNT_FORCE, p); 33527a0bc89SDoug Rabson return error; 33627a0bc89SDoug Rabson } 33727a0bc89SDoug Rabson 338952a6212SJordan K. Hubbard (void) copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size); 339952a6212SJordan K. Hubbard bzero(mp->mnt_stat.f_mntonname + size, MNAMELEN - size); 340952a6212SJordan K. Hubbard (void) copyinstr(args.fspec, mp->mnt_stat.f_mntfromname, MNAMELEN - 1, 341952a6212SJordan K. Hubbard &size); 342952a6212SJordan K. Hubbard bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); 34327a0bc89SDoug Rabson (void) msdosfs_statfs(mp, &mp->mnt_stat, p); 34427a0bc89SDoug Rabson #ifdef MSDOSFS_DEBUG 345623ae52eSPoul-Henning Kamp printf("msdosfs_mount(): mp %p, pmp %p, inusemap %p\n", mp, pmp, pmp->pm_inusemap); 34627a0bc89SDoug Rabson #endif 347952a6212SJordan K. Hubbard return (0); 34827a0bc89SDoug Rabson } 34927a0bc89SDoug Rabson 3507fefffeeSPoul-Henning Kamp static int 351952a6212SJordan K. Hubbard mountmsdosfs(devvp, mp, p, argp) 35227a0bc89SDoug Rabson struct vnode *devvp; 35327a0bc89SDoug Rabson struct mount *mp; 35427a0bc89SDoug Rabson struct proc *p; 355952a6212SJordan K. Hubbard struct msdosfs_args *argp; 35627a0bc89SDoug Rabson { 357952a6212SJordan K. Hubbard struct msdosfsmount *pmp; 358952a6212SJordan K. Hubbard struct buf *bp; 35927a0bc89SDoug Rabson dev_t dev = devvp->v_rdev; 360952a6212SJordan K. Hubbard #ifndef __FreeBSD__ 361952a6212SJordan K. Hubbard struct partinfo dpart; 362f1d19042SArchie Cobbs int bsize = 0, dtype = 0, tmp; 363952a6212SJordan K. Hubbard #endif 36427a0bc89SDoug Rabson union bootsector *bsp; 36527a0bc89SDoug Rabson struct byte_bpb33 *b33; 36627a0bc89SDoug Rabson struct byte_bpb50 *b50; 367952a6212SJordan K. Hubbard struct byte_bpb710 *b710; 368952a6212SJordan K. Hubbard u_int8_t SecPerClust; 369952a6212SJordan K. Hubbard int ronly, error; 37027a0bc89SDoug Rabson 37127a0bc89SDoug Rabson /* 372952a6212SJordan K. Hubbard * Disallow multiple mounts of the same device. 373952a6212SJordan K. Hubbard * Disallow mounting of a device that is currently in use 374952a6212SJordan K. Hubbard * (except for root, which might share swap device for miniroot). 375952a6212SJordan K. Hubbard * Flush out any old buffers remaining from a previous use. 37627a0bc89SDoug Rabson */ 377c3c6d51eSPoul-Henning Kamp error = vfs_mountedon(devvp); 378c3c6d51eSPoul-Henning Kamp if (error) 379952a6212SJordan K. Hubbard return (error); 380952a6212SJordan K. Hubbard if (vcount(devvp) > 1 && devvp != rootvp) 381952a6212SJordan K. Hubbard return (EBUSY); 382952a6212SJordan K. Hubbard vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); 383c3c6d51eSPoul-Henning Kamp error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0); 384952a6212SJordan K. Hubbard VOP_UNLOCK(devvp, 0, p); 385c3c6d51eSPoul-Henning Kamp if (error) 386952a6212SJordan K. Hubbard return (error); 38727a0bc89SDoug Rabson 388952a6212SJordan K. Hubbard ronly = (mp->mnt_flag & MNT_RDONLY) != 0; 389c3c6d51eSPoul-Henning Kamp error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, p); 390c3c6d51eSPoul-Henning Kamp if (error) 391952a6212SJordan K. Hubbard return (error); 392952a6212SJordan K. Hubbard 393952a6212SJordan K. Hubbard bp = NULL; /* both used in error_exit */ 394952a6212SJordan K. Hubbard pmp = NULL; 395952a6212SJordan K. Hubbard 396952a6212SJordan K. Hubbard #ifndef __FreeBSD__ 397952a6212SJordan K. Hubbard if (argp->flags & MSDOSFSMNT_GEMDOSFS) { 39827a0bc89SDoug Rabson /* 399952a6212SJordan K. Hubbard * We need the disklabel to calculate the size of a FAT entry 400952a6212SJordan K. Hubbard * later on. Also make sure the partition contains a filesystem 401952a6212SJordan K. Hubbard * of type FS_MSDOS. This doesn't work for floppies, so we have 402952a6212SJordan K. Hubbard * to check for them too. 403952a6212SJordan K. Hubbard * 404952a6212SJordan K. Hubbard * At least some parts of the msdos fs driver seem to assume 405952a6212SJordan K. Hubbard * that the size of a disk block will always be 512 bytes. 406952a6212SJordan K. Hubbard * Let's check it... 40727a0bc89SDoug Rabson */ 408952a6212SJordan K. Hubbard error = VOP_IOCTL(devvp, DIOCGPART, (caddr_t)&dpart, 409952a6212SJordan K. Hubbard FREAD, NOCRED, p); 410952a6212SJordan K. Hubbard if (error) 411952a6212SJordan K. Hubbard goto error_exit; 412952a6212SJordan K. Hubbard tmp = dpart.part->p_fstype; 413952a6212SJordan K. Hubbard dtype = dpart.disklab->d_type; 414952a6212SJordan K. Hubbard bsize = dpart.disklab->d_secsize; 415952a6212SJordan K. Hubbard if (bsize != 512 || (dtype!=DTYPE_FLOPPY && tmp!=FS_MSDOS)) { 416952a6212SJordan K. Hubbard error = EINVAL; 417952a6212SJordan K. Hubbard goto error_exit; 418952a6212SJordan K. Hubbard } 41927a0bc89SDoug Rabson } 42027a0bc89SDoug Rabson #endif 42127a0bc89SDoug Rabson 42227a0bc89SDoug Rabson /* 423952a6212SJordan K. Hubbard * Read the boot sector of the filesystem, and then check the 424952a6212SJordan K. Hubbard * boot signature. If not a dos boot sector then error out. 42527a0bc89SDoug Rabson */ 426ad63a118SSatoshi Asami #ifdef PC98 427952a6212SJordan K. Hubbard error = bread(devvp, 0, 1024, NOCRED, &bp); 428ad63a118SSatoshi Asami #else 429952a6212SJordan K. Hubbard error = bread(devvp, 0, 512, NOCRED, &bp); 430ad63a118SSatoshi Asami #endif 431c3c6d51eSPoul-Henning Kamp if (error) 43227a0bc89SDoug Rabson goto error_exit; 433952a6212SJordan K. Hubbard bp->b_flags |= B_AGE; 434952a6212SJordan K. Hubbard bsp = (union bootsector *)bp->b_data; 43527a0bc89SDoug Rabson b33 = (struct byte_bpb33 *)bsp->bs33.bsBPB; 43627a0bc89SDoug Rabson b50 = (struct byte_bpb50 *)bsp->bs50.bsBPB; 437952a6212SJordan K. Hubbard b710 = (struct byte_bpb710 *)bsp->bs710.bsPBP; 438952a6212SJordan K. Hubbard 439952a6212SJordan K. Hubbard #ifndef __FreeBSD__ 440952a6212SJordan K. Hubbard if (!(argp->flags & MSDOSFSMNT_GEMDOSFS)) { 441952a6212SJordan K. Hubbard #endif 442ad63a118SSatoshi Asami #ifdef PC98 443efa0ac5bSKATO Takenori if ((bsp->bs50.bsBootSectSig0 != BOOTSIG0 444efa0ac5bSKATO Takenori || bsp->bs50.bsBootSectSig1 != BOOTSIG1) 445efa0ac5bSKATO Takenori && (bsp->bs50.bsBootSectSig0 != 0 /* PC98 DOS 3.3x */ 446efa0ac5bSKATO Takenori || bsp->bs50.bsBootSectSig1 != 0) 447efa0ac5bSKATO Takenori && (bsp->bs50.bsBootSectSig0 != 0x90 /* PC98 DOS 5.0 */ 448efa0ac5bSKATO Takenori || bsp->bs50.bsBootSectSig1 != 0x3d) 449efa0ac5bSKATO Takenori && (bsp->bs50.bsBootSectSig0 != 0x46 /* PC98 DOS 3.3B */ 450efa0ac5bSKATO Takenori || bsp->bs50.bsBootSectSig1 != 0xfa)) { 451ad63a118SSatoshi Asami #else 452952a6212SJordan K. Hubbard if (bsp->bs50.bsBootSectSig0 != BOOTSIG0 453952a6212SJordan K. Hubbard || bsp->bs50.bsBootSectSig1 != BOOTSIG1) { 454ad63a118SSatoshi Asami #endif 45527a0bc89SDoug Rabson error = EINVAL; 45627a0bc89SDoug Rabson goto error_exit; 45727a0bc89SDoug Rabson } 458952a6212SJordan K. Hubbard #ifndef __FreeBSD__ 45927a0bc89SDoug Rabson } 460952a6212SJordan K. Hubbard #endif 46127a0bc89SDoug Rabson 46227a0bc89SDoug Rabson pmp = malloc(sizeof *pmp, M_MSDOSFSMNT, M_WAITOK); 46327a0bc89SDoug Rabson bzero((caddr_t)pmp, sizeof *pmp); 46427a0bc89SDoug Rabson pmp->pm_mountp = mp; 46527a0bc89SDoug Rabson 46627a0bc89SDoug Rabson /* 46727a0bc89SDoug Rabson * Compute several useful quantities from the bpb in the 46827a0bc89SDoug Rabson * bootsector. Copy in the dos 5 variant of the bpb then fix up 46927a0bc89SDoug Rabson * the fields that are different between dos 5 and dos 3.3. 47027a0bc89SDoug Rabson */ 471952a6212SJordan K. Hubbard SecPerClust = b50->bpbSecPerClust; 47227a0bc89SDoug Rabson pmp->pm_BytesPerSec = getushort(b50->bpbBytesPerSec); 47327a0bc89SDoug Rabson pmp->pm_ResSectors = getushort(b50->bpbResSectors); 47427a0bc89SDoug Rabson pmp->pm_FATs = b50->bpbFATs; 47527a0bc89SDoug Rabson pmp->pm_RootDirEnts = getushort(b50->bpbRootDirEnts); 47627a0bc89SDoug Rabson pmp->pm_Sectors = getushort(b50->bpbSectors); 47727a0bc89SDoug Rabson pmp->pm_FATsecs = getushort(b50->bpbFATsecs); 47827a0bc89SDoug Rabson pmp->pm_SecPerTrack = getushort(b50->bpbSecPerTrack); 47927a0bc89SDoug Rabson pmp->pm_Heads = getushort(b50->bpbHeads); 480952a6212SJordan K. Hubbard pmp->pm_Media = b50->bpbMedia; 48127a0bc89SDoug Rabson 482952a6212SJordan K. Hubbard #ifndef __FreeBSD__ 483952a6212SJordan K. Hubbard if (!(argp->flags & MSDOSFSMNT_GEMDOSFS)) { 484952a6212SJordan K. Hubbard #endif 48527a0bc89SDoug Rabson /* XXX - We should probably check more values here */ 486952a6212SJordan K. Hubbard if (!pmp->pm_BytesPerSec || !SecPerClust 487952a6212SJordan K. Hubbard || !pmp->pm_Heads || pmp->pm_Heads > 255 488ad63a118SSatoshi Asami #ifdef PC98 489952a6212SJordan K. Hubbard || !pmp->pm_SecPerTrack || pmp->pm_SecPerTrack > 255) { 490ad63a118SSatoshi Asami #else 491952a6212SJordan K. Hubbard || !pmp->pm_SecPerTrack || pmp->pm_SecPerTrack > 63) { 492ad63a118SSatoshi Asami #endif 49327a0bc89SDoug Rabson error = EINVAL; 49427a0bc89SDoug Rabson goto error_exit; 49527a0bc89SDoug Rabson } 496952a6212SJordan K. Hubbard #ifndef __FreeBSD__ 497952a6212SJordan K. Hubbard } 498952a6212SJordan K. Hubbard #endif 49927a0bc89SDoug Rabson 50027a0bc89SDoug Rabson if (pmp->pm_Sectors == 0) { 50127a0bc89SDoug Rabson pmp->pm_HiddenSects = getulong(b50->bpbHiddenSecs); 50227a0bc89SDoug Rabson pmp->pm_HugeSectors = getulong(b50->bpbHugeSectors); 50327a0bc89SDoug Rabson } else { 50427a0bc89SDoug Rabson pmp->pm_HiddenSects = getushort(b33->bpbHiddenSecs); 50527a0bc89SDoug Rabson pmp->pm_HugeSectors = pmp->pm_Sectors; 50627a0bc89SDoug Rabson } 507c681be37SDmitrij Tejblum if (pmp->pm_HugeSectors > 0xffffffff / 508c681be37SDmitrij Tejblum (pmp->pm_BytesPerSec / sizeof(struct direntry)) + 1) { 509952a6212SJordan K. Hubbard /* 510952a6212SJordan K. Hubbard * We cannot deal currently with this size of disk 511952a6212SJordan K. Hubbard * due to fileid limitations (see msdosfs_getattr and 512952a6212SJordan K. Hubbard * msdosfs_readdir) 513952a6212SJordan K. Hubbard */ 514952a6212SJordan K. Hubbard error = EINVAL; 515aaf0bb19SAndrey A. Chernov printf("mountmsdosfs(): disk too big, sorry\n"); 516952a6212SJordan K. Hubbard goto error_exit; 517952a6212SJordan K. Hubbard } 518952a6212SJordan K. Hubbard 519952a6212SJordan K. Hubbard if (pmp->pm_RootDirEnts == 0) { 520952a6212SJordan K. Hubbard if (bsp->bs710.bsBootSectSig2 != BOOTSIG2 521952a6212SJordan K. Hubbard || bsp->bs710.bsBootSectSig3 != BOOTSIG3 522952a6212SJordan K. Hubbard || pmp->pm_Sectors 523952a6212SJordan K. Hubbard || pmp->pm_FATsecs 524952a6212SJordan K. Hubbard || getushort(b710->bpbFSVers)) { 525952a6212SJordan K. Hubbard error = EINVAL; 526aaf0bb19SAndrey A. Chernov printf("mountmsdosfs(): bad FAT32 filesystem\n"); 527952a6212SJordan K. Hubbard goto error_exit; 528952a6212SJordan K. Hubbard } 529952a6212SJordan K. Hubbard pmp->pm_fatmask = FAT32_MASK; 530952a6212SJordan K. Hubbard pmp->pm_fatmult = 4; 531952a6212SJordan K. Hubbard pmp->pm_fatdiv = 1; 532952a6212SJordan K. Hubbard pmp->pm_FATsecs = getulong(b710->bpbBigFATsecs); 533952a6212SJordan K. Hubbard if (getushort(b710->bpbExtFlags) & FATMIRROR) 534952a6212SJordan K. Hubbard pmp->pm_curfat = getushort(b710->bpbExtFlags) & FATNUM; 535952a6212SJordan K. Hubbard else 536952a6212SJordan K. Hubbard pmp->pm_flags |= MSDOSFS_FATMIRROR; 537952a6212SJordan K. Hubbard } else 538952a6212SJordan K. Hubbard pmp->pm_flags |= MSDOSFS_FATMIRROR; 539952a6212SJordan K. Hubbard 540952a6212SJordan K. Hubbard #ifndef __FreeBSD__ 541952a6212SJordan K. Hubbard if (argp->flags & MSDOSFSMNT_GEMDOSFS) { 542952a6212SJordan K. Hubbard if (FAT32(pmp)) { 543952a6212SJordan K. Hubbard /* 544952a6212SJordan K. Hubbard * GEMDOS doesn't know fat32. 545952a6212SJordan K. Hubbard */ 546952a6212SJordan K. Hubbard error = EINVAL; 547952a6212SJordan K. Hubbard goto error_exit; 548952a6212SJordan K. Hubbard } 549952a6212SJordan K. Hubbard 550952a6212SJordan K. Hubbard /* 551952a6212SJordan K. Hubbard * Check a few values (could do some more): 552952a6212SJordan K. Hubbard * - logical sector size: power of 2, >= block size 553952a6212SJordan K. Hubbard * - sectors per cluster: power of 2, >= 1 554952a6212SJordan K. Hubbard * - number of sectors: >= 1, <= size of partition 555952a6212SJordan K. Hubbard */ 556952a6212SJordan K. Hubbard if ( (SecPerClust == 0) 557952a6212SJordan K. Hubbard || (SecPerClust & (SecPerClust - 1)) 558952a6212SJordan K. Hubbard || (pmp->pm_BytesPerSec < bsize) 559952a6212SJordan K. Hubbard || (pmp->pm_BytesPerSec & (pmp->pm_BytesPerSec - 1)) 560952a6212SJordan K. Hubbard || (pmp->pm_HugeSectors == 0) 561952a6212SJordan K. Hubbard || (pmp->pm_HugeSectors * (pmp->pm_BytesPerSec / bsize) 562952a6212SJordan K. Hubbard > dpart.part->p_size) 563952a6212SJordan K. Hubbard ) { 564952a6212SJordan K. Hubbard error = EINVAL; 565952a6212SJordan K. Hubbard goto error_exit; 566952a6212SJordan K. Hubbard } 567952a6212SJordan K. Hubbard /* 568952a6212SJordan K. Hubbard * XXX - Many parts of the msdos fs driver seem to assume that 569952a6212SJordan K. Hubbard * the number of bytes per logical sector (BytesPerSec) will 570952a6212SJordan K. Hubbard * always be the same as the number of bytes per disk block 571952a6212SJordan K. Hubbard * Let's pretend it is. 572952a6212SJordan K. Hubbard */ 573952a6212SJordan K. Hubbard tmp = pmp->pm_BytesPerSec / bsize; 574952a6212SJordan K. Hubbard pmp->pm_BytesPerSec = bsize; 575952a6212SJordan K. Hubbard pmp->pm_HugeSectors *= tmp; 576952a6212SJordan K. Hubbard pmp->pm_HiddenSects *= tmp; 577952a6212SJordan K. Hubbard pmp->pm_ResSectors *= tmp; 578952a6212SJordan K. Hubbard pmp->pm_Sectors *= tmp; 579952a6212SJordan K. Hubbard pmp->pm_FATsecs *= tmp; 580952a6212SJordan K. Hubbard SecPerClust *= tmp; 581952a6212SJordan K. Hubbard } 582952a6212SJordan K. Hubbard #endif 58327a0bc89SDoug Rabson pmp->pm_fatblk = pmp->pm_ResSectors; 584952a6212SJordan K. Hubbard if (FAT32(pmp)) { 585952a6212SJordan K. Hubbard pmp->pm_rootdirblk = getulong(b710->bpbRootClust); 586952a6212SJordan K. Hubbard pmp->pm_firstcluster = pmp->pm_fatblk 587952a6212SJordan K. Hubbard + (pmp->pm_FATs * pmp->pm_FATsecs); 588952a6212SJordan K. Hubbard pmp->pm_fsinfo = getushort(b710->bpbFSInfo); 589952a6212SJordan K. Hubbard } else { 59027a0bc89SDoug Rabson pmp->pm_rootdirblk = pmp->pm_fatblk + 59127a0bc89SDoug Rabson (pmp->pm_FATs * pmp->pm_FATsecs); 592952a6212SJordan K. Hubbard pmp->pm_rootdirsize = (pmp->pm_RootDirEnts * sizeof(struct direntry) 593952a6212SJordan K. Hubbard + pmp->pm_BytesPerSec - 1) 594952a6212SJordan K. Hubbard / pmp->pm_BytesPerSec;/* in sectors */ 59527a0bc89SDoug Rabson pmp->pm_firstcluster = pmp->pm_rootdirblk + pmp->pm_rootdirsize; 596952a6212SJordan K. Hubbard } 597952a6212SJordan K. Hubbard 59827a0bc89SDoug Rabson pmp->pm_nmbrofclusters = (pmp->pm_HugeSectors - pmp->pm_firstcluster) / 599952a6212SJordan K. Hubbard SecPerClust; 60027a0bc89SDoug Rabson pmp->pm_maxcluster = pmp->pm_nmbrofclusters + 1; 60127a0bc89SDoug Rabson pmp->pm_fatsize = pmp->pm_FATsecs * pmp->pm_BytesPerSec; 602952a6212SJordan K. Hubbard 603952a6212SJordan K. Hubbard #ifndef __FreeBSD__ 604952a6212SJordan K. Hubbard if (argp->flags & MSDOSFSMNT_GEMDOSFS) { 605952a6212SJordan K. Hubbard if ((pmp->pm_nmbrofclusters <= (0xff0 - 2)) 606952a6212SJordan K. Hubbard && ((dtype == DTYPE_FLOPPY) || ((dtype == DTYPE_VNODE) 607952a6212SJordan K. Hubbard && ((pmp->pm_Heads == 1) || (pmp->pm_Heads == 2)))) 608952a6212SJordan K. Hubbard ) { 609952a6212SJordan K. Hubbard pmp->pm_fatmask = FAT12_MASK; 610952a6212SJordan K. Hubbard pmp->pm_fatmult = 3; 611952a6212SJordan K. Hubbard pmp->pm_fatdiv = 2; 612952a6212SJordan K. Hubbard } else { 613952a6212SJordan K. Hubbard pmp->pm_fatmask = FAT16_MASK; 614952a6212SJordan K. Hubbard pmp->pm_fatmult = 2; 615952a6212SJordan K. Hubbard pmp->pm_fatdiv = 1; 616952a6212SJordan K. Hubbard } 617952a6212SJordan K. Hubbard } else 618952a6212SJordan K. Hubbard #endif 619952a6212SJordan K. Hubbard if (pmp->pm_fatmask == 0) { 620952a6212SJordan K. Hubbard if (pmp->pm_maxcluster 621952a6212SJordan K. Hubbard <= ((CLUST_RSRVD - CLUST_FIRST) & FAT12_MASK)) { 62227a0bc89SDoug Rabson /* 623952a6212SJordan K. Hubbard * This will usually be a floppy disk. This size makes 624952a6212SJordan K. Hubbard * sure that one fat entry will not be split across 625952a6212SJordan K. Hubbard * multiple blocks. 62627a0bc89SDoug Rabson */ 627952a6212SJordan K. Hubbard pmp->pm_fatmask = FAT12_MASK; 628952a6212SJordan K. Hubbard pmp->pm_fatmult = 3; 629952a6212SJordan K. Hubbard pmp->pm_fatdiv = 2; 630952a6212SJordan K. Hubbard } else { 631952a6212SJordan K. Hubbard pmp->pm_fatmask = FAT16_MASK; 632952a6212SJordan K. Hubbard pmp->pm_fatmult = 2; 633952a6212SJordan K. Hubbard pmp->pm_fatdiv = 1; 634952a6212SJordan K. Hubbard } 635952a6212SJordan K. Hubbard } 636952a6212SJordan K. Hubbard if (FAT12(pmp)) 63727a0bc89SDoug Rabson pmp->pm_fatblocksize = 3 * pmp->pm_BytesPerSec; 63827a0bc89SDoug Rabson else 639c681be37SDmitrij Tejblum pmp->pm_fatblocksize = DFLTBSIZE; 640952a6212SJordan K. Hubbard 64127a0bc89SDoug Rabson pmp->pm_fatblocksec = pmp->pm_fatblocksize / pmp->pm_BytesPerSec; 642952a6212SJordan K. Hubbard pmp->pm_bnshift = ffs(pmp->pm_BytesPerSec) - 1; 64327a0bc89SDoug Rabson 64427a0bc89SDoug Rabson /* 64527a0bc89SDoug Rabson * Compute mask and shift value for isolating cluster relative byte 64627a0bc89SDoug Rabson * offsets and cluster numbers from a file offset. 64727a0bc89SDoug Rabson */ 648952a6212SJordan K. Hubbard pmp->pm_bpcluster = SecPerClust * pmp->pm_BytesPerSec; 649952a6212SJordan K. Hubbard pmp->pm_crbomask = pmp->pm_bpcluster - 1; 650952a6212SJordan K. Hubbard pmp->pm_cnshift = ffs(pmp->pm_bpcluster) - 1; 65127a0bc89SDoug Rabson 652952a6212SJordan K. Hubbard /* 653952a6212SJordan K. Hubbard * Check for valid cluster size 654952a6212SJordan K. Hubbard * must be a power of 2 655952a6212SJordan K. Hubbard */ 656952a6212SJordan K. Hubbard if (pmp->pm_bpcluster ^ (1 << pmp->pm_cnshift)) { 657952a6212SJordan K. Hubbard error = EINVAL; 658952a6212SJordan K. Hubbard goto error_exit; 659ad63a118SSatoshi Asami } 66027a0bc89SDoug Rabson 66127a0bc89SDoug Rabson /* 66227a0bc89SDoug Rabson * Release the bootsector buffer. 66327a0bc89SDoug Rabson */ 664952a6212SJordan K. Hubbard brelse(bp); 665952a6212SJordan K. Hubbard bp = NULL; 666952a6212SJordan K. Hubbard 667952a6212SJordan K. Hubbard /* 668952a6212SJordan K. Hubbard * Check FSInfo. 669952a6212SJordan K. Hubbard */ 670952a6212SJordan K. Hubbard if (pmp->pm_fsinfo) { 671952a6212SJordan K. Hubbard struct fsinfo *fp; 672952a6212SJordan K. Hubbard 673952a6212SJordan K. Hubbard if ((error = bread(devvp, pmp->pm_fsinfo, 1024, NOCRED, &bp)) != 0) 674952a6212SJordan K. Hubbard goto error_exit; 675952a6212SJordan K. Hubbard fp = (struct fsinfo *)bp->b_data; 676952a6212SJordan K. Hubbard if (!bcmp(fp->fsisig1, "RRaA", 4) 677952a6212SJordan K. Hubbard && !bcmp(fp->fsisig2, "rrAa", 4) 678952a6212SJordan K. Hubbard && !bcmp(fp->fsisig3, "\0\0\125\252", 4) 679952a6212SJordan K. Hubbard && !bcmp(fp->fsisig4, "\0\0\125\252", 4)) 680952a6212SJordan K. Hubbard pmp->pm_nxtfree = getulong(fp->fsinxtfree); 681952a6212SJordan K. Hubbard else 682952a6212SJordan K. Hubbard pmp->pm_fsinfo = 0; 683952a6212SJordan K. Hubbard brelse(bp); 684952a6212SJordan K. Hubbard bp = NULL; 685952a6212SJordan K. Hubbard } 686952a6212SJordan K. Hubbard 687952a6212SJordan K. Hubbard /* 688952a6212SJordan K. Hubbard * Check and validate (or perhaps invalidate?) the fsinfo structure? XXX 689952a6212SJordan K. Hubbard */ 69027a0bc89SDoug Rabson 69127a0bc89SDoug Rabson /* 69227a0bc89SDoug Rabson * Allocate memory for the bitmap of allocated clusters, and then 69327a0bc89SDoug Rabson * fill it in. 69427a0bc89SDoug Rabson */ 69527a0bc89SDoug Rabson pmp->pm_inusemap = malloc(((pmp->pm_maxcluster + N_INUSEBITS - 1) 69627a0bc89SDoug Rabson / N_INUSEBITS) 69727a0bc89SDoug Rabson * sizeof(*pmp->pm_inusemap), 69827a0bc89SDoug Rabson M_MSDOSFSFAT, M_WAITOK); 69927a0bc89SDoug Rabson 70027a0bc89SDoug Rabson /* 70127a0bc89SDoug Rabson * fillinusemap() needs pm_devvp. 70227a0bc89SDoug Rabson */ 70327a0bc89SDoug Rabson pmp->pm_dev = dev; 70427a0bc89SDoug Rabson pmp->pm_devvp = devvp; 70527a0bc89SDoug Rabson 70627a0bc89SDoug Rabson /* 70727a0bc89SDoug Rabson * Have the inuse map filled in. 70827a0bc89SDoug Rabson */ 709952a6212SJordan K. Hubbard if ((error = fillinusemap(pmp)) != 0) 71027a0bc89SDoug Rabson goto error_exit; 71127a0bc89SDoug Rabson 71227a0bc89SDoug Rabson /* 71327a0bc89SDoug Rabson * If they want fat updates to be synchronous then let them suffer 71427a0bc89SDoug Rabson * the performance degradation in exchange for the on disk copy of 71527a0bc89SDoug Rabson * the fat being correct just about all the time. I suppose this 71627a0bc89SDoug Rabson * would be a good thing to turn on if the kernel is still flakey. 71727a0bc89SDoug Rabson */ 718952a6212SJordan K. Hubbard if (mp->mnt_flag & MNT_SYNCHRONOUS) 719952a6212SJordan K. Hubbard pmp->pm_flags |= MSDOSFSMNT_WAITONFAT; 72027a0bc89SDoug Rabson 72127a0bc89SDoug Rabson /* 72227a0bc89SDoug Rabson * Finish up. 72327a0bc89SDoug Rabson */ 724952a6212SJordan K. Hubbard if (ronly) 725952a6212SJordan K. Hubbard pmp->pm_flags |= MSDOSFSMNT_RONLY; 726952a6212SJordan K. Hubbard else 72727a0bc89SDoug Rabson pmp->pm_fmod = 1; 72827a0bc89SDoug Rabson mp->mnt_data = (qaddr_t) pmp; 729939cb752SBruce Evans mp->mnt_stat.f_fsid.val[0] = dev2udev(dev); 730af3f60d5SBruce Evans mp->mnt_stat.f_fsid.val[1] = mp->mnt_vfc->vfc_typenum; 731cc9d8990SPeter Wemm mp->mnt_flag |= MNT_LOCAL; 732b1897c19SJulian Elischer devvp->v_specmountpoint = mp; 73327a0bc89SDoug Rabson 73427a0bc89SDoug Rabson return 0; 73527a0bc89SDoug Rabson 736952a6212SJordan K. Hubbard error_exit: 737952a6212SJordan K. Hubbard if (bp) 738952a6212SJordan K. Hubbard brelse(bp); 739952a6212SJordan K. Hubbard (void) VOP_CLOSE(devvp, ronly ? FREAD : FREAD | FWRITE, NOCRED, p); 74027a0bc89SDoug Rabson if (pmp) { 74127a0bc89SDoug Rabson if (pmp->pm_inusemap) 742952a6212SJordan K. Hubbard free(pmp->pm_inusemap, M_MSDOSFSFAT); 743952a6212SJordan K. Hubbard free(pmp, M_MSDOSFSMNT); 74427a0bc89SDoug Rabson mp->mnt_data = (qaddr_t)0; 74527a0bc89SDoug Rabson } 746952a6212SJordan K. Hubbard return (error); 74727a0bc89SDoug Rabson } 74827a0bc89SDoug Rabson 7497fefffeeSPoul-Henning Kamp static int 75027a0bc89SDoug Rabson msdosfs_start(mp, flags, p) 75127a0bc89SDoug Rabson struct mount *mp; 75227a0bc89SDoug Rabson int flags; 75327a0bc89SDoug Rabson struct proc *p; 75427a0bc89SDoug Rabson { 755952a6212SJordan K. Hubbard 756952a6212SJordan K. Hubbard return (0); 75727a0bc89SDoug Rabson } 75827a0bc89SDoug Rabson 75927a0bc89SDoug Rabson /* 76027a0bc89SDoug Rabson * Unmount the filesystem described by mp. 76127a0bc89SDoug Rabson */ 7627fefffeeSPoul-Henning Kamp static int 76327a0bc89SDoug Rabson msdosfs_unmount(mp, mntflags, p) 76427a0bc89SDoug Rabson struct mount *mp; 76527a0bc89SDoug Rabson int mntflags; 76627a0bc89SDoug Rabson struct proc *p; 76727a0bc89SDoug Rabson { 768952a6212SJordan K. Hubbard struct msdosfsmount *pmp; 769952a6212SJordan K. Hubbard int error, flags; 77027a0bc89SDoug Rabson 771952a6212SJordan K. Hubbard flags = 0; 772952a6212SJordan K. Hubbard if (mntflags & MNT_FORCE) 77327a0bc89SDoug Rabson flags |= FORCECLOSE; 774c3c6d51eSPoul-Henning Kamp error = vflush(mp, NULLVP, flags); 775c3c6d51eSPoul-Henning Kamp if (error) 77627a0bc89SDoug Rabson return error; 777952a6212SJordan K. Hubbard pmp = VFSTOMSDOSFS(mp); 778b1897c19SJulian Elischer pmp->pm_devvp->v_specmountpoint = NULL; 779952a6212SJordan K. Hubbard #ifdef MSDOSFS_DEBUG 780952a6212SJordan K. Hubbard { 781952a6212SJordan K. Hubbard struct vnode *vp = pmp->pm_devvp; 782952a6212SJordan K. Hubbard 783952a6212SJordan K. Hubbard printf("msdosfs_umount(): just before calling VOP_CLOSE()\n"); 784952a6212SJordan K. Hubbard printf("flag %08lx, usecount %d, writecount %d, holdcnt %ld\n", 785952a6212SJordan K. Hubbard vp->v_flag, vp->v_usecount, vp->v_writecount, vp->v_holdcnt); 786952a6212SJordan K. Hubbard printf("lastr %d, id %lu, mount %p, op %p\n", 787952a6212SJordan K. Hubbard vp->v_lastr, vp->v_id, vp->v_mount, vp->v_op); 788952a6212SJordan K. Hubbard printf("freef %p, freeb %p, mount %p\n", 789952a6212SJordan K. Hubbard vp->v_freelist.tqe_next, vp->v_freelist.tqe_prev, 790952a6212SJordan K. Hubbard vp->v_mount); 791952a6212SJordan K. Hubbard printf("cleanblkhd %p, dirtyblkhd %p, numoutput %ld, type %d\n", 79240c8cfe5SPeter Wemm TAILQ_FIRST(&vp->v_cleanblkhd), 79340c8cfe5SPeter Wemm TAILQ_FIRST(&vp->v_dirtyblkhd), 794952a6212SJordan K. Hubbard vp->v_numoutput, vp->v_type); 795952a6212SJordan K. Hubbard printf("union %p, tag %d, data[0] %08x, data[1] %08x\n", 796952a6212SJordan K. Hubbard vp->v_socket, vp->v_tag, 797952a6212SJordan K. Hubbard ((u_int *)vp->v_data)[0], 798952a6212SJordan K. Hubbard ((u_int *)vp->v_data)[1]); 799952a6212SJordan K. Hubbard } 800952a6212SJordan K. Hubbard #endif 801b1897c19SJulian Elischer error = VOP_CLOSE(pmp->pm_devvp, 802b1897c19SJulian Elischer (pmp->pm_flags&MSDOSFSMNT_RONLY) ? FREAD : FREAD | FWRITE, 80327a0bc89SDoug Rabson NOCRED, p); 80427a0bc89SDoug Rabson vrele(pmp->pm_devvp); 805952a6212SJordan K. Hubbard free(pmp->pm_inusemap, M_MSDOSFSFAT); 806952a6212SJordan K. Hubbard free(pmp, M_MSDOSFSMNT); 80727a0bc89SDoug Rabson mp->mnt_data = (qaddr_t)0; 808cc9d8990SPeter Wemm mp->mnt_flag &= ~MNT_LOCAL; 809952a6212SJordan K. Hubbard return (error); 81027a0bc89SDoug Rabson } 81127a0bc89SDoug Rabson 8127fefffeeSPoul-Henning Kamp static int 81327a0bc89SDoug Rabson msdosfs_root(mp, vpp) 81427a0bc89SDoug Rabson struct mount *mp; 81527a0bc89SDoug Rabson struct vnode **vpp; 81627a0bc89SDoug Rabson { 817952a6212SJordan K. Hubbard struct msdosfsmount *pmp = VFSTOMSDOSFS(mp); 81827a0bc89SDoug Rabson struct denode *ndep; 81927a0bc89SDoug Rabson int error; 82027a0bc89SDoug Rabson 82127a0bc89SDoug Rabson #ifdef MSDOSFS_DEBUG 822952a6212SJordan K. Hubbard printf("msdosfs_root(); mp %p, pmp %p\n", mp, pmp); 82327a0bc89SDoug Rabson #endif 824952a6212SJordan K. Hubbard error = deget(pmp, MSDOSFSROOT, MSDOSFSROOT_OFS, &ndep); 825952a6212SJordan K. Hubbard if (error) 826952a6212SJordan K. Hubbard return (error); 82727a0bc89SDoug Rabson *vpp = DETOV(ndep); 828952a6212SJordan K. Hubbard return (0); 82927a0bc89SDoug Rabson } 83027a0bc89SDoug Rabson 8317fefffeeSPoul-Henning Kamp static int 83227a0bc89SDoug Rabson msdosfs_quotactl(mp, cmds, uid, arg, p) 83327a0bc89SDoug Rabson struct mount *mp; 83427a0bc89SDoug Rabson int cmds; 83527a0bc89SDoug Rabson uid_t uid; 83627a0bc89SDoug Rabson caddr_t arg; 83727a0bc89SDoug Rabson struct proc *p; 83827a0bc89SDoug Rabson { 839c3c6d51eSPoul-Henning Kamp return EOPNOTSUPP; 84027a0bc89SDoug Rabson } 84127a0bc89SDoug Rabson 8427fefffeeSPoul-Henning Kamp static int 84327a0bc89SDoug Rabson msdosfs_statfs(mp, sbp, p) 84427a0bc89SDoug Rabson struct mount *mp; 84527a0bc89SDoug Rabson struct statfs *sbp; 84627a0bc89SDoug Rabson struct proc *p; 84727a0bc89SDoug Rabson { 848952a6212SJordan K. Hubbard struct msdosfsmount *pmp; 84927a0bc89SDoug Rabson 850952a6212SJordan K. Hubbard pmp = VFSTOMSDOSFS(mp); 85127a0bc89SDoug Rabson sbp->f_bsize = pmp->pm_bpcluster; 85227a0bc89SDoug Rabson sbp->f_iosize = pmp->pm_bpcluster; 85327a0bc89SDoug Rabson sbp->f_blocks = pmp->pm_nmbrofclusters; 85427a0bc89SDoug Rabson sbp->f_bfree = pmp->pm_freeclustercount; 85527a0bc89SDoug Rabson sbp->f_bavail = pmp->pm_freeclustercount; 85627a0bc89SDoug Rabson sbp->f_files = pmp->pm_RootDirEnts; /* XXX */ 85727a0bc89SDoug Rabson sbp->f_ffree = 0; /* what to put in here? */ 85827a0bc89SDoug Rabson if (sbp != &mp->mnt_stat) { 859af3f60d5SBruce Evans sbp->f_type = mp->mnt_vfc->vfc_typenum; 860952a6212SJordan K. Hubbard bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN); 861952a6212SJordan K. Hubbard bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN); 86227a0bc89SDoug Rabson } 863952a6212SJordan K. Hubbard strncpy(sbp->f_fstypename, mp->mnt_vfc->vfc_name, MFSNAMELEN); 864952a6212SJordan K. Hubbard return (0); 86527a0bc89SDoug Rabson } 86627a0bc89SDoug Rabson 8677fefffeeSPoul-Henning Kamp static int 86827a0bc89SDoug Rabson msdosfs_sync(mp, waitfor, cred, p) 86927a0bc89SDoug Rabson struct mount *mp; 87027a0bc89SDoug Rabson int waitfor; 87127a0bc89SDoug Rabson struct ucred *cred; 87227a0bc89SDoug Rabson struct proc *p; 87327a0bc89SDoug Rabson { 874952a6212SJordan K. Hubbard struct vnode *vp, *nvp; 87527a0bc89SDoug Rabson struct denode *dep; 876952a6212SJordan K. Hubbard struct msdosfsmount *pmp = VFSTOMSDOSFS(mp); 877952a6212SJordan K. Hubbard int error, allerror = 0; 87827a0bc89SDoug Rabson 87927a0bc89SDoug Rabson /* 88027a0bc89SDoug Rabson * If we ever switch to not updating all of the fats all the time, 88127a0bc89SDoug Rabson * this would be the place to update them from the first one. 88227a0bc89SDoug Rabson */ 883dfd5dee1SPeter Wemm if (pmp->pm_fmod != 0) { 884952a6212SJordan K. Hubbard if (pmp->pm_flags & MSDOSFSMNT_RONLY) 88527a0bc89SDoug Rabson panic("msdosfs_sync: rofs mod"); 88627a0bc89SDoug Rabson else { 88727a0bc89SDoug Rabson /* update fats here */ 88827a0bc89SDoug Rabson } 889dfd5dee1SPeter Wemm } 89027a0bc89SDoug Rabson /* 891952a6212SJordan K. Hubbard * Write back each (modified) denode. 89227a0bc89SDoug Rabson */ 893af3f60d5SBruce Evans simple_lock(&mntvnode_slock); 89427a0bc89SDoug Rabson loop: 895c681be37SDmitrij Tejblum for (vp = mp->mnt_vnodelist.lh_first; vp != NULL; vp = nvp) { 896952a6212SJordan K. Hubbard /* 897952a6212SJordan K. Hubbard * If the vnode that we are about to sync is no longer 898c681be37SDmitrij Tejblum * associated with this mount point, start over. 899952a6212SJordan K. Hubbard */ 900952a6212SJordan K. Hubbard if (vp->v_mount != mp) 90127a0bc89SDoug Rabson goto loop; 902952a6212SJordan K. Hubbard 903af3f60d5SBruce Evans simple_lock(&vp->v_interlock); 904952a6212SJordan K. Hubbard nvp = vp->v_mntvnodes.le_next; 90527a0bc89SDoug Rabson dep = VTODE(vp); 906c681be37SDmitrij Tejblum if (vp->v_type == VNON || 907831a80b0SMatthew Dillon ((dep->de_flag & 908c681be37SDmitrij Tejblum (DE_ACCESS | DE_CREATE | DE_UPDATE | DE_MODIFIED)) == 0 && 909831a80b0SMatthew Dillon (TAILQ_EMPTY(&vp->v_dirtyblkhd) || waitfor == MNT_LAZY))) { 910af3f60d5SBruce Evans simple_unlock(&vp->v_interlock); 91127a0bc89SDoug Rabson continue; 912af3f60d5SBruce Evans } 913af3f60d5SBruce Evans simple_unlock(&mntvnode_slock); 914af3f60d5SBruce Evans error = vget(vp, LK_EXCLUSIVE | LK_NOWAIT | LK_INTERLOCK, p); 915af3f60d5SBruce Evans if (error) { 916af3f60d5SBruce Evans simple_lock(&mntvnode_slock); 917af3f60d5SBruce Evans if (error == ENOENT) 91827a0bc89SDoug Rabson goto loop; 919af3f60d5SBruce Evans continue; 920af3f60d5SBruce Evans } 921c3c6d51eSPoul-Henning Kamp error = VOP_FSYNC(vp, cred, waitfor, p); 922c3c6d51eSPoul-Henning Kamp if (error) 92327a0bc89SDoug Rabson allerror = error; 924af3f60d5SBruce Evans VOP_UNLOCK(vp, 0, p); 925c681be37SDmitrij Tejblum vrele(vp); 926af3f60d5SBruce Evans simple_lock(&mntvnode_slock); 92727a0bc89SDoug Rabson } 928af3f60d5SBruce Evans simple_unlock(&mntvnode_slock); 92927a0bc89SDoug Rabson 93027a0bc89SDoug Rabson /* 93127a0bc89SDoug Rabson * Flush filesystem control info. 93227a0bc89SDoug Rabson */ 933c681be37SDmitrij Tejblum if (waitfor != MNT_LAZY) { 934c681be37SDmitrij Tejblum vn_lock(pmp->pm_devvp, LK_EXCLUSIVE | LK_RETRY, p); 935c3c6d51eSPoul-Henning Kamp error = VOP_FSYNC(pmp->pm_devvp, cred, waitfor, p); 936c3c6d51eSPoul-Henning Kamp if (error) 93727a0bc89SDoug Rabson allerror = error; 938c681be37SDmitrij Tejblum VOP_UNLOCK(pmp->pm_devvp, 0, p); 939c681be37SDmitrij Tejblum } 940952a6212SJordan K. Hubbard return (allerror); 94127a0bc89SDoug Rabson } 94227a0bc89SDoug Rabson 9437fefffeeSPoul-Henning Kamp static int 94427a0bc89SDoug Rabson msdosfs_fhtovp(mp, fhp, nam, vpp, exflagsp, credanonp) 94527a0bc89SDoug Rabson struct mount *mp; 94627a0bc89SDoug Rabson struct fid *fhp; 94757bf258eSGarrett Wollman struct sockaddr *nam; 94827a0bc89SDoug Rabson struct vnode **vpp; 94927a0bc89SDoug Rabson int *exflagsp; 95027a0bc89SDoug Rabson struct ucred **credanonp; 95127a0bc89SDoug Rabson { 952952a6212SJordan K. Hubbard struct msdosfsmount *pmp = VFSTOMSDOSFS(mp); 95327a0bc89SDoug Rabson struct defid *defhp = (struct defid *) fhp; 95427a0bc89SDoug Rabson struct denode *dep; 95527a0bc89SDoug Rabson struct netcred *np; 95627a0bc89SDoug Rabson int error; 95727a0bc89SDoug Rabson 95827a0bc89SDoug Rabson np = vfs_export_lookup(mp, &pmp->pm_export, nam); 95927a0bc89SDoug Rabson if (np == NULL) 960952a6212SJordan K. Hubbard return (EACCES); 961952a6212SJordan K. Hubbard error = deget(pmp, defhp->defid_dirclust, defhp->defid_dirofs, &dep); 96227a0bc89SDoug Rabson if (error) { 96327a0bc89SDoug Rabson *vpp = NULLVP; 964952a6212SJordan K. Hubbard return (error); 96527a0bc89SDoug Rabson } 96627a0bc89SDoug Rabson *vpp = DETOV(dep); 96727a0bc89SDoug Rabson *exflagsp = np->netc_exflags; 96827a0bc89SDoug Rabson *credanonp = &np->netc_anon; 969952a6212SJordan K. Hubbard return (0); 97027a0bc89SDoug Rabson } 97127a0bc89SDoug Rabson 9727fefffeeSPoul-Henning Kamp static int 97327a0bc89SDoug Rabson msdosfs_vptofh(vp, fhp) 97427a0bc89SDoug Rabson struct vnode *vp; 97527a0bc89SDoug Rabson struct fid *fhp; 97627a0bc89SDoug Rabson { 977952a6212SJordan K. Hubbard struct denode *dep; 978952a6212SJordan K. Hubbard struct defid *defhp; 97927a0bc89SDoug Rabson 980952a6212SJordan K. Hubbard dep = VTODE(vp); 981952a6212SJordan K. Hubbard defhp = (struct defid *)fhp; 98227a0bc89SDoug Rabson defhp->defid_len = sizeof(struct defid); 98327a0bc89SDoug Rabson defhp->defid_dirclust = dep->de_dirclust; 98427a0bc89SDoug Rabson defhp->defid_dirofs = dep->de_diroffset; 985952a6212SJordan K. Hubbard /* defhp->defid_gen = dep->de_gen; */ 986952a6212SJordan K. Hubbard return (0); 98727a0bc89SDoug Rabson } 98827a0bc89SDoug Rabson 9897fefffeeSPoul-Henning Kamp static int 99027a0bc89SDoug Rabson msdosfs_vget(mp, ino, vpp) 99127a0bc89SDoug Rabson struct mount *mp; 99227a0bc89SDoug Rabson ino_t ino; 99327a0bc89SDoug Rabson struct vnode **vpp; 99427a0bc89SDoug Rabson { 99527a0bc89SDoug Rabson return EOPNOTSUPP; 99627a0bc89SDoug Rabson } 99727a0bc89SDoug Rabson 99830ffadf3SPoul-Henning Kamp static struct vfsops msdosfs_vfsops = { 99927a0bc89SDoug Rabson msdosfs_mount, 100027a0bc89SDoug Rabson msdosfs_start, 100127a0bc89SDoug Rabson msdosfs_unmount, 100227a0bc89SDoug Rabson msdosfs_root, 100327a0bc89SDoug Rabson msdosfs_quotactl, 100427a0bc89SDoug Rabson msdosfs_statfs, 100527a0bc89SDoug Rabson msdosfs_sync, 100627a0bc89SDoug Rabson msdosfs_vget, 100727a0bc89SDoug Rabson msdosfs_fhtovp, 100827a0bc89SDoug Rabson msdosfs_vptofh, 100927a0bc89SDoug Rabson msdosfs_init 101027a0bc89SDoug Rabson }; 1011c901836cSGarrett Wollman 10128994ca3cSBruce Evans VFS_SET(msdosfs_vfsops, msdos, 0); 1013