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

#include <FatFilesystem.h>

+ Inheritance diagram for FatFilesystem:
+ Collaboration diagram for FatFilesystem:

Classes

struct  NodeState
 
struct  PendingAttributes
 
union  RootDirInfo
 
class  ShrinkPlan
 

Public Member Functions

bool initialise (Disk *pDisk) override
 
File * getRoot () const override
 
const String & getVolumeLabel () const override
 
bool getUuid (String &) const override
 
SyncStatus sync () override
 
SyncStatus shutdown () override
 
bool deviceRemoved (bool deviceAvailable=false) override
 
uint64_t read (File *pFile, uint64_t location, uint64_t size, uintptr_t buffer, bool bCanBlock=true)
 
uint64_t write (File *pFile, uint64_t location, uint64_t size, uintptr_t buffer, bool bCanBlock=true)
 
void truncate (File *pFile)
 
void fileAttributeChanged (File *pFile)
 
void cacheDirectoryContents (File *pFile)
 
void extend (File *pFile, size_t size)
 
- Public Member Functions inherited from Filesystem
 Filesystem ()
 
virtual ~Filesystem ()
 
virtual File * find (const StringView &path)
 
virtual File * find (const String &path)
 
virtual File * find (const StringView &path, File *pStartNode)
 
virtual File * find (const String &path, File *pStartNode)
 
File * findRetained (const StringView &path, Directory::ChildLease &result, File *pStartNode=nullptr)
 
virtual FileHandleStatus encodeFileHandle (File &file, FileHandle &handle)
 
virtual FileHandleStatus decodeFileHandle (const FileHandle &handle, RetainedFile &file)
 
virtual FileHandleStatus fileHandleFsid (FileSystemId &id)
 
bool tryAcquireOperation (OperationBarrier::Lease &operation) const
 
bool isDeviceRemoved () const
 
virtual QuotaStatus quotaControl (const QuotaRequest &, QuotaResponse &, File *quotaFile=nullptr)
 
bool createFile (const StringView &path, uint32_t mask, File *pStartNode=0)
 
bool createDirectory (const StringView &path, uint32_t mask, File *pStartNode=0)
 
bool createSymlink (const StringView &path, const String &value, File *pStartNode=0)
 
bool createLink (const StringView &path, File *target, File *pStartNode=0)
 
bool remove (const StringView &path, File *pStartNode=0)
 
bool remove (const StringView &path, File *pStartNode, File *expected)
 
bool rename (const StringView &oldPath, File *oldStart, const StringView &newPath, File *newStart, bool noReplace=false)
 
Disk * getDisk ()
 
bool isReadOnly ()
 
virtual bool isCaseSensitive ()
 
bool remove (File *parent, File *file)
 

Static Public Member Functions

static Filesystem * probe (Disk *pDisk)
 

Protected Member Functions

bool createFile (File *parent, const String &filename, uint32_t mask) override
 
bool createDirectory (File *parent, const String &filename, uint32_t mask) override
 
bool createSymlink (File *parent, const String &filename, const String &value) override
 
bool removeNode (File *parent, const String &filename, File *file) override
 
bool renameNode (Directory *oldParent, const String &oldName, File *source, Directory *newParent, const String &newName, File *replaced) override
 
 FatFilesystem (const FatFilesystem &)
 
void operator= (const FatFilesystem &)
 
void loadRootDir ()
 
void cacheVolumeLabel ()
 
bool readCluster (uint32_t block, uintptr_t buffer) const
 
bool writeCluster (uint32_t block, uintptr_t buffer)
 
bool writeSectorBlock (uint32_t sec, size_t size, uintptr_t buffer)
 
bool readSectorBlock (uint32_t sec, size_t size, uintptr_t buffer) const
 
uint32_t getSectorNumber (uint32_t cluster) const
 
uint32_t getClusterEntry (uint32_t cluster, bool bLock=true)
 
bool setClusterEntry (uint32_t cluster, uint32_t value, bool bLock=true, bool persist=true)
 
String convertFilenameTo (String filename) const
 
String convertFilenameFrom (String filename) const
 
uint32_t findFreeCluster (bool *persisted=nullptr)
 
bool syncFat (bool bLock=true)
 
bool invalidateFsInfoHints ()
 
uint8_t * getFatSector (uint32_t sector)
 
bool chainExtent (File *file, uint32_t &count, uint32_t &last)
 
uint32_t fileClusterAt (File *, size_t)
 
bool truncateFile (File *file)
 
bool prepareFileShrink (FatFile *, size_t, UniquePointer< File::PreparedShrink > &)
 
bool trimFileAllocation (FatFile *)
 
void publishSize (File *, size_t)
 
void unlinkNode (File *)
 
void retireNode (File *)
 
void moveNode (File *, uint32_t, uint32_t)
 
bool isNodeUnlinked (File *) const
 
void writeEntryAttributes (File *, Dir *, bool creating=false)
 
void encodeEntryAttributes (const File::Attributes &, Dir *, bool creating=false)
 
bool syncNodeAttributes (File *)
 
bool syncNode (File *)
 
bool writePendingAttributes (const PendingAttributes &)
 
bool syncPendingAttributes ()
 
void movePendingAttributes (uint32_t oldCluster, uint32_t oldOffset, uint32_t newCluster, uint32_t newOffset)
 
void discardPendingAttributes (uint32_t cluster, uint32_t offset)
 
void clearPendingAttributes ()
 
FatFile::State * acquireFileState (FatFile *, uintptr_t, size_t, uint32_t, uint32_t, Time::Timestamp, Time::Timestamp, Time::Timestamp)
 
void releaseFileState (FatFile *)
 
uintptr_t fileIdentifier (uint32_t cluster, uint32_t offset)
 
uintptr_t fileIdentifierLocked (uint64_t slot)
 
bool writeCachedPages (FatFile::State &, const Cache::WritebackPage *, size_t)
 
bool drainFileStates (bool checked=false)
 
void registerNode (File *)
 
void releaseNode (File *)
 
void moveNonFileNode (File *, uint32_t, uint32_t)
 
void unlinkNonFileNode (File *)
 
bool ensureCapacity (File *file, size_t size)
 
bool zeroRange (File *file, size_t begin, size_t end)
 
bool updateFileMetadata (File *file, size_t size)
 
bool syncFileMetadata (File *file)
 
uint64_t allocatedBlocks (File *file)
 
void * readDirectoryPortion (uint32_t clus) const
 
bool readDirectoryPortion (uint32_t clus, uintptr_t buffer) const
 
bool writeDirectoryPortion (uint32_t clus, void *p)
 
File * createFile (File *parentDir, const String &filename, uint32_t mask, bool bDirectory=false, uint32_t dirClus=0, bool publish=true)
 
bool releaseClusterChain (uint32_t clus, bool lockFile=true)
 
Dir * getDirectoryEntry (uint32_t clus, uint32_t offset) const
 
bool writeDirectoryEntry (Dir *dir, uint32_t clus, uint32_t offset)
 
bool isEof (uint32_t cluster) const
 
uint32_t eofValue () const
 
Time::Timestamp getUnixTimestamp (uint16_t time, uint16_t date) const
 
uint16_t getFatDate (Time::Timestamp timestamp) const
 
uint16_t getFatTime (Time::Timestamp timestamp) const
 
- Protected Member Functions inherited from Filesystem
virtual bool createLink (File *parent, const String &filename, File *target)
 
bool beginDeviceRemoval (bool deviceAvailable)
 

Protected Attributes

bool m_FsInfoInvalidated = false
 
uint64_t m_ChainRevision = 1
 
PendingAttributes * m_PendingAttributes = nullptr
 
Tree< uintptr_t, NodeState * > m_NodeStates
 
Tree< File *, NodeState * > m_NodeAliases
 
Mutex m_StateLock
 
Tree< uint64_t, FatFile::State * > m_FileStates
 
Tree< uint64_t, uintptr_t > m_FileIdentifiers
 
uintptr_t m_NextFileIdentifier = 0x10000000
 
FatFile::State * m_StateList = nullptr
 
bool m_IoFailed = false
 
bool m_ShutdownComplete = false
 
Mutex m_FileMutationLock
 
Superblock m_Superblock
 
Superblock16 m_Superblock16
 
Superblock32 m_Superblock32
 
FSInfo32 m_FsInfo
 
FatType m_Type
 
uint64_t m_DataAreaStart
 
uint32_t m_RootDirCount
 
uint16_t m_FatSector
 
union FatFilesystem::RootDirInfo m_RootDir
 
uint32_t m_BlockSize
 
uint32_t m_ClusterCount
 
uint8_t * m_pFatCache
 
UnlikelyLock m_FatLock
 
Mutex m_AllocationLock
 
File * m_pRoot
 
Tree< uintptr_t, uintptr_t > m_FatCache
 
Tree< uint32_t, bool > m_DirtyFatSectors
 
uint32_t m_FreeClusterHint
 
String m_VolumeLabel
 
- Protected Attributes inherited from Filesystem
bool m_bReadOnly
 
Disk * m_pDisk
 
DiskUse m_DiskUse
 
OperationBarrier m_Operations
 

Friends

class FatFile
 
class FatDirectory
 
class FatSymlink
 

Additional Inherited Members

- Public Types inherited from Filesystem
enum class  SyncStatus { Success , Unsupported , NoMemory , IoError }
 
typedef Filesystem *(* ProbeCallback) (Disk *)
 

Detailed Description

This class provides an implementation of the FAT filesystem.

Definition at line 37 of file FatFilesystem.h.

Constructor & Destructor Documentation

◆ FatFilesystem()

FatFilesystem::FatFilesystem ( )

Definition at line 58 of file FatFilesystem.cc.

◆ ~FatFilesystem()

FatFilesystem::~FatFilesystem ( )
override

Definition at line 82 of file FatFilesystem.cc.

Member Function Documentation

◆ acquireFileState()

FatFile::State * FatFilesystem::acquireFileState ( FatFile *  file,
uintptr_t  inode,
size_t  size,
uint32_t  cluster,
uint32_t  offset,
Time::Timestamp  accessed,
Time::Timestamp  modified,
Time::Timestamp  changed 
)
protected

Definition at line 75 of file FatFilesystem-state.cc.

◆ allocatedBlocks()

uint64_t FatFilesystem::allocatedBlocks ( File *  file)
protected

Definition at line 553 of file FatFilesystem.cc.

◆ cacheDirectoryContents()

void FatFilesystem::cacheDirectoryContents ( File *  pFile)

Definition at line 800 of file FatFilesystem.cc.

◆ cacheVolumeLabel()

void FatFilesystem::cacheVolumeLabel ( )
protected

Definition at line 268 of file FatFilesystem.cc.

◆ chainExtent()

bool FatFilesystem::chainExtent ( File *  file,
uint32_t &  count,
uint32_t &  last 
)
protected

Definition at line 12 of file FatFilesystem-chain.cc.

◆ clearPendingAttributes()

void FatFilesystem::clearPendingAttributes ( )
protected

Definition at line 221 of file FatFilesystem-attributes.cc.

◆ convertFilenameFrom()

String FatFilesystem::convertFilenameFrom ( String  filename) const
protected

Converts a string from 8.3 format

Definition at line 1063 of file FatFilesystem.cc.

◆ convertFilenameTo()

String FatFilesystem::convertFilenameTo ( String  filename) const
protected

Converts a string to 8.3 format

Todo:
This should increment if a file is found with the same name!

todo Increment on duplicate

Definition at line 980 of file FatFilesystem.cc.

◆ createDirectory()

bool FatFilesystem::createDirectory ( File *  parent,
const String &  filename,
uint32_t  mask 
)
overrideprotectedvirtual

createDirectory calls this after it has parsed the string path.

Implements Filesystem.

Definition at line 1159 of file FatFilesystem.cc.

References FatDirectory::addEntry(), createFile(), findFreeCluster(), Directory::fromFile(), Filesystem::m_bReadOnly, releaseClusterChain(), and setClusterEntry().

◆ createFile() [1/2]

bool FatFilesystem::createFile ( File *  parent,
const String &  filename,
uint32_t  mask 
)
overrideprotectedvirtual

createFile calls this after it has parsed the string path.

Implements Filesystem.

Definition at line 1154 of file FatFilesystem.cc.

References createFile().

Referenced by createDirectory(), and createFile().

+ Here is the caller graph for this function:

◆ createFile() [2/2]

File * FatFilesystem::createFile ( File *  parentDir,
const String &  filename,
uint32_t  mask,
bool  bDirectory = false,
uint32_t  dirClus = 0,
bool  publish = true 
)
protected

Creates a file - actual doer for the public createFile

Definition at line 1092 of file FatFilesystem.cc.

References FatDirectory::addEntry(), Directory::fromFile(), getClusterEntry(), File::isDirectory(), isEof(), m_BlockSize, Filesystem::m_bReadOnly, releaseClusterChain(), and writeCluster().

◆ createSymlink()

bool FatFilesystem::createSymlink ( File *  parent,
const String &  filename,
const String &  value 
)
overrideprotectedvirtual

createSymlink calls this after it has parsed the string path.

Implements Filesystem.

Definition at line 1197 of file FatFilesystem.cc.

References FatDirectory::addEntry(), findFreeCluster(), Directory::fromFile(), File::isDirectory(), Filesystem::m_bReadOnly, and releaseClusterChain().

◆ deviceRemoved()

bool FatFilesystem::deviceRemoved ( bool  deviceAvailable = false)
overridevirtual

Rejects backend operations and releases a removed device's ownership.

Reimplemented from Filesystem.

Definition at line 28 of file FatFilesystem-state.cc.

References Filesystem::deviceRemoved().

◆ discardPendingAttributes()

void FatFilesystem::discardPendingAttributes ( uint32_t  cluster,
uint32_t  offset 
)
protected

Definition at line 207 of file FatFilesystem-attributes.cc.

◆ drainFileStates()

bool FatFilesystem::drainFileStates ( bool  checked = false)
protected

Definition at line 287 of file FatFilesystem-state.cc.

◆ encodeEntryAttributes()

void FatFilesystem::encodeEntryAttributes ( const File::Attributes &  attributes,
Dir *  entry,
bool  creating = false 
)
protected

Definition at line 97 of file FatFilesystem-attributes.cc.

◆ ensureCapacity()

bool FatFilesystem::ensureCapacity ( File *  file,
size_t  size 
)
protected

Definition at line 568 of file FatFilesystem.cc.

◆ eofValue()

uint32_t FatFilesystem::eofValue ( ) const
inlineprotected

EOF values

Definition at line 212 of file FatFilesystem.h.

References m_Type.

Referenced by findFreeCluster(), and isEof().

+ Here is the caller graph for this function:

◆ extend()

void FatFilesystem::extend ( File *  pFile,
size_t  size 
)

Definition at line 128 of file FatFilesystem-resize.cc.

◆ fileAttributeChanged()

void FatFilesystem::fileAttributeChanged ( File *  pFile)

Definition at line 229 of file FatFilesystem-attributes.cc.

◆ fileClusterAt()

uint32_t FatFilesystem::fileClusterAt ( File *  file,
size_t  index 
)
protected

Definition at line 60 of file FatFilesystem-chain.cc.

◆ fileIdentifier()

uintptr_t FatFilesystem::fileIdentifier ( uint32_t  cluster,
uint32_t  offset 
)
protected

Definition at line 59 of file FatFilesystem-state.cc.

◆ fileIdentifierLocked()

uintptr_t FatFilesystem::fileIdentifierLocked ( uint64_t  slot)
protected

Definition at line 64 of file FatFilesystem-state.cc.

◆ findFreeCluster()

uint32_t FatFilesystem::findFreeCluster ( bool *  persisted = nullptr)
protected

Finds and reserves a free cluster.

Definition at line 446 of file FatFilesystem.cc.

References eofValue(), getClusterEntry(), m_AllocationLock, m_ClusterCount, m_FreeClusterHint, and setClusterEntry().

Referenced by createDirectory(), and createSymlink().

+ Here is the caller graph for this function:

◆ getClusterEntry()

uint32_t FatFilesystem::getClusterEntry ( uint32_t  cluster,
bool  bLock = true 
)
protected

Grabs a cluster entry - bLock determines if this should enforce locking internally or allow the caller to ensure the FAT is locked.

Definition at line 873 of file FatFilesystem.cc.

References UnlikelyLock::acquire(), m_FatLock, m_Superblock, m_Type, and UnlikelyLock::release().

Referenced by createFile(), findFreeCluster(), initialise(), and releaseClusterChain().

+ Here is the caller graph for this function:

◆ getDirectoryEntry()

Dir * FatFilesystem::getDirectoryEntry ( uint32_t  clus,
uint32_t  offset 
) const
protected

Reads a directory entry from disk

Definition at line 759 of file FatFilesystem.cc.

References m_BlockSize, m_Superblock, and readDirectoryPortion().

◆ getFatDate()

uint16_t FatFilesystem::getFatDate ( Time::Timestamp  timestamp) const
protected

Definition at line 61 of file FatFilesystem-attributes.cc.

◆ getFatSector()

uint8_t * FatFilesystem::getFatSector ( uint32_t  sector)
protected

Definition at line 859 of file FatFilesystem.cc.

◆ getFatTime()

uint16_t FatFilesystem::getFatTime ( Time::Timestamp  timestamp) const
protected

Definition at line 66 of file FatFilesystem-attributes.cc.

◆ getRoot()

File * FatFilesystem::getRoot ( ) const
overridevirtual

Returns the root filesystem node.

Implements Filesystem.

Definition at line 264 of file FatFilesystem.cc.

References m_pRoot.

◆ getSectorNumber()

uint32_t FatFilesystem::getSectorNumber ( uint32_t  cluster) const
protected

Obtains the first sector given a cluster number

Definition at line 855 of file FatFilesystem.cc.

References m_DataAreaStart, and m_Superblock.

Referenced by readCluster(), and writeCluster().

+ Here is the caller graph for this function:

◆ getUnixTimestamp()

Time::Timestamp FatFilesystem::getUnixTimestamp ( uint16_t  time,
uint16_t  date 
) const
protected

Definition at line 71 of file FatFilesystem-attributes.cc.

◆ getUuid()

bool FatFilesystem::getUuid ( String &  uuid) const
overridevirtual

Returns the canonical filesystem UUID when this filesystem has one.

Reimplemented from Filesystem.

Definition at line 49 of file FatFilesystem-attributes.cc.

References m_Type.

◆ getVolumeLabel()

