The Pedigree Project  0.1
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Friends | List of all members
Filesystem Class Referenceabstract

#include <Filesystem.h>

+ Inheritance diagram for Filesystem:
+ Collaboration diagram for Filesystem:

Public Types

typedef Filesystem *(* ProbeCallback) (Disk *)
 

Public Member Functions

 Filesystem ()
 
virtual ~Filesystem ()
 
virtual bool initialise (Disk *pDisk)=0
 
virtual Filefind (const StringView &path)
 
virtual Filefind (const String &path)
 
virtual Filefind (const StringView &path, File *pStartNode)
 
virtual Filefind (const String &path, File *pStartNode)
 
virtual FilegetRoot () const =0
 
virtual String getVolumeLabel () const =0
 
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)
 
DiskgetDisk ()
 
bool isReadOnly ()
 
virtual bool isCaseSensitive ()
 
virtual bool remove (File *parent, File *file)=0
 

Protected Member Functions

virtual bool createFile (File *parent, const String &filename, uint32_t mask)=0
 
virtual bool createDirectory (File *parent, const String &filename, uint32_t mask)=0
 
virtual bool createSymlink (File *parent, const String &filename, const String &value)=0
 
virtual bool createLink (File *parent, const String &filename, File *target)
 

Protected Attributes

bool m_bReadOnly
 
Diskm_pDisk
 

Private Member Functions

FilegetTrueRoot ()
 
FilefindNode (File *pNode, StringView path)
 
FilefindParent (StringView path, File *pStartNode, String &filename)
 
 Filesystem (const Filesystem &)
 
void operator= (const Filesystem &)
 

Private Attributes

size_t m_nAliases
 

Friends

class VFS
 

Detailed Description

This class provides the abstract skeleton that all filesystems must implement.

Thanks to gr00ber at #osdev for the inspiration for the caching algorithms.

Definition at line 36 of file Filesystem.h.

Member Typedef Documentation

typedef Filesystem*(* Filesystem::ProbeCallback) (Disk *)

Type of the probing callback given to the VFS. Probe function - if this filesystem is found on the given Disk device, create a new instance of it and return that. Else return 0.

Definition at line 58 of file Filesystem.h.

Constructor & Destructor Documentation

Filesystem::Filesystem ( )

Constructor - creates a blank object.

Definition at line 35 of file Filesystem.cc.

References ~Filesystem().

Filesystem::~Filesystem ( )
virtualdefault

Destructor

Referenced by Filesystem().

+ Here is the caller graph for this function:

Filesystem::Filesystem ( const Filesystem )
private

Copy constructor.

Note
NOT implemented.

Member Function Documentation

bool Filesystem::createDirectory ( const StringView path,
uint32_t  mask,
File pStartNode = 0 
)

Creates a directory on the filesystem. Fails if the dir's parent directory does not exist.

Definition at line 112 of file Filesystem.cc.

References VFS::checkAccess(), createDirectory(), findNode(), findParent(), and getTrueRoot().

Referenced by createDirectory(), VFS::createDirectory(), and RamFs::getVolumeLabel().

+ Here is the caller graph for this function:

virtual bool Filesystem::createDirectory ( File parent,
const String filename,
uint32_t  mask 
)
protectedpure virtual

createDirectory calls this after it has parsed the string path.

Implemented in ConsoleManager, DevFs, ProcFs, RamFs, UnixFilesystem, RawFs, FatFilesystem, Iso9660Filesystem, and Ext2Filesystem.

bool Filesystem::createFile ( const StringView path,
uint32_t  mask,
File pStartNode = 0 
)

Creates a file on the filesystem - fails if the file's parent directory does not exist.

Definition at line 75 of file Filesystem.cc.

References VFS::checkAccess(), createFile(), findNode(), findParent(), and getTrueRoot().

Referenced by FatFilesystem::createDirectory(), FatFilesystem::createFile(), createFile(), VFS::createFile(), and RamFs::getVolumeLabel().

+ Here is the caller graph for this function:

virtual bool Filesystem::createFile ( File parent,
const String filename,
uint32_t  mask 
)
protectedpure virtual

createFile calls this after it has parsed the string path.

Implemented in ConsoleManager, DevFs, ProcFs, RamFs, UnixFilesystem, RawFs, FatFilesystem, Iso9660Filesystem, and Ext2Filesystem.

bool Filesystem::createLink ( const StringView path,
File target,
File pStartNode = 0 
)

Creates a hard link on the filesystem to the given target.

Definition at line 188 of file Filesystem.cc.

References VFS::checkAccess(), createLink(), findNode(), findParent(), and getTrueRoot().

Referenced by createLink(), and VFS::createLink().

+ Here is the caller graph for this function:

bool Filesystem::createLink ( File parent,
const String filename,
File target 
)
protectedvirtual

createLink calls this after it has parsed the string path.

Reimplemented in Ext2Filesystem.

Definition at line 498 of file Filesystem.cc.

bool Filesystem::createSymlink ( const StringView path,
const String value,
File pStartNode = 0 
)

Creates a symlink on the filesystem, with the given value.

Definition at line 149 of file Filesystem.cc.

References VFS::checkAccess(), createSymlink(), findNode(), findParent(), and getTrueRoot().

Referenced by createSymlink(), VFS::createSymlink(), and RamFs::getVolumeLabel().

+ Here is the caller graph for this function:

virtual bool Filesystem::createSymlink ( File parent,
const String filename,
const String value 
)
protectedpure virtual

createSymlink calls this after it has parsed the string path.

Implemented in ConsoleManager, DevFs, ProcFs, RamFs, UnixFilesystem, RawFs, FatFilesystem, Iso9660Filesystem, and Ext2Filesystem.

File * Filesystem::find ( const StringView path)
virtual

Attempt to find a file or directory in this filesystem.

Parameters
pathThe path to the file, in UTF-8 format, without filesystem identifier (e.g. not "root:/file", but "/file").
pStartNodeThe node to start parsing 'path' from - defaults to / but is expected to contain the current working directory.
Returns
The file if one was found, or 0 otherwise or if there was an error.

Definition at line 53 of file Filesystem.cc.

References assert, findNode(), getTrueRoot(), and String::view().

Referenced by VFS::find(), and Symlink::followLink().

+ Here is the caller graph for this function:

File * Filesystem::findNode ( File pNode,
StringView  path 
)
private

Internal function to find a node - Returns 0 on failure or the node.

Parameters
pNodeThe node to start parsing 'path' from.
pathThe path from pNode to the destination node.
Todo:
do we need to do permissions checks at each intermediate step?

Definition at line 316 of file Filesystem.cc.

References Directory::cacheDirectoryContents(), VFS::checkAccess(), Symlink::followLink(), Symlink::fromFile(), Directory::fromFile(), File::getFullPath(), Directory::getReparsePoint(), getTrueRoot(), Directory::isCachePopulated(), File::isDirectory(), File::isSymlink(), Directory::lookup(), StringView::substring(), UNLIKELY, and WARNING.

Referenced by createDirectory(), createFile(), createLink(), createSymlink(), find(), findParent(), and remove().

+ Here is the caller graph for this function:

File * Filesystem::findParent ( StringView  path,
File pStartNode,
String filename 
)
private

Internal function to find a node's parent directory.

Parameters
pathThe path from pStartNode to the original file.
pStartNodeThe node to start parsing 'path' from.
[out]filenameThe child file's name.

Definition at line 443 of file Filesystem.cc.

References findNode(), Directory::fromFile(), Directory::getReparsePoint(), File::isDirectory(), and StringView::substring().

Referenced by createDirectory(), createFile(), createLink(), createSymlink(), and remove().

+ Here is the caller graph for this function:

Disk* Filesystem::getDisk ( )
inline

Returns the disk in use

Definition at line 101 of file Filesystem.h.

virtual File* Filesystem::getRoot ( ) const
pure virtual

Returns the root filesystem node.

Implemented in ConsoleManager, DevFs, ProcFs, RamFs, UnixFilesystem, Ext2Filesystem, FatFilesystem, Iso9660Filesystem, and RawFs.

Referenced by PosixSubsystem::findFile(), getTrueRoot(), and FatFilesystem::initialise().

+ Here is the caller graph for this function:

File * Filesystem::getTrueRoot ( )
private

Get the true root of the filesystem, considering potential jails.

Definition at line 41 of file Filesystem.cc.

References getRoot(), Process::getRootFile(), and Processor::information().

Referenced by createDirectory(), createFile(), createLink(), createSymlink(), find(), findNode(), and remove().

+ Here is the caller graph for this function:

virtual String Filesystem::getVolumeLabel ( ) const
pure virtual

Returns a string identifying the volume label.

Implemented in ConsoleManager, DevFs, ProcFs, RamFs, UnixFilesystem, Ext2Filesystem, FatFilesystem, Iso9660Filesystem, and RawFs.

Referenced by File::getFilesystemLabel(), and VFS::mount().

+ Here is the caller graph for this function:

virtual bool Filesystem::initialise ( Disk pDisk)
pure virtual

Populates this filesystem with data from the given Disk device.

Returns
true on success, false on failure.

Implemented in ConsoleManager, DevFs, ProcFs, RamFs, Ext2Filesystem, FatFilesystem, UnixFilesystem, Iso9660Filesystem, and RawFs.

Referenced by Symlink::isSymlink().

+ Here is the caller graph for this function:

virtual bool Filesystem::isCaseSensitive ( )
inlinevirtual

Does the filesystem care about case sensitivity?

Definition at line 113 of file Filesystem.h.

References VFS::createDirectory(), VFS::createFile(), VFS::createLink(), and VFS::createSymlink().

bool Filesystem::isReadOnly ( )
inline

Is the filesystem readonly?

Definition at line 107 of file Filesystem.h.

void Filesystem::operator= ( const Filesystem )
private

Assignment operator.

Note
NOT implemented.

Referenced by Symlink::fromFile(), Directory::fromFile(), and RamFs::getVolumeLabel().

+ Here is the caller graph for this function:

bool Filesystem::remove ( const StringView path,
File pStartNode = 0 
)

Removes a file, directory or symlink.

Note
Will fail if it is a directory and is not empty. The failure mode is unspecified.

Definition at line 234 of file Filesystem.cc.

References VFS::checkAccess(), Directory::empty(), FATAL, findNode(), findParent(), Directory::fromFile(), Directory::getCache(), Directory::getNumChildren(), getTrueRoot(), File::isDirectory(), remove(), and Directory::remove().

Referenced by Directory::empty(), remove(), and VFS::remove().

+ Here is the caller graph for this function:

virtual bool Filesystem::remove ( File parent,
File file 
)
pure virtual

Remove a file given a parent and file, assuming path parsing already completed.

Implemented in ConsoleManager, DevFs, ProcFs, RamFs, UnixFilesystem, RawFs, FatFilesystem, Ext2Filesystem, and Iso9660Filesystem.

Friends And Related Function Documentation

friend class VFS
friend

VFS can access nAliases

Definition at line 39 of file Filesystem.h.

Member Data Documentation

bool Filesystem::m_bReadOnly
protected

is this entire filesystem read-only?

Definition at line 135 of file Filesystem.h.

Referenced by FatFilesystem::findFreeCluster().

size_t Filesystem::m_nAliases
private

Accessed by VFS

Definition at line 155 of file Filesystem.h.

Referenced by VFS::addAlias().

Disk* Filesystem::m_pDisk
protected

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