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 /* some systems have these defined */
92 #define IEXEC FFS_IEXEC
93 #define IWRITE FFS_IWRITE
94 #define IREAD FFS_IREAD
95 #define ISVTX FFS_ISVTX
96 #define ISGID FFS_ISGID
97 #define ISUID FFS_ISUID
99 #define IFIFO FFS_IFIFO
100 #define IFCHR FFS_IFCHR
101 #define IFDIR FFS_IFDIR
102 #define IFBLK FFS_IFBLK
103 #define IFREG FFS_IFREG
104 #define IFLNK FFS_IFLNK
105 #define IFSOCK FFS_IFSOCK
106 #define IFWHT FFS_IFWHT
108 /* permissions in Inode.mode */
116 /* type in Inode.mode */
127 /* type in Dirent.type */
157 /* Fields beginning with underscore are deprecated in UFS2 */
162 daddr_t sfragno; /* fragment address of super block in file system */
163 daddr_t cfragno; /* fragment address if cylinder block in file system */
164 daddr_t ifragno; /* fragment offset of inode blocks in file system */
165 daddr_t dfragno; /* fragment offset of data blocks in cg */
166 u32int _cgoffset; /* block (maybe fragment?) offset of Cgblk in cylinder */
169 u32int _nfrag; /* number of blocks in fs * fragsperblock */
171 u32int ncg; /* number of cylinder groups in fs */
172 u32int blocksize; /* block size in fs */
173 u32int fragsize; /* frag size in fs */
174 u32int fragsperblock; /* fragments per block: blocksize / fragsize */
175 u32int minfree; /* ignored by us */
176 u32int rotdelay; /* ... */
186 u32int sbsize; /* size of super block */
187 u32int unused2; /* more stuff we don't use ... */
190 u32int inosperblock; /* inodes per block */
197 daddr_t _csaddr; /* blk addr of cyl grp summary area */
198 u32int cssize; /* size of cyl grp summary area */
199 u32int cgsize; /* cylinder group size */
200 u32int _trackspercyl; /* tracks per cylinder */
201 u32int _secspertrack; /* sectors per track */
202 u32int _secspercyl; /* sectors per cylinder */
203 u32int _ncyl; /* cylinders in fs */
204 u32int _cylspergroup; /* cylinders per group */
205 u32int inospergroup; /* inodes per group */
206 u32int fragspergroup; /* data blocks per group * fragperblock */
207 Cylsum _cstotal; /* more unused... */
212 /* char fsmnt[512]; in UFS1 */
213 char fsmnt[FSMAXMNTLEN2];
214 char volname[FSMAXVOLLEN];
218 uchar ocsp[FSNOCSPTRSLEN]; /* last 4 bytes is contigdirs in UFS2 */
219 u32int contigdirs; /* csp in UFS2 */
220 u32int csp; /* maxcluster in UFS2 */
221 u32int maxcluster; /* active in UFS2 */
223 /* u16int opostbl[16][8]; in UFS1 */
232 u64int pendingblocks;
233 u32int pendinginodes;
234 u32int snapinum[FSMAXSNAP];
237 /* u32int sparecon[26], pendingblocks, pendinginodes; in UFS1 */
241 u32int contigsumsize;
242 u32int maxsymlinklen;
243 u32int _inodefmt; /* format of on-disk inodes */
244 u64int maxfilesize; /* maximum representable file size */
248 u32int _postblformat;
252 u32int magic; /* FSMAGIC or FSMAGIC2 */
256 * Cylinder group block for a file system.
261 u32int magic; /* CGMAGIC */
262 u32int time; /* time last written */
263 u32int num; /* we are cg #cgnum */
264 u16int ncyl; /* number of cylinders in gp */
265 u16int nino; /* number of inodes */
266 u32int nfrag; /* number of fragments */
271 u32int frsum[MAXFRAG]; /* counts of available frags */
274 u32int imapoff; /* offset to used inode map */
275 u32int fmapoff; /* offset to free fragment map */
276 u32int nextfrag; /* next free fragment */
285 /* these are block numbers not fragment numbers */
286 u64int bno; /* disk block address of start of cg */
287 u64int ibno; /* disk block address of first inode */
288 u64int dbno; /* disk block address of first data */
293 * this is the on-disk structure
355 * main file system structure
365 u64int blockspergroup;
366 u64int fragspergroup;