xref: /plan9/sys/src/cmd/cfs/cformat.h (revision 7c70c028d2d46a27a61ae88e6df0eb0935d9da7a)
1 /*
2  *  format of cache on disk
3  */
4 typedef struct Dptr	Dptr;
5 typedef struct Dahdr	Dahdr;
6 typedef struct Dalloc	Dalloc;
7 typedef struct Fphdr	Fphdr;
8 typedef struct Fptr	Fptr;
9 typedef struct Inode	Inode;
10 typedef struct Dihdr	Dihdr;
11 typedef struct Dinode	Dinode;
12 
13 enum
14 {
15 	Amagic= 	0xbebeefed,	/* allocation block magic */
16 	Imagic=		0xbadc00ce,	/* inode block magic */
17 	BtoUL=		8*sizeof(ulong),/* bits in a ulong */
18 	CACHENAMELEN=	128
19 };
20 #define	Indbno		0x80000000	/* indirect block */
21 #define	Notabno		0xFFFFFFFF	/* not a block number */
22 
23 /*
24  *  Allocation blocks at the begining of the disk.  There are
25  *  enough of these blocks to supply 1 bit for each block on the
26  *  disk;
27  */
28 struct Dahdr
29 {
30 	ulong	magic;
31 	ulong	bsize;		/* logical block size */
32 	char	name[CACHENAMELEN];
33 	short	nab;		/* number of allocation blocks */
34 };
35 struct Dalloc
36 {
37 	Dahdr;
38 	ulong	bits[1];
39 };
40 
41 /*
42  *  A pointer to disk data
43  */
44 struct Dptr
45 {
46 	ulong	fbno;		/* file block number */
47 	ulong	bno;		/* disk block number */
48 	ushort	start;		/* offset into block of valid data */
49 	ushort	end;		/* offset into block after valid data */
50 };
51 
52 /*
53  *  A file descriptor.
54  */
55 struct Inode
56 {
57 	Qid	qid;
58 	vlong	length;
59 	Dptr	ptr;		/* pointer page */
60 	char	inuse;
61 };
62 
63 /*
64  *  inode blocks (after allocation blocks)
65  */
66 struct Dihdr
67 {
68 	ulong	magic;
69 	ulong	nino;		/* number of inodes */
70 };
71 struct Dinode
72 {
73 	Dihdr;
74 	Inode	inode[1];
75 };
76