LibCore: Add wrapper for fsync()

This commit is contained in:
Romain Chardiny 2024-03-27 06:53:09 +01:00 committed by Sam Atkins
parent d6732e5906
commit 892da127d0
Notes: sideshowbarker 2024-07-17 02:59:43 +09:00
2 changed files with 8 additions and 0 deletions

View file

@ -598,6 +598,13 @@ ErrorOr<void> ftruncate(int fd, off_t length)
return {};
}
ErrorOr<void> fsync(int fd)
{
if (::fsync(fd) < 0)
return Error::from_syscall("fsync"sv, -errno);
return {};
}
ErrorOr<struct stat> stat(StringView path)
{
if (!path.characters_without_null_termination())

View file

@ -127,6 +127,7 @@ ErrorOr<int> open(StringView path, int options, mode_t mode = 0);
ErrorOr<int> openat(int fd, StringView path, int options, mode_t mode = 0);
ErrorOr<void> close(int fd);
ErrorOr<void> ftruncate(int fd, off_t length);
ErrorOr<void> fsync(int fd);
ErrorOr<struct stat> stat(StringView path);
ErrorOr<struct stat> lstat(StringView path);
ErrorOr<ssize_t> read(int fd, Bytes buffer);