The Pedigree Project 0.1
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
Directory Class Reference

#include <Directory.h>

+ Inheritance diagram for Directory:
+ Collaboration diagram for Directory:

Classes

class  ChildLease
 
struct  DirectoryEntryMetadata
 
struct  DirectoryEntryView
 
struct  EnumerationContext
 
struct  InFlightLookup
 
class  NameReservation
 

Public Types

enum class  LookupStatus { Found , NotFound , IoError , Retry }
 
enum class  ReadStatus { Complete , Stopped , IoError }
 
enum class  AddStatus { Added , Exists , IoError , Detached }
 
enum class  EntryType : uint8_t {
  Unknown , Regular , Directory , Symlink ,
  Fifo , Socket , CharacterDevice , BlockDevice
}
 
using DirectoryEntryEmitter = bool(*)(void *, const DirectoryEntryView &)
 
- Public Types inherited from File
enum  AttributeMask : uint32_t {
  AccessTime = 1U << 0 , ModifyTime = 1U << 1 , ChangeTime = 1U << 2 , Owner = 1U << 3 ,
  Group = 1U << 4 , Permissions = 1U << 5
}
 

Public Member Functions

 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 ()
 
File * getChild (size_t n)
 
bool isDetached () const
 
size_t getNumChildren ()
 
ReadStatus enumerate (uint64_t &cookie, DirectoryEntryEmitter emitter, void *context)
 
ReadStatus isEmpty (bool &empty)
 
virtual void cacheDirectoryContents ()
 
virtual bool isCachePopulated () const
 
File * lookup (const HashedStringView &s) const
 
MUST_USE_RESULT bool lookupRetained (const HashedStringView &s, ChildLease &child) const
 
MUST_USE_RESULT LookupStatus lookupChild (const HashedStringView &s, ChildLease &child) const
 
MUST_USE_RESULT LookupStatus lookupChildAt (uint64_t cookie, const HashedStringView &name, ChildLease &child) const
 
void remove (const HashedStringView &s)
 
Directory * getReparsePoint () 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. The returned pointer is borrowed; atomic publication does not pin the target directory's lifetime.
 
void setReparsePoint (Directory *pTarget)
 
AddStatus addEphemeralFile (File *pFile)
 Add an ephemeral file to the directory.
 
void removeEphemeralFiles ()
 
bool empty ()
 
void emptyCache ()
 
- 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
 
size_t readCached (uint64_t location, size_t size, uintptr_t buffer, bool(*prepare)(uintptr_t, size_t)=nullptr)
 
virtual uint64_t write (uint64_t location, uint64_t size, uintptr_t buffer, bool bCanBlock=true) final
 
uint64_t append (uint64_t size, uintptr_t buffer, uint64_t &location, bool bCanBlock=true)
 
WriteGuard lockWrites ()
 
virtual physical_uintptr_t getPhysicalPage (size_t offset)
 
virtual bool isDirectPhysicalMapping () const
 
size_t physicalMappingFlags () const
 
virtual void returnPhysicalPage (size_t offset)
 
virtual bool tryBeginMappingRelease ()
 
void endMappingRelease ()
 
bool syncAndReturnPhysicalPage (size_t offset, bool async)
 
virtual bool sync ()
 
bool syncRange (size_t offset, size_t length)
 
virtual bool sync (size_t offset, bool async)
 
virtual bool syncPages (const uint64_t *offsets, size_t count)
 
Time::Timestamp getCreationTime ()
 
void setCreationTime (Time::Timestamp t)
 
Time::Timestamp getAccessedTime ()
 
void setAccessedTime (Time::Timestamp t)
 
Time::Timestamp getModifiedTime ()
 
void setModifiedTime (Time::Timestamp t)
 
void setTimes (Time::Timestamp accessed, Time::Timestamp modified, bool changeAccessed, bool changeModified)
 
virtual Attributes getAttributes () const
 
virtual XattrStatus getExtendedAttribute (const StringView &name, void *buffer, size_t capacity, size_t &required)
 
virtual XattrStatus listExtendedAttributes (void *buffer, size_t capacity, size_t &required)
 
virtual XattrStatus setExtendedAttribute (const StringView &name, const void *value, size_t length, unsigned flags)
 
virtual XattrStatus removeExtendedAttribute (const StringView &name)
 
virtual bool prepareSharedMapping (size_t offset, size_t length)
 
String getName () const
 
void getName (String &s) const
 
virtual void getFullPath (String &result, bool bWithMount=true)
 
virtual String getFullPath (bool bWithMount=true)
 
virtual void truncate ()
 
bool resize (size_t size)
 
virtual size_t getSize ()
 
void setSize (size_t sz)
 
virtual bool isSymlink ()
 
virtual bool isBlockDevice () const
 
virtual uint64_t deviceNumber () const
 
virtual bool isPipe () const
 
virtual bool isFifo () const
 
virtual bool isSocket () const
 
virtual bool isSeekable () const
 
bool supportsRegularFileOperations ()
 
virtual bool isCharacterDevice () const
 
virtual bool isConsole () const
 
virtual uint64_t maximumFileSize () const
 
virtual bool allowMapping (bool shared, bool writeRequested, bool &mayWrite)
 
bool acquireMappingUse (bool executable, bool sharedWrite)
 
void releaseMappingUse (bool executable, bool sharedWrite)
 
uintptr_t getInode () const
 
virtual void setInode (uintptr_t inode)
 
virtual uintptr_t futexIdentity ()
 
Filesystem * getFilesystem () const
 
void setFilesystem (Filesystem *pFs)
 
virtual void fileAttributeChanged ()
 
void publishEvent (FileEventMask mask, const StringView &name=StringView(), bool targetIsDirectory=false)
 
virtual FileHandleStatus subscribeInodeEvents (FileEventMask mask, const SharedPointer< FileEventObserver > &observer, FileEventSubscription &subscription)
 
virtual void finishInodeRetirement ()
 
virtual void increaseRefCount (bool bIsWriter)
 
virtual void decreaseRefCount (bool bIsWriter)
 
virtual bool retainVfsReference ()
 
virtual void releaseVfsReference ()
 
virtual bool isStableVfsRoot () const
 
void setPermissions (uint32_t perms)
 
uint32_t getPermissions () const
 
bool setOwnership (size_t uid, size_t gid, bool changeUid, bool changeGid)
 
void setUid (size_t uid)
 
size_t getUid () const
 
void setGid (size_t gid)
 
size_t getGid () const
 
File * getParent () const
 
void getNamespace (ParentLease &parent, String &name) const
 
virtual int select (bool bWriting=false, int timeout=0)
 
virtual ReadyMask queryReady (bool reading, bool writing)
 
virtual bool supportsReadinessNotifications () const
 
void monitor (Thread *pThread, Event *pEvent)
 
void cullMonitorTargets (Thread *pThread)
 
void cullMonitorTargets (Event *pEvent)
 
virtual bool supports (const size_t command) const
 
virtual int command (const size_t command, void *buffer)
 
virtual size_t getBlockSize () const
 
void markPageExternallyWritable (size_t offset)
 
size_t populateRange (size_t offset, size_t length)
 
void enableDirect ()
 
void disableDirect ()
 
virtual void preallocate (size_t expectedSize, bool zero=true)
 
bool allocateRange (size_t offset, size_t length, bool keepSize=false)
 
virtual File * open ()
 
virtual File * openForDescriptor (RetainedFile &owner)
 
- Public Member Functions inherited from ReadinessSource
MUST_USE_RESULT bool subscribeReadiness (ReadyMask interest, const SharedPointer< ReadinessObserver > &observer, ReadinessSubscription &subscription)
 
virtual ReadinessGenerations readinessGenerations ()
 
- Public Member Functions inherited from FileEventSource
MUST_USE_RESULT bool subscribeFileEvents (FileEventMask interest, const SharedPointer< FileEventObserver > &observer, FileEventSubscription &subscription)
 

Static Public Member Functions

static Directory * fromFile (File *pF)
 

Protected Types

typedef LazyEvaluate< File, DirectoryEntryMetadata, evaluateEntry, destroyEntry > DirectoryEntry
 

Protected Member Functions

virtual LookupStatus resolveChild (const StringView &name, File *&child)
 
virtual bool cacheResolvedChildren () const
 
virtual LookupStatus resolveChildAt (uint64_t cookie, const StringView &name, File *&child)
 
virtual ReadStatus readDirectory (uint64_t &cookie, DirectoryEntryEmitter emitter, void *context)
 
virtual const DirectoryEntryCache & getCache ()
 
void markCachePopulated ()
 
bool addDirectoryEntry (const String &name, File *pTarget)
 
bool addDirectoryEntry (const String &name, DirectoryEntryMetadata &&meta)
 
