Kernel: Make sys_.*at use VFS relative path finding
This commit is contained in:
@@ -47,10 +47,23 @@ namespace Kernel
|
||||
return *this;
|
||||
}
|
||||
|
||||
BAN::ErrorOr<File> clone() const
|
||||
{
|
||||
File result;
|
||||
result.inode = inode;
|
||||
TRY(result.canonical_path.append(canonical_path));
|
||||
return BAN::move(result);
|
||||
}
|
||||
|
||||
BAN::RefPtr<Inode> inode;
|
||||
BAN::String canonical_path;
|
||||
};
|
||||
|
||||
File root_file()
|
||||
{
|
||||
return File(root_inode(), "/"_sv);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -39,10 +39,6 @@ namespace Kernel
|
||||
|
||||
BAN::ErrorOr<void> truncate(int fd, off_t length);
|
||||
|
||||
BAN::ErrorOr<void> fstat(int fd, struct stat*) const;
|
||||
BAN::ErrorOr<void> fstatat(int fd, BAN::StringView path, struct stat* buf, int flag);
|
||||
BAN::ErrorOr<void> stat(BAN::StringView absolute_path, struct stat* buf, int flag);
|
||||
|
||||
BAN::ErrorOr<void> close(int);
|
||||
void close_all();
|
||||
void close_cloexec();
|
||||
@@ -52,7 +48,7 @@ namespace Kernel
|
||||
|
||||
BAN::ErrorOr<size_t> read_dir_entries(int fd, struct dirent* list, size_t list_len);
|
||||
|
||||
BAN::ErrorOr<const VirtualFileSystem::File&> file_of(int) const;
|
||||
BAN::ErrorOr<VirtualFileSystem::File> file_of(int) const;
|
||||
BAN::ErrorOr<BAN::StringView> path_of(int) const;
|
||||
BAN::ErrorOr<BAN::RefPtr<Inode>> inode_of(int);
|
||||
BAN::ErrorOr<int> flags_of(int) const;
|
||||
|
||||
@@ -103,8 +103,8 @@ namespace Kernel
|
||||
|
||||
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);
|
||||
BAN::ErrorOr<void> create_file_or_dir(const VirtualFileSystem::File& parent, BAN::StringView path, mode_t mode) const;
|
||||
BAN::ErrorOr<long> open_file_impl(const VirtualFileSystem::File& parent, BAN::StringView path, int oflag, mode_t = 0);
|
||||
BAN::ErrorOr<long> sys_open(const char* path, int, mode_t);
|
||||
BAN::ErrorOr<long> sys_openat(int, const char* path, int, mode_t);
|
||||
BAN::ErrorOr<long> sys_close(int fd);
|
||||
@@ -114,7 +114,7 @@ namespace Kernel
|
||||
BAN::ErrorOr<long> sys_create(const char*, mode_t);
|
||||
BAN::ErrorOr<long> sys_create_dir(const char*, mode_t);
|
||||
BAN::ErrorOr<long> sys_unlink(const char*);
|
||||
BAN::ErrorOr<long> readlink_impl(BAN::StringView absolute_path, char* buffer, size_t bufsize);
|
||||
BAN::ErrorOr<long> readlink_impl(BAN::RefPtr<Inode>, char* buffer, size_t bufsize);
|
||||
BAN::ErrorOr<long> sys_readlink(const char* path, char* buffer, size_t bufsize);
|
||||
BAN::ErrorOr<long> sys_readlinkat(int fd, const char* path, char* buffer, size_t bufsize);
|
||||
|
||||
@@ -217,13 +217,12 @@ namespace Kernel
|
||||
// ONLY CALLED BY TIMER INTERRUPT
|
||||
static void update_alarm_queue();
|
||||
|
||||
const VirtualFileSystem::File& working_directory() const { return m_working_directory; }
|
||||
|
||||
private:
|
||||
Process(const Credentials&, pid_t pid, pid_t parent, pid_t sid, pid_t pgrp);
|
||||
static Process* create_process(const Credentials&, pid_t parent, pid_t sid = 0, pid_t pgrp = 0);
|
||||
|
||||
// Load elf from a file
|
||||
static BAN::ErrorOr<BAN::UniqPtr<LibELF::LoadableELF>> load_elf_for_exec(const Credentials&, BAN::StringView file_path, const BAN::String& cwd, Kernel::PageTable&);
|
||||
|
||||
BAN::ErrorOr<void> validate_string_access(const char*);
|
||||
BAN::ErrorOr<void> validate_pointer_access_check(const void*, size_t, bool needs_write);
|
||||
BAN::ErrorOr<void> validate_pointer_access(const void*, size_t, bool needs_write);
|
||||
@@ -280,7 +279,8 @@ namespace Kernel
|
||||
|
||||
mutable Mutex m_process_lock;
|
||||
|
||||
BAN::String m_working_directory;
|
||||
VirtualFileSystem::File m_working_directory;
|
||||
|
||||
BAN::Vector<Thread*> m_threads;
|
||||
|
||||
uint64_t m_alarm_interval_ns { 0 };
|
||||
|
||||
Reference in New Issue
Block a user