mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
LibC: Add functions for the new statvfs syscalls
This commit adds the statvfs() and fstatvfs() functions into LibC.
This commit is contained in:
parent
1c3badede3
commit
45a1a7e1e6
Notes:
sideshowbarker
2024-07-18 17:46:38 +09:00
Author: https://github.com/sw1tchbl4d3r Commit: https://github.com/SerenityOS/serenity/commit/45a1a7e1e6c Pull-request: https://github.com/SerenityOS/serenity/pull/6742 Reviewed-by: https://github.com/awesomekling
3 changed files with 63 additions and 0 deletions
|
@ -46,6 +46,7 @@ set(LIBC_SOURCES
|
|||
sys/socket.cpp
|
||||
sys/uio.cpp
|
||||
sys/wait.cpp
|
||||
sys/statvfs.cpp
|
||||
termcap.cpp
|
||||
termios.cpp
|
||||
time.cpp
|
||||
|
|
26
Userland/Libraries/LibC/sys/statvfs.cpp
Normal file
26
Userland/Libraries/LibC/sys/statvfs.cpp
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Justin Mietzner <sw1tchbl4d3@sw1tchbl4d3.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <sys/statvfs.h>
|
||||
#include <syscall.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
int statvfs(const char* path, struct statvfs* buf)
|
||||
{
|
||||
Syscall::SC_statvfs_params params { { path, strlen(path) }, buf };
|
||||
int rc = syscall(SC_statvfs, ¶ms);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
int fstatvfs(int fd, struct statvfs* buf)
|
||||
{
|
||||
int rc = syscall(SC_fstatvfs, fd, buf);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
}
|
36
Userland/Libraries/LibC/sys/statvfs.h
Normal file
36
Userland/Libraries/LibC/sys/statvfs.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Justin Mietzner <sw1tchbl4d3@sw1tchbl4d3.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define ST_RDONLY 0x1
|
||||
#define ST_NOSUID 0x2
|
||||
|
||||
struct statvfs {
|
||||
unsigned long f_bsize;
|
||||
unsigned long f_frsize;
|
||||
fsblkcnt_t f_blocks;
|
||||
fsblkcnt_t f_bfree;
|
||||
fsblkcnt_t f_bavail;
|
||||
|
||||
fsfilcnt_t f_files;
|
||||
fsfilcnt_t f_ffree;
|
||||
fsfilcnt_t f_favail;
|
||||
|
||||
unsigned long f_fsid;
|
||||
unsigned long f_flag;
|
||||
unsigned long f_namemax;
|
||||
};
|
||||
|
||||
int statvfs(const char* path, struct statvfs* buf);
|
||||
int fstatvfs(int fd, struct statvfs* buf);
|
||||
|
||||
__END_DECLS
|
Loading…
Reference in a new issue