Annotation of src/sys/fs/msdosfs/msdosfsmount.h, Revision 1.15.30.2
1.15.30.2! yamt 1: /* $NetBSD: msdosfsmount.h,v 1.15.30.1 2012/04/17 00:08:18 yamt Exp $ */
1.1 jdolecek 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:
1.11 christos 50: #ifndef _MSDOSFS_MSDOSFSMOUNT_H_
51: #define _MSDOSFS_MSDOSFSMOUNT_H_
52:
1.1 jdolecek 53: /*
54: * Arguments to mount MSDOS filesystems.
55: */
56: struct msdosfs_args {
57: char *fspec; /* blocks special holding the fs to mount */
1.10 jmmv 58: struct export_args30 _pad1; /* compat with old userland tools */
1.1 jdolecek 59: uid_t uid; /* uid that owns msdosfs files */
60: gid_t gid; /* gid that owns msdosfs files */
61: mode_t mask; /* mask to be applied for msdosfs perms */
62: int flags; /* see below */
1.3 jdolecek 63:
64: /* Following items added after versioning support */
65: int version; /* version of the struct */
1.6 jdolecek 66: #define MSDOSFSMNT_VERSION 3
1.3 jdolecek 67: mode_t dirmask; /* v2: mask to be applied for msdosfs perms */
1.6 jdolecek 68: int gmtoff; /* v3: offset from UTC in seconds */
1.1 jdolecek 69: };
70:
71: /*
72: * Msdosfs mount options:
73: */
74: #define MSDOSFSMNT_SHORTNAME 1 /* Force old DOS short names only */
75: #define MSDOSFSMNT_LONGNAME 2 /* Force Win'95 long names */
76: #define MSDOSFSMNT_NOWIN95 4 /* Completely ignore Win95 entries */
1.15.30.2! yamt 77: #define MSDOSFSMNT_GEMDOSFS 8 /* This is a GEMDOS-flavour */
1.3 jdolecek 78: #define MSDOSFSMNT_VERSIONED 16 /* Struct is versioned */
1.1 jdolecek 79:
80: /* All flags above: */
81: #define MSDOSFSMNT_MNTOPT \
82: (MSDOSFSMNT_SHORTNAME|MSDOSFSMNT_LONGNAME|MSDOSFSMNT_NOWIN95 \
1.3 jdolecek 83: |MSDOSFSMNT_GEMDOSFS|MSDOSFSMNT_VERSIONED)
84:
1.1 jdolecek 85: #define MSDOSFSMNT_RONLY 0x80000000 /* mounted read-only */
86: #define MSDOSFSMNT_WAITONFAT 0x40000000 /* mounted synchronous */
87: #define MSDOSFS_FATMIRROR 0x20000000 /* FAT is mirrored */
88:
89: #define MSDOSFSMNT_BITS "\177\20" \
1.3 jdolecek 90: "b\00shortname\0b\01longname\0b\02nowin95\0b\03gemdosfs\0b\04mntversioned\0" \
1.5 yamt 91: "b\037ronly\0b\036waitonfat\0b\035fatmirror\0"
1.1 jdolecek 92:
93: #ifdef _KERNEL
1.2 thorpej 94: #include <sys/mallocvar.h>
1.15.30.1 yamt 95: #ifdef MALLOC_DECLARE
1.2 thorpej 96: MALLOC_DECLARE(M_MSDOSFSMNT);
1.14 rumble 97: MALLOC_DECLARE(M_MSDOSFSTMP);
1.15.30.1 yamt 98: #endif
1.2 thorpej 99:
1.1 jdolecek 100: /*
1.15.30.2! yamt 101: * Layout of the mount control block for a MSDOSFS file system.
1.1 jdolecek 102: */
103: struct msdosfsmount {
104: struct mount *pm_mountp;/* vfs mount struct for this fs */
105: dev_t pm_dev; /* block special device mounted */
106: uid_t pm_uid; /* uid to set as owner of the files */
107: gid_t pm_gid; /* gid to set as owner of the files */
1.3 jdolecek 108: mode_t pm_mask; /* mask to and with file protection bits
109: for files */
110: mode_t pm_dirmask; /* mask to and with file protection bits
111: for directories */
1.4 itojun 112: int pm_gmtoff; /* offset from UTC in seconds */
1.1 jdolecek 113: struct vnode *pm_devvp; /* vnode for block device mntd */
114: struct bpb50 pm_bpb; /* BIOS parameter blk for this fs */
1.15.30.2! yamt 115: u_long pm_FATsecs; /* actual number of FAT sectors */
1.12 scw 116: u_long pm_fatblk; /* sector # of first FAT */
117: u_long pm_rootdirblk; /* sector # (cluster # for FAT32) of root directory number */
118: u_long pm_rootdirsize; /* size in sectors (not clusters) */
119: u_long pm_firstcluster; /* sector number of first cluster */
1.1 jdolecek 120: u_long pm_nmbrofclusters; /* # of clusters in filesystem */
121: u_long pm_maxcluster; /* maximum cluster number */
122: u_long pm_freeclustercount; /* number of free clusters */
123: u_long pm_cnshift; /* shift file offset right this amount to get a cluster number */
124: u_long pm_crbomask; /* and a file offset with this mask to get cluster rel offset */
1.12 scw 125: u_long pm_bnshift; /* shift file offset right this amount to get a sector number */
1.1 jdolecek 126: u_long pm_bpcluster; /* bytes per cluster */
127: u_long pm_fmod; /* ~0 if fs is modified, this can rollover to 0 */
1.15.30.2! yamt 128: u_long pm_fatblocksize; /* size of FAT blocks in bytes */
! 129: u_long pm_fatblocksec; /* size of FAT blocks in sectors */
! 130: u_long pm_fatsize; /* size of FAT in bytes */
! 131: u_long pm_fatmask; /* mask to use for FAT numbers */
1.1 jdolecek 132: u_long pm_fsinfo; /* fsinfo block number */
133: u_long pm_nxtfree; /* next free cluster in fsinfo block */
1.15.30.2! yamt 134: u_int pm_fatmult; /* these 2 values are used in FAT */
1.1 jdolecek 135: u_int pm_fatdiv; /* offset computation */
1.15.30.2! yamt 136: u_int pm_curfat; /* current FAT for FAT32 (0 otherwise) */
1.1 jdolecek 137: u_int *pm_inusemap; /* ptr to bitmap of in-use clusters */
138: u_int pm_flags; /* see below */
139: };
140: /* Byte offset in FAT on filesystem pmp, cluster cn */
141: #define FATOFS(pmp, cn) ((cn) * (pmp)->pm_fatmult / (pmp)->pm_fatdiv)
142:
143: #define VFSTOMSDOSFS(mp) ((struct msdosfsmount *)mp->mnt_data)
144:
145: /* Number of bits in one pm_inusemap item: */
146: #define N_INUSEBITS (8 * sizeof(u_int))
147:
148: /*
149: * Shorthand for fields in the bpb contained in the msdosfsmount structure.
150: */
151: #define pm_BytesPerSec pm_bpb.bpbBytesPerSec
152: #define pm_ResSectors pm_bpb.bpbResSectors
153: #define pm_FATs pm_bpb.bpbFATs
154: #define pm_RootDirEnts pm_bpb.bpbRootDirEnts
155: #define pm_Sectors pm_bpb.bpbSectors
156: #define pm_Media pm_bpb.bpbMedia
157: #define pm_SecPerTrack pm_bpb.bpbSecPerTrack
158: #define pm_Heads pm_bpb.bpbHeads
159: #define pm_HiddenSects pm_bpb.bpbHiddenSecs
160: #define pm_HugeSectors pm_bpb.bpbHugeSectors
161:
162: /*
163: * Convert pointer to buffer -> pointer to direntry
164: */
165: #define bptoep(pmp, bp, dirofs) \
1.13 christos 166: ((struct direntry *)(((char *)(bp)->b_data) \
1.1 jdolecek 167: + ((dirofs) & (pmp)->pm_crbomask)))
168:
169: /*
1.12 scw 170: * Convert sector number to cluster number
1.1 jdolecek 171: */
172: #define de_bn2cn(pmp, bn) \
173: ((bn) >> ((pmp)->pm_cnshift - (pmp)->pm_bnshift))
174:
175: /*
1.12 scw 176: * Convert cluster number to sector number
1.1 jdolecek 177: */
178: #define de_cn2bn(pmp, cn) \
179: ((cn) << ((pmp)->pm_cnshift - (pmp)->pm_bnshift))
180:
181: /*
1.12 scw 182: * Convert sector number to kernel block number
183: */
184: #define de_bn2kb(pmp, bn) \
185: ((bn) << ((pmp)->pm_bnshift - DEV_BSHIFT))
186:
187: /*
188: * Convert kernel block number to sector number
189: */
190: #define de_kb2bn(pmp, kb) \
191: ((kb) >> ((pmp)->pm_bnshift - DEV_BSHIFT))
192:
193: /*
1.1 jdolecek 194: * Convert file offset to cluster number
195: */
196: #define de_cluster(pmp, off) \
197: ((off) >> (pmp)->pm_cnshift)
198:
199: /*
200: * Clusters required to hold size bytes
201: */
202: #define de_clcount(pmp, size) \
203: (((size) + (pmp)->pm_bpcluster - 1) >> (pmp)->pm_cnshift)
204:
205: /*
1.12 scw 206: * Convert file offset to sector number
1.1 jdolecek 207: */
208: #define de_blk(pmp, off) \
209: (de_cn2bn(pmp, de_cluster((pmp), (off))))
210:
211: /*
212: * Convert cluster number to file offset
213: */
214: #define de_cn2off(pmp, cn) \
215: ((cn) << (pmp)->pm_cnshift)
216:
217: /*
1.12 scw 218: * Convert sector number to file offset
1.1 jdolecek 219: */
220: #define de_bn2off(pmp, bn) \
221: ((bn) << (pmp)->pm_bnshift)
222: /*
1.12 scw 223: * Map a cluster number into a filesystem relative sector number.
1.1 jdolecek 224: */
225: #define cntobn(pmp, cn) \
226: (de_cn2bn((pmp), (cn)-CLUST_FIRST) + (pmp)->pm_firstcluster)
227:
228: /*
1.12 scw 229: * Calculate sector number for directory entry in root dir, offset dirofs
1.1 jdolecek 230: */
231: #define roottobn(pmp, dirofs) \
232: (de_blk((pmp), (dirofs)) + (pmp)->pm_rootdirblk)
233:
234: /*
1.12 scw 235: * Calculate sector number for directory entry at cluster dirclu, offset
1.1 jdolecek 236: * dirofs
237: */
238: #define detobn(pmp, dirclu, dirofs) \
239: ((dirclu) == MSDOSFSROOT \
240: ? roottobn((pmp), (dirofs)) \
241: : cntobn((pmp), (dirclu)))
242:
243: /*
244: * Prototypes for MSDOSFS virtual filesystem operations
245: */
1.8 xtraeme 246: void msdosfs_init(void);
247: void msdosfs_reinit(void);
248: void msdosfs_done(void);
1.1 jdolecek 249:
250: #endif /* _KERNEL */
1.11 christos 251: #endif /* _MSDOSFS_MSDOSFSMOUNT_H_ */
CVSweb <webmaster@jp.NetBSD.org>