1. Remove a rather strangely gratuitous bit of profanity
[unix-history] / sys / pcfs / pcfsmount.h
CommitLineData
15637ed4
RG
1/*
2 * Written by Paul Popelka (paulp@uts.amdahl.com)
3 *
4 * You can do anything you want with this software,
5 * just don't say you wrote it,
6 * and don't remove this notice.
7 *
8 * This software is provided "as is".
9 *
10 * The author supplies this software to be publicly
11 * redistributed on the understanding that the author
12 * is not responsible for the correct functioning of
13 * this software in any circumstances and is not liable
14 * for any damages caused by this software.
15 *
16 * October 1992
17 *
4c45483e 18 * $Id: pcfsmount.h,v 1.3 1993/11/07 17:51:17 wollman Exp $
15637ed4
RG
19 */
20
bbc3f849
GW
21#ifndef _PCFS_PCFSMOUNT_H_
22#define _PCFS_PCFSMOUNT_H_ 1
23
15637ed4
RG
24/*
25 * Layout of the mount control block for a msdos
26 * file system.
27 */
28struct pcfsmount {
29 struct mount *pm_mountp; /* vfs mount struct for this fs */
30 dev_t pm_dev; /* block special device mounted */
31 struct vnode *pm_devvp; /* vnode for block device mntd */
32 struct bpb50 pm_bpb; /* BIOS parameter blk for this fs */
33 u_long pm_fatblk; /* block # of first FAT */
34 u_long pm_rootdirblk; /* block # of root directory */
35 u_long pm_rootdirsize; /* size in blocks (not clusters) */
36 u_long pm_firstcluster; /* block number of first cluster */
37 u_long pm_nmbrofclusters; /* # of clusters in filesystem */
38 u_long pm_maxcluster; /* maximum cluster number */
39 u_long pm_freeclustercount; /* number of free clusters */
40 u_long pm_lookhere; /* start free cluster search here */
41 u_long pm_bnshift; /* shift file offset right this
42 * amount to get a block number */
43 u_long pm_brbomask; /* and a file offset with this
44 * mask to get block rel offset */
45 u_long pm_cnshift; /* shift file offset right this
46 * amount to get a cluster number */
47 u_long pm_crbomask; /* and a file offset with this
48 * mask to get cluster rel offset */
49 u_long pm_bpcluster; /* bytes per cluster */
50 u_long pm_depclust; /* directory entries per cluster */
51 u_long pm_fmod; /* ~0 if fs is modified, this can
52 * rollover to 0 */
53 u_long pm_fatblocksize; /* size of fat blocks in bytes */
54 u_long pm_fatblocksec; /* size of fat blocks in sectors */
55 u_long pm_fatsize; /* size of fat in bytes */
56 u_char *pm_inusemap; /* ptr to bitmap of in-use clusters */
57 char pm_ronly; /* read only if non-zero */
58 char pm_waitonfat; /* wait for writes of the fat to complt,
59 * when 0 use bdwrite, else use bwrite */
60};
61/*
62 * How to compute pm_cnshift and pm_crbomask.
63 *
64 * pm_crbomask = (pm_SectPerClust * pm_BytesPerSect) - 1
65 * if (bytesperclust == 0) return EBADBLKSZ;
66 * bit = 1;
67 * for (i = 0; i < 32; i++) {
68 * if (bit & bytesperclust) {
69 * if (bit ^ bytesperclust) return EBADBLKSZ;
70 * pm_cnshift = i;
71 * break;
72 * }
73 * bit <<= 1;
74 * }
75 */
76
77/*
78 * Shorthand for fields in the bpb contained in
79 * the pcfsmount structure.
80 */
81#define pm_BytesPerSec pm_bpb.bpbBytesPerSec
82#define pm_SectPerClust pm_bpb.bpbSecPerClust
83#define pm_ResSectors pm_bpb.bpbResSectors
84#define pm_FATs pm_bpb.bpbFATs
85#define pm_RootDirEnts pm_bpb.bpbRootDirEnts
86#define pm_Sectors pm_bpb.bpbSectors
87#define pm_Media pm_bpb.bpbMedia
88#define pm_FATsecs pm_bpb.bpbFATsecs
89#define pm_SecPerTrack pm_bpb.bpbSecPerTrack
90#define pm_Heads pm_bpb.bpbHeads
91#define pm_HiddenSects pm_bpb.bpbHiddenSecs
92#define pm_HugeSectors pm_bpb.bpbHugeSectors
93
94/*
95 * Map a cluster number into a filesystem relative
96 * block number.
97 */
98#define cntobn(pmp, cn) \
99 ((((cn)-CLUST_FIRST) * (pmp)->pm_SectPerClust) + (pmp)->pm_firstcluster)
100
101/*
102 * Map a filesystem relative block number back into
103 * a cluster number.
104 */
105#define bntocn(pmp, bn) \
106 ((((bn) - pmp->pm_firstcluster)/ (pmp)->pm_SectPerClust) + CLUST_FIRST)
107
108/*
109 * Calculate block number for directory entry in root dir, offset dirofs
110 */
111#define roottobn(pmp, dirofs) \
112 (((dirofs) / (pmp)->pm_depclust) * (pmp)->pm_SectPerClust \
113 + (pmp)->pm_rootdirblk)
114
115/*
116 * Calculate block number for directory entry at cluster dirclu, offset dirofs
117 */
118#define detobn(pmp, dirclu, dirofs) \
119 ((dirclu) == PCFSROOT \
120 ? roottobn((pmp), (dirofs)) \
121 : cntobn((pmp), (dirclu)))
122
123/*
124 * Convert pointer to buffer -> pointer to direntry
125 */
126#define bptoep(pmp, bp, dirofs) \
127 ((struct direntry *)((bp)->b_un.b_addr) \
128 + (dirofs) % (pmp)->pm_depclust)
129
130
131/*
132 * Prototypes for PCFS virtual filesystem operations
133 */
134int pcfs_mount __P((struct mount *mp, char *path, caddr_t data,
135 struct nameidata *ndp, struct proc *p));
136int pcfs_start __P((struct mount *mp, int flags, struct proc *p));
137int pcfs_unmount __P((struct mount *mp, int mntflags, struct proc *p));
138int pcfs_root __P((struct mount *mp, struct vnode **vpp));
139int pcfs_quotactl __P((struct mount *mp, int cmds, int uid, /* should be uid_t */
140 caddr_t arg, struct proc *p));
141int pcfs_statfs __P((struct mount *mp, struct statfs *sbp, struct proc *p));
142int pcfs_sync __P((struct mount *mp, int waitfor));
143int pcfs_fhtovp __P((struct mount *mp, struct fid *fhp, struct vnode **vpp));
144int pcfs_vptofh __P((struct vnode *vp, struct fid *fhp));
4c45483e 145void pcfs_init __P((void));
bbc3f849 146#endif /* _PCFS_PCFSMOUNT_H_ */