From a439d194fb62a78212c917c088f32b556f3842d3 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Wed, 7 Oct 2009 01:37:57 +0200 Subject: [PATCH] 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 --- misc-utils/namei.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) 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++ = '/'; -- 2.39.5