Ticket #13513: 0001-Fixed-Code-style.patch
File 0001-Fixed-Code-style.patch, 45.3 KB (added by , 7 years ago) |
---|
-
src/add-ons/kernel/file_systems/btrfs/Attribute.cpp
From 1901cdb99644808b0b8d79ae520b0e7704ff82d9 Mon Sep 17 00:00:00 2001 From: hyche <cvghy116@gmail.com> Date: Thu, 18 May 2017 19:52:06 +0700 Subject: [PATCH 1/2] Fixed: Code style * Using tab instead of spaces * Pointer/Reference should be next to type * etc --- .../kernel/file_systems/btrfs/Attribute.cpp | 21 +++-- src/add-ons/kernel/file_systems/btrfs/Attribute.h | 8 +- .../file_systems/btrfs/AttributeIterator.cpp | 7 +- .../kernel/file_systems/btrfs/BPlusTree.cpp | 27 +++--- src/add-ons/kernel/file_systems/btrfs/BPlusTree.h | 40 ++++----- src/add-ons/kernel/file_systems/btrfs/CRCTable.cpp | 66 +++++++-------- src/add-ons/kernel/file_systems/btrfs/CRCTable.h | 3 +- .../kernel/file_systems/btrfs/CachedBlock.h | 7 +- src/add-ons/kernel/file_systems/btrfs/Chunk.cpp | 6 +- src/add-ons/kernel/file_systems/btrfs/Chunk.h | 4 +- .../file_systems/btrfs/DirectoryIterator.cpp | 12 +-- src/add-ons/kernel/file_systems/btrfs/Inode.cpp | 12 +-- src/add-ons/kernel/file_systems/btrfs/Inode.h | 19 +++-- src/add-ons/kernel/file_systems/btrfs/Utility.h | 1 + src/add-ons/kernel/file_systems/btrfs/Volume.cpp | 8 +- src/add-ons/kernel/file_systems/btrfs/Volume.h | 7 +- src/add-ons/kernel/file_systems/btrfs/btrfs.h | 98 ++++++++++++---------- .../kernel/file_systems/btrfs/crc_table.cpp | 66 ++++++++------- .../kernel/file_systems/btrfs/kernel_interface.cpp | 33 ++++---- 19 files changed, 230 insertions(+), 215 deletions(-) diff --git a/src/add-ons/kernel/file_systems/btrfs/Attribute.cpp b/src/add-ons/kernel/file_systems/btrfs/Attribute.cpp index d6be6d3..a73a54d 100644
a b Attribute::Stat(struct stat& stat) 92 92 TRACE("Stat\n"); 93 93 94 94 size_t nameLength = strlen(fName); 95 btrfs_dir_entry *entries;95 btrfs_dir_entry* entries; 96 96 size_t length; 97 97 status_t status = _Lookup(fName, nameLength, &entries, &length); 98 98 if (status < B_OK) 99 99 return status; 100 100 101 btrfs_dir_entry *entry;101 btrfs_dir_entry* entry; 102 102 status = _FindEntry(entries, length, fName, nameLength, &entry); 103 103 if (status != B_OK) { 104 104 free(entries); … … Attribute::Read(attr_cookie* cookie, off_t pos, uint8* buffer, size_t* _length) 120 120 return ERANGE; 121 121 122 122 size_t nameLength = strlen(fName); 123 btrfs_dir_entry *entries;123 btrfs_dir_entry* entries; 124 124 size_t length; 125 125 status_t status = _Lookup(fName, nameLength, &entries, &length); 126 126 if (status < B_OK) 127 127 return status; 128 128 129 btrfs_dir_entry *entry;129 btrfs_dir_entry* entry; 130 130 status = _FindEntry(entries, length, fName, nameLength, &entry); 131 131 if (status != B_OK) { 132 132 free(entries); … … Attribute::Read(attr_cookie* cookie, off_t pos, uint8* buffer, size_t* _length) 149 149 150 150 status_t 151 151 Attribute::_Lookup(const char* name, size_t nameLength, 152 btrfs_dir_entry **_entries, size_t *_length)152 btrfs_dir_entry** _entries, size_t* _length) 153 153 { 154 154 uint32 hash = calculate_crc((uint32)~1, (uint8*)name, nameLength); 155 155 struct btrfs_key key; … … Attribute::_Lookup(const char* name, size_t nameLength, 157 157 key.SetObjectID(fInode->ID()); 158 158 key.SetOffset(hash); 159 159 160 btrfs_dir_entry *entries;160 btrfs_dir_entry* entries; 161 161 size_t length; 162 162 status_t status = fInode->GetVolume()->FSTree()->FindExact(key, 163 163 (void**)&entries, &length); … … Attribute::_Lookup(const char* name, size_t nameLength, 180 180 181 181 182 182 status_t 183 Attribute::_FindEntry(btrfs_dir_entry *entries, size_t length,184 const char* name, size_t nameLength, btrfs_dir_entry **_entry)183 Attribute::_FindEntry(btrfs_dir_entry* entries, size_t length, 184 const char* name, size_t nameLength, btrfs_dir_entry** _entry) 185 185 { 186 btrfs_dir_entry *entry = entries;186 btrfs_dir_entry* entry = entries; 187 187 uint16 current = 0; 188 188 while (current < length) { 189 189 current += entry->Length(); 190 190 break; 191 191 // TODO there could be several entries with the same name hash 192 entry = (btrfs_dir_entry 192 entry = (btrfs_dir_entry*)((uint8*)entry + entry->Length()); 193 193 } 194 194 195 195 *_entry = entry; 196 196 return B_OK; 197 197 } 198 -
src/add-ons/kernel/file_systems/btrfs/Attribute.h
diff --git a/src/add-ons/kernel/file_systems/btrfs/Attribute.h b/src/add-ons/kernel/file_systems/btrfs/Attribute.h index 892b71e..7236673 100644
a b public: 38 38 uint8* buffer, size_t* _length); 39 39 private: 40 40 status_t _Lookup(const char* name, size_t nameLength, 41 btrfs_dir_entry **entries = NULL,42 size_t *length = NULL);43 status_t _FindEntry(btrfs_dir_entry *entries,41 btrfs_dir_entry** entries = NULL, 42 size_t* length = NULL); 43 status_t _FindEntry(btrfs_dir_entry* entries, 44 44 size_t length, const char* name, 45 45 size_t nameLength, 46 btrfs_dir_entry **_entry);46 btrfs_dir_entry** _entry); 47 47 48 48 ::Volume* fVolume; 49 49 Inode* fInode; -
src/add-ons/kernel/file_systems/btrfs/AttributeIterator.cpp
diff --git a/src/add-ons/kernel/file_systems/btrfs/AttributeIterator.cpp b/src/add-ons/kernel/file_systems/btrfs/AttributeIterator.cpp index b668ca5..7601944 100644
a b status_t 50 50 AttributeIterator::GetNext(char* name, size_t* _nameLength) 51 51 { 52 52 btrfs_key key; 53 btrfs_dir_entry *entries;53 btrfs_dir_entry* entries; 54 54 size_t entries_length; 55 55 status_t status = fIterator->GetPreviousEntry(key, (void**)&entries, 56 56 &entries_length); 57 57 if (status != B_OK) 58 58 return status; 59 59 60 btrfs_dir_entry *entry = entries;60 btrfs_dir_entry* entry = entries; 61 61 uint16 current = 0; 62 62 while (current < entries_length) { 63 63 current += entry->Length(); 64 64 break; 65 65 // TODO there could be several entries with the same name hash 66 entry = (btrfs_dir_entry 66 entry = (btrfs_dir_entry*)((uint8*)entry + entry->Length()); 67 67 } 68 68 69 69 TRACE("DirectoryIterator::GetNext() entries_length %ld name_length %d\n", … … AttributeIterator::Rewind() 85 85 fOffset = -1ULL; 86 86 return B_OK; 87 87 } 88 -
src/add-ons/kernel/file_systems/btrfs/BPlusTree.cpp
diff --git a/src/add-ons/kernel/file_systems/btrfs/BPlusTree.cpp b/src/add-ons/kernel/file_systems/btrfs/BPlusTree.cpp index 1e28a5b..2128c0c 100644
a b 26 26 # define ERROR(x...) dprintf("\33[34mbtrfs:\33[0m " x) 27 27 28 28 29 BPlusTree::BPlusTree(Volume* volume, struct btrfs_stream *stream)29 BPlusTree::BPlusTree(Volume* volume, struct btrfs_stream* stream) 30 30 : 31 31 fStream(stream), 32 32 fRootBlock(0), … … BPlusTree::~BPlusTree() 62 62 63 63 64 64 int32 65 BPlusTree::_CompareKeys(struct btrfs_key &key1, struct btrfs_key &key2)65 BPlusTree::_CompareKeys(struct btrfs_key& key1, struct btrfs_key& key2) 66 66 { 67 67 if (key1.ObjectID() > key2.ObjectID()) 68 68 return 1; … … BPlusTree::_CompareKeys(struct btrfs_key &key1, struct btrfs_key &key2) 86 86 It can also return other errors to indicate that something went wrong. 87 87 */ 88 88 status_t 89 BPlusTree::_Find(struct btrfs_key &key, void** _value, size_t* _size,89 BPlusTree::_Find(struct btrfs_key& key, void** _value, size_t* _size, 90 90 bplustree_traversing type) 91 91 { 92 92 TRACE("Find() objectid %" B_PRId64 " type %d offset %" B_PRId64 " \n", 93 93 key.ObjectID(), key.Type(), key.Offset()); 94 btrfs_stream *stream = fStream;94 btrfs_stream* stream = fStream; 95 95 CachedBlock cached(fVolume); 96 96 fsblock_t physical; 97 97 if (stream == NULL) { … … BPlusTree::_Find(struct btrfs_key &key, void** _value, size_t* _size, 99 99 ERROR("Find() unmapped block %" B_PRId64 "\n", fRootBlock); 100 100 return B_ERROR; 101 101 } 102 stream = (btrfs_stream 102 stream = (btrfs_stream*)cached.SetTo(physical); 103 103 } 104 104 105 105 while (stream->header.Level() != 0) { … … BPlusTree::_Find(struct btrfs_key &key, void** _value, size_t* _size, 123 123 stream->index[i - 1].BlockNum()); 124 124 return B_ERROR; 125 125 } 126 stream = (btrfs_stream 126 stream = (btrfs_stream*)cached.SetTo(physical); 127 127 } 128 128 129 129 uint32 i; … … BPlusTree::_Find(struct btrfs_key &key, void** _value, size_t* _size, 175 175 if ((fVolume->BlockSize() - totalOffset % fVolume->BlockSize()) 176 176 >= stream->entries[i].Size()) { 177 177 //If there is enough space for *_value 178 memcpy(*_value, ((uint8 178 memcpy(*_value, ((uint8*)cached.SetTo(physical 179 179 + totalOffset / fVolume->BlockSize()) 180 180 + totalOffset % fVolume->BlockSize()), 181 181 stream->entries[i].Size()); … … BPlusTree::_Find(struct btrfs_key &key, void** _value, size_t* _size, 201 201 202 202 203 203 status_t 204 BPlusTree::FindNext(struct btrfs_key &key, void** _value, size_t* _size)204 BPlusTree::FindNext(struct btrfs_key& key, void** _value, size_t* _size) 205 205 { 206 206 return _Find(key, _value, _size, BPLUSTREE_FORWARD); 207 207 } 208 208 209 209 210 210 status_t 211 BPlusTree::FindPrevious(struct btrfs_key &key, void** _value, size_t* _size)211 BPlusTree::FindPrevious(struct btrfs_key& key, void** _value, size_t* _size) 212 212 { 213 213 return _Find(key, _value, _size, BPLUSTREE_BACKWARD); 214 214 } 215 215 216 216 217 217 status_t 218 BPlusTree::FindExact(struct btrfs_key &key, void** _value, size_t* _size)218 BPlusTree::FindExact(struct btrfs_key& key, void** _value, size_t* _size) 219 219 { 220 220 return _Find(key, _value, _size, BPLUSTREE_EXACT); 221 221 } … … BPlusTree::_RemoveIterator(TreeIterator* iterator) 240 240 // #pragma mark - 241 241 242 242 243 TreeIterator::TreeIterator(BPlusTree* tree, struct btrfs_key &key)243 TreeIterator::TreeIterator(BPlusTree* tree, struct btrfs_key& key) 244 244 : 245 245 fTree(tree), 246 246 fCurrentKey(key) … … TreeIterator::~TreeIterator() 260 260 /*! Iterates through the tree in the specified direction. 261 261 */ 262 262 status_t 263 TreeIterator::Traverse(bplustree_traversing direction, struct btrfs_key &key,263 TreeIterator::Traverse(bplustree_traversing direction, struct btrfs_key& key, 264 264 void** value, size_t* size) 265 265 { 266 266 if (fTree == NULL) … … TreeIterator::Traverse(bplustree_traversing direction, struct btrfs_key &key, 281 281 /*! just sets the current key in the iterator. 282 282 */ 283 283 status_t 284 TreeIterator::Find(struct btrfs_key &key)284 TreeIterator::Find(struct btrfs_key& key) 285 285 { 286 286 if (fTree == NULL) 287 287 return B_INTERRUPTED; … … TreeIterator::Stop() 295 295 { 296 296 fTree = NULL; 297 297 } 298 -
src/add-ons/kernel/file_systems/btrfs/BPlusTree.h
diff --git a/src/add-ons/kernel/file_systems/btrfs/BPlusTree.h b/src/add-ons/kernel/file_systems/btrfs/BPlusTree.h index fb051a0..7f7babe 100644
a b enum bplustree_traversing { 30 30 31 31 // #pragma mark - in-memory structures 32 32 33 33 34 template<class T> class Stack; 34 35 class TreeIterator; 35 36 … … struct node_and_key { 44 45 class BPlusTree { 45 46 public: 46 47 BPlusTree(Volume* volume, 47 struct btrfs_stream *stream);48 struct btrfs_stream* stream); 48 49 BPlusTree(Volume* volume, 49 50 fsblock_t rootBlock); 50 51 ~BPlusTree(); 51 status_t FindExact(struct btrfs_key &key, void** value,52 status_t FindExact(struct btrfs_key& key, void** value, 52 53 size_t* size = NULL); 53 status_t FindNext(struct btrfs_key &key, void** value,54 status_t FindNext(struct btrfs_key& key, void** value, 54 55 size_t* size = NULL); 55 status_t FindPrevious(struct btrfs_key &key, void** value,56 status_t FindPrevious(struct btrfs_key& key, void** value, 56 57 size_t* size = NULL); 57 58 58 59 private: … … private: 60 61 BPlusTree& operator=(const BPlusTree& other); 61 62 // no implementation 62 63 63 int32 _CompareKeys(struct btrfs_key &key1,64 struct btrfs_key &key2);65 status_t _Find(struct btrfs_key &key, void** value,64 int32 _CompareKeys(struct btrfs_key& key1, 65 struct btrfs_key& key2); 66 status_t _Find(struct btrfs_key& key, void** value, 66 67 size_t* size, bplustree_traversing type); 67 68 void _AddIterator(TreeIterator* iterator); 68 69 void _RemoveIterator(TreeIterator* iterator); … … private: 79 80 80 81 class TreeIterator : public SinglyLinkedListLinkImpl<TreeIterator> { 81 82 public: 82 TreeIterator(BPlusTree* tree, struct btrfs_key &key);83 TreeIterator(BPlusTree* tree, struct btrfs_key& key); 83 84 ~TreeIterator(); 84 85 85 86 status_t Traverse(bplustree_traversing direction, 86 struct btrfs_key &key, void** value,87 size_t *size = NULL);88 status_t Find(struct btrfs_key &key);87 struct btrfs_key& key, void** value, 88 size_t* size = NULL); 89 status_t Find(struct btrfs_key& key); 89 90 90 91 status_t Rewind(); 91 status_t GetNextEntry(struct btrfs_key &key, void** value,92 size_t *size = NULL);93 status_t GetPreviousEntry(struct btrfs_key &key, void** value,94 size_t *size = NULL);92 status_t GetNextEntry(struct btrfs_key& key, void** value, 93 size_t* size = NULL); 94 status_t GetPreviousEntry(struct btrfs_key& key, void** value, 95 size_t* size = NULL); 95 96 96 97 BPlusTree* Tree() const { return fTree; } 97 98 … … TreeIterator::Rewind() 117 118 return B_OK; 118 119 } 119 120 121 120 122 inline status_t 121 TreeIterator::GetNextEntry(struct btrfs_key &key, void** value, size_t *size)123 TreeIterator::GetNextEntry(struct btrfs_key& key, void** value, size_t* size) 122 124 { 123 125 return Traverse(BPLUSTREE_FORWARD, key, value, size); 124 126 } 125 127 128 126 129 inline status_t 127 TreeIterator::GetPreviousEntry(struct btrfs_key &key, void** value,128 size_t *size)130 TreeIterator::GetPreviousEntry(struct btrfs_key& key, void** value, 131 size_t* size) 129 132 { 130 133 return Traverse(BPLUSTREE_BACKWARD, key, value, size); 131 134 } 132 135 133 136 134 135 137 #endif // B_PLUS_TREE_H -
src/add-ons/kernel/file_systems/btrfs/CRCTable.cpp
diff --git a/src/add-ons/kernel/file_systems/btrfs/CRCTable.cpp b/src/add-ons/kernel/file_systems/btrfs/CRCTable.cpp index 75f35e5..0c5736c 100644
a b 12 12 13 13 //! CRC 03667067501 table, as generated by crc_table.cpp 14 14 static uint32 kCrcTable[256] = { 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 15 0x00000000, 0xf26b8303, 0xe13b70f7, 0x1350f3f4, 0xc79a971f, 0x35f1141c, 0x26a1e7e8, 0xd4ca64eb, 16 0x8ad958cf, 0x78b2dbcc, 0x6be22838, 0x9989ab3b, 0x4d43cfd0, 0xbf284cd3, 0xac78bf27, 0x5e133c24, 17 0x105ec76f, 0xe235446c, 0xf165b798, 0x030e349b, 0xd7c45070, 0x25afd373, 0x36ff2087, 0xc494a384, 18 0x9a879fa0, 0x68ec1ca3, 0x7bbcef57, 0x89d76c54, 0x5d1d08bf, 0xaf768bbc, 0xbc267848, 0x4e4dfb4b, 19 0x20bd8ede, 0xd2d60ddd, 0xc186fe29, 0x33ed7d2a, 0xe72719c1, 0x154c9ac2, 0x061c6936, 0xf477ea35, 20 0xaa64d611, 0x580f5512, 0x4b5fa6e6, 0xb93425e5, 0x6dfe410e, 0x9f95c20d, 0x8cc531f9, 0x7eaeb2fa, 21 0x30e349b1, 0xc288cab2, 0xd1d83946, 0x23b3ba45, 0xf779deae, 0x05125dad, 0x1642ae59, 0xe4292d5a, 22 0xba3a117e, 0x4851927d, 0x5b016189, 0xa96ae28a, 0x7da08661, 0x8fcb0562, 0x9c9bf696, 0x6ef07595, 23 0x417b1dbc, 0xb3109ebf, 0xa0406d4b, 0x522bee48, 0x86e18aa3, 0x748a09a0, 0x67dafa54, 0x95b17957, 24 0xcba24573, 0x39c9c670, 0x2a993584, 0xd8f2b687, 0x0c38d26c, 0xfe53516f, 0xed03a29b, 0x1f682198, 25 0x5125dad3, 0xa34e59d0, 0xb01eaa24, 0x42752927, 0x96bf4dcc, 0x64d4cecf, 0x77843d3b, 0x85efbe38, 26 0xdbfc821c, 0x2997011f, 0x3ac7f2eb, 0xc8ac71e8, 0x1c661503, 0xee0d9600, 0xfd5d65f4, 0x0f36e6f7, 27 0x61c69362, 0x93ad1061, 0x80fde395, 0x72966096, 0xa65c047d, 0x5437877e, 0x4767748a, 0xb50cf789, 28 0xeb1fcbad, 0x197448ae, 0x0a24bb5a, 0xf84f3859, 0x2c855cb2, 0xdeeedfb1, 0xcdbe2c45, 0x3fd5af46, 29 0x7198540d, 0x83f3d70e, 0x90a324fa, 0x62c8a7f9, 0xb602c312, 0x44694011, 0x5739b3e5, 0xa55230e6, 30 0xfb410cc2, 0x092a8fc1, 0x1a7a7c35, 0xe811ff36, 0x3cdb9bdd, 0xceb018de, 0xdde0eb2a, 0x2f8b6829, 31 0x82f63b78, 0x709db87b, 0x63cd4b8f, 0x91a6c88c, 0x456cac67, 0xb7072f64, 0xa457dc90, 0x563c5f93, 32 0x082f63b7, 0xfa44e0b4, 0xe9141340, 0x1b7f9043, 0xcfb5f4a8, 0x3dde77ab, 0x2e8e845f, 0xdce5075c, 33 0x92a8fc17, 0x60c37f14, 0x73938ce0, 0x81f80fe3, 0x55326b08, 0xa759e80b, 0xb4091bff, 0x466298fc, 34 0x1871a4d8, 0xea1a27db, 0xf94ad42f, 0x0b21572c, 0xdfeb33c7, 0x2d80b0c4, 0x3ed04330, 0xccbbc033, 35 0xa24bb5a6, 0x502036a5, 0x4370c551, 0xb11b4652, 0x65d122b9, 0x97baa1ba, 0x84ea524e, 0x7681d14d, 36 0x2892ed69, 0xdaf96e6a, 0xc9a99d9e, 0x3bc21e9d, 0xef087a76, 0x1d63f975, 0x0e330a81, 0xfc588982, 37 0xb21572c9, 0x407ef1ca, 0x532e023e, 0xa145813d, 0x758fe5d6, 0x87e466d5, 0x94b49521, 0x66df1622, 38 0x38cc2a06, 0xcaa7a905, 0xd9f75af1, 0x2b9cd9f2, 0xff56bd19, 0x0d3d3e1a, 0x1e6dcdee, 0xec064eed, 39 0xc38d26c4, 0x31e6a5c7, 0x22b65633, 0xd0ddd530, 0x0417b1db, 0xf67c32d8, 0xe52cc12c, 0x1747422f, 40 0x49547e0b, 0xbb3ffd08, 0xa86f0efc, 0x5a048dff, 0x8ecee914, 0x7ca56a17, 0x6ff599e3, 0x9d9e1ae0, 41 0xd3d3e1ab, 0x21b862a8, 0x32e8915c, 0xc083125f, 0x144976b4, 0xe622f5b7, 0xf5720643, 0x07198540, 42 0x590ab964, 0xab613a67, 0xb831c993, 0x4a5a4a90, 0x9e902e7b, 0x6cfbad78, 0x7fab5e8c, 0x8dc0dd8f, 43 0xe330a81a, 0x115b2b19, 0x020bd8ed, 0xf0605bee, 0x24aa3f05, 0xd6c1bc06, 0xc5914ff2, 0x37faccf1, 44 0x69e9f0d5, 0x9b8273d6, 0x88d28022, 0x7ab90321, 0xae7367ca, 0x5c18e4c9, 0x4f48173d, 0xbd23943e, 45 0xf36e6f75, 0x0105ec76, 0x12551f82, 0xe03e9c81, 0x34f4f86a, 0xc69f7b69, 0xd5cf889d, 0x27a40b9e, 46 0x79b737ba, 0x8bdcb4b9, 0x988c474d, 0x6ae7c44e, 0xbe2da0a5, 0x4c4623a6, 0x5f16d052, 0xad7d5351 47 47 }; 48 48 49 49 … … static uint32 kCrcTable[256] = { 58 58 \return The crc checksum, or 0 if an error occurred. 59 59 */ 60 60 uint32 61 calculate_crc(uint32 crc, uint8 *data, uint16 length)61 calculate_crc(uint32 crc, uint8* data, uint16 length) 62 62 { 63 63 if (data) { 64 64 for ( ; length > 0; length--, data++) -
src/add-ons/kernel/file_systems/btrfs/CRCTable.h
diff --git a/src/add-ons/kernel/file_systems/btrfs/CRCTable.h b/src/add-ons/kernel/file_systems/btrfs/CRCTable.h index 965251a..b6c1192 100644
a b 6 6 * Jérôme Duval 7 7 */ 8 8 9 uint32 calculate_crc(uint32 crc, uint8 *data, uint16 length); 10 9 uint32 calculate_crc(uint32 crc, uint8* data, uint16 length); -
src/add-ons/kernel/file_systems/btrfs/CachedBlock.h
diff --git a/src/add-ons/kernel/file_systems/btrfs/CachedBlock.h b/src/add-ons/kernel/file_systems/btrfs/CachedBlock.h index 09fec08..1fafbb4 100644
a b public: 27 27 off_t BlockNumber() const { return fBlockNumber; } 28 28 29 29 private: 30 CachedBlock(const CachedBlock 31 CachedBlock &operator=(const CachedBlock&);30 CachedBlock(const CachedBlock&); 31 CachedBlock& operator=(const CachedBlock&); 32 32 // no implementation 33 33 34 34 protected: … … CachedBlock::SetTo(off_t block) 91 91 { 92 92 Unset(); 93 93 fBlockNumber = block; 94 return fBlock = (uint8 94 return fBlock = (uint8*)block_cache_get(fVolume->BlockCache(), block); 95 95 } 96 96 97 97 98 #endif // CACHED_BLOCK_H -
src/add-ons/kernel/file_systems/btrfs/Chunk.cpp
diff --git a/src/add-ons/kernel/file_systems/btrfs/Chunk.cpp b/src/add-ons/kernel/file_systems/btrfs/Chunk.cpp index ee08cbd..3d804d5 100644
a b Chunk::Chunk(struct btrfs_chunk* chunk, fsblock_t offset) 43 43 "sector_size %" B_PRIu32 "\n", chunk->Length(), chunk->Owner(), 44 44 chunk->StripeLength(), chunk->Type(), chunk->StripeCount(), 45 45 chunk->SubStripes(), chunk->SectorSize()); 46 for (int32 i = 0; i < chunk->StripeCount(); i++) {46 for (int32 i = 0; i < chunk->StripeCount(); i++) { 47 47 TRACE("chunk.stripe[%" B_PRId32 "].physical %" B_PRId64 " deviceid %" 48 48 B_PRId64 "\n", i, chunk->stripes[i].Offset(), 49 49 chunk->stripes[i].DeviceID()); … … Chunk::Size() const 66 66 67 67 68 68 status_t 69 Chunk::FindBlock(off_t logical, off_t &physical)69 Chunk::FindBlock(off_t logical, off_t& physical) 70 70 { 71 71 if (fChunk == NULL) 72 72 return B_NO_INIT; 73 73 74 74 if (logical < (off_t)fChunkOffset 75 75 || logical > (off_t)(fChunkOffset + fChunk->Length())) 76 76 return B_BAD_VALUE; 77 77 78 78 // only one stripe 79 79 physical = logical + fChunk->stripes[0].Offset() - fChunkOffset; -
src/add-ons/kernel/file_systems/btrfs/Chunk.h
diff --git a/src/add-ons/kernel/file_systems/btrfs/Chunk.h b/src/add-ons/kernel/file_systems/btrfs/Chunk.h index b751e72..4119dec 100644
a b public: 18 18 fsblock_t offset); 19 19 ~Chunk(); 20 20 uint32 Size() const; 21 status_t FindBlock(off_t logical, off_t &physical);21 status_t FindBlock(off_t logical, off_t& physical); 22 22 fsblock_t Offset() const { return fChunkOffset; } 23 fsblock_t End() const 23 fsblock_t End() const 24 24 { return fChunkOffset + fChunk->Length(); } 25 25 private: 26 26 struct btrfs_chunk* fChunk; -
src/add-ons/kernel/file_systems/btrfs/DirectoryIterator.cpp
diff --git a/src/add-ons/kernel/file_systems/btrfs/DirectoryIterator.cpp b/src/add-ons/kernel/file_systems/btrfs/DirectoryIterator.cpp index 01eb988..62241e6 100644
a b DirectoryIterator::GetNext(char* name, size_t* _nameLength, ino_t* _id) 73 73 } 74 74 75 75 btrfs_key key; 76 btrfs_dir_entry *entries;76 btrfs_dir_entry* entries; 77 77 size_t entries_length; 78 78 status_t status = fIterator->GetNextEntry(key, (void**)&entries, 79 79 &entries_length); 80 80 if (status != B_OK) 81 81 return status; 82 82 83 btrfs_dir_entry *entry = entries;83 btrfs_dir_entry* entry = entries; 84 84 uint16 current = 0; 85 85 while (current < entries_length) { 86 86 current += entry->Length(); 87 87 break; 88 88 // TODO there could be several entries with the same name hash 89 entry = (btrfs_dir_entry 89 entry = (btrfs_dir_entry*)((uint8*)entry + entry->Length()); 90 90 } 91 91 92 92 size_t length = entry->NameLength(); … … DirectoryIterator::Lookup(const char* name, size_t nameLength, ino_t* _id) 127 127 key.SetObjectID(fInode->ID()); 128 128 key.SetOffset(hash); 129 129 130 btrfs_dir_entry *entries;130 btrfs_dir_entry* entries; 131 131 size_t length; 132 132 status_t status = fInode->GetVolume()->FSTree()->FindExact(key, 133 133 (void**)&entries, &length); … … DirectoryIterator::Lookup(const char* name, size_t nameLength, ino_t* _id) 137 137 return status; 138 138 } 139 139 140 btrfs_dir_entry *entry = entries;140 btrfs_dir_entry* entry = entries; 141 141 uint16 current = 0; 142 142 while (current < length) { 143 143 current += entry->Length(); 144 144 break; 145 145 // TODO there could be several entries with the same name hash 146 entry = (btrfs_dir_entry 146 entry = (btrfs_dir_entry*)((uint8*)entry + entry->Length()); 147 147 } 148 148 149 149 TRACE("DirectoryIterator::Lookup() entries_length %ld name_length %d\n", -
src/add-ons/kernel/file_systems/btrfs/Inode.cpp
diff --git a/src/add-ons/kernel/file_systems/btrfs/Inode.cpp b/src/add-ons/kernel/file_systems/btrfs/Inode.cpp index 742f6d5..0932acd 100644
a b Inode::UpdateNodeFromDisk() 84 84 search_key.SetObjectID(fID); 85 85 search_key.SetOffset(0); 86 86 87 struct btrfs_inode *node;87 struct btrfs_inode* node; 88 88 if (fVolume->FSTree()->FindExact(search_key, (void**)&node) != B_OK) { 89 89 ERROR("Inode::UpdateNodeFromDisk(): Couldn't find inode %" 90 90 B_PRIdINO "\n", fID); … … Inode::CheckPermissions(int accessMode) const 110 110 111 111 112 112 status_t 113 Inode::FindBlock(off_t pos, off_t& physical, off_t *_length)113 Inode::FindBlock(off_t pos, off_t& physical, off_t* _length) 114 114 { 115 115 struct btrfs_key search_key; 116 116 search_key.SetType(BTRFS_KEY_TYPE_EXTENT_DATA); 117 117 search_key.SetObjectID(fID); 118 118 search_key.SetOffset(pos + 1); 119 119 120 btrfs_extent_data *extent_data;120 btrfs_extent_data* extent_data; 121 121 status_t status = fVolume->FSTree()->FindPrevious(search_key, 122 122 (void**)&extent_data); 123 123 if (status != B_OK) { … … Inode::ReadAt(off_t pos, uint8* buffer, size_t* _length) 173 173 search_key.SetOffset(pos + 1); 174 174 175 175 size_t item_size; 176 btrfs_extent_data *extent_data;176 btrfs_extent_data* extent_data; 177 177 status_t status = fVolume->FSTree()->FindPrevious(search_key, 178 178 (void**)&extent_data, &item_size); 179 179 if (status != B_OK) { … … Inode::ReadAt(off_t pos, uint8* buffer, size_t* _length) 291 291 292 292 293 293 status_t 294 Inode::FindParent(ino_t *id)294 Inode::FindParent(ino_t* id) 295 295 { 296 296 struct btrfs_key search_key; 297 297 search_key.SetType(BTRFS_KEY_TYPE_INODE_REF); 298 298 search_key.SetObjectID(fID); 299 299 search_key.SetOffset(-1); 300 300 301 void *node_ref;301 void* node_ref; 302 302 if (fVolume->FSTree()->FindPrevious(search_key, &node_ref) != B_OK) { 303 303 ERROR("Inode::FindParent(): Couldn't find inode for %" B_PRIdINO "\n", 304 304 fID); -
src/add-ons/kernel/file_systems/btrfs/Inode.h
diff --git a/src/add-ons/kernel/file_systems/btrfs/Inode.h b/src/add-ons/kernel/file_systems/btrfs/Inode.h index b6fa157..0213e88 100644
a b public: 32 32 33 33 ino_t ID() const { return fID; } 34 34 35 rw_lock* Lock() { return &fLock; }35 rw_lock* Lock() { return& fLock; } 36 36 37 37 status_t UpdateNodeFromDisk(); 38 38 … … public: 48 48 off_t Size() const { return fNode.Size(); } 49 49 uid_t UserID() const { return fNode.UserID(); } 50 50 gid_t GroupID() const { return fNode.GroupID(); } 51 void GetChangeTime(struct timespec ×pec) const51 void GetChangeTime(struct timespec& timespec) const 52 52 { fNode.GetChangeTime(timespec); } 53 void GetModificationTime(struct timespec ×pec) const53 void GetModificationTime(struct timespec& timespec) const 54 54 { fNode.GetModificationTime(timespec); } 55 void GetCreationTime(struct timespec ×pec) const55 void GetCreationTime(struct timespec& timespec) const 56 56 { fNode.GetCreationTime(timespec); } 57 void GetAccessTime(struct timespec ×pec) const57 void GetAccessTime(struct timespec& timespec) const 58 58 { fNode.GetCreationTime(timespec); } 59 59 60 60 Volume* GetVolume() const { return fVolume; } 61 61 62 62 status_t FindBlock(off_t logical, off_t& physical, 63 off_t *_length = NULL);64 status_t ReadAt(off_t pos, uint8 *buffer, size_t *length);63 off_t* _length = NULL); 64 status_t ReadAt(off_t pos, uint8* buffer, size_t* length); 65 65 status_t FillGapWithZeros(off_t start, off_t end); 66 66 67 67 void* FileCache() const { return fCache; } 68 68 void* Map() const { return fMap; } 69 69 70 status_t FindParent(ino_t *id);70 status_t FindParent(ino_t* id); 71 71 private: 72 72 Inode(Volume* volume); 73 73 Inode(const Inode&); 74 Inode &operator=(const Inode&);74 Inode& operator=(const Inode&); 75 75 // no implementation 76 76 77 77 uint64 _NumBlocks(); … … private: 149 149 Inode* fInode; 150 150 }; 151 151 152 152 153 #endif // INODE_H -
src/add-ons/kernel/file_systems/btrfs/Utility.h
diff --git a/src/add-ons/kernel/file_systems/btrfs/Utility.h b/src/add-ons/kernel/file_systems/btrfs/Utility.h index 07a252e..6f7430f 100644
a b open_mode_to_access(int openMode) 38 38 return R_OK | W_OK; 39 39 } 40 40 41 41 42 #endif // UTILITY_H -
src/add-ons/kernel/file_systems/btrfs/Volume.cpp
diff --git a/src/add-ons/kernel/file_systems/btrfs/Volume.cpp b/src/add-ons/kernel/file_systems/btrfs/Volume.cpp index 5b99447..6f44df5 100644
a b Volume::Mount(const char* deviceName, uint32 flags) 348 348 search_key.SetOffset(0); 349 349 search_key.SetType(BTRFS_KEY_TYPE_ROOT_ITEM); 350 350 search_key.SetObjectID(BTRFS_OBJECT_ID_EXTENT_TREE); 351 struct btrfs_root *root;351 struct btrfs_root* root; 352 352 if (fRootTree->FindNext(search_key, (void**)&root) != B_OK) { 353 353 ERROR("Volume::Mount(): Couldn't find extent root\n"); 354 354 return B_ERROR; … … Volume::LoadSuperBlock() 478 478 479 479 480 480 status_t 481 Volume::FindBlock(off_t logical, fsblock_t &physicalBlock)481 Volume::FindBlock(off_t logical, fsblock_t& physicalBlock) 482 482 { 483 483 off_t physical; 484 484 status_t status = FindBlock(logical, physical); … … Volume::FindBlock(off_t logical, fsblock_t &physicalBlock) 490 490 491 491 492 492 status_t 493 Volume::FindBlock(off_t logical, off_t &physical)493 Volume::FindBlock(off_t logical, off_t& physical) 494 494 { 495 495 if (fChunkTree == NULL 496 496 || (logical >= (off_t)fChunk->Offset() … … Volume::FindBlock(off_t logical, off_t &physical) 503 503 search_key.SetOffset(logical); 504 504 search_key.SetType(BTRFS_KEY_TYPE_CHUNK_ITEM); 505 505 search_key.SetObjectID(BTRFS_OBJECT_ID_CHUNK_TREE); 506 struct btrfs_chunk *chunk;506 struct btrfs_chunk* chunk; 507 507 size_t chunk_length; 508 508 status_t status = fChunkTree->FindPrevious(search_key, (void**)&chunk, 509 509 &chunk_length); -
src/add-ons/kernel/file_systems/btrfs/Volume.h
diff --git a/src/add-ons/kernel/file_systems/btrfs/Volume.h b/src/add-ons/kernel/file_systems/btrfs/Volume.h index a832fd2..dabdca5 100644
a b 6 6 #ifndef VOLUME_H 7 7 #define VOLUME_H 8 8 9 10 9 #include <lock.h> 11 10 12 11 #include "btrfs.h" … … public: 53 52 54 53 static status_t Identify(int fd, btrfs_super_block* superBlock); 55 54 56 status_t FindBlock(off_t logical, fsblock_t &physical);57 status_t FindBlock(off_t logical, off_t &physical);55 status_t FindBlock(off_t logical, fsblock_t& physical); 56 status_t FindBlock(off_t logical, off_t& physical); 58 57 59 58 private: 60 59 mutex fLock; … … private: 78 77 BPlusTree* fChecksumTree; 79 78 }; 80 79 81 #endif // VOLUME_H82 80 81 #endif // VOLUME_H -
src/add-ons/kernel/file_systems/btrfs/btrfs.h
diff --git a/src/add-ons/kernel/file_systems/btrfs/btrfs.h b/src/add-ons/kernel/file_systems/btrfs/btrfs.h index c3e6ad5..ef2a69c 100644
a b struct btrfs_key { 32 32 void SetOffset(uint64 off) { offset = B_HOST_TO_LENDIAN_INT64(off); } 33 33 } _PACKED; 34 34 35 35 36 struct btrfs_timespec { 36 37 uint64 seconds; 37 38 uint32 nanoseconds; 38 39 } _PACKED; 39 40 41 40 42 struct btrfs_header { 41 43 uint8 checksum[32]; 42 44 uint8 fsid[16]; … … struct btrfs_header { 49 51 uint8 level; 50 52 uint64 BlockNum() const { return B_LENDIAN_TO_HOST_INT64(blocknum); } 51 53 uint64 Flags() const { return B_LENDIAN_TO_HOST_INT64(flags); } 52 uint64 Generation() const {53 return B_LENDIAN_TO_HOST_INT64(generation); }54 uint64 Owner() const {55 return B_LENDIAN_TO_HOST_INT64(owner); }56 uint32 ItemCount() const {57 return B_LENDIAN_TO_HOST_INT32(item_count); }54 uint64 Generation() const 55 { return B_LENDIAN_TO_HOST_INT64(generation); } 56 uint64 Owner() const 57 { return B_LENDIAN_TO_HOST_INT64(owner); } 58 uint32 ItemCount() const 59 { return B_LENDIAN_TO_HOST_INT32(item_count); } 58 60 uint8 Level() const { return level; } 59 61 } _PACKED; 60 62 63 61 64 struct btrfs_index { 62 65 btrfs_key key; 63 66 uint64 blocknum; 64 67 uint64 generation; 65 68 uint64 BlockNum() const { return B_LENDIAN_TO_HOST_INT64(blocknum); } 66 uint64 Generation() const {67 return B_LENDIAN_TO_HOST_INT64(generation); }69 uint64 Generation() const 70 { return B_LENDIAN_TO_HOST_INT64(generation); } 68 71 } _PACKED; 69 72 73 70 74 struct btrfs_entry { 71 75 btrfs_key key; 72 76 uint32 offset; 73 77 uint32 size; 74 uint32 Offset() const {75 return B_LENDIAN_TO_HOST_INT32(offset); }76 uint32 Size() const {77 return B_LENDIAN_TO_HOST_INT32(size); }78 uint32 Offset() const 79 { return B_LENDIAN_TO_HOST_INT32(offset); } 80 uint32 Size() const 81 { return B_LENDIAN_TO_HOST_INT32(size); } 78 82 } _PACKED; 79 83 84 80 85 struct btrfs_stream { 81 86 btrfs_header header; 82 87 union { … … struct btrfs_stream { 85 90 }; 86 91 } _PACKED; 87 92 93 88 94 struct btrfs_stripe { 89 95 uint64 device_id; 90 96 uint64 offset; … … struct btrfs_stripe { 93 99 uint64 Offset() const { return B_LENDIAN_TO_HOST_INT64(offset); } 94 100 } _PACKED; 95 101 102 96 103 struct btrfs_chunk { 97 104 uint64 length; 98 105 uint64 owner; … … struct btrfs_chunk { 119 126 { return B_LENDIAN_TO_HOST_INT16(sub_stripes); } 120 127 } _PACKED; 121 128 129 122 130 struct btrfs_device { 123 131 uint64 id; 124 132 uint64 total_size; … … struct btrfs_super_block { 174 182 // implemented in Volume.cpp 175 183 uint64 TotalSize() const { return B_LENDIAN_TO_HOST_INT64(total_size); } 176 184 uint32 BlockSize() const { return B_LENDIAN_TO_HOST_INT32(sector_size); } 177 uint64 RootDirObjectID() const {178 return B_LENDIAN_TO_HOST_INT64(root_dir_object_id); }179 uint64 Generation() const {180 return B_LENDIAN_TO_HOST_INT64(generation); }181 uint64 Root() const {182 return B_LENDIAN_TO_HOST_INT64(root); }183 uint64 ChunkRoot() const {184 return B_LENDIAN_TO_HOST_INT64(chunk_root); }185 uint64 LogRoot() const {186 return B_LENDIAN_TO_HOST_INT64(log_root); }185 uint64 RootDirObjectID() const 186 { return B_LENDIAN_TO_HOST_INT64(root_dir_object_id); } 187 uint64 Generation() const 188 { return B_LENDIAN_TO_HOST_INT64(generation); } 189 uint64 Root() const 190 { return B_LENDIAN_TO_HOST_INT64(root); } 191 uint64 ChunkRoot() const 192 { return B_LENDIAN_TO_HOST_INT64(chunk_root); } 193 uint64 LogRoot() const 194 { return B_LENDIAN_TO_HOST_INT64(log_root); } 187 195 uint8 ChunkRootLevel() const { return chunk_root_level; } 188 196 } _PACKED; 189 197 198 190 199 struct btrfs_inode { 191 200 uint64 generation; 192 201 uint64 transaction_id; … … struct btrfs_inode { 212 221 uint32 Mode() const { return B_LENDIAN_TO_HOST_INT32(mode); } 213 222 uint64 Flags() const { return B_LENDIAN_TO_HOST_INT64(flags); } 214 223 uint64 Sequence() const { return B_LENDIAN_TO_HOST_INT64(sequence); } 215 static void _DecodeTime(struct timespec ×pec,216 const struct btrfs_timespec &time)224 static void _DecodeTime(struct timespec& timespec, 225 const struct btrfs_timespec& time) 217 226 { 218 227 timespec.tv_sec = B_LENDIAN_TO_HOST_INT64(time.seconds); 219 228 timespec.tv_nsec = B_LENDIAN_TO_HOST_INT32(time.nanoseconds); 220 229 } 221 void GetAccessTime(struct timespec ×pec) const230 void GetAccessTime(struct timespec& timespec) const 222 231 { _DecodeTime(timespec, access_time); } 223 void GetChangeTime(struct timespec ×pec) const232 void GetChangeTime(struct timespec& timespec) const 224 233 { _DecodeTime(timespec, change_time); } 225 void GetModificationTime(struct timespec ×pec) const234 void GetModificationTime(struct timespec& timespec) const 226 235 { _DecodeTime(timespec, modification_time); } 227 void GetCreationTime(struct timespec ×pec) const236 void GetCreationTime(struct timespec& timespec) const 228 237 { _DecodeTime(timespec, creation_time); } 229 238 } _PACKED; 230 239 240 231 241 struct btrfs_root { 232 242 btrfs_inode inode; 233 243 uint64 generation; … … struct btrfs_root { 241 251 btrfs_key drop_progress; 242 252 uint8 drop_level; 243 253 uint8 level; 244 uint64 Generation() const {245 return B_LENDIAN_TO_HOST_INT64(generation); }254 uint64 Generation() const 255 { return B_LENDIAN_TO_HOST_INT64(generation); } 246 256 uint64 BlockNum() const { return B_LENDIAN_TO_HOST_INT64(blocknum); } 247 257 } _PACKED; 248 258 259 249 260 struct btrfs_dir_entry { 250 261 btrfs_key location; 251 262 uint64 transaction_id; … … struct btrfs_dir_entry { 259 270 { return sizeof(*this) + NameLength() + DataLength(); } 260 271 } _PACKED; 261 272 273 262 274 struct btrfs_extent_data { 263 275 uint64 generation; 264 276 uint64 memory_size; … … struct btrfs_extent_data { 275 287 }; 276 288 uint8 inline_data[0]; 277 289 }; 278 uint64 Generation() const {279 return B_LENDIAN_TO_HOST_INT64(generation); }280 uint64 MemoryBytes() const {281 return B_LENDIAN_TO_HOST_INT64(memory_size); }290 uint64 Generation() const 291 { return B_LENDIAN_TO_HOST_INT64(generation); } 292 uint64 MemoryBytes() const 293 { return B_LENDIAN_TO_HOST_INT64(memory_size); } 282 294 uint8 Compression() const { return compression; } 283 295 uint8 Type() const { return type; } 284 uint64 DiskOffset() const {285 return B_LENDIAN_TO_HOST_INT64(disk_offset); }286 uint64 DiskSize() const {287 return B_LENDIAN_TO_HOST_INT64(disk_size); }288 uint64 ExtentOffset() const {289 return B_LENDIAN_TO_HOST_INT64(extent_offset); }290 uint64 Size() const {291 return B_LENDIAN_TO_HOST_INT64(size); }296 uint64 DiskOffset() const 297 { return B_LENDIAN_TO_HOST_INT64(disk_offset); } 298 uint64 DiskSize() const 299 { return B_LENDIAN_TO_HOST_INT64(disk_size); } 300 uint64 ExtentOffset() const 301 { return B_LENDIAN_TO_HOST_INT64(extent_offset); } 302 uint64 Size() const 303 { return B_LENDIAN_TO_HOST_INT64(size); } 292 304 } _PACKED; 293 305 294 306 … … struct file_cookie { 326 338 int open_mode; 327 339 }; 328 340 341 329 342 #define BTRFS_OPEN_MODE_USER_MASK 0x7fffffff 330 343 331 344 extern fs_volume_ops gBtrfsVolumeOps; 332 345 extern fs_vnode_ops gBtrfsVnodeOps; 333 346 347 334 348 #endif // BTRFS_H -
src/add-ons/kernel/file_systems/btrfs/crc_table.cpp
diff --git a/src/add-ons/kernel/file_systems/btrfs/crc_table.cpp b/src/add-ons/kernel/file_systems/btrfs/crc_table.cpp index b5de8bd..1413f95 100644
a b 7 7 8 8 /*! \file crc_table.cpp 9 9 10 Standalone program to generate the CRC table used for calculating 11 UDF tag id CRC values. 12 13 This code based off of crc code in UDF-2.50 specs, as permitted. 14 See UDF-2.50 6.5 for more information. 10 Standalone program to generate the CRC table used for calculating 11 UDF tag id CRC values. 15 12 16 Reflected version by Jéme Duval 13 This code based off of crc code in UDF-2.50 specs, as permitted. 14 See UDF-2.50 6.5 for more information. 15 16 Reflected version by Jéme Duval 17 17 */ 18 18 19 19 20 #include <stdio.h> 20 21 #include <sys/types.h> 21 22 23 22 24 typedef unsigned int uint32 ; 23 25 24 26 uint32 … … reflect32 (uint32 b) 36 38 37 39 38 40 int 39 main(int argc, char *argv[]) {40 41 main(int argc, char* argv[]) { 42 uint32 crc, poly; 41 43 42 if (argc != 2) { 43 fprintf(stderr, "USAGE: crc_table <octal polynomial=3667067501 for btrfs>\n"); 44 return 0; 45 } 44 if (argc != 2) { 45 fprintf(stderr, "USAGE: crc_table <octal polynomial=3667067501 for btrfs>\n"); 46 return 0; 47 } 48 49 sscanf(argv[1], "%lo", &poly); 46 50 47 sscanf(argv[1], "%lo", &poly); 48 49 printf("//! CRC 0%o table, as generated by crc_table.cpp\n", poly); 50 printf("static uint32 crc_table[256] = { \n"); 51 for (int n = 0; n < 256; n++) { 52 if (n%8 == 0) 53 printf(" "); 54 crc = reflect32(n); 55 for (int i = 0; i < 8; i++) { 56 if (crc & 0x80000000) 57 crc = (crc << 1) ^ poly; 58 else 59 crc <<= 1; 60 } 51 printf("//! CRC 0%o table, as generated by crc_table.cpp\n", poly); 52 printf("static uint32 crc_table[256] = { \n"); 53 for (int n = 0; n < 256; n++) { 54 if (n % 8 == 0) 55 printf(" "); 56 crc = reflect32(n); 57 for (int i = 0; i < 8; i++) { 58 if (crc & 0x80000000) 59 crc = (crc << 1) ^ poly; 60 else 61 crc <<= 1; 62 } 61 63 crc = reflect32(crc); 62 63 if (n%8 == 7)64 65 66 67 64 printf("0x%08x%s ", crc, (n != 255 ? "," : "")); 65 if (n % 8 == 7) 66 printf("\n"); 67 } 68 printf("};\n"); 69 return 0; 68 70 } -
src/add-ons/kernel/file_systems/btrfs/kernel_interface.cpp
diff --git a/src/add-ons/kernel/file_systems/btrfs/kernel_interface.cpp b/src/add-ons/kernel/file_systems/btrfs/kernel_interface.cpp index 3ab3765..303d416 100644
a b iterative_io_finished_hook(void* cookie, io_request* request, status_t status, 68 68 69 69 70 70 static float 71 btrfs_identify_partition(int fd, partition_data *partition, void **_cookie)71 btrfs_identify_partition(int fd, partition_data* partition, void** _cookie) 72 72 { 73 73 btrfs_super_block superBlock; 74 74 status_t status = Volume::Identify(fd, &superBlock); 75 75 if (status != B_OK) 76 76 return -1; 77 77 78 identify_cookie *cookie = new identify_cookie;78 identify_cookie* cookie = new identify_cookie; 79 79 memcpy(&cookie->super_block, &superBlock, sizeof(btrfs_super_block)); 80 80 81 81 *_cookie = cookie; … … btrfs_identify_partition(int fd, partition_data *partition, void **_cookie) 84 84 85 85 86 86 static status_t 87 btrfs_scan_partition(int fd, partition_data *partition, void *_cookie)87 btrfs_scan_partition(int fd, partition_data* partition, void* _cookie) 88 88 { 89 identify_cookie *cookie = (identify_cookie*)_cookie;89 identify_cookie* cookie = (identify_cookie*)_cookie; 90 90 91 91 partition->status = B_PARTITION_VALID; 92 92 partition->flags |= B_PARTITION_FILE_SYSTEM; … … btrfs_mount(fs_volume* _volume, const char* device, uint32 flags, 138 138 139 139 140 140 static status_t 141 btrfs_unmount(fs_volume *_volume)141 btrfs_unmount(fs_volume* _volume) 142 142 { 143 Volume* volume = (Volume 143 Volume* volume = (Volume*)_volume->private_volume; 144 144 145 145 status_t status = volume->Unmount(); 146 146 delete volume; … … btrfs_read(fs_volume* _volume, fs_vnode* _node, void* _cookie, off_t pos, 452 452 453 453 454 454 static status_t 455 btrfs_close(fs_volume *_volume, fs_vnode *_node, void *_cookie)455 btrfs_close(fs_volume* _volume, fs_vnode* _node, void* _cookie) 456 456 { 457 457 return B_OK; 458 458 } … … btrfs_access(fs_volume* _volume, fs_vnode* _node, int accessMode) 482 482 483 483 484 484 static status_t 485 btrfs_read_link(fs_volume *_volume, fs_vnode *_node, char *buffer,486 size_t *_bufferSize)485 btrfs_read_link(fs_volume* _volume, fs_vnode* _node, char* buffer, 486 size_t* _bufferSize) 487 487 { 488 488 Inode* inode = (Inode*)_node->private_node; 489 489 return inode->ReadAt(0, (uint8*)buffer, _bufferSize); … … btrfs_open_dir(fs_volume* /*_volume*/, fs_vnode* _node, void** _cookie) 516 516 517 517 518 518 static status_t 519 btrfs_read_dir(fs_volume *_volume, fs_vnode *_node, void *_cookie,520 struct dirent *dirent, size_t bufferSize, uint32 *_num)519 btrfs_read_dir(fs_volume* _volume, fs_vnode* _node, void* _cookie, 520 struct dirent* dirent, size_t bufferSize, uint32* _num) 521 521 { 522 522 DirectoryIterator* iterator = (DirectoryIterator*)_cookie; 523 523 Volume* volume = (Volume*)_volume->private_volume; … … btrfs_read_dir(fs_volume *_volume, fs_vnode *_node, void *_cookie, 560 560 561 561 562 562 static status_t 563 btrfs_rewind_dir(fs_volume * /*_volume*/, fs_vnode * /*node*/, void *_cookie)563 btrfs_rewind_dir(fs_volume* /*_volume*/, fs_vnode* /*node*/, void* _cookie) 564 564 { 565 565 DirectoryIterator* iterator = (DirectoryIterator*)_cookie; 566 566 … … btrfs_close_dir(fs_volume * /*_volume*/, fs_vnode * /*node*/, void * /*_cookie*/ 576 576 577 577 578 578 static status_t 579 btrfs_free_dir_cookie(fs_volume *_volume, fs_vnode *_node, void *_cookie)579 btrfs_free_dir_cookie(fs_volume* _volume, fs_vnode* _node, void* _cookie) 580 580 { 581 581 delete (DirectoryIterator*)_cookie; 582 582 return B_OK; … … btrfs_free_dir_cookie(fs_volume *_volume, fs_vnode *_node, void *_cookie) 584 584 585 585 586 586 static status_t 587 btrfs_open_attr_dir(fs_volume *_volume, fs_vnode *_node, void **_cookie)587 btrfs_open_attr_dir(fs_volume* _volume, fs_vnode* _node, void** _cookie) 588 588 { 589 589 Inode* inode = (Inode*)_node->private_node; 590 590 TRACE("%s()\n", __FUNCTION__); … … btrfs_write_attr(fs_volume* _volume, fs_vnode* _node, void* cookie, 716 716 } 717 717 718 718 719 720 719 static status_t 721 720 btrfs_read_attr_stat(fs_volume* _volume, fs_vnode* _node, 722 721 void* _cookie, struct stat* stat) … … static file_system_module_info sBtrfsFileSystem = { 859 858 }; 860 859 861 860 862 module_info *modules[] = {863 (module_info 861 module_info* modules[] = { 862 (module_info*)&sBtrfsFileSystem, 864 863 NULL, 865 864 };