summaryrefslogtreecommitdiffstats
path: root/misc-utils/namei.c
diff options
context:
space:
mode:
authorKarel Zak2009-01-26 11:36:31 +0100
committerKarel Zak2009-01-26 11:36:31 +0100
commit922a121b6065ae8fd124a72cd0b7e8b9b890f9f6 (patch)
treea3b38f253122f1a0d28935e71e5668a0c261c119 /misc-utils/namei.c
parentionice: a little cleanup of "none" description (diff)
downloadkernel-qcow2-util-linux-922a121b6065ae8fd124a72cd0b7e8b9b890f9f6.tar.gz
kernel-qcow2-util-linux-922a121b6065ae8fd124a72cd0b7e8b9b890f9f6.tar.xz
kernel-qcow2-util-linux-922a121b6065ae8fd124a72cd0b7e8b9b890f9f6.zip
namei: don't duplicate '/' directory
sake@lelux ~ namei -l / f: / drwxr-xr-x root root / drwxr-xr-x root root The duplicate '/' directory is unexpected behavior. Reported-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'misc-utils/namei.c')
-rw-r--r--misc-utils/namei.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/misc-utils/namei.c b/misc-utils/namei.c
index c259b30f7..e2d4f7e65 100644
--- a/misc-utils/namei.c
+++ b/misc-utils/namei.c
@@ -256,12 +256,15 @@ add_namei(struct namei *parent, const char *orgpath, int start, struct namei **l
for (end = fname; fname && end; ) {
/* set end of filename */
- end = strchr(fname, '/');
- if (end)
- *end = '\0';
-
- /* create a new entry */
- nm = new_namei(nm, path, fname, level);
+ if (*fname) {
+ end = strchr(fname, '/');
+ if (end)
+ *end = '\0';
+
+ /* create a new entry */
+ nm = new_namei(nm, path, fname, level);
+ } else
+ end = NULL;
if (!first)
first = nm;
if (S_ISLNK(nm->st.st_mode))