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 Ffs Ffs;
23 typedef struct Fsblk Fsblk;
24 typedef struct Inode Inode;
25 typedef struct Dirent Dirent;
31 /* constants for Fsblk */
33 FSNOCSPTRS = 128 / sizeof(void*) - 3,
36 FSCHECKSUM = 0x7c269d38,
42 /* offset and size of first boot block */
46 /* offset and size of first super block */
50 /* minimum block size */
53 /* maximum fragments per block */
56 /* constants for Cgblk */
66 /* permissions in Inode.mode */
74 /* type in Inode.mode */
85 /* type in Dirent.type */
109 daddr_t sfragno; /* fragment address of super block in file system */
110 daddr_t cfragno; /* fragment address if cylinder block in file system */
111 daddr_t ifragno; /* fragment offset of inode blocks in file system */
112 daddr_t dfragno; /* fragment offset of data blocks in cg */
113 u32int cgoffset; /* block (maybe fragment?) offset of Cgblk in cylinder */
116 u32int nfrag; /* number of blocks in fs * fragsperblock */
118 u32int ncg; /* number of cylinder groups in fs */
119 u32int blocksize; /* block size in fs */
120 u32int fragsize; /* frag size in fs */
121 u32int fragsperblock; /* fragments per block: blocksize / fragsize */
122 u32int minfree; /* ignored by us */
123 u32int rotdelay; /* ... */
133 u32int sbsize; /* size of super block */
134 u32int unused2; /* more stuff we don't use ... */
137 u32int inosperblock; /* inodes per block */
144 daddr_t csaddr; /* blk addr of cyl grp summary area */
145 u32int cssize; /* size of cyl grp summary area */
146 u32int cgsize; /* cylinder group size */
147 u32int trackspercyl; /* tracks per cylinder */
148 u32int secspertrack; /* sectors per track */
149 u32int secspercyl; /* sectors per cylinder */
150 u32int ncyl; /* cylinders in fs */
151 u32int cylspergroup; /* cylinders per group */
152 u32int inospergroup; /* inodes per group */
153 u32int fragspergroup; /* data blocks per group * fragperblock */
154 Cylsum cstotal; /* more unused... */
159 char fsmnt[FSMAXMNTLEN];
161 void* ocsp[FSNOCSPTRS];
166 u16int opostbl[16][8];
167 u32int snapinum[FSMAXSNAP];
171 u32int pendingblocks;
172 u32int pendinginodes;
173 u32int contigsumsize;
174 u32int maxsymlinklen;
175 u32int inodefmt; /* format of on-disk inodes */
176 u64int maxfilesize; /* maximum representable file size */
184 u32int magic; /* FS_MAGIC */
188 * Cylinder group block for a file system.
193 u32int magic; /* CGMAGIC */
194 u32int time; /* time last written */
195 u32int num; /* we are cg #cgnum */
196 u16int ncyl; /* number of cylinders in gp */
197 u16int nino; /* number of inodes */
198 u32int nfrag; /* number of fragments */
203 u32int frsum[MAXFRAG]; /* counts of available frags */
206 u32int imapoff; /* offset to used inode map */
207 u32int fmapoff; /* offset to free fragment map */
208 u32int nextfrag; /* next free fragment */
217 /* these are block numbers not fragment numbers */
218 u32int bno; /* disk block address of start of cg */
219 u32int ibno; /* disk block address of first inode */
220 u32int dbno; /* disk block address of first data */
225 * this is the on-disk structure
260 * main file system structure