mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 15:12:45 +00:00 
			
		
		
		
	 286984750e
			
		
	
	
		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;
 | |
| }
 | |
| 
 | |
| }
 |