|
The Pedigree Project 0.1
|
#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) |
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 *) |
This class provides an implementation of the FAT filesystem.
Definition at line 37 of file FatFilesystem.h.
| FatFilesystem::FatFilesystem | ( | ) |
Definition at line 58 of file FatFilesystem.cc.
|
override |
Definition at line 82 of file FatFilesystem.cc.
|
protected |
Definition at line 75 of file FatFilesystem-state.cc.
|
protected |
Definition at line 553 of file FatFilesystem.cc.
| void FatFilesystem::cacheDirectoryContents | ( | File * | pFile | ) |
Definition at line 800 of file FatFilesystem.cc.
|
protected |
Definition at line 268 of file FatFilesystem.cc.
|
protected |
Definition at line 12 of file FatFilesystem-chain.cc.
|
protected |
Definition at line 221 of file FatFilesystem-attributes.cc.
Converts a string from 8.3 format
Definition at line 1063 of file FatFilesystem.cc.
Converts a string to 8.3 format
todo Increment on duplicate
Definition at line 980 of file FatFilesystem.cc.
|
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().
|
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:
|
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().
|
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().
|
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().
|
protected |
Definition at line 207 of file FatFilesystem-attributes.cc.
|
protected |
Definition at line 287 of file FatFilesystem-state.cc.
|
protected |
Definition at line 97 of file FatFilesystem-attributes.cc.
|
protected |
Definition at line 568 of file FatFilesystem.cc.
|
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:| void FatFilesystem::extend | ( | File * | pFile, |
| size_t | size | ||
| ) |
Definition at line 128 of file FatFilesystem-resize.cc.
| void FatFilesystem::fileAttributeChanged | ( | File * | pFile | ) |
Definition at line 229 of file FatFilesystem-attributes.cc.
|
protected |
Definition at line 60 of file FatFilesystem-chain.cc.
|
protected |
Definition at line 59 of file FatFilesystem-state.cc.
|
protected |
Definition at line 64 of file FatFilesystem-state.cc.
|
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:
|
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:
|
protected |
Reads a directory entry from disk
Definition at line 759 of file FatFilesystem.cc.
References m_BlockSize, m_Superblock, and readDirectoryPortion().
|
protected |
Definition at line 61 of file FatFilesystem-attributes.cc.
|
protected |
Definition at line 859 of file FatFilesystem.cc.
|
protected |
Definition at line 66 of file FatFilesystem-attributes.cc.
|
overridevirtual |
Returns the root filesystem node.
Implements Filesystem.
Definition at line 264 of file FatFilesystem.cc.
References m_pRoot.
|
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:
|
protected |
Definition at line 71 of file FatFilesystem-attributes.cc.
|
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.
|
overridevirtual |
Returns a string identifying the volume label.
Implements Filesystem.
Definition at line 338 of file FatFilesystem.cc.
References m_VolumeLabel.
|
overridevirtual |
Populates this filesystem with data from the given Disk device.
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().
|
protected |
Definition at line 12 of file FatFilesystem-fsinfo.cc.
|
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:
|
protected |
Definition at line 150 of file FatFilesystem-state.cc.
|
protected |
Definition at line 248 of file FatFilesystem.cc.
|
protected |
Definition at line 180 of file FatFilesystem-state.cc.
|
protected |
Definition at line 88 of file FatFilesystem-node-state.cc.
|
protected |
Definition at line 192 of file FatFilesystem-attributes.cc.
|
protected |
Definition at line 32 of file FatFilesystem-resize.cc.
|
static |
Definition at line 238 of file FatFilesystem.cc.
|
protected |
Definition at line 137 of file FatFilesystem-state.cc.
| 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.
|
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:
|
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:
|
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().
|
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:
|
protected |
Definition at line 13 of file FatFilesystem-node-state.cc.
|
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:
|
protected |
Definition at line 102 of file FatFilesystem-state.cc.
|
protected |
Definition at line 58 of file FatFilesystem-node-state.cc.
|
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().
|
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.
|
protected |
Definition at line 208 of file FatFilesystem-state.cc.
|
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:
|
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().
|
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().
|
protected |
Definition at line 933 of file FatFilesystem.cc.
|
protected |
Definition at line 697 of file FatFilesystem.cc.
|
protected |
Definition at line 273 of file FatFilesystem-attributes.cc.
|
protected |
Definition at line 129 of file FatFilesystem-attributes.cc.
|
protected |
Definition at line 174 of file FatFilesystem-attributes.cc.
|
protected |
Definition at line 62 of file FatFilesystem-resize.cc.
| void FatFilesystem::truncate | ( | File * | pFile | ) |
Definition at line 120 of file FatFilesystem-resize.cc.
|
protected |
Definition at line 124 of file FatFilesystem-resize.cc.
|
protected |
Definition at line 158 of file FatFilesystem-state.cc.
|
protected |
Definition at line 112 of file FatFilesystem-node-state.cc.
|
protected |
Definition at line 626 of file FatFilesystem.cc.
| 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.
|
protected |
Definition at line 7 of file FatFilesystem-writeback.cc.
|
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:
|
protected |
Writes a directry entry to disk
Definition at line 777 of file FatFilesystem.cc.
References m_BlockSize, m_Superblock, readDirectoryPortion(), and writeDirectoryPortion().
|
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:
|
protected |
Definition at line 92 of file FatFilesystem-attributes.cc.
|
protected |
Definition at line 112 of file FatFilesystem-attributes.cc.
|
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:
|
protected |
Definition at line 661 of file FatFilesystem.cc.
|
friend |
Definition at line 39 of file FatFilesystem.h.
|
friend |
Definition at line 38 of file FatFilesystem.h.
|
friend |
Definition at line 40 of file FatFilesystem.h.
|
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().
|
protected |
Size of a block (in this case, a cluster)
Definition at line 249 of file FatFilesystem.h.
Referenced by createFile(), FatDirectory::FatDirectory(), getDirectoryEntry(), initialise(), readCluster(), readDirectoryPortion(), writeCluster(), writeDirectoryEntry(), and writeDirectoryPortion().
|
protected |
Definition at line 121 of file FatFilesystem.h.
|
protected |
Number of addressable data clusters.
Definition at line 252 of file FatFilesystem.h.
Referenced by findFreeCluster(), initialise(), releaseClusterChain(), and setClusterEntry().
|
protected |
Required information
Definition at line 236 of file FatFilesystem.h.
Referenced by getSectorNumber(), and initialise().
|
protected |
Definition at line 272 of file FatFilesystem.h.
|
protected |
Definition at line 271 of file FatFilesystem.h.
|
protected |
FAT lock
Definition at line 259 of file FatFilesystem.h.
Referenced by getClusterEntry(), and setClusterEntry().
|
protected |
|
protected |
Definition at line 169 of file FatFilesystem.h.
|
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().
|
protected |
Definition at line 168 of file FatFilesystem.h.
|
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().
|
protected |
Definition at line 230 of file FatFilesystem.h.
|
protected |
Definition at line 117 of file FatFilesystem.h.
|
protected |
Definition at line 172 of file FatFilesystem.h.
|
protected |
Definition at line 170 of file FatFilesystem.h.
Definition at line 162 of file FatFilesystem.h.
Definition at line 161 of file FatFilesystem.h.
|
protected |
Definition at line 140 of file FatFilesystem.h.
|
protected |
FAT cache
Definition at line 255 of file FatFilesystem.h.
|
protected |
Root filesystem node.
Definition at line 267 of file FatFilesystem.h.
Referenced by getRoot(), and initialise().
|
protected |
Definition at line 237 of file FatFilesystem.h.
|
protected |
Definition at line 173 of file FatFilesystem.h.
|
protected |
Definition at line 171 of file FatFilesystem.h.
|
protected |
Definition at line 167 of file FatFilesystem.h.
|
protected |
Our superblocks
Definition at line 227 of file FatFilesystem.h.
Referenced by getClusterEntry(), getDirectoryEntry(), getSectorNumber(), initialise(), readDirectoryPortion(), readDirectoryPortion(), readSectorBlock(), setClusterEntry(), FatDirectory::setInode(), writeDirectoryEntry(), writeDirectoryPortion(), and writeSectorBlock().
|
protected |
Definition at line 228 of file FatFilesystem.h.
|
protected |
Definition at line 229 of file FatFilesystem.h.
|
protected |
Type of the FAT
Definition at line 233 of file FatFilesystem.h.
Referenced by eofValue(), FatDirectory::FatDirectory(), getClusterEntry(), getUuid(), initialise(), readDirectoryPortion(), readDirectoryPortion(), setClusterEntry(), FatDirectory::setInode(), and writeDirectoryPortion().
|
protected |
Cached volume label for the filesystem.
Definition at line 281 of file FatFilesystem.h.
Referenced by getVolumeLabel().