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

#include <ProcFs.h>

+ Inheritance diagram for ProcFs:
+ Collaboration diagram for ProcFs:

Public Member Functions

SyncStatus sync () override
 
 ProcFs (const SharedPointer< UserspacePidNamespace > &space=Process::rootPidNamespace())
 
const SharedPointer< UserspacePidNamespace > & pidNamespace () const
 
virtual bool initialise (Disk *pDisk)
 
virtual File * getRoot () const
 
virtual const String & getVolumeLabel () const
 
virtual size_t getNextInode ()
 
virtual void revertInode ()
 
void addProcess (PosixProcess *proc)
 
void removeProcess (PosixProcess *proc)
 
void invalidateNamespaceTask (const SharedPointer< PosixNamespaceContext > &context, size_t pid, size_t taskId)
 
- 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 shutdown ()
 
virtual bool deviceRemoved (bool deviceAvailable=false)
 
bool tryAcquireOperation (OperationBarrier::Lease &operation) const
 
bool isDeviceRemoved () const
 
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 void publishProcess (PosixProcess *process)
 
static void unpublishProcess (PosixProcess *process)
 

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)
 
bool beginDeviceRemoval (bool deviceAvailable)
 

Private Member Functions

 ProcFs (const ProcFs &)
 
ProcFs & operator= (const ProcFs &)
 
bool initialiseNamespaceLinks ()
 
void initialiseResolverFile ()
 
void initialiseNetworkFile ()
 
ProcFsDirectory * createProcessDirectory (PosixProcess *process)
 

Private Attributes

SharedPointer< UserspacePidNamespace > m_PidNamespace
 
ProcFs * m_RegistryNext = nullptr
 
bool m_Registered = false
 
ProcFsDirectory * m_pRoot
 
Atomic< size_t > m_NextInode
 
String m_PciDevices
 

Additional Inherited Members

- Public Types inherited from Filesystem
enum class  SyncStatus { Success , Unsupported , NoMemory , IoError }
 
typedef Filesystem *(* ProbeCallback) (Disk *)
 
- Protected Attributes inherited from Filesystem
bool m_bReadOnly
 
Disk * m_pDisk
 
DiskUse m_DiskUse
 
OperationBarrier m_Operations
 

Detailed Description

This class provides /dev

Definition at line 165 of file ProcFs.h.

Constructor & Destructor Documentation

◆ ProcFs()

ProcFs::ProcFs ( const SharedPointer< UserspacePidNamespace > &  space = Process::rootPidNamespace())
inlineexplicit

Definition at line 171 of file ProcFs.h.

◆ ~ProcFs()

ProcFs::~ProcFs ( )
virtual

Definition at line 327 of file ProcFs.cc.

Member Function Documentation

◆ addProcess()

void ProcFs::addProcess ( PosixProcess *  proc)
Todo:
is this correct? or should it be effective user/group?
Todo:
add some info to the directory...

Definition at line 533 of file ProcFs.cc.

References Dec, SharedPointer< T >::get(), Process::getGroup(), Group::getId(), User::getId(), Process::getUser(), Process::getUserspaceId(), and Directory::lookupChild().

Referenced by initialise().

+ Here is the caller graph for this function:

◆ createDirectory()

virtual bool ProcFs::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 203 of file ProcFs.h.

◆ createFile()

virtual bool ProcFs::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 200 of file ProcFs.h.

◆ createProcessDirectory()

ProcFsDirectory * ProcFs::createProcessDirectory ( PosixProcess *  process)
private

Definition at line 396 of file ProcFs-namespaces.cc.

◆ createSymlink()

virtual bool ProcFs::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 206 of file ProcFs.h.

◆ getNextInode()

size_t ProcFs::getNextInode ( )
virtual

Definition at line 524 of file ProcFs.cc.

◆ getRoot()

virtual File * ProcFs::getRoot ( ) const
inlinevirtual

Returns the root filesystem node.

Implements Filesystem.

Definition at line 183 of file ProcFs.h.

◆ getVolumeLabel()

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

Returns a string identifying the volume label.

Implements Filesystem.

Definition at line 186 of file ProcFs.h.

◆ initialise()

bool ProcFs::initialise ( Disk *  pDisk)
virtual

Populates this filesystem with data from the given Disk device.

Returns
true on success, false on failure.
Todo:
ConstantFile is taking const char *s of all this and holding them which is extremely unsafe. That must be fixed because right now the ConstantFile could point into freed heap memory.
Todo:
need to know parent (if any) so we can add dotdot too
Todo:
also probably need /etc/mtab...
Todo:
need to add some flags here
Todo:
add driver name here if known?

Implements Filesystem.

Definition at line 341 of file ProcFs.cc.

References addProcess(), VFS::find(), Device::foreach(), Directory::fromFile(), Process::getId(), File::getName(), VFS::instance(), and Scheduler::instance().

◆ initialiseNamespaceLinks()

bool ProcFs::initialiseNamespaceLinks ( )
private

Definition at line 383 of file ProcFs-namespaces.cc.

◆ initialiseNetworkFile()

void ProcFs::initialiseNetworkFile ( )
private

Definition at line 220 of file ProcFs-network.cc.

◆ initialiseResolverFile()

void ProcFs::initialiseResolverFile ( )
private

Definition at line 85 of file ProcFs-resolver.cc.

◆ invalidateNamespaceTask()

void ProcFs::invalidateNamespaceTask ( const SharedPointer< PosixNamespaceContext > &  context,
size_t  pid,
size_t  taskId 
)

Definition at line 413 of file ProcFs-namespaces.cc.

◆ pidNamespace()

const SharedPointer< UserspacePidNamespace > & ProcFs::pidNamespace ( ) const
inline

Definition at line 173 of file ProcFs.h.

◆ publishProcess()

void ProcFs::publishProcess ( PosixProcess *  process)
static

Definition at line 578 of file ProcFs.cc.

◆ removeNode()

virtual bool ProcFs::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 209 of file ProcFs.h.

◆ removeProcess()

void ProcFs::removeProcess ( PosixProcess *  proc)

Definition at line 566 of file ProcFs.cc.

◆ revertInode()

void ProcFs::revertInode ( )
virtual

Definition at line 528 of file ProcFs.cc.

◆ sync()

SyncStatus ProcFs::sync ( )
inlineoverridevirtual

Completes data, metadata and device writeback for changes made before entry.

Reimplemented from Filesystem.

Definition at line 167 of file ProcFs.h.

◆ unpublishProcess()

void ProcFs::unpublishProcess ( PosixProcess *  process)
static

Definition at line 585 of file ProcFs.cc.

Member Data Documentation

◆ m_NextInode

Atomic<size_t> ProcFs::m_NextInode
private

Definition at line 227 of file ProcFs.h.

◆ m_PciDevices

String ProcFs::m_PciDevices
private

Definition at line 229 of file ProcFs.h.

◆ m_PidNamespace

SharedPointer<UserspacePidNamespace> ProcFs::m_PidNamespace
private

Definition at line 222 of file ProcFs.h.

◆ m_pRoot

ProcFsDirectory* ProcFs::m_pRoot
private

Definition at line 225 of file ProcFs.h.

◆ m_Registered

bool ProcFs::m_Registered = false
private

Definition at line 224 of file ProcFs.h.

◆ m_RegistryNext

ProcFs* ProcFs::m_RegistryNext = nullptr
private

Definition at line 223 of file ProcFs.h.


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