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

It's pretty weird to mount a directory at a device
- Alejandro
And a implemented 'read-only' mount option is even nicer - as well
as a remount possibility in rescue conditions ;-)
- Rene Rebe <rene@rocklinux.org>
--- ./src/domount.c 1998-09-25 14:07:09.000000000 +0200
+++ ./src/domount.c 2003-12-24 16:16:17.000000000 +0100
@@ -2,27 +2,34 @@
int domount (Stringstack s)
{
- register int
- opt;
- register char
- *type = NULL;
+ int opt;
+ char *type = NULL;
+ int mount_opt = 0;
- while ( (opt = getopt (s.nstr, s.str, "t:h")) != -1 )
+ while ( (opt = getopt (s.nstr, s.str, "t:hrR")) != -1 )
switch (opt)
{
case 't':
if (! (type = optarg))
error ("missing type after \"-t\"");
break;
+ case 'r':
+ mount_opt |= MS_RDONLY;
+ break;
+ case 'R':
+ mount_opt |= MS_REMOUNT;
+ break;
default:
case 'h':
error ("Bad commandline.\n"
"Usage: %s\n"
- " or: %s [-t type] [-r] device directory\n"
+ " or: %s [-t type] [-r] [-R] device directory\n"
"Where:\n"
" -t type : mount as type, e.g. ext2, minix\n"
" device : device to mount\n"
" directory : mount point\n"
+ " -r : mount read-only\n"
+ " -R : remount\n"
, progname, progname);
}
@@ -49,9 +56,9 @@
if (! type)
error ("need \"-t type\" specification");
- if (mount (s.str [optind], s.str [optind + 1], type, 1, 0))
- error ("problem mounting \"%s\" on \"%s\" (type \"%s\")",
- s.str [optind + 1], s.str [optind], type);
+ if (mount (s.str [optind], s.str [optind + 1], type, mount_opt, 0))
+ error ("problem mounting \"%s\" on \"%s\" (type \"%s\", opts \"%x\")",
+ s.str [optind], s.str [optind + 1], type, mount_opt);
if (! (mtab = fopen (MTAB, "a")) )
return (warning ("\"%s\" not updated", MTAB));