bool reserveDirectoryEntry (const HashedStringView &name, NameReservation &reservation)
 
bool addCachedDirectoryEntry (NameReservation &reservation, File *pTarget)
 
void invalidateDirectoryEntry (const HashedStringView &name)
 
bool removeDirectoryEntry (const HashedStringView &name, File *expected)
 
Mutex & namespaceMutationLock ()
 
void markDetached ()
 
void preallocateDirectoryEntries (size_t count)
 
virtual File * convertToFile (const DirectoryEntryMetadata &meta)
 
- Protected Member Functions inherited from File
bool tryAcquireFilesystemOperation (OperationBarrier::Lease &operation) const
 
virtual void updateAttributes (const Attributes &attributes, uint32_t mask)
 
virtual bool changeOwnership (size_t uid, size_t gid, bool changeUid, bool changeGid)
 
virtual bool allowPhysicalPage () const
 
virtual bool prepareWrite (uint64_t location, uint64_t size)
 
virtual bool allowResize (size_t oldSize, size_t newSize)
 
virtual bool prepareShrink (const ShrinkContext &context, UniquePointer< PreparedShrink > &prepared)
 
virtual bool resizeFile (size_t size)
 
virtual bool allocateFileRange (size_t offset, size_t length)
 
virtual Mutex & writeSerializationLock ()
 
virtual Mutex & dataMutationLock ()
 
virtual size_t & physicalPageLoans ()
 
bool clearDataCache ()
 
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 bool readPage (uint64_t location, uintptr_t destination)
 
virtual bool readPages (ReadPage *pages, size_t count)
 
virtual void writeBlock (uint64_t location, uintptr_t addr)
 
virtual void writeBlocks (uint64_t location, uintptr_t addr, size_t length)
 
virtual void extend (size_t newSize)
 
virtual void extend (size_t newSize, uint64_t location, uint64_t size)
 
virtual void publishInodeEvent (const FileEvent &event)
 
void dataChanged ()
 
void getFilesystemLabel (HugeStaticString &s)
 
void enableFillCacheWriteback ()
 
void shutdownFillCacheWriteback ()
 
bool syncFillCache (size_t offset, bool async, bool &present)
 
virtual bool useFillCache () const
 
virtual MUST_USE_RESULT bool pinBlock (uint64_t location)
 
virtual MUST_USE_RESULT uintptr_t acquireCachedBlock (uint64_t location, bool retryChanged)
 
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)
 
void retainDetachedParent ()
 
void moveNamespace (const String &name, File *parent)
 
bool snapshotNamespace (ParentLease &parent, String &name, FileEventMask interest) const
 
virtual CacheState & cacheState ()
 
void setPhysicalMappingFlags (size_t flags)
 
- Protected Member Functions inherited from ReadinessSource
void notifyReadiness (ReadyMask mask)
 
void closeReadiness (ReadyMask mask=ReadyInvalid|ReadyHangup)
 
- Protected Member Functions inherited from FileEventSource
bool hasFileEventObservers (FileEventMask mask) const
 
void notifyFileEvent (const FileEvent &event)
 
void notifyFinalFileEvent (const FileEvent &event)
 
void beginFinalFileEvent (const FileEvent &event)
 
void drainFileEvents ()
 
void closeFileEvents ()
 

Private Types

typedef HashTable< String, DirectoryEntry *, HashedStringView > DirectoryEntryCache
 
typedef HashTable< String, uint64_t, HashedStringView > DirectoryEntryGenerationCache
 
typedef HashTable< String, bool, HashedStringView > EphemeralEntryCache
 
typedef HashTable< String, InFlightLookup *, HashedStringView > InFlightLookupCache
 

Private Member Functions

 Directory (const Directory &file)
 
Directory & operator= (const Directory &)
 
virtual bool isBytewise () const
 
bool reserveRenameEntry (const String &name, NameReservation &reservation)
 
void moveReservedEntry (NameReservation &sourceReservation, Directory *destination, NameReservation &destinationReservation, File *source)
 
uint64_t nextCacheGeneration ()
 
bool removeEphemeralFileLocked (const HashedStringView &name, File *expected)
 
void finishNameReservation (NameReservation &reservation, LookupStatus result)
 
bool addResidentDirectoryEntry (NameReservation &reservation, File *pTarget, bool ephemeral)
 
bool addResidentDirectoryEntry (NameReservation &reservation, DirectoryEntry *entry, bool ephemeral, File *createdTarget=nullptr)
 
void tombstoneResidentLocked (const HashedStringView &name)
 
File * cachedFileLocked (const HashedStringView &name) const
 
LookupStatus lookupChildInternal (const HashedStringView &name, uint64_t cookie, bool hasCookie, ChildLease &child) const
 

Static Private Member Functions

static File * evaluateEntry (const DirectoryEntryMetadata &meta)
 
static void destroyEntry (File *file)
 
static EntryType entryType (File *file)
 
static bool emitBackingEntry (void *context, const DirectoryEntryView &entry)
 

Private Attributes

DirectoryEntryCache m_Cache
 
DirectoryEntryCache m_ResidentEntries
 
Vector< String > m_ResidentOrder
 
EphemeralEntryCache m_EphemeralEntries
 
DirectoryEntryGenerationCache m_CacheGenerations
 
uint64_t m_NextCacheGeneration
 
InFlightLookupCache m_InFlightLookups
 
bool m_bCachePopulated
 
bool m_Detached
 
Directory * m_ReparseTarget = nullptr
 
uintptr_t m_ParentInode
 
Mutex m_CacheLock
 
Mutex m_NamespaceMutationLock
 

Static Private Attributes

static constexpr uint64_t ResidentCookie = static_cast<uint64_t>(1) << 62
 

Friends

class Filesystem
 

Additional Inherited Members

- Static Public Attributes inherited from File
static constexpr size_t MaxReadPages = 32
 
- Static Protected Member Functions inherited from File
static bool writeCallback (CacheConstants::CallbackCause cause, uintptr_t loc, uintptr_t page, void *meta)
 
static bool fillCacheCallback (CacheConstants::CallbackCause cause, uintptr_t loc, uintptr_t page, void *meta)
 
- Static Protected Member Functions inherited from FileEventSource
static bool anyFileEventObservers ()
 
- Protected Attributes inherited from File
String m_Name
 
Time::Timestamp m_AccessedTime
 
Time::Timestamp m_ModifiedTime
 
Time::Timestamp m_CreationTime
 
uintptr_t m_Inode
 
uintptr_t m_FutexIdentity = 0
 
class Filesystem * m_pFilesystem
 
size_t m_Size
 
File * m_pParent
 
Mutex m_MetadataLock
 
File * m_pDetachedParent
 
bool m_bDetachedParentHandled
 
size_t m_nWriters
 
size_t m_nReaders
 
size_t m_Uid
 
size_t m_Gid
 
uint32_t m_Permissions
 
CacheState m_CacheState
 
bool m_bDirect
 
Mutex m_WriteLock
 
Mutex m_DataMutationLock
 
size_t m_PhysicalPageLoans = 0
 
size_t m_PhysicalMappingFlags = 0
 
Mutex m_Lock
 
List< MonitorTarget * > m_MonitorTargets
 

Detailed Description

A Directory node.

Todo:
Need to add a way to count # of times a particular lookup has happened so we can potentially offer a way to cull directory entries that are otherwise just consuming space.

Definition at line 50 of file Directory.h.

Member Typedef Documentation

◆ DirectoryEntry

typedef LazyEvaluate<File, DirectoryEntryMetadata, evaluateEntry, destroyEntry> Directory::DirectoryEntry
protected

Definition at line 325 of file Directory.h.

◆ DirectoryEntryCache

Definition at line 328 of file Directory.h.

◆ DirectoryEntryEmitter

using Directory::DirectoryEntryEmitter = bool (*)(void*, const DirectoryEntryView&)

Definition at line 79 of file Directory.h.

◆ DirectoryEntryGenerationCache

Definition at line 329 of file Directory.h.

◆ EphemeralEntryCache

Definition at line 330 of file Directory.h.

◆ InFlightLookupCache

Definition at line 342 of file Directory.h.

Member Enumeration Documentation

◆ AddStatus

enum class Directory::AddStatus
strong

Definition at line 58 of file Directory.h.

◆ EntryType

enum class Directory::EntryType : uint8_t
strong

Definition at line 60 of file Directory.h.

◆ LookupStatus

enum class Directory::LookupStatus
strong

Definition at line 54 of file Directory.h.

◆ ReadStatus

enum class Directory::ReadStatus
strong

Definition at line 56 of file Directory.h.

Constructor & Destructor Documentation

◆ Directory() [1/3]

Directory::Directory ( )

Constructor, creates an invalid directory.

Definition at line 101 of file Directory.cc.

