The Pedigree Project  0.1
Public Member Functions | Private Member Functions | List of all members
Ext2Directory Class Reference

#include <Ext2Directory.h>

+ Inheritance diagram for Ext2Directory:
+ Collaboration diagram for Ext2Directory:

Public Member Functions

 Ext2Directory (const String &name, uintptr_t inode_num, Inode *inode, class Ext2Filesystem *pFs, File *pParent)
 
virtual ~Ext2Directory ()
 
void truncate ()
 
virtual void cacheDirectoryContents ()
 
virtual bool addEntry (String filename, File *pFile, size_t type)
 
virtual bool removeEntry (const String &filename, Ext2Node *pFile)
 
void fileAttributeChanged ()
 
- Public Member Functions inherited from Directory
 Directory ()
 
 Directory (const String &name, Time::Timestamp accessedTime, Time::Timestamp modifiedTime, Time::Timestamp creationTime, uintptr_t inode, class Filesystem *pFs, size_t size, File *pParent)
 
virtual ~Directory ()
 
virtual bool isDirectory ()
 
FilegetChild (size_t n)
 
size_t getNumChildren ()
 
virtual bool isCachePopulated () const
 
Filelookup (const HashedStringView &s) const
 
void remove (const HashedStringView &s)
 
DirectorygetReparsePoint () const
 Get the reparse point attached to this directory. Reparse points allow locations on the filesystem to redirect lookups to a separate directory. While the reparse point is active, the target directory is used for lookups instead of this one.
 
void setReparsePoint (Directory *pTarget)
 
bool addEphemeralFile (File *pFile)
 Add an ephemeral file to the directory. More...
 
bool empty ()
 
- Public Member Functions inherited from File
 File ()
 
 File (const String &name, Time::Timestamp accessedTime, Time::Timestamp modifiedTime, Time::Timestamp creationTime, uintptr_t inode, class Filesystem *pFs, size_t size, File *pParent)
 
virtual ~File ()
 
virtual uint64_t read (uint64_t location, uint64_t size, uintptr_t buffer, bool bCanBlock=true) final
 
virtual uint64_t write (uint64_t location, uint64_t size, uintptr_t buffer, bool bCanBlock=true) final
 
virtual physical_uintptr_t getPhysicalPage (size_t offset)
 
virtual void returnPhysicalPage (size_t offset)
 
virtual void sync ()
 
virtual void sync (size_t offset, bool async)
 
Time::Timestamp getCreationTime ()
 
void setCreationTime (Time::Timestamp t)
 
Time::Timestamp getAccessedTime ()
 
void setAccessedTime (Time::Timestamp t)
 
Time::Timestamp getModifiedTime ()
 
void setModifiedTime (Time::Timestamp t)
 
String getName () const
 
void getName (String &s) const
 
virtual String getFullPath (bool bWithLabel=true)
 
size_t getSize ()
 
void setSize (size_t sz)
 
virtual bool isSymlink ()
 
virtual bool isPipe () const
 
virtual bool isFifo () const
 
virtual bool isSocket () const
 
uintptr_t getInode () const
 
virtual void setInode (uintptr_t inode)
 
FilesystemgetFilesystem () const
 
void setFilesystem (Filesystem *pFs)
 
virtual void increaseRefCount (bool bIsWriter)
 
virtual void decreaseRefCount (bool bIsWriter)
 
void setPermissions (uint32_t perms)
 
uint32_t getPermissions () const
 
void setUid (size_t uid)
 
size_t getUid () const
 
void setGid (size_t gid)
 
size_t getGid () const
 
FilegetParent () const
 
virtual int select (bool bWriting=false, int timeout=0)
 
void monitor (Thread *pThread, Event *pEvent)
 
void cullMonitorTargets (Thread *pThread)
 
virtual bool supports (const size_t command) const
 
virtual int command (const size_t command, void *buffer)
 
virtual size_t getBlockSize () const
 
void enableDirect ()
 
void disableDirect ()
 
virtual void preallocate (size_t expectedSize, bool zero=true)
 
virtual Fileopen ()
 
- Public Member Functions inherited from Ext2Node
 Ext2Node (uintptr_t inode_num, Inode *pInode, class Ext2Filesystem *pFs)
 
