xref: /haiku/src/tests/system/kernel/file_corruption/checksumfs.h (revision 7461b83d3b3d3641845ca0d4060323f617a9d1d0)
1 /*
2  * Copyright 2010, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef CHECK_SUM_FS_H
6 #define CHECK_SUM_FS_H
7 
8 
9 #include <OS.h>
10 
11 
12 #define CHECK_SUM_FS_PRETTY_NAME	"CheckSum File System"
13 
14 
15 static const uint64 kCheckSumFSSuperBlockOffset = 16 * B_PAGE_SIZE;
16 static const uint64 kCheckSumFSMinSize
17 	= kCheckSumFSSuperBlockOffset + 16 * B_PAGE_SIZE;
18 
19 
20 static const uint32 kCheckSumFSNameLength		= 256;
21 
22 static const uint32 kCheckSumFSSignatureLength	= 16;
23 #define CHECK_SUM_FS_SIGNATURE_1	"_1!cHEcKsUmfS!1_"
24 #define CHECK_SUM_FS_SIGNATURE_2	"-2@ChECkSumFs@2-"
25 
26 static const uint32 kCheckSumFSVersion = 1;
27 
28 struct checksumfs_super_block {
29 	char	signature1[kCheckSumFSSignatureLength];
30 	uint32	version;
31 	uint32	pad1;
32 	uint64	totalBlocks;
33 	uint64	freeBlocks;
34 	uint64	rootDir;
35 	uint64	blockBitmap;
36 	char	name[kCheckSumFSNameLength];
37 	char	signature2[kCheckSumFSSignatureLength];
38 } _PACKED;
39 
40 
41 struct checksumfs_node {
42 	uint32	mode;				// node type + permissions
43 	uint32	attributeType;		// attribute type (attributes only)
44 	uint32	uid;				// owning user ID
45 	uint32	gid;				// owning group ID
46 	uint64	creationTime;		// in ns since the epoche
47 	uint64	modificationTime;	//
48 	uint64	changeTime;			//
49 	uint64	hardLinks;			// number of references to the node
50 	uint64	size;				// content size in bytes
51 	uint64	parentDirectory;	// block index of the parent directory
52 								// (directories and attributes only)
53 	uint64	attributeDirectory;	// block index of the attribute directory (0 if
54 								// empty)
55 } _PACKED;
56 
57 
58 static const uint32 kCheckSumFSMaxDirEntryTreeDepth		= 24;
59 
60 struct checksumfs_dir_entry_tree {
61 	uint16	depth;
62 } _PACKED;
63 
64 
65 struct checksumfs_dir_entry_block {
66 	uint16	entryCount;
67 	uint16	nameEnds[0];		// end offsets of the names (relative to the
68 								// start of the first name),
69 								// e.g. nameEnds[0] == length of first name
70 	// char	names[];			// string of all (unterminated) names,
71 								// directly follows the nameEnds array
72 	// ...
73 	// uint64	nodes[];
74 		// node array ends at the end of the block
75 };
76 
77 
78 #endif	// CHECK_SUM_FS_H
79