The Pedigree Project
0.1
|
#include <Filesystem.h>
Public Types | |
typedef Filesystem *(* | ProbeCallback) (Disk *) |
Public Member Functions | |
Filesystem () | |
virtual | ~Filesystem () |
virtual bool | initialise (Disk *pDisk)=0 |
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) |
virtual File * | getRoot () 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) |
Disk * | getDisk () |
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 |
Disk * | m_pDisk |
Private Member Functions | |
File * | getTrueRoot () |
File * | findNode (File *pNode, StringView path) |
File * | findParent (StringView path, File *pStartNode, String &filename) |
Filesystem (const Filesystem &) | |
void | operator= (const Filesystem &) |
Private Attributes | |
size_t | m_nAliases |
Friends | |
class | VFS |
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.
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.
Filesystem::Filesystem | ( | ) |
Constructor - creates a blank object.
Definition at line 35 of file Filesystem.cc.
References ~Filesystem().
|
virtualdefault |
|
private |
Copy constructor.
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().
|
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().
|
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().
|
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().
|
protectedpure virtual |
createSymlink calls this after it has parsed the string path.
Implemented in ConsoleManager, DevFs, ProcFs, RamFs, UnixFilesystem, RawFs, FatFilesystem, Iso9660Filesystem, and Ext2Filesystem.
|
virtual |
Attempt to find a file or directory in this filesystem.
path | The path to the file, in UTF-8 format, without filesystem identifier (e.g. not "root:/file", but "/file"). |
pStartNode | The node to start parsing 'path' from - defaults to / but is expected to contain the current working directory. |
Definition at line 53 of file Filesystem.cc.
References assert, findNode(), getTrueRoot(), and String::view().
Referenced by VFS::find(), and Symlink::followLink().
|
private |
Internal function to find a node - Returns 0 on failure or the node.
pNode | The node to start parsing 'path' from. |
path | The path from pNode to the destination node. |
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().
|
private |
Internal function to find a node's parent directory.
path | The path from pStartNode to the original file. | |
pStartNode | The node to start parsing 'path' from. | |
[out] | filename | The 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().
|
inline |
Returns the disk in use
Definition at line 101 of file Filesystem.h.
|
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().
|
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().
|
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().
|
pure virtual |
Populates this filesystem with data from the given Disk device.
Implemented in ConsoleManager, DevFs, ProcFs, RamFs, Ext2Filesystem, FatFilesystem, UnixFilesystem, Iso9660Filesystem, and RawFs.
Referenced by Symlink::isSymlink().
|
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().
|
inline |
Is the filesystem readonly?
Definition at line 107 of file Filesystem.h.
|
private |
Assignment operator.
Referenced by Symlink::fromFile(), Directory::fromFile(), and RamFs::getVolumeLabel().
bool Filesystem::remove | ( | const StringView & | path, |
File * | pStartNode = 0 |
||
) |
Removes a file, directory or symlink.
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().
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.
|
friend |
VFS can access nAliases
Definition at line 39 of file Filesystem.h.
|
protected |
is this entire filesystem read-only?
Definition at line 135 of file Filesystem.h.
Referenced by FatFilesystem::findFreeCluster().
|
private |
|
protected |
Disk device(if any).
Definition at line 137 of file Filesystem.h.
Referenced by RawFsFile::getBlockSize(), FatFilesystem::initialise(), RawFsFile::RawFsFile(), RawFsFile::readBlock(), FatFilesystem::readSectorBlock(), and FatFilesystem::writeSectorBlock().