The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/fs/msdosfs/msdosfsmount.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: msdosfsmount.h,v 1.5.2.2 2004/05/23 10:46:11 tron Exp $        */
    2 
    3 /*-
    4  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
    5  * Copyright (C) 1994, 1995, 1997 TooLs GmbH.
    6  * All rights reserved.
    7  * Original code by Paul Popelka (paulp@uts.amdahl.com) (see below).
    8  *
    9  * Redistribution and use in source and binary forms, with or without
   10  * modification, are permitted provided that the following conditions
   11  * are met:
   12  * 1. Redistributions of source code must retain the above copyright
   13  *    notice, this list of conditions and the following disclaimer.
   14  * 2. Redistributions in binary form must reproduce the above copyright
   15  *    notice, this list of conditions and the following disclaimer in the
   16  *    documentation and/or other materials provided with the distribution.
   17  * 3. All advertising materials mentioning features or use of this software
   18  *    must display the following acknowledgement:
   19  *      This product includes software developed by TooLs GmbH.
   20  * 4. The name of TooLs GmbH may not be used to endorse or promote products
   21  *    derived from this software without specific prior written permission.
   22  *
   23  * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
   24  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   25  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   26  * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   27  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
   28  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
   29  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
   30  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
   31  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
   32  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   33  */
   34 /*
   35  * Written by Paul Popelka (paulp@uts.amdahl.com)
   36  *
   37  * You can do anything you want with this software, just don't say you wrote
   38  * it, and don't remove this notice.
   39  *
   40  * This software is provided "as is".
   41  *
   42  * The author supplies this software to be publicly redistributed on the
   43  * understanding that the author is not responsible for the correct
   44  * functioning of this software in any circumstances and is not liable for
   45  * any damages caused by this software.
   46  *
   47  * October 1992
   48  */
   49 
   50 /*
   51  *  Arguments to mount MSDOS filesystems.
   52  */
   53 struct msdosfs_args {
   54         char    *fspec;         /* blocks special holding the fs to mount */
   55         struct  export_args export;     /* network export information */
   56         uid_t   uid;            /* uid that owns msdosfs files */
   57         gid_t   gid;            /* gid that owns msdosfs files */
   58         mode_t  mask;           /* mask to be applied for msdosfs perms */
   59         int     flags;          /* see below */
   60 
   61         /* Following items added after versioning support */
   62         int     version;        /* version of the struct */
   63 #define MSDOSFSMNT_VERSION      3
   64         mode_t  dirmask;        /* v2: mask to be applied for msdosfs perms */
   65         int     gmtoff;         /* v3: offset from UTC in seconds */
   66 };
   67 
   68 /*
   69  * Msdosfs mount options:
   70  */
   71 #define MSDOSFSMNT_SHORTNAME    1       /* Force old DOS short names only */
   72 #define MSDOSFSMNT_LONGNAME     2       /* Force Win'95 long names */
   73 #define MSDOSFSMNT_NOWIN95      4       /* Completely ignore Win95 entries */
   74 #define MSDOSFSMNT_GEMDOSFS     8       /* This is a gemdos-flavour */
   75 #define MSDOSFSMNT_VERSIONED    16      /* Struct is versioned */
   76 
   77 /* All flags above: */
   78 #define MSDOSFSMNT_MNTOPT \
   79         (MSDOSFSMNT_SHORTNAME|MSDOSFSMNT_LONGNAME|MSDOSFSMNT_NOWIN95 \
   80          |MSDOSFSMNT_GEMDOSFS|MSDOSFSMNT_VERSIONED)
   81 
   82 #define MSDOSFSMNT_RONLY        0x80000000      /* mounted read-only    */
   83 #define MSDOSFSMNT_WAITONFAT    0x40000000      /* mounted synchronous  */
   84 #define MSDOSFS_FATMIRROR       0x20000000      /* FAT is mirrored */
   85 
   86 #define MSDOSFSMNT_BITS "\177\2" \
   87     "b\00shortname\0b\01longname\0b\02nowin95\0b\03gemdosfs\0b\04mntversioned\0" \
   88     "b\037ronly\0b\036waitonfat\0b\035fatmirror\0"
   89 
   90 #ifdef _KERNEL
   91 #include <sys/mallocvar.h>
   92 MALLOC_DECLARE(M_MSDOSFSMNT);
   93 
   94 /*
   95  * Layout of the mount control block for a msdos file system.
   96  */
   97 struct msdosfsmount {
   98         struct mount *pm_mountp;/* vfs mount struct for this fs */
   99         dev_t pm_dev;           /* block special device mounted */
  100         uid_t pm_uid;           /* uid to set as owner of the files */
  101         gid_t pm_gid;           /* gid to set as owner of the files */
  102         mode_t pm_mask;         /* mask to and with file protection bits
  103                                    for files */
  104         mode_t pm_dirmask;      /* mask to and with file protection bits
  105                                    for directories */
  106         int pm_gmtoff;          /* offset from UTC in seconds */
  107         struct vnode *pm_devvp; /* vnode for block device mntd */
  108         struct bpb50 pm_bpb;    /* BIOS parameter blk for this fs */
  109         u_long pm_FATsecs;      /* actual number of fat sectors */
  110         u_long pm_fatblk;       /* block # of first FAT */
  111         u_long pm_rootdirblk;   /* block # (cluster # for FAT32) of root directory number */
  112         u_long pm_rootdirsize;  /* size in blocks (not clusters) */
  113         u_long pm_firstcluster; /* block number of first cluster */
  114         u_long pm_nmbrofclusters;       /* # of clusters in filesystem */
  115         u_long pm_maxcluster;   /* maximum cluster number */
  116         u_long pm_freeclustercount;     /* number of free clusters */
  117         u_long pm_cnshift;      /* shift file offset right this amount to get a cluster number */
  118         u_long pm_crbomask;     /* and a file offset with this mask to get cluster rel offset */
  119         u_long pm_bnshift;      /* shift file offset right this amount to get a block number */
  120         u_long pm_bpcluster;    /* bytes per cluster */
  121         u_long pm_fmod;         /* ~0 if fs is modified, this can rollover to 0 */
  122         u_long pm_fatblocksize; /* size of fat blocks in bytes */
  123         u_long pm_fatblocksec;  /* size of fat blocks in sectors */
  124         u_long pm_fatsize;      /* size of fat in bytes */
  125         u_long pm_fatmask;      /* mask to use for fat numbers */
  126         u_long pm_fsinfo;       /* fsinfo block number */
  127         u_long pm_nxtfree;      /* next free cluster in fsinfo block */
  128         u_int pm_fatmult;       /* these 2 values are used in fat */
  129         u_int pm_fatdiv;        /*      offset computation */
  130         u_int pm_curfat;        /* current fat for FAT32 (0 otherwise) */
  131         u_int *pm_inusemap;     /* ptr to bitmap of in-use clusters */
  132         u_int pm_flags;         /* see below */
  133         struct netexport pm_export;     /* export information */
  134 };
  135 /* Byte offset in FAT on filesystem pmp, cluster cn */
  136 #define FATOFS(pmp, cn) ((cn) * (pmp)->pm_fatmult / (pmp)->pm_fatdiv)
  137 
  138 #define VFSTOMSDOSFS(mp)        ((struct msdosfsmount *)mp->mnt_data)
  139 
  140 /* Number of bits in one pm_inusemap item: */
  141 #define N_INUSEBITS     (8 * sizeof(u_int))
  142 
  143 /*
  144  * Shorthand for fields in the bpb contained in the msdosfsmount structure.
  145  */
  146 #define pm_BytesPerSec  pm_bpb.bpbBytesPerSec
  147 #define pm_ResSectors   pm_bpb.bpbResSectors
  148 #define pm_FATs         pm_bpb.bpbFATs
  149 #define pm_RootDirEnts  pm_bpb.bpbRootDirEnts
  150 #define pm_Sectors      pm_bpb.bpbSectors
  151 #define pm_Media        pm_bpb.bpbMedia
  152 #define pm_SecPerTrack  pm_bpb.bpbSecPerTrack
  153 #define pm_Heads        pm_bpb.bpbHeads
  154 #define pm_HiddenSects  pm_bpb.bpbHiddenSecs
  155 #define pm_HugeSectors  pm_bpb.bpbHugeSectors
  156 
  157 /*
  158  * Convert pointer to buffer -> pointer to direntry
  159  */
  160 #define bptoep(pmp, bp, dirofs) \
  161         ((struct direntry *)(((bp)->b_data)     \
  162          + ((dirofs) & (pmp)->pm_crbomask)))
  163 
  164 /*
  165  * Convert block number to cluster number
  166  */
  167 #define de_bn2cn(pmp, bn) \
  168         ((bn) >> ((pmp)->pm_cnshift - (pmp)->pm_bnshift))
  169 
  170 /*
  171  * Convert cluster number to block number
  172  */
  173 #define de_cn2bn(pmp, cn) \
  174         ((cn) << ((pmp)->pm_cnshift - (pmp)->pm_bnshift))
  175 
  176 /*
  177  * Convert file offset to cluster number
  178  */
  179 #define de_cluster(pmp, off) \
  180         ((off) >> (pmp)->pm_cnshift)
  181 
  182 /*
  183  * Clusters required to hold size bytes
  184  */
  185 #define de_clcount(pmp, size) \
  186         (((size) + (pmp)->pm_bpcluster - 1) >> (pmp)->pm_cnshift)
  187 
  188 /*
  189  * Convert file offset to block number
  190  */
  191 #define de_blk(pmp, off) \
  192         (de_cn2bn(pmp, de_cluster((pmp), (off))))
  193 
  194 /*
  195  * Convert cluster number to file offset
  196  */
  197 #define de_cn2off(pmp, cn) \
  198         ((cn) << (pmp)->pm_cnshift)
  199 
  200 /*
  201  * Convert block number to file offset
  202  */
  203 #define de_bn2off(pmp, bn) \
  204         ((bn) << (pmp)->pm_bnshift)
  205 /*
  206  * Map a cluster number into a filesystem relative block number.
  207  */
  208 #define cntobn(pmp, cn) \
  209         (de_cn2bn((pmp), (cn)-CLUST_FIRST) + (pmp)->pm_firstcluster)
  210 
  211 /*
  212  * Calculate block number for directory entry in root dir, offset dirofs
  213  */
  214 #define roottobn(pmp, dirofs) \
  215         (de_blk((pmp), (dirofs)) + (pmp)->pm_rootdirblk)
  216 
  217 /*
  218  * Calculate block number for directory entry at cluster dirclu, offset
  219  * dirofs
  220  */
  221 #define detobn(pmp, dirclu, dirofs) \
  222         ((dirclu) == MSDOSFSROOT \
  223          ? roottobn((pmp), (dirofs)) \
  224          : cntobn((pmp), (dirclu)))
  225 
  226 /*
  227  * Prototypes for MSDOSFS virtual filesystem operations
  228  */
  229 void msdosfs_init __P((void));
  230 void msdosfs_reinit __P((void));
  231 void msdosfs_done __P((void));
  232 
  233 #ifdef SYSCTL_SETUP_PROTO
  234 SYSCTL_SETUP_PROTO(sysctl_vfs_msdosfs_setup);
  235 #endif /* SYSCTL_SETUP_PROTO */
  236 #endif /* _KERNEL */

Cache object: a4066afa671623b6242426bddc4038c3


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.