btrfs-progs: Do not add extra slash if given path end with it
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> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
5f53c23e76
commit
a5ef445f05
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue