blob: e1ec41f1b8117383aa6ec30a9788095f19fb36ad [file] [log] [blame]
Denis Vlasenkode7684a2008-02-18 21:08:49 +00001/* vi: set sw=4 ts=4: */
2/*
3 * Support functions for mounting devices by label/uuid
4 *
5 * Copyright (C) 2006 by Jason Schoon <floydpink@gmail.com>
6 * Some portions cribbed from e2fsprogs, util-linux, dosfstools
7 *
Denys Vlasenko0ef64bd2010-08-16 20:14:46 +02008 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
Denis Vlasenkode7684a2008-02-18 21:08:49 +00009 */
10
11#include "libbb.h"
12#include "volume_id.h"
13
14int findfs_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
Natanael Copa9aff2992009-09-20 04:28:22 +020015int findfs_main(int argc UNUSED_PARAM, char **argv)
Denis Vlasenkode7684a2008-02-18 21:08:49 +000016{
Natanael Copa9aff2992009-09-20 04:28:22 +020017 char *dev = *++argv;
Denis Vlasenkode7684a2008-02-18 21:08:49 +000018
Natanael Copa9aff2992009-09-20 04:28:22 +020019 if (!dev)
Denis Vlasenko53ce7f02008-02-19 11:29:46 +000020 bb_show_usage();
Denis Vlasenkode7684a2008-02-18 21:08:49 +000021
Natanael Copa9aff2992009-09-20 04:28:22 +020022 if (strncmp(dev, "/dev/", 5) == 0) {
23 /* Just pass any /dev/xxx name right through.
24 * This might aid in some scripts being able
25 * to call this unconditionally */
26 dev = NULL;
27 } else {
28 /* Otherwise, handle LABEL=xxx and UUID=xxx,
29 * fail on anything else */
30 if (!resolve_mount_spec(argv))
31 bb_show_usage();
32 }
Denis Vlasenko53ce7f02008-02-19 11:29:46 +000033
Natanael Copa9aff2992009-09-20 04:28:22 +020034 if (*argv != dev) {
35 puts(*argv);
Denis Vlasenkode7684a2008-02-18 21:08:49 +000036 return 0;
37 }
38 return 1;
Denis Vlasenko53ce7f02008-02-19 11:29:46 +000039}