1997-11-17 18:36:17 +03:00
|
|
|
/* $NetBSD: msdosfsmount.h,v 1.17 1997/11/17 15:37:07 ws Exp $ */
|
1994-06-29 10:29:24 +04:00
|
|
|
|
1994-07-19 01:38:08 +04:00
|
|
|
/*-
|
1997-10-17 15:23:29 +04:00
|
|
|
* Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
|
|
|
|
* Copyright (C) 1994, 1995, 1997 TooLs GmbH.
|
1994-07-19 01:38:08 +04:00
|
|
|
* All rights reserved.
|
1994-08-21 22:43:49 +04:00
|
|
|
* Original code by Paul Popelka (paulp@uts.amdahl.com) (see below).
|
1994-07-19 01:38:08 +04:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by TooLs GmbH.
|
|
|
|
* 4. The name of TooLs GmbH may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
|
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
|
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
|
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
1993-08-13 15:35:13 +04:00
|
|
|
/*
|
|
|
|
* Written by Paul Popelka (paulp@uts.amdahl.com)
|
1997-11-17 18:36:17 +03:00
|
|
|
*
|
1993-08-13 15:35:13 +04:00
|
|
|
* You can do anything you want with this software, just don't say you wrote
|
|
|
|
* it, and don't remove this notice.
|
1997-11-17 18:36:17 +03:00
|
|
|
*
|
1993-08-13 15:35:13 +04:00
|
|
|
* This software is provided "as is".
|
1997-11-17 18:36:17 +03:00
|
|
|
*
|
1993-08-13 15:35:13 +04:00
|
|
|
* The author supplies this software to be publicly redistributed on the
|
|
|
|
* understanding that the author is not responsible for the correct
|
|
|
|
* functioning of this software in any circumstances and is not liable for
|
|
|
|
* any damages caused by this software.
|
1997-11-17 18:36:17 +03:00
|
|
|
*
|
1993-08-13 15:35:13 +04:00
|
|
|
* October 1992
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Layout of the mount control block for a msdos file system.
|
|
|
|
*/
|
|
|
|
struct msdosfsmount {
|
|
|
|
struct mount *pm_mountp;/* vfs mount struct for this fs */
|
|
|
|
dev_t pm_dev; /* block special device mounted */
|
1994-04-07 11:30:23 +04:00
|
|
|
uid_t pm_uid; /* uid to set as owner of the files */
|
|
|
|
gid_t pm_gid; /* gid to set as owner of the files */
|
|
|
|
mode_t pm_mask; /* mask to and with file protection bits */
|
1993-08-13 15:35:13 +04:00
|
|
|
struct vnode *pm_devvp; /* vnode for block device mntd */
|
|
|
|
struct bpb50 pm_bpb; /* BIOS parameter blk for this fs */
|
1997-10-17 15:23:29 +04:00
|
|
|
u_long pm_FATsecs; /* actual number of fat sectors */
|
1993-08-13 15:35:13 +04:00
|
|
|
u_long pm_fatblk; /* block # of first FAT */
|
1997-10-17 15:23:29 +04:00
|
|
|
u_long pm_rootdirblk; /* block # (cluster # for FAT32) of root directory number */
|
1993-08-13 15:35:13 +04:00
|
|
|
u_long pm_rootdirsize; /* size in blocks (not clusters) */
|
|
|
|
u_long pm_firstcluster; /* block number of first cluster */
|
|
|
|
u_long pm_nmbrofclusters; /* # of clusters in filesystem */
|
|
|
|
u_long pm_maxcluster; /* maximum cluster number */
|
|
|
|
u_long pm_freeclustercount; /* number of free clusters */
|
|
|
|
u_long pm_cnshift; /* shift file offset right this amount to get a cluster number */
|
|
|
|
u_long pm_crbomask; /* and a file offset with this mask to get cluster rel offset */
|
1995-10-15 18:34:19 +03:00
|
|
|
u_long pm_bnshift; /* shift file offset right this amount to get a block number */
|
1993-08-13 15:35:13 +04:00
|
|
|
u_long pm_bpcluster; /* bytes per cluster */
|
|
|
|
u_long pm_fmod; /* ~0 if fs is modified, this can rollover to 0 */
|
|
|
|
u_long pm_fatblocksize; /* size of fat blocks in bytes */
|
|
|
|
u_long pm_fatblocksec; /* size of fat blocks in sectors */
|
|
|
|
u_long pm_fatsize; /* size of fat in bytes */
|
1997-10-17 15:23:29 +04:00
|
|
|
u_long pm_fatmask; /* mask to use for fat numbers */
|
|
|
|
u_long pm_fsinfo; /* fsinfo block number */
|
|
|
|
u_long pm_nxtfree; /* next free cluster in fsinfo block */
|
|
|
|
u_int pm_fatmult; /* these 2 values are used in fat */
|
|
|
|
u_int pm_fatdiv; /* offset computation */
|
|
|
|
u_int pm_curfat; /* current fat for FAT32 (0 otherwise) */
|
1994-07-19 01:38:08 +04:00
|
|
|
u_int *pm_inusemap; /* ptr to bitmap of in-use clusters */
|
1995-10-15 18:34:19 +03:00
|
|
|
u_int pm_flags; /* see below */
|
1994-07-17 01:32:06 +04:00
|
|
|
struct netexport pm_export; /* export information */
|
1993-08-13 15:35:13 +04:00
|
|
|
};
|
1997-10-17 15:23:29 +04:00
|
|
|
/* Byte offset in FAT on filesystem pmp, cluster cn */
|
|
|
|
#define FATOFS(pmp, cn) ((cn) * (pmp)->pm_fatmult / (pmp)->pm_fatdiv)
|
1993-08-13 15:35:13 +04:00
|
|
|
|
1995-10-15 18:34:19 +03:00
|
|
|
/*
|
|
|
|
* Mount point flags:
|
|
|
|
*/
|
1996-02-09 22:13:39 +03:00
|
|
|
#if 0
|
|
|
|
/* Defined in <sys/mount.h> */
|
|
|
|
#define MSDOSFSMNT_SHORTNAME 1
|
|
|
|
#define MSDOSFSMNT_LONGNAME 2
|
|
|
|
#define MSDOSFSMNT_NOWIN95 4
|
|
|
|
#define MSDOSFSMNT_GEMDOSFS 8
|
|
|
|
#endif
|
|
|
|
|
1995-10-15 18:34:19 +03:00
|
|
|
/* All flags above: */
|
|
|
|
#define MSDOSFSMNT_MNTOPT \
|
1996-01-19 17:28:05 +03:00
|
|
|
(MSDOSFSMNT_SHORTNAME|MSDOSFSMNT_LONGNAME|MSDOSFSMNT_NOWIN95 \
|
|
|
|
|MSDOSFSMNT_GEMDOSFS)
|
1995-10-15 18:34:19 +03:00
|
|
|
#define MSDOSFSMNT_RONLY 0x80000000 /* mounted read-only */
|
|
|
|
#define MSDOSFSMNT_WAITONFAT 0x40000000 /* mounted synchronous */
|
1997-10-17 15:23:29 +04:00
|
|
|
#define MSDOSFS_FATMIRROR 0x20000000 /* FAT is mirrored */
|
1995-10-15 18:34:19 +03:00
|
|
|
|
1994-09-22 06:34:49 +04:00
|
|
|
#define VFSTOMSDOSFS(mp) ((struct msdosfsmount *)mp->mnt_data)
|
|
|
|
|
1994-07-19 01:38:08 +04:00
|
|
|
/* Number of bits in one pm_inusemap item: */
|
|
|
|
#define N_INUSEBITS (8 * sizeof(u_int))
|
|
|
|
|
1993-08-13 15:35:13 +04:00
|
|
|
/*
|
|
|
|
* Shorthand for fields in the bpb contained in the msdosfsmount structure.
|
|
|
|
*/
|
|
|
|
#define pm_BytesPerSec pm_bpb.bpbBytesPerSec
|
|
|
|
#define pm_ResSectors pm_bpb.bpbResSectors
|
|
|
|
#define pm_FATs pm_bpb.bpbFATs
|
|
|
|
#define pm_RootDirEnts pm_bpb.bpbRootDirEnts
|
|
|
|
#define pm_Sectors pm_bpb.bpbSectors
|
|
|
|
#define pm_Media pm_bpb.bpbMedia
|
|
|
|
#define pm_SecPerTrack pm_bpb.bpbSecPerTrack
|
|
|
|
#define pm_Heads pm_bpb.bpbHeads
|
|
|
|
#define pm_HiddenSects pm_bpb.bpbHiddenSecs
|
|
|
|
#define pm_HugeSectors pm_bpb.bpbHugeSectors
|
|
|
|
|
|
|
|
/*
|
1995-10-15 18:34:19 +03:00
|
|
|
* Convert pointer to buffer -> pointer to direntry
|
1993-08-13 15:35:13 +04:00
|
|
|
*/
|
1995-10-15 18:34:19 +03:00
|
|
|
#define bptoep(pmp, bp, dirofs) \
|
|
|
|
((struct direntry *)(((bp)->b_data) \
|
|
|
|
+ ((dirofs) & (pmp)->pm_crbomask)))
|
1993-08-13 15:35:13 +04:00
|
|
|
|
|
|
|
/*
|
1995-10-15 18:34:19 +03:00
|
|
|
* Convert block number to cluster number
|
1993-08-13 15:35:13 +04:00
|
|
|
*/
|
1995-10-15 18:34:19 +03:00
|
|
|
#define de_bn2cn(pmp, bn) \
|
|
|
|
((bn) >> ((pmp)->pm_cnshift - (pmp)->pm_bnshift))
|
1993-08-13 15:35:13 +04:00
|
|
|
|
|
|
|
/*
|
1995-10-15 18:34:19 +03:00
|
|
|
* Convert cluster number to block number
|
1993-08-13 15:35:13 +04:00
|
|
|
*/
|
1995-10-15 18:34:19 +03:00
|
|
|
#define de_cn2bn(pmp, cn) \
|
|
|
|
((cn) << ((pmp)->pm_cnshift - (pmp)->pm_bnshift))
|
1993-08-13 15:35:13 +04:00
|
|
|
|
|
|
|
/*
|
1995-10-15 18:34:19 +03:00
|
|
|
* Convert file offset to cluster number
|
1993-08-13 15:35:13 +04:00
|
|
|
*/
|
1995-10-15 18:34:19 +03:00
|
|
|
#define de_cluster(pmp, off) \
|
|
|
|
((off) >> (pmp)->pm_cnshift)
|
1993-08-13 15:35:13 +04:00
|
|
|
|
|
|
|
/*
|
1995-10-15 18:34:19 +03:00
|
|
|
* Clusters required to hold size bytes
|
1993-08-13 15:35:13 +04:00
|
|
|
*/
|
1995-10-15 18:34:19 +03:00
|
|
|
#define de_clcount(pmp, size) \
|
|
|
|
(((size) + (pmp)->pm_bpcluster - 1) >> (pmp)->pm_cnshift)
|
1993-08-13 15:35:13 +04:00
|
|
|
|
1994-07-19 01:38:08 +04:00
|
|
|
/*
|
1995-10-15 18:34:19 +03:00
|
|
|
* Convert file offset to block number
|
1994-07-19 01:38:08 +04:00
|
|
|
*/
|
|
|
|
#define de_blk(pmp, off) \
|
1995-10-15 18:34:19 +03:00
|
|
|
(de_cn2bn(pmp, de_cluster((pmp), (off))))
|
1994-07-19 01:38:08 +04:00
|
|
|
|
|
|
|
/*
|
1995-10-15 18:34:19 +03:00
|
|
|
* Convert cluster number to file offset
|
1994-07-19 01:38:08 +04:00
|
|
|
*/
|
1995-10-15 18:34:19 +03:00
|
|
|
#define de_cn2off(pmp, cn) \
|
|
|
|
((cn) << (pmp)->pm_cnshift)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Convert block number to file offset
|
|
|
|
*/
|
|
|
|
#define de_bn2off(pmp, bn) \
|
|
|
|
((bn) << (pmp)->pm_bnshift)
|
|
|
|
/*
|
|
|
|
* Map a cluster number into a filesystem relative block number.
|
|
|
|
*/
|
|
|
|
#define cntobn(pmp, cn) \
|
|
|
|
(de_cn2bn((pmp), (cn)-CLUST_FIRST) + (pmp)->pm_firstcluster)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Calculate block number for directory entry in root dir, offset dirofs
|
|
|
|
*/
|
|
|
|
#define roottobn(pmp, dirofs) \
|
|
|
|
(de_blk((pmp), (dirofs)) + (pmp)->pm_rootdirblk)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Calculate block number for directory entry at cluster dirclu, offset
|
|
|
|
* dirofs
|
|
|
|
*/
|
|
|
|
#define detobn(pmp, dirclu, dirofs) \
|
|
|
|
((dirclu) == MSDOSFSROOT \
|
|
|
|
? roottobn((pmp), (dirofs)) \
|
|
|
|
: cntobn((pmp), (dirclu)))
|
1994-07-19 01:38:08 +04:00
|
|
|
|
1993-08-13 15:35:13 +04:00
|
|
|
/*
|
|
|
|
* Prototypes for MSDOSFS virtual filesystem operations
|
|
|
|
*/
|
1996-12-22 13:31:41 +03:00
|
|
|
int msdosfs_mount __P((struct mount *, const char *, void *, struct nameidata *, struct proc *));
|
1994-07-17 01:32:06 +04:00
|
|
|
int msdosfs_start __P((struct mount *, int, struct proc *));
|
|
|
|
int msdosfs_unmount __P((struct mount *, int, struct proc *));
|
|
|
|
int msdosfs_root __P((struct mount *, struct vnode **));
|
|
|
|
int msdosfs_quotactl __P((struct mount *, int, uid_t, caddr_t, struct proc *));
|
|
|
|
int msdosfs_statfs __P((struct mount *, struct statfs *, struct proc *));
|
|
|
|
int msdosfs_sync __P((struct mount *, int, struct ucred *, struct proc *));
|
|
|
|
int msdosfs_fhtovp __P((struct mount *, struct fid *, struct mbuf *, struct vnode **, int *, struct ucred **));
|
|
|
|
int msdosfs_vptofh __P((struct vnode *, struct fid *));
|
1996-02-09 22:13:39 +03:00
|
|
|
void msdosfs_init __P((void));
|