namei.c: In function ‘print_namei’:
namei.c:368:16: warning: variable ‘prev’ set but not used [-Wunused-but-set-variable]
Signed-off-by: Karel Zak <kzak@redhat.com>
Solaris lacks err, errx, warn and warnx. This also means the err.h header
doesn't exist. Removed err.h include from all files, and included err.h from
c.h instead if it exists, otherwise alternatives are provided.
Signed-off-by: Fabian Groffen <grobian@gentoo.org>
Old implementation of namei listed path all the way to non-existing
file or directory, something like:
f: /usr/bin/nxdir/file
d /
d usr
d bin
? nxdir - No such file or directory (2)
whiles the current implementation prints:
namei: failed to stat: /usr/bin/nxdir/file: No such file or directory
The new output it's not helpful. I am especially interested see where
the path is broken when a path is symlink to other path with symlink,
and few more like that, and something somewhere is broken.
[kzak@redhat.com: - coding style changes]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
$ mkdir aaa
$ ln -s aaa mylink
old version:
$ namei mylink
namei: could not stat 'mylink/aaa': No such file or directory
new version:
$ namei mylink
f: mylink
l mylink -> aaa
d aaa
Signed-off-by: Karel Zak <kzak@redhat.com>
Added file owner and group name printing support. The groupnames and
usernames are cached to avoid an extra overhead. This implementation
does not use fixed width of user/group name columns.
$ namei -l /var/www/cgi-bin
f: /var/www/cgi-bin
drwxr-xr-x root root /
drwxr-xr-x root root var
drwxr-xr-x root root www
drwxr-xr-x root root cgi-bin
Signed-off-by: Karel Zak <kzak@redhat.com>
This new version:
* not based on chdir()
* implemented without recursion (does not depend on stack size)
* list of directories is stored in allocated memory (the code is
extendable with new functionality (e.g. show usernames, groupnames,
selunux contexts, ...).
* supports long command line options
* adds a new command line option:
-n, --nosymlinks don't follow symlinks
Signed-off-by: Karel Zak <kzak@redhat.com>
Don't follow the path if a component is not directory. It doesn't make sense
to support something like:
$ touch a b
$ namei a/b <-- where "a" is not directory
The support for infinite loop of symbolic links is a strange wish only. The
stack size is very limited. Try:
$ ln -s x
$ namei x/x
[Migration note: severity="low"]
Signed-off-by: Karel Zak <kzak@redhat.com>