diff options
author | Bernhard Voelker <mail@bernhard-voelker.de> | 2012-08-14 09:22:13 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2012-08-14 11:34:54 +0200 |
commit | 46afefaaa8ea95b5eb63a62792774cd18738234a (patch) | |
tree | 4d76b669c082df105808d05af462652923d70258 /src | |
parent | a07dfa9064bf80b4ceea7048c3104495797a6668 (diff) | |
download | coreutils-46afefaaa8ea95b5eb63a62792774cd18738234a.tar.xz |
df: fail when the mount list is required but cannot be read
* src/df.c (main): Add conditions to fail when the mount list cannot
be read: this includes the cases when a file name argument is given
and any of -a, -l, -t or -x is used.
* doc/coreutils.texi: Document the additional error conditions.
* tests/df/no-mtab-status: Add a new test.
* tests/Makefile.am: Reference the new test.
* NEWS: Mention the fix.
Diffstat (limited to 'src')
-rw-r--r-- | src/df.c | 17 |
1 files changed, 13 insertions, 4 deletions
@@ -1100,10 +1100,19 @@ main (int argc, char **argv) if (mount_list == NULL) { /* Couldn't read the table of mounted file systems. - Fail if df was invoked with no file name arguments; - Otherwise, merely give a warning and proceed. */ - int status = (optind < argc ? 0 : EXIT_FAILURE); - const char *warning = (optind < argc ? _("Warning: ") : ""); + Fail if df was invoked with no file name arguments, + or when either of -a, -l, -t or -x is used with file name + arguments. Otherwise, merely give a warning and proceed. */ + int status = 0; + if ( ! (optind < argc) + || (show_all_fs + || show_local_fs + || fs_select_list != NULL + || fs_exclude_list != NULL)) + { + status = EXIT_FAILURE; + } + const char *warning = (status == 0 ? _("Warning: ") : ""); error (status, errno, "%s%s", warning, _("cannot read table of mounted file systems")); } |