forked from Bananymous/banan-os
Kernel: Fix Process APIs
This commit is contained in:
parent
132286895f
commit
572c4052f6
|
@ -96,7 +96,7 @@ namespace Kernel
|
||||||
BAN::ErrorOr<long> sys_getpgid(pid_t);
|
BAN::ErrorOr<long> sys_getpgid(pid_t);
|
||||||
|
|
||||||
BAN::ErrorOr<void> create_file_or_dir(BAN::StringView name, mode_t mode);
|
BAN::ErrorOr<void> create_file_or_dir(BAN::StringView name, mode_t mode);
|
||||||
BAN::ErrorOr<long> open_file(BAN::StringView path, int, mode_t = 0);
|
BAN::ErrorOr<long> open_file(BAN::StringView path, int oflag, mode_t = 0);
|
||||||
BAN::ErrorOr<long> sys_open(const char* path, int, mode_t);
|
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_openat(int, const char* path, int, mode_t);
|
||||||
BAN::ErrorOr<long> sys_close(int fd);
|
BAN::ErrorOr<long> sys_close(int fd);
|
||||||
|
@ -180,6 +180,8 @@ namespace Kernel
|
||||||
// Return false if access was page violation (segfault)
|
// Return false if access was page violation (segfault)
|
||||||
BAN::ErrorOr<bool> allocate_page_for_demand_paging(vaddr_t addr);
|
BAN::ErrorOr<bool> allocate_page_for_demand_paging(vaddr_t addr);
|
||||||
|
|
||||||
|
BAN::ErrorOr<BAN::String> absolute_path_of(BAN::StringView) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Process(const Credentials&, pid_t pid, pid_t parent, pid_t sid, pid_t pgrp);
|
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);
|
static Process* create_process(const Credentials&, pid_t parent, pid_t sid = 0, pid_t pgrp = 0);
|
||||||
|
@ -189,8 +191,6 @@ namespace Kernel
|
||||||
|
|
||||||
BAN::ErrorOr<int> block_until_exit(pid_t pid);
|
BAN::ErrorOr<int> block_until_exit(pid_t pid);
|
||||||
|
|
||||||
BAN::ErrorOr<BAN::String> absolute_path_of(BAN::StringView) const;
|
|
||||||
|
|
||||||
BAN::ErrorOr<void> validate_string_access(const char*);
|
BAN::ErrorOr<void> validate_string_access(const char*);
|
||||||
BAN::ErrorOr<void> validate_pointer_access(const void*, size_t);
|
BAN::ErrorOr<void> validate_pointer_access(const void*, size_t);
|
||||||
|
|
||||||
|
|
|
@ -710,6 +710,8 @@ namespace Kernel
|
||||||
|
|
||||||
BAN::ErrorOr<long> Process::open_file(BAN::StringView path, int flags, mode_t mode)
|
BAN::ErrorOr<long> Process::open_file(BAN::StringView path, int flags, mode_t mode)
|
||||||
{
|
{
|
||||||
|
LockGuard _(m_lock);
|
||||||
|
|
||||||
BAN::String absolute_path = TRY(absolute_path_of(path));
|
BAN::String absolute_path = TRY(absolute_path_of(path));
|
||||||
|
|
||||||
if (flags & O_CREAT)
|
if (flags & O_CREAT)
|
||||||
|
@ -717,6 +719,8 @@ namespace Kernel
|
||||||
if (flags & O_DIRECTORY)
|
if (flags & O_DIRECTORY)
|
||||||
return BAN::Error::from_errno(ENOTSUP);
|
return BAN::Error::from_errno(ENOTSUP);
|
||||||
auto file_or_error = VirtualFileSystem::get().file_from_absolute_path(m_credentials, absolute_path, O_WRONLY);
|
auto file_or_error = VirtualFileSystem::get().file_from_absolute_path(m_credentials, absolute_path, O_WRONLY);
|
||||||
|
if (!file_or_error.is_error() && (flags & O_EXCL))
|
||||||
|
return BAN::Error::from_errno(EEXIST);
|
||||||
if (file_or_error.is_error())
|
if (file_or_error.is_error())
|
||||||
{
|
{
|
||||||
if (file_or_error.error().get_error_code() == ENOENT)
|
if (file_or_error.error().get_error_code() == ENOENT)
|
||||||
|
@ -1744,7 +1748,7 @@ namespace Kernel
|
||||||
|
|
||||||
BAN::ErrorOr<BAN::String> Process::absolute_path_of(BAN::StringView path) const
|
BAN::ErrorOr<BAN::String> Process::absolute_path_of(BAN::StringView path) const
|
||||||
{
|
{
|
||||||
ASSERT(m_lock.is_locked());
|
LockGuard _(m_lock);
|
||||||
|
|
||||||
if (path.empty() || path == "."sv)
|
if (path.empty() || path == "."sv)
|
||||||
return m_working_directory;
|
return m_working_directory;
|
||||||
|
|
Loading…
Reference in New Issue