2 * Copyright (C) 2009 Karel Zak <kzak@redhat.com>
4 * This file may be redistributed under the terms of the GNU Public
16 #include "closestream.h"
19 /* Exit codes used by findfs. */
20 #define FINDFS_SUCCESS 0 /* no errors */
21 #define FINDFS_NOT_FOUND 1 /* label or uuid cannot be found */
22 #define FINDFS_USAGE_ERROR 2 /* user did something unexpected */
24 static void __attribute__((__noreturn__
)) usage(void)
27 fputs(USAGE_HEADER
, out
);
28 fprintf(out
, _(" %s [options] {LABEL,UUID,PARTUUID,PARTLABEL}=<value>\n"),
29 program_invocation_short_name
);
31 fputs(USAGE_SEPARATOR
, out
);
32 fputs(_("Find a filesystem by label or UUID.\n"), out
);
34 fputs(USAGE_OPTIONS
, out
);
35 printf(USAGE_HELP_OPTIONS(16));
36 printf(USAGE_MAN_TAIL("findfs(8)"));
40 int main(int argc
, char **argv
)
44 static const struct option longopts
[] = {
45 {"version", no_argument
, NULL
, 'V'},
46 {"help", no_argument
, NULL
, 'h'},
50 setlocale(LC_ALL
, "");
51 bindtextdomain(PACKAGE
, LOCALEDIR
);
56 /* we return '2' for backward compatibility
57 * with version from e2fsprogs */
58 warnx(_("bad usage"));
59 errtryhelp(FINDFS_USAGE_ERROR
);
62 while ((c
= getopt_long(argc
, argv
, "Vh", longopts
, NULL
)) != -1)
65 printf(UTIL_LINUX_VERSION
);
66 return FINDFS_SUCCESS
;
70 errtryhelp(FINDFS_USAGE_ERROR
);
73 dev
= blkid_evaluate_tag(argv
[1], NULL
, NULL
);
75 errx(FINDFS_NOT_FOUND
, _("unable to resolve '%s'"), argv
[1]);
78 return FINDFS_SUCCESS
;