All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs-progs: Do not add extra slash if given path end with it
@ 2018-03-29  9:11 Gu Jinxiang
  2018-04-09 14:39 ` David Sterba
  0 siblings, 1 reply; 2+ messages in thread
From: Gu Jinxiang @ 2018-03-29  9:11 UTC (permalink / raw)
  To: linux-btrfs

When use a given path end with a slash like below,
the output of path will have double slash.

Do not add extra slash if there is already one in the given
path.

$ btrfs filesystem du ./test/
output:
Total   Exclusive  Set shared  Filename
0.00B       0.00B           -  /home/gujx/device/tmp/test//foo

Signed-off-by: Gu Jinxiang <gujx@cn.fujitsu.com>
---
 cmds-fi-du.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmds-fi-du.c b/cmds-fi-du.c
index 8a44665c..74f57320 100644
--- a/cmds-fi-du.c
+++ b/cmds-fi-du.c
@@ -449,7 +449,7 @@ static int du_add_file(const char *filename, int dirfd,
 	}
 
 	pathtmp = pathp;
-	if (pathp == path)
+	if (pathp == path || *(pathp-1) == '/')
 		ret = sprintf(pathp, "%s", filename);
 	else
 		ret = sprintf(pathp, "/%s", filename);
-- 
2.14.3




^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] btrfs-progs: Do not add extra slash if given path end with it
  2018-03-29  9:11 [PATCH] btrfs-progs: Do not add extra slash if given path end with it Gu Jinxiang
@ 2018-04-09 14:39 ` David Sterba
  0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2018-04-09 14:39 UTC (permalink / raw)
  To: Gu Jinxiang; +Cc: linux-btrfs

On Thu, Mar 29, 2018 at 05:11:19PM +0800, Gu Jinxiang wrote:
> When use a given path end with a slash like below,
> the output of path will have double slash.
> 
> Do not add extra slash if there is already one in the given
> path.
> 
> $ btrfs filesystem du ./test/
> output:
> Total   Exclusive  Set shared  Filename
> 0.00B       0.00B           -  /home/gujx/device/tmp/test//foo
> 
> Signed-off-by: Gu Jinxiang <gujx@cn.fujitsu.com>

Applied, thanks.

I was wondering if we should remove all trailing slashes, but I think
that the chance of that happening often is too low. The tab completion
will append only a single tab and that's about the case I'd care.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-04-09 14:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-29  9:11 [PATCH] btrfs-progs: Do not add extra slash if given path end with it Gu Jinxiang
2018-04-09 14:39 ` David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.