From: "Ni, Ruiyu" <ruiyu.ni@intel.com>
To: Jeff Westfahl <jeff.westfahl@ni.com>,
"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Kinney, Michael D" <michael.d.kinney@intel.com>,
"Carsey, Jaben" <jaben.carsey@intel.com>,
"Gao, Liming" <liming.gao@intel.com>
Subject: Re: [PATCH] MdePkg/BaseLib: Fix PathRemoveLastItem to ignore consecutive '\'
Date: Tue, 16 May 2017 07:48:59 +0000 [thread overview]
Message-ID: <734D49CCEBEEF84792F5B80ED585239D5B94A668@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <1d9b206d346af8fa90fda6b3cc4404a1f66f55d5.1494604752.git.jeff.westfahl@ni.com>
Jeff,
PathRemoveLastItem() is expected to be called after PathCleanUpDirectories().
E.g.: what should we expect PathRemoveLastItem() do for "fs0:\a\b\..\"?
So PathRemoveLastItem() expects the incoming path is cleaned.
Thanks/Ray
> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Jeff Westfahl
> Sent: Saturday, May 13, 2017 12:01 AM
> To: edk2-devel@lists.01.org
> Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Ni, Ruiyu
> <ruiyu.ni@intel.com>; Carsey, Jaben <jaben.carsey@intel.com>; Gao, Liming
> <liming.gao@intel.com>
> Subject: [edk2] [PATCH] MdePkg/BaseLib: Fix PathRemoveLastItem to ignore
> consecutive '\'
>
> This patch makes PathRemoveLastItem ignore consecutive occurrences of
> the '\' path separator.
>
> Consider a path like "FS0:\ABC\DEF\\", noting the consecutive '\' path
> separator characters at the end. The expected result of
> PathRemoveLastItem on such a path is "FS0:\ABC\". However, what we get is
> "FS0:\ABC\DEF\".
>
> We can see the result of this behavior with 'ls' in the EFI shell. Go a couple of
> folders deep into a filesystem and try 'ls ..\..'. Here's an example, with a
> filesystem with folder ABC in the root, with subfolder DEF.
>
> FS0:\ABC\DEF\> ls ..
> Directory of: FS0:\ABC\
> 05/12/2017 15:46 <DIR> 8,192 .
> 05/12/2017 15:46 <DIR> 0 ..
> 05/12/2017 15:46 <DIR> 8,192 DEF
> 0 File(s) 0 bytes
> 3 Dir(s)
> FS0:\ABC\DEF\> ls ..\..
> Directory of: FS0:\ABC\
> 05/12/2017 15:46 <DIR> 8,192 .
> 05/12/2017 15:46 <DIR> 0 ..
> 05/12/2017 15:46 <DIR> 8,192 DEF
> 0 File(s) 0 bytes
> 3 Dir(s)
> fs0:\ABC\DEF\>
>
> As you can see, 'ls ..\..' lists only the parent folder. This patch resolves the
> issue so that 'ls ..\..' lists the grandparent folder.
>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Jaben Carsey <jaben.carsey@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jeff Westfahl <jeff.westfahl@ni.com>
> ---
> MdePkg/Library/BaseLib/FilePaths.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/MdePkg/Library/BaseLib/FilePaths.c
> b/MdePkg/Library/BaseLib/FilePaths.c
> index 203045c..bbaf140 100644
> --- a/MdePkg/Library/BaseLib/FilePaths.c
> +++ b/MdePkg/Library/BaseLib/FilePaths.c
> @@ -37,9 +37,7 @@ PathRemoveLastItem(
> ; Walker != NULL && *Walker != CHAR_NULL
> ; Walker++
> ){
> - if (*Walker == L'\\' && *(Walker + 1) != CHAR_NULL) {
> - LastSlash = Walker+1;
> - } else if (*Walker == L':' && *(Walker + 1) != L'\\' && *(Walker + 1) !=
> CHAR_NULL) {
> + if ((*Walker == L'\\' || *Walker == L':') && *(Walker + 1) != L'\\'
> + && *(Walker + 1) != CHAR_NULL) {
> LastSlash = Walker+1;
> }
> }
> --
> 2.7.4
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
next prev parent reply other threads:[~2017-05-16 7:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-12 16:00 [PATCH] MdePkg/BaseLib: Fix PathRemoveLastItem to ignore consecutive '\' Jeff Westfahl
2017-05-16 7:48 ` Ni, Ruiyu [this message]
2017-05-16 16:20 ` Jeff Westfahl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=734D49CCEBEEF84792F5B80ED585239D5B94A668@SHSMSX104.ccr.corp.intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox