From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-it0-x233.google.com (mail-it0-x233.google.com [IPv6:2607:f8b0:4001:c0b::233]) (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 AF2A71A1E15 for ; Tue, 27 Sep 2016 02:25:29 -0700 (PDT) Received: by mail-it0-x233.google.com with SMTP id u134so36222820itb.1 for ; Tue, 27 Sep 2016 02:25:29 -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 :cc; bh=jUXnFSTVcqBbRyPmDdb3yLtTIXD118ZlVyHNa6dqhwc=; b=QUApbO82y9pLl1atD7FT1ABPNzE7BvTgzZa4wMSlk4fcBtkREye2IgMaxAbtdt0zdu UP+foEs96J5e5BV/SZV9/y6bP7BGVg/EnLavrRK4eQUsHXhcYjwlzzgt+nUb34k2oPSY qqQMxcZULbOSn52n1KO7W+ebVagjIpN2D9w/+SdtVA/G1npUD3eGUrnJctUWDHRYgx9/ 1S9cf9D158ZxV0luWjrzeavENMAQr9uyObWvva7rlo37/0KhhWVHMNYJouSrdeV/uz63 MdTk5OWPMRe2YiOoDFjyxrh0RgJLAc98GeEOWx+zr4eMjYIS0fh0mIqmO9+n3HORv5Yb F22w== 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:cc; bh=jUXnFSTVcqBbRyPmDdb3yLtTIXD118ZlVyHNa6dqhwc=; b=N/9RGDfGa9nhdanG+PXrOAxXwdE0DsoBGQOd6wgupmRux8OF+2stszweTRWP8FSoYq ljs/vQmck80/eIK7j02e6Gs0BxLwPadMFAEq9qp9JlGCLveN1ZodP1gXUL4gjQm4Jd5e UHY6C8zYgotKb11kfFYEacyFlN7uilCItpA85clDvOZErFjiNZeSvLSAmedobXXfTOWN tUhpoWjtHimf8aEmYYpoOtD2lQGbmPJ6bcC3mTNViLldZAMGDNzM+Z1iOoouQTVCvezx Vm0fcMN5LXRsH6o2aTCfQgKzMjD8rh4OlUYFRBefyP4adCilGgnlStiVLKKPOI3oDBeK vtxA== X-Gm-Message-State: AA6/9RnR/4RJ/EA/3bHzEHsPyj5kDuyjyNWOtVVavsijgYswMOsjDAhBcibn84yJcb8v+AN0Kbq+iLGBqZjrKg== X-Received: by 10.36.40.130 with SMTP id h124mr2755226ith.89.1474968328923; Tue, 27 Sep 2016 02:25:28 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: GN Keshava Date: Tue, 27 Sep 2016 09:25:18 +0000 Message-ID: To: Laszlo Ersek Cc: "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: Tue, 27 Sep 2016 09:25:30 -0000 Content-Type: text/plain; charset=UTF-8 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 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 > >