mountpoint: different exit status for errors and non-mountpoint situation
Fixes: https://github.com/karelzak/util-linux/issues/1260 Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
6b6dbcbae6
commit
e0ecd19641
|
@ -42,7 +42,17 @@ Display version information and exit.
|
|||
.BR \-h , " \-\-help"
|
||||
Display help text and exit.
|
||||
.SH EXIT STATUS
|
||||
Zero if the directory or file is a mountpoint, non-zero if not.
|
||||
.B mountpoint
|
||||
has the following exit status values:
|
||||
.TP
|
||||
.B 0
|
||||
success; the directory is a mountpoint, or device is block device on \fB\-\-devno\fR
|
||||
.TP
|
||||
.B 1
|
||||
failure; incorrect invocation, permissions or system error
|
||||
.TP
|
||||
.B 32
|
||||
failure; the directory is not a mountpoint, or device is not a block device on \fB\-\-devno\fR
|
||||
.SH ENVIRONMENT
|
||||
.IP LIBMOUNT_DEBUG=all
|
||||
enables libmount debug output.
|
||||
|
|
|
@ -40,6 +40,8 @@
|
|||
#include "closestream.h"
|
||||
#include "pathnames.h"
|
||||
|
||||
#define MOUNTPOINT_EXIT_NOMNT 32
|
||||
|
||||
struct mountpoint_control {
|
||||
char *path;
|
||||
dev_t dev;
|
||||
|
@ -201,15 +203,17 @@ int main(int argc, char **argv)
|
|||
return EXIT_FAILURE;
|
||||
}
|
||||
if (ctl.dev_devno)
|
||||
return print_devno(&ctl) ? EXIT_FAILURE : EXIT_SUCCESS;
|
||||
return print_devno(&ctl) ? MOUNTPOINT_EXIT_NOMNT : EXIT_SUCCESS;
|
||||
|
||||
if ((ctl.nofollow && S_ISLNK(ctl.st.st_mode)) || dir_to_device(&ctl)) {
|
||||
if (!ctl.quiet)
|
||||
printf(_("%s is not a mountpoint\n"), ctl.path);
|
||||
return EXIT_FAILURE;
|
||||
return MOUNTPOINT_EXIT_NOMNT;
|
||||
}
|
||||
if (ctl.fs_devno)
|
||||
printf("%u:%u\n", major(ctl.dev), minor(ctl.dev));
|
||||
else if (!ctl.quiet)
|
||||
printf(_("%s is a mountpoint\n"), ctl.path);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue