summaryrefslogtreecommitdiffstats
path: root/misc-utils/namei.c
Commit message (Collapse)AuthorAgeFilesLines
* misc: consolidate version printing and close_stdout()Karel Zak2019-04-161-7/+6Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* nls: remove translation stringsSami Kerola2018-05-281-1/+1
| | | | | | | | | | While looking earlier commit I noticed everything but formatting was removed from a message in namei.c file. That inspired me to look if there are more strings that does not need translation project attention. This change removes at least some of them, if not all. Reference: e19cc7b65b31c57f0fe9cb73c9afad5197796f82 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* namei: provide more usable error message on lstat() errorKarel Zak2018-03-271-4/+5
| | | | | Addresses: https://github.com/karelzak/util-linux/issues/608 Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: consolidate macro style USAGE_HELP_OPTIONSRuediger Meier2017-06-291-2/+2
| | | | | | | | | changed in include/c.h and applied via sed: sed -i 's/fprintf.*\(USAGE_MAN_TAIL.*\)/printf(\1/' $(git ls-files -- "*.c") sed -i 's/print_usage_help_options\(.*\);/printf(USAGE_HELP_OPTIONS\1);/' $(git ls-files -- "*.c") Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: consolidate all --help option descriptionsRuediger Meier2017-06-271-2/+2
| | | | | | | | Now we are always using the same text also for commands which had still hardcoded descriptions or where we can't use the standard print_usage_help_options macro. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: never use usage(ERROR)Ruediger Meier2017-06-261-5/+5
| | | | | | | | | | We are using better/shorter error messages and somtimes also errtryhelp(). Here we fix all cases where the usage function took an int argument for exit_code. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: do not use plain 0 as NULL [smatch scan]Sami Kerola2017-02-201-9/+9
| | | | | | | | | | text-utils/tailf.c:69:21: warning: Using plain integer as NULL pointer Since many 'struct option' has used zero as NULL make them more readable in same go by reindenting, and using named argument requirements. Reference: https://lwn.net/Articles/93577/ Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* Use --help suggestion on invalid optionKarel Zak2016-12-191-1/+1
| | | | | | | | The current default is to print all usage() output. This is overkill in many case. Addresses: https://github.com/karelzak/util-linux/issues/338 Signed-off-by: Karel Zak <kzak@redhat.com>
* lib: define LOGIN_NAME_MAX fallbackRuediger Meier2016-02-181-4/+0Star
| | | | | | LOGIN_NAME_MAX was unused in misc-utils/namei.c since 04a5cb58. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* lib: rename strmode() and setmode()Ruediger Meier2016-02-181-1/+1
| | | | | | On BSD they are part of the standard C library. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* namei: move icache to lib/Karel Zak2015-11-271-98/+13Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* textual: grammarize and harmonize the stat error messageBenno Schulenberg2015-02-021-1/+1
| | | | | | | | | The message "stat failed %s" seems to say that stat() failed to do something, or failed to pass a test, but of course it means that the statting of something failed. So say so. Also make two very similar messages equal to this one. Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* textual: add a docstring to most of the utilitiesBenno Schulenberg2015-01-061-0/+4
| | | | | | | | | 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>
* textual: use usage() text element macrosSami Kerola2014-10-011-3/+2Star
| | | | | | | 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>
* textual: use manual tail usage() macroSami Kerola2014-10-011-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* textual: fix some typos and inconsistencies in various messagesBenno Schulenberg2014-07-231-1/+1
| | | | | | | | 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>
* namei: align missing files with rest of the print outSami Kerola2013-12-021-0/+9
| | | | | | | | | | | | | | | | | | | | | | | 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>
* textual: spell and encode the name of Arkadiusz Miśkiewicz correctlyBenno Schulenberg2013-02-061-2/+2
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* textual: use UTIL_LINUX_VERSION everywhereKarel Zak2013-01-251-2/+1Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* namei: don't care about xasprintf() return codeKarel Zak2012-12-121-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* namei: remove dead code [coverity scan]Karel Zak2012-09-071-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* translation: unify stat error messagesSami Kerola2012-07-161-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc-utils: cleanup unused strings.h includesmaximilian attems2012-05-231-1/+0Star
| | | | | | Noticed on klibc building. Signed-off-by: maximilian attems <max@stro.at>
* namei: fix relative symlinks evaluationKarel Zak2012-04-201-3/+10
| | | | | | | | | | | | | 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>
* misc-utils: verify writing to streams was successfulSami Kerola2012-04-041-0/+2
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* xalloc: use xasprintf in all filesSami Kerola2012-03-181-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* namei: more robust add_it() [coverity scan]Karel Zak2012-01-311-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* namei: cleanup usage()Karel Zak2011-08-161-16/+17
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* namei: fix to argument handlingSami Kerola2011-06-251-6/+9
| | | | | | | | | | | | | | | | 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>
* namei: use xalloc.hSami Kerola2011-06-251-20/+6Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* namei: add --version optionSami Kerola2011-06-251-1/+7
| | | | | | | Add to namei.1 man also the --help option along with the new --version. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* namei: remove unused variableKarel Zak2011-06-081-2/+1Star
| | | | | | | 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>
* lsblk: use ssize_t for readlink() return codeKarel Zak2011-03-111-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* move struct option to .rodataKarel Zak2011-03-031-1/+1
| | | | | | | It does not make sense to have writable large arrays of "struct option" on the stack. Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: provide alternatives for err, errx, warn and warnxFabian Groffen2011-02-141-1/+0Star
| | | | | | | | 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>
* rename util-linux-ng back to util-linuxKarel Zak2010-11-301-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib: [strutils] move strmode() from namei.c to strutils.cKarel Zak2010-11-241-36/+1Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc-utils: use new xmalloc() wrapperDavidlohr Bueso2010-10-211-3/+3
| | | | Signed-off-by: Davidlohr Bueso <dave@gnu.org>
* namei: parse all path arguments when an optarg path will failSami Kerola2010-10-011-11/+26
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* namei: fix memory leak in namei(1)Davidlohr Bueso2010-07-291-0/+3
| | | | Signed-off-by: Davidlohr Bueso <dave@gnu.org>
* namei: use c.hKarel Zak2009-10-161-4/+2Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* namei: better mount points detectionKarel Zak2009-10-091-3/+40
| | | | | Reported-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
* namei: gater information about / (root)Karel Zak2009-10-071-6/+8
| | | | | | | | | | | | | | | | | | | | $ 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>
* namei: fix alone symlink evaluationKarel Zak2009-10-071-3/+4
| | | | | | | | | | | | | | | | | | | $ 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>
* namei: add --vertical optionKarel Zak2009-01-271-8/+21
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* namei: don't duplicate '/' directoryKarel Zak2009-01-261-6/+9
| | | | | | | | | | | | 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>
* namei: fix buffer overflowKarel Zak2009-01-061-1/+2
| | | | | | | | | | $ ./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>
* namei: add --owners and --long optionsKarel Zak2008-11-131-7/+138
| | | | | | | | | | | | | | | 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>
* namei: new re-written versionKarel Zak2008-11-131-329/+294Star
| | | | | | | | | | | | | | 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>
* namei: non-linux support (get_current_dir_name() and PATH_MAX)Karel Zak2007-11-261-4/+15
| | | | | Co-Author: Samuel Thibault <samuel.thibault@ens-lyon.org> Signed-off-by: Karel Zak <kzak@redhat.com>