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

#include <Pipe.h>

+ Inheritance diagram for Pipe:
+ Collaboration diagram for Pipe:

Public Member Functions

 Pipe ()
 
 Pipe (const Pipe &file)
 
 Pipe (const String &name, Time::Timestamp accessedTime, Time::Timestamp modifiedTime, Time::Timestamp creationTime, uintptr_t inode, class Filesystem *pFs, size_t size, File *pParent, bool bIsAnonymous=false)
 
virtual ~Pipe ()
 
virtual int select (bool bWriting=false, int timeout=0)
 
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 bool isPipe () const
 
virtual bool isFifo () const
 
virtual void increaseRefCount (bool bIsWriter)
 
virtual void decreaseRefCount (bool bIsWriter)
 
size_t getReaderCount () const
 
size_t getWriterCount () const
 
bool waitForReader ()
 
- Public Member Functions inherited from File
 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
 
virtual uint64_t write (uint64_t location, uint64_t size, uintptr_t buffer, bool bCanBlock=true) final
 
virtual physical_uintptr_t getPhysicalPage (size_t offset)
 
virtual void returnPhysicalPage (size_t offset)
 
virtual void sync ()
 
virtual void sync (size_t offset, bool async)
 
Time::Timestamp getCreationTime ()
 
void setCreationTime (Time::Timestamp t)
 
Time::Timestamp getAccessedTime ()
 
void setAccessedTime (Time::Timestamp t)
 
Time::Timestamp getModifiedTime ()
 
void setModifiedTime (Time::Timestamp t)
 
String getName () const
 
void getName (String &s) const
 
virtual String getFullPath (bool bWithLabel=true)
 
virtual void truncate ()
 
size_t getSize ()
 
void setSize (size_t sz)
 
virtual bool isSymlink ()
 
virtual bool isDirectory ()
 
virtual bool isSocket () const
 
uintptr_t getInode () const
 
virtual void setInode (uintptr_t inode)
 
FilesystemgetFilesystem () const
 
void setFilesystem (Filesystem *pFs)
 
virtual void fileAttributeChanged ()
 
void setPermissions (uint32_t perms)
 
uint32_t getPermissions () const
 
void setUid (size_t uid)
 
size_t getUid () const
 
void setGid (size_t gid)
 
size_t getGid () const
 
FilegetParent () const
 
void monitor (Thread *pThread, Event *pEvent)
 
void cullMonitorTargets (Thread *pThread)
 
virtual bool supports (const size_t command) const
 
virtual int command (const size_t command, void *buffer)
 
virtual size_t getBlockSize () const
 
void enableDirect ()
 
void disableDirect ()
 
virtual void preallocate (size_t expectedSize, bool zero=true)
 
virtual Fileopen ()
 

Static Public Member Functions

static PipefromFile (File *pF)
 

Protected Member Functions

virtual bool isBytewise () const
 
- Protected Member Functions inherited from File
virtual uintptr_t readBlock (uint64_t location)
 
virtual void writeBlock (uint64_t location, uintptr_t addr)
 
virtual void extend (size_t newSize)
 
virtual void extend (size_t newSize, uint64_t location, uint64_t size)
 
void dataChanged ()
 
void getFilesystemLabel (HugeStaticString &s)
 
virtual void pinBlock (uint64_t location)
 
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)
 

Protected Attributes

bool m_bIsAnonymous
 
volatile bool m_bIsEOF
 
Buffer< uint8_t > m_Buffer
 
Semaphore m_ReaderSem
 
- Protected Attributes inherited from File
String m_Name
 
Time::Timestamp m_AccessedTime
 
Time::Timestamp m_ModifiedTime
 
Time::Timestamp m_CreationTime
 
uintptr_t m_Inode
 
class Filesystemm_pFilesystem
 
size_t m_Size
 
Filem_pParent
 
size_t m_nWriters
 
size_t m_nReaders
 
size_t m_Uid
 
size_t m_Gid
 
uint32_t m_Permissions
 
HashTable< DataCacheKey, uintptr_t > m_DataCache
 
bool m_bDirect
 
Cache m_FillCache
 
Mutex m_Lock
 
List< MonitorTarget * > m_MonitorTargets
 

Private Member Functions

Pipeoperator= (const Pipe &)
 

Friends

class Filesystem
 
class ZombiePipe
 

Additional Inherited Members

- Static Protected Member Functions inherited from File
static void writeCallback (CacheConstants::CallbackCause cause, uintptr_t loc, uintptr_t page, void *meta)
 

Detailed Description

A first-in-first-out buffer node.

Definition at line 35 of file Pipe.h.

Constructor & Destructor Documentation

Pipe::Pipe ( )

Constructor, creates an invalid file.

Definition at line 50 of file Pipe.cc.

References NOTICE.

Pipe::Pipe ( const Pipe file)

Copy constructors are hidden - unused!

Pipe::Pipe ( const String name,
Time::Timestamp  accessedTime,
Time::Timestamp  modifiedTime,
Time::Timestamp  creationTime,
uintptr_t  inode,
class Filesystem pFs,
size_t  size,
File pParent,
bool  bIsAnonymous = false 
)

Constructor, should be called only by a Filesystem.

Definition at line 59 of file Pipe.cc.

References Hex, and NOTICE.

Pipe::~Pipe ( )
virtual

Destructor - doesn't do anything.

Definition at line 76 of file Pipe.cc.

References Semaphore::acquire(), and Semaphore::release().

Member Function Documentation

void Pipe::decreaseRefCount ( bool  bIsWriter)
virtual

Override decreaseRefCount so we can tell when all writers have hung up (and also when all readers have hung up so we can die).

Reimplemented from File.

Definition at line 162 of file Pipe.cc.

References Semaphore::acquire(), File::dataChanged(), Buffer< T, allowShortOperation >::disableReads(), Buffer< T, allowShortOperation >::disableWrites(), ERROR, Processor::information(), m_bIsAnonymous, m_Buffer, m_ReaderSem, and NOTICE.

static Pipe* Pipe::fromFile ( File pF)
inlinestatic

Eases the pain of casting, and performs a sanity check.

Definition at line 42 of file Pipe.h.

References FATAL, File::isFifo(), File::isPipe(), File::readBytewise(), File::select(), and File::writeBytewise().

virtual bool Pipe::isBytewise ( ) const
inlineprotectedvirtual

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 from File.

Definition at line 118 of file Pipe.h.

bool Pipe::isFifo ( ) const
virtual
bool Pipe::isPipe ( ) const
virtual

Pipes are anonymous (no name).

Reimplemented from File.

Definition at line 130 of file Pipe.cc.

References File::getName(), and m_bIsAnonymous.

uint64_t Pipe::readBytewise ( uint64_t  location,
uint64_t  size,
uintptr_t  buffer,
bool  bCanBlock = true 
)
virtual

Reads from the file.

Reimplemented from File.

Definition at line 98 of file Pipe.cc.

References m_Buffer, and Buffer< T, allowShortOperation >::read().

int Pipe::select ( bool  bWriting = false,
int  timeout = 0 
)
virtual
uint64_t Pipe::writeBytewise ( uint64_t  location,
uint64_t  size,
uintptr_t  buffer,
bool  bCanBlock = true 
)
virtual

Writes to the file.

Reimplemented from File.

Definition at line 111 of file Pipe.cc.

References File::dataChanged(), m_Buffer, and Buffer< T, allowShortOperation >::write().

Member Data Documentation

bool Pipe::m_bIsAnonymous
protected

If we're an anonymous pipe, we should delete ourselves when all readers/writers have hung up.

Definition at line 107 of file Pipe.h.

Referenced by decreaseRefCount(), isFifo(), and isPipe().

volatile bool Pipe::m_bIsEOF
protected

Have we reached EOF?

Definition at line 110 of file Pipe.h.

Buffer<uint8_t> Pipe::m_Buffer
protected

Internal pipe buffer.

Definition at line 113 of file Pipe.h.

Referenced by decreaseRefCount(), isFifo(), readBytewise(), select(), and writeBytewise().

Semaphore Pipe::m_ReaderSem
protected

Reader semaphore to allow blocking until a reader arrives.

Definition at line 116 of file Pipe.h.

Referenced by decreaseRefCount(), and isFifo().


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