LibCore: Add syscall wrapper for ftruncate()

This commit is contained in:
Andreas Kling 2021-11-23 12:16:07 +01:00
parent 4bf08e4d52
commit 4a213869f2
Notes: sideshowbarker 2024-07-18 00:48:47 +09:00
2 changed files with 8 additions and 0 deletions

View File

@ -123,4 +123,11 @@ ErrorOr<void> close(int fd)
return {};
}
ErrorOr<void> ftruncate(int fd, off_t length)
{
if (::ftruncate(fd, length) < 0)
return Error::from_syscall("ftruncate"sv, -errno);
return {};
}
}

View File

@ -24,5 +24,6 @@ ErrorOr<void*> mmap(void* address, size_t, int protection, int flags, int fd, of
ErrorOr<void> munmap(void* address, size_t);
ErrorOr<int> open(StringView path, int options, ...);
ErrorOr<void> close(int fd);
ErrorOr<void> ftruncate(int fd, off_t length);
}