diff --git a/src/add-ons/kernel/file_systems/btrfs/Attribute.h b/src/add-ons/kernel/file_systems/btrfs/Attribute.h index 630440fc9a..1d8829d518 100644 --- a/src/add-ons/kernel/file_systems/btrfs/Attribute.h +++ b/src/add-ons/kernel/file_systems/btrfs/Attribute.h @@ -1,4 +1,5 @@ /* + * Copyright 2019, Bharathi Ramana Joshi, joshibharathiramana@gmail.com. * Copyright 2017, Chế Vũ Gia Hy, cvghy116@gmail.com. * Copyright 2010-2011, Jérôme Duval, korli@users.berlios.de. * Copyright 2004-2008, Axel Dörfler, axeld@pinc-software.de. @@ -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 { public: + //! Constructs an Attribute object for the file inode Attribute(Inode* inode); Attribute(Inode* inode, attr_cookie* cookie); ~Attribute(); + //! Tests if operations specified by openMode can be performed on file *name status_t CheckAccess(const char* name, int openMode); status_t Create(const char* name, type_code type, int openMode, attr_cookie** _cookie); + //! Loads file attributes into cookie status_t Open(const char* name, int openMode, attr_cookie** _cookie); + //! Get the stat from the attribute status_t Stat(struct stat& stat); + //! Loads extended attributes of file into buffer status_t Read(attr_cookie* cookie, off_t pos, uint8* buffer, size_t* _length); private: + //! Searches through the filesystem tree for the entry named *name status_t _Lookup(const char* name, size_t nameLength, btrfs_dir_entry** entries = NULL, uint32* length = NULL); + //! Searches through the entry array for the entry named *name status_t _FindEntry(btrfs_dir_entry* entries, size_t length, const char* name, size_t nameLength, diff --git a/src/add-ons/kernel/file_systems/btrfs/AttributeIterator.h b/src/add-ons/kernel/file_systems/btrfs/AttributeIterator.h index 73db74d3ff..58126ba6f9 100644 --- a/src/add-ons/kernel/file_systems/btrfs/AttributeIterator.h +++ b/src/add-ons/kernel/file_systems/btrfs/AttributeIterator.h @@ -10,19 +10,29 @@ #include "BTree.h" #include "Inode.h" - +//! Used to traverse through attributes of a given inode class AttributeIterator { public: + //! Constructs an AttributeIterator object for Inode object *inode AttributeIterator(Inode* inode); ~AttributeIterator(); - + //! Check if fIterator pointer is valid 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); + //! Rewind the iterator to the first attribute of the node status_t Rewind(); private: + //! Value of current offset from beginning of Attribute list uint64 fOffset; + //! Pointer to Inode object corresponding to AttributeIterator Inode* fInode; + //! Pointer to beginning of current Attribute TreeIterator* fIterator; };