*.sh
bin/blkid
+bin/findfs
test_*
AM_LDFLAGS += -L$(top_builddir)/libs/blkid/src -lblkid
AM_CPPFLAGS += -I$(top_builddir)/libs/blkid/src/
-sbin_PROGRAMS = blkid
-dist_man_MANS = blkid.8
+sbin_PROGRAMS = blkid findfs
+dist_man_MANS = blkid.8 findfs.8
-shell_in_files = blkid.sh.in
+shell_in_files = blkid.sh.in findfs.sh
noinst_SCRIPTS = $(shell_in_files:.sh.in=.sh)
blkid_SOURCES = blkid.c
+findfs_SOURCES = findfs.c
CLEANFILES = $(noinst_SCRIPTS)
--- /dev/null
+.\" -*- nroff -*-
+.\" 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" "Linux" "MAINTENANCE COMMANDS"
+.SH NAME
+findfs \- Find a filesystem by label or UUID
+.SH SYNOPSIS
+.B findfs
+.BI LABEL= label
+.sp
+.B findfs
+.BI UUID= uuid
+.SH DESCRIPTION
+.B findfs
+will search the disks in the system looking for a filesystem which has
+a label matching
+.I label
+or a UUID equal to
+.IR uuid .
+If the filesystem is found, the device name for the filesystem will
+be printed on stdout.
+.PP
+.SH AUTHOR
+.B findfs
+was originally written by Theodore Ts'o (tytso@mit.edu) and re-written for
+util-linux-ng package by Karel Zak (kzak@redhat.com).
+.SH AVAILABILITY
+.B findfs
+The blkid command is part of the util-linux-ng package and is available from
+ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/.
+.SH SEE ALSO
+.BR blkid (8)
+.BR fsck (8)
+
--- /dev/null
+/*
+ * 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_spec(tk, vl, NULL);
+ if (!dev)
+ errx(EXIT_FAILURE, _("unable to resolve '%s'"), argv[1]);
+
+ puts(dev);
+ exit(EXIT_SUCCESS);
+}
+
--- /dev/null
+#!/bin/bash
+
+# libtool? Don't ask!
+
+BLKIDDIR=@SRCDIR@/libs/blkid
+BINARY=$BLKIDDIR/bin/findfs
+LD_LIBRARY_PATH=$BLKIDDIR/src/
+
+export LD_LIBRARY_PATH
+exec $BINARY $@