Truly independent web browser
LibCore: Add System::statfs() and System::fstatfs()
Shannon Boothad205d93e395
diff --git a/Libraries/LibCore/System.cpp b/Libraries/LibCore/System.cppindex 9480ba04c54..f85dd0cf304 100644--- a/Libraries/LibCore/System.cpp+++ b/Libraries/LibCore/System.cpp@@ -109,6 +109,28 @@ ErrorOr<struct stat> fstat(int fd)return st;}+#if defined(AK_OS_LINUX) || defined(AK_OS_MACOS)+ErrorOr<struct statfs> statfs(StringView path)+{+ if (!path.characters_without_null_termination())+ return Error::from_syscall("statfs"sv, EFAULT);++ struct statfs file_system = {};+ ByteString path_string = path;+ if (::statfs(path_string.characters(), &file_system) < 0)+ return Error::from_syscall("statfs"sv, errno);+ return file_system;+}++ErrorOr<struct statfs> fstatfs(int fd)+{+ struct statfs file_system = {};+ if (::fstatfs(fd, &file_system) < 0)+ return Error::from_syscall("fstatfs"sv, errno);+ return file_system;+}+#endif+ErrorOr<struct stat> fstatat(int fd, StringView path, int flags){if (!path.characters_without_null_termination())diff --git a/Libraries/LibCore/System.h b/Libraries/LibCore/System.hindex e96ab59b150..158f1b399af 100644--- a/Libraries/LibCore/System.h+++ b/Libraries/LibCore/System.h@@ -54,6 +54,12 @@ struct sockaddr;# include <sys/ucred.h>#endif+#if defined(AK_OS_LINUX)+# include <sys/vfs.h>+#elif defined(AK_OS_MACOS)+# include <sys/mount.h>+#endif+#ifdef AK_OS_SOLARIS# include <sys/filio.h># include <ucred.h>@@ -77,6 +83,10 @@ CORE_API ErrorOr<sighandler_t> signal(int signal, sighandler_t handler);# endifCORE_API ErrorOr<struct stat> fstat(int fd);CORE_API ErrorOr<struct stat> fstatat(int fd, StringView path, int flags);+# if defined(AK_OS_LINUX) || defined(AK_OS_MACOS)+CORE_API ErrorOr<struct statfs> statfs(StringView path);+CORE_API ErrorOr<struct statfs> fstatfs(int fd);+# endifErrorOr<int> openat(int fd, StringView path, int options, mode_t mode = 0);CORE_API ErrorOr<int> fcntl(int fd, int command, ...);ErrorOr<void*> mmap(void* address, size_t, int protection, int flags, int fd, off_t, size_t alignment = 0, StringView name = {});