summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem/ProcFS.h
diff options
context:
space:
mode:
authorSergey Bugaev <bugaevc@serenityos.org>2020-06-24 23:35:56 +0300
committerAndreas Kling <kling@serenityos.org>2020-06-25 15:49:04 +0200
commitdf66c28479e9206adeef1f40f8c0e448c8aea77e (patch)
tree8f9c8e5d764847e0acabf3a266ace76d7ca9bc1a /Kernel/FileSystem/ProcFS.h
parentc689be0dbc702f3187029deee58ac9e5cf749372 (diff)
downloadserenity-df66c28479e9206adeef1f40f8c0e448c8aea77e.zip
Kernel: Deemphasize inode identifiers
These APIs were clearly modeled after Ext2FS internals, and make perfect sense in Ext2FS context. The new APIs are more generic, and map better to the semantics exported to the userspace, where inode identifiers only appear in stat() and readdir() output, but never in any input. This will also hopefully reduce the potential for races (see commit https://github.com/SerenityOS/serenity/commit/c44b4d61f350703fcf1bbd8f6e353b9c6c4210c2). Lastly, this makes it way more viable to implement a filesystem that only synthesizes its inodes lazily when queried, and destroys them when they are no longer in use. With inode identifiers being used to reference inodes, the only choice for such a filesystem is to persist any inode it has given out the identifier for, because it might be queried at any later time. With direct references to inodes, the filesystem will know when the last reference is dropped and the inode can be safely destroyed.
Diffstat (limited to 'Kernel/FileSystem/ProcFS.h')
-rw-r--r--Kernel/FileSystem/ProcFS.h11
1 files changed, 5 insertions, 6 deletions
diff --git a/Kernel/FileSystem/ProcFS.h b/Kernel/FileSystem/ProcFS.h
index d498c27b0a..280249897e 100644
--- a/Kernel/FileSystem/ProcFS.h
+++ b/Kernel/FileSystem/ProcFS.h
@@ -49,12 +49,9 @@ public:
virtual bool initialize() override;
virtual const char* class_name() const override;
- virtual InodeIdentifier root_inode() const override;
+ virtual NonnullRefPtr<Inode> root_inode() const override;
virtual RefPtr<Inode> get_inode(InodeIdentifier) const override;
- virtual KResultOr<NonnullRefPtr<Inode>> create_inode(InodeIdentifier parent_id, const String& name, mode_t, off_t size, dev_t, uid_t, gid_t) override;
- virtual KResult create_directory(InodeIdentifier parent_id, const String& name, mode_t, uid_t, gid_t) override;
-
static void add_sys_bool(String&&, Lockable<bool>&, Function<void()>&& notify_callback = nullptr);
static void add_sys_string(String&&, Lockable<String>&, Function<void()>&& notify_callback = nullptr);
@@ -105,7 +102,8 @@ private:
virtual RefPtr<Inode> lookup(StringView name) override;
virtual void flush_metadata() override;
virtual ssize_t write_bytes(off_t, ssize_t, const u8* buffer, FileDescription*) override;
- virtual KResult add_child(InodeIdentifier child_id, const StringView& name, mode_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 remove_child(const StringView& name) override;
virtual size_t directory_entry_count() const override;
virtual KResult chmod(mode_t) override;
@@ -131,7 +129,8 @@ private:
virtual RefPtr<Inode> lookup(StringView name) override;
virtual void flush_metadata() override {};
virtual ssize_t write_bytes(off_t, ssize_t, const u8*, FileDescription*) override { ASSERT_NOT_REACHED(); }
- virtual KResult add_child(InodeIdentifier child_id, const StringView& name, mode_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 remove_child(const StringView& name) override;
virtual size_t directory_entry_count() const override;
virtual KResult chmod(mode_t) override { return KResult(-EINVAL); }