◆ Directory() [2/3]

Directory::Directory ( const Directory &  file)
private

Copy constructors are hidden - unused!

◆ Directory() [3/3]

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 
)

Constructor, should be called only by a Filesystem.

Definition at line 116 of file Directory.cc.

◆ ~Directory()

Directory::~Directory ( )
virtual

Destructor - doesn't do anything.

Definition at line 136 of file Directory.cc.

References emptyCache().

Member Function Documentation

◆ addCachedDirectoryEntry()

bool Directory::addCachedDirectoryEntry ( NameReservation &  reservation,
File *  pTarget 
)
protected

◆ addDirectoryEntry() [1/2]

bool Directory::addDirectoryEntry ( const String &  name,
DirectoryEntryMetadata &&  meta 
)
protected

Add a lazily-evaluated entry to the directory.

Definition at line 846 of file Directory.cc.

References reserveDirectoryEntry().

◆ addDirectoryEntry() [2/2]

bool Directory::addDirectoryEntry ( const String &  name,
File *  pTarget 
)
protected

Add an entry to the directory.

Definition at line 835 of file Directory.cc.

References VFS::instance(), reserveDirectoryEntry(), and VFS::trackFile().

Referenced by RawFsDir::addEntry().

+ Here is the caller graph for this function:

◆ addEphemeralFile()

Directory::AddStatus Directory::addEphemeralFile ( File *  pFile)

Add an ephemeral file to the directory.

This is used to store files that need to be visible in the VFS but are not backed by a "real" file on disk. For example, a socket might need to be present with a filesystem path but should not be written to disk.

Definition at line 924 of file Directory.cc.

References addCachedDirectoryEntry(), File::getName(), VFS::instance(), isDetached(), reserveDirectoryEntry(), resolveChild(), VFS::trackFile(), and String::view().

◆ addResidentDirectoryEntry() [1/2]

bool Directory::addResidentDirectoryEntry ( NameReservation &  reservation,
DirectoryEntry *  entry,
bool  ephemeral,
File *  createdTarget = nullptr 
)
private

Definition at line 801 of file Directory.cc.

◆ addResidentDirectoryEntry() [2/2]

bool Directory::addResidentDirectoryEntry ( NameReservation &  reservation,
File *  pTarget,
bool  ephemeral 
)
private

Definition at line 795 of file Directory.cc.

◆ cachedFileLocked()

File * Directory::cachedFileLocked ( const HashedStringView &  name) const
private

Definition at line 1196 of file Directory.cc.

◆ cacheDirectoryContents()

void Directory::cacheDirectoryContents ( )
virtual

Load the directory's contents into the cache.

Reimplemented in UnixDirectory, RawFsDir, FatDirectory, and RamDir.

Definition at line 332 of file Directory.cc.

◆ cacheResolvedChildren()

virtual bool Directory::cacheResolvedChildren ( ) const
inlineprotectedvirtual

Dynamic namespaces may return a fresh retained node on every lookup.

Definition at line 299 of file Directory.h.

Referenced by Filesystem::findNode(), getChild(), and lookup().

+ Here is the caller graph for this function:

◆ convertToFile()

File * Directory::convertToFile ( const DirectoryEntryMetadata &  meta)
protectedvirtual

Convert given metadata into a useful File object.

Definition at line 1148 of file Directory.cc.

◆ destroyEntry()

void Directory::destroyEntry ( File *  file)
staticprivate

Definition at line 1144 of file Directory.cc.

◆ emitBackingEntry()

bool Directory::emitBackingEntry ( void *  context,
const DirectoryEntryView &  entry 
)
staticprivate

Definition at line 201 of file Directory.cc.

◆ empty()

bool Directory::empty ( )

Empty the entire directory, deleting all files within it (non-recursively). This does NOT check that the directory is "empty" first.

Definition at line 1033 of file Directory.cc.

References enumerate(), lookup(), and lookupChildAt().

Referenced by isEmpty().

+ Here is the caller graph for this function:

◆ emptyCache()

void Directory::emptyCache ( )

◆ entryType()

Directory::EntryType Directory::entryType ( File *  file)
staticprivate

Definition at line 1208 of file Directory.cc.

◆ enumerate()

Directory::ReadStatus Directory::enumerate ( uint64_t &  cookie,
DirectoryEntryEmitter  emitter,
void *  context 
)

Stream directory records without constructing a File for every child. The cookie is opaque to callers and advances only when an entry is accepted by the emitter.

Definition at line 224 of file Directory.cc.

References String::compare(), Vector< T >::count(), VFS::instance(), isDetached(), m_CacheLock, m_ParentInode, m_ResidentOrder, and readDirectory().

Referenced by empty(), getChild(), getNumChildren(), and isEmpty().

+ Here is the caller graph for this function:

◆ evaluateEntry()

File * Directory::evaluateEntry ( const DirectoryEntryMetadata &  meta)
staticprivate

Definition at line 1126 of file Directory.cc.

◆ finishNameReservation()

void Directory::finishNameReservation ( NameReservation &  reservation,
LookupStatus  result 
)
private

Definition at line 670 of file Directory.cc.

◆ fromFile()

static Directory * Directory::fromFile ( File *  pF)
inlinestatic

◆ getCache()

virtual const DirectoryEntryCache & Directory::getCache ( )
inlineprotectedvirtual

Provides subclasses with direct access to the directory's listing.

Definition at line 390 of file Directory.h.

◆ getChild()

File * Directory::getChild ( size_t  n)

Returns the n'th child of this directory, or an invalid file.

Definition at line 140 of file Directory.cc.

References cacheResolvedChildren(), enumerate(), and lookupChildAt().

◆ getNumChildren()

size_t Directory::getNumChildren ( )

Returns the number of children in this directory.

Definition at line 183 of file Directory.cc.

References enumerate().

◆ getReparsePoint()

Directory * Directory::getReparsePoint ( ) 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. The returned pointer is borrowed; atomic publication does not pin the target directory's lifetime.

Definition at line 916 of file Directory.cc.

References m_ReparseTarget.

Referenced by Filesystem::findNode(), and Filesystem::findParent().

+ Here is the caller graph for this function:

◆ invalidateDirectoryEntry()

void Directory::invalidateDirectoryEntry ( const HashedStringView &  name)
protected

◆ isBytewise()

virtual bool Directory::isBytewise ( ) const
inlineprivatevirtual

File subclasses can define this and return true if they require read() calls to perform actual data reads, and false if readBlock() is otherwise sufficient.

Reimplemented from File.

Definition at line 317 of file Directory.h.

◆ isCachePopulated()

bool Directory::isCachePopulated ( ) const
virtual

Does this directory have cache?

Definition at line 334 of file Directory.cc.

References m_bCachePopulated, and m_CacheLock.

◆ isDetached()

bool Directory::isDetached ( ) const
inline

Snapshot only; namespace entry operations separately enforce admission.

Definition at line 182 of file Directory.h.

Referenced by FatDirectory::addEntry(), addEphemeralFile(), enumerate(), FatDirectory::readDirectory(), FatFilesystem::removeNode(), reserveDirectoryEntry(), reserveRenameEntry(), FatDirectory::resolveChild(), and FatDirectory::resolveChildAt().

+ Here is the caller graph for this function:

◆ isDirectory()

virtual bool Directory::isDirectory ( )
inlinevirtual

Returns true if the File is actually a directory.

Reimplemented from File.

Definition at line 174 of file Directory.h.

◆ isEmpty()

Directory::ReadStatus Directory::isEmpty ( bool &  empty)

Determine whether this directory contains entries other than . and ...

Definition at line 318 of file Directory.cc.

References empty(), and enumerate().

Referenced by Filesystem::removeChild(), and FatFilesystem::removeNode().

+ Here is the caller graph for this function:

◆ lookup()

File * Directory::lookup ( const HashedStringView &  s) const

Look up the given filename in the directory.

Definition at line 339 of file Directory.cc.

References cacheResolvedChildren(), and lookupChild().

Referenced by empty(), reserveDirectoryEntry(), and reserveRenameEntry().

+ Here is the caller graph for this function:

◆ lookupChild()

Directory::LookupStatus Directory::lookupChild ( const HashedStringView &  s,
ChildLease &  child 
) const

Resolve and retain one child without populating the whole directory.

Definition at line 355 of file Directory.cc.

Referenced by ProcFs::addProcess(), Filesystem::findNode(), lookup(), lookupChildAt(), lookupRetained(), and Filesystem::removeChild().

+ Here is the caller graph for this function:

◆ lookupChildAt()

Directory::LookupStatus Directory::lookupChildAt ( uint64_t  cookie,
const HashedStringView &  name,
ChildLease &  child 
) const

Materialize a streamed record without rescanning earlier directory entries.

Definition at line 359 of file Directory.cc.

References Vector< T >::count(), File::getNamespace(), VFS::instance(), HashTable< K, V, SiblingK, InitialBuckets, QuadraticProbe, GrowthFactor >::lookup(), lookupChild(), m_CacheLock, m_InFlightLookups, m_ResidentEntries, m_ResidentOrder, and VFS::retainTrackedFile().

Referenced by empty(), and getChild().

+ Here is the caller graph for this function:

◆ lookupChildInternal()

Directory::LookupStatus Directory::lookupChildInternal ( const HashedStringView &  name,
uint64_t  cookie,
bool  hasCookie,
ChildLease &  child 
) const
private

Definition at line 424 of file Directory.cc.

◆ lookupRetained()

bool Directory::lookupRetained ( const HashedStringView &  s,
ChildLease &  child 
) const

Atomically retain the current child of an already-stable directory. A previous output lease is preserved on failure and released only after the replacement lookup has finished using this directory. Leases are thread-affine and must have strictly lexical stack lifetimes on the Thread which acquired them.

Definition at line 351 of file Directory.cc.

References lookupChild().

◆ markCachePopulated()

void Directory::markCachePopulated ( )
protected

Mark the directory cache as populated now.

Definition at line 1170 of file Directory.cc.

References m_bCachePopulated, and m_CacheLock.

Referenced by UnixDirectory::cacheDirectoryContents().

+ Here is the caller graph for this function:

◆ markDetached()

void Directory::markDetached ( )
protected

Definition at line 1082 of file Directory.cc.

◆ moveReservedEntry()

void Directory::moveReservedEntry ( NameReservation &  sourceReservation,
Directory *  destination,
NameReservation &  destinationReservation,
File *  source 
)
private

Definition at line 730 of file Directory.cc.

◆ namespaceMutationLock()

Mutex & Directory::namespaceMutationLock ( )
inlineprotected

Serialises namespace mutations and empty-directory removal.

Definition at line 416 of file Directory.h.

Referenced by Filesystem::removeChild(), and FatFilesystem::removeNode().

+ Here is the caller graph for this function:

◆ nextCacheGeneration()

uint64_t Directory::nextCacheGeneration ( )
private

Definition at line 1175 of file Directory.cc.

◆ preallocateDirectoryEntries()

void Directory::preallocateDirectoryEntries ( size_t  count)
protected

Preallocate space for the given number of directory entries.

Definition at line 1165 of file Directory.cc.

References m_CacheLock, m_ResidentEntries, and HashTable< K, V, SiblingK, InitialBuckets, QuadraticProbe, GrowthFactor >::reserve().

◆ readDirectory()

Directory::ReadStatus Directory::readDirectory ( uint64_t &  cookie,
DirectoryEntryEmitter  emitter,
void *  context 
)
protectedvirtual

Stream backing-store entries. Resident entries are merged by enumerate().

Reimplemented in Ext2Directory, FatDirectory, and Iso9660Directory.

Definition at line 1161 of file Directory.cc.

Referenced by enumerate().

+ Here is the caller graph for this function:

◆ remove()

void Directory::remove ( const HashedStringView &  s)

◆ removeDirectoryEntry()

bool Directory::removeDirectoryEntry ( const HashedStringView &  name,
File *  expected 
)
protected

◆ removeEphemeralFileLocked()

bool Directory::removeEphemeralFileLocked ( const HashedStringView &  name,
File *  expected 
)
private

Definition at line 1008 of file Directory.cc.

◆ removeEphemeralFiles()

void Directory::removeEphemeralFiles ( )

◆ reserveDirectoryEntry()

bool Directory::reserveDirectoryEntry ( const HashedStringView &  name,
NameReservation &  reservation 
)
protected

◆ reserveRenameEntry()

bool Directory::reserveRenameEntry ( const String &  name,
NameReservation &  reservation 
)
private

◆ resolveChild()

Directory::LookupStatus Directory::resolveChild ( const StringView &  name,
File *&  child 
)
protectedvirtual

Resolve one backing-store entry. A found File must be new and untracked.

Reimplemented in Ext2Directory, FatDirectory, and Iso9660Directory.

Definition at line 1152 of file Directory.cc.

Referenced by addEphemeralFile(), and resolveChildAt().

+ Here is the caller graph for this function:

◆ resolveChildAt()

Directory::LookupStatus Directory::resolveChildAt ( uint64_t  cookie,
const StringView &  name,
File *&  child 
)
protectedvirtual

