mirror of the now-defunct rocklinux.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.9 KiB

  1. It's pretty weird to mount a directory at a device
  2. - Alejandro
  3. And a implemented 'read-only' mount option is even nicer - as well
  4. as a remount possibility in rescue conditions ;-)
  5. - Rene Rebe <rene@rocklinux.org>
  6. --- ./src/domount.c 1998-09-25 14:07:09.000000000 +0200
  7. +++ ./src/domount.c 2003-12-24 16:16:17.000000000 +0100
  8. @@ -2,27 +2,34 @@
  9. int domount (Stringstack s)
  10. {
  11. - register int
  12. - opt;
  13. - register char
  14. - *type = NULL;
  15. + int opt;
  16. + char *type = NULL;
  17. + int mount_opt = 0;
  18. - while ( (opt = getopt (s.nstr, s.str, "t:h")) != -1 )
  19. + while ( (opt = getopt (s.nstr, s.str, "t:hrR")) != -1 )
  20. switch (opt)
  21. {
  22. case 't':
  23. if (! (type = optarg))
  24. error ("missing type after \"-t\"");
  25. break;
  26. + case 'r':
  27. + mount_opt |= MS_RDONLY;
  28. + break;
  29. + case 'R':
  30. + mount_opt |= MS_REMOUNT;
  31. + break;
  32. default:
  33. case 'h':
  34. error ("Bad commandline.\n"
  35. "Usage: %s\n"
  36. - " or: %s [-t type] [-r] device directory\n"
  37. + " or: %s [-t type] [-r] [-R] device directory\n"
  38. "Where:\n"
  39. " -t type : mount as type, e.g. ext2, minix\n"
  40. " device : device to mount\n"
  41. " directory : mount point\n"
  42. + " -r : mount read-only\n"
  43. + " -R : remount\n"
  44. , progname, progname);
  45. }
  46. @@ -49,9 +56,9 @@
  47. if (! type)
  48. error ("need \"-t type\" specification");
  49. - if (mount (s.str [optind], s.str [optind + 1], type, 1, 0))
  50. - error ("problem mounting \"%s\" on \"%s\" (type \"%s\")",
  51. - s.str [optind + 1], s.str [optind], type);
  52. + if (mount (s.str [optind], s.str [optind + 1], type, mount_opt, 0))
  53. + error ("problem mounting \"%s\" on \"%s\" (type \"%s\", opts \"%x\")",
  54. + s.str [optind], s.str [optind + 1], type, mount_opt);
  55. if (! (mtab = fopen (MTAB, "a")) )
  56. return (warning ("\"%s\" not updated", MTAB));