Commit Graph

53 Commits

Author SHA1 Message Date
Benno Schulenberg 451dbcfae1 textual: add a docstring to most of the utilities
This adds a concise description of a tool to its usage text.

A first form of this patch was proposed by Steven Honeyman
(see http://www.spinics.net/lists/util-linux-ng/msg09994.html).

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-06 11:27:38 +01:00
Sami Kerola db433bf737 textual: use usage() text element macros
Translating these text elements should happen only once, which is
more likely when the text macros are used properly.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:26 +02:00
Sami Kerola a587cc5520 textual: use manual tail usage() macro
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:24 +02:00
Benno Schulenberg 09af3db48e textual: fix some typos and inconsistencies in various messages
Fixing plain typos, miswordings, inconsistent periods, some missing
angular brackets, and a proper pluralization (even when it involves
a constant, because for some languages the precise value matters).

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-07-23 08:56:00 +02:00
Sami Kerola cd80445017 namei: align missing files with rest of the print out
This change should make namei output more readable when multiple
arguments are supplied.

The old:

$ namei -l /usr/foo
f: /usr/foo
drwxr-xr-x root root /
drwxr-xr-x root root usr
foo - No such file or directory

The new:

$ namei -l /usr/foo
f: /usr/foo
drwxr-xr-x root root /
drwxr-xr-x root root usr
                     foo - No such file or directory

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-12-02 10:59:27 +01:00
Benno Schulenberg b50945d4ac textual: spell and encode the name of Arkadiusz Miśkiewicz correctly
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-02-06 11:15:02 +01:00
Karel Zak e421313dc2 textual: use UTIL_LINUX_VERSION everywhere
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-25 12:05:26 +01:00
Karel Zak 7a591a1fb5 namei: don't care about xasprintf() return code
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-12 12:12:25 +01:00
Karel Zak 38efd1e2b7 namei: remove dead code [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-07 11:39:38 +02:00
Sami Kerola add1b8afd0 translation: unify stat error messages
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-16 18:18:22 +02:00
maximilian attems adddfd37a1 misc-utils: cleanup unused strings.h includes
Noticed on klibc building.

Signed-off-by: maximilian attems <max@stro.at>
2012-05-23 10:31:12 +02:00
Karel Zak 89394013f6 namei: fix relative symlinks evaluation
Fedora 17 (/bin is symlink to /usr/bin):

	[root@intel ~]# /bin/namei /bin/namei
	f: /bin/namei
	 d /
	 l bin -> usr/bin
	usr - No such file or directory

Reported-by: Jan Stancek <jstancek@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-20 15:06:57 +02:00
Sami Kerola c05a80ca63 misc-utils: verify writing to streams was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-04-04 19:56:48 +02:00
Sami Kerola 6f312c8957 xalloc: use xasprintf in all files
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-18 14:28:05 +01:00
Karel Zak 54b6adf344 namei: more robust add_it() [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-31 14:04:03 +01:00
Karel Zak 54f0728944 namei: cleanup usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-16 12:33:56 +02:00
Sami Kerola 5a0d925569 namei: fix to argument handling
Missing pathname argument can only be checked after options are
parsed. Earlier for example 'namei -l' print nothing and was
successful.

The option parsing is changed to be less POSIXLY_CORRECT and
continue if nonoption argument is found, which allows users to
define options and arguments in the order they prefer.

Unknown short options, which earlier matched case '?' that was
help option alias, are now made to indicate failure in return
value.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-06-25 12:37:37 +02:00
Sami Kerola b977951749 namei: use xalloc.h
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-06-25 12:37:37 +02:00
Sami Kerola 64718fe7d9 namei: add --version option
Add to namei.1 man also the --help option along with the new
--version.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-06-25 12:37:04 +02:00
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