3
0

findfs.c 906 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /* 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. *
  8. * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
  9. */
  10. #include "libbb.h"
  11. #include "volume_id.h"
  12. int findfs_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
  13. int findfs_main(int argc UNUSED_PARAM, char **argv)
  14. {
  15. char *dev = *++argv;
  16. if (!dev)
  17. bb_show_usage();
  18. if (strncmp(dev, "/dev/", 5) == 0) {
  19. /* Just pass any /dev/xxx name right through.
  20. * This might aid in some scripts being able
  21. * to call this unconditionally */
  22. dev = NULL;
  23. } else {
  24. /* Otherwise, handle LABEL=xxx and UUID=xxx,
  25. * fail on anything else */
  26. if (!resolve_mount_spec(argv))
  27. bb_show_usage();
  28. }
  29. if (*argv != dev) {
  30. puts(*argv);
  31. return 0;
  32. }
  33. return 1;
  34. }