|
@@ -5,32 +5,11 @@
|
|
|
*/
|
|
|
|
|
|
#include <AK/StringView.h>
|
|
|
-#include <Kernel/FileSystem/SysFS.h>
|
|
|
-#include <Kernel/FileSystem/SysFS/Registry.h>
|
|
|
-#include <Kernel/Sections.h>
|
|
|
+#include <Kernel/FileSystem/SysFS/Inode.h>
|
|
|
#include <Kernel/Time/TimeManagement.h>
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
|
-ErrorOr<NonnullLockRefPtr<FileSystem>> SysFS::try_create()
|
|
|
-{
|
|
|
- return TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) SysFS));
|
|
|
-}
|
|
|
-
|
|
|
-SysFS::SysFS() = default;
|
|
|
-SysFS::~SysFS() = default;
|
|
|
-
|
|
|
-ErrorOr<void> SysFS::initialize()
|
|
|
-{
|
|
|
- m_root_inode = TRY(SysFSComponentRegistry::the().root_directory().to_inode(*this));
|
|
|
- return {};
|
|
|
-}
|
|
|
-
|
|
|
-Inode& SysFS::root_inode()
|
|
|
-{
|
|
|
- return *m_root_inode;
|
|
|
-}
|
|
|
-
|
|
|
ErrorOr<NonnullLockRefPtr<SysFSInode>> SysFSInode::try_create(SysFS const& fs, SysFSComponent const& component)
|
|
|
{
|
|
|
return adopt_nonnull_lock_ref_or_enomem(new (nothrow) SysFSInode(fs, component));
|
|
@@ -131,68 +110,4 @@ ErrorOr<void> SysFSInode::update_timestamps(Optional<time_t>, Optional<time_t>,
|
|
|
return {};
|
|
|
}
|
|
|
|
|
|
-ErrorOr<NonnullLockRefPtr<SysFSLinkInode>> SysFSLinkInode::try_create(SysFS const& sysfs, SysFSComponent const& component)
|
|
|
-{
|
|
|
- return adopt_nonnull_lock_ref_or_enomem(new (nothrow) SysFSLinkInode(sysfs, component));
|
|
|
-}
|
|
|
-
|
|
|
-SysFSLinkInode::SysFSLinkInode(SysFS const& fs, SysFSComponent const& component)
|
|
|
- : SysFSInode(fs, component)
|
|
|
-{
|
|
|
-}
|
|
|
-
|
|
|
-SysFSLinkInode::~SysFSLinkInode() = default;
|
|
|
-
|
|
|
-InodeMetadata SysFSLinkInode::metadata() const
|
|
|
-{
|
|
|
- // NOTE: No locking required as m_associated_component or its component index will never change during our lifetime.
|
|
|
- InodeMetadata metadata;
|
|
|
- metadata.inode = { fsid(), m_associated_component->component_index() };
|
|
|
- metadata.mode = S_IFLNK | S_IRUSR | S_IRGRP | S_IROTH | S_IXOTH;
|
|
|
- metadata.uid = 0;
|
|
|
- metadata.gid = 0;
|
|
|
- metadata.size = 0;
|
|
|
- metadata.mtime = TimeManagement::boot_time();
|
|
|
- return metadata;
|
|
|
-}
|
|
|
-
|
|
|
-ErrorOr<NonnullLockRefPtr<SysFSDirectoryInode>> SysFSDirectoryInode::try_create(SysFS const& sysfs, SysFSComponent const& component)
|
|
|
-{
|
|
|
- return adopt_nonnull_lock_ref_or_enomem(new (nothrow) SysFSDirectoryInode(sysfs, component));
|
|
|
-}
|
|
|
-
|
|
|
-SysFSDirectoryInode::SysFSDirectoryInode(SysFS const& fs, SysFSComponent const& component)
|
|
|
- : SysFSInode(fs, component)
|
|
|
-{
|
|
|
-}
|
|
|
-
|
|
|
-SysFSDirectoryInode::~SysFSDirectoryInode() = default;
|
|
|
-
|
|
|
-InodeMetadata SysFSDirectoryInode::metadata() const
|
|
|
-{
|
|
|
- // NOTE: No locking required as m_associated_component or its component index will never change during our lifetime.
|
|
|
- InodeMetadata metadata;
|
|
|
- metadata.inode = { fsid(), m_associated_component->component_index() };
|
|
|
- metadata.mode = S_IFDIR | S_IRUSR | S_IRGRP | S_IROTH | S_IXOTH;
|
|
|
- metadata.uid = 0;
|
|
|
- metadata.gid = 0;
|
|
|
- metadata.size = 0;
|
|
|
- metadata.mtime = TimeManagement::boot_time();
|
|
|
- return metadata;
|
|
|
-}
|
|
|
-ErrorOr<void> SysFSDirectoryInode::traverse_as_directory(Function<ErrorOr<void>(FileSystem::DirectoryEntryView const&)> callback) const
|
|
|
-{
|
|
|
- MutexLocker locker(fs().m_lock);
|
|
|
- return m_associated_component->traverse_as_directory(fs().fsid(), move(callback));
|
|
|
-}
|
|
|
-
|
|
|
-ErrorOr<NonnullLockRefPtr<Inode>> SysFSDirectoryInode::lookup(StringView name)
|
|
|
-{
|
|
|
- MutexLocker locker(fs().m_lock);
|
|
|
- auto component = m_associated_component->lookup(name);
|
|
|
- if (!component)
|
|
|
- return ENOENT;
|
|
|
- return TRY(component->to_inode(fs()));
|
|
|
-}
|
|
|
-
|
|
|
}
|