]> err.no Git - util-linux/commitdiff
namei: gater information about / (root)
authorKarel Zak <kzak@redhat.com>
Tue, 6 Oct 2009 23:37:57 +0000 (01:37 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 6 Oct 2009 23:37:57 +0000 (01:37 +0200)
$ ll -d /foo
drwxr-xr-x 2 kzak kzak 4096 2009-10-07 01:23 /foo

old version:

$ namei -l /foo
f: /foo
Segmentation fault

new version:

$ namei -l /foo
f: /foo
drwxr-xr-x root root /
drwxr-xr-x kzak kzak foo

Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/namei.c

index ebd82fdb8a944018782c5e63910ab6800ae1b637..94a3c25914679e8adaf85e9eed58e546c4507555 100644 (file)
@@ -228,6 +228,14 @@ new_namei(struct namei *parent, const char *path, const char *fname, int lev)
                err(EXIT_FAILURE, _("out of memory?"));
        if (lstat(path, &nm->st) == -1)
                err(EXIT_FAILURE, _("could not stat '%s'"), path);
+
+       if (S_ISLNK(nm->st.st_mode))
+               readlink_to_namei(nm, path);
+       if (flags & NAMEI_OWNERS) {
+               add_uid(nm->st.st_uid);
+               add_gid(nm->st.st_gid);
+       }
+
        return nm;
 }
 
@@ -269,12 +277,6 @@ add_namei(struct namei *parent, const char *orgpath, int start, struct namei **l
                        end = NULL;
                if (!first)
                        first = nm;
-               if (S_ISLNK(nm->st.st_mode))
-                       readlink_to_namei(nm, path);
-               if (flags & NAMEI_OWNERS) {
-                       add_uid(nm->st.st_uid);
-                       add_gid(nm->st.st_gid);
-               }
                /* set begin of the next filename */
                if (end) {
                        *end++ = '/';