const String & FatFilesystem::getVolumeLabel ( ) const
overridevirtual

Returns a string identifying the volume label.

Implements Filesystem.

Definition at line 338 of file FatFilesystem.cc.

References m_VolumeLabel.

◆ initialise()

bool FatFilesystem::initialise ( Disk *  pDisk)
overridevirtual

Populates this filesystem with data from the given Disk device.

Returns
true on success, false on failure.

Validate the BPB and check for FAT FS

Check the FAT FS itself, ensuring it's valid

Start loading actual FS info

Implements Filesystem.

Definition at line 96 of file FatFilesystem.cc.

References getClusterEntry(), Disk::getName(), m_BlockSize, m_ClusterCount, m_DataAreaStart, m_FatSector, m_FreeClusterHint, Filesystem::m_pDisk, m_pRoot, m_Superblock, m_Type, Disk::read(), readSectorBlock(), and Disk::unpin().

◆ invalidateFsInfoHints()

bool FatFilesystem::invalidateFsInfoHints ( )
protected

Definition at line 12 of file FatFilesystem-fsinfo.cc.

◆ isEof()

bool FatFilesystem::isEof ( uint32_t  cluster) const
inlineprotected

Is a given cluster VALUE EOF?

Definition at line 207 of file FatFilesystem.h.

References eofValue().

Referenced by createFile(), and releaseClusterChain().

+ Here is the caller graph for this function:

◆ isNodeUnlinked()

bool FatFilesystem::isNodeUnlinked ( File *  file) const
protected

Definition at line 150 of file FatFilesystem-state.cc.

◆ loadRootDir()

void FatFilesystem::loadRootDir ( )
protected

Definition at line 248 of file FatFilesystem.cc.

◆ moveNode()

void FatFilesystem::moveNode ( File *  file,
uint32_t  cluster,
uint32_t  offset 
)
protected

Definition at line 180 of file FatFilesystem-state.cc.

◆ moveNonFileNode()

void FatFilesystem::moveNonFileNode ( File *  file,
uint32_t  cluster,
uint32_t  offset 
)
protected

Definition at line 88 of file FatFilesystem-node-state.cc.

◆ movePendingAttributes()

void FatFilesystem::movePendingAttributes ( uint32_t  oldCluster,
uint32_t  oldOffset,
uint32_t  newCluster,
uint32_t  newOffset 
)
protected

Definition at line 192 of file FatFilesystem-attributes.cc.

◆ prepareFileShrink()

bool FatFilesystem::prepareFileShrink ( FatFile *  file,
size_t  size,
UniquePointer< File::PreparedShrink > &  prepared 
)
protected

Definition at line 32 of file FatFilesystem-resize.cc.

◆ probe()

Filesystem * FatFilesystem::probe ( Disk *  pDisk)
static

Definition at line 238 of file FatFilesystem.cc.

◆ publishSize()

void FatFilesystem::publishSize ( File *  file,
size_t  size 
)
protected

Definition at line 137 of file FatFilesystem-state.cc.

◆ read()

uint64_t FatFilesystem::read ( File *  pFile,
uint64_t  location,
uint64_t  size,
uintptr_t  buffer,
bool  bCanBlock = true 
)

Definition at line 344 of file FatFilesystem.cc.

◆ readCluster()

bool FatFilesystem::readCluster ( uint32_t  block,
uintptr_t  buffer 
) const
protected

Reads a cluster from the disk.

Definition at line 802 of file FatFilesystem.cc.

References getSectorNumber(), m_BlockSize, and readSectorBlock().

Referenced by readDirectoryPortion().

+ Here is the caller graph for this function:

◆ readDirectoryPortion() [1/2]

void * FatFilesystem::readDirectoryPortion ( uint32_t  clus) const
protected

