mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
286984750e
Now that support for 32-bit x86 has been removed, we don't have to worry about the top half of `off_t`/`u64` values being chopped off when we try to pass them in registers. Therefore, we no longer need the workaround of pointers to stack-allocated values to syscalls. Note that this changes the system call ABI, so statically linked programs will have to be re-linked.
25 lines
600 B
C++
25 lines
600 B
C++
/*
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <Kernel/FileSystem/OpenFileDescription.h>
|
|
#include <Kernel/Tasks/Process.h>
|
|
|
|
namespace Kernel {
|
|
|
|
ErrorOr<FlatPtr> Process::sys$ftruncate(int fd, off_t length)
|
|
{
|
|
VERIFY_NO_PROCESS_BIG_LOCK(this);
|
|
TRY(require_promise(Pledge::stdio));
|
|
if (length < 0)
|
|
return EINVAL;
|
|
auto description = TRY(open_file_description(fd));
|
|
if (!description->is_writable())
|
|
return EBADF;
|
|
TRY(description->truncate(static_cast<u64>(length)));
|
|
return 0;
|
|
}
|
|
|
|
}
|