1952d6c8cSIngo Weinhold /* 2952d6c8cSIngo Weinhold * Copyright 2010, Ingo Weinhold, ingo_weinhold@gmx.de. 3952d6c8cSIngo Weinhold * Distributed under the terms of the MIT License. 4952d6c8cSIngo Weinhold */ 5952d6c8cSIngo Weinhold #ifndef CHECK_SUM_FS_H 6952d6c8cSIngo Weinhold #define CHECK_SUM_FS_H 7952d6c8cSIngo Weinhold 8952d6c8cSIngo Weinhold 9952d6c8cSIngo Weinhold #include <OS.h> 10952d6c8cSIngo Weinhold 11952d6c8cSIngo Weinhold 12952d6c8cSIngo Weinhold #define CHECK_SUM_FS_PRETTY_NAME "CheckSum File System" 13952d6c8cSIngo Weinhold 14952d6c8cSIngo Weinhold 15952d6c8cSIngo Weinhold static const uint64 kCheckSumFSSuperBlockOffset = 16 * B_PAGE_SIZE; 16952d6c8cSIngo Weinhold static const uint64 kCheckSumFSMinSize 17952d6c8cSIngo Weinhold = kCheckSumFSSuperBlockOffset + 16 * B_PAGE_SIZE; 18952d6c8cSIngo Weinhold 19952d6c8cSIngo Weinhold 20952d6c8cSIngo Weinhold static const uint32 kCheckSumFSNameLength = 256; 21952d6c8cSIngo Weinhold 22952d6c8cSIngo Weinhold static const uint32 kCheckSumFSSignatureLength = 16; 23952d6c8cSIngo Weinhold #define CHECK_SUM_FS_SIGNATURE_1 "_1!cHEcKsUmfS!1_" 24952d6c8cSIngo Weinhold #define CHECK_SUM_FS_SIGNATURE_2 "-2@ChECkSumFs@2-" 25952d6c8cSIngo Weinhold 26952d6c8cSIngo Weinhold static const uint32 kCheckSumFSVersion = 1; 27952d6c8cSIngo Weinhold 28952d6c8cSIngo Weinhold struct checksumfs_super_block { 29952d6c8cSIngo Weinhold char signature1[kCheckSumFSSignatureLength]; 30952d6c8cSIngo Weinhold uint32 version; 31952d6c8cSIngo Weinhold uint32 pad1; 32952d6c8cSIngo Weinhold uint64 totalBlocks; 33952d6c8cSIngo Weinhold uint64 freeBlocks; 34952d6c8cSIngo Weinhold uint64 rootDir; 35952d6c8cSIngo Weinhold uint64 blockBitmap; 36952d6c8cSIngo Weinhold char name[kCheckSumFSNameLength]; 37952d6c8cSIngo Weinhold char signature2[kCheckSumFSSignatureLength]; 38952d6c8cSIngo Weinhold } _PACKED; 39952d6c8cSIngo Weinhold 40952d6c8cSIngo Weinhold 4174956f43SIngo Weinhold struct checksumfs_node { 4274956f43SIngo Weinhold uint32 mode; // node type + permissions 4374956f43SIngo Weinhold uint32 attributeType; // attribute type (attributes only) 4474956f43SIngo Weinhold uint32 uid; // owning user ID 4574956f43SIngo Weinhold uint32 gid; // owning group ID 4674956f43SIngo Weinhold uint64 creationTime; // in ns since the epoche 4774956f43SIngo Weinhold uint64 modificationTime; // 4874956f43SIngo Weinhold uint64 changeTime; // 4974956f43SIngo Weinhold uint64 hardLinks; // number of references to the node 5074956f43SIngo Weinhold uint64 size; // content size in bytes 5174956f43SIngo Weinhold uint64 parentDirectory; // block index of the parent directory 5274956f43SIngo Weinhold // (directories and attributes only) 5374956f43SIngo Weinhold uint64 attributeDirectory; // block index of the attribute directory (0 if 5474956f43SIngo Weinhold // empty) 5574956f43SIngo Weinhold } _PACKED; 5674956f43SIngo Weinhold 5774956f43SIngo Weinhold 58*a2e7c741SIngo Weinhold static const uint32 kCheckSumFSMaxDirEntryTreeDepth = 24; 59*a2e7c741SIngo Weinhold 60*a2e7c741SIngo Weinhold struct checksumfs_dir_entry_tree { 61*a2e7c741SIngo Weinhold uint16 depth; 62*a2e7c741SIngo Weinhold } _PACKED; 63*a2e7c741SIngo Weinhold 64*a2e7c741SIngo Weinhold 6574956f43SIngo Weinhold struct checksumfs_dir_entry_block { 6674956f43SIngo Weinhold uint16 entryCount; 67*a2e7c741SIngo Weinhold uint16 nameEnds[0]; // end offsets of the names (relative to the 68*a2e7c741SIngo Weinhold // start of the first name), 6974956f43SIngo Weinhold // e.g. nameEnds[0] == length of first name 7074956f43SIngo Weinhold // char names[]; // string of all (unterminated) names, 7174956f43SIngo Weinhold // directly follows the nameEnds array 7274956f43SIngo Weinhold // ... 7374956f43SIngo Weinhold // uint64 nodes[]; 7474956f43SIngo Weinhold // node array ends at the end of the block 7574956f43SIngo Weinhold }; 7674956f43SIngo Weinhold 7774956f43SIngo Weinhold 78952d6c8cSIngo Weinhold #endif // CHECK_SUM_FS_H 79