Don't write to /etc/mtab in newroot, may be an issue on read-only filesystems

This commit is contained in:
Erik van der Kouwe 2010-08-03 13:57:58 +00:00
parent 256c37f7fa
commit 4989de6acc
3 changed files with 8 additions and 4 deletions

View file

@ -26,12 +26,13 @@ int main(argc, argv)
int argc;
char *argv[];
{
int i, n, v = 0, mountflags;
int i, n, v = 0, mountflags, write_mtab;
char **ap, *vs, *opt, *err, *type, *args, *device;
char special[PATH_MAX+1], mounted_on[PATH_MAX+1], version[10], rw_flag[10];
if (argc == 1) list(); /* just list /etc/mtab */
mountflags = 0;
write_mtab = 1;
type = NULL;
args = NULL;
ap = argv+1;
@ -44,6 +45,7 @@ char *argv[];
type = argv[i];
break;
case 'i': mountflags |= MS_REUSE; break;
case 'n': write_mtab = 0; break;
case 'o': if (++i == argc) usage();
args = argv[i];
break;
@ -84,6 +86,7 @@ char *argv[];
argv[1], mountflags & MS_RDONLY ? "only" : "write", argv[2]);
/* Update /etc/mtab. */
if (!write_mtab) return 0;
n = load_mtab("mount");
if (n < 0) exit(1); /* something is wrong. */

View file

@ -1,5 +1,5 @@
#!/bin/sh
# Actually, newroot is just like mounting on the root
exec mount "$*" /
exec mount -n "$*" /

View file

@ -17,6 +17,7 @@ mount \- mount a file system
.SH OPTIONS
.FL "\-r" "File system is mounted read-only"
.FL "\-t" "File system type"
.FL "\-n" "Don't update mtab"
.FL "\-o" "Options passed to FS server"
.SH EXAMPLES
.EX "mount /dev/fd1 /user" "Mount diskette 1 on \fI/user\fP"