From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-in6.apple.com (mail-out6.apple.com [17.151.62.28]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 3084E1A1DF5 for ; Tue, 27 Sep 2016 09:48:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; d=apple.com; s=mailout2048s; c=relaxed/simple; q=dns/txt; i=@apple.com; t=1474994902; x=2338908502; h=From:Sender:Reply-To:Subject:Date:Message-id:To:Cc:MIME-version:Content-type: Content-transfer-encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-reply-to:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=3CRMJJHzpgfTwRXHNd0/S9mecZaXcQMS3qZBVP6HDwg=; b=KUol+rD2mIFaecunyXc5wxKCAFypvsCwSumlHPakYPfzb0XEsnwJxqqr62SjIA+K Uo/m0nXkOpuE2NgH3e1RIx9DpTdly2t5tYQ+u81JRgljTH1YujyOZDwdFwUglZJy uqNq+aCmEfvik++Zd6E4yVfLiMFBg+wvC0Jv4rs9bVOdJi4IriQMyHYxxIeDFWRB SXsjitFL7Y/Efxc+tTlE1UofOC9RQZcC479h6oh9JCuLi3RgN65FAarOHz7Fp+Go 8u7yt1WeC4GGbjqsxM5sMTu3pCzAWYy8R6tCKMnuqlYitupMLJiR4btnflDWoUGW Vnw6A++Jooaa66FAyUdOfg==; Received: from relay5.apple.com (relay5.apple.com [17.128.113.88]) by mail-in6.apple.com (Apple Secure Mail Relay) with SMTP id 07.0B.07752.6D2AAE75; Tue, 27 Sep 2016 09:48:22 -0700 (PDT) X-AuditID: 11973e15-f798f6d000001e48-ef-57eaa2d697a4 Received: from nwk-mmpp-sz11.apple.com (nwk-mmpp-sz11.apple.com [17.128.115.155]) by relay5.apple.com (Apple SCV relay) with SMTP id 2F.9D.27929.6D2AAE75; Tue, 27 Sep 2016 09:48:22 -0700 (PDT) MIME-version: 1.0 Received: from da0601a-dhcp143.apple.com ([17.226.15.143]) by nwk-mmpp-sz11.apple.com (Oracle Communications Messaging Server 8.0.1.1.0 64bit (built Jun 15 2016)) with ESMTPSA id <0OE600E4T9CMPF90@nwk-mmpp-sz11.apple.com>; Tue, 27 Sep 2016 09:48:22 -0700 (PDT) Sender: afish@apple.com From: Andrew Fish In-reply-to: <10380531DF222B45964BE3E93EFE5F045D229577@fmsmsx104.amr.corp.intel.com> Date: Tue, 27 Sep 2016 09:48:22 -0700 Cc: GN Keshava , Laszlo Ersek , Laurie Jarlstrom Message-id: References: <765021a6-cea7-ba5f-58cf-5e8fce05bbf2@redhat.com> <87d54199-6065-47e4-b3f8-04fd6f93220f@redhat.com> <10380531DF222B45964BE3E93EFE5F045D229577@fmsmsx104.amr.corp.intel.com> To: "edk2-devel@lists.01.org" X-Mailer: Apple Mail (2.3226) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrFLMWRmVeSWpSXmKPExsUi2FAYoXtt0atwg42vdS3W7fnGbtH+pYXV 4urnv2wWy47tYHFg8dg56y67x+I9L5k8Jl14zOzxft9VtgCWKC6blNSczLLUIn27BK6MDQc3 sRes1q94f20CSwPjD+UuRk4OCQETieYdU1kgbDGJC/fWs3UxcnEICexllHj34TpQggOs6NVa VYj4IUaJ1RvPs4E08AoISvyYfA+shllAXuLgeVmQMLOAlsT3R60sEPU9TBKndl5mBkkIC4hL vDuzCcp2kNj9eQEriM0moCyxYv4HdhCbUyBM4v6mbjCbRUBVYkn3YUaIoRUSW963Q+21kfjz tYkJYkEvi8SXWQ1gCREBM4n7H86yQRwtKzH7lxdIjYTAGTaJzoZ7LBMYRWYhuXsWwt2zkNy9 gJF5FaNQbmJmjm5mnpleYkFBTqpecn7uJkZQZEy3E93BeGaV1SFGAQ5GJR5ehqJX4UKsiWXF lbmHGKU5WJTEef9XPw0XEkhPLEnNTk0tSC2KLyrNSS0+xMjEwSnVwMi5cvJSIc26gpnn7m7b eebuxcivmu0L/wZK3P4/+VDxVcdv/SsTqrqnzF/z28H3erPQmZx7q3Nmsd0wtOqMrHA97/Gv WGX7c4E5l359n2r8SE9Ro5N7i+iJWBcxax31ncc5Y6T9PwoskXsbzuYtHOqjsfZi1tO568OC e38yPRYqj9cXTOcs36rEUpyRaKjFXFScCACp0PQkbQIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprKIsWRmVeSWpSXmKPExsUi2FA8W/faolfhBvO2aVms2/ON3aL9Swur xdXPf9kslh3bweLA4rFz1l12j8V7XjJ5TLrwmNnj/b6rbAEsUVw2Kak5mWWpRfp2CVwZGw5u Yi9YrV/x/toElgbGH8pdjBwcEgImEq/WqnYxcgKZYhIX7q1n62Lk4hASOMQosXrjeTaQBK+A oMSPyfdYQOqZBeQlDp6XBQkzC2hJfH/UygJR38MkcWrnZWaQhLCAuMS7M5ugbAeJ3Z8XsILY bALKEivmf2AHsTkFwiTub+oGs1kEVCWWdB9mhBhaIbHlfTvUXhuJP1+bmCAW9LJIfJnVAJYQ ETCTuP/hLBvEA7ISs395TWAUnIXk1FkIp85CcuoCRuZVjAJFqTmJlaZ6iQUFOal6yfm5mxjB gVwYsYPx/zKrQ4wCHIxKPLwMRa/ChVgTy4orc4FhwcGsJMLrPQ8oxJuSWFmVWpQfX1Sak1p8 iDEZ6P6JzFKiyfnAKMsriTc0MTEwMTY2MzY2NzEnTVhJnHcd74NwIYH0xJLU7NTUgtQimC1M HJxSDYxLGp/NZ76oMcGj5YTKW9bEH0f4+Bc7LCm7GSez2Vryc5Lvpf25XS2Wb6K2PjxbVW6b 3C6Wac75kWfzroPaC7YcmHaQ1XXy/DMPzy1zvHg29YZSU6+vldR+6xBuPfepO1TXb3t+meFm /Z8dvScOPeRvkZppM2dGb3+c5br7LQYch60D4+IdHTuVWIozEg21mIuKEwEV40iSqAIAAA== 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 16:48:23 -0000 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII I was kind of surprised that an example like this did not exist in: https://github.com/tianocore/edk2/tree/master/ShellPkg/Application Thanks, Andrew Fish > On Sep 27, 2016, at 9:44 AM, Jarlstrom, Laurie wrote: > > Keshava, > Attached Sample code is an example that will open a file name passed through the command line using the Shell. > > > thanks, > Laurie > > laurie.jarlstrom@intel.com > > Intel SSG/STO/EBP > (503) 712-9395 > > > > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of GN Keshava > Sent: Tuesday, September 27, 2016 4:52 AM > To: Laszlo Ersek > Cc: edk2-devel@lists.01.org > Subject: Re: [edk2] How to open a file by it's full path in UEFI > > Thank you Laszlo. > > I'll check it out. :) > > Thanks again. > Regards, > Keshava > > On Tue, 27 Sep 2016 at 16:47 Laszlo Ersek wrote: > >> On 09/27/16 12:46, GN Keshava wrote: >>> Hi Laszlo, >>> >>> Thank you for the answer. It was helpful. >>> >>> Considering option #1, can you give some more details (a small >>> example or any reference link would be helpful), how I can use Shell >>> APIs in my C file (which will compile to my .efi app)? >> >> Hmmm, I don't have hands-on experience with this, but you might want >> to try the ShellOpenFileByName() function, from >> "ShellPkg/Include/Library/ShellLib.h". >> >> You can find examples for UEFI applications that use the Shell library >> with: >> >> git grep -w ShellLib -- '*inf' >> >> or just grep the tree for ShellOpenFileByName(). >> >> See also "AppPkg/ReadMe.txt". >> >>> Considering option #2, How I can find device path programatically >>> from my C file? >> >> The EFI_SHELL_PROTOCOL.GetDevicePathFromMap() member function seems >> relevant -- it is specified in the UEFI Shell spec --, but I would >> definitely try ShellOpenFileByName() first. >> >> Thanks >> Laszlo >> >>> Thanks again for the help. :) >>> With regards, >>> Keshava >>> >>> On Tue, 27 Sep 2016 at 15:19 Laszlo Ersek >> > wrote: >>> >>> On 09/27/16 11:25, GN Keshava wrote: >>>> 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? >>> >>> The pathname you seem to have (as "complete") is specific to a given >>> simple FS, so system-wide it cannot be considered complete >>> (there >> can be >>> multiple filesystems). >>> >>> In your original email I missed that you started with "FS1:". >> Andrew's >>> answer covers that case. >>> >>> In summary, you can do three things: >>> - have a pathname that starts with FSx: (which is a shell-specific >>> mapping), and use Andrew's recommendation, >>> - have a complete UEFI device path, and then use what I recommended, >>> - have no information for selecting the filesystem (from the many >>> possible), and use your current iteration. >>> >>> Options #1 and #2 actually correspond to each other, considering >>> "expressive power" / information content (as long as you are in the >>> shell); please see the MAP shell command. >>> >>> Thanks >>> Laszlo >>> >>>> On Tue, 27 Sep 2016 at 14:46 Laszlo Ersek >> >>>> >> 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 > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel