From: Karel Zak Date: Tue, 6 Oct 2009 23:37:57 +0000 (+0200) Subject: namei: gater information about / (root) X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a439d194fb62a78212c917c088f32b556f3842d3;p=util-linux namei: gater information about / (root) $ 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 --- diff --git a/misc-utils/namei.c b/misc-utils/namei.c index ebd82fdb..94a3c259 100644 --- a/misc-utils/namei.c +++ b/misc-utils/namei.c @@ -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++ = '/';