1 /* 2 * Copyright 2008, Axel Dörfler, axeld@pinc-software.de. 3 * This file may be used under the terms of the MIT License. 4 */ 5 #ifndef INODE_H 6 #define INODE_H 7 8 9 #include <lock.h> 10 11 #include "ext2.h" 12 #include "Volume.h" 13 14 15 class Inode { 16 public: 17 Inode(Volume* volume, ino_t id); 18 ~Inode(); 19 20 status_t InitCheck(); 21 22 ino_t ID() const { return fID; } 23 24 rw_lock* Lock() { return &fLock; } 25 26 bool IsDirectory() const 27 { return S_ISDIR(Mode()); } 28 bool IsFile() const 29 { return S_ISREG(Mode()); } 30 bool IsSymLink() const 31 { return S_ISLNK(Mode()); } 32 33 status_t CheckPermissions(int accessMode) const; 34 35 mode_t Mode() const { return fNode->Mode(); } 36 int32 Flags() const { return fNode->Flags(); } 37 38 off_t Size() const { return fNode->Size(); } 39 time_t ModificationTime() const 40 { return fNode->ModificationTime(); } 41 time_t CreationTime() const 42 { return fNode->CreationTime(); } 43 time_t AccessTime() const 44 { return fNode->AccessTime(); } 45 46 //::Volume* _Volume() const { return fVolume; } 47 Volume* GetVolume() const { return fVolume; } 48 49 status_t FindBlock(off_t offset, uint32& block); 50 status_t ReadAt(off_t pos, uint8 *buffer, size_t *length); 51 52 status_t AttributeBlockReadAt(off_t pos, uint8 *buffer, 53 size_t *length); 54 55 ext2_inode& Node() { return *fNode; } 56 57 void* FileCache() const { return fCache; } 58 void* Map() const { return fMap; } 59 60 private: 61 Inode(const Inode&); 62 Inode &operator=(const Inode&); 63 // no implementation 64 65 private: 66 rw_lock fLock; 67 ::Volume* fVolume; 68 ino_t fID; 69 void* fCache; 70 void* fMap; 71 ext2_inode* fNode; 72 ext2_xattr_header* fAttributesBlock; 73 }; 74 75 #endif // INODE_H 76