Ticket #13513: 0001-Fixed-Code-style.patch

File 0001-Fixed-Code-style.patch, 45.3 KB (added by hyche, 3 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)  
    9292    TRACE("Stat\n");
    9393
    9494    size_t nameLength = strlen(fName);
    95     btrfs_dir_entry *entries;
     95    btrfs_dir_entry* entries;
    9696    size_t length;
    9797    status_t status = _Lookup(fName, nameLength, &entries, &length);
    9898    if (status < B_OK)
    9999        return status;
    100100
    101     btrfs_dir_entry *entry;
     101    btrfs_dir_entry* entry;
    102102    status = _FindEntry(entries, length, fName, nameLength, &entry);
    103103    if (status != B_OK) {
    104104        free(entries);
    Attribute::Read(attr_cookie* cookie, off_t pos, uint8* buffer, size_t* _length)  
    120120        return ERANGE;
    121121
    122122    size_t nameLength = strlen(fName);
    123     btrfs_dir_entry *entries;
     123    btrfs_dir_entry* entries;
    124124    size_t length;
    125125    status_t status = _Lookup(fName, nameLength, &entries, &length);
    126126    if (status < B_OK)
    127127        return status;
    128128
    129     btrfs_dir_entry *entry;
     129    btrfs_dir_entry* entry;
    130130    status = _FindEntry(entries, length, fName, nameLength, &entry);
    131131    if (status != B_OK) {
    132132        free(entries);
    Attribute::Read(attr_cookie* cookie, off_t pos, uint8* buffer, size_t* _length)  
    149149
    150150status_t
    151151Attribute::_Lookup(const char* name, size_t nameLength,
    152     btrfs_dir_entry **_entries, size_t *_length)
     152    btrfs_dir_entry** _entries, size_t* _length)
    153153{
    154154    uint32 hash = calculate_crc((uint32)~1, (uint8*)name, nameLength);
    155155    struct btrfs_key key;
    Attribute::_Lookup(const char* name, size_t nameLength,  
    157157    key.SetObjectID(fInode->ID());
    158158    key.SetOffset(hash);
    159159
    160     btrfs_dir_entry *entries;
     160    btrfs_dir_entry* entries;
    161161    size_t length;
    162162    status_t status = fInode->GetVolume()->FSTree()->FindExact(key,
    163163        (void**)&entries, &length);
    Attribute::_Lookup(const char* name, size_t nameLength,  
    180180
    181181
    182182status_t
    183 Attribute::_FindEntry(btrfs_dir_entry *entries, size_t length,
    184     const char* name, size_t nameLength, btrfs_dir_entry **_entry)
     183Attribute::_FindEntry(btrfs_dir_entry* entries, size_t length,
     184    const char* name, size_t nameLength, btrfs_dir_entry** _entry)
    185185{
    186     btrfs_dir_entry *entry = entries;
     186    btrfs_dir_entry* entry = entries;
    187187    uint16 current = 0;
    188188    while (current < length) {
    189189        current += entry->Length();
    190190        break;
    191191        // TODO there could be several entries with the same name hash
    192         entry = (btrfs_dir_entry *)((uint8*)entry + entry->Length());
     192        entry = (btrfs_dir_entry*)((uint8*)entry + entry->Length());
    193193    }
    194194   
    195195    *_entry = entry;
    196196    return B_OK;
    197197}
    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:  
    3838                                    uint8* buffer, size_t* _length);
    3939private:
    4040            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,
    4444                                    size_t length, const char* name,
    4545                                    size_t nameLength,
    46                                     btrfs_dir_entry **_entry);
     46                                    btrfs_dir_entry** _entry);
    4747
    4848            ::Volume*           fVolume;
    4949            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  
    5050AttributeIterator::GetNext(char* name, size_t* _nameLength)
    5151{
    5252    btrfs_key key;
    53     btrfs_dir_entry *entries;
     53    btrfs_dir_entry* entries;
    5454    size_t entries_length;
    5555    status_t status = fIterator->GetPreviousEntry(key, (void**)&entries,
    5656        &entries_length);
    5757    if (status != B_OK)
    5858        return status;
    5959
    60     btrfs_dir_entry *entry = entries;
     60    btrfs_dir_entry* entry = entries;
    6161    uint16 current = 0;
    6262    while (current < entries_length) {
    6363        current += entry->Length();
    6464        break;
    6565        // TODO there could be several entries with the same name hash
    66         entry = (btrfs_dir_entry *)((uint8*)entry + entry->Length());
     66        entry = (btrfs_dir_entry*)((uint8*)entry + entry->Length());
    6767    }
    6868
    6969    TRACE("DirectoryIterator::GetNext() entries_length %ld name_length %d\n",
    AttributeIterator::Rewind()  
    8585    fOffset = -1ULL;
    8686    return B_OK;
    8787}
    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  
    2626#   define ERROR(x...) dprintf("\33[34mbtrfs:\33[0m " x)
    2727
    2828
    29 BPlusTree::BPlusTree(Volume* volume, struct btrfs_stream *stream)
     29BPlusTree::BPlusTree(Volume* volume, struct btrfs_stream* stream)
    3030    :
    3131    fStream(stream),
    3232    fRootBlock(0),
    BPlusTree::~BPlusTree()  
    6262
    6363
    6464int32
    65 BPlusTree::_CompareKeys(struct btrfs_key &key1, struct btrfs_key &key2)
     65BPlusTree::_CompareKeys(struct btrfs_key& key1, struct btrfs_key& key2)
    6666{
    6767    if (key1.ObjectID() > key2.ObjectID())
    6868        return 1;
    BPlusTree::_CompareKeys(struct btrfs_key &key1, struct btrfs_key &key2)  
    8686    It can also return other errors to indicate that something went wrong.
    8787*/
    8888status_t
    89 BPlusTree::_Find(struct btrfs_key &key, void** _value, size_t* _size,
     89BPlusTree::_Find(struct btrfs_key& key, void** _value, size_t* _size,
    9090    bplustree_traversing type)
    9191{
    9292    TRACE("Find() objectid %" B_PRId64 " type %d offset %" B_PRId64 " \n",
    9393        key.ObjectID(), key.Type(), key.Offset());
    94     btrfs_stream *stream = fStream;
     94    btrfs_stream* stream = fStream;
    9595    CachedBlock cached(fVolume);
    9696    fsblock_t physical;
    9797    if (stream == NULL) {
    BPlusTree::_Find(struct btrfs_key &key, void** _value, size_t* _size,  
    9999            ERROR("Find() unmapped block %" B_PRId64 "\n", fRootBlock);
    100100            return B_ERROR;
    101101        }
    102         stream = (btrfs_stream *)cached.SetTo(physical);
     102        stream = (btrfs_stream*)cached.SetTo(physical);
    103103    }
    104104
    105105    while (stream->header.Level() != 0) {
    BPlusTree::_Find(struct btrfs_key &key, void** _value, size_t* _size,  
    123123                stream->index[i - 1].BlockNum());
    124124            return B_ERROR;
    125125        }
    126         stream = (btrfs_stream *)cached.SetTo(physical);
     126        stream = (btrfs_stream*)cached.SetTo(physical);
    127127    }
    128128
    129129    uint32 i;
    BPlusTree::_Find(struct btrfs_key &key, void** _value, size_t* _size,  
    175175            if ((fVolume->BlockSize() - totalOffset % fVolume->BlockSize())
    176176                >= stream->entries[i].Size()) {
    177177                //If there is enough space for *_value
    178                 memcpy(*_value, ((uint8 *)cached.SetTo(physical
     178                memcpy(*_value, ((uint8*)cached.SetTo(physical
    179179                    + totalOffset / fVolume->BlockSize())
    180180                    + totalOffset % fVolume->BlockSize()),
    181181                    stream->entries[i].Size());
    BPlusTree::_Find(struct btrfs_key &key, void** _value, size_t* _size,  
    201201
    202202
    203203status_t
    204 BPlusTree::FindNext(struct btrfs_key &key, void** _value, size_t* _size)
     204BPlusTree::FindNext(struct btrfs_key& key, void** _value, size_t* _size)
    205205{
    206206    return _Find(key, _value, _size, BPLUSTREE_FORWARD);
    207207}
    208208
    209209
    210210status_t
    211 BPlusTree::FindPrevious(struct btrfs_key &key, void** _value, size_t* _size)
     211BPlusTree::FindPrevious(struct btrfs_key& key, void** _value, size_t* _size)
    212212{
    213213    return _Find(key, _value, _size, BPLUSTREE_BACKWARD);
    214214}
    215215
    216216
    217217status_t
    218 BPlusTree::FindExact(struct btrfs_key &key, void** _value, size_t* _size)
     218BPlusTree::FindExact(struct btrfs_key& key, void** _value, size_t* _size)
    219219{
    220220    return _Find(key, _value, _size, BPLUSTREE_EXACT);
    221221}
    BPlusTree::_RemoveIterator(TreeIterator* iterator)  
    240240//  #pragma mark -
    241241
    242242
    243 TreeIterator::TreeIterator(BPlusTree* tree, struct btrfs_key &key)
     243TreeIterator::TreeIterator(BPlusTree* tree, struct btrfs_key& key)
    244244    :
    245245    fTree(tree),
    246246    fCurrentKey(key)
    TreeIterator::~TreeIterator()  
    260260/*! Iterates through the tree in the specified direction.
    261261*/
    262262status_t
    263 TreeIterator::Traverse(bplustree_traversing direction, struct btrfs_key &key,
     263TreeIterator::Traverse(bplustree_traversing direction, struct btrfs_key& key,
    264264    void** value, size_t* size)
    265265{
    266266    if (fTree == NULL)
    TreeIterator::Traverse(bplustree_traversing direction, struct btrfs_key &key,  
    281281/*! just sets the current key in the iterator.
    282282*/
    283283status_t
    284 TreeIterator::Find(struct btrfs_key &key)
     284TreeIterator::Find(struct btrfs_key& key)
    285285{
    286286    if (fTree == NULL)
    287287        return B_INTERRUPTED;
    TreeIterator::Stop()  
    295295{
    296296    fTree = NULL;
    297297}
    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 {  
    3030
    3131//  #pragma mark - in-memory structures
    3232
     33
    3334template<class T> class Stack;
    3435class TreeIterator;
    3536
    struct node_and_key {  
    4445class BPlusTree {
    4546public:
    4647                                BPlusTree(Volume* volume,
    47                                     struct btrfs_stream *stream);
     48                                    struct btrfs_stream* stream);
    4849                                BPlusTree(Volume* volume,
    4950                                    fsblock_t rootBlock);
    5051                                ~BPlusTree();
    51             status_t            FindExact(struct btrfs_key &key, void** value,
     52            status_t            FindExact(struct btrfs_key& key, void** value,
    5253                                    size_t* size = NULL);
    53             status_t            FindNext(struct btrfs_key &key, void** value,
     54            status_t            FindNext(struct btrfs_key& key, void** value,
    5455                                    size_t* size = NULL);
    55             status_t            FindPrevious(struct btrfs_key &key, void** value,
     56            status_t            FindPrevious(struct btrfs_key& key, void** value,
    5657                                    size_t* size = NULL);
    5758
    5859private:
    private:  
    6061                                BPlusTree& operator=(const BPlusTree& other);
    6162                                    // no implementation
    6263
    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,
    6667                                    size_t* size, bplustree_traversing type);
    6768            void                _AddIterator(TreeIterator* iterator);
    6869            void                _RemoveIterator(TreeIterator* iterator);
    private:  
    7980
    8081class TreeIterator : public SinglyLinkedListLinkImpl<TreeIterator> {
    8182public:
    82                                 TreeIterator(BPlusTree* tree, struct btrfs_key &key);
     83                                TreeIterator(BPlusTree* tree, struct btrfs_key& key);
    8384                                ~TreeIterator();
    8485
    8586            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);
    8990
    9091            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);
    9596
    9697            BPlusTree*          Tree() const { return fTree; }
    9798
    TreeIterator::Rewind()  
    117118    return B_OK;
    118119}
    119120
     121
    120122inline status_t
    121 TreeIterator::GetNextEntry(struct btrfs_key &key, void** value, size_t *size)
     123TreeIterator::GetNextEntry(struct btrfs_key& key, void** value, size_t* size)
    122124{
    123125    return Traverse(BPLUSTREE_FORWARD, key, value, size);
    124126}
    125127
     128
    126129inline status_t
    127 TreeIterator::GetPreviousEntry(struct btrfs_key &key, void** value,
    128     size_t *size)
     130TreeIterator::GetPreviousEntry(struct btrfs_key& key, void** value,
     131    size_t* size)
    129132{
    130133    return Traverse(BPLUSTREE_BACKWARD, key, value, size);
    131134}
    132135
    133136
    134 
    135137#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  
    1212
    1313//! CRC 03667067501 table, as generated by crc_table.cpp
    1414static uint32 kCrcTable[256] = {
    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
     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
    4747};
    4848
    4949
    static uint32 kCrcTable[256] = {  
    5858    \return The crc checksum, or 0 if an error occurred.
    5959*/
    6060uint32
    61 calculate_crc(uint32 crc, uint8 *data, uint16 length)
     61calculate_crc(uint32 crc, uint8* data, uint16 length)
    6262{
    6363    if (data) {
    6464        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  
    66 *      Jérôme Duval
    77 */
    88
    9 uint32 calculate_crc(uint32 crc, uint8 *data, uint16 length);
    10 
     9uint32 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:  
    2727            off_t           BlockNumber() const { return fBlockNumber; }
    2828
    2929private:
    30                             CachedBlock(const CachedBlock &);
    31                             CachedBlock &operator=(const CachedBlock &);
     30                            CachedBlock(const CachedBlock&);
     31                            CachedBlock& operator=(const CachedBlock&);
    3232                                // no implementation
    3333                       
    3434protected:
    CachedBlock::SetTo(off_t block)  
    9191{
    9292    Unset();
    9393    fBlockNumber = block;
    94     return fBlock = (uint8 *)block_cache_get(fVolume->BlockCache(), block);
     94    return fBlock = (uint8*)block_cache_get(fVolume->BlockCache(), block);
    9595}
    9696
     97
    9798#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)  
    4343        "sector_size %" B_PRIu32 "\n", chunk->Length(), chunk->Owner(),
    4444        chunk->StripeLength(), chunk->Type(), chunk->StripeCount(),
    4545        chunk->SubStripes(), chunk->SectorSize());
    46     for(int32 i = 0; i < chunk->StripeCount(); i++) {
     46    for (int32 i = 0; i < chunk->StripeCount(); i++) {
    4747        TRACE("chunk.stripe[%" B_PRId32 "].physical %" B_PRId64 " deviceid %"
    4848            B_PRId64 "\n", i, chunk->stripes[i].Offset(),
    4949            chunk->stripes[i].DeviceID());
    Chunk::Size() const  
    6666
    6767
    6868status_t
    69 Chunk::FindBlock(off_t logical, off_t &physical)
     69Chunk::FindBlock(off_t logical, off_t& physical)
    7070{
    7171    if (fChunk == NULL)
    7272        return B_NO_INIT;
    7373
    7474    if (logical < (off_t)fChunkOffset
    7575        || logical > (off_t)(fChunkOffset + fChunk->Length()))
    76             return B_BAD_VALUE;
     76        return B_BAD_VALUE;
    7777   
    7878    // only one stripe
    7979    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:  
    1818                                    fsblock_t offset);
    1919                                ~Chunk();
    2020            uint32              Size() const;
    21             status_t            FindBlock(off_t logical, off_t &physical);
     21            status_t            FindBlock(off_t logical, off_t& physical);
    2222            fsblock_t           Offset() const { return fChunkOffset; }
    23             fsblock_t           End() const 
     23            fsblock_t           End() const
    2424                                    { return fChunkOffset + fChunk->Length(); }
    2525private:
    2626            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)  
    7373    }
    7474
    7575    btrfs_key key;
    76     btrfs_dir_entry *entries;
     76    btrfs_dir_entry* entries;
    7777    size_t entries_length;
    7878    status_t status = fIterator->GetNextEntry(key, (void**)&entries,
    7979        &entries_length);
    8080    if (status != B_OK)
    8181        return status;
    8282
    83     btrfs_dir_entry *entry = entries;
     83    btrfs_dir_entry* entry = entries;
    8484    uint16 current = 0;
    8585    while (current < entries_length) {
    8686        current += entry->Length();
    8787        break;
    8888        // TODO there could be several entries with the same name hash
    89         entry = (btrfs_dir_entry *)((uint8*)entry + entry->Length());
     89        entry = (btrfs_dir_entry*)((uint8*)entry + entry->Length());
    9090    }
    9191
    9292    size_t length = entry->NameLength();
    DirectoryIterator::Lookup(const char* name, size_t nameLength, ino_t* _id)  
    127127    key.SetObjectID(fInode->ID());
    128128    key.SetOffset(hash);
    129129
    130     btrfs_dir_entry *entries;
     130    btrfs_dir_entry* entries;
    131131    size_t length;
    132132    status_t status = fInode->GetVolume()->FSTree()->FindExact(key,
    133133        (void**)&entries, &length);
    DirectoryIterator::Lookup(const char* name, size_t nameLength, ino_t* _id)  
    137137        return status;
    138138    }
    139139
    140     btrfs_dir_entry *entry = entries;
     140    btrfs_dir_entry* entry = entries;
    141141    uint16 current = 0;
    142142    while (current < length) {
    143143        current += entry->Length();
    144144        break;
    145145        // TODO there could be several entries with the same name hash
    146         entry = (btrfs_dir_entry *)((uint8*)entry + entry->Length());
     146        entry = (btrfs_dir_entry*)((uint8*)entry + entry->Length());
    147147    }
    148148
    149149    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()  
    8484    search_key.SetObjectID(fID);
    8585    search_key.SetOffset(0);
    8686
    87     struct btrfs_inode *node;
     87    struct btrfs_inode* node;
    8888    if (fVolume->FSTree()->FindExact(search_key, (void**)&node) != B_OK) {
    8989        ERROR("Inode::UpdateNodeFromDisk(): Couldn't find inode %"
    9090            B_PRIdINO "\n", fID);
    Inode::CheckPermissions(int accessMode) const  
    110110
    111111
    112112status_t
    113 Inode::FindBlock(off_t pos, off_t& physical, off_t *_length)
     113Inode::FindBlock(off_t pos, off_t& physical, off_t* _length)
    114114{
    115115    struct btrfs_key search_key;
    116116    search_key.SetType(BTRFS_KEY_TYPE_EXTENT_DATA);
    117117    search_key.SetObjectID(fID);
    118118    search_key.SetOffset(pos + 1);
    119119
    120     btrfs_extent_data *extent_data;
     120    btrfs_extent_data* extent_data;
    121121    status_t status = fVolume->FSTree()->FindPrevious(search_key,
    122122        (void**)&extent_data);
    123123    if (status != B_OK) {
    Inode::ReadAt(off_t pos, uint8* buffer, size_t* _length)  
    173173    search_key.SetOffset(pos + 1);
    174174
    175175    size_t item_size;
    176     btrfs_extent_data *extent_data;
     176    btrfs_extent_data* extent_data;
    177177    status_t status = fVolume->FSTree()->FindPrevious(search_key,
    178178        (void**)&extent_data, &item_size);
    179179    if (status != B_OK) {
    Inode::ReadAt(off_t pos, uint8* buffer, size_t* _length)  
    291291
    292292
    293293status_t
    294 Inode::FindParent(ino_t *id)
     294Inode::FindParent(ino_t* id)
    295295{
    296296    struct btrfs_key search_key;
    297297    search_key.SetType(BTRFS_KEY_TYPE_INODE_REF);
    298298    search_key.SetObjectID(fID);
    299299    search_key.SetOffset(-1);
    300300
    301     void *node_ref;
     301    void* node_ref;
    302302    if (fVolume->FSTree()->FindPrevious(search_key, &node_ref) != B_OK) {
    303303        ERROR("Inode::FindParent(): Couldn't find inode for %" B_PRIdINO "\n",
    304304            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:  
    3232
    3333            ino_t       ID() const { return fID; }
    3434
    35             rw_lock*    Lock() { return &fLock; }
     35            rw_lock*    Lock() { return& fLock; }
    3636
    3737            status_t    UpdateNodeFromDisk();
    3838
    public:  
    4848            off_t       Size() const { return fNode.Size(); }
    4949            uid_t       UserID() const { return fNode.UserID(); }
    5050            gid_t       GroupID() const { return fNode.GroupID(); }
    51             void        GetChangeTime(struct timespec &timespec) const
     51            void        GetChangeTime(struct timespec& timespec) const
    5252                            { fNode.GetChangeTime(timespec); }
    53             void        GetModificationTime(struct timespec &timespec) const
     53            void        GetModificationTime(struct timespec& timespec) const
    5454                            { fNode.GetModificationTime(timespec); }
    55             void        GetCreationTime(struct timespec &timespec) const
     55            void        GetCreationTime(struct timespec& timespec) const
    5656                            { fNode.GetCreationTime(timespec); }
    57             void        GetAccessTime(struct timespec &timespec) const
     57            void        GetAccessTime(struct timespec& timespec) const
    5858                            { fNode.GetCreationTime(timespec); }
    5959
    6060            Volume*     GetVolume() const { return fVolume; }
    6161
    6262            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);
    6565            status_t    FillGapWithZeros(off_t start, off_t end);
    6666
    6767            void*       FileCache() const { return fCache; }
    6868            void*       Map() const { return fMap; }
    6969           
    70             status_t    FindParent(ino_t *id);
     70            status_t    FindParent(ino_t* id);
    7171private:
    7272                        Inode(Volume* volume);
    7373                        Inode(const Inode&);
    74                         Inode &operator=(const Inode&);
     74                        Inode& operator=(const Inode&);
    7575                            // no implementation
    7676
    7777            uint64      _NumBlocks();
    private:  
    149149    Inode*      fInode;
    150150};
    151151
     152
    152153#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)  
    3838    return R_OK | W_OK;
    3939}
    4040
     41
    4142#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)  
    348348    search_key.SetOffset(0);
    349349    search_key.SetType(BTRFS_KEY_TYPE_ROOT_ITEM);
    350350    search_key.SetObjectID(BTRFS_OBJECT_ID_EXTENT_TREE);
    351     struct btrfs_root *root;
     351    struct btrfs_root* root;
    352352    if (fRootTree->FindNext(search_key, (void**)&root) != B_OK) {
    353353        ERROR("Volume::Mount(): Couldn't find extent root\n");
    354354        return B_ERROR;
    Volume::LoadSuperBlock()  
    478478
    479479
    480480status_t
    481 Volume::FindBlock(off_t logical, fsblock_t &physicalBlock)
     481Volume::FindBlock(off_t logical, fsblock_t& physicalBlock)
    482482{
    483483    off_t physical;
    484484    status_t status = FindBlock(logical, physical);
    Volume::FindBlock(off_t logical, fsblock_t &physicalBlock)  
    490490
    491491
    492492status_t
    493 Volume::FindBlock(off_t logical, off_t &physical)
     493Volume::FindBlock(off_t logical, off_t& physical)
    494494{
    495495    if (fChunkTree == NULL
    496496        || (logical >= (off_t)fChunk->Offset()
    Volume::FindBlock(off_t logical, off_t &physical)  
    503503    search_key.SetOffset(logical);
    504504    search_key.SetType(BTRFS_KEY_TYPE_CHUNK_ITEM);
    505505    search_key.SetObjectID(BTRFS_OBJECT_ID_CHUNK_TREE);
    506     struct btrfs_chunk *chunk;
     506    struct btrfs_chunk* chunk;
    507507    size_t chunk_length;
    508508    status_t status = fChunkTree->FindPrevious(search_key, (void**)&chunk,
    509509        &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  
    66#ifndef VOLUME_H
    77#define VOLUME_H
    88
    9 
    109#include <lock.h>
    1110
    1211#include "btrfs.h"
    public:  
    5352
    5453    static  status_t            Identify(int fd, btrfs_super_block* superBlock);
    5554
    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);
    5857
    5958private:
    6059            mutex               fLock;
    private:  
    7877            BPlusTree*          fChecksumTree;
    7978};
    8079
    81 #endif  // VOLUME_H
    8280
     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 {  
    3232    void SetOffset(uint64 off) { offset = B_HOST_TO_LENDIAN_INT64(off); }
    3333} _PACKED;
    3434
     35
    3536struct btrfs_timespec {
    3637    uint64  seconds;
    3738    uint32  nanoseconds;
    3839} _PACKED;
    3940
     41
    4042struct btrfs_header {
    4143    uint8   checksum[32];
    4244    uint8   fsid[16];
    struct btrfs_header {  
    4951    uint8   level;
    5052    uint64 BlockNum() const { return B_LENDIAN_TO_HOST_INT64(blocknum); }
    5153    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); }
    5860    uint8 Level() const { return level; }
    5961} _PACKED;
    6062
     63
    6164struct btrfs_index {
    6265    btrfs_key key;
    6366    uint64  blocknum;
    6467    uint64  generation;
    6568    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); }
    6871} _PACKED;
    6972
     73
    7074struct btrfs_entry {
    7175    btrfs_key key;
    7276    uint32 offset;
    7377    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); }
    7882} _PACKED;
    7983
     84
    8085struct btrfs_stream {
    8186    btrfs_header header;
    8287    union {
    struct btrfs_stream {  
    8590    };
    8691} _PACKED;
    8792
     93
    8894struct btrfs_stripe {
    8995    uint64  device_id;
    9096    uint64  offset;
    struct btrfs_stripe {  
    9399    uint64  Offset() const { return B_LENDIAN_TO_HOST_INT64(offset); }
    94100} _PACKED;
    95101
     102
    96103struct btrfs_chunk {
    97104    uint64  length;
    98105    uint64  owner;
    struct btrfs_chunk {  
    119126        { return B_LENDIAN_TO_HOST_INT16(sub_stripes); }
    120127} _PACKED;
    121128
     129
    122130struct btrfs_device {
    123131    uint64  id;
    124132    uint64  total_size;
    struct btrfs_super_block {  
    174182        // implemented in Volume.cpp
    175183    uint64 TotalSize() const { return B_LENDIAN_TO_HOST_INT64(total_size); }
    176184    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); }
    187195    uint8 ChunkRootLevel() const { return chunk_root_level; }
    188196} _PACKED;
    189197
     198
    190199struct btrfs_inode {
    191200    uint64  generation;
    192201    uint64  transaction_id;
    struct btrfs_inode {  
    212221    uint32 Mode() const { return B_LENDIAN_TO_HOST_INT32(mode); }
    213222    uint64 Flags() const { return B_LENDIAN_TO_HOST_INT64(flags); }
    214223    uint64 Sequence() const { return B_LENDIAN_TO_HOST_INT64(sequence); }
    215     static void _DecodeTime(struct timespec &timespec,
    216         const struct btrfs_timespec &time)
     224    static void _DecodeTime(struct timespec& timespec,
     225        const struct btrfs_timespec& time)
    217226    {
    218227        timespec.tv_sec = B_LENDIAN_TO_HOST_INT64(time.seconds);
    219228        timespec.tv_nsec = B_LENDIAN_TO_HOST_INT32(time.nanoseconds);
    220229    }
    221     void GetAccessTime(struct timespec &timespec) const
     230    void GetAccessTime(struct timespec& timespec) const
    222231        { _DecodeTime(timespec, access_time); }
    223     void GetChangeTime(struct timespec &timespec) const
     232    void GetChangeTime(struct timespec& timespec) const
    224233        { _DecodeTime(timespec, change_time); }
    225     void GetModificationTime(struct timespec &timespec) const
     234    void GetModificationTime(struct timespec& timespec) const
    226235        { _DecodeTime(timespec, modification_time); }
    227     void GetCreationTime(struct timespec &timespec) const
     236    void GetCreationTime(struct timespec& timespec) const
    228237        { _DecodeTime(timespec, creation_time); }
    229238} _PACKED;
    230239
     240
    231241struct btrfs_root {
    232242    btrfs_inode inode;
    233243    uint64  generation;
    struct btrfs_root {  
    241251    btrfs_key drop_progress;
    242252    uint8   drop_level;
    243253    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); }
    246256    uint64 BlockNum() const { return B_LENDIAN_TO_HOST_INT64(blocknum); }
    247257} _PACKED;
    248258
     259
    249260struct btrfs_dir_entry {
    250261    btrfs_key location;
    251262    uint64  transaction_id;
    struct btrfs_dir_entry {  
    259270        { return sizeof(*this) + NameLength() + DataLength(); }
    260271} _PACKED;
    261272
     273
    262274struct btrfs_extent_data {
    263275    uint64  generation;
    264276    uint64  memory_size;
    struct btrfs_extent_data {  
    275287        };
    276288        uint8 inline_data[0];
    277289    };
    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); }
    282294    uint8 Compression() const { return compression; }
    283295    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); }
    292304} _PACKED;
    293305
    294306
    struct file_cookie {  
    326338    int         open_mode;
    327339};
    328340
     341
    329342#define BTRFS_OPEN_MODE_USER_MASK       0x7fffffff
    330343
    331344extern fs_volume_ops gBtrfsVolumeOps;
    332345extern fs_vnode_ops gBtrfsVnodeOps;
    333346
     347
    334348#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  
    77
    88/*! \file crc_table.cpp
    99
    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.
    1512
    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
    1717*/
    1818
     19
    1920#include <stdio.h>
    2021#include <sys/types.h>
    2122
     23
    2224typedef unsigned int uint32 ;
    2325
    2426uint32
    reflect32 (uint32 b)  
    3638
    3739
    3840int
    39 main(int argc, char *argv[]) {
    40         uint32 crc, poly;
     41main(int argc, char* argv[]) {
     42    uint32 crc, poly;
    4143
    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);
    4650
    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        }
    6163        crc = reflect32(crc);
    62                 printf("0x%08x%s ", crc, (n != 255 ? "," : ""));
    63                 if (n%8 == 7)
    64                         printf("\n");
    65         }
    66         printf("};\n");
    67         return 0;
     64        printf("0x%08x%s ", crc, (n != 255 ? "," : ""));
     65        if (n % 8 == 7)
     66            printf("\n");
     67    }
     68    printf("};\n");
     69    return 0;
    6870}
  • 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,  
    6868
    6969
    7070static float
    71 btrfs_identify_partition(int fd, partition_data *partition, void **_cookie)
     71btrfs_identify_partition(int fd, partition_data* partition, void** _cookie)
    7272{
    7373    btrfs_super_block superBlock;
    7474    status_t status = Volume::Identify(fd, &superBlock);
    7575    if (status != B_OK)
    7676        return -1;
    7777
    78     identify_cookie *cookie = new identify_cookie;
     78    identify_cookie* cookie = new identify_cookie;
    7979    memcpy(&cookie->super_block, &superBlock, sizeof(btrfs_super_block));
    8080
    8181    *_cookie = cookie;
    btrfs_identify_partition(int fd, partition_data *partition, void **_cookie)  
    8484
    8585
    8686static status_t
    87 btrfs_scan_partition(int fd, partition_data *partition, void *_cookie)
     87btrfs_scan_partition(int fd, partition_data* partition, void* _cookie)
    8888{
    89     identify_cookie *cookie = (identify_cookie *)_cookie;
     89    identify_cookie* cookie = (identify_cookie*)_cookie;
    9090
    9191    partition->status = B_PARTITION_VALID;
    9292    partition->flags |= B_PARTITION_FILE_SYSTEM;
    btrfs_mount(fs_volume* _volume, const char* device, uint32 flags,  
    138138
    139139
    140140static status_t
    141 btrfs_unmount(fs_volume *_volume)
     141btrfs_unmount(fs_volume* _volume)
    142142{
    143     Volume* volume = (Volume *)_volume->private_volume;
     143    Volume* volume = (Volume*)_volume->private_volume;
    144144
    145145    status_t status = volume->Unmount();
    146146    delete volume;
    btrfs_read(fs_volume* _volume, fs_vnode* _node, void* _cookie, off_t pos,  
    452452
    453453
    454454static status_t
    455 btrfs_close(fs_volume *_volume, fs_vnode *_node, void *_cookie)
     455btrfs_close(fs_volume* _volume, fs_vnode* _node, void* _cookie)
    456456{
    457457    return B_OK;
    458458}
    btrfs_access(fs_volume* _volume, fs_vnode* _node, int accessMode)  
    482482
    483483
    484484static status_t
    485 btrfs_read_link(fs_volume *_volume, fs_vnode *_node, char *buffer,
    486     size_t *_bufferSize)
     485btrfs_read_link(fs_volume* _volume, fs_vnode* _node, char* buffer,
     486    size_t* _bufferSize)
    487487{
    488488    Inode* inode = (Inode*)_node->private_node;
    489489    return inode->ReadAt(0, (uint8*)buffer, _bufferSize);
    btrfs_open_dir(fs_volume* /*_volume*/, fs_vnode* _node, void** _cookie)  
    516516
    517517
    518518static status_t
    519 btrfs_read_dir(fs_volume *_volume, fs_vnode *_node, void *_cookie,
    520     struct dirent *dirent, size_t bufferSize, uint32 *_num)
     519btrfs_read_dir(fs_volume* _volume, fs_vnode* _node, void* _cookie,
     520    struct dirent* dirent, size_t bufferSize, uint32* _num)
    521521{
    522522    DirectoryIterator* iterator = (DirectoryIterator*)_cookie;
    523523    Volume* volume = (Volume*)_volume->private_volume;
    btrfs_read_dir(fs_volume *_volume, fs_vnode *_node, void *_cookie,  
    560560
    561561
    562562static status_t
    563 btrfs_rewind_dir(fs_volume * /*_volume*/, fs_vnode * /*node*/, void *_cookie)
     563btrfs_rewind_dir(fs_volume* /*_volume*/, fs_vnode* /*node*/, void* _cookie)
    564564{
    565565    DirectoryIterator* iterator = (DirectoryIterator*)_cookie;
    566566
    btrfs_close_dir(fs_volume * /*_volume*/, fs_vnode * /*node*/, void * /*_cookie*/  
    576576
    577577
    578578static status_t
    579 btrfs_free_dir_cookie(fs_volume *_volume, fs_vnode *_node, void *_cookie)
     579btrfs_free_dir_cookie(fs_volume* _volume, fs_vnode* _node, void* _cookie)
    580580{
    581581    delete (DirectoryIterator*)_cookie;
    582582    return B_OK;
    btrfs_free_dir_cookie(fs_volume *_volume, fs_vnode *_node, void *_cookie)  
    584584
    585585
    586586static status_t
    587 btrfs_open_attr_dir(fs_volume *_volume, fs_vnode *_node, void **_cookie)
     587btrfs_open_attr_dir(fs_volume* _volume, fs_vnode* _node, void** _cookie)
    588588{
    589589    Inode* inode = (Inode*)_node->private_node;
    590590    TRACE("%s()\n", __FUNCTION__);
    btrfs_write_attr(fs_volume* _volume, fs_vnode* _node, void* cookie,  
    716716}
    717717
    718718
    719 
    720719static status_t
    721720btrfs_read_attr_stat(fs_volume* _volume, fs_vnode* _node,
    722721    void* _cookie, struct stat* stat)
    static file_system_module_info sBtrfsFileSystem = {  
    859858};
    860859
    861860
    862 module_info *modules[] = {
    863     (module_info *)&sBtrfsFileSystem,
     861module_info* modules[] = {
     862    (module_info*)&sBtrfsFileSystem,
    864863    NULL,
    865864};