virtual ~Ext2Node ()
 
InodegetInode ()
 
uint32_t getInodeNumber ()
 
void fileAttributeChanged (size_t size, size_t atime, size_t mtime, size_t ctime)
 
void updateMetadata (uint16_t uid, uint16_t gid, uint32_t perms)
 
void wipe ()
 
void extend (size_t newSize)
 
void extend (size_t newSize, uint64_t location, uint64_t size)
 
uintptr_t readBlock (uint64_t location)
 
void writeBlock (uint64_t location)
 
void trackBlock (uint32_t block)
 
void pinBlock (uint64_t location)
 
void unpinBlock (uint64_t location)
 
void sync (size_t offset, bool async)
 

Private Member Functions

 Ext2Directory (const Ext2Directory &file)
 
Ext2Directoryoperator= (const Ext2Directory &)
 
virtual FileconvertToFile (const DirectoryEntryMetadata &meta)
 

Additional Inherited Members

- Static Public Member Functions inherited from Directory
static DirectoryfromFile (File *pF)
 
- Protected Types inherited from Directory
typedef LazyEvaluate< File, DirectoryEntryMetadata, evaluateEntry, destroyEntryDirectoryEntry
 
- Protected Member Functions inherited from Directory
virtual const DirectoryEntryCachegetCache ()
 
void markCachePopulated ()
 
void addDirectoryEntry (const String &name, File *pTarget)
 
void addDirectoryEntry (const String &name, DirectoryEntryMetadata &&meta)
 
void preallocateDirectoryEntries (size_t count)
 
- Protected Member Functions inherited from File
virtual uint64_t readBytewise (uint64_t location, uint64_t size, uintptr_t buffer, bool bCanBlock=true)
 
virtual uint64_t writeBytewise (uint64_t location, uint64_t size, uintptr_t buffer, bool bCanBlock=true)
 
virtual uintptr_t readBlock (uint64_t location)
 
virtual void writeBlock (uint64_t location, uintptr_t addr)
 
virtual void extend (size_t newSize)
 
virtual void extend (size_t newSize, uint64_t location, uint64_t size)
 
void dataChanged ()
 
void getFilesystemLabel (HugeStaticString &s)
 
virtual void pinBlock (uint64_t location)
 
virtual void unpinBlock (uint64_t location)
 
void evict (uint64_t location)
 
void setPermissionsOnly (uint32_t perms)
 
void setUidOnly (size_t uid)
 
void setGidOnly (size_t gid)
 
- Protected Member Functions inherited from Ext2Node
bool ensureLargeEnough (size_t size, uint64_t location, uint64_t opsize, bool onlyBlocks=false, bool nozeroblocks=false)
 
bool addBlock (uint32_t blockValue)
 
bool ensureBlockLoaded (size_t nBlock)
 
bool getBlockNumber (size_t nBlock)
 
bool getBlockNumberIndirect (uint32_t inode_block, size_t nBlocks, size_t nBlock)
 
bool getBlockNumberBiindirect (uint32_t inode_block, size_t nBlocks, size_t nBlock)
 
bool getBlockNumberTriindirect (uint32_t inode_block, size_t nBlocks, size_t nBlock)
 
bool setBlockNumber (size_t blockNum, uint32_t blockValue)
 
uint32_t modeToPermissions (uint32_t mode) const
 
uint32_t permissionsToMode (uint32_t permissions) const
 
- Static Protected Member Functions inherited from File
static void writeCallback (CacheConstants::CallbackCause cause, uintptr_t loc, uintptr_t page, void *meta)
 
- Protected Attributes inherited from File
String m_Name
 
Time::Timestamp m_AccessedTime
 
Time::Timestamp m_ModifiedTime
 
Time::Timestamp m_CreationTime
 
uintptr_t m_Inode
 
class Filesystemm_pFilesystem
 
size_t m_Size
 
Filem_pParent
 
size_t m_nWriters
 
size_t m_nReaders
 
size_t m_Uid
 
size_t m_Gid
 
uint32_t m_Permissions
 
HashTable< DataCacheKey, uintptr_t > m_DataCache
 
bool m_bDirect
 
Cache m_FillCache
 
Mutex m_Lock
 
List< MonitorTarget * > m_MonitorTargets
 
- Protected Attributes inherited from Ext2Node
Inodem_pInode
 
uint32_t m_InodeNumber
 
class Ext2Filesystemm_pExt2Fs
 
Vector< uint32_t > m_Blocks
 
uint32_t m_nMetadataBlocks
 
size_t m_nSize
 

Detailed Description

A File is a file, a directory or a symlink.

Definition at line 32 of file Ext2Directory.h.

Constructor & Destructor Documentation

Ext2Directory::Ext2Directory ( const Ext2Directory file)
private

Copy constructors are hidden - unused!

Referenced by convertToFile().

+ Here is the caller graph for this function:

Ext2Directory::Ext2Directory ( const String name,
uintptr_t  inode_num,
Inode inode,
class Ext2Filesystem pFs,
File pParent 
)

Constructor, should be called only by a Filesystem.

Definition at line 36 of file Ext2Directory.cc.

References File::setGidOnly(), File::setPermissionsOnly(), and File::setUidOnly().

Ext2Directory::~Ext2Directory ( )
virtual

Destructor

Definition at line 53 of file Ext2Directory.cc.

Member Function Documentation

bool Ext2Directory::addEntry ( String  filename,
File pFile,
size_t  type 
)
virtual

Adds a directory entry.

Todo:
Ensure 4-byte alignment.
Todo:
Previous directory entry might need its reclen updated to point to this new entry (as directory entries cannot cross block boundaries).
Todo:
Update our i_size for our directory.

Definition at line 57 of file Ext2Directory.cc.

References Directory::addDirectoryEntry(), cacheDirectoryContents(), Vector< T >::count(), ERROR, fileAttributeChanged(), Ext2Filesystem::m_BlockSize, Ext2Filesystem::readBlock(), and Ext2Filesystem::writeBlock().

Referenced by Ext2Filesystem::createNode(), and truncate().

+ Here is the caller graph for this function:

void Ext2Directory::cacheDirectoryContents ( )
virtual

Reads directory contents into File* cache.

Todo:
need to handle short/failed reads better

Reimplemented from Directory.

Definition at line 290 of file Ext2Directory.cc.

References Directory::addDirectoryEntry(), assert, Vector< T >::count(), ERROR, Directory::isCachePopulated(), Ext2Filesystem::m_BlockSize, Directory::markCachePopulated(), and Ext2Filesystem::readBlock().

Referenced by addEntry(), and truncate().

+ Here is the caller graph for this function:

File * Ext2Directory::convertToFile ( const DirectoryEntryMetadata meta)
privatevirtual

Convert given metadata into a useful File object.

Reimplemented from Directory.

Definition at line 410 of file Ext2Directory.cc.

References Ext2Directory(), and FATAL.

Referenced by truncate().

+ Here is the caller graph for this function:

void Ext2Directory::fileAttributeChanged ( )
virtual

Updates inode attributes.

Reimplemented from File.

Definition at line 402 of file Ext2Directory.cc.

References Ext2Node::updateMetadata().

Referenced by addEntry(), and truncate().

+ Here is the caller graph for this function:

bool Ext2Directory::removeEntry ( const String filename,
Ext2Node pFile 
)
virtual

Removes a directory entry.

Todo:
Okay, this is not quite enough. The previous entry needs to be updated to skip past this now-empty entry. If this was the first entry, a blank record must be created to point to either the next entry or the end of the block.

Definition at line 213 of file Ext2Directory.cc.

References Vector< T >::count(), Ext2Filesystem::m_BlockSize, Ext2Filesystem::readBlock(), Ext2Filesystem::releaseInode(), Ext2Node::wipe(), and Ext2Filesystem::writeBlock().

Referenced by Ext2Filesystem::remove(), and truncate().

+ Here is the caller graph for this function:

void Ext2Directory::truncate ( )
inlinevirtual

Delete all data from the file.

Reimplemented from File.

Definition at line 47 of file Ext2Directory.h.

References addEntry(), cacheDirectoryContents(), convertToFile(), fileAttributeChanged(), and removeEntry().


The documentation for this class was generated from the following files: