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 <kzak@redhat.com>
This commit is contained in:
Karel Zak 2009-10-07 01:37:57 +02:00
parent d1dca71078
commit a439d194fb
1 changed files with 8 additions and 6 deletions

View 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++ = '/';