Kernel/LibC: Add SYS_TRUNCATE
This commit is contained in:
@@ -242,6 +242,12 @@ namespace Kernel
|
||||
return m_open_files[fd]->offset;
|
||||
}
|
||||
|
||||
BAN::ErrorOr<void> OpenFileDescriptorSet::truncate(int fd, off_t length)
|
||||
{
|
||||
TRY(validate_fd(fd));
|
||||
return m_open_files[fd]->inode->truncate(length);
|
||||
}
|
||||
|
||||
static void read_stat_from_inode(BAN::RefPtr<Inode> inode, struct stat* out)
|
||||
{
|
||||
out->st_dev = inode->dev();
|
||||
|
||||
@@ -1145,6 +1145,13 @@ namespace Kernel
|
||||
return TRY(m_open_file_descriptors.tell(fd));
|
||||
}
|
||||
|
||||
BAN::ErrorOr<long> Process::sys_truncate(int fd, off_t length)
|
||||
{
|
||||
LockGuard _(m_process_lock);
|
||||
TRY(m_open_file_descriptors.truncate(fd, length));
|
||||
return 0;
|
||||
}
|
||||
|
||||
BAN::ErrorOr<void> Process::mount(BAN::StringView source, BAN::StringView target)
|
||||
{
|
||||
BAN::String absolute_source, absolute_target;
|
||||
|
||||
Reference in New Issue
Block a user