Hi Laszlo, Thanks for the reply. I meant I have complete file path. I believe the "device path" is different. Is it possible to obtain DevicePath using my full file path?
Thanks. Regards, Keshava On Tue, 27 Sep 2016 at 14:46 Laszlo Ersek <[email protected]> wrote: > On 09/27/16 11:03, GN Keshava wrote: > > Hi all, > > > > > > I'm trying to open a file from my UEFI application. The path of file is > > > > fs1:/myfolder/myfile.txt > > > > The code : > > > > efiStatus = bs->LocateHandleBuffer(ByProtocol, > > &sfspGuid, > > NULL, > > &handleCount, > > &handles); > > > > for (index = 0; index < (int)handleCount; ++ index) > > { > > EFI_SIMPLE_FILE_SYSTEM_PROTOCOL* fs = NULL; > > > > efiStatus = bs->HandleProtocol( > > handles[index], > > &sfspGuid, > > (void**)&fs); > > > > EFI_FILE_PROTOCOL* root = NULL; > > ... > > efiStatus = fs->OpenVolume(fs, &root); > > > > EFI_FILE_PROTOCOL* token = NULL; > > > > efiStatus = root->Open( > > root, > > &token, > > L"myfolder\\myfile.txt", > > EFI_FILE_MODE_READ, > > EFI_FILE_READ_ONLY | EFI_FILE_HIDDEN | EFI_FILE_SYSTEM); > > } > > > > But using this method, I can only go through all the file system handles > > and open each volume and try opening my file. > > > > But I want to give full path to my file and open it in it's volume. > > > > How can I acheive this? > > Thanks. > > If you have a complete device path, you can use gBS->LocateDevicePath() > with gEfiSimpleFileSystemProtocolGuid, to locate the handle with the > most specific device path (--> the longest device path prefix) with the > simple FS protocol installed on it. Then you can check if the remaining > device path (returned by the service) consist of nothing but one File > Path Media Device Path node. If so, you can open the simple FS protocol > on the handle found, then use that to open the file by pathname. > > Laszlo > > _______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

