2 * An FFS file system is a sequence of cylinder groups.
4 * Each cylinder group is laid out as follows:
6 * fs superblock (Fsblk)
7 * cylinder group block (Cgblk)
11 * The location of the fs superblock in the first cylinder
12 * group is known. The rest of the info about cylinder group
13 * layout can be derived from the super block.
16 #define daddr_t u32int
19 typedef struct Cgblk Cgblk;
20 typedef struct Cylgrp Cylgrp;
21 typedef struct Cylsum Cylsum;
22 typedef struct Cylsumtotal Cylsumtotal;
23 typedef struct Ffs Ffs;
24 typedef struct Fsblk Fsblk;
25 typedef struct Inode1 Inode1;
26 typedef struct Inode Inode;
27 typedef struct Dirent Dirent;
33 /* constants for Fsblk */
36 FSMAXVOLLEN = 32, /* UFS2 */
37 FSNOCSPTRSLEN = 128-12,
38 FSNOCSPTRSLEN2 = 128-16, /* UFS2 */
41 FSMAGIC2 = 0x19540119,
42 FSCHECKSUM = 0x7c269d38,
48 /* offset and size of first boot block */
52 /* offset and size of first super block */
54 SBOFF2 = BBOFF+65536, /* UFS2 */
55 SBOFFPIGGY = BBOFF+262144, /* UFS2 */
58 /* minimum block size */
61 /* maximum fragments per block */
64 /* constants for Cgblk */
71 NXADDR = 2, /* UFS2 */
75 /* permissions in Inode.mode */
83 /* type in Inode.mode */
94 /* type in Dirent.type */
124 /* Fields beginning with underscore are deprecated in UFS2 */
129 daddr_t sfragno; /* fragment address of super block in file system */
130 daddr_t cfragno; /* fragment address if cylinder block in file system */
131 daddr_t ifragno; /* fragment offset of inode blocks in file system */
132 daddr_t dfragno; /* fragment offset of data blocks in cg */
133 u32int _cgoffset; /* block (maybe fragment?) offset of Cgblk in cylinder */
136 u32int _nfrag; /* number of blocks in fs * fragsperblock */
138 u32int ncg; /* number of cylinder groups in fs */
139 u32int blocksize; /* block size in fs */
140 u32int fragsize; /* frag size in fs */
141 u32int fragsperblock; /* fragments per block: blocksize / fragsize */
142 u32int minfree; /* ignored by us */
143 u32int rotdelay; /* ... */
153 u32int sbsize; /* size of super block */
154 u32int unused2; /* more stuff we don't use ... */
157 u32int inosperblock; /* inodes per block */
164 daddr_t _csaddr; /* blk addr of cyl grp summary area */
165 u32int cssize; /* size of cyl grp summary area */
166 u32int cgsize; /* cylinder group size */
167 u32int _trackspercyl; /* tracks per cylinder */
168 u32int _secspertrack; /* sectors per track */
169 u32int _secspercyl; /* sectors per cylinder */
170 u32int _ncyl; /* cylinders in fs */
171 u32int _cylspergroup; /* cylinders per group */
172 u32int inospergroup; /* inodes per group */
173 u32int fragspergroup; /* data blocks per group * fragperblock */
174 Cylsum _cstotal; /* more unused... */
179 /* char fsmnt[512]; in UFS1 */
180 char fsmnt[FSMAXMNTLEN2];
181 char volname[FSMAXVOLLEN];
185 uchar ocsp[FSNOCSPTRSLEN]; /* last 4 bytes is contigdirs in UFS2 */
186 u32int contigdirs; /* csp in UFS2 */
187 u32int csp; /* maxcluster in UFS2 */
188 u32int maxcluster; /* active in UFS2 */
190 /* u16int opostbl[16][8]; in UFS1 */
199 u64int pendingblocks;
200 u32int pendinginodes;
201 u32int snapinum[FSMAXSNAP];
204 /* u32int sparecon[26], pendingblocks, pendinginodes; in UFS1 */
208 u32int contigsumsize;
209 u32int maxsymlinklen;
210 u32int _inodefmt; /* format of on-disk inodes */
211 u64int maxfilesize; /* maximum representable file size */
215 u32int _postblformat;
219 u32int magic; /* FSMAGIC or FSMAGIC2 */
223 * Cylinder group block for a file system.
228 u32int magic; /* CGMAGIC */
229 u32int time; /* time last written */
230 u32int num; /* we are cg #cgnum */
231 u16int ncyl; /* number of cylinders in gp */
232 u16int nino; /* number of inodes */
233 u32int nfrag; /* number of fragments */
238 u32int frsum[MAXFRAG]; /* counts of available frags */
241 u32int imapoff; /* offset to used inode map */
242 u32int fmapoff; /* offset to free fragment map */
243 u32int nextfrag; /* next free fragment */
252 /* these are block numbers not fragment numbers */
253 u64int bno; /* disk block address of start of cg */
254 u64int ibno; /* disk block address of first inode */
255 u64int dbno; /* disk block address of first data */
260 * this is the on-disk structure
322 * main file system structure
332 u64int blockspergroup;
333 u64int fragspergroup;