findfs.c 932 B

1234567891011121314151617181920212223242526272829303132333435363738
  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, char **argv)
  14. {
  15. char *tmp = NULL;
  16. if (argc != 2)
  17. bb_show_usage();
  18. if (!strncmp(argv[1], "LABEL=", 6))
  19. tmp = get_devname_from_label(argv[1] + 6);
  20. else if (!strncmp(argv[1], "UUID=", 5))
  21. tmp = get_devname_from_uuid(argv[1] + 5);
  22. else if (!strncmp(argv[1], "/dev/", 5)) {
  23. /* Just pass a device name right through. This might aid in some scripts
  24. being able to call this unconditionally */
  25. tmp = argv[1];
  26. } else
  27. bb_show_usage();
  28. if (tmp) {
  29. puts(tmp);
  30. return 0;
  31. }
  32. return 1;
  33. }