File tree Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Original file line number Diff line number Diff line change 55- Added ` proto::shell::Shell::{var(), set_var(), vars()} `
66- Added ` proto::pci::root_bridge::PciRootBridgeIo::configuration() ` .
77- Added ` proto::pci::root_bridge::PciRootBridgeIo::enumerate() ` .
8+ - Added ` proto::device_path::DevicePath::to_pool() ` .
9+ - Added ` proto::device_path::DevicePathUtilities::duplicate_path() ` .
810
911## Changed
1012- Changed ordering of ` proto::pci::PciIoAddress ` to (bus -> dev -> fun -> reg -> ext_reg).
Original file line number Diff line number Diff line change @@ -590,6 +590,15 @@ impl DevicePath {
590590 unsafe { mem:: transmute ( data) }
591591 }
592592
593+ /// Returns an owned pool copy of this path.
594+ #[ cfg( feature = "alloc" ) ]
595+ #[ must_use]
596+ pub fn to_pool ( & self ) -> Result < PoolDevicePath , DevicePathUtilitiesError > {
597+ open_utility_protocol ( ) ?
598+ . duplicate_path ( self )
599+ . map_err ( |_| DevicePathUtilitiesError :: OutOfMemory )
600+ }
601+
593602 /// Transforms the device path to its string representation using the
594603 /// [`DevicePathToText`] protocol.
595604 #[ cfg( feature = "alloc" ) ]
Original file line number Diff line number Diff line change @@ -29,6 +29,22 @@ impl DevicePathUtilities {
2929 unsafe { ( self . 0 . get_device_path_size ) ( device_path. as_ffi_ptr ( ) . cast ( ) ) }
3030 }
3131
32+ /// Create a new device path by cloning the given `path` into newly allocated memory.
33+ ///
34+ /// # Arguments
35+ /// - `path`: A reference to the device path to clone.
36+ ///
37+ /// # Returns
38+ /// A [`PoolDevicePath`] instance created by cloning the given `path`.
39+ pub fn duplicate_path ( & self , path : & DevicePath ) -> crate :: Result < PoolDevicePath > {
40+ unsafe {
41+ let ptr = ( self . 0 . duplicate_device_path ) ( path. as_ffi_ptr ( ) . cast ( ) ) ;
42+ NonNull :: new ( ptr. cast_mut ( ) )
43+ . map ( |p| PoolDevicePath ( PoolAllocation :: new ( p. cast ( ) ) ) )
44+ . ok_or_else ( || Status :: OUT_OF_RESOURCES . into ( ) )
45+ }
46+ }
47+
3248 /// Creates a new device path by appending the second device path to the first.
3349 ///
3450 /// # Arguments
You can’t perform that action at this time.
0 commit comments