summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem/TmpFS.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/TmpFS.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/TmpFS.h')
-rw-r--r--Kernel/FileSystem/TmpFS.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/Kernel/FileSystem/TmpFS.h b/Kernel/FileSystem/TmpFS.h
index b90aac1f47..a2bc5d8181 100644
--- a/Kernel/FileSystem/TmpFS.h
+++ b/Kernel/FileSystem/TmpFS.h
@@ -48,12 +48,9 @@ public:
virtual bool supports_watchers() const override { return true; }
- 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;
-
private:
TmpFS();
@@ -83,7 +80,8 @@ public:
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;
@@ -99,6 +97,8 @@ private:
static NonnullRefPtr<TmpFSInode> create(TmpFS&, InodeMetadata metadata, InodeIdentifier parent);
static NonnullRefPtr<TmpFSInode> create_root(TmpFS&);
+ void notify_watchers();
+
InodeMetadata m_metadata;
InodeIdentifier m_parent;