From 729ff267d7e6a8265f90dbaf310c8620dcde5f38 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Thu, 11 May 2023 01:48:33 +0300 Subject: [PATCH] LibC: add function declarations to sys/stat.h --- LibELF/LibELF/ELF.cpp | 2 +- kernel/include/kernel/Process.h | 4 ++-- kernel/kernel/Font.cpp | 2 +- kernel/kernel/Shell.cpp | 4 ++-- libc/include/sys/stat.h | 23 ++++++++++++++++++++--- 5 files changed, 26 insertions(+), 9 deletions(-) diff --git a/LibELF/LibELF/ELF.cpp b/LibELF/LibELF/ELF.cpp index 27998a9c71..6d696e3134 100644 --- a/LibELF/LibELF/ELF.cpp +++ b/LibELF/LibELF/ELF.cpp @@ -20,7 +20,7 @@ namespace LibELF int fd = TRY(Kernel::Process::current().open(file_path, O_RDONLY)); BAN::ScopeGuard _([fd] { MUST(Kernel::Process::current().close(fd)); }); - stat st; + struct stat st; TRY(Kernel::Process::current().fstat(fd, &st)); TRY(data.resize(st.st_size)); diff --git a/kernel/include/kernel/Process.h b/kernel/include/kernel/Process.h index 6f85dbe556..90f1528c85 100644 --- a/kernel/include/kernel/Process.h +++ b/kernel/include/kernel/Process.h @@ -46,8 +46,8 @@ namespace Kernel BAN::ErrorOr write(int fd, const void* buffer, size_t offset, size_t count); BAN::ErrorOr creat(BAN::StringView name, mode_t); - BAN::ErrorOr fstat(int fd, stat*); - BAN::ErrorOr stat(BAN::StringView path, stat*); + BAN::ErrorOr fstat(int fd, struct stat*); + BAN::ErrorOr stat(BAN::StringView path, struct stat*); BAN::ErrorOr mount(BAN::StringView source, BAN::StringView target); diff --git a/kernel/kernel/Font.cpp b/kernel/kernel/Font.cpp index 7000d7eeaf..3bd31da814 100644 --- a/kernel/kernel/Font.cpp +++ b/kernel/kernel/Font.cpp @@ -40,7 +40,7 @@ namespace Kernel int fd = TRY(Process::current().open(path, O_RDONLY)); BAN::ScopeGuard _([fd] { MUST(Process::current().close(fd)); }); - stat st; + struct stat st; TRY(Process::current().fstat(fd, &st)); BAN::Vector file_data; diff --git a/kernel/kernel/Shell.cpp b/kernel/kernel/Shell.cpp index 60a6d8e323..e8c41465e0 100644 --- a/kernel/kernel/Shell.cpp +++ b/kernel/kernel/Shell.cpp @@ -522,7 +522,7 @@ argument_done: TRY(entry_prefix.push_back('/')); for (const auto& entry : all_entries) { - stat st; + struct stat st; BAN::String entry_path; TRY(entry_path.append(entry_prefix)); @@ -572,7 +572,7 @@ argument_done: return {}; } - stat st; + struct stat st; TRY(Process::current().stat(arguments[1], &st)); Inode::Mode mode { st.st_mode }; diff --git a/libc/include/sys/stat.h b/libc/include/sys/stat.h index 7e92c950e6..2113dc1c7f 100644 --- a/libc/include/sys/stat.h +++ b/libc/include/sys/stat.h @@ -3,12 +3,12 @@ #include #include -__BEGIN_DECLS - #define st_atime st_atim.tv_sec #define st_ctime st_ctim.tv_sec #define st_mtime st_mtim.tv_sec +__BEGIN_DECLS + struct stat { dev_t st_dev; @@ -26,4 +26,21 @@ struct stat blkcnt_t st_blocks; }; -__END_DECLS \ No newline at end of file +int chmod(const char*, mode_t); +int fchmod(int, mode_t); +int fchmodat(int, const char*, mode_t, int); +int fstat(int, struct stat*); +int fstatat(int, const char*, struct stat*, int); +int futimens(int, const struct timespec[2]); +int lstat(const char*, struct stat*); +int mkdir(const char*, mode_t); +int mkdirat(int, const char*, mode_t); +int mkfifo(const char*, mode_t); +int mkfifoat(int, const char*, mode_t); +int mknod(const char*, mode_t, dev_t); +int mknodat(int, const char*, mode_t, dev_t); +int stat(const char*, struct stat*); +mode_t umask(mode_t); +int utimensat(int, const char*, const struct timespec[2], int); + +__END_DECLS