BTRFS: code cleanups
* Removed struct keyword for declaring variable. * Renamed BPlusTree to BTree because BtrFS use a variant of BTree not B+Tree. Signed-off-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
This commit is contained in:
parent
b24d4c8a32
commit
299aba38f0
@ -9,7 +9,7 @@
|
||||
|
||||
|
||||
#include "Attribute.h"
|
||||
#include "BPlusTree.h"
|
||||
#include "BTree.h"
|
||||
#include "CRCTable.h"
|
||||
#include "Utility.h"
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
#define ATTRIBUTEITERATOR_H
|
||||
|
||||
|
||||
#include "BPlusTree.h"
|
||||
#include "BTree.h"
|
||||
#include "Inode.h"
|
||||
|
||||
|
||||
|
@ -1,134 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011, Jérôme Duval, korli@users.berlios.de.
|
||||
* Copyright 2001-2010, Axel Dörfler, axeld@pinc-software.de.
|
||||
* This file may be used under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef B_PLUS_TREE_H
|
||||
#define B_PLUS_TREE_H
|
||||
|
||||
|
||||
#include "btrfs.h"
|
||||
#include "Volume.h"
|
||||
|
||||
|
||||
#define BPLUSTREE_NULL -1LL
|
||||
#define BPLUSTREE_FREE -2LL
|
||||
|
||||
|
||||
enum bplustree_traversing {
|
||||
BPLUSTREE_FORWARD = 1,
|
||||
BPLUSTREE_EXACT = 0,
|
||||
BPLUSTREE_BACKWARD = -1,
|
||||
|
||||
BPLUSTREE_BEGIN = 0,
|
||||
BPLUSTREE_END = -1
|
||||
};
|
||||
|
||||
|
||||
// #pragma mark - in-memory structures
|
||||
|
||||
|
||||
template<class T> class Stack;
|
||||
class TreeIterator;
|
||||
|
||||
|
||||
// needed for searching (utilizing a stack)
|
||||
struct node_and_key {
|
||||
off_t nodeOffset;
|
||||
uint16 keyIndex;
|
||||
};
|
||||
|
||||
|
||||
class BPlusTree {
|
||||
public:
|
||||
BPlusTree(Volume* volume,
|
||||
struct btrfs_stream* stream);
|
||||
BPlusTree(Volume* volume,
|
||||
fsblock_t rootBlock);
|
||||
~BPlusTree();
|
||||
status_t FindExact(struct btrfs_key& key, void** value,
|
||||
size_t* size = NULL);
|
||||
status_t FindNext(struct btrfs_key& key, void** value,
|
||||
size_t* size = NULL);
|
||||
status_t FindPrevious(struct btrfs_key& key, void** value,
|
||||
size_t* size = NULL);
|
||||
|
||||
private:
|
||||
BPlusTree(const BPlusTree& other);
|
||||
BPlusTree& operator=(const BPlusTree& other);
|
||||
// no implementation
|
||||
|
||||
int32 _CompareKeys(struct btrfs_key& key1,
|
||||
struct btrfs_key& key2);
|
||||
status_t _Find(struct btrfs_key& key, void** value,
|
||||
size_t* size, bplustree_traversing type);
|
||||
void _AddIterator(TreeIterator* iterator);
|
||||
void _RemoveIterator(TreeIterator* iterator);
|
||||
private:
|
||||
friend class TreeIterator;
|
||||
|
||||
struct btrfs_stream* fStream;
|
||||
fsblock_t fRootBlock;
|
||||
Volume* fVolume;
|
||||
mutex fIteratorLock;
|
||||
SinglyLinkedList<TreeIterator> fIterators;
|
||||
};
|
||||
|
||||
|
||||
class TreeIterator : public SinglyLinkedListLinkImpl<TreeIterator> {
|
||||
public:
|
||||
TreeIterator(BPlusTree* tree, struct btrfs_key& key);
|
||||
~TreeIterator();
|
||||
|
||||
status_t Traverse(bplustree_traversing direction,
|
||||
struct btrfs_key& key, void** value,
|
||||
size_t* size = NULL);
|
||||
status_t Find(struct btrfs_key& key);
|
||||
|
||||
status_t Rewind();
|
||||
status_t GetNextEntry(struct btrfs_key& key, void** value,
|
||||
size_t* size = NULL);
|
||||
status_t GetPreviousEntry(struct btrfs_key& key, void** value,
|
||||
size_t* size = NULL);
|
||||
|
||||
BPlusTree* Tree() const { return fTree; }
|
||||
|
||||
private:
|
||||
friend class BPlusTree;
|
||||
|
||||
// called by BPlusTree
|
||||
void Stop();
|
||||
|
||||
private:
|
||||
BPlusTree* fTree;
|
||||
struct btrfs_key fCurrentKey;
|
||||
};
|
||||
|
||||
|
||||
// #pragma mark - TreeIterator inline functions
|
||||
|
||||
|
||||
inline status_t
|
||||
TreeIterator::Rewind()
|
||||
{
|
||||
fCurrentKey.SetOffset(BPLUSTREE_BEGIN);
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
inline status_t
|
||||
TreeIterator::GetNextEntry(struct btrfs_key& key, void** value, size_t* size)
|
||||
{
|
||||
return Traverse(BPLUSTREE_FORWARD, key, value, size);
|
||||
}
|
||||
|
||||
|
||||
inline status_t
|
||||
TreeIterator::GetPreviousEntry(struct btrfs_key& key, void** value,
|
||||
size_t* size)
|
||||
{
|
||||
return Traverse(BPLUSTREE_BACKWARD, key, value, size);
|
||||
}
|
||||
|
||||
|
||||
#endif // B_PLUS_TREE_H
|
@ -5,10 +5,10 @@
|
||||
*/
|
||||
|
||||
|
||||
//! B+Tree implementation
|
||||
//! BTree implementation
|
||||
|
||||
|
||||
#include "BPlusTree.h"
|
||||
#include "BTree.h"
|
||||
#include "CachedBlock.h"
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
# define ERROR(x...) dprintf("\33[34mbtrfs:\33[0m " x)
|
||||
|
||||
|
||||
BPlusTree::BPlusTree(Volume* volume, struct btrfs_stream* stream)
|
||||
BTree::BTree(Volume* volume, btrfs_stream* stream)
|
||||
:
|
||||
fStream(stream),
|
||||
fRootBlock(0),
|
||||
@ -31,7 +31,7 @@ BPlusTree::BPlusTree(Volume* volume, struct btrfs_stream* stream)
|
||||
}
|
||||
|
||||
|
||||
BPlusTree::BPlusTree(Volume* volume, fsblock_t rootBlock)
|
||||
BTree::BTree(Volume* volume, fsblock_t rootBlock)
|
||||
:
|
||||
fStream(NULL),
|
||||
fRootBlock(rootBlock),
|
||||
@ -41,7 +41,7 @@ BPlusTree::BPlusTree(Volume* volume, fsblock_t rootBlock)
|
||||
}
|
||||
|
||||
|
||||
BPlusTree::~BPlusTree()
|
||||
BTree::~BTree()
|
||||
{
|
||||
// if there are any TreeIterators left, we need to stop them
|
||||
// (can happen when the tree's inode gets deleted while
|
||||
@ -57,7 +57,7 @@ BPlusTree::~BPlusTree()
|
||||
|
||||
|
||||
int32
|
||||
BPlusTree::_CompareKeys(struct btrfs_key& key1, struct btrfs_key& key2)
|
||||
BTree::_CompareKeys(btrfs_key& key1, btrfs_key& key2)
|
||||
{
|
||||
if (key1.ObjectID() > key2.ObjectID())
|
||||
return 1;
|
||||
@ -81,8 +81,8 @@ BPlusTree::_CompareKeys(struct btrfs_key& key1, struct btrfs_key& key2)
|
||||
It can also return other errors to indicate that something went wrong.
|
||||
*/
|
||||
status_t
|
||||
BPlusTree::_Find(struct btrfs_key& key, void** _value, size_t* _size,
|
||||
bplustree_traversing type)
|
||||
BTree::_Find(btrfs_key& key, void** _value, size_t* _size,
|
||||
btree_traversing type)
|
||||
{
|
||||
TRACE("Find() objectid %" B_PRId64 " type %d offset %" B_PRId64 " \n",
|
||||
key.ObjectID(), key.Type(), key.Offset());
|
||||
@ -106,7 +106,7 @@ BPlusTree::_Find(struct btrfs_key& key, void** _value, size_t* _size,
|
||||
B_PRId32 "\n", i, stream->index[i].BlockNum(), comp);
|
||||
if (comp < 0)
|
||||
continue;
|
||||
if (comp > 0 || type == BPLUSTREE_BACKWARD)
|
||||
if (comp > 0 || type == BTREE_BACKWARD)
|
||||
break;
|
||||
}
|
||||
TRACE("Find() getting index %" B_PRIu32 " at %" B_PRId64 "\n", i - 1,
|
||||
@ -142,16 +142,16 @@ BPlusTree::_Find(struct btrfs_key& key, void** _value, size_t* _size,
|
||||
if (comp == 0)
|
||||
break;
|
||||
if (comp < 0 && i > 0) {
|
||||
if (type == BPLUSTREE_EXACT)
|
||||
if (type == BTREE_EXACT)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
if (type == BPLUSTREE_BACKWARD)
|
||||
if (type == BTREE_BACKWARD)
|
||||
i--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == stream->header.ItemCount()) {
|
||||
if (type == BPLUSTREE_BACKWARD)
|
||||
if (type == BTREE_BACKWARD)
|
||||
i--;
|
||||
else
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
@ -196,28 +196,28 @@ BPlusTree::_Find(struct btrfs_key& key, void** _value, size_t* _size,
|
||||
|
||||
|
||||
status_t
|
||||
BPlusTree::FindNext(struct btrfs_key& key, void** _value, size_t* _size)
|
||||
BTree::FindNext(btrfs_key& key, void** _value, size_t* _size)
|
||||
{
|
||||
return _Find(key, _value, _size, BPLUSTREE_FORWARD);
|
||||
return _Find(key, _value, _size, BTREE_FORWARD);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BPlusTree::FindPrevious(struct btrfs_key& key, void** _value, size_t* _size)
|
||||
BTree::FindPrevious(btrfs_key& key, void** _value, size_t* _size)
|
||||
{
|
||||
return _Find(key, _value, _size, BPLUSTREE_BACKWARD);
|
||||
return _Find(key, _value, _size, BTREE_BACKWARD);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BPlusTree::FindExact(struct btrfs_key& key, void** _value, size_t* _size)
|
||||
BTree::FindExact(btrfs_key& key, void** _value, size_t* _size)
|
||||
{
|
||||
return _Find(key, _value, _size, BPLUSTREE_EXACT);
|
||||
return _Find(key, _value, _size, BTREE_EXACT);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BPlusTree::_AddIterator(TreeIterator* iterator)
|
||||
BTree::_AddIterator(TreeIterator* iterator)
|
||||
{
|
||||
MutexLocker _(fIteratorLock);
|
||||
fIterators.Add(iterator);
|
||||
@ -225,7 +225,7 @@ BPlusTree::_AddIterator(TreeIterator* iterator)
|
||||
|
||||
|
||||
void
|
||||
BPlusTree::_RemoveIterator(TreeIterator* iterator)
|
||||
BTree::_RemoveIterator(TreeIterator* iterator)
|
||||
{
|
||||
MutexLocker _(fIteratorLock);
|
||||
fIterators.Remove(iterator);
|
||||
@ -235,7 +235,7 @@ BPlusTree::_RemoveIterator(TreeIterator* iterator)
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
TreeIterator::TreeIterator(BPlusTree* tree, struct btrfs_key& key)
|
||||
TreeIterator::TreeIterator(BTree* tree, btrfs_key& key)
|
||||
:
|
||||
fTree(tree),
|
||||
fCurrentKey(key)
|
||||
@ -255,7 +255,7 @@ TreeIterator::~TreeIterator()
|
||||
/*! Iterates through the tree in the specified direction.
|
||||
*/
|
||||
status_t
|
||||
TreeIterator::Traverse(bplustree_traversing direction, struct btrfs_key& key,
|
||||
TreeIterator::Traverse(btree_traversing direction, btrfs_key& key,
|
||||
void** value, size_t* size)
|
||||
{
|
||||
if (fTree == NULL)
|
||||
@ -276,7 +276,7 @@ TreeIterator::Traverse(bplustree_traversing direction, struct btrfs_key& key,
|
||||
/*! just sets the current key in the iterator.
|
||||
*/
|
||||
status_t
|
||||
TreeIterator::Find(struct btrfs_key& key)
|
||||
TreeIterator::Find(btrfs_key& key)
|
||||
{
|
||||
if (fTree == NULL)
|
||||
return B_INTERRUPTED;
|
134
src/add-ons/kernel/file_systems/btrfs/BTree.h
Normal file
134
src/add-ons/kernel/file_systems/btrfs/BTree.h
Normal file
@ -0,0 +1,134 @@
|
||||
/*
|
||||
* Copyright 2011, Jérôme Duval, korli@users.berlios.de.
|
||||
* Copyright 2001-2010, Axel Dörfler, axeld@pinc-software.de.
|
||||
* This file may be used under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef B_PLUS_TREE_H
|
||||
#define B_PLUS_TREE_H
|
||||
|
||||
|
||||
#include "btrfs.h"
|
||||
#include "Volume.h"
|
||||
|
||||
|
||||
#define BTREE_NULL -1LL
|
||||
#define BTREE_FREE -2LL
|
||||
|
||||
|
||||
enum btree_traversing {
|
||||
BTREE_FORWARD = 1,
|
||||
BTREE_EXACT = 0,
|
||||
BTREE_BACKWARD = -1,
|
||||
|
||||
BTREE_BEGIN = 0,
|
||||
BTREE_END = -1
|
||||
};
|
||||
|
||||
|
||||
// #pragma mark - in-memory structures
|
||||
|
||||
|
||||
template<class T> class Stack;
|
||||
class TreeIterator;
|
||||
|
||||
|
||||
// needed for searching (utilizing a stack)
|
||||
struct node_and_key {
|
||||
off_t nodeOffset;
|
||||
uint16 keyIndex;
|
||||
};
|
||||
|
||||
|
||||
class BTree {
|
||||
public:
|
||||
BTree(Volume* volume,
|
||||
btrfs_stream* stream);
|
||||
BTree(Volume* volume,
|
||||
fsblock_t rootBlock);
|
||||
~BTree();
|
||||
status_t FindExact(btrfs_key& key, void** value,
|
||||
size_t* size = NULL);
|
||||
status_t FindNext(btrfs_key& key, void** value,
|
||||
size_t* size = NULL);
|
||||
status_t FindPrevious(btrfs_key& key, void** value,
|
||||
size_t* size = NULL);
|
||||
|
||||
private:
|
||||
BTree(const BTree& other);
|
||||
BTree& operator=(const BTree& other);
|
||||
// no implementation
|
||||
|
||||
int32 _CompareKeys(btrfs_key& key1,
|
||||
btrfs_key& key2);
|
||||
status_t _Find(btrfs_key& key, void** value,
|
||||
size_t* size, btree_traversing type);
|
||||
void _AddIterator(TreeIterator* iterator);
|
||||
void _RemoveIterator(TreeIterator* iterator);
|
||||
private:
|
||||
friend class TreeIterator;
|
||||
|
||||
btrfs_stream* fStream;
|
||||
fsblock_t fRootBlock;
|
||||
Volume* fVolume;
|
||||
mutex fIteratorLock;
|
||||
SinglyLinkedList<TreeIterator> fIterators;
|
||||
};
|
||||
|
||||
|
||||
class TreeIterator : public SinglyLinkedListLinkImpl<TreeIterator> {
|
||||
public:
|
||||
TreeIterator(BTree* tree, btrfs_key& key);
|
||||
~TreeIterator();
|
||||
|
||||
status_t Traverse(btree_traversing direction,
|
||||
btrfs_key& key, void** value,
|
||||
size_t* size = NULL);
|
||||
status_t Find(btrfs_key& key);
|
||||
|
||||
status_t Rewind();
|
||||
status_t GetNextEntry(btrfs_key& key, void** value,
|
||||
size_t* size = NULL);
|
||||
status_t GetPreviousEntry(btrfs_key& key, void** value,
|
||||
size_t* size = NULL);
|
||||
|
||||
BTree* Tree() const { return fTree; }
|
||||
|
||||
private:
|
||||
friend class BTree;
|
||||
|
||||
// called by BTree
|
||||
void Stop();
|
||||
|
||||
private:
|
||||
BTree* fTree;
|
||||
btrfs_key fCurrentKey;
|
||||
};
|
||||
|
||||
|
||||
// #pragma mark - TreeIterator inline functions
|
||||
|
||||
|
||||
inline status_t
|
||||
TreeIterator::Rewind()
|
||||
{
|
||||
fCurrentKey.SetOffset(BTREE_BEGIN);
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
inline status_t
|
||||
TreeIterator::GetNextEntry(btrfs_key& key, void** value, size_t* size)
|
||||
{
|
||||
return Traverse(BTREE_FORWARD, key, value, size);
|
||||
}
|
||||
|
||||
|
||||
inline status_t
|
||||
TreeIterator::GetPreviousEntry(btrfs_key& key, void** value,
|
||||
size_t* size)
|
||||
{
|
||||
return Traverse(BTREE_BACKWARD, key, value, size);
|
||||
}
|
||||
|
||||
|
||||
#endif // B_PLUS_TREE_H
|
@ -19,21 +19,21 @@
|
||||
# define FATAL(x...) dprintf("\33[34mbtrfs:\33[0m " x)
|
||||
|
||||
|
||||
Chunk::Chunk(struct btrfs_chunk* chunk, fsblock_t offset)
|
||||
Chunk::Chunk(btrfs_chunk* chunk, fsblock_t offset)
|
||||
:
|
||||
fChunk(NULL),
|
||||
fInitStatus(B_OK)
|
||||
{
|
||||
fChunkOffset = offset;
|
||||
fChunk = (struct btrfs_chunk*)malloc(sizeof(struct btrfs_chunk)
|
||||
+ chunk->StripeCount() * sizeof(struct btrfs_stripe));
|
||||
fChunk = (btrfs_chunk*)malloc(sizeof(btrfs_chunk)
|
||||
+ chunk->StripeCount() * sizeof(btrfs_stripe));
|
||||
if (fChunk == NULL) {
|
||||
fInitStatus = B_NO_MEMORY;
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(fChunk, chunk, sizeof(struct btrfs_chunk)
|
||||
+ chunk->StripeCount() * sizeof(struct btrfs_stripe));
|
||||
memcpy(fChunk, chunk, sizeof(btrfs_chunk)
|
||||
+ chunk->StripeCount() * sizeof(btrfs_stripe));
|
||||
|
||||
TRACE("chunk[0] length %" B_PRIu64 " owner %" B_PRIu64 " stripe_length %"
|
||||
B_PRIu64 " type %" B_PRIu64 " stripe_count %u sub_stripes %u "
|
||||
@ -57,8 +57,8 @@ Chunk::~Chunk()
|
||||
uint32
|
||||
Chunk::Size() const
|
||||
{
|
||||
return sizeof(struct btrfs_chunk)
|
||||
+ fChunk->StripeCount() * sizeof(struct btrfs_stripe);
|
||||
return sizeof(btrfs_chunk)
|
||||
+ fChunk->StripeCount() * sizeof(btrfs_stripe);
|
||||
}
|
||||
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
class Chunk {
|
||||
public:
|
||||
Chunk(struct btrfs_chunk* chunk,
|
||||
Chunk(btrfs_chunk* chunk,
|
||||
fsblock_t offset);
|
||||
~Chunk();
|
||||
uint32 Size() const;
|
||||
@ -23,7 +23,7 @@ public:
|
||||
fsblock_t End() const
|
||||
{ return fChunkOffset + fChunk->Length(); }
|
||||
private:
|
||||
struct btrfs_chunk* fChunk;
|
||||
btrfs_chunk* fChunk;
|
||||
fsblock_t fChunkOffset;
|
||||
status_t fInitStatus;
|
||||
};
|
||||
|
@ -23,7 +23,7 @@ DirectoryIterator::DirectoryIterator(Inode* inode)
|
||||
fInode(inode),
|
||||
fIterator(NULL)
|
||||
{
|
||||
struct btrfs_key key;
|
||||
btrfs_key key;
|
||||
key.SetType(BTRFS_KEY_TYPE_DIR_INDEX);
|
||||
key.SetObjectID(inode->ID());
|
||||
fIterator = new(std::nothrow) TreeIterator(inode->GetVolume()->FSTree(),
|
||||
@ -118,7 +118,7 @@ DirectoryIterator::Lookup(const char* name, size_t nameLength, ino_t* _id)
|
||||
}
|
||||
|
||||
uint32 hash = calculate_crc((uint32)~1, (uint8*)name, nameLength);
|
||||
struct btrfs_key key;
|
||||
btrfs_key key;
|
||||
key.SetType(BTRFS_KEY_TYPE_DIR_ITEM);
|
||||
key.SetObjectID(fInode->ID());
|
||||
key.SetOffset(hash);
|
||||
@ -156,7 +156,7 @@ status_t
|
||||
DirectoryIterator::Rewind()
|
||||
{
|
||||
fIterator->Rewind();
|
||||
fOffset = BPLUSTREE_BEGIN;
|
||||
fOffset = BTREE_BEGIN;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
#define DIRECTORYITERATOR_H
|
||||
|
||||
|
||||
#include "BPlusTree.h"
|
||||
#include "BTree.h"
|
||||
#include "Inode.h"
|
||||
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
|
||||
#include "Inode.h"
|
||||
#include "BPlusTree.h"
|
||||
#include "BTree.h"
|
||||
#include "CachedBlock.h"
|
||||
#include "Utility.h"
|
||||
|
||||
@ -74,19 +74,19 @@ Inode::InitCheck()
|
||||
status_t
|
||||
Inode::UpdateNodeFromDisk()
|
||||
{
|
||||
struct btrfs_key search_key;
|
||||
btrfs_key search_key;
|
||||
search_key.SetType(BTRFS_KEY_TYPE_INODE_ITEM);
|
||||
search_key.SetObjectID(fID);
|
||||
search_key.SetOffset(0);
|
||||
|
||||
struct btrfs_inode* node;
|
||||
btrfs_inode* node;
|
||||
if (fVolume->FSTree()->FindExact(search_key, (void**)&node) != B_OK) {
|
||||
ERROR("Inode::UpdateNodeFromDisk(): Couldn't find inode %"
|
||||
B_PRIdINO "\n", fID);
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
}
|
||||
|
||||
memcpy(&fNode, node, sizeof(struct btrfs_inode));
|
||||
memcpy(&fNode, node, sizeof(btrfs_inode));
|
||||
free(node);
|
||||
return B_OK;
|
||||
}
|
||||
@ -107,7 +107,7 @@ Inode::CheckPermissions(int accessMode) const
|
||||
status_t
|
||||
Inode::FindBlock(off_t pos, off_t& physical, off_t* _length)
|
||||
{
|
||||
struct btrfs_key search_key;
|
||||
btrfs_key search_key;
|
||||
search_key.SetType(BTRFS_KEY_TYPE_EXTENT_DATA);
|
||||
search_key.SetObjectID(fID);
|
||||
search_key.SetOffset(pos + 1);
|
||||
@ -162,7 +162,7 @@ Inode::ReadAt(off_t pos, uint8* buffer, size_t* _length)
|
||||
|
||||
// the file cache doesn't seem to like non block aligned file offset
|
||||
// so we avoid the file cache for inline extents
|
||||
struct btrfs_key search_key;
|
||||
btrfs_key search_key;
|
||||
search_key.SetType(BTRFS_KEY_TYPE_EXTENT_DATA);
|
||||
search_key.SetObjectID(fID);
|
||||
search_key.SetOffset(pos + 1);
|
||||
@ -288,7 +288,7 @@ Inode::ReadAt(off_t pos, uint8* buffer, size_t* _length)
|
||||
status_t
|
||||
Inode::FindParent(ino_t* id)
|
||||
{
|
||||
struct btrfs_key search_key;
|
||||
btrfs_key search_key;
|
||||
search_key.SetType(BTRFS_KEY_TYPE_INODE_REF);
|
||||
search_key.SetObjectID(fID);
|
||||
search_key.SetOffset(-1);
|
||||
|
@ -78,7 +78,7 @@ private:
|
||||
void* fCache;
|
||||
void* fMap;
|
||||
status_t fInitStatus;
|
||||
struct btrfs_inode fNode;
|
||||
btrfs_inode fNode;
|
||||
};
|
||||
|
||||
|
||||
|
@ -12,7 +12,7 @@ KernelAddon btrfs :
|
||||
kernel_interface.cpp
|
||||
Attribute.cpp
|
||||
AttributeIterator.cpp
|
||||
BPlusTree.cpp
|
||||
BTree.cpp
|
||||
Chunk.cpp
|
||||
CRCTable.cpp
|
||||
DirectoryIterator.cpp
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
|
||||
#include "Volume.h"
|
||||
#include "BPlusTree.h"
|
||||
#include "BTree.h"
|
||||
#include "CachedBlock.h"
|
||||
#include "Chunk.h"
|
||||
#include "Inode.h"
|
||||
@ -271,19 +271,19 @@ Volume::Mount(const char* deviceName, uint32 flags)
|
||||
uint8* start = (uint8*)&fSuperBlock.system_chunk_array[0];
|
||||
uint8* end = (uint8*)&fSuperBlock.system_chunk_array[2048];
|
||||
while (start < end) {
|
||||
struct btrfs_key* key = (struct btrfs_key*)start;
|
||||
btrfs_key* key = (btrfs_key*)start;
|
||||
TRACE("system_chunk_array object_id 0x%" B_PRIx64 " offset 0x%"
|
||||
B_PRIx64 " type 0x%x\n", key->ObjectID(), key->Offset(),
|
||||
key->Type());
|
||||
if (key->Type() != BTRFS_KEY_TYPE_CHUNK_ITEM) {
|
||||
break;
|
||||
}
|
||||
|
||||
struct btrfs_chunk* chunk = (struct btrfs_chunk*)(key + 1);
|
||||
|
||||
btrfs_chunk* chunk = (btrfs_chunk*)(key + 1);
|
||||
fChunk = new(std::nothrow) Chunk(chunk, key->Offset());
|
||||
if (fChunk == NULL)
|
||||
return B_ERROR;
|
||||
start += sizeof(struct btrfs_key) + fChunk->Size();
|
||||
start += sizeof(btrfs_key) + fChunk->Size();
|
||||
}
|
||||
|
||||
TRACE("Volume::Mount() generation: %" B_PRIu64 "\n",
|
||||
@ -314,7 +314,7 @@ Volume::Mount(const char* deviceName, uint32 flags)
|
||||
|
||||
TRACE("Volume::Mount(): Initialized block cache: %p\n", fBlockCache);
|
||||
|
||||
fChunkTree = new(std::nothrow) BPlusTree(this, fSuperBlock.ChunkRoot());
|
||||
fChunkTree = new(std::nothrow) BTree(this, fSuperBlock.ChunkRoot());
|
||||
if (fChunkTree == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
@ -328,22 +328,22 @@ Volume::Mount(const char* deviceName, uint32 flags)
|
||||
TRACE("Volume::Mount() log_root: %" B_PRIu64 " (physical %" B_PRIu64 ")\n",
|
||||
fSuperBlock.LogRoot(), physical);
|
||||
|
||||
fRootTree = new(std::nothrow) BPlusTree(this, fSuperBlock.Root());
|
||||
fRootTree = new(std::nothrow) BTree(this, fSuperBlock.Root());
|
||||
if (fRootTree == NULL)
|
||||
return B_NO_MEMORY;
|
||||
TRACE("Volume::Mount(): Searching extent root\n");
|
||||
struct btrfs_key search_key;
|
||||
btrfs_key search_key;
|
||||
search_key.SetOffset(0);
|
||||
search_key.SetType(BTRFS_KEY_TYPE_ROOT_ITEM);
|
||||
search_key.SetObjectID(BTRFS_OBJECT_ID_EXTENT_TREE);
|
||||
struct btrfs_root* root;
|
||||
btrfs_root* root;
|
||||
if (fRootTree->FindNext(search_key, (void**)&root) != B_OK) {
|
||||
ERROR("Volume::Mount(): Couldn't find extent root\n");
|
||||
return B_ERROR;
|
||||
}
|
||||
TRACE("Volume::Mount(): Found extent root: %" B_PRIu64 "\n",
|
||||
root->BlockNum());
|
||||
fExtentTree = new(std::nothrow) BPlusTree(this, root->BlockNum());
|
||||
fExtentTree = new(std::nothrow) BTree(this, root->BlockNum());
|
||||
free(root);
|
||||
if (fExtentTree == NULL)
|
||||
return B_NO_MEMORY;
|
||||
@ -355,7 +355,7 @@ Volume::Mount(const char* deviceName, uint32 flags)
|
||||
return B_ERROR;
|
||||
}
|
||||
TRACE("Volume::Mount(): Found fs root: %" B_PRIu64 "\n", root->BlockNum());
|
||||
fFSTree = new(std::nothrow) BPlusTree(this, root->BlockNum());
|
||||
fFSTree = new(std::nothrow) BTree(this, root->BlockNum());
|
||||
free(root);
|
||||
if (fFSTree == NULL)
|
||||
return B_NO_MEMORY;
|
||||
@ -368,7 +368,7 @@ Volume::Mount(const char* deviceName, uint32 flags)
|
||||
}
|
||||
TRACE("Volume::Mount(): Found dev root: %" B_PRIu64 "\n",
|
||||
root->BlockNum());
|
||||
fDevTree = new(std::nothrow) BPlusTree(this, root->BlockNum());
|
||||
fDevTree = new(std::nothrow) BTree(this, root->BlockNum());
|
||||
free(root);
|
||||
if (fDevTree == NULL)
|
||||
return B_NO_MEMORY;
|
||||
@ -381,7 +381,7 @@ Volume::Mount(const char* deviceName, uint32 flags)
|
||||
}
|
||||
TRACE("Volume::Mount(): Found checksum root: %" B_PRIu64 "\n",
|
||||
root->BlockNum());
|
||||
fChecksumTree = new(std::nothrow) BPlusTree(this, root->BlockNum());
|
||||
fChecksumTree = new(std::nothrow) BTree(this, root->BlockNum());
|
||||
free(root);
|
||||
if (fChecksumTree == NULL)
|
||||
return B_NO_MEMORY;
|
||||
@ -487,11 +487,11 @@ Volume::FindBlock(off_t logical, off_t& physical)
|
||||
return fChunk->FindBlock(logical, physical);
|
||||
}
|
||||
|
||||
struct btrfs_key search_key;
|
||||
btrfs_key search_key;
|
||||
search_key.SetOffset(logical);
|
||||
search_key.SetType(BTRFS_KEY_TYPE_CHUNK_ITEM);
|
||||
search_key.SetObjectID(BTRFS_OBJECT_ID_CHUNK_TREE);
|
||||
struct btrfs_chunk* chunk;
|
||||
btrfs_chunk* chunk;
|
||||
size_t chunk_length;
|
||||
status_t status = fChunkTree->FindPrevious(search_key, (void**)&chunk,
|
||||
&chunk_length);
|
||||
|
@ -14,7 +14,7 @@ enum volume_flags {
|
||||
VOLUME_READ_ONLY = 0x0001
|
||||
};
|
||||
|
||||
class BPlusTree;
|
||||
class BTree;
|
||||
class Chunk;
|
||||
class Inode;
|
||||
|
||||
@ -38,8 +38,8 @@ public:
|
||||
{ return fFSVolume ? fFSVolume->id : -1; }
|
||||
fs_volume* FSVolume() const { return fFSVolume; }
|
||||
const char* Name() const;
|
||||
BPlusTree* FSTree() const { return fFSTree; }
|
||||
BPlusTree* RootTree() const { return fRootTree; }
|
||||
BTree* FSTree() const { return fFSTree; }
|
||||
BTree* RootTree() const { return fRootTree; }
|
||||
|
||||
uint32 BlockSize() const { return fBlockSize; }
|
||||
btrfs_super_block& SuperBlock() { return fSuperBlock; }
|
||||
@ -68,12 +68,12 @@ private:
|
||||
Inode* fRootNode;
|
||||
|
||||
Chunk* fChunk;
|
||||
BPlusTree* fChunkTree;
|
||||
BPlusTree* fRootTree;
|
||||
BPlusTree* fDevTree;
|
||||
BPlusTree* fExtentTree;
|
||||
BPlusTree* fFSTree;
|
||||
BPlusTree* fChecksumTree;
|
||||
BTree* fChunkTree;
|
||||
BTree* fRootTree;
|
||||
BTree* fDevTree;
|
||||
BTree* fExtentTree;
|
||||
BTree* fFSTree;
|
||||
BTree* fChecksumTree;
|
||||
};
|
||||
|
||||
|
||||
|
@ -106,7 +106,7 @@ struct btrfs_chunk {
|
||||
uint32 sector_size;
|
||||
uint16 stripe_count;
|
||||
uint16 sub_stripes;
|
||||
struct btrfs_stripe stripes[0];
|
||||
btrfs_stripe stripes[0];
|
||||
uint64 Length() const { return B_LENDIAN_TO_HOST_INT64(length); }
|
||||
uint64 Owner() const { return B_LENDIAN_TO_HOST_INT64(owner); }
|
||||
uint64 StripeLength() const
|
||||
@ -169,7 +169,7 @@ struct btrfs_super_block {
|
||||
uint8 root_level;
|
||||
uint8 chunk_root_level;
|
||||
uint8 log_root_level;
|
||||
struct btrfs_device device;
|
||||
btrfs_device device;
|
||||
char label[256];
|
||||
uint64 reserved[32];
|
||||
uint8 system_chunk_array[2048];
|
||||
@ -206,10 +206,10 @@ struct btrfs_inode {
|
||||
uint64 flags;
|
||||
uint64 sequence;
|
||||
uint64 reserved[4];
|
||||
struct btrfs_timespec access_time;
|
||||
struct btrfs_timespec change_time;
|
||||
struct btrfs_timespec modification_time;
|
||||
struct btrfs_timespec creation_time;
|
||||
btrfs_timespec access_time;
|
||||
btrfs_timespec change_time;
|
||||
btrfs_timespec modification_time;
|
||||
btrfs_timespec creation_time;
|
||||
uint64 Generation() const { return B_LENDIAN_TO_HOST_INT64(generation); }
|
||||
uint64 Size() const { return B_LENDIAN_TO_HOST_INT64(size); }
|
||||
uint32 UserID() const { return B_LENDIAN_TO_HOST_INT32(uid); }
|
||||
@ -218,7 +218,7 @@ struct btrfs_inode {
|
||||
uint64 Flags() const { return B_LENDIAN_TO_HOST_INT64(flags); }
|
||||
uint64 Sequence() const { return B_LENDIAN_TO_HOST_INT64(sequence); }
|
||||
static void _DecodeTime(struct timespec& timespec,
|
||||
const struct btrfs_timespec& time)
|
||||
const btrfs_timespec& time)
|
||||
{
|
||||
timespec.tv_sec = B_LENDIAN_TO_HOST_INT64(time.seconds);
|
||||
timespec.tv_nsec = B_LENDIAN_TO_HOST_INT32(time.nanoseconds);
|
||||
|
@ -37,7 +37,7 @@ UseHeaders [ FDirName $(HAIKU_TOP) src tools fs_shell ] ;
|
||||
local btrfsSources =
|
||||
Attribute.cpp
|
||||
AttributeIterator.cpp
|
||||
BPlusTree.cpp
|
||||
BTree.cpp
|
||||
Chunk.cpp
|
||||
CRCTable.cpp
|
||||
DirectoryIterator.cpp
|
||||
|
Loading…
Reference in New Issue
Block a user