xref: /haiku/src/tests/system/kernel/file_corruption/checksumfs.h (revision a2e7c7417b968392fd1756b6b097eb047003e6c7)
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	content;			// block index of the content (0 if empty)
51 	uint64	size;				// content size in bytes
52 	uint64	parentDirectory;	// block index of the parent directory
53 								// (directories and attributes only)
54 	uint64	attributeDirectory;	// block index of the attribute directory (0 if
55 								// empty)
56 } _PACKED;
57 
58 
59 static const uint32 kCheckSumFSMaxDirEntryTreeDepth		= 24;
60 
61 struct checksumfs_dir_entry_tree {
62 	uint16	depth;
63 } _PACKED;
64 
65 
66 struct checksumfs_dir_entry_block {
67 	uint16	entryCount;
68 	uint16	nameEnds[0];		// end offsets of the names (relative to the
69 								// start of the first name),
70 								// e.g. nameEnds[0] == length of first name
71 	// char	names[];			// string of all (unterminated) names,
72 								// directly follows the nameEnds array
73 	// ...
74 	// uint64	nodes[];
75 		// node array ends at the end of the block
76 };
77 
78 
79 #endif	// CHECK_SUM_FS_H
80