Commit Graph

34 Commits

Author SHA1 Message Date
Karel Zak 8fec558bc3 namei: remove unused variable
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>
2011-06-08 12:18:49 +02:00
Karel Zak eb9a65bb54 lsblk: use ssize_t for readlink() return code
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-03-11 10:49:08 +01:00
Karel Zak 6c7d5ae9a2 move struct option to .rodata
It does not make sense to have writable large arrays of "struct
option" on the stack.

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-03-03 15:00:30 +01:00
Fabian Groffen eb76ca98b0 build-sys: provide alternatives for err, errx, warn and warnx
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>
2011-02-14 17:45:24 +01:00
Karel Zak 601d12fb10 rename util-linux-ng back to util-linux
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-11-30 11:41:59 +01:00
Karel Zak ce877f2d16 lib: [strutils] move strmode() from namei.c to strutils.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-11-24 17:08:32 +01:00
Davidlohr Bueso 87f3feac71 misc-utils: use new xmalloc() wrapper
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2010-10-21 10:31:50 +02:00
Sami Kerola c49e31f4ee namei: parse all path arguments when an optarg path will fail
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>
2010-10-01 00:36:45 +02:00
Davidlohr Bueso bf13602c24 namei: fix memory leak in namei(1)
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2010-07-29 17:50:46 +02:00
Karel Zak fd03d92da8 namei: use c.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-10-16 01:44:33 +02:00
Karel Zak c21e7023ca namei: better mount points detection
Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-10-09 16:43:35 +02:00
Karel Zak a439d194fb 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>
2009-10-07 01:37:57 +02:00
Karel Zak d1dca71078 namei: fix alone symlink evaluation
$ 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>
2009-10-07 01:34:36 +02:00
Karel Zak c3ecdb3ea4 namei: add --vertical option
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-01-27 14:48:32 +01:00
Karel Zak 922a121b60 namei: don't duplicate '/' directory
sake@lelux ~ namei -l /
f: /
 drwxr-xr-x root root /
 drwxr-xr-x root root

The duplicate '/' directory is unexpected behavior.

Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-01-26 11:36:31 +01:00
Karel Zak f7ed29a7b6 namei: fix buffer overflow
$ ./namei  /usr/bin/java
 *** glibc detected *** ./namei: free(): invalid next size (fast): 0x00000000018e5070 ***
 [...]
 Aborted

Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-01-06 14:26:12 +01:00
Karel Zak 4cfcf09b33 namei: add --owners and --long options
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>
2008-11-13 23:25:59 +01:00
Karel Zak c84a633a92 namei: new re-written version
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>
2008-11-13 23:25:46 +01:00
Karel Zak e27a08abb7 namei: non-linux support (get_current_dir_name() and PATH_MAX)
Co-Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2007-11-26 15:00:16 +01:00
Karel Zak db8a3e23c7 namei: cleanup tailing white-spaces
Signed-off-by: Karel Zak <kzak@redhat.com>
2007-09-20 00:24:02 +02:00
Li Zefan f062c8a69a namei: add to identify FIFO (named pipe) and update manpage
namei can't identify FIFO, and it will complain that it's an unknown type.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
2007-09-19 23:14:04 +02:00
Karel Zak d8ef4c19ab namei: fix logic and infinite loop of symlinks
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>
2007-01-31 16:43:18 +01:00
Karel Zak 2cccd0ff2b Imported from util-linux-2.12d tarball. 2006-12-07 00:26:18 +01:00
Karel Zak ffc4374869 Imported from util-linux-2.11o tarball. 2006-12-07 00:25:53 +01:00
Karel Zak e8f2641919 Imported from util-linux-2.11m tarball. 2006-12-07 00:25:49 +01:00
Karel Zak c07ebfa1e0 Imported from util-linux-2.11b tarball. 2006-12-07 00:25:46 +01:00
Karel Zak 66ee8158b6 Imported from util-linux-2.10s tarball. 2006-12-07 00:25:44 +01:00
Karel Zak 22853e4a82 Imported from util-linux-2.10m tarball. 2006-12-07 00:25:43 +01:00
Karel Zak eb63b9b8f4 Imported from util-linux-2.10f tarball. 2006-12-07 00:25:41 +01:00
Karel Zak 7eda085c41 Imported from util-linux-2.9v tarball. 2006-12-07 00:25:39 +01:00
Karel Zak 2b6fc908bc Imported from util-linux-2.8 tarball. 2006-12-07 00:25:35 +01:00
Karel Zak fd6b7a7ffc Imported from util-linux-2.7.1 tarball. 2006-12-07 00:25:34 +01:00
Karel Zak 726f69e29c Imported from util-linux-2.5 tarball. 2006-12-07 00:25:33 +01:00
Karel Zak 6dbe3af945 Imported from util-linux-2.2 tarball. 2006-12-07 00:25:32 +01:00