Reads part of a directory into a buffer, returns the allocated buffer (which needs to be freed

Definition at line 712 of file FatFilesystem.cc.

References m_BlockSize, m_Superblock, m_Type, and readDirectoryPortion().

Referenced by getDirectoryEntry(), readDirectoryPortion(), and writeDirectoryEntry().

+ Here is the caller graph for this function:

◆ readDirectoryPortion() [2/2]

bool FatFilesystem::readDirectoryPortion ( uint32_t  clus,
uintptr_t  buffer 
) const
protected

Reads part of a directory into a caller-provided buffer.

Definition at line 726 of file FatFilesystem.cc.

References m_Superblock, m_Type, readCluster(), and readSectorBlock().

◆ readSectorBlock()

bool FatFilesystem::readSectorBlock ( uint32_t  sec,
size_t  size,
uintptr_t  buffer 
) const
protected

Reads a block starting from a specific sector from the disk.

Definition at line 807 of file FatFilesystem.cc.

References Filesystem::m_pDisk, m_Superblock, Disk::read(), and Disk::unpin().

Referenced by initialise(), readCluster(), and readDirectoryPortion().

+ Here is the caller graph for this function:

◆ registerNode()

void FatFilesystem::registerNode ( File *  file)
protected

Definition at line 13 of file FatFilesystem-node-state.cc.

◆ releaseClusterChain()

bool FatFilesystem::releaseClusterChain ( uint32_t  clus,
bool  lockFile = true 
)
protected

Releases a validated cluster chain as one allocation transaction.

Definition at line 1248 of file FatFilesystem.cc.

References getClusterEntry(), isEof(), m_AllocationLock, m_ClusterCount, m_FileMutationLock, and setClusterEntry().

Referenced by createDirectory(), createFile(), and createSymlink().

+ Here is the caller graph for this function:

◆ releaseFileState()

void FatFilesystem::releaseFileState ( FatFile *  file)
protected

Definition at line 102 of file FatFilesystem-state.cc.

◆ releaseNode()

void FatFilesystem::releaseNode ( File *  file)
protected

Definition at line 58 of file FatFilesystem-node-state.cc.

◆ removeNode()

bool FatFilesystem::removeNode ( File *  parent,
const String &  filename,
File *  file 
)
overrideprotectedvirtual

Remove a backing node while the VFS holds the parent's namespace lock. A successful implementation must retire the parent's cached entry before returning and must recheck directory emptiness while holding the child's namespace lock.

Implements Filesystem.

Definition at line 1285 of file FatFilesystem.cc.

References Directory::fromFile(), Directory::isDetached(), File::isDirectory(), Directory::isEmpty(), Filesystem::m_bReadOnly, FatDirectory::m_Lock, Directory::namespaceMutationLock(), and FatDirectory::removeEntry().

◆ renameNode()

bool FatFilesystem::renameNode ( Directory *  oldParent,
const String &  oldName,
File *  source,
Directory *  newParent,
const String &  newName,
File *  replaced 
)
overrideprotectedvirtual

Change backing entries while the VFS reserves both names and owns their namespace locks. Do not call ordinary lookup/add/remove APIs here. Failure must leave both names unchanged; the VFS publishes cache changes on success.

Reimplemented from Filesystem.

Definition at line 411 of file FatFilesystem-namespace.cc.

References File::isDirectory(), File::isSymlink(), m_FileMutationLock, and FatDirectory::m_Lock.

◆ retireNode()

void FatFilesystem::retireNode ( File *  file)
protected

Definition at line 208 of file FatFilesystem-state.cc.

◆ setClusterEntry()

bool FatFilesystem::setClusterEntry ( uint32_t  cluster,
uint32_t  value,
bool  bLock = true,
bool  persist = true 
)
protected

Sets a cluster entry - bLock determines if this should enforce locking internally or allow the caller to ensure the FAT is locked.

Definition at line 896 of file FatFilesystem.cc.

References UnlikelyLock::acquire(), Tree< K, E >::insert(), m_AllocationLock, m_ClusterCount, m_FatLock, m_Superblock, m_Type, and UnlikelyLock::release().

Referenced by createDirectory(), findFreeCluster(), and releaseClusterChain().

+ Here is the caller graph for this function:

◆ shutdown()

Filesystem::SyncStatus FatFilesystem::shutdown ( )
overridevirtual

After all users drain, finish teardown writes before backend destruction.

Reimplemented from Filesystem.

Definition at line 261 of file FatFilesystem-state.cc.

References FatFile::sync().

◆ sync()

Filesystem::SyncStatus FatFilesystem::sync ( )
overridevirtual

Completes data, metadata and device writeback for changes made before entry.

Reimplemented from Filesystem.

Definition at line 226 of file FatFilesystem-state.cc.

References Vector< T >::count(), Vector< T >::pushBack(), and Cache::syncAll().

◆ syncFat()

bool FatFilesystem::syncFat ( bool  bLock = true)
protected

Definition at line 933 of file FatFilesystem.cc.

◆ syncFileMetadata()

bool FatFilesystem::syncFileMetadata ( File *  file)
protected

Definition at line 697 of file FatFilesystem.cc.

◆ syncNode()

bool FatFilesystem::syncNode ( File *  file)
protected

Definition at line 273 of file FatFilesystem-attributes.cc.

◆ syncNodeAttributes()

bool FatFilesystem::syncNodeAttributes ( File *  file)
protected

Definition at line 129 of file FatFilesystem-attributes.cc.

◆ syncPendingAttributes()

bool FatFilesystem::syncPendingAttributes ( )
protected

Definition at line 174 of file FatFilesystem-attributes.cc.

◆ trimFileAllocation()

bool FatFilesystem::trimFileAllocation ( FatFile *  file)
protected

Definition at line 62 of file FatFilesystem-resize.cc.

◆ truncate()

void FatFilesystem::truncate ( File *  pFile)

Definition at line 120 of file FatFilesystem-resize.cc.

◆ truncateFile()

bool FatFilesystem::truncateFile ( File *  file)
protected

Definition at line 124 of file FatFilesystem-resize.cc.

◆ unlinkNode()

void FatFilesystem::unlinkNode ( File *  file)
protected

Definition at line 158 of file FatFilesystem-state.cc.

◆ unlinkNonFileNode()

void FatFilesystem::unlinkNonFileNode ( File *  file)
protected

Definition at line 112 of file FatFilesystem-node-state.cc.

◆ updateFileMetadata()

bool FatFilesystem::updateFileMetadata ( File *  file,
size_t  size 
)
protected

Definition at line 626 of file FatFilesystem.cc.

◆ write()

uint64_t FatFilesystem::write ( File *  pFile,
uint64_t  location,
uint64_t  size,
uintptr_t  buffer,
bool  bCanBlock = true 
)

Definition at line 485 of file FatFilesystem.cc.

◆ writeCachedPages()

bool FatFilesystem::writeCachedPages ( FatFile::State &  state,
const Cache::WritebackPage *  pages,
size_t  count 
)
protected

Definition at line 7 of file FatFilesystem-writeback.cc.

◆ writeCluster()

bool FatFilesystem::writeCluster ( uint32_t  block,
uintptr_t  buffer 
)
protected

Writes a cluster to the disk.

Definition at line 837 of file FatFilesystem.cc.

References getSectorNumber(), m_BlockSize, and writeSectorBlock().

Referenced by createFile(), and writeDirectoryPortion().

+ Here is the caller graph for this function:

◆ writeDirectoryEntry()

bool FatFilesystem::writeDirectoryEntry ( Dir *  dir,
uint32_t  clus,
uint32_t  offset 
)
protected

Writes a directry entry to disk

Definition at line 777 of file FatFilesystem.cc.

References m_BlockSize, m_Superblock, readDirectoryPortion(), and writeDirectoryPortion().

◆ writeDirectoryPortion()

bool FatFilesystem::writeDirectoryPortion ( uint32_t  clus,
void *  p 
)
protected

Writes part of a directory from a buffer

Definition at line 740 of file FatFilesystem.cc.

References m_BlockSize, m_Superblock, m_Type, writeCluster(), and writeSectorBlock().

Referenced by writeDirectoryEntry().

+ Here is the caller graph for this function:

◆ writeEntryAttributes()

void FatFilesystem::writeEntryAttributes ( File *  file,
Dir *  entry,
bool  creating = false 
)
protected

Definition at line 92 of file FatFilesystem-attributes.cc.

◆ writePendingAttributes()

bool FatFilesystem::writePendingAttributes ( const PendingAttributes &  pending)
protected

Definition at line 112 of file FatFilesystem-attributes.cc.

◆ writeSectorBlock()

bool FatFilesystem::writeSectorBlock ( uint32_t  sec,
size_t  size,
uintptr_t  buffer 
)
protected

Writes a block starting from a specific sector to the disk.

Definition at line 842 of file FatFilesystem.cc.

References Filesystem::m_pDisk, m_Superblock, and Disk::syncData().

Referenced by writeCluster(), and writeDirectoryPortion().

+ Here is the caller graph for this function:

◆ zeroRange()

bool FatFilesystem::zeroRange ( File *  file,
size_t  begin,
size_t  end 
)
protected

Definition at line 661 of file FatFilesystem.cc.

Friends And Related Symbol Documentation

◆ FatDirectory

friend class FatDirectory
friend

Definition at line 39 of file FatFilesystem.h.

◆ FatFile

friend class FatFile
friend

Definition at line 38 of file FatFilesystem.h.

◆ FatSymlink

friend class FatSymlink
friend

Definition at line 40 of file FatFilesystem.h.

Member Data Documentation

◆ m_AllocationLock

Mutex FatFilesystem::m_AllocationLock
protected

Serialises the scan-and-reserve transaction across the whole volume.

Definition at line 263 of file FatFilesystem.h.

Referenced by findFreeCluster(), releaseClusterChain(), and setClusterEntry().

◆ m_BlockSize

uint32_t FatFilesystem::m_BlockSize
protected

◆ m_ChainRevision

uint64_t FatFilesystem::m_ChainRevision = 1
protected

Definition at line 121 of file FatFilesystem.h.

◆ m_ClusterCount

uint32_t FatFilesystem::m_ClusterCount
protected

Number of addressable data clusters.

Definition at line 252 of file FatFilesystem.h.

Referenced by findFreeCluster(), initialise(), releaseClusterChain(), and setClusterEntry().

◆ m_DataAreaStart

uint64_t FatFilesystem::m_DataAreaStart
protected

Required information

Definition at line 236 of file FatFilesystem.h.

Referenced by getSectorNumber(), and initialise().

◆ m_DirtyFatSectors

Tree<uint32_t, bool> FatFilesystem::m_DirtyFatSectors
protected

Definition at line 272 of file FatFilesystem.h.

◆ m_FatCache

Tree<uintptr_t, uintptr_t> FatFilesystem::m_FatCache
protected

Definition at line 271 of file FatFilesystem.h.

◆ m_FatLock

UnlikelyLock FatFilesystem::m_FatLock
protected

FAT lock

Definition at line 259 of file FatFilesystem.h.

Referenced by getClusterEntry(), and setClusterEntry().

◆ m_FatSector

uint16_t FatFilesystem::m_FatSector
protected

FAT sector

Definition at line 240 of file FatFilesystem.h.

Referenced by initialise().

◆ m_FileIdentifiers

Tree<uint64_t, uintptr_t> FatFilesystem::m_FileIdentifiers
protected

Definition at line 169 of file FatFilesystem.h.

◆ m_FileMutationLock

Mutex FatFilesystem::m_FileMutationLock
protected

Serialises chain changes and attribute snapshots across file aliases.

Definition at line 181 of file FatFilesystem.h.

Referenced by FatFilesystem::ShrinkPlan::commit(), releaseClusterChain(), and renameNode().

◆ m_FileStates

Tree<uint64_t, FatFile::State*> FatFilesystem::m_FileStates
protected

Definition at line 168 of file FatFilesystem.h.

◆ m_FreeClusterHint

uint32_t FatFilesystem::m_FreeClusterHint
protected

Hint for the free cluster code, to avoid searching the ENTIRE FAT each time someone wants a free cluster (on non-FAT32 volumes).

Definition at line 278 of file FatFilesystem.h.

Referenced by findFreeCluster(), and initialise().

◆ m_FsInfo

FSInfo32 FatFilesystem::m_FsInfo
protected

Definition at line 230 of file FatFilesystem.h.

◆ m_FsInfoInvalidated

bool FatFilesystem::m_FsInfoInvalidated = false
protected

Definition at line 117 of file FatFilesystem.h.

◆ m_IoFailed

bool FatFilesystem::m_IoFailed = false
protected

Definition at line 172 of file FatFilesystem.h.

◆ m_NextFileIdentifier

uintptr_t FatFilesystem::m_NextFileIdentifier = 0x10000000
protected

Definition at line 170 of file FatFilesystem.h.

◆ m_NodeAliases

Tree<File*, NodeState*> FatFilesystem::m_NodeAliases
protected

Definition at line 162 of file FatFilesystem.h.

◆ m_NodeStates

Tree<uintptr_t, NodeState*> FatFilesystem::m_NodeStates
protected

Definition at line 161 of file FatFilesystem.h.

◆ m_PendingAttributes

PendingAttributes* FatFilesystem::m_PendingAttributes = nullptr
protected

Definition at line 140 of file FatFilesystem.h.

◆ m_pFatCache

uint8_t* FatFilesystem::m_pFatCache
protected

FAT cache

Definition at line 255 of file FatFilesystem.h.

◆ m_pRoot

File* FatFilesystem::m_pRoot
protected

Root filesystem node.

Definition at line 267 of file FatFilesystem.h.

Referenced by getRoot(), and initialise().

◆ m_RootDirCount

uint32_t FatFilesystem::m_RootDirCount
protected

Definition at line 237 of file FatFilesystem.h.

◆ m_ShutdownComplete

bool FatFilesystem::m_ShutdownComplete = false
protected

Definition at line 173 of file FatFilesystem.h.

◆ m_StateList

FatFile::State* FatFilesystem::m_StateList = nullptr
protected

Definition at line 171 of file FatFilesystem.h.

◆ m_StateLock

Mutex FatFilesystem::m_StateLock
protected

Definition at line 167 of file FatFilesystem.h.

◆ m_Superblock

Superblock FatFilesystem::m_Superblock
protected

◆ m_Superblock16

Superblock16 FatFilesystem::m_Superblock16
protected

Definition at line 228 of file FatFilesystem.h.

◆ m_Superblock32

Superblock32 FatFilesystem::m_Superblock32
protected

Definition at line 229 of file FatFilesystem.h.

◆ m_Type

FatType FatFilesystem::m_Type
protected

◆ m_VolumeLabel

String FatFilesystem::m_VolumeLabel
protected

Cached volume label for the filesystem.

Definition at line 281 of file FatFilesystem.h.

Referenced by getVolumeLabel().


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