mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 10:22:45 +00:00 
			
		
		
		
	Kernel/Storage: Migrate the partition code to use the ErrorOr container
That code used the old AK::Result container, which leads to overly complicated initialization flow when trying to figure out the correct partition table type. Instead, when using the ErrorOr container the code is much simpler and more understandable.
This commit is contained in:
		
							parent
							
								
									19912a0b32
								
							
						
					
					
						commit
						5ed3f7c6bf
					
				
					 9 changed files with 39 additions and 50 deletions
				
			
		|  | @ -1,5 +1,5 @@ | |||
| /*
 | ||||
|  * Copyright (c) 2020, Liav A. <liavalb@hotmail.co.il> | ||||
|  * Copyright (c) 2020-2022, Liav A. <liavalb@hotmail.co.il> | ||||
|  * | ||||
|  * SPDX-License-Identifier: BSD-2-Clause | ||||
|  */ | ||||
|  | @ -15,15 +15,15 @@ namespace Kernel { | |||
| #define EBR_CHS_CONTAINER 0x05 | ||||
| #define EBR_LBA_CONTAINER 0x0F | ||||
| 
 | ||||
| Result<NonnullOwnPtr<MBRPartitionTable>, PartitionTable::Error> MBRPartitionTable::try_to_initialize(StorageDevice const& device) | ||||
| ErrorOr<NonnullOwnPtr<MBRPartitionTable>> MBRPartitionTable::try_to_initialize(StorageDevice const& device) | ||||
| { | ||||
|     auto table = adopt_nonnull_own_or_enomem(new (nothrow) MBRPartitionTable(device)).release_value_but_fixme_should_propagate_errors(); | ||||
|     auto table = TRY(adopt_nonnull_own_or_enomem(new (nothrow) MBRPartitionTable(device))); | ||||
|     if (table->contains_ebr()) | ||||
|         return { PartitionTable::Error::ContainsEBR }; | ||||
|         return Error::from_errno(ENOTSUP); | ||||
|     if (table->is_protective_mbr()) | ||||
|         return { PartitionTable::Error::MBRProtective }; | ||||
|         return Error::from_errno(ENOTSUP); | ||||
|     if (!table->is_valid()) | ||||
|         return { PartitionTable::Error::Invalid }; | ||||
|         return Error::from_errno(EINVAL); | ||||
|     return table; | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Liav A
						Liav A