summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-07-17 22:36:04 +0200
committerAndreas Kling <kling@serenityos.org>2021-07-17 22:36:04 +0200
commitb8d6c3722d2887e45d6f2128cf9fd6f2f657c0b7 (patch)
tree182349460cd377b49e67927e52a0bd93da79bde7
parentd1bbe8b65220ab500917aaf79d2051023fb00ec6 (diff)
downloadserenity-b8d6c3722d2887e45d6f2128cf9fd6f2f657c0b7.zip
Kernel: Remove Inode::directory_entry_count()
This was only used in one place: VirtualFileSystem::rmdir(), and that has now been converted to a simple directory traversal.
-rw-r--r--Kernel/FileSystem/DevFS.cpp20
-rw-r--r--Kernel/FileSystem/DevFS.h4
-rw-r--r--Kernel/FileSystem/DevPtsFS.cpp7
-rw-r--r--Kernel/FileSystem/DevPtsFS.h1
-rw-r--r--Kernel/FileSystem/Ext2FileSystem.cpp9
-rw-r--r--Kernel/FileSystem/Ext2FileSystem.h1
-rw-r--r--Kernel/FileSystem/Inode.h1
-rw-r--r--Kernel/FileSystem/Plan9FileSystem.cpp14
-rw-r--r--Kernel/FileSystem/Plan9FileSystem.h1
-rw-r--r--Kernel/FileSystem/ProcFS.cpp11
-rw-r--r--Kernel/FileSystem/ProcFS.h2
-rw-r--r--Kernel/FileSystem/SysFS.cpp11
-rw-r--r--Kernel/FileSystem/SysFS.h2
-rw-r--r--Kernel/FileSystem/TmpFS.cpp7
-rw-r--r--Kernel/FileSystem/TmpFS.h1
15 files changed, 0 insertions, 92 deletions
diff --git a/Kernel/FileSystem/DevFS.cpp b/Kernel/FileSystem/DevFS.cpp
index 48534b9406..78811b8872 100644
--- a/Kernel/FileSystem/DevFS.cpp
+++ b/Kernel/FileSystem/DevFS.cpp
@@ -122,11 +122,6 @@ KResult DevFSInode::remove_child(const StringView&)
return EROFS;
}
-KResultOr<size_t> DevFSInode::directory_entry_count() const
-{
- VERIFY_NOT_REACHED();
-}
-
KResult DevFSInode::chmod(mode_t)
{
return EPERM;
@@ -221,12 +216,6 @@ RefPtr<Inode> DevFSDirectoryInode::lookup(StringView)
return nullptr;
}
-KResultOr<size_t> DevFSDirectoryInode::directory_entry_count() const
-{
- Locker locker(m_inode_lock);
- return m_devices.size();
-}
-
DevFSRootDirectoryInode::DevFSRootDirectoryInode(DevFS& fs)
: DevFSDirectoryInode(fs)
, m_parent_fs(fs)
@@ -332,11 +321,6 @@ InodeMetadata DevFSRootDirectoryInode::metadata() const
metadata.mtime = mepoch;
return metadata;
}
-KResultOr<size_t> DevFSRootDirectoryInode::directory_entry_count() const
-{
- Locker locker(m_parent_fs.m_lock);
- return m_devices.size() + DevFSDirectoryInode::directory_entry_count().value();
-}
DevFSDeviceInode::DevFSDeviceInode(DevFS& fs, Device const& device, NonnullOwnPtr<KString> name)
: DevFSInode(fs)
@@ -429,9 +413,5 @@ InodeMetadata DevFSPtsDirectoryInode::metadata() const
metadata.mtime = mepoch;
return metadata;
}
-KResultOr<size_t> DevFSPtsDirectoryInode::directory_entry_count() const
-{
- return 0;
-}
}
diff --git a/Kernel/FileSystem/DevFS.h b/Kernel/FileSystem/DevFS.h
index 4ffd625269..94e9a8b0b7 100644
--- a/Kernel/FileSystem/DevFS.h
+++ b/Kernel/FileSystem/DevFS.h
@@ -58,7 +58,6 @@ protected:
virtual KResultOr<NonnullRefPtr<Inode>> create_child(StringView 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 KResultOr<size_t> directory_entry_count() const override;
virtual KResult chmod(mode_t) override;
virtual KResult chown(uid_t, gid_t) override;
virtual KResult truncate(u64) override;
@@ -119,7 +118,6 @@ protected:
virtual InodeMetadata metadata() const override;
virtual KResult traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
virtual RefPtr<Inode> lookup(StringView name) override;
- virtual KResultOr<size_t> directory_entry_count() const override;
NonnullRefPtrVector<DevFSDeviceInode> m_devices;
};
@@ -137,7 +135,6 @@ private:
virtual KResult traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
virtual RefPtr<Inode> lookup(StringView name) override;
virtual InodeMetadata metadata() const override;
- virtual KResultOr<size_t> directory_entry_count() const override;
};
class DevFSRootDirectoryInode final : public DevFSDirectoryInode {
@@ -153,7 +150,6 @@ private:
virtual KResult traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
virtual RefPtr<Inode> lookup(StringView name) override;
virtual InodeMetadata metadata() const override;
- virtual KResultOr<size_t> directory_entry_count() const override;
NonnullRefPtrVector<DevFSDirectoryInode> m_subfolders;
NonnullRefPtrVector<DevFSLinkInode> m_links;
diff --git a/Kernel/FileSystem/DevPtsFS.cpp b/Kernel/FileSystem/DevPtsFS.cpp
index 172ef6514f..5b1ab50ec4 100644
--- a/Kernel/FileSystem/DevPtsFS.cpp
+++ b/Kernel/FileSystem/DevPtsFS.cpp
@@ -136,13 +136,6 @@ KResult DevPtsFSInode::traverse_as_directory(Function<bool(FileSystem::Directory
return KSuccess;
}
-KResultOr<size_t> DevPtsFSInode::directory_entry_count() const
-{
- VERIFY(identifier().index() == 1);
-
- return 2 + s_ptys->size();
-}
-
RefPtr<Inode> DevPtsFSInode::lookup(StringView name)
{
VERIFY(identifier().index() == 1);
diff --git a/Kernel/FileSystem/DevPtsFS.h b/Kernel/FileSystem/DevPtsFS.h
index d32a4e4dd7..24a650ffeb 100644
--- a/Kernel/FileSystem/DevPtsFS.h
+++ b/Kernel/FileSystem/DevPtsFS.h
@@ -56,7 +56,6 @@ private:
virtual KResultOr<NonnullRefPtr<Inode>> create_child(StringView 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 KResultOr<size_t> directory_entry_count() const override;
virtual KResult chmod(mode_t) override;
virtual KResult chown(uid_t, gid_t) override;
diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp
index 82df1eb9de..40adb0d303 100644
--- a/Kernel/FileSystem/Ext2FileSystem.cpp
+++ b/Kernel/FileSystem/Ext2FileSystem.cpp
@@ -1709,15 +1709,6 @@ void Ext2FS::uncache_inode(InodeIndex index)
m_inode_cache.remove(index);
}
-KResultOr<size_t> Ext2FSInode::directory_entry_count() const
-{
- VERIFY(is_directory());
- Locker locker(m_inode_lock);
- if (auto result = populate_lookup_cache(); result.is_error())
- return KResultOr<size_t>(result);
- return m_lookup_cache.size();
-}
-
KResult Ext2FSInode::chmod(mode_t mode)
{
Locker locker(m_inode_lock);
diff --git a/Kernel/FileSystem/Ext2FileSystem.h b/Kernel/FileSystem/Ext2FileSystem.h
index 77cefcb4d4..65cc380efb 100644
--- a/Kernel/FileSystem/Ext2FileSystem.h
+++ b/Kernel/FileSystem/Ext2FileSystem.h
@@ -52,7 +52,6 @@ private:
virtual KResult set_mtime(time_t) override;
virtual KResult increment_link_count() override;
virtual KResult decrement_link_count() override;
- virtual KResultOr<size_t> directory_entry_count() const override;
virtual KResult chmod(mode_t) override;
virtual KResult chown(uid_t, gid_t) override;
virtual KResult truncate(u64) override;
diff --git a/Kernel/FileSystem/Inode.h b/Kernel/FileSystem/Inode.h
index 31c1230c68..519e4a9db0 100644
--- a/Kernel/FileSystem/Inode.h
+++ b/Kernel/FileSystem/Inode.h
@@ -59,7 +59,6 @@ public:
virtual KResultOr<NonnullRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, uid_t, gid_t) = 0;
virtual KResult add_child(Inode&, const StringView& name, mode_t) = 0;
virtual KResult remove_child(const StringView& name) = 0;
- virtual KResultOr<size_t> directory_entry_count() const = 0;
virtual KResult chmod(mode_t) = 0;
virtual KResult chown(uid_t, gid_t) = 0;
virtual KResult truncate(u64) { return KSuccess; }
diff --git a/Kernel/FileSystem/Plan9FileSystem.cpp b/Kernel/FileSystem/Plan9FileSystem.cpp
index 7ee81bc7d8..4983beab9c 100644
--- a/Kernel/FileSystem/Plan9FileSystem.cpp
+++ b/Kernel/FileSystem/Plan9FileSystem.cpp
@@ -851,20 +851,6 @@ void Plan9FSInode::flush_metadata()
// Do nothing.
}
-KResultOr<size_t> Plan9FSInode::directory_entry_count() const
-{
- size_t count = 0;
- KResult result = traverse_as_directory([&count](auto&) {
- count++;
- return true;
- });
-
- if (result.is_error())
- return result;
-
- return count;
-}
-
KResult Plan9FSInode::traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)> callback) const
{
KResult result = KSuccess;
diff --git a/Kernel/FileSystem/Plan9FileSystem.h b/Kernel/FileSystem/Plan9FileSystem.h
index 243c695889..ba26834c59 100644
--- a/Kernel/FileSystem/Plan9FileSystem.h
+++ b/Kernel/FileSystem/Plan9FileSystem.h
@@ -163,7 +163,6 @@ public:
virtual KResultOr<NonnullRefPtr<Inode>> create_child(StringView 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 KResultOr<size_t> directory_entry_count() const override;
virtual KResult chmod(mode_t) override;
virtual KResult chown(uid_t, gid_t) override;
virtual KResult truncate(u64) override;
diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp
index 8084ef6554..9dcf4c09b3 100644
--- a/Kernel/FileSystem/ProcFS.cpp
+++ b/Kernel/FileSystem/ProcFS.cpp
@@ -173,11 +173,6 @@ KResult ProcFSInode::remove_child(const StringView&)
return EROFS;
}
-KResultOr<size_t> ProcFSInode::directory_entry_count() const
-{
- VERIFY_NOT_REACHED();
-}
-
KResult ProcFSInode::chmod(mode_t)
{
return EPERM;
@@ -234,12 +229,6 @@ RefPtr<Inode> ProcFSDirectoryInode::lookup(StringView name)
return component->to_inode(m_parent_fs);
}
-KResultOr<size_t> ProcFSDirectoryInode::directory_entry_count() const
-{
- Locker locker(m_inode_lock);
- return m_associated_component->entries_count();
-}
-
NonnullRefPtr<ProcFSLinkInode> ProcFSLinkInode::create(const ProcFS& procfs, const ProcFSExposedComponent& component)
{
return adopt_ref(*new (nothrow) ProcFSLinkInode(procfs, component));
diff --git a/Kernel/FileSystem/ProcFS.h b/Kernel/FileSystem/ProcFS.h
index d88df337ac..a477ccd304 100644
--- a/Kernel/FileSystem/ProcFS.h
+++ b/Kernel/FileSystem/ProcFS.h
@@ -59,7 +59,6 @@ protected:
virtual KResult add_child(Inode&, const StringView& name, mode_t) override;
virtual KResult remove_child(const StringView& name) override;
virtual void did_seek(FileDescription&, off_t) override;
- virtual KResultOr<size_t> directory_entry_count() const override;
virtual KResult chmod(mode_t) override;
virtual KResult chown(uid_t, gid_t) override;
virtual KResult truncate(u64) override;
@@ -91,7 +90,6 @@ protected:
virtual InodeMetadata metadata() const override;
virtual KResult traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
virtual RefPtr<Inode> lookup(StringView name) override;
- virtual KResultOr<size_t> directory_entry_count() const override;
ProcFS& m_parent_fs;
};
diff --git a/Kernel/FileSystem/SysFS.cpp b/Kernel/FileSystem/SysFS.cpp
index c7cb243f3a..e6b7431512 100644
--- a/Kernel/FileSystem/SysFS.cpp
+++ b/Kernel/FileSystem/SysFS.cpp
@@ -145,11 +145,6 @@ KResult SysFSInode::remove_child(StringView const&)
return EROFS;
}
-KResultOr<size_t> SysFSInode::directory_entry_count() const
-{
- VERIFY_NOT_REACHED();
-}
-
KResult SysFSInode::chmod(mode_t)
{
return EPERM;
@@ -206,10 +201,4 @@ RefPtr<Inode> SysFSDirectoryInode::lookup(StringView name)
return component->to_inode(m_parent_fs);
}
-KResultOr<size_t> SysFSDirectoryInode::directory_entry_count() const
-{
- Locker locker(m_inode_lock);
- return m_associated_component->entries_count();
-}
-
}
diff --git a/Kernel/FileSystem/SysFS.h b/Kernel/FileSystem/SysFS.h
index 204c333bde..1c793659e4 100644
--- a/Kernel/FileSystem/SysFS.h
+++ b/Kernel/FileSystem/SysFS.h
@@ -78,7 +78,6 @@ protected:
virtual KResultOr<NonnullRefPtr<Inode>> create_child(StringView name, mode_t, dev_t, uid_t, gid_t) override;
virtual KResult add_child(Inode&, StringView const& name, mode_t) override;
virtual KResult remove_child(StringView const& name) override;
- virtual KResultOr<size_t> directory_entry_count() const override;
virtual KResult chmod(mode_t) override;
virtual KResult chown(uid_t, gid_t) override;
virtual KResult truncate(u64) override;
@@ -99,7 +98,6 @@ protected:
virtual InodeMetadata metadata() const override;
virtual KResult traverse_as_directory(Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
virtual RefPtr<Inode> lookup(StringView name) override;
- virtual KResultOr<size_t> directory_entry_count() const override;
SysFS& m_parent_fs;
};
diff --git a/Kernel/FileSystem/TmpFS.cpp b/Kernel/FileSystem/TmpFS.cpp
index 7f9365592a..409cf20953 100644
--- a/Kernel/FileSystem/TmpFS.cpp
+++ b/Kernel/FileSystem/TmpFS.cpp
@@ -212,13 +212,6 @@ RefPtr<Inode> TmpFSInode::lookup(StringView name)
return fs().get_inode(it->value.inode->identifier());
}
-KResultOr<size_t> TmpFSInode::directory_entry_count() const
-{
- Locker locker(m_inode_lock, Mutex::Mode::Shared);
- VERIFY(is_directory());
- return 2 + m_children.size();
-}
-
void TmpFSInode::notify_watchers()
{
set_metadata_dirty(true);
diff --git a/Kernel/FileSystem/TmpFS.h b/Kernel/FileSystem/TmpFS.h
index 3b747d7194..4e30ec236f 100644
--- a/Kernel/FileSystem/TmpFS.h
+++ b/Kernel/FileSystem/TmpFS.h
@@ -63,7 +63,6 @@ public:
virtual KResultOr<NonnullRefPtr<Inode>> create_child(StringView 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 KResultOr<size_t> directory_entry_count() const override;
virtual KResult chmod(mode_t) override;
virtual KResult chown(uid_t, gid_t) override;
virtual KResult truncate(u64) override;