|
The Pedigree Project 0.1
|
#include <FileDescriptor.h>
Collaboration diagram for FileDescriptor:Classes | |
| class | OpenFileDescription |
| class | PositionGuard |
| class | TerminalOperation |
| class | TransferPositionGuard |
Public Types | |
| using | OpenFileDescriptionLease = SharedPointer< OpenFileDescription > |
Public Member Functions | |
| FileDescriptor () | |
| Default constructor. | |
| FileDescriptor (File *newFile, uint64_t newOffset=0, size_t newFd=0xFFFFFFFF, int fdFlags=0, int flFlags=0) | |
| Parameterised constructor. | |
| FileDescriptor (const FilesystemPathRef &path, uint64_t newOffset=0, size_t newFd=0xFFFFFFFF, int fdFlags=0, int flFlags=0) | |
| FileDescriptor (FileDescriptor &desc) | |
| Copy constructor. | |
| FileDescriptor (FileDescriptor *desc) | |
| Pointer copy constructor. | |
| FileDescriptor & | operator= (FileDescriptor &desc)=delete |
| Descriptors own registrations and references which cannot be replaced. | |
| virtual | ~FileDescriptor () |
| Destructor - decreases file reference count. | |
| void | setFlags (int newFlags) |
| Set flags, distributing any associated changes as needed. | |
| void | addFlag (int newFlag) |
| Helper to add a single flag to the descriptor flags. | |
| int | getFlags () const |
| Get current descriptor flags. | |
| void | setStatusFlags (int newFlags) |
| Set status flags, distributing any associated changes as needed. | |
| void | addStatusFlag (int newFlag) |
| Helper to add a single flag to the status flags. | |
| void | removeStatusFlag (int flag) |
| Helper to remove a single flag from the status flags. | |
| int | getStatusFlags () const |
| Get current status flags. | |
| bool | truncateAllowed () const |
| void | setTruncateAllowed (bool allowed) |
| int | getAccessFlags () const |
| OpenFileDescriptionLease | acquireOpenFileDescription () const |
| void | setNetworkImpl (const SharedPointer< NetworkSyscalls > &implementation) |
| bool | networkPublished () const |
| void | setEventFdImpl (const SharedPointer< EventFd > &implementation) |
| SharedPointer< EventFd > | getEventFdImpl () const |
| bool | eventFdPublished () const |
| void | setTimerFdImpl (const SharedPointer< TimerFd > &implementation) |
| SharedPointer< TimerFd > | getTimerFdImpl () const |
| bool | timerFdPublished () const |
| void | setSignalFdImpl (const SharedPointer< SignalFd > &implementation) |
| SharedPointer< SignalFd > | getSignalFdImpl () const |
| bool | signalFdPublished () const |
| void | setInotifyImpl (const SharedPointer< InotifyInstance > &implementation) |
| SharedPointer< InotifyInstance > | getInotifyImpl () const |
| void | setFanotifyImpl (const SharedPointer< FanotifyInstance > &implementation) |
| SharedPointer< FanotifyInstance > | getFanotifyImpl () const |
| void | setMqueueImpl (const SharedPointer< PosixMessageQueue > &implementation) |
| SharedPointer< PosixMessageQueue > | getMqueueImpl () const |
| void | unpublish () |
| PositionGuard | lockPosition () const |
| uint64_t | getOffset () const |
| void | setOffset (uint64_t offset) |
| uint64_t | read (uint64_t size, uintptr_t buffer, bool canBlock=true) |
| uint64_t | write (uint64_t size, uintptr_t buffer, bool canBlock=true) |
| bool | acquireTerminalOperation (TerminalOperation &operation) const |
| bool | terminalHungUp () const |
| bool | terminalAvailable () const |
| SharedPointer< ConsoleIoState > | terminalEpoch (bool waitForReopen=true) const |
| uint64_t | readFile (uint64_t location, uint64_t size, uintptr_t buffer, bool canBlock) |
| uint64_t | writeFile (uint64_t location, uint64_t size, uintptr_t buffer, bool canBlock) |
| File * | getFile () const |
| FilesystemPathRef | openingPath () const |
Public Attributes | |
| size_t | fd |
| Descriptor number. | |
| SharedPointer< NetworkSyscalls > | networkImpl |
| Network syscall implementation for this descriptor (if it's a socket). | |
| SharedPointer< EpollInstance > | epollImpl |
| Epoll implementation for this descriptor (if it is an epoll object). | |
| IoEvent * | ioevent |
| IO event for reporting changes to files. | |
| int | fdflags |
| File descriptor flags (fcntl) | |
Private Attributes | |
| OpenFileDescriptionLease | m_OpenFile |
| bool | m_NetworkPublished |
| bool | m_EventFdPublished |
| bool | m_TimerFdPublished = false |
| bool | m_SignalFdPublished = false |
Friends | |
| class | PosixSubsystem |
Abstraction of a file descriptor, which defines an open file and related flags.
Definition at line 53 of file FileDescriptor.h.
Definition at line 128 of file FileDescriptor.h.
| FileDescriptor::FileDescriptor | ( | ) |
Default constructor.
Definition at line 281 of file FileDescriptor.cc.
| FileDescriptor::FileDescriptor | ( | File * | newFile, |
| uint64_t | newOffset = 0, |
||
| size_t | newFd = 0xFFFFFFFF, |
||
| int | fdFlags = 0, |
||
| int | flFlags = 0 |
||
| ) |
Parameterised constructor.
Definition at line 292 of file FileDescriptor.cc.
| FileDescriptor::FileDescriptor | ( | const FilesystemPathRef & | path, |
| uint64_t | newOffset = 0, |
||
| size_t | newFd = 0xFFFFFFFF, |
||
| int | fdFlags = 0, |
||
| int | flFlags = 0 |
||
| ) |
Definition at line 305 of file FileDescriptor.cc.
| FileDescriptor::FileDescriptor | ( | FileDescriptor & | desc | ) |
Copy constructor.
Definition at line 317 of file FileDescriptor.cc.
References NetworkSyscalls::addDescriptorOwner(), ioevent, m_EventFdPublished, m_NetworkPublished, m_OpenFile, and networkImpl.
| FileDescriptor::FileDescriptor | ( | FileDescriptor * | desc | ) |
Pointer copy constructor.
Definition at line 352 of file FileDescriptor.cc.
References NetworkSyscalls::addDescriptorOwner(), epollImpl, fd, fdflags, ioevent, m_EventFdPublished, m_NetworkPublished, m_OpenFile, networkImpl, and SharedPointer< T >::reset().
|
virtual |
Destructor - decreases file reference count.
Definition at line 397 of file FileDescriptor.cc.
References ioevent, m_OpenFile, networkImpl, and unpublish().
| FileDescriptor::OpenFileDescriptionLease FileDescriptor::acquireOpenFileDescription | ( | ) | const |
Retain and identify the open file description behind this descriptor.
Definition at line 455 of file FileDescriptor.cc.
References m_OpenFile.
Referenced by EpollInstance::control().
Here is the caller graph for this function:| bool FileDescriptor::acquireTerminalOperation | ( | TerminalOperation & | operation | ) | const |
Definition at line 179 of file FileDescriptor.cc.
| void FileDescriptor::addFlag | ( | int | newFlag | ) |
Helper to add a single flag to the descriptor flags.
Definition at line 415 of file FileDescriptor.cc.
References fdflags, and setFlags().
| void FileDescriptor::addStatusFlag | ( | int | newFlag | ) |
Helper to add a single flag to the status flags.
Definition at line 434 of file FileDescriptor.cc.
References m_OpenFile.
| bool FileDescriptor::eventFdPublished | ( | ) | const |
Whether this descriptor still owns a published eventfd alias.
Definition at line 498 of file FileDescriptor.cc.
References m_EventFdPublished.
|
inline |
Definition at line 248 of file FileDescriptor.h.
| SharedPointer< EventFd > FileDescriptor::getEventFdImpl | ( | ) | const |
Retain the eventfd counter behind this descriptor, if any.
Definition at line 494 of file FileDescriptor.cc.
References m_OpenFile.
| SharedPointer< FanotifyInstance > FileDescriptor::getFanotifyImpl | ( | ) | const |
Definition at line 562 of file FileDescriptor.cc.
|
inline |
Definition at line 326 of file FileDescriptor.h.
| int FileDescriptor::getFlags | ( | ) | const |
| SharedPointer< InotifyInstance > FileDescriptor::getInotifyImpl | ( | ) | const |
Retain the inotify queue behind this descriptor, if any.
Definition at line 551 of file FileDescriptor.cc.
References m_OpenFile.
| SharedPointer< PosixMessageQueue > FileDescriptor::getMqueueImpl | ( | ) | const |
Definition at line 577 of file FileDescriptor.cc.
| uint64_t FileDescriptor::getOffset | ( | ) | const |
Read the current shared offset.
Definition at line 619 of file FileDescriptor.cc.
References lockPosition().
| SharedPointer< SignalFd > FileDescriptor::getSignalFdImpl | ( | ) | const |
Definition at line 536 of file FileDescriptor.cc.
| int FileDescriptor::getStatusFlags | ( | ) | const |
Get current status flags.
Definition at line 450 of file FileDescriptor.cc.
References m_OpenFile.
Referenced by EpollInstance::control(), read(), and write().
Here is the caller graph for this function:| SharedPointer< TimerFd > FileDescriptor::getTimerFdImpl | ( | ) | const |
Definition at line 515 of file FileDescriptor.cc.
| FileDescriptor::PositionGuard FileDescriptor::lockPosition | ( | ) | const |
Lock and access the offset shared by this open-file description.
Definition at line 615 of file FileDescriptor.cc.
References m_OpenFile.
Referenced by getOffset(), and setOffset().
Here is the caller graph for this function:| bool FileDescriptor::networkPublished | ( | ) | const |
Whether this descriptor retained socket ownership during clone admission.
Definition at line 476 of file FileDescriptor.cc.
References m_NetworkPublished.
| FilesystemPathRef FileDescriptor::openingPath | ( | ) | const |
Definition at line 129 of file FileDescriptor.cc.
| uint64_t FileDescriptor::read | ( | uint64_t | size, |
| uintptr_t | buffer, | ||
| bool | canBlock = true |
||
| ) |
Read while applying this open-file description's offset policy.
Definition at line 629 of file FileDescriptor.cc.
References getStatusFlags(), m_OpenFile, and File::read().
| uint64_t FileDescriptor::readFile | ( | uint64_t | location, |
| uint64_t | size, | ||
| uintptr_t | buffer, | ||
| bool | canBlock | ||
| ) |
Definition at line 187 of file FileDescriptor.cc.
| void FileDescriptor::removeStatusFlag | ( | int | flag | ) |
Helper to remove a single flag from the status flags.
Definition at line 442 of file FileDescriptor.cc.
References m_OpenFile.
| void FileDescriptor::setEventFdImpl | ( | const SharedPointer< EventFd > & | implementation | ) |
Associate an eventfd counter with this open file description.
Definition at line 480 of file FileDescriptor.cc.
References m_EventFdPublished, and m_OpenFile.
| void FileDescriptor::setFanotifyImpl | ( | const SharedPointer< FanotifyInstance > & | implementation | ) |
Definition at line 555 of file FileDescriptor.cc.
| void FileDescriptor::setFlags | ( | int | newFlags | ) |
Set flags, distributing any associated changes as needed.
Definition at line 411 of file FileDescriptor.cc.
References fdflags.
Referenced by addFlag().
Here is the caller graph for this function:| void FileDescriptor::setInotifyImpl | ( | const SharedPointer< InotifyInstance > & | implementation | ) |
Associate an inotify queue with this open file description.
Definition at line 544 of file FileDescriptor.cc.
References m_OpenFile.
| void FileDescriptor::setMqueueImpl | ( | const SharedPointer< PosixMessageQueue > & | implementation | ) |
Definition at line 570 of file FileDescriptor.cc.
| void FileDescriptor::setNetworkImpl | ( | const SharedPointer< NetworkSyscalls > & | implementation | ) |
Associate a socket implementation with this open file description.
Definition at line 459 of file FileDescriptor.cc.
References m_NetworkPublished, m_OpenFile, and networkImpl.
Referenced by LwipSocketSyscalls::accept().
Here is the caller graph for this function:| void FileDescriptor::setOffset | ( | uint64_t | offset | ) |
Replace the current shared offset.
Definition at line 624 of file FileDescriptor.cc.
References lockPosition().
| void FileDescriptor::setSignalFdImpl | ( | const SharedPointer< SignalFd > & | implementation | ) |
Definition at line 523 of file FileDescriptor.cc.
| void FileDescriptor::setStatusFlags | ( | int | newFlags | ) |
Set status flags, distributing any associated changes as needed.
Definition at line 423 of file FileDescriptor.cc.
References m_OpenFile.
| void FileDescriptor::setTimerFdImpl | ( | const SharedPointer< TimerFd > & | implementation | ) |
Definition at line 502 of file FileDescriptor.cc.
|
inline |
Definition at line 241 of file FileDescriptor.h.
| bool FileDescriptor::signalFdPublished | ( | ) | const |
Definition at line 540 of file FileDescriptor.cc.
| bool FileDescriptor::terminalAvailable | ( | ) | const |
Definition at line 174 of file FileDescriptor.cc.
| SharedPointer< ConsoleIoState > FileDescriptor::terminalEpoch | ( | bool | waitForReopen = true | ) | const |
Definition at line 163 of file FileDescriptor.cc.
| bool FileDescriptor::terminalHungUp | ( | ) | const |
Definition at line 167 of file FileDescriptor.cc.
| bool FileDescriptor::timerFdPublished | ( | ) | const |
Definition at line 519 of file FileDescriptor.cc.
|
inline |
Definition at line 237 of file FileDescriptor.h.
| void FileDescriptor::unpublish | ( | ) |
Notify anonymous targets that this descriptor left its descriptor table.
Definition at line 581 of file FileDescriptor.cc.
References m_EventFdPublished, m_NetworkPublished, m_OpenFile, and networkImpl.
Referenced by ~FileDescriptor().
Here is the caller graph for this function:| uint64_t FileDescriptor::write | ( | uint64_t | size, |
| uintptr_t | buffer, | ||
| bool | canBlock = true |
||
| ) |
Write while applying this open-file description's offset policy.
Definition at line 644 of file FileDescriptor.cc.
References File::append(), getStatusFlags(), m_OpenFile, and File::write().
| uint64_t FileDescriptor::writeFile | ( | uint64_t | location, |
| uint64_t | size, | ||
| uintptr_t | buffer, | ||
| bool | canBlock | ||
| ) |
Definition at line 194 of file FileDescriptor.cc.
|
friend |
Definition at line 348 of file FileDescriptor.h.
| SharedPointer<EpollInstance> FileDescriptor::epollImpl |
Epoll implementation for this descriptor (if it is an epoll object).
Definition at line 338 of file FileDescriptor.h.
Referenced by EpollInstance::control(), and FileDescriptor().
| size_t FileDescriptor::fd |
Descriptor number.
Definition at line 332 of file FileDescriptor.h.
Referenced by FileDescriptor(), and PosixSubsystem::installFileDescriptor().
| int FileDescriptor::fdflags |
File descriptor flags (fcntl)
Definition at line 345 of file FileDescriptor.h.
Referenced by addFlag(), FileDescriptor(), getFlags(), and setFlags().
| IoEvent* FileDescriptor::ioevent |
IO event for reporting changes to files.
Definition at line 341 of file FileDescriptor.h.
Referenced by FileDescriptor(), FileDescriptor(), and ~FileDescriptor().
|
private |
Eventfd table ownership is released before in-flight syscall pins drain.
Definition at line 356 of file FileDescriptor.h.
Referenced by eventFdPublished(), FileDescriptor(), FileDescriptor(), setEventFdImpl(), and unpublish().
|
private |
Whether this object still owns one published socket alias.
Definition at line 354 of file FileDescriptor.h.
Referenced by FileDescriptor(), FileDescriptor(), networkPublished(), setNetworkImpl(), and unpublish().
|
private |
State and serialization shared by aliases of one open file.
Definition at line 351 of file FileDescriptor.h.
Referenced by acquireOpenFileDescription(), addStatusFlag(), FileDescriptor(), FileDescriptor(), getEventFdImpl(), getInotifyImpl(), getStatusFlags(), lockPosition(), read(), removeStatusFlag(), setEventFdImpl(), setInotifyImpl(), setNetworkImpl(), setStatusFlags(), unpublish(), write(), and ~FileDescriptor().
|
private |
Definition at line 358 of file FileDescriptor.h.
|
private |
Definition at line 357 of file FileDescriptor.h.
| SharedPointer<NetworkSyscalls> FileDescriptor::networkImpl |
Network syscall implementation for this descriptor (if it's a socket).
Definition at line 335 of file FileDescriptor.h.
Referenced by FileDescriptor(), FileDescriptor(), setNetworkImpl(), unpublish(), and ~FileDescriptor().