mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 00:42:44 +00:00 
			
		
		
		
	 79fa9765ca
			
		
	
	
		79fa9765ca
		
	
	
	
	
		
			
			We now use AK::Error and AK::ErrorOr<T> in both kernel and userspace! This was a slightly tedious refactoring that took a long time, so it's not unlikely that some bugs crept in. Nevertheless, it does pass basic functionality testing, and it's just real nice to finally see the same pattern in all contexts. :^)
		
			
				
	
	
		
			38 lines
		
	
	
	
		
			944 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			38 lines
		
	
	
	
		
			944 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #include <Kernel/FileSystem/AnonymousFile.h>
 | |
| #include <Kernel/Memory/AnonymousVMObject.h>
 | |
| #include <Kernel/Process.h>
 | |
| 
 | |
| namespace Kernel {
 | |
| 
 | |
| AnonymousFile::AnonymousFile(NonnullRefPtr<Memory::AnonymousVMObject> vmobject)
 | |
|     : m_vmobject(move(vmobject))
 | |
| {
 | |
| }
 | |
| 
 | |
| AnonymousFile::~AnonymousFile()
 | |
| {
 | |
| }
 | |
| 
 | |
| ErrorOr<Memory::Region*> AnonymousFile::mmap(Process& process, OpenFileDescription&, Memory::VirtualRange const& range, u64 offset, int prot, bool shared)
 | |
| {
 | |
|     if (offset != 0)
 | |
|         return EINVAL;
 | |
| 
 | |
|     if (range.size() != m_vmobject->size())
 | |
|         return EINVAL;
 | |
| 
 | |
|     return process.address_space().allocate_region_with_vmobject(range, m_vmobject, offset, {}, prot, shared);
 | |
| }
 | |
| 
 | |
| ErrorOr<NonnullOwnPtr<KString>> AnonymousFile::pseudo_path(const OpenFileDescription&) const
 | |
| {
 | |
|     return KString::try_create(":anonymous-file:"sv);
 | |
| }
 | |
| 
 | |
| }
 |