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

#include <Console.h>

+ Inheritance diagram for ConsoleManager:
+ Collaboration diagram for ConsoleManager:

Public Types

enum  IAttribute { IMapCRToNL = 1 , IIgnoreCR = 2 , IMapNLToCR = 4 , IStripToSevenBits = 8 }
 
enum  OAttribute {
  OPostProcess = 16 , OMapCRToNL = 32 , ONoCrAtCol0 = 64 , OMapNLToCRNL = 128 ,
  ONLCausesCR = 256
}
 
enum  LAttribute {
  LEcho = 512 , LEchoErase = 1024 , LEchoKill = 2048 , LEchoNewline = 4096 ,
  LCookedMode = 8192 , LGenerateEvent = 16384
}
 
- Public Types inherited from Filesystem
enum class  SyncStatus { Success , Unsupported , NoMemory , IoError }
 
typedef Filesystem *(* ProbeCallback) (Disk *)
 

Public Member Functions

File * getConsole (String consoleName)
 
ConsoleFile * getConsoleFile (RequestQueue *pBackend)
 
bool lockConsole (File *file)
 
void unlockConsole (File *file)
 Release a console master locked as above.
 
bool setPtyLock (File *file, bool locked)
 Set the UNIX 98 PTY slave lock associated with a master.
 
bool isPtySlaveLocked (File *file)
 Returns whether a PTY slave is currently locked.
 
void newConsole (char c, size_t i)
 
bool isConsole (File *file)
 
bool isMasterConsole (File *file)
 
void setAttributes (File *file, size_t flags)
 
void getAttributes (File *file, size_t *flags)
 
void getControlChars (File *file, void *p)
 
void setControlChars (File *file, void *p)
 
int getWindowSize (File *file, unsigned short *rows, unsigned short *cols)
 
int setWindowSize (File *file, unsigned short rows, unsigned short cols)
 
bool hasDataAvailable (File *file)
 
void flush (File *file)
 
File * getOther (File *file)
 
virtual bool initialise (Disk *pDisk)
 
virtual File * getRoot () const
 
virtual const String & getVolumeLabel () const
 
- 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 bool getUuid (String &uuid) const
 
virtual FileHandleStatus encodeFileHandle (File &file, FileHandle &handle)
 
virtual FileHandleStatus decodeFileHandle (const FileHandle &handle, RetainedFile &file)
 
virtual FileHandleStatus fileHandleFsid (FileSystemId &id)
 
virtual SyncStatus sync ()
 
virtual SyncStatus shutdown ()
 
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 ConsoleManager & instance ()
 

Protected Member Functions

virtual bool createFile (File *parent, const String &filename, uint32_t mask)
 
virtual bool createDirectory (File *parent, const String &filename, uint32_t mask)
 
virtual bool createSymlink (File *parent, const String &filename, const String &value)
 
virtual bool removeNode (File *, const String &, File *)
 
- Protected Member Functions inherited from Filesystem
virtual bool createLink (File *parent, const String &filename, File *target)
 
virtual bool renameNode (Directory *oldParent, const String &oldName, File *source, Directory *newParent, const String &newName, File *replaced)
 

Private Member Functions

void newConsole (char c, size_t i, bool lock)
 

Private Attributes

Vector< ConsoleFile * > m_Consoles
 
Spinlock m_Lock
 

Static Private Attributes

static ConsoleManager m_Instance
 

Additional Inherited Members

- Protected Attributes inherited from Filesystem
bool m_bReadOnly
 
Disk * m_pDisk
 
DiskUse m_DiskUse
 

Detailed Description

This class provides a way for consoles (TTYs) to be created to interact with applications.

registerConsole is called by a class that subclasses RequestQueue. getConsole returns a File that forwards any read/write requests straight to that RequestQueue backend.

read: request with p1: CONSOLE_READ, p2: param, p3: requested size, p4: buffer. write: request with p1: CONSOLE_WRITE, p2: param, p3: size of buffer, p4: buffer.

Definition at line 298 of file Console.h.

Member Enumeration Documentation

◆ IAttribute

enum ConsoleManager::IAttribute

Definition at line 300 of file Console.h.

◆ LAttribute

enum ConsoleManager::LAttribute

Definition at line 308 of file Console.h.

◆ OAttribute

enum ConsoleManager::OAttribute

Definition at line 301 of file Console.h.

Constructor & Destructor Documentation

◆ ConsoleManager()

ConsoleManager::ConsoleManager ( )

Definition at line 59 of file Console.cc.

◆ ~ConsoleManager()

ConsoleManager::~ConsoleManager ( )
virtual

Definition at line 71 of file Console.cc.

Member Function Documentation

◆ createDirectory()

virtual bool ConsoleManager::createDirectory ( File *  parent,
const String &  filename,
uint32_t  mask 
)
inlineprotectedvirtual

createDirectory calls this after it has parsed the string path.

Implements Filesystem.

Definition at line 379 of file Console.h.

◆ createFile()

virtual bool ConsoleManager::createFile ( File *  parent,
const String &  filename,
uint32_t  mask 
)
inlineprotectedvirtual

createFile calls this after it has parsed the string path.

Implements Filesystem.

