]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
findfs: use symbolic exit values, and tell about them in manual
authorSami Kerola <kerolasa@iki.fi>
Sun, 9 Mar 2014 20:30:14 +0000 (15:30 -0500)
committerKarel Zak <kzak@redhat.com>
Wed, 26 Mar 2014 11:17:36 +0000 (12:17 +0100)
[[kzak@redhat.com: - move return codes to findfs.c]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/findfs.8
misc-utils/findfs.c

index 8a6bca1d3229e5a752aa427d6f78fcf94182f29f..1469df2dc80eb02cb0990ce50f5af4f832a7c5b9 100644 (file)
@@ -2,7 +2,7 @@
 .\" Copyright 1993, 1994, 1995 by Theodore Ts'o.  All Rights Reserved.
 .\" This file may be copied under the terms of the GNU Public License.
 .\"
-.TH FINDFS 8 "February 2009" "util-linux" "System Administration"
+.TH FINDFS 8 "March 2014" "util-linux" "System Administration"
 .SH NAME
 findfs \- find a filesystem by label or UUID
 .SH SYNOPSIS
@@ -21,10 +21,30 @@ or a UUID equal to
 If the filesystem is found, the device name for the filesystem will
 be printed on stdout.
 .PP
+.SH "EXIT STATUS"
+.RS
+.PD 0
+.TP
+.B 0
+success
+.TP
+.B 1
+label or uuid cannot be found
+.TP
+.B 2
+usage error, wrong number of arguments or unknown option
+.PD
+.RE
 .SH AUTHOR
 .B findfs
-was originally written by Theodore Ts'o (tytso@mit.edu) and re-written for
-the util-linux package by Karel Zak (kzak@redhat.com).
+was originally written by
+.MT tytso@mit.edu
+Theodore Ts'o
+.ME
+and re-written for the util-linux package by
+.MT kzak@redhat.com
+Karel Zak
+.ME .
 .SH ENVIRONMENT
 .IP LIBBLKID_DEBUG=0xffff
 enables debug output.
@@ -33,4 +53,6 @@ enables debug output.
 .BR fsck (8)
 .SH AVAILABILITY
 The findfs command is part of the util-linux package and is available from
-ftp://ftp.kernel.org/pub/linux/utils/util-linux/.
+.UR ftp://\:ftp.kernel.org\:/pub\:/linux\:/utils\:/util-linux/
+Linux Kernel Archive
+.UE .
index bc4a843131db6540eb4aaf59da9ccb9823411a58..23d121b0bd2245b247b3ea1fc1341d9a9ae99d09 100644 (file)
 #include "nls.h"
 #include "closestream.h"
 #include "c.h"
+#include "exitcodes.h"
+
+/* Exit codes used by findfs. */
+#define FINDFS_SUCCESS         0       /* no errors */
+#define FINDFS_NOT_FOUND       1       /* label or uuid cannot be found */
+#define FINDFS_USAGE_ERROR     2       /* user did something unexpected */
 
 static void __attribute__((__noreturn__)) usage(int rc)
 {
@@ -41,7 +47,7 @@ int main(int argc, char **argv)
        if (argc != 2)
                /* we return '2' for backward compatibility
                 * with version from e2fsprogs */
-               usage(2);
+               usage(FINDFS_USAGE_ERROR);
 
        if (!strncmp(argv[1], "LABEL=", 6)) {
                tk = "LABEL";
@@ -52,18 +58,18 @@ int main(int argc, char **argv)
        } else if (strcmp(argv[1], "-V") == 0 ||
                   strcmp(argv[1], "--version") == 0) {
                printf(UTIL_LINUX_VERSION);
-               return EXIT_SUCCESS;
+               return FINDFS_SUCCESS;
        } else if (strcmp(argv[1], "-h") == 0 ||
                   strcmp(argv[1], "--help") == 0) {
-               usage(EXIT_SUCCESS);
+               usage(FINDFS_SUCCESS);
        } else
-               usage(2);
+               usage(FINDFS_USAGE_ERROR);
 
        dev = blkid_evaluate_tag(tk, vl, NULL);
        if (!dev)
-               errx(EXIT_FAILURE, _("unable to resolve '%s'"), argv[1]);
+               errx(FINDFS_NOT_FOUND, _("unable to resolve '%s'"), argv[1]);
 
        puts(dev);
-       exit(EXIT_SUCCESS);
+       return FINDFS_SUCCESS;
 }