From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-it0-x22a.google.com (mail-it0-x22a.google.com [IPv6:2607:f8b0:4001:c0b::22a]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id AB6161A1E26 for ; Thu, 29 Sep 2016 03:22:23 -0700 (PDT) Received: by mail-it0-x22a.google.com with SMTP id j69so74174920itb.0 for ; Thu, 29 Sep 2016 03:22:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=qQSE3t8O/sVvZD9eiSn/Oueus6lloqzo2qgjoJLj9ZE=; b=hpKX81yKE3hn5oMg7VLidzAumgadJO+4kwepCLSAC4ZmxvQzycVsYUBBcZb9be8pAu 4Ej6dpvkOTAzuon6S/24TVB8mP5qCDnc4+7o7oLaQ3qsxdEKJYn9M/erwlao6/93qcta ZDw+0WpuQpuMcPYUrCMLvYTI9Kx58UH8SQpH+2+9k7wvyyQs0XB9lRlxT/WjPyuv5IZ6 UBB9GCCNVprvwCqs7QQ8mHhgNXjYqZ/tgg1HpUa7fcvcRoLkPuW55IROopg/n9bsC2R/ UllGAXWjE2U/e46kfJqznTMrWOCD42NkA8H6AJCtKFFjEGczXDTazuXB8k/2WelUiuqo HWjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=qQSE3t8O/sVvZD9eiSn/Oueus6lloqzo2qgjoJLj9ZE=; b=OGtGi4h1Og/Cm8Ya3Gtl8+S+fjGwTcL976dV8f1JhpDJ9J/Yy9RB8XZmBz6shw12KY KsBwlyzSjfpyCXZjzxgvZjZAOC1/yXWo9gDyuAV5jPyzwUpwE9Ysi8VC7kKLTK2rt0ba w7Skxmn0RM5Vg2Wm1+HHQGwRKirm6mB9TH292hF52norY3rndcaTpb9DpNjwAClyZazr Tt8+Ru9DYeXOE6BV8BmX3OdMZg8DSO6PWLPqTDb09/jL2uZf8jiRjk5c3VeaPIX0WxDK 5j5vm7o1svHt5iGQEW/g7ukuiEN+M7LSjholPG1was+XGdBqsqOCD6CxFCp6MojLPV+q in2Q== X-Gm-Message-State: AA6/9Rl1E591QU3ryv9whFGBPejJNVMdi8i0yT3jz5VmQIdKFZ/N80Ox6NZHICP7YjomlX1w9n7n2XWN3DbMGA== X-Received: by 10.36.117.6 with SMTP id y6mr7333298itc.102.1475144543022; Thu, 29 Sep 2016 03:22:23 -0700 (PDT) MIME-Version: 1.0 References: <765021a6-cea7-ba5f-58cf-5e8fce05bbf2@redhat.com> <87d54199-6065-47e4-b3f8-04fd6f93220f@redhat.com> <10380531DF222B45964BE3E93EFE5F045D229577@fmsmsx104.amr.corp.intel.com> In-Reply-To: <10380531DF222B45964BE3E93EFE5F045D229577@fmsmsx104.amr.corp.intel.com> From: GN Keshava Date: Thu, 29 Sep 2016 10:22:11 +0000 Message-ID: To: "Jarlstrom, Laurie" , "edk2-devel@lists.01.org" X-Content-Filtered-By: Mailman/MimeDel 2.1.21 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: Thu, 29 Sep 2016 10:22:24 -0000 Content-Type: text/plain; charset=UTF-8 Hi Laurie, I'm trying this code, but it hangs in OpenFileByName function. It does not return. Any idea on this issue? Thanks. With regards, Keshava GN On Tue, 27 Sep 2016 at 22:14 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 >