unmount.c 943 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #include <u.h>
  10. #include <libc.h>
  11. void
  12. main(int argc, char *argv[])
  13. {
  14. int r;
  15. char *mnted, *mtpt;
  16. argv0 = argv[0];
  17. switch (argc) {
  18. case 2:
  19. mnted = nil;
  20. mtpt = argv[1];
  21. break;
  22. case 3:
  23. mnted = argv[1];
  24. mtpt = argv[2];
  25. break;
  26. default:
  27. SET(mnted); SET(mtpt);
  28. fprint(2, "usage: unmount mountpoint\n");
  29. fprint(2, " unmount mounted mountpoint\n");
  30. exits("usage");
  31. }
  32. /* unmount takes arguments in the same order as mount */
  33. r = unmount(mnted, mtpt);
  34. if(r < 0)
  35. sysfatal("%s: %r", mtpt);
  36. exits(0);
  37. }