summaryrefslogtreecommitdiff
path: root/misc-utils/findfs.c
diff options
context:
space:
mode:
authorLaMont Jones <lamont@debian.org>2009-07-21 15:45:04 -0600
committerLaMont Jones <lamont@debian.org>2009-07-21 15:45:04 -0600
commit7a22bb9abcb56d1010cefd204709e3888f95f735 (patch)
tree5c38b4485f79ee8f6a9d5f9537e973f1f663f027 /misc-utils/findfs.c
parent4e13a18f57a5b427c559f3b466b9655db14d28f8 (diff)
parent741064af10ec81635d708e9fb8373f96341246eb (diff)
downloadutil-linux-old-7a22bb9abcb56d1010cefd204709e3888f95f735.tar.gz
Merge commit 'origin/master'
Conflicts: AUTHORS NEWS config/include-Makefile.am configure.ac mount/lomount.c po/POTFILES.in po/ca.po po/cs.po po/da.po po/de.po po/es.po po/et.po po/eu.po po/fi.po po/fr.po po/hu.po po/id.po po/it.po po/ja.po po/nl.po po/pl.po po/pt_BR.po po/ru.po po/sl.po po/sv.po po/tr.po po/uk.po po/util-linux-ng.pot po/vi.po po/zh_CN.po
Diffstat (limited to 'misc-utils/findfs.c')
-rw-r--r--misc-utils/findfs.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/misc-utils/findfs.c b/misc-utils/findfs.c
new file mode 100644
index 00000000..18608b47
--- /dev/null
+++ b/misc-utils/findfs.c
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2009 Karel Zak <kzak@redhat.com>
+ *
+ * This file may be redistributed under the terms of the GNU Public
+ * License.
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <err.h>
+
+#include <blkid.h>
+
+#include "nls.h"
+
+static void __attribute__((__noreturn__)) usage(int rc)
+{
+ const char *p = program_invocation_short_name;
+
+ if (!p)
+ p = "findfs";
+
+ fprintf(stderr, _("Usage: %s LABEL=<label>|UUID=<uuid>\n"), p);
+ exit(rc);
+}
+
+int main(int argc, char **argv)
+{
+ char *dev, *tk, *vl;
+
+ setlocale(LC_ALL, "");
+ bindtextdomain(PACKAGE, LOCALEDIR);
+ textdomain(PACKAGE);
+
+ if (argc != 2)
+ /* we return '2' for backward compatibility
+ * with version from e2fsprogs */
+ usage(2);
+
+ if (!strncmp(argv[1], "LABEL=", 6)) {
+ tk = "LABEL";
+ vl = argv[1] + 6;
+ } else if (!strncmp(argv[1], "UUID=", 5)) {
+ tk = "UUID";
+ vl = argv[1] + 5;
+ } else if (!strcmp(argv[1], "-h") == 0 ||
+ !strcmp(argv[1], "--help") == 0) {
+ usage(EXIT_SUCCESS);
+ } else
+ usage(2);
+
+ dev = blkid_evaluate_tag(tk, vl, NULL);
+ if (!dev)
+ errx(EXIT_FAILURE, _("unable to resolve '%s'"), argv[1]);
+
+ puts(dev);
+ exit(EXIT_SUCCESS);
+}
+