Definition at line 376 of file Console.h.

◆ createSymlink()

virtual bool ConsoleManager::createSymlink ( File *  parent,
const String &  filename,
const String &  value 
)
inlineprotectedvirtual

createSymlink calls this after it has parsed the string path.

Implements Filesystem.

Definition at line 382 of file Console.h.

◆ flush()

void ConsoleManager::flush ( File *  file)

Definition at line 232 of file Console.cc.

◆ getAttributes()

void ConsoleManager::getAttributes ( File *  file,
size_t *  flags 
)

Definition at line 176 of file Console.cc.

◆ getConsole()

File * ConsoleManager::getConsole ( String  consoleName)

Definition at line 81 of file Console.cc.

◆ getConsoleFile()

ConsoleFile * ConsoleManager::getConsoleFile ( RequestQueue *  pBackend)

Definition at line 93 of file Console.cc.

◆ getControlChars()

void ConsoleManager::getControlChars ( File *  file,
void *  p 
)

Definition at line 190 of file Console.cc.

◆ getOther()

File * ConsoleManager::getOther ( File *  file)

Definition at line 234 of file Console.cc.

◆ getRoot()

virtual File * ConsoleManager::getRoot ( ) const
inlinevirtual

Returns the root filesystem node.

Implements Filesystem.

Definition at line 367 of file Console.h.

◆ getVolumeLabel()

virtual const String & ConsoleManager::getVolumeLabel ( ) const
inlinevirtual

Returns a string identifying the volume label.

Implements Filesystem.

Definition at line 370 of file Console.h.

◆ getWindowSize()

int ConsoleManager::getWindowSize ( File *  file,
unsigned short *  rows,
unsigned short *  cols 
)

Definition at line 197 of file Console.cc.

◆ hasDataAvailable()

bool ConsoleManager::hasDataAvailable ( File *  file)

Definition at line 225 of file Console.cc.

◆ initialise()

virtual bool ConsoleManager::initialise ( Disk *  pDisk)
inlinevirtual

Populates this filesystem with data from the given Disk device.

Returns
true on success, false on failure.

Implements Filesystem.

Definition at line 364 of file Console.h.

◆ instance()

ConsoleManager & ConsoleManager::instance ( )
static

Definition at line 77 of file Console.cc.

◆ isConsole()

bool ConsoleManager::isConsole ( File *  file)

Definition at line 154 of file Console.cc.

◆ isMasterConsole()

bool ConsoleManager::isMasterConsole ( File *  file)

Definition at line 160 of file Console.cc.

◆ isPtySlaveLocked()

bool ConsoleManager::isPtySlaveLocked ( File *  file)

Returns whether a PTY slave is currently locked.

Definition at line 143 of file Console.cc.

◆ lockConsole()

bool ConsoleManager::lockConsole ( File *  file)

Acquire a console master in such a way that it cannot be opened by another process.

Definition at line 97 of file Console.cc.

References ConsoleMasterFile::bLocked, Process::getParent(), ProcessorBase::information(), and ConsoleMasterFile::pLocker.

◆ newConsole() [1/2]

void ConsoleManager::newConsole ( char  c,
size_t  i 
)

Create a new console - /dev/ptyXY -> /dev/ttyXY, where X is and Y is @i.

Definition at line 32 of file Console.cc.

References newConsole().

Referenced by newConsole().

+ Here is the caller graph for this function:

◆ newConsole() [2/2]

void ConsoleManager::newConsole ( char  c,
size_t  i,
bool  lock 
)
private

Definition at line 36 of file Console.cc.

◆ removeNode()

virtual bool ConsoleManager::removeNode ( File *  parent,
const String &  filename,
File *  file 
)
inlineprotectedvirtual

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 385 of file Console.h.

◆ setAttributes()

void ConsoleManager::setAttributes ( File *  file,
size_t  flags 
)

Definition at line 168 of file Console.cc.

◆ setControlChars()

void ConsoleManager::setControlChars ( File *  file,
void *  p 
)

Definition at line 183 of file Console.cc.

◆ setPtyLock()

bool ConsoleManager::setPtyLock ( File *  file,
bool  locked 
)

Set the UNIX 98 PTY slave lock associated with a master.

Definition at line 133 of file Console.cc.

References ConsoleMasterFile::bSlaveLocked.

◆ setWindowSize()

int ConsoleManager::setWindowSize ( File *  file,
unsigned short  rows,
unsigned short  cols 
)

Definition at line 212 of file Console.cc.

◆ unlockConsole()

void ConsoleManager::unlockConsole ( File *  file)

Release a console master locked as above.

Definition at line 116 of file Console.cc.

References ConsoleMasterFile::bLocked, Process::getParent(), ProcessorBase::information(), and ConsoleMasterFile::pLocker.

Member Data Documentation

◆ m_Consoles

Vector<ConsoleFile*> ConsoleManager::m_Consoles
private

Definition at line 390 of file Console.h.

◆ m_Instance

ConsoleManager ConsoleManager::m_Instance
staticprivate

Definition at line 391 of file Console.h.

◆ m_Lock

Spinlock ConsoleManager::m_Lock
private

Definition at line 392 of file Console.h.


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