@@ -79,7 +79,7 @@ pub struct BootServices {
79
79
) -> Status ,
80
80
locate_device_path : unsafe extern "efiapi" fn (
81
81
proto : & Guid ,
82
- device_path : & mut * mut DevicePath ,
82
+ device_path : & mut & DevicePath ,
83
83
out_handle : * mut Handle ,
84
84
) -> Status ,
85
85
install_configuration_table : usize ,
@@ -531,12 +531,19 @@ impl BootServices {
531
531
}
532
532
533
533
/// Locates the handle to a device on the device path that supports the specified protocol.
534
- pub fn locate_device_path < P : Protocol > ( & self , device_path : & mut DevicePath ) -> Result < Handle > {
534
+ ///
535
+ /// The `device_path` is updated to point at the remaining part of the [`DevicePath`] after
536
+ /// the part that matched the protocol. For example, it can be used with a device path
537
+ /// that contains a file path to strip off the file system portion of the device path,
538
+ /// leaving the file path and handle to the file system driver needed to access the file.
539
+ ///
540
+ /// If the first node of `device_path` matches the
541
+ /// protocol, the `device_path` is advanced to the device path terminator node. If `device_path`
542
+ /// is a multi-instance device path, the function will operate on the first instance.
543
+ pub fn locate_device_path < P : Protocol > ( & self , device_path : & mut & DevicePath ) -> Result < Handle > {
535
544
unsafe {
536
545
let mut handle = Handle :: uninitialized ( ) ;
537
- let mut device_path_ptr = device_path as * mut DevicePath ;
538
- ( self . locate_device_path ) ( & P :: GUID , & mut device_path_ptr, & mut handle)
539
- . into_with_val ( || handle)
546
+ ( self . locate_device_path ) ( & P :: GUID , device_path, & mut handle) . into_with_val ( || handle)
540
547
}
541
548
}
542
549
@@ -777,10 +784,10 @@ impl BootServices {
777
784
let device_path = self
778
785
. handle_protocol :: < DevicePath > ( device_handle) ?
779
786
. expect ( "Failed to retrieve `DevicePath` protocol from image's device handle" ) ;
780
- let device_path = unsafe { & mut * device_path. get ( ) } ;
787
+ let mut device_path = unsafe { & * device_path. get ( ) } ;
781
788
782
789
let device_handle = self
783
- . locate_device_path :: < SimpleFileSystem > ( device_path) ?
790
+ . locate_device_path :: < SimpleFileSystem > ( & mut device_path) ?
784
791
. expect ( "Failed to locate `SimpleFileSystem` protocol on device path" ) ;
785
792
786
793
self . handle_protocol :: < SimpleFileSystem > ( device_handle)
0 commit comments