BTRFS: Implement Insert() in Inode that inserts inode_item.
Signed-off-by: Augustin Cavalier <[email protected]>
This commit is contained in:
@@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "Inode.h"
|
#include "Inode.h"
|
||||||
#include "BTree.h"
|
|
||||||
#include "CachedBlock.h"
|
#include "CachedBlock.h"
|
||||||
#include "Utility.h"
|
#include "Utility.h"
|
||||||
|
|
||||||
@@ -372,3 +371,26 @@ Inode::FindParent(ino_t* id)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Insert inode_item
|
||||||
|
*/
|
||||||
|
status_t
|
||||||
|
Inode::Insert(Transaction& transaction, BTree::Path* path)
|
||||||
|
{
|
||||||
|
BTree* tree = path->Tree();
|
||||||
|
|
||||||
|
btrfs_entry item;
|
||||||
|
item.key.SetObjectID(fID);
|
||||||
|
item.key.SetType(BTRFS_KEY_TYPE_INODE_ITEM);
|
||||||
|
item.key.SetOffset(0);
|
||||||
|
item.SetSize(sizeof(btrfs_inode));
|
||||||
|
|
||||||
|
void* data[1];
|
||||||
|
data[0] = (void*)&fNode;
|
||||||
|
status_t status = tree->InsertEntries(transaction, path, &item, data, 1);
|
||||||
|
if (status != B_OK)
|
||||||
|
return status;
|
||||||
|
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include "btrfs.h"
|
#include "btrfs.h"
|
||||||
#include "Volume.h"
|
#include "Volume.h"
|
||||||
#include "Journal.h"
|
#include "Journal.h"
|
||||||
|
#include "BTree.h"
|
||||||
|
|
||||||
|
|
||||||
//#define TRACE_BTRFS
|
//#define TRACE_BTRFS
|
||||||
@@ -70,6 +71,7 @@ public:
|
|||||||
static Inode* Create(Transaction& transaction, ino_t id,
|
static Inode* Create(Transaction& transaction, ino_t id,
|
||||||
Inode* parent, int32 mode, uint64 size = 0,
|
Inode* parent, int32 mode, uint64 size = 0,
|
||||||
uint64 flags = 0);
|
uint64 flags = 0);
|
||||||
|
status_t Insert(Transaction& transaction, BTree::Path* path);
|
||||||
private:
|
private:
|
||||||
Inode(Volume* volume);
|
Inode(Volume* volume);
|
||||||
Inode(const Inode&);
|
Inode(const Inode&);
|
||||||
|
|||||||
@@ -145,6 +145,7 @@ struct btrfs_entry {
|
|||||||
uint32 Size() const
|
uint32 Size() const
|
||||||
{ return B_LENDIAN_TO_HOST_INT32(size); }
|
{ return B_LENDIAN_TO_HOST_INT32(size); }
|
||||||
void SetOffset(uint32 off) { offset = B_HOST_TO_LENDIAN_INT32(off); }
|
void SetOffset(uint32 off) { offset = B_HOST_TO_LENDIAN_INT32(off); }
|
||||||
|
void SetSize(uint32 itemSize) { size = B_HOST_TO_LENDIAN_INT32(itemSize); }
|
||||||
} _PACKED;
|
} _PACKED;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user