From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 68BAF1A1E15 for ; Tue, 27 Sep 2016 02:16:22 -0700 (PDT) Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F12D461A11; Tue, 27 Sep 2016 09:16:21 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-5.phx2.redhat.com [10.3.116.5]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u8R9GKnU026137; Tue, 27 Sep 2016 05:16:21 -0400 To: GN Keshava References: From: Laszlo Ersek Cc: "edk2-devel@lists.01.org" Message-ID: Date: Tue, 27 Sep 2016 11:16:20 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 27 Sep 2016 09:16:22 +0000 (UTC) Subject: Re: How to open a file by it's full path in UEFI X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Sep 2016 09:16:22 -0000 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit 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