|
The Pedigree Project 0.1
|
#include <File.h>
Inheritance diagram for File:
Collaboration diagram for File:Classes | |
| struct | Attributes |
| struct | CacheState |
| class | DataCacheKey |
| struct | MonitorTarget |
| class | ParentLease |
| class | PreparedShrink |
| struct | ReadPage |
| struct | ShrinkContext |
| class | WriteGuard |
Public Types | |
| 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 | |
| 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 | isDirectory () |
| 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 Attributes | |
| static constexpr size_t | MaxReadPages = 32 |
Protected Member Functions | |
| 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 bool | isBytewise () const |
| 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 () |
Static Protected Member Functions | |
| 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 | |
| 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 |
Private Member Functions | |
| File (const File &file) | |
| File & | operator= (const File &) |
| void | publishWriteMetadata () |
| uint64_t | writeUnlocked (uint64_t location, uint64_t size, uintptr_t buffer, bool bCanBlock) |
| uintptr_t | getCachedPage (size_t block, bool locked=true) |
| void | setCachedPage (size_t block, uintptr_t value, bool locked=true) |
| uintptr_t | readIntoCache (uintptr_t block, bool overwriteWholePage=false, size_t readAheadBytes=0) |
| size_t | populateRangeLocked (size_t offset, size_t length) |
| void | releaseReadReference (uintptr_t block) |
Friends | |
| class | Filesystem |
| class | Directory |
|
private |
Copy constructors are hidden - unused!
| 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 | ||
| ) |
Constructor, should be called only by a Filesystem.
Definition at line 188 of file File.cc.
References getBlockSize(), and setCachedPage().
|
virtual |
Destructor - doesn't do anything.
Definition at line 221 of file File.cc.
References ReadinessSource::closeReadiness(), VFS::instance(), m_pDetachedParent, and VFS::untrackFile().
|
protectedvirtual |
Returns an existing block's exact address with one caller-owned reference, or zero without a reference. The aligned byte location must be released with one unpinBlock(). No backend population occurs on a miss. retryChanged retries when the File index changes while acquiring the pin.
Reimplemented in RamFile.
Definition at line 1419 of file File.cc.
References getBlockSize(), getCachedPage(), pinBlock(), and unpinBlock().
Referenced by getPhysicalPage(), and readIntoCache().
Here is the caller graph for this function:| bool File::acquireMappingUse | ( | bool | executable, |
| bool | sharedWrite | ||
| ) |
Exclude backing mutations while executable bytes can still be faulted in.
Definition at line 1181 of file File.cc.
Referenced by PosixSubsystem::prepareExecutable(), and MemoryMappedFile::setPermissions().
Here is the caller graph for this function:
|
protectedvirtual |
Called with write/data locks held; must reserve and zero newly allocated storage.
Reimplemented in Ext2File, and RamFile.
Definition at line 72 of file File-allocation.cc.
Referenced by allocateRange().
Here is the caller graph for this function:| bool File::allocateRange | ( | size_t | offset, |
| size_t | length, | ||
| bool | keepSize = false |
||
| ) |
Reserve backing storage, optionally extending EOF after reservation succeeds.
Definition at line 10 of file File-allocation.cc.
References allocateFileRange(), PhysicalMemoryManager::getPageSize(), isDirectory(), Filesystem::isReadOnly(), Cache::lookup(), Cache::markDirty(), maximumFileSize(), publishEvent(), Cache::release(), supportsRegularFileOperations(), and useFillCache().
|
virtual |
|
inlineprotectedvirtual |
|
protectedvirtual |
| uint64_t File::append | ( | uint64_t | size, |
| uintptr_t | buffer, | ||
| uint64_t & | location, | ||
| bool | bCanBlock = true |
||
| ) |
Atomically selects EOF and performs one append write.
Definition at line 415 of file File.cc.
References lockWrites().
Referenced by FileDescriptor::write().
Here is the caller graph for this function:
|
protectedvirtual |
|
protectedvirtual |
|
protected |
|
virtual |
Handle a command.
Reimplemented in RtcFile, FramebufferFile, RandomFile, and EvdevFile.
| void File::cullMonitorTargets | ( | Event * | pEvent | ) |
| void File::cullMonitorTargets | ( | Thread * | pThread | ) |
|
protected |
Internal function to notify all registered MonitorTargets.
Definition at line 1452 of file File.cc.
References EMIT_IF, Scheduler::instance(), ReadinessSource::notifyReadiness(), Thread::sendEvent(), and Scheduler::yield().
Referenced by Pipe::decreaseRefCount(), UnixSocket::sendDatagram(), and TextIO::writeStr().
Here is the caller graph for this function:
|
virtual |
| void File::disableDirect | ( | ) |
| void File::enableDirect | ( | ) |
|
protected |
Installs and drains the native-page fill-cache callback.
Definition at line 1763 of file File.cc.
References Cache::setCallback().
Referenced by Iso9660File::Iso9660File().
Here is the caller graph for this function:
|
protected |
Removes the given location from the VFS-level File cache.
Each File offers read() and write(), which in turn call readBlock. The result from readBlock is cached at the File object level in such a way that requires notification from the File subclass when the address returned from readBlock is no longer valid.
Definition at line 1436 of file File.cc.
References getBlockSize(), and setCachedPage().
|
protectedvirtual |
|
protectedvirtual |
Does the same thing as extend() but with an optional hint indicating that the upcoming write will fill an entire block. This hint can be used to do things like avoid zeroing the block that would otherwise be written over anyway.
Reimplemented in Ext2File, and FatFile.
Definition at line 1411 of file File.cc.
References extend().
|
virtual |
Reimplemented in Ext2Symlink, Ext2Directory, Ext2File, and FatDirectory.
|
staticprotected |
|
virtual |
Stable backing token; aliases of one backing object must share it.
Reimplemented in Ext2File, and FatFile.
Definition at line 75 of file File.cc.
Referenced by Ext2File::Ext2File(), MemoryMapManager::hasSharedWriteCapability(), and MemoryMapManager::prepareFileResize().
Here is the caller graph for this function:| Time::Timestamp File::getAccessedTime | ( | ) |
|
virtual |
|
virtual |
Function to retrieve the block size returned by readBlock.
Reimplemented in ConsoleFile, RawFsFile, Ext2File, and Iso9660File.
Definition at line 1077 of file File.cc.
References PhysicalMemoryManager::getPageSize().
Referenced by acquireCachedBlock(), RamFile::allocateFileRange(), RamFile::ShrinkPlan::commit(), evict(), FatFile::extend(), File(), getPhysicalPage(), FatFile::pinBlock(), read(), FatFile::readBlock(), RamFile::readBlock(), readIntoCache(), readPage(), FatFile::readPage(), releaseReadReference(), resize(), returnPhysicalPage(), FatFile::sync(), FatFile::syncPages(), syncRange(), FatFile::unpinBlock(), useFillCache(), FatFile::writeBlock(), writeBlocks(), writeCallback(), and writeUnlocked().
Here is the caller graph for this function:
|
private |
Retrieve a page from our cache.
Definition at line 1586 of file File.cc.
Referenced by acquireCachedBlock(), and syncRange().
Here is the caller graph for this function:| Time::Timestamp File::getCreationTime | ( | ) |
|
virtual |
Kernel buffers only. Capacity zero queries size without touching output; successful mutations update ctime and publish one Attributes event.
Reimplemented in Ext2Symlink, Ext2Directory, Ext2File, RamFile, and RamDir.
| Filesystem * File::getFilesystem | ( | ) | const |
|
protected |
Internal function to get the filesystem label for this file.
Definition at line 1531 of file File.cc.
References Filesystem::getVolumeLabel().
|
virtual |
Obtains the full path of the File and returns it.
Definition at line 1580 of file File.cc.
References getFullPath().
|
virtual |
Obtains the full path of the File in the root namespace.
Definition at line 1535 of file File.cc.
References getNamespace(), and VFS::instance().
Referenced by Filesystem::findNode(), getFullPath(), PosixSubsystem::parseShebang(), and readBlock().
Here is the caller graph for this function:| Time::Timestamp File::getModifiedTime | ( | ) |
| String File::getName | ( | ) | const |
Returns the name of the file.
Definition at line 782 of file File.cc.
Referenced by RawFsDir::addEntry(), FatDirectory::addEntry(), Directory::addEphemeralFile(), DevFs::initialise(), ProcFs::initialise(), PosixSubsystem::invoke(), Pipe::isFifo(), Pipe::isPipe(), PosixSubsystem::loadElf(), DynamicLinker::loadObject(), DynamicLinker::loadProgram(), InputFile::open(), EvdevFile::open(), VirtualTerminalManager::openInactive(), Filesystem::remove(), and RawFsDir::removeRecursive().
Here is the caller graph for this function:| void File::getNamespace | ( | ParentLease & | parent, |
| String & | name | ||
| ) | const |
Snapshot a name and retain its parent across concurrent namespace moves.
Definition at line 992 of file File.cc.
Referenced by Filesystem::findNode(), Symlink::followLinkRetained(), getFullPath(), and Directory::lookupChildAt().
Here is the caller graph for this function:
|
virtual |
Get the physical address for the given offset into the file. Returns (physical_uintptr_t) ~0 if the offset isn't in the cache.
Reimplemented in FramebufferFile, and MemFile.
Definition at line 486 of file File.cc.
References acquireCachedBlock(), EMIT_IF, getBlockSize(), VirtualAddressSpace::getMapping(), PhysicalMemoryManager::getPageSize(), ProcessorBase::information(), VirtualAddressSpace::isMapped(), LIKELY, Cache::lookup(), Cache::release(), UNLIKELY, unpinBlock(), and useFillCache().
Referenced by MemoryMappedFile::clone().
Here is the caller graph for this function:
|
protectedvirtual |
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 in RandomFile, NullFile, ZeroFile, SerialFile, PtmxFile, RtcFile, Tty0File, MeminfoFile, PciDevicesFile, MountFile, UptimeFile, ConstantFile, PsAuxFile, UnixSocket, ConsoleFile, TextIO, Directory, Pipe, Symlink, InputFile, and EvdevFile.
Definition at line 1365 of file File.cc.
Referenced by populateRange(), read(), readBytewise(), readCached(), supportsRegularFileOperations(), writeBytewise(), and writeUnlocked().
Here is the caller graph for this function:
|
virtual |
Returns true if the File is actually a directory.
Reimplemented in Directory.
Definition at line 804 of file File.cc.
Referenced by Ext2Directory::addEntry(), FatDirectory::addEntry(), allocateRange(), UnixSocketSyscalls::bind(), RamFs::createDirectory(), RamFs::createFile(), FatFilesystem::createFile(), Ext2Filesystem::createLink(), RamFs::createLink(), Ext2Filesystem::createNode(), FatFilesystem::createSymlink(), RamFs::createSymlink(), Filesystem::findNode(), Filesystem::findParent(), Directory::fromFile(), publishEvent(), Filesystem::removeChild(), VFS::removeDiskFilesystem(), Directory::removeEphemeralFiles(), VFS::removeEphemeralFiles(), UnixFilesystem::removeNode(), Ext2Filesystem::removeNode(), FatFilesystem::removeNode(), RamFs::removeNode(), Ext2Filesystem::renameNode(), FatFilesystem::renameNode(), resize(), supportsRegularFileOperations(), and VFS::unregisterFilesystem().
Here is the caller graph for this function:
|
inlinevirtual |
|
virtual |
Returns true if the File is actually a fifo.
Reimplemented in Pipe.
Definition at line 812 of file File.cc.
Referenced by Pipe::fromFile(), and supportsRegularFileOperations().
Here is the caller graph for this function:
|
virtual |
Returns true if the File is actually a pipe.
Reimplemented in Pipe.
Definition at line 808 of file File.cc.
Referenced by Pipe::fromFile(), and supportsRegularFileOperations().
Here is the caller graph for this function:
|
virtual |
Whether ordinary reads and writes consume a persistent byte offset.
Reimplemented in UnixSocket, ConsoleFile, TextIO, Pipe, InputFile, and EvdevFile.
Definition at line 820 of file File.cc.
Referenced by supportsRegularFileOperations().
Here is the caller graph for this function:
|
virtual |
Returns true if the File is actually a socket.
Reimplemented in UnixSocket.
Definition at line 816 of file File.cc.
Referenced by supportsRegularFileOperations().
Here is the caller graph for this function:
|
virtual |
Whether this untracked File is the externally owned filesystem root.
Definition at line 918 of file File.cc.
References Filesystem::getRoot().
|
virtual |
Returns true if the File is actually a symlink.
Reimplemented in Symlink.
Definition at line 800 of file File.cc.
Referenced by Ext2Filesystem::createLink(), RamFs::createLink(), Ext2Filesystem::createNode(), Filesystem::findNode(), Symlink::fromFile(), DynamicLinker::loadObject(), DynamicLinker::loadProgram(), Ext2Filesystem::removeNode(), RamFs::removeNode(), Ext2Filesystem::renameNode(), FatFilesystem::renameNode(), and supportsRegularFileOperations().
Here is the caller graph for this function:
|
virtual |
| File::WriteGuard File::lockWrites | ( | ) |
| void File::markPageExternallyWritable | ( | size_t | offset | ) |
Mark an already borrowed page before exposing a writable shared mapping.
Definition at line 1611 of file File.cc.
References PhysicalMemoryManager::getPageSize(), Cache::markExternallyWritable(), and useFillCache().
Referenced by MemoryMappedFile::setPermissions(), and MemoryMappedFile::trap().
Here is the caller graph for this function:
|
virtual |
Maximum byte length supported by the backing, independent of free space.
Reimplemented in Ext2File, and FatFile.
Definition at line 829 of file File.cc.
Referenced by allocateRange().
Here is the caller graph for this function:Causes the event pEvent to be dispatched to pThread when activity occurs on this File. Activity includes the file becoming available for reading, writing or erroring.
Definition at line 1482 of file File.cc.
References EMIT_IF, and Event::tryAcquireRegistration().
|
virtual |
Obtain the actual File object to use when opening this file.
This allows a File to exist and perform logic on an open() before returning either itself or some other File object. Some files require side effects as part of their opening, this facilitates that.
Reimplemented in PtmxFile, Tty0File, InputFile, and EvdevFile.
Definition at line 1357 of file File.cc.
Referenced by openForDescriptor().
Here is the caller graph for this function:
|
virtual |
|
protectedvirtual |
Pins the given page.
If your File subclass uses a Cache for readBlock, this method should be implemented to call Cache::pin. The VFS layer calls this method when it determines it is about to give a physical page to an upper layer, and therefore will be unable to guarantee the virtual page's dirty status is a correct reflection of the page's state.
Returns true only when the page currently published for location is held until the matching unpinBlock(). The base implementation returns false so a cache-backed subclass cannot silently claim unsafe pages.
Reimplemented in RawFsFile, Ext2File, FatFile, Iso9660File, and RamFile.
Definition at line 1415 of file File.cc.
Referenced by acquireCachedBlock(), and syncRange().
Here is the caller graph for this function:| size_t File::populateRange | ( | size_t | offset, |
| size_t | length | ||
| ) |
Populate at most MaxReadPages and return the ready prefix from offset. Existing demand pages return immediately; later fill failures leave successfully populated pages available for subsequent demands.
Definition at line 1618 of file File.cc.
References PhysicalMemoryManager::getPageSize(), isBytewise(), read(), and useFillCache().
|
private |
|
virtual |
|
virtual |
Prepare backing storage before a writable shared mapping is published.
Reimplemented in Ext2File, and Iso9660File.
Definition at line 1143 of file File.cc.
Referenced by MemoryMappedFile::trap().
Here is the caller graph for this function:
|
protectedvirtual |
|
protectedvirtual |
| void File::publishEvent | ( | FileEventMask | mask, |
| const StringView & | name = StringView(), |
||
| bool | targetIsDirectory = false |
||
| ) |
Publish a completed VFS operation to payload event subscribers.
Definition at line 861 of file File.cc.
References FileEventSource::anyFileEventObservers(), Process::getId(), Thread::getParent(), ProcessorBase::information(), isDirectory(), FileEventSource::notifyFileEvent(), FileEventSource::notifyFinalFileEvent(), and String::view().
Referenced by Ext2Directory::addEntry(), FatDirectory::addEntry(), allocateRange(), Filesystem::removeChild(), resize(), setAccessedTime(), setCreationTime(), and setModifiedTime().
Here is the caller graph for this function:
|
protectedvirtual |
|
virtual |
Return the current readiness state for this open endpoint.
Reimplemented in ConsoleFile, ConsolePhysicalFile, and Pipe.
Definition at line 1054 of file File.cc.
References select().
Referenced by ConsolePhysicalFile::queryReady().
Here is the caller graph for this function:
|
finalvirtual |
Reads from the file.
| [in] | buffer | Buffer to write the read data into. Can be null, in which case the data can be found by calling getPhysicalPage. |
| [in] | bCanBlock | Whether or not the File can block when reading |
Definition at line 239 of file File.cc.
References getBlockSize(), PhysicalMemoryManager::getPageSize(), isBytewise(), read(), Cache::read(), readBytewise(), readIntoCache(), releaseReadReference(), and useFillCache().
Referenced by Symlink::initialise(), PosixSubsystem::invoke(), PosixSubsystem::parseShebang(), populateRange(), PosixSubsystem::prepareExecutable(), FileDisk::read(), read(), FileDescriptor::read(), readCached(), and MemoryMappedFile::trap().
Here is the caller graph for this function:
|
protectedvirtual |
Retrieves an aligned block with one caller-owned lifetime reference.
Every successful call must be balanced by exactly one unpinBlock() at the same location. Cache-backed implementations must acquire a reference in addition to the cache entry's publication reference on both hit and miss paths.
Reimplemented in FramebufferFile, RawFsFile, Ext2File, FatFile, Iso9660File, and RamFile.
Definition at line 1383 of file File.cc.
References getFullPath().
Referenced by readIntoCache(), and readPage().
Here is the caller graph for this function:
|
protectedvirtual |
Reads bytes from the file, if isBytewise() == true.
Reimplemented in RandomFile, NullFile, ZeroFile, SerialFile, PtmxFile, RtcFile, Tty0File, MeminfoFile, PciDevicesFile, MountFile, UptimeFile, ConstantFile, PsAuxFile, UnixSocket, ConsoleMasterFile, ConsoleSlaveFile, ConsolePhysicalFile, TextIO, Pipe, InputFile, EvdevFile, FatSymlink, and Ext2Symlink.
Definition at line 1369 of file File.cc.
References isBytewise().
Referenced by read().
Here is the caller graph for this function:| size_t File::readCached | ( | uint64_t | location, |
| size_t | size, | ||
| uintptr_t | buffer, | ||
| bool(*)(uintptr_t, size_t) | prepare = nullptr |
||
| ) |
Copies a bounded resident prefix without backend I/O. The destination must remain writable throughout the call. prepare runs under dataMutationLock; callers must acquire any outer mapping guard before entering.
Definition at line 319 of file File.cc.
References isBytewise(), read(), Cache::read(), and useFillCache().
Referenced by PosixSubsystem::readCachedFile().
Here is the caller graph for this function:
|
private |
Reads the given cache block and returns one per-use reference.
The block index does not own this reference.
Definition at line 1790 of file File.cc.
References acquireCachedBlock(), LockGuard< T >::disown(), getBlockSize(), PhysicalMemoryManager::getPageSize(), Cache::insert(), Cache::lookup(), Cache::markNoLongerEditing(), readBlock(), readIntoCache(), readPage(), Semaphore::release(), Cache::release(), setCachedPage(), and useFillCache().
Referenced by read(), readIntoCache(), and writeUnlocked().
Here is the caller graph for this function:
|
protectedvirtual |
Fill a caller-owned native page, including zeroes for holes and the EOF tail.
Reimplemented in Ext2File, FatFile, and Iso9660File.
Definition at line 1727 of file File.cc.
References getBlockSize(), PhysicalMemoryManager::getPageSize(), readBlock(), and unpinBlock().
Referenced by readIntoCache(), and readPages().
Here is the caller graph for this function:
|
protectedvirtual |
All destination accesses finish before return; complete identifies each fully initialised page even when another page in the batch failed.
Reimplemented in Ext2File.
Definition at line 1716 of file File.cc.
References readPage().
| void File::releaseMappingUse | ( | bool | executable, |
| bool | sharedWrite | ||
| ) |
|
private |
Releases the per-use reference returned by readIntoCache().
Definition at line 1892 of file File.cc.
References getBlockSize(), PhysicalMemoryManager::getPageSize(), Cache::release(), unpinBlock(), and useFillCache().
Referenced by read(), and writeUnlocked().
Here is the caller graph for this function:
|
virtual |
Releases a reference acquired by retainVfsReference().
Reimplemented in InputFile, EvdevFile, and Pipe.
Definition at line 914 of file File.cc.
References VFS::instance(), and VFS::untrackFile().
Referenced by UnixSocketSyscalls::bind(), InputFile::releaseVfsReference(), EvdevFile::releaseVfsReference(), Pipe::releaseVfsReference(), and Process::setCtty().
Here is the caller graph for this function:
|
virtual |
| bool File::resize | ( | size_t | size | ) |
Resize a regular file without changing any open description's position.
Definition at line 1213 of file File.cc.
References getBlockSize(), PhysicalMemoryManager::getPageSize(), MemoryMapManager::instance(), isDirectory(), Filesystem::isReadOnly(), Cache::lookup(), Cache::markDirty(), Cache::prepareDiscardFrom(), MemoryMapManager::prepareFileResize(), publishEvent(), Cache::release(), supportsRegularFileOperations(), and useFillCache().
Referenced by Ext2File::truncate(), FatFile::truncate(), and RamFile::truncate().
Here is the caller graph for this function:
|
protected |
Keep the former parent alive after this node leaves its namespace.
Definition at line 1025 of file File.cc.
References Filesystem::getRoot(), VFS::instance(), and m_pDetachedParent.
|
virtual |
Attempts to retain this File through its existing VFS ownership record. Untracked filesystem roots remain borrowed and return false. Virtual dispatch lets kernel-owned contexts use the loadable VFS lifetime model without creating a kernel-to-module link dependency.
Reimplemented in InputFile, EvdevFile, and Pipe.
Definition at line 910 of file File.cc.
References VFS::instance(), and VFS::retainTrackedFile().
Referenced by InputFile::retainVfsReference(), EvdevFile::retainVfsReference(), Pipe::retainVfsReference(), and Process::setCtty().
Here is the caller graph for this function:
|
virtual |
Specifies that the system is done with the physical page retrieved from getPhysicalPage now. Allows the physical page to be evicted from the file cache again.
Reimplemented in MemFile, and FramebufferFile.
Definition at line 557 of file File.cc.
References getBlockSize(), PhysicalMemoryManager::getPageSize(), Cache::release(), UNLIKELY, unpinBlock(), and useFillCache().
Referenced by MemoryMappedFile::compact(), MemoryMappedFile::remove(), syncAndReturnPhysicalPage(), and MemoryMappedFile::trap().
Here is the caller graph for this function:
|
virtual |
Similar to POSIX's select() function
Reimplemented in ConsoleFile, ConsolePhysicalFile, SerialFile, PsAuxFile, UnixSocket, TextIO, Pipe, InputFile, and EvdevFile.
Definition at line 1050 of file File.cc.
Referenced by queryReady(), and ConsolePhysicalFile::select().
Here is the caller graph for this function:| void File::setAccessedTime | ( | Time::Timestamp | t | ) |
Sets the time the file was last accessed.
Definition at line 740 of file File.cc.
References publishEvent().
Referenced by Ext2Filesystem::createNode().
Here is the caller graph for this function:
|
private |
Set a page in our cache.
Definition at line 1598 of file File.cc.
Referenced by evict(), File(), readIntoCache(), and writeCallback().
Here is the caller graph for this function:| void File::setCreationTime | ( | Time::Timestamp | t | ) |
Sets the time the file was created.
Definition at line 725 of file File.cc.
References publishEvent().
Referenced by RamFs::createLink(), and RamFs::removeNode().
Here is the caller graph for this function:
|
virtual |
| void File::setFilesystem | ( | Filesystem * | pFs | ) |
|
protected |
Set GID without raising fileAttributeChanged.
Definition at line 1448 of file File.cc.
Referenced by Ext2Directory::Ext2Directory(), Ext2File::Ext2File(), Ext2Symlink::Ext2Symlink(), and FatDirectory::FatDirectory().
Here is the caller graph for this function:
|
virtual |
Reimplemented in FatDirectory.
| void File::setModifiedTime | ( | Time::Timestamp | t | ) |
Sets the time the file was last modified.
Definition at line 771 of file File.cc.
References publishEvent().
Referenced by Ext2Filesystem::createNode().
Here is the caller graph for this function:| bool File::setOwnership | ( | size_t | uid, |
| size_t | gid, | ||
| bool | changeUid, | ||
| bool | changeGid | ||
| ) |
|
protected |
Set permissions without raising fileAttributeChanged.
Definition at line 1440 of file File.cc.
Referenced by Ext2Directory::Ext2Directory(), Ext2File::Ext2File(), Ext2Symlink::Ext2Symlink(), FatDirectory::FatDirectory(), and FatFile::FatFile().
Here is the caller graph for this function:
|
inlineprotected |
| void File::setTimes | ( | Time::Timestamp | accessed, |
| Time::Timestamp | modified, | ||
| bool | changeAccessed, | ||
| bool | changeModified | ||
| ) |
|
protected |
Set UID without raising fileAttributeChanged.
Definition at line 1444 of file File.cc.
Referenced by Ext2Directory::Ext2Directory(), Ext2File::Ext2File(), Ext2Symlink::Ext2Symlink(), and FatDirectory::FatDirectory().
Here is the caller graph for this function:
|
protected |
|
virtual |
|
virtual |
Does this File object support the given integer-based command?
Reimplemented in RtcFile, FramebufferFile, RandomFile, and EvdevFile.
|
virtual |
Whether readiness transitions are reported through ReadinessSource.
Reimplemented in InputFile, EvdevFile, ConsoleFile, ConsolePhysicalFile, and Pipe.
Definition at line 1065 of file File.cc.
Referenced by EpollInstance::control().
Here is the caller graph for this function:| bool File::supportsRegularFileOperations | ( | ) |
Whether the backing supports ordinary file range operations.
Definition at line 824 of file File.cc.
References isBytewise(), isDirectory(), isFifo(), isPipe(), isSeekable(), isSocket(), and isSymlink().
Referenced by allocateRange(), Ext2Filesystem::encodeFileHandle(), PosixSubsystem::readCachedFile(), and resize().
Here is the caller graph for this function:
|
virtual |
Sync all cached pages for the file back to disk.
Returns false if any cached page cannot be synchronised. Successful pages remain written when another page fails.
Reimplemented in RawFsFile, Ext2Directory, Ext2File, FatDirectory, FatFile, and FatSymlink.
Definition at line 595 of file File.cc.
References syncRange().
Referenced by MemoryMappedFile::compact(), Ext2File::sync(), MemoryMappedFile::sync(), syncAndReturnPhysicalPage(), syncPages(), and MemoryMappedFile::syncRange().
Here is the caller graph for this function:
|
virtual |
Trigger a sync of an inner cache back to disk and report completion (or queue admission for an asynchronous request).
Reimplemented in RawFsFile, Ext2File, FatFile, FatDirectory, and FatSymlink.
| bool File::syncAndReturnPhysicalPage | ( | size_t | offset, |
| bool | async | ||
| ) |
Syncs a mapped page before releasing its backing-cache reference.
Definition at line 581 of file File.cc.
References returnPhysicalPage(), and sync().
Referenced by MemoryMappedFile::remove().
Here is the caller graph for this function:
|
protected |
Reports writeback success separately from an absent fill page.
Definition at line 1771 of file File.cc.
References PhysicalMemoryManager::getPageSize(), Cache::lookup(), Cache::release(), and Cache::sync().
Referenced by Ext2File::sync().
Here is the caller graph for this function:
|
virtual |
Persists a bounded group of offsets whose producer pages remain pinned.
Reimplemented in Ext2File, and FatFile.
Definition at line 688 of file File.cc.
References sync().
Referenced by syncRange(), and MemoryMappedFile::syncRange().
Here is the caller graph for this function:| bool File::syncRange | ( | size_t | offset, |
| size_t | length | ||
| ) |
Sync cached pages overlapping a byte range; zero length extends to EOF.
Definition at line 599 of file File.cc.
References Vector< T >::count(), getBlockSize(), getCachedPage(), PhysicalMemoryManager::getPageSize(), Cache::lookup(), pinBlock(), Vector< T >::pushBack(), Cache::release(), syncPages(), unpinBlock(), useFillCache(), and writeBlock().
Referenced by sync().
Here is the caller graph for this function:
|
virtual |
Delete all data from the file.
Reimplemented in Ext2Symlink, Ext2Directory, Ext2File, FatDirectory, FatFile, and RamFile.
|
protected |
|
virtual |
Memory-pressure compaction must never wait on a backing mutation.
Reimplemented in Ext2File.
Definition at line 587 of file File.cc.
References Semaphore::tryAcquire().
Referenced by MemoryMappedFile::compact().
Here is the caller graph for this function:
|
protectedvirtual |
Unpins the given page.
Reimplemented in RawFsFile, Ext2File, FatFile, Iso9660File, and RamFile.
Definition at line 1434 of file File.cc.
Referenced by acquireCachedBlock(), getPhysicalPage(), readPage(), releaseReadReference(), returnPhysicalPage(), and syncRange().
Here is the caller graph for this function:
|
protectedvirtual |
|
protectedvirtual |
Whether this file currently uses native-page fill caching.
Reimplemented in Ext2File, and FatFile.
Definition at line 1746 of file File.cc.
References EMIT_IF, getBlockSize(), and PhysicalMemoryManager::getPageSize().
Referenced by allocateRange(), getPhysicalPage(), markPageExternallyWritable(), populateRange(), read(), readCached(), readIntoCache(), releaseReadReference(), resize(), returnPhysicalPage(), syncRange(), Ext2File::useFillCache(), and writeUnlocked().
Here is the caller graph for this function:
|
finalvirtual |
Writes to the file.
| [in] | bCanBlock | Whether or not the File can block when reading |
Definition at line 342 of file File.cc.
References lockWrites().
Referenced by Ext2Filesystem::createNode(), and FileDescriptor::write().
Here is the caller graph for this function:
|
protectedvirtual |
Internal function to write a block retrieved with readBlock back to the file. The address of the block is provided for convenience.
Reimplemented in Ext2File, FatFile, and RawFsFile.
Definition at line 1393 of file File.cc.
Referenced by syncRange(), writeBlocks(), and writeUnlocked().
Here is the caller graph for this function:
|
protectedvirtual |
Writes a range of whole filesystem blocks back to the file.
Reimplemented in Ext2File.
Definition at line 1395 of file File.cc.
References getBlockSize(), and writeBlock().
Referenced by Ext2File::writeBlocks(), writeCallback(), and writeUnlocked().
Here is the caller graph for this function:
|
protectedvirtual |
Writes bytes to the file, if isBytewise() == true.
Reimplemented in RandomFile, NullFile, ZeroFile, SerialFile, PtmxFile, RtcFile, Tty0File, MeminfoFile, PciDevicesFile, MountFile, UptimeFile, ConstantFile, PsAuxFile, UnixSocket, ConsoleMasterFile, ConsoleSlaveFile, ConsolePhysicalFile, TextIO, Pipe, InputFile, EvdevFile, FatSymlink, and Ext2Symlink.
Definition at line 1376 of file File.cc.
References isBytewise().
Referenced by writeUnlocked().
Here is the caller graph for this function:
|
staticprotected |
Called by a cache to write back changed data to disk.
File subclasses that use a Cache for readBlock can utilise this as the callback on their Cache instance to get a write-back notification.
Definition at line 116 of file File.cc.
References getBlockSize(), PhysicalMemoryManager::getPageSize(), setCachedPage(), and writeBlocks().
|
private |
Performs a write while m_WriteLock is already held.
Definition at line 347 of file File.cc.
References getBlockSize(), PhysicalMemoryManager::getPageSize(), isBytewise(), readIntoCache(), releaseReadReference(), useFillCache(), writeBlock(), writeBlocks(), and writeBytewise().
|
friend |
|
protected |
|
protected |
|
protected |
Pins a former tracked parent for this detached node's remaining life.
Definition at line 631 of file File.h.
Referenced by retainDetachedParent(), and ~File().
|
protected |
|
protected |
Serializes file mutation, including append EOF selection, across open descriptions.
Definition at line 680 of file File.h.
Referenced by Ext2Filesystem::renameNode().