mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:38:11 +00:00
Kernel: Rename FS => FileSystem
This matches our common naming style better.
This commit is contained in:
parent
dd65f52331
commit
d53d9d3677
33 changed files with 108 additions and 108 deletions
|
@ -124,7 +124,7 @@ public:
|
||||||
void unplug(USB::Device&);
|
void unplug(USB::Device&);
|
||||||
|
|
||||||
virtual KResultOr<size_t> entries_count() const override;
|
virtual KResultOr<size_t> entries_count() const override;
|
||||||
virtual KResult traverse_as_directory(unsigned, Function<bool(const FS::DirectoryEntryView&)>) const override;
|
virtual KResult traverse_as_directory(unsigned, Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
|
||||||
virtual RefPtr<ProcFSExposedComponent> lookup(StringView name) override;
|
virtual RefPtr<ProcFSExposedComponent> lookup(StringView name) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -141,7 +141,7 @@ KResultOr<size_t> ProcFSUSBBusFolder::entries_count() const
|
||||||
ScopedSpinLock lock(m_lock);
|
ScopedSpinLock lock(m_lock);
|
||||||
return m_device_nodes.size_slow();
|
return m_device_nodes.size_slow();
|
||||||
}
|
}
|
||||||
KResult ProcFSUSBBusFolder::traverse_as_directory(unsigned fsid, Function<bool(const FS::DirectoryEntryView&)> callback) const
|
KResult ProcFSUSBBusFolder::traverse_as_directory(unsigned fsid, Function<bool(FileSystem::DirectoryEntryView const&)> callback) const
|
||||||
{
|
{
|
||||||
ScopedSpinLock lock(m_lock);
|
ScopedSpinLock lock(m_lock);
|
||||||
auto parent_folder = m_parent_folder.strong_ref();
|
auto parent_folder = m_parent_folder.strong_ref();
|
||||||
|
|
|
@ -86,7 +86,7 @@ KResultOr<size_t> DevFSInode::read_bytes(off_t, size_t, UserOrKernelBuffer&, Fil
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
KResult DevFSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntryView&)>) const
|
KResult DevFSInode::traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)>) const
|
||||||
{
|
{
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
@ -201,7 +201,7 @@ InodeMetadata DevFSDirectoryInode::metadata() const
|
||||||
metadata.mtime = mepoch;
|
metadata.mtime = mepoch;
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
KResult DevFSDirectoryInode::traverse_as_directory(Function<bool(const FS::DirectoryEntryView&)>) const
|
KResult DevFSDirectoryInode::traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)>) const
|
||||||
{
|
{
|
||||||
Locker locker(m_lock);
|
Locker locker(m_lock);
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
@ -222,7 +222,7 @@ DevFSRootDirectoryInode::DevFSRootDirectoryInode(DevFS& fs)
|
||||||
, m_parent_fs(fs)
|
, m_parent_fs(fs)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
KResult DevFSRootDirectoryInode::traverse_as_directory(Function<bool(const FS::DirectoryEntryView&)> callback) const
|
KResult DevFSRootDirectoryInode::traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)> callback) const
|
||||||
{
|
{
|
||||||
Locker locker(m_parent_fs.m_lock);
|
Locker locker(m_parent_fs.m_lock);
|
||||||
callback({ ".", identifier(), 0 });
|
callback({ ".", identifier(), 0 });
|
||||||
|
@ -392,7 +392,7 @@ DevFSPtsDirectoryInode::DevFSPtsDirectoryInode(DevFS& fs)
|
||||||
: DevFSDirectoryInode(fs)
|
: DevFSDirectoryInode(fs)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
KResult DevFSPtsDirectoryInode::traverse_as_directory(Function<bool(const FS::DirectoryEntryView&)> callback) const
|
KResult DevFSPtsDirectoryInode::traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)> callback) const
|
||||||
{
|
{
|
||||||
Locker locker(m_lock);
|
Locker locker(m_lock);
|
||||||
callback({ ".", identifier(), 0 });
|
callback({ ".", identifier(), 0 });
|
||||||
|
|
|
@ -21,7 +21,7 @@ class DevFSRootDirectoryInode;
|
||||||
class DevFSDevicesDirectoryInode;
|
class DevFSDevicesDirectoryInode;
|
||||||
class DevFSPtsDirectoryInode;
|
class DevFSPtsDirectoryInode;
|
||||||
class Device;
|
class Device;
|
||||||
class DevFS final : public FS {
|
class DevFS final : public FileSystem {
|
||||||
friend class DevFSInode;
|
friend class DevFSInode;
|
||||||
friend class DevFSRootDirectoryInode;
|
friend class DevFSRootDirectoryInode;
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
DevFSInode(DevFS&);
|
DevFSInode(DevFS&);
|
||||||
virtual KResultOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, FileDescription*) const override;
|
virtual KResultOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, FileDescription*) const override;
|
||||||
virtual KResult traverse_as_directory(Function<bool(const FS::DirectoryEntryView&)>) const override;
|
virtual KResult traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
|
||||||
virtual RefPtr<Inode> lookup(StringView name) override;
|
virtual RefPtr<Inode> lookup(StringView name) override;
|
||||||
virtual void flush_metadata() override;
|
virtual void flush_metadata() override;
|
||||||
virtual KResultOr<size_t> write_bytes(off_t, size_t, const UserOrKernelBuffer& buffer, FileDescription*) override;
|
virtual KResultOr<size_t> write_bytes(off_t, size_t, const UserOrKernelBuffer& buffer, FileDescription*) override;
|
||||||
|
@ -125,7 +125,7 @@ protected:
|
||||||
DevFSDirectoryInode(DevFS&);
|
DevFSDirectoryInode(DevFS&);
|
||||||
// ^Inode
|
// ^Inode
|
||||||
virtual InodeMetadata metadata() const override;
|
virtual InodeMetadata metadata() const override;
|
||||||
virtual KResult traverse_as_directory(Function<bool(const FS::DirectoryEntryView&)>) const override;
|
virtual KResult traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
|
||||||
virtual RefPtr<Inode> lookup(StringView name) override;
|
virtual RefPtr<Inode> lookup(StringView name) override;
|
||||||
virtual KResultOr<size_t> directory_entry_count() const override;
|
virtual KResultOr<size_t> directory_entry_count() const override;
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit DevFSPtsDirectoryInode(DevFS&);
|
explicit DevFSPtsDirectoryInode(DevFS&);
|
||||||
virtual KResult traverse_as_directory(Function<bool(const FS::DirectoryEntryView&)>) const override;
|
virtual KResult traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
|
||||||
virtual RefPtr<Inode> lookup(StringView name) override;
|
virtual RefPtr<Inode> lookup(StringView name) override;
|
||||||
virtual InodeMetadata metadata() const override;
|
virtual InodeMetadata metadata() const override;
|
||||||
virtual KResultOr<size_t> directory_entry_count() const override;
|
virtual KResultOr<size_t> directory_entry_count() const override;
|
||||||
|
@ -158,7 +158,7 @@ public:
|
||||||
private:
|
private:
|
||||||
explicit DevFSRootDirectoryInode(DevFS&);
|
explicit DevFSRootDirectoryInode(DevFS&);
|
||||||
virtual KResultOr<NonnullRefPtr<Inode>> create_child(const String& name, mode_t, dev_t, uid_t, gid_t) override;
|
virtual KResultOr<NonnullRefPtr<Inode>> create_child(const String& name, mode_t, dev_t, uid_t, gid_t) override;
|
||||||
virtual KResult traverse_as_directory(Function<bool(const FS::DirectoryEntryView&)>) const override;
|
virtual KResult traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
|
||||||
virtual RefPtr<Inode> lookup(StringView name) override;
|
virtual RefPtr<Inode> lookup(StringView name) override;
|
||||||
virtual InodeMetadata metadata() const override;
|
virtual InodeMetadata metadata() const override;
|
||||||
virtual KResultOr<size_t> directory_entry_count() const override;
|
virtual KResultOr<size_t> directory_entry_count() const override;
|
||||||
|
|
|
@ -120,7 +120,7 @@ InodeMetadata DevPtsFSInode::metadata() const
|
||||||
return m_metadata;
|
return m_metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
KResult DevPtsFSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntryView&)> callback) const
|
KResult DevPtsFSInode::traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)> callback) const
|
||||||
{
|
{
|
||||||
if (identifier().index() > 1)
|
if (identifier().index() > 1)
|
||||||
return ENOTDIR;
|
return ENOTDIR;
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace Kernel {
|
||||||
class SlavePTY;
|
class SlavePTY;
|
||||||
class DevPtsFSInode;
|
class DevPtsFSInode;
|
||||||
|
|
||||||
class DevPtsFS final : public FS {
|
class DevPtsFS final : public FileSystem {
|
||||||
friend class DevPtsFSInode;
|
friend class DevPtsFSInode;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -49,7 +49,7 @@ private:
|
||||||
// ^Inode
|
// ^Inode
|
||||||
virtual KResultOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, FileDescription*) const override;
|
virtual KResultOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, FileDescription*) const override;
|
||||||
virtual InodeMetadata metadata() const override;
|
virtual InodeMetadata metadata() const override;
|
||||||
virtual KResult traverse_as_directory(Function<bool(const FS::DirectoryEntryView&)>) const override;
|
virtual KResult traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
|
||||||
virtual RefPtr<Inode> lookup(StringView name) override;
|
virtual RefPtr<Inode> lookup(StringView name) override;
|
||||||
virtual void flush_metadata() override;
|
virtual void flush_metadata() override;
|
||||||
virtual KResultOr<size_t> write_bytes(off_t, size_t, const UserOrKernelBuffer& buffer, FileDescription*) override;
|
virtual KResultOr<size_t> write_bytes(off_t, size_t, const UserOrKernelBuffer& buffer, FileDescription*) override;
|
||||||
|
|
|
@ -1068,7 +1068,7 @@ Ext2FS::FeaturesReadOnly Ext2FS::get_features_readonly() const
|
||||||
return Ext2FS::FeaturesReadOnly::None;
|
return Ext2FS::FeaturesReadOnly::None;
|
||||||
}
|
}
|
||||||
|
|
||||||
KResult Ext2FSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntryView&)> callback) const
|
KResult Ext2FSInode::traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)> callback) const
|
||||||
{
|
{
|
||||||
Locker locker(m_lock);
|
Locker locker(m_lock);
|
||||||
VERIFY(is_directory());
|
VERIFY(is_directory());
|
||||||
|
|
|
@ -40,7 +40,7 @@ private:
|
||||||
// ^Inode
|
// ^Inode
|
||||||
virtual KResultOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, FileDescription*) const override;
|
virtual KResultOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, FileDescription*) const override;
|
||||||
virtual InodeMetadata metadata() const override;
|
virtual InodeMetadata metadata() const override;
|
||||||
virtual KResult traverse_as_directory(Function<bool(const FS::DirectoryEntryView&)>) const override;
|
virtual KResult traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
|
||||||
virtual RefPtr<Inode> lookup(StringView name) override;
|
virtual RefPtr<Inode> lookup(StringView name) override;
|
||||||
virtual void flush_metadata() override;
|
virtual void flush_metadata() override;
|
||||||
virtual KResultOr<size_t> write_bytes(off_t, size_t, const UserOrKernelBuffer& data, FileDescription*) override;
|
virtual KResultOr<size_t> write_bytes(off_t, size_t, const UserOrKernelBuffer& data, FileDescription*) override;
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
class FileBackedFS : public FS {
|
class FileBackedFS : public FileSystem {
|
||||||
public:
|
public:
|
||||||
virtual ~FileBackedFS() override;
|
virtual ~FileBackedFS() override;
|
||||||
|
|
||||||
|
|
|
@ -19,57 +19,57 @@
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
static u32 s_lastFileSystemID;
|
static u32 s_lastFileSystemID;
|
||||||
static AK::Singleton<HashMap<u32, FS*>> s_fs_map;
|
static AK::Singleton<HashMap<u32, FileSystem*>> s_file_system_map;
|
||||||
|
|
||||||
static HashMap<u32, FS*>& all_fses()
|
static HashMap<u32, FileSystem*>& all_file_systems()
|
||||||
{
|
{
|
||||||
return *s_fs_map;
|
return *s_file_system_map;
|
||||||
}
|
}
|
||||||
|
|
||||||
FS::FS()
|
FileSystem::FileSystem()
|
||||||
: m_fsid(++s_lastFileSystemID)
|
: m_fsid(++s_lastFileSystemID)
|
||||||
{
|
{
|
||||||
all_fses().set(m_fsid, this);
|
s_file_system_map->set(m_fsid, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
FS::~FS()
|
FileSystem::~FileSystem()
|
||||||
{
|
{
|
||||||
all_fses().remove(m_fsid);
|
s_file_system_map->remove(m_fsid);
|
||||||
}
|
}
|
||||||
|
|
||||||
FS* FS::from_fsid(u32 id)
|
FileSystem* FileSystem::from_fsid(u32 id)
|
||||||
{
|
{
|
||||||
auto it = all_fses().find(id);
|
auto it = all_file_systems().find(id);
|
||||||
if (it != all_fses().end())
|
if (it != all_file_systems().end())
|
||||||
return (*it).value;
|
return (*it).value;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
FS::DirectoryEntryView::DirectoryEntryView(const StringView& n, InodeIdentifier i, u8 ft)
|
FileSystem::DirectoryEntryView::DirectoryEntryView(const StringView& n, InodeIdentifier i, u8 ft)
|
||||||
: name(n)
|
: name(n)
|
||||||
, inode(i)
|
, inode(i)
|
||||||
, file_type(ft)
|
, file_type(ft)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void FS::sync()
|
void FileSystem::sync()
|
||||||
{
|
{
|
||||||
Inode::sync();
|
Inode::sync();
|
||||||
|
|
||||||
NonnullRefPtrVector<FS, 32> fses;
|
NonnullRefPtrVector<FileSystem, 32> file_systems;
|
||||||
{
|
{
|
||||||
InterruptDisabler disabler;
|
InterruptDisabler disabler;
|
||||||
for (auto& it : all_fses())
|
for (auto& it : all_file_systems())
|
||||||
fses.append(*it.value);
|
file_systems.append(*it.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& fs : fses)
|
for (auto& fs : file_systems)
|
||||||
fs.flush_writes();
|
fs.flush_writes();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FS::lock_all()
|
void FileSystem::lock_all()
|
||||||
{
|
{
|
||||||
for (auto& it : all_fses()) {
|
for (auto& it : all_file_systems()) {
|
||||||
it.value->m_lock.lock();
|
it.value->m_lock.lock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -25,14 +25,14 @@ class FileDescription;
|
||||||
class LocalSocket;
|
class LocalSocket;
|
||||||
class VMObject;
|
class VMObject;
|
||||||
|
|
||||||
class FS : public RefCounted<FS> {
|
class FileSystem : public RefCounted<FileSystem> {
|
||||||
friend class Inode;
|
friend class Inode;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~FS();
|
virtual ~FileSystem();
|
||||||
|
|
||||||
unsigned fsid() const { return m_fsid; }
|
unsigned fsid() const { return m_fsid; }
|
||||||
static FS* from_fsid(u32);
|
static FileSystem* from_fsid(u32);
|
||||||
static void sync();
|
static void sync();
|
||||||
static void lock_all();
|
static void lock_all();
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ public:
|
||||||
virtual u8 internal_file_type_to_directory_entry_type(const DirectoryEntryView& entry) const { return entry.file_type; }
|
virtual u8 internal_file_type_to_directory_entry_type(const DirectoryEntryView& entry) const { return entry.file_type; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
FS();
|
FileSystem();
|
||||||
|
|
||||||
void set_block_size(u64 size) { m_block_size = size; }
|
void set_block_size(u64 size) { m_block_size = size; }
|
||||||
void set_fragment_size(size_t size) { m_fragment_size = size; }
|
void set_fragment_size(size_t size) { m_fragment_size = size; }
|
||||||
|
@ -83,14 +83,14 @@ private:
|
||||||
bool m_readonly { false };
|
bool m_readonly { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
inline FS* InodeIdentifier::fs()
|
inline FileSystem* InodeIdentifier::fs()
|
||||||
{
|
{
|
||||||
return FS::from_fsid(m_fsid);
|
return FileSystem::from_fsid(m_fsid);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const FS* InodeIdentifier::fs() const
|
inline const FileSystem* InodeIdentifier::fs() const
|
||||||
{
|
{
|
||||||
return FS::from_fsid(m_fsid);
|
return FileSystem::from_fsid(m_fsid);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,8 +89,8 @@ KResultOr<NonnullRefPtr<Custody>> Inode::resolve_as_link(Custody& base, RefPtr<C
|
||||||
return VFS::the().resolve_path(path, base, out_parent, options, symlink_recursion_level);
|
return VFS::the().resolve_path(path, base, out_parent, options, symlink_recursion_level);
|
||||||
}
|
}
|
||||||
|
|
||||||
Inode::Inode(FS& fs, InodeIndex index)
|
Inode::Inode(FileSystem& fs, InodeIndex index)
|
||||||
: m_fs(fs)
|
: m_file_system(fs)
|
||||||
, m_index(index)
|
, m_index(index)
|
||||||
{
|
{
|
||||||
ScopedSpinLock all_inodes_lock(s_all_inodes_lock);
|
ScopedSpinLock all_inodes_lock(s_all_inodes_lock);
|
||||||
|
|
|
@ -26,16 +26,16 @@ namespace Kernel {
|
||||||
class Inode : public RefCounted<Inode>
|
class Inode : public RefCounted<Inode>
|
||||||
, public Weakable<Inode> {
|
, public Weakable<Inode> {
|
||||||
friend class VFS;
|
friend class VFS;
|
||||||
friend class FS;
|
friend class FileSystem;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~Inode();
|
virtual ~Inode();
|
||||||
|
|
||||||
virtual void one_ref_left() { }
|
virtual void one_ref_left() { }
|
||||||
|
|
||||||
FS& fs() { return m_fs; }
|
FileSystem& fs() { return m_file_system; }
|
||||||
const FS& fs() const { return m_fs; }
|
FileSystem const& fs() const { return m_file_system; }
|
||||||
unsigned fsid() const { return m_fs.fsid(); }
|
unsigned fsid() const { return m_file_system.fsid(); }
|
||||||
InodeIndex index() const { return m_index; }
|
InodeIndex index() const { return m_index; }
|
||||||
|
|
||||||
size_t size() const { return metadata().size; }
|
size_t size() const { return metadata().size; }
|
||||||
|
@ -53,7 +53,7 @@ public:
|
||||||
virtual void detach(FileDescription&) { }
|
virtual void detach(FileDescription&) { }
|
||||||
virtual void did_seek(FileDescription&, off_t) { }
|
virtual void did_seek(FileDescription&, off_t) { }
|
||||||
virtual KResultOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, FileDescription*) const = 0;
|
virtual KResultOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, FileDescription*) const = 0;
|
||||||
virtual KResult traverse_as_directory(Function<bool(const FS::DirectoryEntryView&)>) const = 0;
|
virtual KResult traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)>) const = 0;
|
||||||
virtual RefPtr<Inode> lookup(StringView name) = 0;
|
virtual RefPtr<Inode> lookup(StringView name) = 0;
|
||||||
virtual KResultOr<size_t> write_bytes(off_t, size_t, const UserOrKernelBuffer& data, FileDescription*) = 0;
|
virtual KResultOr<size_t> write_bytes(off_t, size_t, const UserOrKernelBuffer& data, FileDescription*) = 0;
|
||||||
virtual KResultOr<NonnullRefPtr<Inode>> create_child(const String& name, mode_t, dev_t, uid_t, gid_t) = 0;
|
virtual KResultOr<NonnullRefPtr<Inode>> create_child(const String& name, mode_t, dev_t, uid_t, gid_t) = 0;
|
||||||
|
@ -100,7 +100,7 @@ public:
|
||||||
NonnullRefPtr<FIFO> fifo();
|
NonnullRefPtr<FIFO> fifo();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Inode(FS& fs, InodeIndex);
|
Inode(FileSystem&, InodeIndex);
|
||||||
void set_metadata_dirty(bool);
|
void set_metadata_dirty(bool);
|
||||||
KResult prepare_to_write_data();
|
KResult prepare_to_write_data();
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ protected:
|
||||||
mutable Lock m_lock { "Inode" };
|
mutable Lock m_lock { "Inode" };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FS& m_fs;
|
FileSystem& m_file_system;
|
||||||
InodeIndex m_index { 0 };
|
InodeIndex m_index { 0 };
|
||||||
WeakPtr<SharedInodeVMObject> m_shared_vmobject;
|
WeakPtr<SharedInodeVMObject> m_shared_vmobject;
|
||||||
RefPtr<LocalSocket> m_socket;
|
RefPtr<LocalSocket> m_socket;
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
class FS;
|
class FileSystem;
|
||||||
struct InodeMetadata;
|
struct InodeMetadata;
|
||||||
|
|
||||||
TYPEDEF_DISTINCT_ORDERED_ID(u64, InodeIndex);
|
TYPEDEF_DISTINCT_ORDERED_ID(u64, InodeIndex);
|
||||||
|
@ -32,8 +32,8 @@ public:
|
||||||
u32 fsid() const { return m_fsid; }
|
u32 fsid() const { return m_fsid; }
|
||||||
InodeIndex index() const { return m_index; }
|
InodeIndex index() const { return m_index; }
|
||||||
|
|
||||||
FS* fs();
|
FileSystem* fs();
|
||||||
const FS* fs() const;
|
const FileSystem* fs() const;
|
||||||
|
|
||||||
bool operator==(const InodeIdentifier& other) const
|
bool operator==(const InodeIdentifier& other) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -865,7 +865,7 @@ KResultOr<size_t> Plan9FSInode::directory_entry_count() const
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
KResult Plan9FSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntryView&)> callback) const
|
KResult Plan9FSInode::traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)> callback) const
|
||||||
{
|
{
|
||||||
KResult result = KSuccess;
|
KResult result = KSuccess;
|
||||||
|
|
||||||
|
|
|
@ -158,7 +158,7 @@ public:
|
||||||
virtual void flush_metadata() override;
|
virtual void flush_metadata() override;
|
||||||
virtual KResultOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, FileDescription*) const override;
|
virtual KResultOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, FileDescription*) const override;
|
||||||
virtual KResultOr<size_t> write_bytes(off_t, size_t, const UserOrKernelBuffer& data, FileDescription*) override;
|
virtual KResultOr<size_t> write_bytes(off_t, size_t, const UserOrKernelBuffer& data, FileDescription*) override;
|
||||||
virtual KResult traverse_as_directory(Function<bool(const FS::DirectoryEntryView&)>) const override;
|
virtual KResult traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
|
||||||
virtual RefPtr<Inode> lookup(StringView name) override;
|
virtual RefPtr<Inode> lookup(StringView name) override;
|
||||||
virtual KResultOr<NonnullRefPtr<Inode>> create_child(const String& name, mode_t, dev_t, uid_t, gid_t) override;
|
virtual KResultOr<NonnullRefPtr<Inode>> create_child(const String& name, mode_t, dev_t, uid_t, gid_t) override;
|
||||||
virtual KResult add_child(Inode&, const StringView& name, mode_t) override;
|
virtual KResult add_child(Inode&, const StringView& name, mode_t) override;
|
||||||
|
|
|
@ -129,7 +129,7 @@ StringView ProcFSInode::name() const
|
||||||
return m_associated_component->name();
|
return m_associated_component->name();
|
||||||
}
|
}
|
||||||
|
|
||||||
KResult ProcFSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntryView&)>) const
|
KResult ProcFSInode::traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)>) const
|
||||||
{
|
{
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
@ -222,7 +222,7 @@ InodeMetadata ProcFSDirectoryInode::metadata() const
|
||||||
metadata.mtime = m_associated_component->modified_time();
|
metadata.mtime = m_associated_component->modified_time();
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
KResult ProcFSDirectoryInode::traverse_as_directory(Function<bool(const FS::DirectoryEntryView&)> callback) const
|
KResult ProcFSDirectoryInode::traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)> callback) const
|
||||||
{
|
{
|
||||||
Locker locker(m_parent_fs.m_lock);
|
Locker locker(m_parent_fs.m_lock);
|
||||||
return m_associated_component->traverse_as_directory(m_parent_fs.fsid(), move(callback));
|
return m_associated_component->traverse_as_directory(m_parent_fs.fsid(), move(callback));
|
||||||
|
|
|
@ -21,7 +21,7 @@ class Process;
|
||||||
class ProcFSInode;
|
class ProcFSInode;
|
||||||
class ProcFSDirectoryInode;
|
class ProcFSDirectoryInode;
|
||||||
|
|
||||||
class ProcFS final : public FS {
|
class ProcFS final : public FileSystem {
|
||||||
friend class ProcFSInode;
|
friend class ProcFSInode;
|
||||||
friend class ProcFSDirectoryInode;
|
friend class ProcFSDirectoryInode;
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ protected:
|
||||||
// ^Inode
|
// ^Inode
|
||||||
virtual KResult attach(FileDescription& description) override;
|
virtual KResult attach(FileDescription& description) override;
|
||||||
virtual KResultOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, FileDescription*) const override;
|
virtual KResultOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, FileDescription*) const override;
|
||||||
virtual KResult traverse_as_directory(Function<bool(const FS::DirectoryEntryView&)>) const override;
|
virtual KResult traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
|
||||||
virtual RefPtr<Inode> lookup(StringView name) override;
|
virtual RefPtr<Inode> lookup(StringView name) override;
|
||||||
virtual void flush_metadata() override;
|
virtual void flush_metadata() override;
|
||||||
virtual InodeMetadata metadata() const override;
|
virtual InodeMetadata metadata() const override;
|
||||||
|
@ -93,7 +93,7 @@ protected:
|
||||||
ProcFSDirectoryInode(const ProcFS&, const ProcFSExposedComponent&);
|
ProcFSDirectoryInode(const ProcFS&, const ProcFSExposedComponent&);
|
||||||
// ^Inode
|
// ^Inode
|
||||||
virtual InodeMetadata metadata() const override;
|
virtual InodeMetadata metadata() const override;
|
||||||
virtual KResult traverse_as_directory(Function<bool(const FS::DirectoryEntryView&)>) const override;
|
virtual KResult traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
|
||||||
virtual RefPtr<Inode> lookup(StringView name) override;
|
virtual RefPtr<Inode> lookup(StringView name) override;
|
||||||
virtual KResultOr<size_t> directory_entry_count() const override;
|
virtual KResultOr<size_t> directory_entry_count() const override;
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ NonnullRefPtr<SysFSRootFolder> SysFSRootFolder::create()
|
||||||
return adopt_ref(*new (nothrow) SysFSRootFolder);
|
return adopt_ref(*new (nothrow) SysFSRootFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
KResult SysFSRootFolder::traverse_as_directory(unsigned fsid, Function<bool(const FS::DirectoryEntryView&)> callback) const
|
KResult SysFSRootFolder::traverse_as_directory(unsigned fsid, Function<bool(FileSystem::DirectoryEntryView const&)> callback) const
|
||||||
{
|
{
|
||||||
Locker locker(SystemRegistrar::the().m_lock);
|
Locker locker(SystemRegistrar::the().m_lock);
|
||||||
callback({ ".", { fsid, component_index() }, 0 });
|
callback({ ".", { fsid, component_index() }, 0 });
|
||||||
|
@ -101,7 +101,7 @@ KResultOr<size_t> SysFSInode::read_bytes(off_t offset, size_t count, UserOrKerne
|
||||||
return m_associated_component->read_bytes(offset, count, buffer, fd);
|
return m_associated_component->read_bytes(offset, count, buffer, fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
KResult SysFSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntryView&)>) const
|
KResult SysFSInode::traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)>) const
|
||||||
{
|
{
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
@ -194,7 +194,7 @@ InodeMetadata SysFSDirectoryInode::metadata() const
|
||||||
metadata.mtime = mepoch;
|
metadata.mtime = mepoch;
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
KResult SysFSDirectoryInode::traverse_as_directory(Function<bool(const FS::DirectoryEntryView&)> callback) const
|
KResult SysFSDirectoryInode::traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)> callback) const
|
||||||
{
|
{
|
||||||
Locker locker(m_parent_fs.m_lock);
|
Locker locker(m_parent_fs.m_lock);
|
||||||
return m_associated_component->traverse_as_directory(m_parent_fs.fsid(), move(callback));
|
return m_associated_component->traverse_as_directory(m_parent_fs.fsid(), move(callback));
|
||||||
|
|
|
@ -26,7 +26,7 @@ class SysFSRootFolder final : public SystemExposedFolder {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static NonnullRefPtr<SysFSRootFolder> create();
|
static NonnullRefPtr<SysFSRootFolder> create();
|
||||||
virtual KResult traverse_as_directory(unsigned, Function<bool(const FS::DirectoryEntryView&)>) const override;
|
virtual KResult traverse_as_directory(unsigned, Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SysFSRootFolder();
|
SysFSRootFolder();
|
||||||
|
@ -53,7 +53,7 @@ private:
|
||||||
NonnullRefPtr<SysFSRootFolder> m_root_folder;
|
NonnullRefPtr<SysFSRootFolder> m_root_folder;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SysFS final : public FS {
|
class SysFS final : public FileSystem {
|
||||||
friend class SysFSInode;
|
friend class SysFSInode;
|
||||||
friend class SysFSDirectoryInode;
|
friend class SysFSDirectoryInode;
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
SysFSInode(const SysFS&, const SystemExposedComponent&);
|
SysFSInode(const SysFS&, const SystemExposedComponent&);
|
||||||
virtual KResultOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, FileDescription*) const override;
|
virtual KResultOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, FileDescription*) const override;
|
||||||
virtual KResult traverse_as_directory(Function<bool(const FS::DirectoryEntryView&)>) const override;
|
virtual KResult traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
|
||||||
virtual RefPtr<Inode> lookup(StringView name) override;
|
virtual RefPtr<Inode> lookup(StringView name) override;
|
||||||
virtual void flush_metadata() override;
|
virtual void flush_metadata() override;
|
||||||
virtual InodeMetadata metadata() const override;
|
virtual InodeMetadata metadata() const override;
|
||||||
|
@ -111,7 +111,7 @@ protected:
|
||||||
SysFSDirectoryInode(const SysFS&, const SystemExposedComponent&);
|
SysFSDirectoryInode(const SysFS&, const SystemExposedComponent&);
|
||||||
// ^Inode
|
// ^Inode
|
||||||
virtual InodeMetadata metadata() const override;
|
virtual InodeMetadata metadata() const override;
|
||||||
virtual KResult traverse_as_directory(Function<bool(const FS::DirectoryEntryView&)>) const override;
|
virtual KResult traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
|
||||||
virtual RefPtr<Inode> lookup(StringView name) override;
|
virtual RefPtr<Inode> lookup(StringView name) override;
|
||||||
virtual KResultOr<size_t> directory_entry_count() const override;
|
virtual KResultOr<size_t> directory_entry_count() const override;
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,7 @@ InodeMetadata TmpFSInode::metadata() const
|
||||||
return m_metadata;
|
return m_metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
KResult TmpFSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntryView&)> callback) const
|
KResult TmpFSInode::traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)> callback) const
|
||||||
{
|
{
|
||||||
Locker locker(m_lock, Lock::Mode::Shared);
|
Locker locker(m_lock, Lock::Mode::Shared);
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace Kernel {
|
||||||
|
|
||||||
class TmpFSInode;
|
class TmpFSInode;
|
||||||
|
|
||||||
class TmpFS final : public FS {
|
class TmpFS final : public FileSystem {
|
||||||
friend class TmpFSInode;
|
friend class TmpFSInode;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -56,7 +56,7 @@ public:
|
||||||
// ^Inode
|
// ^Inode
|
||||||
virtual KResultOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, FileDescription*) const override;
|
virtual KResultOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, FileDescription*) const override;
|
||||||
virtual InodeMetadata metadata() const override;
|
virtual InodeMetadata metadata() const override;
|
||||||
virtual KResult traverse_as_directory(Function<bool(const FS::DirectoryEntryView&)>) const override;
|
virtual KResult traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
|
||||||
virtual RefPtr<Inode> lookup(StringView name) override;
|
virtual RefPtr<Inode> lookup(StringView name) override;
|
||||||
virtual void flush_metadata() override;
|
virtual void flush_metadata() override;
|
||||||
virtual KResultOr<size_t> write_bytes(off_t, size_t, const UserOrKernelBuffer& buffer, FileDescription*) override;
|
virtual KResultOr<size_t> write_bytes(off_t, size_t, const UserOrKernelBuffer& buffer, FileDescription*) override;
|
||||||
|
|
|
@ -49,18 +49,18 @@ InodeIdentifier VFS::root_inode_id() const
|
||||||
return m_root_inode->identifier();
|
return m_root_inode->identifier();
|
||||||
}
|
}
|
||||||
|
|
||||||
KResult VFS::mount(FS& file_system, Custody& mount_point, int flags)
|
KResult VFS::mount(FileSystem& fs, Custody& mount_point, int flags)
|
||||||
{
|
{
|
||||||
Locker locker(m_lock);
|
Locker locker(m_lock);
|
||||||
|
|
||||||
auto& inode = mount_point.inode();
|
auto& inode = mount_point.inode();
|
||||||
dbgln("VFS: Mounting {} at {} (inode: {}) with flags {}",
|
dbgln("VFS: Mounting {} at {} (inode: {}) with flags {}",
|
||||||
file_system.class_name(),
|
fs.class_name(),
|
||||||
mount_point.try_create_absolute_path(),
|
mount_point.try_create_absolute_path(),
|
||||||
inode.identifier(),
|
inode.identifier(),
|
||||||
flags);
|
flags);
|
||||||
// FIXME: check that this is not already a mount point
|
// FIXME: check that this is not already a mount point
|
||||||
Mount mount { file_system, &mount_point, flags };
|
Mount mount { fs, &mount_point, flags };
|
||||||
m_mounts.append(move(mount));
|
m_mounts.append(move(mount));
|
||||||
return KSuccess;
|
return KSuccess;
|
||||||
}
|
}
|
||||||
|
@ -112,23 +112,23 @@ KResult VFS::unmount(Inode& guest_inode)
|
||||||
return ENODEV;
|
return ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VFS::mount_root(FS& file_system)
|
bool VFS::mount_root(FileSystem& fs)
|
||||||
{
|
{
|
||||||
if (m_root_inode) {
|
if (m_root_inode) {
|
||||||
dmesgln("VFS: mount_root can't mount another root");
|
dmesgln("VFS: mount_root can't mount another root");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Mount mount { file_system, nullptr, root_mount_flags };
|
Mount mount { fs, nullptr, root_mount_flags };
|
||||||
|
|
||||||
auto root_inode = file_system.root_inode();
|
auto root_inode = fs.root_inode();
|
||||||
if (!root_inode->is_directory()) {
|
if (!root_inode->is_directory()) {
|
||||||
dmesgln("VFS: root inode ({}) for / is not a directory :(", root_inode->identifier());
|
dmesgln("VFS: root inode ({}) for / is not a directory :(", root_inode->identifier());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_root_inode = move(root_inode);
|
m_root_inode = move(root_inode);
|
||||||
dmesgln("VFS: mounted root from {} ({})", file_system.class_name(), static_cast<FileBackedFS&>(file_system).file_description().absolute_path());
|
dmesgln("VFS: mounted root from {} ({})", fs.class_name(), static_cast<FileBackedFS&>(fs).file_description().absolute_path());
|
||||||
|
|
||||||
m_mounts.append(move(mount));
|
m_mounts.append(move(mount));
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@ bool VFS::is_vfs_root(InodeIdentifier inode) const
|
||||||
return inode == root_inode_id();
|
return inode == root_inode_id();
|
||||||
}
|
}
|
||||||
|
|
||||||
KResult VFS::traverse_directory_inode(Inode& dir_inode, Function<bool(const FS::DirectoryEntryView&)> callback)
|
KResult VFS::traverse_directory_inode(Inode& dir_inode, Function<bool(FileSystem::DirectoryEntryView const&)> callback)
|
||||||
{
|
{
|
||||||
return dir_inode.traverse_as_directory([&](auto& entry) {
|
return dir_inode.traverse_as_directory([&](auto& entry) {
|
||||||
InodeIdentifier resolved_inode;
|
InodeIdentifier resolved_inode;
|
||||||
|
@ -780,7 +780,7 @@ KResult VFS::rmdir(StringView path, Custody& base)
|
||||||
return parent_inode.remove_child(KLexicalPath::basename(path));
|
return parent_inode.remove_child(KLexicalPath::basename(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
VFS::Mount::Mount(FS& guest_fs, Custody* host_custody, int flags)
|
VFS::Mount::Mount(FileSystem& guest_fs, Custody* host_custody, int flags)
|
||||||
: m_guest(guest_fs.root_inode())
|
: m_guest(guest_fs.root_inode())
|
||||||
, m_guest_fs(guest_fs)
|
, m_guest_fs(guest_fs)
|
||||||
, m_host_custody(host_custody)
|
, m_host_custody(host_custody)
|
||||||
|
@ -826,7 +826,7 @@ void VFS::for_each_mount(Function<void(const Mount&)> callback) const
|
||||||
|
|
||||||
void VFS::sync()
|
void VFS::sync()
|
||||||
{
|
{
|
||||||
FS::sync();
|
FileSystem::sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
Custody& VFS::root_custody()
|
Custody& VFS::root_custody()
|
||||||
|
|
|
@ -35,7 +35,7 @@ class VFS {
|
||||||
public:
|
public:
|
||||||
class Mount {
|
class Mount {
|
||||||
public:
|
public:
|
||||||
Mount(FS&, Custody* host_custody, int flags);
|
Mount(FileSystem&, Custody* host_custody, int flags);
|
||||||
Mount(Inode& source, Custody& host_custody, int flags);
|
Mount(Inode& source, Custody& host_custody, int flags);
|
||||||
|
|
||||||
const Inode* host() const;
|
const Inode* host() const;
|
||||||
|
@ -44,7 +44,7 @@ public:
|
||||||
const Inode& guest() const { return *m_guest; }
|
const Inode& guest() const { return *m_guest; }
|
||||||
Inode& guest() { return *m_guest; }
|
Inode& guest() { return *m_guest; }
|
||||||
|
|
||||||
const FS& guest_fs() const { return *m_guest_fs; }
|
FileSystem const& guest_fs() const { return *m_guest_fs; }
|
||||||
|
|
||||||
String absolute_path() const;
|
String absolute_path() const;
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NonnullRefPtr<Inode> m_guest;
|
NonnullRefPtr<Inode> m_guest;
|
||||||
NonnullRefPtr<FS> m_guest_fs;
|
NonnullRefPtr<FileSystem> m_guest_fs;
|
||||||
RefPtr<Custody> m_host_custody;
|
RefPtr<Custody> m_host_custody;
|
||||||
int m_flags;
|
int m_flags;
|
||||||
};
|
};
|
||||||
|
@ -64,8 +64,8 @@ public:
|
||||||
VFS();
|
VFS();
|
||||||
~VFS();
|
~VFS();
|
||||||
|
|
||||||
bool mount_root(FS&);
|
bool mount_root(FileSystem&);
|
||||||
KResult mount(FS&, Custody& mount_point, int flags);
|
KResult mount(FileSystem&, Custody& mount_point, int flags);
|
||||||
KResult bind_mount(Custody& source, Custody& mount_point, int flags);
|
KResult bind_mount(Custody& source, Custody& mount_point, int flags);
|
||||||
KResult remount(Custody& mount_point, int new_flags);
|
KResult remount(Custody& mount_point, int new_flags);
|
||||||
KResult unmount(Inode& guest_inode);
|
KResult unmount(Inode& guest_inode);
|
||||||
|
@ -108,7 +108,7 @@ private:
|
||||||
|
|
||||||
bool is_vfs_root(InodeIdentifier) const;
|
bool is_vfs_root(InodeIdentifier) const;
|
||||||
|
|
||||||
KResult traverse_directory_inode(Inode&, Function<bool(const FS::DirectoryEntryView&)>);
|
KResult traverse_directory_inode(Inode&, Function<bool(FileSystem::DirectoryEntryView const&)>);
|
||||||
|
|
||||||
Mount* find_mount_for_host(Inode&);
|
Mount* find_mount_for_host(Inode&);
|
||||||
Mount* find_mount_for_host(InodeIdentifier);
|
Mount* find_mount_for_host(InodeIdentifier);
|
||||||
|
|
|
@ -864,7 +864,7 @@ UNMAP_AFTER_INIT NonnullRefPtr<ProcFSRootFolder> ProcFSRootFolder::must_create()
|
||||||
return folder;
|
return folder;
|
||||||
}
|
}
|
||||||
|
|
||||||
KResult ProcFSRootFolder::traverse_as_directory(unsigned fsid, Function<bool(const FS::DirectoryEntryView&)> callback) const
|
KResult ProcFSRootFolder::traverse_as_directory(unsigned fsid, Function<bool(FileSystem::DirectoryEntryView const&)> callback) const
|
||||||
{
|
{
|
||||||
Locker locker(ProcFSComponentsRegistrar::the().m_lock);
|
Locker locker(ProcFSComponentsRegistrar::the().m_lock);
|
||||||
callback({ ".", { fsid, component_index() }, 0 });
|
callback({ ".", { fsid, component_index() }, 0 });
|
||||||
|
|
|
@ -240,7 +240,7 @@ RefPtr<ProcFSExposedComponent> ProcFSExposedFolder::lookup(StringView name)
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
KResult ProcFSExposedFolder::traverse_as_directory(unsigned fsid, Function<bool(const FS::DirectoryEntryView&)> callback) const
|
KResult ProcFSExposedFolder::traverse_as_directory(unsigned fsid, Function<bool(FileSystem::DirectoryEntryView const&)> callback) const
|
||||||
{
|
{
|
||||||
Locker locker(ProcFSComponentsRegistrar::the().m_lock);
|
Locker locker(ProcFSComponentsRegistrar::the().m_lock);
|
||||||
auto parent_folder = m_parent_folder.strong_ref();
|
auto parent_folder = m_parent_folder.strong_ref();
|
||||||
|
|
|
@ -61,7 +61,7 @@ public:
|
||||||
virtual KResultOr<size_t> entries_count() const { VERIFY_NOT_REACHED(); };
|
virtual KResultOr<size_t> entries_count() const { VERIFY_NOT_REACHED(); };
|
||||||
StringView name() const { return m_name->view(); }
|
StringView name() const { return m_name->view(); }
|
||||||
virtual KResultOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer&, FileDescription*) const { VERIFY_NOT_REACHED(); }
|
virtual KResultOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer&, FileDescription*) const { VERIFY_NOT_REACHED(); }
|
||||||
virtual KResult traverse_as_directory(unsigned, Function<bool(const FS::DirectoryEntryView&)>) const { VERIFY_NOT_REACHED(); }
|
virtual KResult traverse_as_directory(unsigned, Function<bool(FileSystem::DirectoryEntryView const&)>) const { VERIFY_NOT_REACHED(); }
|
||||||
virtual RefPtr<ProcFSExposedComponent> lookup(StringView) { VERIFY_NOT_REACHED(); };
|
virtual RefPtr<ProcFSExposedComponent> lookup(StringView) { VERIFY_NOT_REACHED(); };
|
||||||
virtual KResultOr<size_t> write_bytes(off_t, size_t, const UserOrKernelBuffer&, FileDescription*) { return KResult(EROFS); }
|
virtual KResultOr<size_t> write_bytes(off_t, size_t, const UserOrKernelBuffer&, FileDescription*) { return KResult(EROFS); }
|
||||||
virtual size_t size() const { return 0; }
|
virtual size_t size() const { return 0; }
|
||||||
|
@ -100,7 +100,7 @@ class ProcFSExposedFolder
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual KResultOr<size_t> entries_count() const override { return m_components.size(); };
|
virtual KResultOr<size_t> entries_count() const override { return m_components.size(); };
|
||||||
virtual KResult traverse_as_directory(unsigned, Function<bool(const FS::DirectoryEntryView&)>) const override;
|
virtual KResult traverse_as_directory(unsigned, Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
|
||||||
virtual RefPtr<ProcFSExposedComponent> lookup(StringView name) override;
|
virtual RefPtr<ProcFSExposedComponent> lookup(StringView name) override;
|
||||||
void add_component(const ProcFSExposedComponent&);
|
void add_component(const ProcFSExposedComponent&);
|
||||||
|
|
||||||
|
@ -194,7 +194,7 @@ public:
|
||||||
virtual ~ProcFSRootFolder();
|
virtual ~ProcFSRootFolder();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual KResult traverse_as_directory(unsigned, Function<bool(const FS::DirectoryEntryView&)>) const override;
|
virtual KResult traverse_as_directory(unsigned, Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
|
||||||
ProcFSRootFolder();
|
ProcFSRootFolder();
|
||||||
|
|
||||||
RefPtr<ProcFSBusDirectory> m_buses_folder;
|
RefPtr<ProcFSBusDirectory> m_buses_folder;
|
||||||
|
|
|
@ -62,7 +62,7 @@ class ProcFSProcessStacks final : public ProcFSExposedFolder {
|
||||||
// It should be deleted (as soon as possible)
|
// It should be deleted (as soon as possible)
|
||||||
public:
|
public:
|
||||||
virtual KResultOr<size_t> entries_count() const override;
|
virtual KResultOr<size_t> entries_count() const override;
|
||||||
virtual KResult traverse_as_directory(unsigned, Function<bool(const FS::DirectoryEntryView&)>) const override;
|
virtual KResult traverse_as_directory(unsigned, Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
|
||||||
virtual RefPtr<ProcFSExposedComponent> lookup(StringView name) override;
|
virtual RefPtr<ProcFSExposedComponent> lookup(StringView name) override;
|
||||||
|
|
||||||
static NonnullRefPtr<ProcFSProcessStacks> create(const ProcFSProcessFolder& parent_folder)
|
static NonnullRefPtr<ProcFSProcessStacks> create(const ProcFSProcessFolder& parent_folder)
|
||||||
|
@ -96,7 +96,7 @@ KResultOr<size_t> ProcFSProcessStacks::entries_count() const
|
||||||
return parent_folder->m_associated_process->thread_count();
|
return parent_folder->m_associated_process->thread_count();
|
||||||
}
|
}
|
||||||
|
|
||||||
KResult ProcFSProcessStacks::traverse_as_directory(unsigned fsid, Function<bool(const FS::DirectoryEntryView&)> callback) const
|
KResult ProcFSProcessStacks::traverse_as_directory(unsigned fsid, Function<bool(FileSystem::DirectoryEntryView const&)> callback) const
|
||||||
{
|
{
|
||||||
Locker locker(m_lock);
|
Locker locker(m_lock);
|
||||||
auto parent_folder = m_process_folder.strong_ref();
|
auto parent_folder = m_process_folder.strong_ref();
|
||||||
|
@ -165,7 +165,7 @@ class ProcFSProcessFileDescriptions final : public ProcFSExposedFolder {
|
||||||
// It should be deleted (as soon as possible)
|
// It should be deleted (as soon as possible)
|
||||||
public:
|
public:
|
||||||
virtual KResultOr<size_t> entries_count() const override;
|
virtual KResultOr<size_t> entries_count() const override;
|
||||||
virtual KResult traverse_as_directory(unsigned, Function<bool(const FS::DirectoryEntryView&)>) const override;
|
virtual KResult traverse_as_directory(unsigned, Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
|
||||||
virtual RefPtr<ProcFSExposedComponent> lookup(StringView name) override;
|
virtual RefPtr<ProcFSExposedComponent> lookup(StringView name) override;
|
||||||
|
|
||||||
static NonnullRefPtr<ProcFSProcessFileDescriptions> create(const ProcFSProcessFolder& parent_folder)
|
static NonnullRefPtr<ProcFSProcessFileDescriptions> create(const ProcFSProcessFolder& parent_folder)
|
||||||
|
@ -197,7 +197,7 @@ KResultOr<size_t> ProcFSProcessFileDescriptions::entries_count() const
|
||||||
return KResult(EINVAL);
|
return KResult(EINVAL);
|
||||||
return parent_folder->m_associated_process->fds().open_count();
|
return parent_folder->m_associated_process->fds().open_count();
|
||||||
}
|
}
|
||||||
KResult ProcFSProcessFileDescriptions::traverse_as_directory(unsigned fsid, Function<bool(const FS::DirectoryEntryView&)> callback) const
|
KResult ProcFSProcessFileDescriptions::traverse_as_directory(unsigned fsid, Function<bool(FileSystem::DirectoryEntryView const&)> callback) const
|
||||||
{
|
{
|
||||||
Locker locker(m_lock);
|
Locker locker(m_lock);
|
||||||
auto parent_folder = m_process_folder.strong_ref();
|
auto parent_folder = m_process_folder.strong_ref();
|
||||||
|
|
|
@ -176,7 +176,7 @@ int StorageManagement::minor_number()
|
||||||
return s_device_minor_number++;
|
return s_device_minor_number++;
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<FS> StorageManagement::root_filesystem() const
|
NonnullRefPtr<FileSystem> StorageManagement::root_filesystem() const
|
||||||
{
|
{
|
||||||
auto boot_device_description = boot_block_device();
|
auto boot_device_description = boot_block_device();
|
||||||
if (!boot_device_description) {
|
if (!boot_device_description) {
|
||||||
|
|
|
@ -26,7 +26,7 @@ public:
|
||||||
static void initialize(String boot_argument, bool force_pio);
|
static void initialize(String boot_argument, bool force_pio);
|
||||||
static StorageManagement& the();
|
static StorageManagement& the();
|
||||||
|
|
||||||
NonnullRefPtr<FS> root_filesystem() const;
|
NonnullRefPtr<FileSystem> root_filesystem() const;
|
||||||
|
|
||||||
static int major_number();
|
static int major_number();
|
||||||
static int minor_number();
|
static int minor_number();
|
||||||
|
|
|
@ -64,7 +64,7 @@ KResultOr<FlatPtr> Process::sys$mount(Userspace<const Syscall::SC_mount_params*>
|
||||||
return VFS::the().bind_mount(*description->custody(), target_custody, params.flags);
|
return VFS::the().bind_mount(*description->custody(), target_custody, params.flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<FS> fs;
|
RefPtr<FileSystem> fs;
|
||||||
|
|
||||||
if (fs_type == "ext2" || fs_type == "Ext2FS") {
|
if (fs_type == "ext2" || fs_type == "Ext2FS") {
|
||||||
if (description.is_null())
|
if (description.is_null())
|
||||||
|
|
|
@ -20,9 +20,9 @@ KResultOr<FlatPtr> Process::sys$reboot()
|
||||||
REQUIRE_NO_PROMISES;
|
REQUIRE_NO_PROMISES;
|
||||||
|
|
||||||
dbgln("acquiring FS locks...");
|
dbgln("acquiring FS locks...");
|
||||||
FS::lock_all();
|
FileSystem::lock_all();
|
||||||
dbgln("syncing mounted filesystems...");
|
dbgln("syncing mounted filesystems...");
|
||||||
FS::sync();
|
FileSystem::sync();
|
||||||
dbgln("attempting reboot via ACPI");
|
dbgln("attempting reboot via ACPI");
|
||||||
if (ACPI::is_enabled())
|
if (ACPI::is_enabled())
|
||||||
ACPI::Parser::the()->try_acpi_reboot();
|
ACPI::Parser::the()->try_acpi_reboot();
|
||||||
|
@ -41,9 +41,9 @@ KResultOr<FlatPtr> Process::sys$halt()
|
||||||
ConsoleManagement::the().switch_to_debug();
|
ConsoleManagement::the().switch_to_debug();
|
||||||
|
|
||||||
dbgln("acquiring FS locks...");
|
dbgln("acquiring FS locks...");
|
||||||
FS::lock_all();
|
FileSystem::lock_all();
|
||||||
dbgln("syncing mounted filesystems...");
|
dbgln("syncing mounted filesystems...");
|
||||||
FS::sync();
|
FileSystem::sync();
|
||||||
dbgln("attempting system shutdown...");
|
dbgln("attempting system shutdown...");
|
||||||
// QEMU Shutdown
|
// QEMU Shutdown
|
||||||
IO::out16(0x604, 0x2000);
|
IO::out16(0x604, 0x2000);
|
||||||
|
|
|
@ -26,7 +26,7 @@ SystemExposedComponent::SystemExposedComponent(StringView name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
KResult SystemExposedFolder::traverse_as_directory(unsigned fsid, Function<bool(const FS::DirectoryEntryView&)> callback) const
|
KResult SystemExposedFolder::traverse_as_directory(unsigned fsid, Function<bool(FileSystem::DirectoryEntryView const&)> callback) const
|
||||||
{
|
{
|
||||||
Locker locker(SystemRegistrar::the().m_lock);
|
Locker locker(SystemRegistrar::the().m_lock);
|
||||||
VERIFY(m_parent_folder);
|
VERIFY(m_parent_folder);
|
||||||
|
|
|
@ -24,7 +24,7 @@ public:
|
||||||
virtual KResultOr<size_t> entries_count() const { VERIFY_NOT_REACHED(); };
|
virtual KResultOr<size_t> entries_count() const { VERIFY_NOT_REACHED(); };
|
||||||
virtual StringView name() const { return m_name->view(); }
|
virtual StringView name() const { return m_name->view(); }
|
||||||
virtual KResultOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer&, FileDescription*) const { VERIFY_NOT_REACHED(); }
|
virtual KResultOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer&, FileDescription*) const { VERIFY_NOT_REACHED(); }
|
||||||
virtual KResult traverse_as_directory(unsigned, Function<bool(const FS::DirectoryEntryView&)>) const { VERIFY_NOT_REACHED(); }
|
virtual KResult traverse_as_directory(unsigned, Function<bool(FileSystem::DirectoryEntryView const&)>) const { VERIFY_NOT_REACHED(); }
|
||||||
virtual RefPtr<SystemExposedComponent> lookup(StringView) { VERIFY_NOT_REACHED(); };
|
virtual RefPtr<SystemExposedComponent> lookup(StringView) { VERIFY_NOT_REACHED(); };
|
||||||
virtual KResultOr<size_t> write_bytes(off_t, size_t, const UserOrKernelBuffer&, FileDescription*) { return -EROFS; }
|
virtual KResultOr<size_t> write_bytes(off_t, size_t, const UserOrKernelBuffer&, FileDescription*) { return -EROFS; }
|
||||||
virtual size_t size() const { return 0; }
|
virtual size_t size() const { return 0; }
|
||||||
|
@ -46,7 +46,7 @@ private:
|
||||||
class SystemExposedFolder : public SystemExposedComponent {
|
class SystemExposedFolder : public SystemExposedComponent {
|
||||||
public:
|
public:
|
||||||
virtual KResultOr<size_t> entries_count() const override { return m_components.size(); };
|
virtual KResultOr<size_t> entries_count() const override { return m_components.size(); };
|
||||||
virtual KResult traverse_as_directory(unsigned, Function<bool(const FS::DirectoryEntryView&)>) const override;
|
virtual KResult traverse_as_directory(unsigned, Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
|
||||||
virtual RefPtr<SystemExposedComponent> lookup(StringView name) override;
|
virtual RefPtr<SystemExposedComponent> lookup(StringView name) override;
|
||||||
void add_component(const SystemExposedComponent&);
|
void add_component(const SystemExposedComponent&);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue