Kernel: Make VirtualFileSystem::File non copyable
This commit is contained in:
@@ -24,6 +24,29 @@ namespace Kernel
|
||||
|
||||
struct File
|
||||
{
|
||||
File() = default;
|
||||
explicit File(BAN::RefPtr<Inode> inode)
|
||||
: inode(BAN::move(inode))
|
||||
{ }
|
||||
explicit File(BAN::RefPtr<Inode> inode, BAN::String&& canonical_path)
|
||||
: inode(BAN::move(inode))
|
||||
, canonical_path(BAN::move(canonical_path))
|
||||
{ }
|
||||
|
||||
File(const File&) = delete;
|
||||
File(File&& other)
|
||||
: inode(BAN::move(other.inode))
|
||||
, canonical_path(BAN::move(other.canonical_path))
|
||||
{ }
|
||||
|
||||
File& operator=(const File&) = delete;
|
||||
File& operator=(File&& other)
|
||||
{
|
||||
inode = BAN::move(other.inode);
|
||||
canonical_path = BAN::move(other.canonical_path);
|
||||
return *this;
|
||||
}
|
||||
|
||||
BAN::RefPtr<Inode> inode;
|
||||
BAN::String canonical_path;
|
||||
};
|
||||
@@ -31,7 +54,7 @@ namespace Kernel
|
||||
BAN::ErrorOr<File> file_from_relative_path(const File& parent, const Credentials&, BAN::StringView, int);
|
||||
BAN::ErrorOr<File> file_from_absolute_path(const Credentials& credentials, BAN::StringView path, int flags)
|
||||
{
|
||||
return file_from_relative_path({ .inode = root_inode(), .canonical_path = {} }, credentials, path, flags);
|
||||
return file_from_relative_path(File(root_inode()), credentials, path, flags);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace Kernel
|
||||
|
||||
BAN::ErrorOr<long> sys_getpid() const { return pid(); }
|
||||
|
||||
BAN::ErrorOr<long> open_inode(BAN::RefPtr<Inode>, int flags);
|
||||
BAN::ErrorOr<long> open_inode(VirtualFileSystem::File&&, int flags);
|
||||
|
||||
BAN::ErrorOr<void> create_file_or_dir(BAN::StringView name, mode_t mode);
|
||||
BAN::ErrorOr<long> open_file(BAN::StringView path, int oflag, mode_t = 0);
|
||||
|
||||
Reference in New Issue
Block a user