summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-10-21 17:01:52 +0200
committerAndreas Kling <kling@serenityos.org>2021-10-21 23:23:23 +0200
commit6f69d5204fecf151ca0c4a1c0ca904c13ae8d095 (patch)
tree6faa78b40930a8c71d1d6dd680bb2c3a4fd8a8a6
parent6337d742bbe1d0a97a7c5cf73d24ca1d1cc2adbf (diff)
downloadserenity-6f69d5204fecf151ca0c4a1c0ca904c13ae8d095.zip
Kernel: Make Inode::flush_metadata() return a KResult
Even if this goes nowhere yet, we have to start building an error propagation path somewhere.
-rw-r--r--Kernel/FileSystem/DevPtsFS.cpp3
-rw-r--r--Kernel/FileSystem/DevPtsFS.h2
-rw-r--r--Kernel/FileSystem/DevTmpFS.cpp3
-rw-r--r--Kernel/FileSystem/DevTmpFS.h2
-rw-r--r--Kernel/FileSystem/Ext2FileSystem.cpp3
-rw-r--r--Kernel/FileSystem/Ext2FileSystem.h2
-rw-r--r--Kernel/FileSystem/ISO9660FileSystem.cpp3
-rw-r--r--Kernel/FileSystem/ISO9660FileSystem.h2
-rw-r--r--Kernel/FileSystem/Inode.cpp6
-rw-r--r--Kernel/FileSystem/Inode.h2
-rw-r--r--Kernel/FileSystem/Plan9FileSystem.cpp3
-rw-r--r--Kernel/FileSystem/Plan9FileSystem.h2
-rw-r--r--Kernel/FileSystem/ProcFS.cpp3
-rw-r--r--Kernel/FileSystem/ProcFS.h2
-rw-r--r--Kernel/FileSystem/SysFS.cpp3
-rw-r--r--Kernel/FileSystem/SysFS.h2
-rw-r--r--Kernel/FileSystem/TmpFS.cpp3
-rw-r--r--Kernel/FileSystem/TmpFS.h2
18 files changed, 28 insertions, 20 deletions
diff --git a/Kernel/FileSystem/DevPtsFS.cpp b/Kernel/FileSystem/DevPtsFS.cpp
index 4c64ef1958..b96cb5bf13 100644
--- a/Kernel/FileSystem/DevPtsFS.cpp
+++ b/Kernel/FileSystem/DevPtsFS.cpp
@@ -145,8 +145,9 @@ KResultOr<NonnullRefPtr<Inode>> DevPtsFSInode::lookup(StringView name)
});
}
-void DevPtsFSInode::flush_metadata()
+KResult DevPtsFSInode::flush_metadata()
{
+ return KSuccess;
}
KResult DevPtsFSInode::add_child(Inode&, const StringView&, mode_t)
diff --git a/Kernel/FileSystem/DevPtsFS.h b/Kernel/FileSystem/DevPtsFS.h
index 11a336039b..e907a52177 100644
--- a/Kernel/FileSystem/DevPtsFS.h
+++ b/Kernel/FileSystem/DevPtsFS.h
@@ -51,7 +51,7 @@ private:
virtual InodeMetadata metadata() const override;
virtual KResult traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
virtual KResultOr<NonnullRefPtr<Inode>> lookup(StringView name) override;
- virtual void flush_metadata() override;
+ virtual KResult flush_metadata() override;
virtual KResultOr<size_t> write_bytes(off_t, size_t, const UserOrKernelBuffer& buffer, OpenFileDescription*) override;
virtual KResultOr<NonnullRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override;
virtual KResult add_child(Inode&, const StringView& name, mode_t) override;
diff --git a/Kernel/FileSystem/DevTmpFS.cpp b/Kernel/FileSystem/DevTmpFS.cpp
index 93df86d516..8552bb2eaa 100644
--- a/Kernel/FileSystem/DevTmpFS.cpp
+++ b/Kernel/FileSystem/DevTmpFS.cpp
@@ -70,8 +70,9 @@ KResultOr<NonnullRefPtr<Inode>> DevTmpFSInode::lookup(StringView)
VERIFY_NOT_REACHED();
}
-void DevTmpFSInode::flush_metadata()
+KResult DevTmpFSInode::flush_metadata()
{
+ return KSuccess;
}
KResultOr<size_t> DevTmpFSInode::write_bytes(off_t, size_t, const UserOrKernelBuffer&, OpenFileDescription*)
diff --git a/Kernel/FileSystem/DevTmpFS.h b/Kernel/FileSystem/DevTmpFS.h
index d2545599ea..418252d6af 100644
--- a/Kernel/FileSystem/DevTmpFS.h
+++ b/Kernel/FileSystem/DevTmpFS.h
@@ -51,7 +51,7 @@ protected:
virtual KResultOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const override;
virtual KResult traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
virtual KResultOr<NonnullRefPtr<Inode>> lookup(StringView name) override;
- virtual void flush_metadata() override;
+ virtual KResult flush_metadata() override;
virtual InodeMetadata metadata() const override final;
virtual KResultOr<size_t> write_bytes(off_t, size_t, const UserOrKernelBuffer& buffer, OpenFileDescription*) override;
virtual KResultOr<NonnullRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override;
diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp
index f50ba21849..98a9979dc0 100644
--- a/Kernel/FileSystem/Ext2FileSystem.cpp
+++ b/Kernel/FileSystem/Ext2FileSystem.cpp
@@ -773,7 +773,7 @@ InodeMetadata Ext2FSInode::metadata() const
return metadata;
}
-void Ext2FSInode::flush_metadata()
+KResult Ext2FSInode::flush_metadata()
{
MutexLocker locker(m_inode_lock);
dbgln_if(EXT2_DEBUG, "Ext2FSInode[{}]::flush_metadata(): Flushing inode", identifier());
@@ -786,6 +786,7 @@ void Ext2FSInode::flush_metadata()
}
}
set_metadata_dirty(false);
+ return KSuccess;
}
KResultOr<NonnullRefPtr<Inode>> Ext2FS::get_inode(InodeIdentifier inode) const
diff --git a/Kernel/FileSystem/Ext2FileSystem.h b/Kernel/FileSystem/Ext2FileSystem.h
index 1da3ccf9aa..078152daf1 100644
--- a/Kernel/FileSystem/Ext2FileSystem.h
+++ b/Kernel/FileSystem/Ext2FileSystem.h
@@ -42,7 +42,7 @@ private:
virtual InodeMetadata metadata() const override;
virtual KResult traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
virtual KResultOr<NonnullRefPtr<Inode>> lookup(StringView name) override;
- virtual void flush_metadata() override;
+ virtual KResult flush_metadata() override;
virtual KResultOr<size_t> write_bytes(off_t, size_t, const UserOrKernelBuffer& data, OpenFileDescription*) override;
virtual KResultOr<NonnullRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override;
virtual KResult add_child(Inode& child, const StringView& name, mode_t) override;
diff --git a/Kernel/FileSystem/ISO9660FileSystem.cpp b/Kernel/FileSystem/ISO9660FileSystem.cpp
index a964f1945f..492433f3d7 100644
--- a/Kernel/FileSystem/ISO9660FileSystem.cpp
+++ b/Kernel/FileSystem/ISO9660FileSystem.cpp
@@ -499,8 +499,9 @@ KResultOr<NonnullRefPtr<Inode>> ISO9660Inode::lookup(StringView name)
return inode.release_nonnull();
}
-void ISO9660Inode::flush_metadata()
+KResult ISO9660Inode::flush_metadata()
{
+ return KSuccess;
}
KResultOr<size_t> ISO9660Inode::write_bytes(off_t, size_t, const UserOrKernelBuffer&, OpenFileDescription*)
diff --git a/Kernel/FileSystem/ISO9660FileSystem.h b/Kernel/FileSystem/ISO9660FileSystem.h
index f0bb51832d..5db938cdd8 100644
--- a/Kernel/FileSystem/ISO9660FileSystem.h
+++ b/Kernel/FileSystem/ISO9660FileSystem.h
@@ -351,7 +351,7 @@ public:
virtual InodeMetadata metadata() const override;
virtual KResult traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
virtual KResultOr<NonnullRefPtr<Inode>> lookup(StringView name) override;
- virtual void flush_metadata() override;
+ virtual KResult flush_metadata() override;
virtual KResultOr<size_t> write_bytes(off_t, size_t, const UserOrKernelBuffer& buffer, OpenFileDescription*) override;
virtual KResultOr<NonnullRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override;
virtual KResult add_child(Inode&, const StringView& name, mode_t) override;
diff --git a/Kernel/FileSystem/Inode.cpp b/Kernel/FileSystem/Inode.cpp
index 799e6cbb7a..dd53e593d9 100644
--- a/Kernel/FileSystem/Inode.cpp
+++ b/Kernel/FileSystem/Inode.cpp
@@ -41,14 +41,14 @@ void Inode::sync_all()
for (auto& inode : inodes) {
VERIFY(inode.is_metadata_dirty());
- inode.flush_metadata();
+ (void)inode.flush_metadata();
}
}
void Inode::sync()
{
if (is_metadata_dirty())
- flush_metadata();
+ (void)flush_metadata();
fs().flush_writes();
}
@@ -103,7 +103,7 @@ void Inode::will_be_destroyed()
{
MutexLocker locker(m_inode_lock);
if (m_metadata_dirty)
- flush_metadata();
+ (void)flush_metadata();
}
KResult Inode::set_atime(time_t)
diff --git a/Kernel/FileSystem/Inode.h b/Kernel/FileSystem/Inode.h
index 4356915a82..eddb3030c1 100644
--- a/Kernel/FileSystem/Inode.h
+++ b/Kernel/FileSystem/Inode.h
@@ -81,7 +81,7 @@ public:
virtual KResult increment_link_count();
virtual KResult decrement_link_count();
- virtual void flush_metadata() = 0;
+ virtual KResult flush_metadata() = 0;
void will_be_destroyed();
diff --git a/Kernel/FileSystem/Plan9FileSystem.cpp b/Kernel/FileSystem/Plan9FileSystem.cpp
index d239f4a741..3ad1158577 100644
--- a/Kernel/FileSystem/Plan9FileSystem.cpp
+++ b/Kernel/FileSystem/Plan9FileSystem.cpp
@@ -822,9 +822,10 @@ InodeMetadata Plan9FSInode::metadata() const
return metadata;
}
-void Plan9FSInode::flush_metadata()
+KResult Plan9FSInode::flush_metadata()
{
// Do nothing.
+ return KSuccess;
}
KResult Plan9FSInode::traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)> callback) const
diff --git a/Kernel/FileSystem/Plan9FileSystem.h b/Kernel/FileSystem/Plan9FileSystem.h
index 1dfe4f7e55..835432b44e 100644
--- a/Kernel/FileSystem/Plan9FileSystem.h
+++ b/Kernel/FileSystem/Plan9FileSystem.h
@@ -155,7 +155,7 @@ public:
// ^Inode
virtual InodeMetadata metadata() const override;
- virtual void flush_metadata() override;
+ virtual KResult flush_metadata() override;
virtual KResultOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const override;
virtual KResultOr<size_t> write_bytes(off_t, size_t, const UserOrKernelBuffer& data, OpenFileDescription*) override;
virtual KResult traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp
index fd88f671a4..de36b0513f 100644
--- a/Kernel/FileSystem/ProcFS.cpp
+++ b/Kernel/FileSystem/ProcFS.cpp
@@ -70,8 +70,9 @@ ProcFSInode::~ProcFSInode()
{
}
-void ProcFSInode::flush_metadata()
+KResult ProcFSInode::flush_metadata()
{
+ return KSuccess;
}
KResult ProcFSInode::add_child(Inode&, const StringView&, mode_t)
diff --git a/Kernel/FileSystem/ProcFS.h b/Kernel/FileSystem/ProcFS.h
index 966cfd55a4..abd525ea5b 100644
--- a/Kernel/FileSystem/ProcFS.h
+++ b/Kernel/FileSystem/ProcFS.h
@@ -56,7 +56,7 @@ protected:
// ^Inode
virtual KResult attach(OpenFileDescription& description) = 0;
virtual void did_seek(OpenFileDescription&, off_t) = 0;
- virtual void flush_metadata() override final;
+ virtual KResult flush_metadata() override final;
virtual KResultOr<NonnullRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override final;
virtual KResult add_child(Inode&, const StringView& name, mode_t) override final;
virtual KResult remove_child(const StringView& name) override final;
diff --git a/Kernel/FileSystem/SysFS.cpp b/Kernel/FileSystem/SysFS.cpp
index cc26614663..e45da8a733 100644
--- a/Kernel/FileSystem/SysFS.cpp
+++ b/Kernel/FileSystem/SysFS.cpp
@@ -148,8 +148,9 @@ InodeMetadata SysFSInode::metadata() const
return metadata;
}
-void SysFSInode::flush_metadata()
+KResult SysFSInode::flush_metadata()
{
+ return KSuccess;
}
KResultOr<size_t> SysFSInode::write_bytes(off_t offset, size_t count, UserOrKernelBuffer const& buffer, OpenFileDescription* fd)
diff --git a/Kernel/FileSystem/SysFS.h b/Kernel/FileSystem/SysFS.h
index 4b8bf05c94..d62781f48c 100644
--- a/Kernel/FileSystem/SysFS.h
+++ b/Kernel/FileSystem/SysFS.h
@@ -137,7 +137,7 @@ protected:
virtual KResultOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const override;
virtual KResult traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
virtual KResultOr<NonnullRefPtr<Inode>> lookup(StringView name) override;
- virtual void flush_metadata() override;
+ virtual KResult flush_metadata() override;
virtual InodeMetadata metadata() const override;
virtual KResultOr<size_t> write_bytes(off_t, size_t, UserOrKernelBuffer const&, OpenFileDescription*) override;
virtual KResultOr<NonnullRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override;
diff --git a/Kernel/FileSystem/TmpFS.cpp b/Kernel/FileSystem/TmpFS.cpp
index f1e43397e2..17115a093a 100644
--- a/Kernel/FileSystem/TmpFS.cpp
+++ b/Kernel/FileSystem/TmpFS.cpp
@@ -216,7 +216,7 @@ void TmpFSInode::notify_watchers()
set_metadata_dirty(false);
}
-void TmpFSInode::flush_metadata()
+KResult TmpFSInode::flush_metadata()
{
// We don't really have any metadata that could become dirty.
// The only reason we even call set_metadata_dirty() is
@@ -224,6 +224,7 @@ void TmpFSInode::flush_metadata()
// switched to a different mechanism, we can stop ever marking
// our metadata as dirty at all.
set_metadata_dirty(false);
+ return KSuccess;
}
KResult TmpFSInode::chmod(mode_t mode)
diff --git a/Kernel/FileSystem/TmpFS.h b/Kernel/FileSystem/TmpFS.h
index 87441885b6..c13cc908f2 100644
--- a/Kernel/FileSystem/TmpFS.h
+++ b/Kernel/FileSystem/TmpFS.h
@@ -56,7 +56,7 @@ public:
virtual InodeMetadata metadata() const override;
virtual KResult traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
virtual KResultOr<NonnullRefPtr<Inode>> lookup(StringView name) override;
- virtual void flush_metadata() override;
+ virtual KResult flush_metadata() override;
virtual KResultOr<size_t> write_bytes(off_t, size_t, const UserOrKernelBuffer& buffer, OpenFileDescription*) override;
virtual KResultOr<NonnullRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override;
virtual KResult add_child(Inode&, const StringView& name, mode_t) override;