Resolve one backing record at a cookie returned by readDirectory(). Implementations must fall back to a full name lookup if the cookie has become stale, so this remains equivalent to resolveChild().

Reimplemented in Ext2Directory, FatDirectory, and Iso9660Directory.

Definition at line 1157 of file Directory.cc.

References resolveChild().

◆ setReparsePoint()

void Directory::setReparsePoint ( Directory *  pTarget)

Set/unset the reparse point for this directory.

Definition at line 920 of file Directory.cc.

References m_ReparseTarget.

Referenced by VFS::removeDiskFilesystem(), and VFS::unregisterFilesystem().

+ Here is the caller graph for this function:

◆ tombstoneResidentLocked()

void Directory::tombstoneResidentLocked ( const HashedStringView &  name)
private

Definition at line 1183 of file Directory.cc.

Friends And Related Symbol Documentation

◆ Filesystem

friend class Filesystem
friend

Definition at line 51 of file Directory.h.

Member Data Documentation

◆ m_bCachePopulated

bool Directory::m_bCachePopulated
private

Whether the directory cache is populated with entries or still needs to be loaded. Directories are lazy-loaded using this.

Definition at line 367 of file Directory.h.

Referenced by emptyCache(), isCachePopulated(), and markCachePopulated().

◆ m_Cache

DirectoryEntryCache Directory::m_Cache
private

◆ m_CacheGenerations

DirectoryEntryGenerationCache Directory::m_CacheGenerations
private

Publication identity for cache entries across callback unlocks.

Definition at line 357 of file Directory.h.

Referenced by addCachedDirectoryEntry(), emptyCache(), invalidateDirectoryEntry(), remove(), and removeDirectoryEntry().

◆ m_CacheLock

Mutex Directory::m_CacheLock
mutableprivate

◆ m_Detached

bool Directory::m_Detached
private

Whether this directory has been unlinked from its parent namespace.

Definition at line 370 of file Directory.h.

◆ m_EphemeralEntries

EphemeralEntryCache Directory::m_EphemeralEntries
private

Names whose resident entry overlays, rather than belongs to, the filesystem.

Definition at line 354 of file Directory.h.

Referenced by emptyCache(), remove(), removeDirectoryEntry(), and removeEphemeralFiles().

◆ m_InFlightLookups

InFlightLookupCache Directory::m_InFlightLookups
mutableprivate

Same-name backing lookups share one resolver and publication point.

Definition at line 361 of file Directory.h.

Referenced by emptyCache(), invalidateDirectoryEntry(), lookupChildAt(), remove(), removeDirectoryEntry(), reserveDirectoryEntry(), and reserveRenameEntry().

◆ m_NamespaceMutationLock

Mutex Directory::m_NamespaceMutationLock
mutableprivate

Prevents namespace publication from crossing a removal boundary.

Definition at line 382 of file Directory.h.

Referenced by emptyCache(), remove(), removeEphemeralFiles(), and reserveDirectoryEntry().

◆ m_NextCacheGeneration

uint64_t Directory::m_NextCacheGeneration
private

Definition at line 358 of file Directory.h.

◆ m_ParentInode

uintptr_t Directory::m_ParentInode
private

Stable metadata for synthetic .. after this directory is unlinked.

Definition at line 376 of file Directory.h.

Referenced by enumerate().

◆ m_ReparseTarget

Directory* Directory::m_ReparseTarget = nullptr
private

Reparse target.

Definition at line 373 of file Directory.h.

Referenced by getReparsePoint(), and setReparsePoint().

◆ m_ResidentEntries

DirectoryEntryCache Directory::m_ResidentEntries
private

Authoritative in-memory names, including synthetic and ephemeral files.

Definition at line 348 of file Directory.h.

Referenced by addCachedDirectoryEntry(), emptyCache(), lookupChildAt(), preallocateDirectoryEntries(), remove(), removeDirectoryEntry(), and removeEphemeralFiles().

◆ m_ResidentOrder

Vector<String> Directory::m_ResidentOrder
private

Stable resident enumeration slots. Removed entries leave tombstones.

Definition at line 351 of file Directory.h.

Referenced by emptyCache(), enumerate(), lookupChildAt(), and removeEphemeralFiles().

◆ ResidentCookie

constexpr uint64_t Directory::ResidentCookie = static_cast<uint64_t>(1) << 62
staticconstexprprivate

Definition at line 434 of file Directory.h.


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