mirror of
https://github.com/SerenityOS/serenity
synced 2026-05-10 17:12:55 +02:00
Previously, the VFS layer would try to handle renames more-or-less by itself, which really only worked for ext2, and even that was only due to the replace_child kludge existing specifically for this purpose. This never worked properly for FATFS, since the VFS layer effectively depended on filesystems having some kind of reference-counting for inodes, which is something that simply doesn't exist on any FAT variant we support. To resolve various issues with the existing scheme, this commit makes filesystem implementations themselves responsible for the actual rename operation, while keeping all the existing validation inside the VFS layer. The only intended behavior change here is that rename operations should actually properly work on FATFS.
43 lines
1.1 KiB
C++
43 lines
1.1 KiB
C++
/*
|
|
* Copyright (c) 2024, Liav A. <liavalb@hotmail.co.il>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Types.h>
|
|
#include <Kernel/FileSystem/FileSystem.h>
|
|
#include <Kernel/FileSystem/FileSystemSpecificOption.h>
|
|
#include <Kernel/FileSystem/Inode.h>
|
|
|
|
namespace Kernel {
|
|
|
|
class LoopDevice;
|
|
class DevLoopFSInode;
|
|
|
|
class DevLoopFS final : public FileSystem {
|
|
friend class DevLoopFSInode;
|
|
|
|
public:
|
|
virtual ~DevLoopFS() override;
|
|
static ErrorOr<NonnullRefPtr<FileSystem>> try_create(FileSystemSpecificOptions const&);
|
|
|
|
virtual ErrorOr<void> initialize() override;
|
|
virtual StringView class_name() const override { return "DevLoopFS"sv; }
|
|
|
|
virtual Inode& root_inode() override;
|
|
|
|
virtual ErrorOr<void> rename(Inode& old_parent_inode, StringView old_basename, Inode& new_parent_inode, StringView new_basename) override;
|
|
|
|
private:
|
|
virtual u8 internal_file_type_to_directory_entry_type(DirectoryEntryView const& entry) const override;
|
|
|
|
DevLoopFS();
|
|
ErrorOr<NonnullRefPtr<Inode>> get_inode(InodeIdentifier) const;
|
|
|
|
RefPtr<DevLoopFSInode> m_root_inode;
|
|
};
|
|
|
|
}
|