Some more renaming:
FileSystem -> FS SyntheticFileSystem -> SynthFS ProcFileSystem -> ProcFS Ext2FileSystem -> Ext2FS Ext2Inode -> Ext2FSInode
This commit is contained in:
parent
eced5f11e3
commit
2529925fe9
Notes:
sideshowbarker
2024-07-19 16:10:27 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/2529925fe9e
16 changed files with 187 additions and 187 deletions
|
@ -6,25 +6,25 @@
|
|||
#include "StdLib.h"
|
||||
#include "i386.h"
|
||||
|
||||
static ProcFileSystem* s_the;
|
||||
static ProcFS* s_the;
|
||||
|
||||
ProcFileSystem& ProcFileSystem::the()
|
||||
ProcFS& ProcFS::the()
|
||||
{
|
||||
ASSERT(s_the);
|
||||
return *s_the;
|
||||
}
|
||||
|
||||
RetainPtr<ProcFileSystem> ProcFileSystem::create()
|
||||
RetainPtr<ProcFS> ProcFS::create()
|
||||
{
|
||||
return adopt(*new ProcFileSystem);
|
||||
return adopt(*new ProcFS);
|
||||
}
|
||||
|
||||
ProcFileSystem::ProcFileSystem()
|
||||
ProcFS::ProcFS()
|
||||
{
|
||||
s_the = this;
|
||||
}
|
||||
|
||||
ProcFileSystem::~ProcFileSystem()
|
||||
ProcFS::~ProcFS()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,7 @@ ByteBuffer procfs$pid_cwd(Process& process)
|
|||
return VFS::the().absolute_path(*inode).toByteBuffer();
|
||||
}
|
||||
|
||||
void ProcFileSystem::addProcess(Process& process)
|
||||
void ProcFS::addProcess(Process& process)
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
char buf[16];
|
||||
|
@ -163,7 +163,7 @@ void ProcFileSystem::addProcess(Process& process)
|
|||
addFile(create_generated_file("cwd", [&process] { return procfs$pid_cwd(process); }, 00120777), dir.index());
|
||||
}
|
||||
|
||||
void ProcFileSystem::removeProcess(Process& process)
|
||||
void ProcFS::removeProcess(Process& process)
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
auto pid = process.pid();
|
||||
|
@ -354,9 +354,9 @@ ByteBuffer procfs$vnodes()
|
|||
return buffer;
|
||||
}
|
||||
|
||||
bool ProcFileSystem::initialize()
|
||||
bool ProcFS::initialize()
|
||||
{
|
||||
SyntheticFileSystem::initialize();
|
||||
SynthFS::initialize();
|
||||
addFile(create_generated_file("mm", procfs$mm));
|
||||
addFile(create_generated_file("regions", procfs$regions));
|
||||
addFile(create_generated_file("mounts", procfs$mounts));
|
||||
|
@ -367,7 +367,7 @@ bool ProcFileSystem::initialize()
|
|||
return true;
|
||||
}
|
||||
|
||||
const char* ProcFileSystem::class_name() const
|
||||
const char* ProcFS::class_name() const
|
||||
{
|
||||
return "procfs";
|
||||
}
|
||||
|
|
|
@ -5,12 +5,12 @@
|
|||
|
||||
class Process;
|
||||
|
||||
class ProcFileSystem final : public SyntheticFileSystem {
|
||||
class ProcFS final : public SynthFS {
|
||||
public:
|
||||
static ProcFileSystem& the() PURE;
|
||||
static ProcFS& the() PURE;
|
||||
|
||||
virtual ~ProcFileSystem() override;
|
||||
static RetainPtr<ProcFileSystem> create();
|
||||
virtual ~ProcFS() override;
|
||||
static RetainPtr<ProcFS> create();
|
||||
|
||||
virtual bool initialize() override;
|
||||
virtual const char* class_name() const override;
|
||||
|
@ -19,7 +19,7 @@ public:
|
|||
void removeProcess(Process&);
|
||||
|
||||
private:
|
||||
ProcFileSystem();
|
||||
ProcFS();
|
||||
|
||||
HashMap<pid_t, InodeIndex> m_pid2inode;
|
||||
};
|
||||
|
|
|
@ -274,7 +274,7 @@ Process* Process::fork(RegisterDump& regs)
|
|||
dbgprintf("fork: child will begin executing at %w:%x with stack %w:%x\n", child->m_tss.cs, child->m_tss.eip, child->m_tss.ss, child->m_tss.esp);
|
||||
#endif
|
||||
|
||||
ProcFileSystem::the().addProcess(*child);
|
||||
ProcFS::the().addProcess(*child);
|
||||
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
|
@ -498,7 +498,7 @@ Process* Process::create_user_process(const String& path, uid_t uid, gid_t gid,
|
|||
if (error != 0)
|
||||
return nullptr;
|
||||
|
||||
ProcFileSystem::the().addProcess(*process);
|
||||
ProcFS::the().addProcess(*process);
|
||||
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
|
@ -561,7 +561,7 @@ Process* Process::create_kernel_process(void (*e)(), String&& name)
|
|||
g_processes->prepend(process);
|
||||
system.nprocess++;
|
||||
}
|
||||
ProcFileSystem::the().addProcess(*process);
|
||||
ProcFS::the().addProcess(*process);
|
||||
#ifdef TASK_DEBUG
|
||||
kprintf("Kernel process %u (%s) spawned @ %p\n", process->pid(), process->name().characters(), process->m_tss.eip);
|
||||
#endif
|
||||
|
@ -691,7 +691,7 @@ Process::Process(String&& name, uid_t uid, gid_t gid, pid_t ppid, RingLevel ring
|
|||
Process::~Process()
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
ProcFileSystem::the().removeProcess(*this);
|
||||
ProcFS::the().removeProcess(*this);
|
||||
system.nprocess--;
|
||||
|
||||
gdt_free_entry(selector());
|
||||
|
|
|
@ -195,7 +195,7 @@ static void init_stage2()
|
|||
vfs->register_character_device(*tty3);
|
||||
|
||||
auto dev_hd0 = IDEDiskDevice::create();
|
||||
auto e2fs = Ext2FileSystem::create(dev_hd0.copyRef());
|
||||
auto e2fs = Ext2FS::create(dev_hd0.copyRef());
|
||||
e2fs->initialize();
|
||||
|
||||
vfs->mount_root(e2fs.copyRef());
|
||||
|
@ -214,7 +214,7 @@ static void init_stage2()
|
|||
}
|
||||
#endif
|
||||
|
||||
vfs->mount(ProcFileSystem::the(), "/proc");
|
||||
vfs->mount(ProcFS::the(), "/proc");
|
||||
|
||||
Vector<String> environment;
|
||||
environment.append("TERM=ansi");
|
||||
|
@ -280,7 +280,7 @@ void init()
|
|||
kprintf("%u kB base memory\n", base_memory);
|
||||
kprintf("%u kB extended memory\n", ext_memory);
|
||||
|
||||
auto procfs = ProcFileSystem::create();
|
||||
auto procfs = ProcFS::create();
|
||||
procfs->initialize();
|
||||
|
||||
Process::initialize();
|
||||
|
|
|
@ -9,17 +9,17 @@ typedef int InterruptDisabler;
|
|||
//#define DBFS_DEBUG
|
||||
#define BLOCK_CACHE
|
||||
|
||||
DiskBackedFileSystem::DiskBackedFileSystem(RetainPtr<DiskDevice>&& device)
|
||||
DiskBackedFS::DiskBackedFS(RetainPtr<DiskDevice>&& device)
|
||||
: m_device(move(device))
|
||||
{
|
||||
ASSERT(m_device);
|
||||
}
|
||||
|
||||
DiskBackedFileSystem::~DiskBackedFileSystem()
|
||||
DiskBackedFS::~DiskBackedFS()
|
||||
{
|
||||
}
|
||||
|
||||
bool DiskBackedFileSystem::writeBlock(unsigned index, const ByteBuffer& data)
|
||||
bool DiskBackedFS::writeBlock(unsigned index, const ByteBuffer& data)
|
||||
{
|
||||
ASSERT(data.size() == blockSize());
|
||||
#ifdef DBFS_DEBUG
|
||||
|
@ -29,7 +29,7 @@ bool DiskBackedFileSystem::writeBlock(unsigned index, const ByteBuffer& data)
|
|||
return device().write(baseOffset, blockSize(), data.pointer());
|
||||
}
|
||||
|
||||
bool DiskBackedFileSystem::writeBlocks(unsigned index, unsigned count, const ByteBuffer& data)
|
||||
bool DiskBackedFS::writeBlocks(unsigned index, unsigned count, const ByteBuffer& data)
|
||||
{
|
||||
#ifdef DBFS_DEBUG
|
||||
kprintf("DiskBackedFileSystem::writeBlocks %u x%u\n", index, count);
|
||||
|
@ -38,7 +38,7 @@ bool DiskBackedFileSystem::writeBlocks(unsigned index, unsigned count, const Byt
|
|||
return device().write(baseOffset, count * blockSize(), data.pointer());
|
||||
}
|
||||
|
||||
ByteBuffer DiskBackedFileSystem::readBlock(unsigned index) const
|
||||
ByteBuffer DiskBackedFS::readBlock(unsigned index) const
|
||||
{
|
||||
#ifdef DBFS_DEBUG
|
||||
kprintf("DiskBackedFileSystem::readBlock %u\n", index);
|
||||
|
@ -75,7 +75,7 @@ ByteBuffer DiskBackedFileSystem::readBlock(unsigned index) const
|
|||
return buffer;
|
||||
}
|
||||
|
||||
ByteBuffer DiskBackedFileSystem::readBlocks(unsigned index, unsigned count) const
|
||||
ByteBuffer DiskBackedFS::readBlocks(unsigned index, unsigned count) const
|
||||
{
|
||||
if (!count)
|
||||
return nullptr;
|
||||
|
@ -95,7 +95,7 @@ ByteBuffer DiskBackedFileSystem::readBlocks(unsigned index, unsigned count) cons
|
|||
return blocks;
|
||||
}
|
||||
|
||||
void DiskBackedFileSystem::setBlockSize(unsigned blockSize)
|
||||
void DiskBackedFS::setBlockSize(unsigned blockSize)
|
||||
{
|
||||
if (blockSize == m_blockSize)
|
||||
return;
|
||||
|
@ -103,7 +103,7 @@ void DiskBackedFileSystem::setBlockSize(unsigned blockSize)
|
|||
invalidateCaches();
|
||||
}
|
||||
|
||||
void DiskBackedFileSystem::invalidateCaches()
|
||||
void DiskBackedFS::invalidateCaches()
|
||||
{
|
||||
LOCKER(m_blockCacheLock);
|
||||
InterruptDisabler disabler;
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
#include <AK/HashMap.h>
|
||||
#include <AK/Lock.h>
|
||||
|
||||
class DiskBackedFileSystem : public FileSystem {
|
||||
class DiskBackedFS : public FS {
|
||||
public:
|
||||
virtual ~DiskBackedFileSystem() override;
|
||||
virtual ~DiskBackedFS() override;
|
||||
|
||||
DiskDevice& device() { return *m_device; }
|
||||
const DiskDevice& device() const { return *m_device; }
|
||||
|
@ -15,7 +15,7 @@ public:
|
|||
unsigned blockSize() const { return m_blockSize; }
|
||||
|
||||
protected:
|
||||
explicit DiskBackedFileSystem(RetainPtr<DiskDevice>&&);
|
||||
explicit DiskBackedFS(RetainPtr<DiskDevice>&&);
|
||||
|
||||
void setBlockSize(unsigned);
|
||||
void invalidateCaches();
|
||||
|
|
|
@ -11,14 +11,14 @@
|
|||
|
||||
//#define EXT2_DEBUG
|
||||
|
||||
class Ext2FileSystem::CachedExt2InodeImpl : public Retainable<CachedExt2InodeImpl> {
|
||||
class Ext2FS::CachedExt2InodeImpl : public Retainable<CachedExt2InodeImpl> {
|
||||
public:
|
||||
CachedExt2InodeImpl(OwnPtr<ext2_inode>&& e2i) : e2inode(move(e2i)) { }
|
||||
~CachedExt2InodeImpl() { }
|
||||
OwnPtr<ext2_inode> e2inode;
|
||||
};
|
||||
|
||||
class Ext2FileSystem::CachedExt2Inode {
|
||||
class Ext2FS::CachedExt2Inode {
|
||||
public:
|
||||
const ext2_inode* operator->() const { return ptr->e2inode.ptr(); }
|
||||
const ext2_inode& operator*() const { return *ptr->e2inode; }
|
||||
|
@ -36,21 +36,21 @@ public:
|
|||
RetainPtr<CachedExt2InodeImpl> ptr;
|
||||
};
|
||||
|
||||
RetainPtr<Ext2FileSystem> Ext2FileSystem::create(RetainPtr<DiskDevice>&& device)
|
||||
RetainPtr<Ext2FS> Ext2FS::create(RetainPtr<DiskDevice>&& device)
|
||||
{
|
||||
return adopt(*new Ext2FileSystem(move(device)));
|
||||
return adopt(*new Ext2FS(move(device)));
|
||||
}
|
||||
|
||||
Ext2FileSystem::Ext2FileSystem(RetainPtr<DiskDevice>&& device)
|
||||
: DiskBackedFileSystem(move(device))
|
||||
Ext2FS::Ext2FS(RetainPtr<DiskDevice>&& device)
|
||||
: DiskBackedFS(move(device))
|
||||
{
|
||||
}
|
||||
|
||||
Ext2FileSystem::~Ext2FileSystem()
|
||||
Ext2FS::~Ext2FS()
|
||||
{
|
||||
}
|
||||
|
||||
ByteBuffer Ext2FileSystem::readSuperBlock() const
|
||||
ByteBuffer Ext2FS::readSuperBlock() const
|
||||
{
|
||||
auto buffer = ByteBuffer::createUninitialized(1024);
|
||||
device().readBlock(2, buffer.pointer());
|
||||
|
@ -58,7 +58,7 @@ ByteBuffer Ext2FileSystem::readSuperBlock() const
|
|||
return buffer;
|
||||
}
|
||||
|
||||
bool Ext2FileSystem::writeSuperBlock(const ext2_super_block& sb)
|
||||
bool Ext2FS::writeSuperBlock(const ext2_super_block& sb)
|
||||
{
|
||||
const byte* raw = (const byte*)&sb;
|
||||
bool success;
|
||||
|
@ -71,19 +71,19 @@ bool Ext2FileSystem::writeSuperBlock(const ext2_super_block& sb)
|
|||
return true;
|
||||
}
|
||||
|
||||
unsigned Ext2FileSystem::firstBlockOfGroup(unsigned groupIndex) const
|
||||
unsigned Ext2FS::firstBlockOfGroup(unsigned groupIndex) const
|
||||
{
|
||||
return superBlock().s_first_data_block + (groupIndex * superBlock().s_blocks_per_group);
|
||||
}
|
||||
|
||||
const ext2_super_block& Ext2FileSystem::superBlock() const
|
||||
const ext2_super_block& Ext2FS::superBlock() const
|
||||
{
|
||||
if (!m_cachedSuperBlock)
|
||||
m_cachedSuperBlock = readSuperBlock();
|
||||
return *reinterpret_cast<ext2_super_block*>(m_cachedSuperBlock.pointer());
|
||||
}
|
||||
|
||||
const ext2_group_desc& Ext2FileSystem::blockGroupDescriptor(unsigned groupIndex) const
|
||||
const ext2_group_desc& Ext2FS::blockGroupDescriptor(unsigned groupIndex) const
|
||||
{
|
||||
// FIXME: Should this fail gracefully somehow?
|
||||
ASSERT(groupIndex <= m_blockGroupCount);
|
||||
|
@ -100,7 +100,7 @@ const ext2_group_desc& Ext2FileSystem::blockGroupDescriptor(unsigned groupIndex)
|
|||
return reinterpret_cast<ext2_group_desc*>(m_cachedBlockGroupDescriptorTable.pointer())[groupIndex - 1];
|
||||
}
|
||||
|
||||
bool Ext2FileSystem::initialize()
|
||||
bool Ext2FS::initialize()
|
||||
{
|
||||
auto& superBlock = this->superBlock();
|
||||
#ifdef EXT2_DEBUG
|
||||
|
@ -146,12 +146,12 @@ bool Ext2FileSystem::initialize()
|
|||
return true;
|
||||
}
|
||||
|
||||
const char* Ext2FileSystem::class_name() const
|
||||
const char* Ext2FS::class_name() const
|
||||
{
|
||||
return "ext2fs";
|
||||
}
|
||||
|
||||
InodeIdentifier Ext2FileSystem::rootInode() const
|
||||
InodeIdentifier Ext2FS::rootInode() const
|
||||
{
|
||||
return { id(), EXT2_ROOT_INO };
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ static void dumpExt2Inode(const ext2_inode& inode)
|
|||
}
|
||||
#endif
|
||||
|
||||
ByteBuffer Ext2FileSystem::readBlockContainingInode(unsigned inode, unsigned& blockIndex, unsigned& offset) const
|
||||
ByteBuffer Ext2FS::readBlockContainingInode(unsigned inode, unsigned& blockIndex, unsigned& offset) const
|
||||
{
|
||||
auto& superBlock = this->superBlock();
|
||||
|
||||
|
@ -187,7 +187,7 @@ ByteBuffer Ext2FileSystem::readBlockContainingInode(unsigned inode, unsigned& bl
|
|||
return readBlock(blockIndex);
|
||||
}
|
||||
|
||||
auto Ext2FileSystem::lookupExt2Inode(unsigned inode) const -> CachedExt2Inode
|
||||
auto Ext2FS::lookupExt2Inode(unsigned inode) const -> CachedExt2Inode
|
||||
{
|
||||
{
|
||||
LOCKER(m_inodeCacheLock);
|
||||
|
@ -218,7 +218,7 @@ auto Ext2FileSystem::lookupExt2Inode(unsigned inode) const -> CachedExt2Inode
|
|||
return CachedExt2Inode{ cachedInode };
|
||||
}
|
||||
|
||||
InodeMetadata Ext2FileSystem::inodeMetadata(InodeIdentifier inode) const
|
||||
InodeMetadata Ext2FS::inodeMetadata(InodeIdentifier inode) const
|
||||
{
|
||||
ASSERT(inode.fsid() == id());
|
||||
|
||||
|
@ -249,7 +249,7 @@ InodeMetadata Ext2FileSystem::inodeMetadata(InodeIdentifier inode) const
|
|||
return metadata;
|
||||
}
|
||||
|
||||
Vector<unsigned> Ext2FileSystem::blockListForInode(const ext2_inode& e2inode) const
|
||||
Vector<unsigned> Ext2FS::blockListForInode(const ext2_inode& e2inode) const
|
||||
{
|
||||
unsigned entriesPerBlock = EXT2_ADDR_PER_BLOCK(&superBlock());
|
||||
|
||||
|
@ -310,17 +310,17 @@ Vector<unsigned> Ext2FileSystem::blockListForInode(const ext2_inode& e2inode) co
|
|||
return list;
|
||||
}
|
||||
|
||||
Ext2Inode::Ext2Inode(Ext2FileSystem& fs, unsigned index, const ext2_inode& raw_inode)
|
||||
Ext2FSInode::Ext2FSInode(Ext2FS& fs, unsigned index, const ext2_inode& raw_inode)
|
||||
: CoreInode(fs, index)
|
||||
, m_raw_inode(raw_inode)
|
||||
{
|
||||
}
|
||||
|
||||
Ext2Inode::~Ext2Inode()
|
||||
Ext2FSInode::~Ext2FSInode()
|
||||
{
|
||||
}
|
||||
|
||||
void Ext2Inode::populate_metadata() const
|
||||
void Ext2FSInode::populate_metadata() const
|
||||
{
|
||||
m_metadata.inode = identifier();
|
||||
m_metadata.size = m_raw_inode.i_size;
|
||||
|
@ -342,7 +342,7 @@ void Ext2Inode::populate_metadata() const
|
|||
}
|
||||
}
|
||||
|
||||
RetainPtr<CoreInode> Ext2FileSystem::get_inode(InodeIdentifier inode) const
|
||||
RetainPtr<CoreInode> Ext2FS::get_inode(InodeIdentifier inode) const
|
||||
{
|
||||
ASSERT(inode.fsid() == id());
|
||||
{
|
||||
|
@ -358,12 +358,12 @@ RetainPtr<CoreInode> Ext2FileSystem::get_inode(InodeIdentifier inode) const
|
|||
auto it = m_inode_cache.find(inode.index());
|
||||
if (it != m_inode_cache.end())
|
||||
return (*it).value;
|
||||
auto new_inode = adopt(*new Ext2Inode(const_cast<Ext2FileSystem&>(*this), inode.index(), *raw_inode));
|
||||
auto new_inode = adopt(*new Ext2FSInode(const_cast<Ext2FS&>(*this), inode.index(), *raw_inode));
|
||||
m_inode_cache.set(inode.index(), new_inode.copyRef());
|
||||
return new_inode;
|
||||
}
|
||||
|
||||
Unix::ssize_t Ext2Inode::read_bytes(Unix::off_t offset, Unix::size_t count, byte* buffer, FileDescriptor*)
|
||||
Unix::ssize_t Ext2FSInode::read_bytes(Unix::off_t offset, Unix::size_t count, byte* buffer, FileDescriptor*)
|
||||
{
|
||||
ASSERT(offset >= 0);
|
||||
if (m_raw_inode.i_size == 0)
|
||||
|
@ -425,7 +425,7 @@ Unix::ssize_t Ext2Inode::read_bytes(Unix::off_t offset, Unix::size_t count, byte
|
|||
return nread;
|
||||
}
|
||||
|
||||
Unix::ssize_t Ext2FileSystem::read_inode_bytes(InodeIdentifier inode, Unix::off_t offset, Unix::size_t count, byte* buffer, FileDescriptor*) const
|
||||
Unix::ssize_t Ext2FS::read_inode_bytes(InodeIdentifier inode, Unix::off_t offset, Unix::size_t count, byte* buffer, FileDescriptor*) const
|
||||
{
|
||||
ASSERT(offset >= 0);
|
||||
ASSERT(inode.fsid() == id());
|
||||
|
@ -501,7 +501,7 @@ Unix::ssize_t Ext2FileSystem::read_inode_bytes(InodeIdentifier inode, Unix::off_
|
|||
return nread;
|
||||
}
|
||||
|
||||
bool Ext2FileSystem::writeInode(InodeIdentifier inode, const ByteBuffer& data)
|
||||
bool Ext2FS::writeInode(InodeIdentifier inode, const ByteBuffer& data)
|
||||
{
|
||||
ASSERT(inode.fsid() == id());
|
||||
|
||||
|
@ -536,7 +536,7 @@ bool Ext2FileSystem::writeInode(InodeIdentifier inode, const ByteBuffer& data)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Ext2Inode::traverse_as_directory(Function<bool(const FileSystem::DirectoryEntry&)> callback)
|
||||
bool Ext2FSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntry&)> callback)
|
||||
{
|
||||
ASSERT(metadata().isDirectory());
|
||||
|
||||
|
@ -561,7 +561,7 @@ bool Ext2Inode::traverse_as_directory(Function<bool(const FileSystem::DirectoryE
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Ext2FileSystem::deprecated_enumerateDirectoryInode(InodeIdentifier inode, Function<bool(const DirectoryEntry&)> callback) const
|
||||
bool Ext2FS::deprecated_enumerateDirectoryInode(InodeIdentifier inode, Function<bool(const DirectoryEntry&)> callback) const
|
||||
{
|
||||
ASSERT(inode.fsid() == id());
|
||||
ASSERT(isDirectoryInode(inode.index()));
|
||||
|
@ -587,7 +587,7 @@ bool Ext2FileSystem::deprecated_enumerateDirectoryInode(InodeIdentifier inode, F
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Ext2FileSystem::addInodeToDirectory(unsigned directoryInode, unsigned inode, const String& name, byte fileType)
|
||||
bool Ext2FS::addInodeToDirectory(unsigned directoryInode, unsigned inode, const String& name, byte fileType)
|
||||
{
|
||||
auto e2inodeForDirectory = lookupExt2Inode(directoryInode);
|
||||
ASSERT(e2inodeForDirectory);
|
||||
|
@ -616,7 +616,7 @@ bool Ext2FileSystem::addInodeToDirectory(unsigned directoryInode, unsigned inode
|
|||
return writeDirectoryInode(directoryInode, move(entries));
|
||||
}
|
||||
|
||||
bool Ext2FileSystem::writeDirectoryInode(unsigned directoryInode, Vector<DirectoryEntry>&& entries)
|
||||
bool Ext2FS::writeDirectoryInode(unsigned directoryInode, Vector<DirectoryEntry>&& entries)
|
||||
{
|
||||
kprintf("ext2fs: New directory inode %u contents to write:\n", directoryInode);
|
||||
|
||||
|
@ -679,27 +679,27 @@ bool Ext2FileSystem::writeDirectoryInode(unsigned directoryInode, Vector<Directo
|
|||
return true;
|
||||
}
|
||||
|
||||
unsigned Ext2FileSystem::inodesPerBlock() const
|
||||
unsigned Ext2FS::inodesPerBlock() const
|
||||
{
|
||||
return EXT2_INODES_PER_BLOCK(&superBlock());
|
||||
}
|
||||
|
||||
unsigned Ext2FileSystem::inodesPerGroup() const
|
||||
unsigned Ext2FS::inodesPerGroup() const
|
||||
{
|
||||
return EXT2_INODES_PER_GROUP(&superBlock());
|
||||
}
|
||||
|
||||
unsigned Ext2FileSystem::inodeSize() const
|
||||
unsigned Ext2FS::inodeSize() const
|
||||
{
|
||||
return EXT2_INODE_SIZE(&superBlock());
|
||||
|
||||
}
|
||||
unsigned Ext2FileSystem::blocksPerGroup() const
|
||||
unsigned Ext2FS::blocksPerGroup() const
|
||||
{
|
||||
return EXT2_BLOCKS_PER_GROUP(&superBlock());
|
||||
}
|
||||
|
||||
void Ext2FileSystem::dumpBlockBitmap(unsigned groupIndex) const
|
||||
void Ext2FS::dumpBlockBitmap(unsigned groupIndex) const
|
||||
{
|
||||
ASSERT(groupIndex <= m_blockGroupCount);
|
||||
auto& bgd = blockGroupDescriptor(groupIndex);
|
||||
|
@ -719,7 +719,7 @@ void Ext2FileSystem::dumpBlockBitmap(unsigned groupIndex) const
|
|||
kprintf("\n");
|
||||
}
|
||||
|
||||
void Ext2FileSystem::dumpInodeBitmap(unsigned groupIndex) const
|
||||
void Ext2FS::dumpInodeBitmap(unsigned groupIndex) const
|
||||
{
|
||||
traverseInodeBitmap(groupIndex, [] (unsigned, const Bitmap& bitmap) {
|
||||
for (unsigned i = 0; i < bitmap.size(); ++i)
|
||||
|
@ -729,7 +729,7 @@ void Ext2FileSystem::dumpInodeBitmap(unsigned groupIndex) const
|
|||
}
|
||||
|
||||
template<typename F>
|
||||
void Ext2FileSystem::traverseInodeBitmap(unsigned groupIndex, F callback) const
|
||||
void Ext2FS::traverseInodeBitmap(unsigned groupIndex, F callback) const
|
||||
{
|
||||
ASSERT(groupIndex <= m_blockGroupCount);
|
||||
auto& bgd = blockGroupDescriptor(groupIndex);
|
||||
|
@ -747,7 +747,7 @@ void Ext2FileSystem::traverseInodeBitmap(unsigned groupIndex, F callback) const
|
|||
}
|
||||
|
||||
template<typename F>
|
||||
void Ext2FileSystem::traverseBlockBitmap(unsigned groupIndex, F callback) const
|
||||
void Ext2FS::traverseBlockBitmap(unsigned groupIndex, F callback) const
|
||||
{
|
||||
ASSERT(groupIndex <= m_blockGroupCount);
|
||||
auto& bgd = blockGroupDescriptor(groupIndex);
|
||||
|
@ -764,7 +764,7 @@ void Ext2FileSystem::traverseBlockBitmap(unsigned groupIndex, F callback) const
|
|||
}
|
||||
}
|
||||
|
||||
bool Ext2FileSystem::modifyLinkCount(InodeIndex inode, int delta)
|
||||
bool Ext2FS::modifyLinkCount(InodeIndex inode, int delta)
|
||||
{
|
||||
ASSERT(inode);
|
||||
auto e2inode = lookupExt2Inode(inode);
|
||||
|
@ -778,7 +778,7 @@ bool Ext2FileSystem::modifyLinkCount(InodeIndex inode, int delta)
|
|||
return writeExt2Inode(inode, *e2inode);
|
||||
}
|
||||
|
||||
bool Ext2FileSystem::set_mtime(InodeIdentifier inode, dword timestamp)
|
||||
bool Ext2FS::set_mtime(InodeIdentifier inode, dword timestamp)
|
||||
{
|
||||
ASSERT(inode.fsid() == id());
|
||||
|
||||
|
@ -792,7 +792,7 @@ bool Ext2FileSystem::set_mtime(InodeIdentifier inode, dword timestamp)
|
|||
return writeExt2Inode(inode.index(), *e2inode);
|
||||
}
|
||||
|
||||
bool Ext2FileSystem::writeExt2Inode(unsigned inode, const ext2_inode& e2inode)
|
||||
bool Ext2FS::writeExt2Inode(unsigned inode, const ext2_inode& e2inode)
|
||||
{
|
||||
unsigned blockIndex;
|
||||
unsigned offset;
|
||||
|
@ -804,14 +804,14 @@ bool Ext2FileSystem::writeExt2Inode(unsigned inode, const ext2_inode& e2inode)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Ext2FileSystem::isDirectoryInode(unsigned inode) const
|
||||
bool Ext2FS::isDirectoryInode(unsigned inode) const
|
||||
{
|
||||
if (auto e2inode = lookupExt2Inode(inode))
|
||||
return isDirectory(e2inode->i_mode);
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector<Ext2FileSystem::BlockIndex> Ext2FileSystem::allocateBlocks(unsigned group, unsigned count)
|
||||
Vector<Ext2FS::BlockIndex> Ext2FS::allocateBlocks(unsigned group, unsigned count)
|
||||
{
|
||||
kprintf("ext2fs: allocateBlocks(group: %u, count: %u)\n", group, count);
|
||||
|
||||
|
@ -841,7 +841,7 @@ Vector<Ext2FileSystem::BlockIndex> Ext2FileSystem::allocateBlocks(unsigned group
|
|||
return blocks;
|
||||
}
|
||||
|
||||
unsigned Ext2FileSystem::allocateInode(unsigned preferredGroup, unsigned expectedSize)
|
||||
unsigned Ext2FS::allocateInode(unsigned preferredGroup, unsigned expectedSize)
|
||||
{
|
||||
kprintf("ext2fs: allocateInode(preferredGroup: %u, expectedSize: %u)\n", preferredGroup, expectedSize);
|
||||
|
||||
|
@ -896,14 +896,14 @@ unsigned Ext2FileSystem::allocateInode(unsigned preferredGroup, unsigned expecte
|
|||
return inode;
|
||||
}
|
||||
|
||||
unsigned Ext2FileSystem::groupIndexFromInode(unsigned inode) const
|
||||
unsigned Ext2FS::groupIndexFromInode(unsigned inode) const
|
||||
{
|
||||
if (!inode)
|
||||
return 0;
|
||||
return (inode - 1) / inodesPerGroup() + 1;
|
||||
}
|
||||
|
||||
bool Ext2FileSystem::setInodeAllocationState(unsigned inode, bool newState)
|
||||
bool Ext2FS::setInodeAllocationState(unsigned inode, bool newState)
|
||||
{
|
||||
auto& bgd = blockGroupDescriptor(groupIndexFromInode(inode));
|
||||
|
||||
|
@ -947,7 +947,7 @@ bool Ext2FileSystem::setInodeAllocationState(unsigned inode, bool newState)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Ext2FileSystem::setBlockAllocationState(GroupIndex group, BlockIndex bi, bool newState)
|
||||
bool Ext2FS::setBlockAllocationState(GroupIndex group, BlockIndex bi, bool newState)
|
||||
{
|
||||
auto& bgd = blockGroupDescriptor(group);
|
||||
|
||||
|
@ -991,7 +991,7 @@ bool Ext2FileSystem::setBlockAllocationState(GroupIndex group, BlockIndex bi, bo
|
|||
return true;
|
||||
}
|
||||
|
||||
InodeIdentifier Ext2FileSystem::create_directory(InodeIdentifier parentInode, const String& name, Unix::mode_t mode)
|
||||
InodeIdentifier Ext2FS::create_directory(InodeIdentifier parentInode, const String& name, Unix::mode_t mode)
|
||||
{
|
||||
ASSERT(parentInode.fsid() == id());
|
||||
ASSERT(isDirectoryInode(parentInode.index()));
|
||||
|
@ -1030,7 +1030,7 @@ InodeIdentifier Ext2FileSystem::create_directory(InodeIdentifier parentInode, co
|
|||
return inode;
|
||||
}
|
||||
|
||||
InodeIdentifier Ext2FileSystem::create_inode(InodeIdentifier parentInode, const String& name, Unix::mode_t mode, unsigned size)
|
||||
InodeIdentifier Ext2FS::create_inode(InodeIdentifier parentInode, const String& name, Unix::mode_t mode, unsigned size)
|
||||
{
|
||||
ASSERT(parentInode.fsid() == id());
|
||||
ASSERT(isDirectoryInode(parentInode.index()));
|
||||
|
@ -1119,7 +1119,7 @@ InodeIdentifier Ext2FileSystem::create_inode(InodeIdentifier parentInode, const
|
|||
return { id(), inode };
|
||||
}
|
||||
|
||||
InodeIdentifier Ext2FileSystem::find_parent_of_inode(InodeIdentifier inode_id) const
|
||||
InodeIdentifier Ext2FS::find_parent_of_inode(InodeIdentifier inode_id) const
|
||||
{
|
||||
auto inode = get_inode(inode_id);
|
||||
ASSERT(inode);
|
||||
|
@ -1127,7 +1127,7 @@ InodeIdentifier Ext2FileSystem::find_parent_of_inode(InodeIdentifier inode_id) c
|
|||
unsigned groupIndex = groupIndexFromInode(inode->index());
|
||||
unsigned firstInodeInGroup = inodesPerGroup() * (groupIndex - 1);
|
||||
|
||||
Vector<RetainPtr<Ext2Inode>> directories_in_group;
|
||||
Vector<RetainPtr<Ext2FSInode>> directories_in_group;
|
||||
|
||||
for (unsigned i = 0; i < inodesPerGroup(); ++i) {
|
||||
auto group_member = get_inode({ id(), firstInodeInGroup + i });
|
||||
|
@ -1148,7 +1148,7 @@ InodeIdentifier Ext2FileSystem::find_parent_of_inode(InodeIdentifier inode_id) c
|
|||
return foundParent;
|
||||
}
|
||||
|
||||
void Ext2Inode::populate_lookup_cache()
|
||||
void Ext2FSInode::populate_lookup_cache()
|
||||
{
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
|
@ -1168,7 +1168,7 @@ void Ext2Inode::populate_lookup_cache()
|
|||
m_lookup_cache = move(children);
|
||||
}
|
||||
|
||||
InodeIdentifier Ext2Inode::lookup(const String& name)
|
||||
InodeIdentifier Ext2FSInode::lookup(const String& name)
|
||||
{
|
||||
ASSERT(is_directory());
|
||||
populate_lookup_cache();
|
||||
|
@ -1179,7 +1179,7 @@ InodeIdentifier Ext2Inode::lookup(const String& name)
|
|||
return { };
|
||||
}
|
||||
|
||||
String Ext2Inode::reverse_lookup(InodeIdentifier child_id)
|
||||
String Ext2FSInode::reverse_lookup(InodeIdentifier child_id)
|
||||
{
|
||||
ASSERT(is_directory());
|
||||
ASSERT(child_id.fsid() == fsid());
|
||||
|
|
|
@ -10,12 +10,12 @@ struct ext2_group_desc;
|
|||
struct ext2_inode;
|
||||
struct ext2_super_block;
|
||||
|
||||
class Ext2FileSystem;
|
||||
class Ext2FS;
|
||||
|
||||
class Ext2Inode final : public CoreInode {
|
||||
friend class Ext2FileSystem;
|
||||
class Ext2FSInode final : public CoreInode {
|
||||
friend class Ext2FS;
|
||||
public:
|
||||
virtual ~Ext2Inode() override;
|
||||
virtual ~Ext2FSInode() override;
|
||||
|
||||
size_t size() const { return m_raw_inode.i_size; }
|
||||
bool is_symlink() const { return isSymbolicLink(m_raw_inode.i_mode); }
|
||||
|
@ -24,15 +24,15 @@ private:
|
|||
// ^CoreInode
|
||||
virtual Unix::ssize_t read_bytes(Unix::off_t, Unix::size_t, byte* buffer, FileDescriptor*) override;
|
||||
virtual void populate_metadata() const override;
|
||||
virtual bool traverse_as_directory(Function<bool(const FileSystem::DirectoryEntry&)>) override;
|
||||
virtual bool traverse_as_directory(Function<bool(const FS::DirectoryEntry&)>) override;
|
||||
virtual InodeIdentifier lookup(const String& name) override;
|
||||
virtual String reverse_lookup(InodeIdentifier) override;
|
||||
|
||||
void populate_lookup_cache();
|
||||
|
||||
Ext2FileSystem& fs();
|
||||
const Ext2FileSystem& fs() const;
|
||||
Ext2Inode(Ext2FileSystem&, unsigned index, const ext2_inode&);
|
||||
Ext2FS& fs();
|
||||
const Ext2FS& fs() const;
|
||||
Ext2FSInode(Ext2FS&, unsigned index, const ext2_inode&);
|
||||
|
||||
SpinLock m_lock;
|
||||
Vector<unsigned> m_block_list;
|
||||
|
@ -40,11 +40,11 @@ private:
|
|||
ext2_inode m_raw_inode;
|
||||
};
|
||||
|
||||
class Ext2FileSystem final : public DiskBackedFileSystem {
|
||||
friend class Ext2Inode;
|
||||
class Ext2FS final : public DiskBackedFS {
|
||||
friend class Ext2FSInode;
|
||||
public:
|
||||
static RetainPtr<Ext2FileSystem> create(RetainPtr<DiskDevice>&&);
|
||||
virtual ~Ext2FileSystem() override;
|
||||
static RetainPtr<Ext2FS> create(RetainPtr<DiskDevice>&&);
|
||||
virtual ~Ext2FS() override;
|
||||
virtual bool initialize() override;
|
||||
|
||||
private:
|
||||
|
@ -54,7 +54,7 @@ private:
|
|||
class CachedExt2Inode;
|
||||
class CachedExt2InodeImpl;
|
||||
|
||||
explicit Ext2FileSystem(RetainPtr<DiskDevice>&&);
|
||||
explicit Ext2FS(RetainPtr<DiskDevice>&&);
|
||||
|
||||
const ext2_super_block& superBlock() const;
|
||||
const ext2_group_desc& blockGroupDescriptor(unsigned groupIndex) const;
|
||||
|
@ -113,15 +113,15 @@ private:
|
|||
mutable HashMap<unsigned, RetainPtr<CachedExt2InodeImpl>> m_inodeCache;
|
||||
|
||||
mutable SpinLock m_inode_cache_lock;
|
||||
mutable HashMap<BlockIndex, RetainPtr<Ext2Inode>> m_inode_cache;
|
||||
mutable HashMap<BlockIndex, RetainPtr<Ext2FSInode>> m_inode_cache;
|
||||
};
|
||||
|
||||
inline Ext2FileSystem& Ext2Inode::fs()
|
||||
inline Ext2FS& Ext2FSInode::fs()
|
||||
{
|
||||
return static_cast<Ext2FileSystem&>(CoreInode::fs());
|
||||
return static_cast<Ext2FS&>(CoreInode::fs());
|
||||
}
|
||||
|
||||
inline const Ext2FileSystem& Ext2Inode::fs() const
|
||||
inline const Ext2FS& Ext2FSInode::fs() const
|
||||
{
|
||||
return static_cast<const Ext2FileSystem&>(CoreInode::fs());
|
||||
return static_cast<const Ext2FS&>(CoreInode::fs());
|
||||
}
|
||||
|
|
|
@ -3,33 +3,33 @@
|
|||
#include "FileSystem.h"
|
||||
|
||||
static dword s_lastFileSystemID;
|
||||
static HashMap<dword, FileSystem*>* map;
|
||||
static HashMap<dword, FS*>* map;
|
||||
|
||||
static HashMap<dword, FileSystem*>& fileSystems()
|
||||
static HashMap<dword, FS*>& fileSystems()
|
||||
{
|
||||
if (!map)
|
||||
map = new HashMap<dword, FileSystem*>();
|
||||
map = new HashMap<dword, FS*>();
|
||||
return *map;
|
||||
}
|
||||
|
||||
void FileSystem::initializeGlobals()
|
||||
void FS::initializeGlobals()
|
||||
{
|
||||
s_lastFileSystemID = 0;
|
||||
map = 0;
|
||||
}
|
||||
|
||||
FileSystem::FileSystem()
|
||||
FS::FS()
|
||||
: m_id(++s_lastFileSystemID)
|
||||
{
|
||||
fileSystems().set(m_id, this);
|
||||
}
|
||||
|
||||
FileSystem::~FileSystem()
|
||||
FS::~FS()
|
||||
{
|
||||
fileSystems().remove(m_id);
|
||||
}
|
||||
|
||||
FileSystem* FileSystem::fromID(dword id)
|
||||
FS* FS::fromID(dword id)
|
||||
{
|
||||
auto it = fileSystems().find(id);
|
||||
if (it != fileSystems().end())
|
||||
|
@ -69,7 +69,7 @@ ByteBuffer CoreInode::read_entire(FileDescriptor* descriptor)
|
|||
*/
|
||||
}
|
||||
|
||||
ByteBuffer FileSystem::readEntireInode(InodeIdentifier inode, FileDescriptor* handle) const
|
||||
ByteBuffer FS::readEntireInode(InodeIdentifier inode, FileDescriptor* handle) const
|
||||
{
|
||||
ASSERT(inode.fsid() == id());
|
||||
|
||||
|
@ -106,7 +106,7 @@ ByteBuffer FileSystem::readEntireInode(InodeIdentifier inode, FileDescriptor* ha
|
|||
return contents;
|
||||
}
|
||||
|
||||
FileSystem::DirectoryEntry::DirectoryEntry(const char* n, InodeIdentifier i, byte ft)
|
||||
FS::DirectoryEntry::DirectoryEntry(const char* n, InodeIdentifier i, byte ft)
|
||||
: name_length(strlen(name))
|
||||
, inode(i)
|
||||
, fileType(ft)
|
||||
|
@ -115,7 +115,7 @@ FileSystem::DirectoryEntry::DirectoryEntry(const char* n, InodeIdentifier i, byt
|
|||
name[name_length] = '\0';
|
||||
}
|
||||
|
||||
FileSystem::DirectoryEntry::DirectoryEntry(const char* n, Unix::size_t nl, InodeIdentifier i, byte ft)
|
||||
FS::DirectoryEntry::DirectoryEntry(const char* n, Unix::size_t nl, InodeIdentifier i, byte ft)
|
||||
: name_length(nl)
|
||||
, inode(i)
|
||||
, fileType(ft)
|
||||
|
|
|
@ -19,13 +19,13 @@ static const dword mepoch = 476763780;
|
|||
class CoreInode;
|
||||
class FileDescriptor;
|
||||
|
||||
class FileSystem : public Retainable<FileSystem> {
|
||||
class FS : public Retainable<FS> {
|
||||
public:
|
||||
static void initializeGlobals();
|
||||
virtual ~FileSystem();
|
||||
virtual ~FS();
|
||||
|
||||
dword id() const { return m_id; }
|
||||
static FileSystem* fromID(dword);
|
||||
static FS* fromID(dword);
|
||||
|
||||
virtual bool initialize() = 0;
|
||||
virtual const char* class_name() const = 0;
|
||||
|
@ -55,7 +55,7 @@ public:
|
|||
ByteBuffer readEntireInode(InodeIdentifier, FileDescriptor* = nullptr) const;
|
||||
|
||||
protected:
|
||||
FileSystem();
|
||||
FS();
|
||||
|
||||
private:
|
||||
dword m_id { 0 };
|
||||
|
@ -66,8 +66,8 @@ class CoreInode : public Retainable<CoreInode> {
|
|||
public:
|
||||
virtual ~CoreInode();
|
||||
|
||||
FileSystem& fs() { return m_fs; }
|
||||
const FileSystem& fs() const { return m_fs; }
|
||||
FS& fs() { return m_fs; }
|
||||
const FS& fs() const { return m_fs; }
|
||||
unsigned fsid() const;
|
||||
unsigned index() const { return m_index; }
|
||||
|
||||
|
@ -81,12 +81,12 @@ public:
|
|||
ByteBuffer read_entire(FileDescriptor* = nullptr);
|
||||
|
||||
virtual Unix::ssize_t read_bytes(Unix::off_t, Unix::size_t, byte* buffer, FileDescriptor*) = 0;
|
||||
virtual bool traverse_as_directory(Function<bool(const FileSystem::DirectoryEntry&)>) = 0;
|
||||
virtual bool traverse_as_directory(Function<bool(const FS::DirectoryEntry&)>) = 0;
|
||||
virtual InodeIdentifier lookup(const String& name) = 0;
|
||||
virtual String reverse_lookup(InodeIdentifier) = 0;
|
||||
|
||||
protected:
|
||||
CoreInode(FileSystem& fs, unsigned index)
|
||||
CoreInode(FS& fs, unsigned index)
|
||||
: m_fs(fs)
|
||||
, m_index(index)
|
||||
{
|
||||
|
@ -96,18 +96,18 @@ protected:
|
|||
|
||||
mutable InodeMetadata m_metadata;
|
||||
private:
|
||||
FileSystem& m_fs;
|
||||
FS& m_fs;
|
||||
unsigned m_index { 0 };
|
||||
};
|
||||
|
||||
inline FileSystem* InodeIdentifier::fileSystem()
|
||||
inline FS* InodeIdentifier::fileSystem()
|
||||
{
|
||||
return FileSystem::fromID(m_fileSystemID);
|
||||
return FS::fromID(m_fileSystemID);
|
||||
}
|
||||
|
||||
inline const FileSystem* InodeIdentifier::fileSystem() const
|
||||
inline const FS* InodeIdentifier::fileSystem() const
|
||||
{
|
||||
return FileSystem::fromID(m_fileSystemID);
|
||||
return FS::fromID(m_fileSystemID);
|
||||
}
|
||||
|
||||
inline InodeMetadata InodeIdentifier::metadata() const
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/Types.h>
|
||||
|
||||
class FileSystem;
|
||||
class FS;
|
||||
struct InodeMetadata;
|
||||
|
||||
class InodeIdentifier {
|
||||
|
@ -20,8 +20,8 @@ public:
|
|||
dword fsid() const { return m_fileSystemID; }
|
||||
dword index() const { return m_index; }
|
||||
|
||||
FileSystem* fileSystem();
|
||||
const FileSystem* fileSystem() const;
|
||||
FS* fileSystem();
|
||||
const FS* fileSystem() const;
|
||||
|
||||
bool operator==(const InodeIdentifier& other) const
|
||||
{
|
||||
|
|
|
@ -9,20 +9,20 @@ typedef int InterruptDisabler;
|
|||
|
||||
//#define SYNTHFS_DEBUG
|
||||
|
||||
RetainPtr<SyntheticFileSystem> SyntheticFileSystem::create()
|
||||
RetainPtr<SynthFS> SynthFS::create()
|
||||
{
|
||||
return adopt(*new SyntheticFileSystem);
|
||||
return adopt(*new SynthFS);
|
||||
}
|
||||
|
||||
SyntheticFileSystem::SyntheticFileSystem()
|
||||
SynthFS::SynthFS()
|
||||
{
|
||||
}
|
||||
|
||||
SyntheticFileSystem::~SyntheticFileSystem()
|
||||
SynthFS::~SynthFS()
|
||||
{
|
||||
}
|
||||
|
||||
bool SyntheticFileSystem::initialize()
|
||||
bool SynthFS::initialize()
|
||||
{
|
||||
// Add a File for the root directory.
|
||||
// FIXME: This needs work.
|
||||
|
@ -43,7 +43,7 @@ bool SyntheticFileSystem::initialize()
|
|||
return true;
|
||||
}
|
||||
|
||||
RetainPtr<SynthFSInode> SyntheticFileSystem::create_directory(String&& name)
|
||||
RetainPtr<SynthFSInode> SynthFS::create_directory(String&& name)
|
||||
{
|
||||
auto file = adopt(*new SynthFSInode(*this, generateInodeIndex()));
|
||||
file->m_name = move(name);
|
||||
|
@ -55,7 +55,7 @@ RetainPtr<SynthFSInode> SyntheticFileSystem::create_directory(String&& name)
|
|||
return file;
|
||||
}
|
||||
|
||||
RetainPtr<SynthFSInode> SyntheticFileSystem::create_text_file(String&& name, ByteBuffer&& contents, Unix::mode_t mode)
|
||||
RetainPtr<SynthFSInode> SynthFS::create_text_file(String&& name, ByteBuffer&& contents, Unix::mode_t mode)
|
||||
{
|
||||
auto file = adopt(*new SynthFSInode(*this, generateInodeIndex()));
|
||||
file->m_data = contents;
|
||||
|
@ -68,7 +68,7 @@ RetainPtr<SynthFSInode> SyntheticFileSystem::create_text_file(String&& name, Byt
|
|||
return file;
|
||||
}
|
||||
|
||||
RetainPtr<SynthFSInode> SyntheticFileSystem::create_generated_file(String&& name, Function<ByteBuffer()>&& generator, Unix::mode_t mode)
|
||||
RetainPtr<SynthFSInode> SynthFS::create_generated_file(String&& name, Function<ByteBuffer()>&& generator, Unix::mode_t mode)
|
||||
{
|
||||
auto file = adopt(*new SynthFSInode(*this, generateInodeIndex()));
|
||||
file->m_generator = move(generator);
|
||||
|
@ -81,7 +81,7 @@ RetainPtr<SynthFSInode> SyntheticFileSystem::create_generated_file(String&& name
|
|||
return file;
|
||||
}
|
||||
|
||||
InodeIdentifier SyntheticFileSystem::addFile(RetainPtr<SynthFSInode>&& file, InodeIndex parent)
|
||||
InodeIdentifier SynthFS::addFile(RetainPtr<SynthFSInode>&& file, InodeIndex parent)
|
||||
{
|
||||
ASSERT_INTERRUPTS_DISABLED();
|
||||
ASSERT(file);
|
||||
|
@ -95,7 +95,7 @@ InodeIdentifier SyntheticFileSystem::addFile(RetainPtr<SynthFSInode>&& file, Ino
|
|||
return new_inode_id;
|
||||
}
|
||||
|
||||
bool SyntheticFileSystem::removeFile(InodeIndex inode)
|
||||
bool SynthFS::removeFile(InodeIndex inode)
|
||||
{
|
||||
ASSERT_INTERRUPTS_DISABLED();
|
||||
auto it = m_inodes.find(inode);
|
||||
|
@ -121,17 +121,17 @@ bool SyntheticFileSystem::removeFile(InodeIndex inode)
|
|||
return true;
|
||||
}
|
||||
|
||||
const char* SyntheticFileSystem::class_name() const
|
||||
const char* SynthFS::class_name() const
|
||||
{
|
||||
return "synthfs";
|
||||
}
|
||||
|
||||
InodeIdentifier SyntheticFileSystem::rootInode() const
|
||||
InodeIdentifier SynthFS::rootInode() const
|
||||
{
|
||||
return { id(), 1 };
|
||||
}
|
||||
|
||||
InodeMetadata SyntheticFileSystem::inodeMetadata(InodeIdentifier inode) const
|
||||
InodeMetadata SynthFS::inodeMetadata(InodeIdentifier inode) const
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
ASSERT(inode.fsid() == id());
|
||||
|
@ -145,14 +145,14 @@ InodeMetadata SyntheticFileSystem::inodeMetadata(InodeIdentifier inode) const
|
|||
return (*it).value->m_metadata;
|
||||
}
|
||||
|
||||
bool SyntheticFileSystem::set_mtime(InodeIdentifier, dword timestamp)
|
||||
bool SynthFS::set_mtime(InodeIdentifier, dword timestamp)
|
||||
{
|
||||
(void) timestamp;
|
||||
kprintf("FIXME: Implement SyntheticFileSystem::setModificationTime().\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
InodeIdentifier SyntheticFileSystem::create_inode(InodeIdentifier parentInode, const String& name, Unix::mode_t mode, unsigned size)
|
||||
InodeIdentifier SynthFS::create_inode(InodeIdentifier parentInode, const String& name, Unix::mode_t mode, unsigned size)
|
||||
{
|
||||
(void) parentInode;
|
||||
(void) name;
|
||||
|
@ -162,13 +162,13 @@ InodeIdentifier SyntheticFileSystem::create_inode(InodeIdentifier parentInode, c
|
|||
return { };
|
||||
}
|
||||
|
||||
bool SyntheticFileSystem::writeInode(InodeIdentifier, const ByteBuffer&)
|
||||
bool SynthFS::writeInode(InodeIdentifier, const ByteBuffer&)
|
||||
{
|
||||
kprintf("FIXME: Implement SyntheticFileSystem::writeInode().\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
Unix::ssize_t SyntheticFileSystem::read_inode_bytes(InodeIdentifier inode, Unix::off_t offset, Unix::size_t count, byte* buffer, FileDescriptor* handle) const
|
||||
Unix::ssize_t SynthFS::read_inode_bytes(InodeIdentifier inode, Unix::off_t offset, Unix::size_t count, byte* buffer, FileDescriptor* handle) const
|
||||
{
|
||||
ASSERT(inode.fsid() == id());
|
||||
#ifdef SYNTHFS_DEBUG
|
||||
|
@ -205,7 +205,7 @@ Unix::ssize_t SyntheticFileSystem::read_inode_bytes(InodeIdentifier inode, Unix:
|
|||
return nread;
|
||||
}
|
||||
|
||||
InodeIdentifier SyntheticFileSystem::create_directory(InodeIdentifier parentInode, const String& name, Unix::mode_t)
|
||||
InodeIdentifier SynthFS::create_directory(InodeIdentifier parentInode, const String& name, Unix::mode_t)
|
||||
{
|
||||
(void) parentInode;
|
||||
(void) name;
|
||||
|
@ -213,12 +213,12 @@ InodeIdentifier SyntheticFileSystem::create_directory(InodeIdentifier parentInod
|
|||
return { };
|
||||
}
|
||||
|
||||
auto SyntheticFileSystem::generateInodeIndex() -> InodeIndex
|
||||
auto SynthFS::generateInodeIndex() -> InodeIndex
|
||||
{
|
||||
return m_nextInodeIndex++;
|
||||
}
|
||||
|
||||
InodeIdentifier SyntheticFileSystem::find_parent_of_inode(InodeIdentifier inode) const
|
||||
InodeIdentifier SynthFS::find_parent_of_inode(InodeIdentifier inode) const
|
||||
{
|
||||
auto it = m_inodes.find(inode.index());
|
||||
if (it == m_inodes.end())
|
||||
|
@ -226,7 +226,7 @@ InodeIdentifier SyntheticFileSystem::find_parent_of_inode(InodeIdentifier inode)
|
|||
return (*it).value->m_parent;
|
||||
}
|
||||
|
||||
RetainPtr<CoreInode> SyntheticFileSystem::get_inode(InodeIdentifier inode) const
|
||||
RetainPtr<CoreInode> SynthFS::get_inode(InodeIdentifier inode) const
|
||||
{
|
||||
auto it = m_inodes.find(inode.index());
|
||||
if (it == m_inodes.end())
|
||||
|
@ -234,7 +234,7 @@ RetainPtr<CoreInode> SyntheticFileSystem::get_inode(InodeIdentifier inode) const
|
|||
return (*it).value;
|
||||
}
|
||||
|
||||
SynthFSInode::SynthFSInode(SyntheticFileSystem& fs, unsigned index)
|
||||
SynthFSInode::SynthFSInode(SynthFS& fs, unsigned index)
|
||||
: CoreInode(fs, index)
|
||||
{
|
||||
m_metadata.inode = { fs.id(), index };
|
||||
|
@ -276,7 +276,7 @@ Unix::ssize_t SynthFSInode::read_bytes(Unix::off_t offset, Unix::size_t count, b
|
|||
return nread;
|
||||
}
|
||||
|
||||
bool SynthFSInode::traverse_as_directory(Function<bool(const FileSystem::DirectoryEntry&)> callback)
|
||||
bool SynthFSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntry&)> callback)
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
#ifdef SYNTHFS_DEBUG
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
|
||||
class SynthFSInode;
|
||||
|
||||
class SyntheticFileSystem : public FileSystem {
|
||||
class SynthFS : public FS {
|
||||
public:
|
||||
virtual ~SyntheticFileSystem() override;
|
||||
static RetainPtr<SyntheticFileSystem> create();
|
||||
virtual ~SynthFS() override;
|
||||
static RetainPtr<SynthFS> create();
|
||||
|
||||
virtual bool initialize() override;
|
||||
virtual const char* class_name() const override;
|
||||
|
@ -29,7 +29,7 @@ protected:
|
|||
InodeIndex generateInodeIndex();
|
||||
static constexpr InodeIndex RootInodeIndex = 1;
|
||||
|
||||
SyntheticFileSystem();
|
||||
SynthFS();
|
||||
|
||||
RetainPtr<SynthFSInode> create_directory(String&& name);
|
||||
RetainPtr<SynthFSInode> create_text_file(String&& name, ByteBuffer&&, Unix::mode_t = 0010644);
|
||||
|
@ -44,7 +44,7 @@ private:
|
|||
};
|
||||
|
||||
class SynthFSInode final : public CoreInode {
|
||||
friend class SyntheticFileSystem;
|
||||
friend class SynthFS;
|
||||
public:
|
||||
virtual ~SynthFSInode() override;
|
||||
|
||||
|
@ -52,13 +52,13 @@ private:
|
|||
// ^CoreInode
|
||||
virtual Unix::ssize_t read_bytes(Unix::off_t, Unix::size_t, byte* buffer, FileDescriptor*) override;
|
||||
virtual void populate_metadata() const override;
|
||||
virtual bool traverse_as_directory(Function<bool(const FileSystem::DirectoryEntry&)>) override;
|
||||
virtual bool traverse_as_directory(Function<bool(const FS::DirectoryEntry&)>) override;
|
||||
virtual InodeIdentifier lookup(const String& name) override;
|
||||
virtual String reverse_lookup(InodeIdentifier) override;
|
||||
|
||||
SyntheticFileSystem& fs();
|
||||
const SyntheticFileSystem& fs() const;
|
||||
SynthFSInode(SyntheticFileSystem&, unsigned index);
|
||||
SynthFS& fs();
|
||||
const SynthFS& fs() const;
|
||||
SynthFSInode(SynthFS&, unsigned index);
|
||||
|
||||
String m_name;
|
||||
InodeIdentifier m_parent;
|
||||
|
|
|
@ -25,7 +25,7 @@ VFS& VFS::the()
|
|||
void VFS::initialize_globals()
|
||||
{
|
||||
s_the = nullptr;
|
||||
FileSystem::initializeGlobals();
|
||||
FS::initializeGlobals();
|
||||
}
|
||||
|
||||
VFS::VFS()
|
||||
|
@ -74,7 +74,7 @@ auto VFS::makeNode(InodeIdentifier inode) -> RetainPtr<Vnode>
|
|||
auto vnode = allocateNode();
|
||||
ASSERT(vnode);
|
||||
|
||||
FileSystem* fileSystem = inode.fileSystem();
|
||||
FS* fileSystem = inode.fileSystem();
|
||||
fileSystem->retain();
|
||||
|
||||
vnode->inode = inode;
|
||||
|
@ -129,7 +129,7 @@ auto VFS::get_or_create_node(CharacterDevice& device) -> RetainPtr<Vnode>
|
|||
return makeNode(device);
|
||||
}
|
||||
|
||||
bool VFS::mount(RetainPtr<FileSystem>&& fileSystem, const String& path)
|
||||
bool VFS::mount(RetainPtr<FS>&& fileSystem, const String& path)
|
||||
{
|
||||
ASSERT(fileSystem);
|
||||
int error;
|
||||
|
@ -146,7 +146,7 @@ bool VFS::mount(RetainPtr<FileSystem>&& fileSystem, const String& path)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool VFS::mount_root(RetainPtr<FileSystem>&& fileSystem)
|
||||
bool VFS::mount_root(RetainPtr<FS>&& fileSystem)
|
||||
{
|
||||
if (m_root_vnode) {
|
||||
kprintf("VFS: mount_root can't mount another root\n");
|
||||
|
@ -243,9 +243,9 @@ bool VFS::is_vfs_root(InodeIdentifier inode) const
|
|||
return inode == m_root_vnode->inode;
|
||||
}
|
||||
|
||||
void VFS::traverse_directory_inode(CoreInode& dir_inode, Function<bool(const FileSystem::DirectoryEntry&)> callback)
|
||||
void VFS::traverse_directory_inode(CoreInode& dir_inode, Function<bool(const FS::DirectoryEntry&)> callback)
|
||||
{
|
||||
dir_inode.traverse_as_directory([&] (const FileSystem::DirectoryEntry& entry) {
|
||||
dir_inode.traverse_as_directory([&] (const FS::DirectoryEntry& entry) {
|
||||
InodeIdentifier resolvedInode;
|
||||
if (auto mount = find_mount_for_host(entry.inode))
|
||||
resolvedInode = mount->guest();
|
||||
|
@ -257,7 +257,7 @@ void VFS::traverse_directory_inode(CoreInode& dir_inode, Function<bool(const Fil
|
|||
ASSERT(mount);
|
||||
resolvedInode = mount->host();
|
||||
}
|
||||
callback(FileSystem::DirectoryEntry(entry.name, entry.name_length, resolvedInode, entry.fileType));
|
||||
callback(FS::DirectoryEntry(entry.name, entry.name_length, resolvedInode, entry.fileType));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
@ -597,7 +597,7 @@ const InodeMetadata& Vnode::metadata() const
|
|||
return m_cachedMetadata;
|
||||
}
|
||||
|
||||
VFS::Mount::Mount(InodeIdentifier host, RetainPtr<FileSystem>&& guest_fs)
|
||||
VFS::Mount::Mount(InodeIdentifier host, RetainPtr<FS>&& guest_fs)
|
||||
: m_host(host)
|
||||
, m_guest(guest_fs->rootInode())
|
||||
, m_guest_fs(move(guest_fs))
|
||||
|
|
|
@ -49,8 +49,8 @@ public:
|
|||
void retain();
|
||||
void release();
|
||||
|
||||
FileSystem* fileSystem() { return inode.fileSystem(); }
|
||||
const FileSystem* fileSystem() const { return inode.fileSystem(); }
|
||||
FS* fileSystem() { return inode.fileSystem(); }
|
||||
const FS* fileSystem() const { return inode.fileSystem(); }
|
||||
|
||||
VFS* vfs() { return m_vfs; }
|
||||
const VFS* vfs() const { return m_vfs; }
|
||||
|
@ -80,17 +80,17 @@ public:
|
|||
|
||||
class Mount {
|
||||
public:
|
||||
Mount(InodeIdentifier host, RetainPtr<FileSystem>&&);
|
||||
Mount(InodeIdentifier host, RetainPtr<FS>&&);
|
||||
|
||||
InodeIdentifier host() const { return m_host; }
|
||||
InodeIdentifier guest() const { return m_guest; }
|
||||
|
||||
const FileSystem& guest_fs() const { return *m_guest_fs; }
|
||||
const FS& guest_fs() const { return *m_guest_fs; }
|
||||
|
||||
private:
|
||||
InodeIdentifier m_host;
|
||||
InodeIdentifier m_guest;
|
||||
RetainPtr<FileSystem> m_guest_fs;
|
||||
RetainPtr<FS> m_guest_fs;
|
||||
};
|
||||
|
||||
static VFS& the() PURE;
|
||||
|
@ -110,8 +110,8 @@ public:
|
|||
Vnode* root() { return m_root_vnode.ptr(); }
|
||||
const Vnode* root() const { return m_root_vnode.ptr(); }
|
||||
|
||||
bool mount_root(RetainPtr<FileSystem>&&);
|
||||
bool mount(RetainPtr<FileSystem>&&, const String& path);
|
||||
bool mount_root(RetainPtr<FS>&&);
|
||||
bool mount(RetainPtr<FS>&&, const String& path);
|
||||
|
||||
RetainPtr<FileDescriptor> open(CharacterDevice&, int options);
|
||||
RetainPtr<FileDescriptor> open(const String& path, int& error, int options = 0, InodeIdentifier base = InodeIdentifier());
|
||||
|
@ -135,7 +135,7 @@ private:
|
|||
|
||||
bool is_vfs_root(InodeIdentifier) const;
|
||||
|
||||
void traverse_directory_inode(CoreInode&, Function<bool(const FileSystem::DirectoryEntry&)>);
|
||||
void traverse_directory_inode(CoreInode&, Function<bool(const FS::DirectoryEntry&)>);
|
||||
InodeIdentifier resolve_path(const String& path, int& error, CoreInode& base, int options = 0);
|
||||
InodeIdentifier resolve_path(const String& path, int& error, InodeIdentifier base = InodeIdentifier(), int options = 0);
|
||||
InodeIdentifier resolveSymbolicLink(InodeIdentifier base, InodeIdentifier symlinkInode, int& error);
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include <AK/kmalloc.h>
|
||||
#include <AK/ktime.h>
|
||||
|
||||
static RetainPtr<FileSystem> makeFileSystem(const char* imagePath);
|
||||
static RetainPtr<FS> makeFileSystem(const char* imagePath);
|
||||
|
||||
int main(int c, char** v)
|
||||
{
|
||||
|
@ -72,8 +72,8 @@ int main(int c, char** v)
|
|||
return 0;
|
||||
}
|
||||
|
||||
auto synthfs = SyntheticFileSystem::create();
|
||||
bool success = static_cast<FileSystem&>(*synthfs).initialize();
|
||||
auto synthfs = SynthFS::create();
|
||||
bool success = static_cast<FS&>(*synthfs).initialize();
|
||||
printf("synth->initialize(): returned %u\n", success);
|
||||
|
||||
vfs.mount(std::move(synthfs), "/syn");
|
||||
|
@ -234,16 +234,16 @@ int main(int c, char** v)
|
|||
return 0;
|
||||
}
|
||||
|
||||
RetainPtr<FileSystem> makeFileSystem(const char* imagePath)
|
||||
RetainPtr<FS> makeFileSystem(const char* imagePath)
|
||||
{
|
||||
auto fsImage = FileBackedDiskDevice::create(imagePath, 512);
|
||||
if (!fsImage->isValid()) {
|
||||
fprintf(stderr, "Failed to open fs image file '%s'\n", imagePath);
|
||||
exit(1);
|
||||
}
|
||||
auto ext2 = Ext2FileSystem::create(std::move(fsImage));
|
||||
auto ext2 = Ext2FS::create(std::move(fsImage));
|
||||
|
||||
bool success = static_cast<FileSystem&>(*ext2).initialize();
|
||||
bool success = static_cast<FS&>(*ext2).initialize();
|
||||
printf("ext2->initialize(): returned %u\n", success);
|
||||
return ext2;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue