The Pedigree Project  0.1
Public Member Functions | Public Attributes | List of all members
FileDescriptor Class Reference

#include <FileDescriptor.h>

+ Collaboration diagram for FileDescriptor:

Public Member Functions

 FileDescriptor ()
 Default constructor.
 
 FileDescriptor (File *newFile, uint64_t newOffset=0, size_t newFd=0xFFFFFFFF, int fdFlags=0, int flFlags=0, LockedFile *lf=0)
 Parameterised constructor. More...
 
 FileDescriptor (FileDescriptor &desc)
 Copy constructor.
 
 FileDescriptor (FileDescriptor *desc)
 Pointer copy constructor.
 
FileDescriptoroperator= (FileDescriptor &desc)
 Assignment operator implementation.
 
virtual ~FileDescriptor ()
 Destructor - decreases file reference count. More...
 
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. More...
 
void addStatusFlag (int newFlag)
 Helper to add a single flag to the status flags.
 
int getStatusFlags () const
 Get current status flags.
 

Public Attributes

Filefile
 Our open file pointer.
 
uint64_t offset
 Offset within the file for I/O.
 
size_t fd
 Descriptor number.
 
LockedFilelockedFile
 Locked file, non-zero if there is an advisory lock on the file.
 
SharedPointer< class NetworkSyscallsnetworkImpl
 Network syscall implementation for this descriptor (if it's a socket).
 
IoEventioevent
 IO event for reporting changes to files.
 
int fdflags
 File descriptor flags (fcntl) More...
 
int flflags
 File status flags (fcntl)
 

Detailed Description

Abstraction of a file descriptor, which defines an open file and related flags.

Definition at line 36 of file FileDescriptor.h.

Constructor & Destructor Documentation

FileDescriptor::FileDescriptor ( File newFile,
uint64_t  newOffset = 0,
size_t  newFd = 0xFFFFFFFF,
int  fdFlags = 0,
int  flFlags = 0,
LockedFile lf = 0 
)

Parameterised constructor.

Todo:
need a copy constructor for networkImpl

Definition at line 42 of file FileDescriptor.cc.

References file, flflags, File::getFullPath(), lockedFile, and RadixTree< T >::lookup().

FileDescriptor::~FileDescriptor ( )
virtual

Destructor - decreases file reference count.

Note
sockets are cleaned up by their reference count hitting zero (SharedPointer)

Definition at line 140 of file FileDescriptor.cc.

References file, flflags, File::getFullPath(), ioevent, lockedFile, networkImpl, RadixTree< T >::remove(), and LockedFile::unlock().

Member Function Documentation

void FileDescriptor::setStatusFlags ( int  newFlags)

Set status flags, distributing any associated changes as needed.

Todo:
this blocks all operations on the socket. However, we should only be blocking operations associated with this descriptor on the socket! maybe pass in a FileDescriptor to recvfrom et al?

Definition at line 194 of file FileDescriptor.cc.

References flflags, and networkImpl.

Member Data Documentation

int FileDescriptor::fdflags

File descriptor flags (fcntl)

Todo:
swap this to private and fix everything that breaks

Definition at line 97 of file FileDescriptor.h.

Referenced by addFlag(), FileDescriptor(), PosixSubsystem::freeMultipleFds(), getFlags(), operator=(), and setFlags().


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