btrfs: documented Attribute and AttributeIterator classes (no functional change)
Change-Id: I3bbd36132824df49339ceb98e811e36942714447
This commit is contained in:
committed by
Adrien Destugues
parent
9d2ab65187
commit
5bfbdf0dc8
@@ -1,4 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
|
* Copyright 2019, Bharathi Ramana Joshi, [email protected].
|
||||||
* Copyright 2017, Chế Vũ Gia Hy, [email protected].
|
* Copyright 2017, Chế Vũ Gia Hy, [email protected].
|
||||||
* Copyright 2010-2011, Jérôme Duval, [email protected].
|
* Copyright 2010-2011, Jérôme Duval, [email protected].
|
||||||
* Copyright 2004-2008, Axel Dörfler, [email protected].
|
* Copyright 2004-2008, Axel Dörfler, [email protected].
|
||||||
@@ -20,27 +21,41 @@ struct attr_cookie {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/** Attributes in btrfs use the same on-disk format as directories, in the
|
||||||
|
* XATTR_ITEM of the inode. Each attribute appears as a "file" there.
|
||||||
|
*
|
||||||
|
* Additionally, this class provides access to the non-extended attributes
|
||||||
|
* through the Stat method. These are stored dorectly in the base inode of
|
||||||
|
* the file.
|
||||||
|
*/
|
||||||
class Attribute {
|
class Attribute {
|
||||||
public:
|
public:
|
||||||
|
//! Constructs an Attribute object for the file inode
|
||||||
Attribute(Inode* inode);
|
Attribute(Inode* inode);
|
||||||
Attribute(Inode* inode, attr_cookie* cookie);
|
Attribute(Inode* inode, attr_cookie* cookie);
|
||||||
~Attribute();
|
~Attribute();
|
||||||
|
|
||||||
|
//! Tests if operations specified by openMode can be performed on file *name
|
||||||
status_t CheckAccess(const char* name, int openMode);
|
status_t CheckAccess(const char* name, int openMode);
|
||||||
|
|
||||||
status_t Create(const char* name, type_code type,
|
status_t Create(const char* name, type_code type,
|
||||||
int openMode, attr_cookie** _cookie);
|
int openMode, attr_cookie** _cookie);
|
||||||
|
//! Loads file attributes into cookie
|
||||||
status_t Open(const char* name, int openMode,
|
status_t Open(const char* name, int openMode,
|
||||||
attr_cookie** _cookie);
|
attr_cookie** _cookie);
|
||||||
|
|
||||||
|
//! Get the stat from the attribute
|
||||||
status_t Stat(struct stat& stat);
|
status_t Stat(struct stat& stat);
|
||||||
|
|
||||||
|
//! Loads extended attributes of file into buffer
|
||||||
status_t Read(attr_cookie* cookie, off_t pos,
|
status_t Read(attr_cookie* cookie, off_t pos,
|
||||||
uint8* buffer, size_t* _length);
|
uint8* buffer, size_t* _length);
|
||||||
private:
|
private:
|
||||||
|
//! Searches through the filesystem tree for the entry named *name
|
||||||
status_t _Lookup(const char* name, size_t nameLength,
|
status_t _Lookup(const char* name, size_t nameLength,
|
||||||
btrfs_dir_entry** entries = NULL,
|
btrfs_dir_entry** entries = NULL,
|
||||||
uint32* length = NULL);
|
uint32* length = NULL);
|
||||||
|
//! Searches through the entry array for the entry named *name
|
||||||
status_t _FindEntry(btrfs_dir_entry* entries,
|
status_t _FindEntry(btrfs_dir_entry* entries,
|
||||||
size_t length, const char* name,
|
size_t length, const char* name,
|
||||||
size_t nameLength,
|
size_t nameLength,
|
||||||
|
|||||||
@@ -10,19 +10,29 @@
|
|||||||
#include "BTree.h"
|
#include "BTree.h"
|
||||||
#include "Inode.h"
|
#include "Inode.h"
|
||||||
|
|
||||||
|
//! Used to traverse through attributes of a given inode
|
||||||
class AttributeIterator {
|
class AttributeIterator {
|
||||||
public:
|
public:
|
||||||
|
//! Constructs an AttributeIterator object for Inode object *inode
|
||||||
AttributeIterator(Inode* inode);
|
AttributeIterator(Inode* inode);
|
||||||
~AttributeIterator();
|
~AttributeIterator();
|
||||||
|
//! Check if fIterator pointer is valid
|
||||||
status_t InitCheck();
|
status_t InitCheck();
|
||||||
|
|
||||||
|
/*! Copy details of next Attribute into *name and *_nameLength
|
||||||
|
* \param[out] name name of the current attribute
|
||||||
|
* \param[out] _nameLength length of name
|
||||||
|
* \return B_OK on success, B_ENTRY_NOT_FOUND otherwise
|
||||||
|
*/
|
||||||
status_t GetNext(char* name, size_t* _nameLength);
|
status_t GetNext(char* name, size_t* _nameLength);
|
||||||
|
//! Rewind the iterator to the first attribute of the node
|
||||||
status_t Rewind();
|
status_t Rewind();
|
||||||
private:
|
private:
|
||||||
|
//! Value of current offset from beginning of Attribute list
|
||||||
uint64 fOffset;
|
uint64 fOffset;
|
||||||
|
//! Pointer to Inode object corresponding to AttributeIterator
|
||||||
Inode* fInode;
|
Inode* fInode;
|
||||||
|
//! Pointer to beginning of current Attribute
|
||||||
TreeIterator* fIterator;
|
TreeIterator* fIterator;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user