From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10d4db,a87e4e06347c36bb,start X-Google-Attributes: gid10d4db,public X-Google-ArrivalTime: 1993-07-12 07:15:02 PST Newsgroups: comp.os.linux.announce Path: gmd.de!xlink.net!howland.reston.ans.net!noc.near.net!uunet!psinntp!dg-rtp!bounce-bounce From: kevin@frobozz.sccsi.com Subject: MS_REMOUNT support in mount.c Sender: usenet@dg-rtp.dg.com (Usenet Administration) Message-ID: <1993Jul12.134402.23674@dg-rtp.dg.com> Date: Mon, 12 Jul 93 13:44:02 GMT Reply-To: kevin@frobozz.sccsi.com Organization: None Followup-To: comp.os.linux Keywords: filesystem, root, readonly, remount, patch While upgrading to 0.99.10, I ran across the problem of the kernel mounting my root filesystem readonly. This turned out to be the result of using Frank Xia's mkboot program with the kernel in a raw partition, which is why I'm sure nobody else saw the behavior at all. To deal with this, I modified the mount program to allow one to use the new MS_REMOUNT option to mount(). As it stands now, my kernel mounts my root filesystem readonly, and I change that with the following command: mount -n -o rw,remount / The mount command won't touch /etc/mtab if remount is one of the flags. This is a bug in that it should really change the attributes recorded there, but that seemed more difficult than I wanted to deal with. What follows is the patch to mount.c and mount.8, in the usermount-0.2 distribution, to allow remounting of filesystems in place. Usermount-0.2 can be found on tsx-11.mit.edu in the file /pub/linux/sources/sbin/usermount-0.2.tar.z. What follows is the patch. Just do a "patch -p mnt_dir)) { + strncpy(mntdevbuf, mp->mnt_fsname, sizeof(mntdevbuf)-1); + mntdev = mntdevbuf; + break; + } else if(!strcmp(mntdir, mp->mnt_fsname)) { + strncpy(mntdevbuf, mp->mnt_dir, sizeof(mntdevbuf)-1); + mntdev = mntdir; + mntdir = mntdevbuf; + } + } + } + if(!mntdev) { fprintf(stderr, "mount: Don't know what to mount on %s\n", mntdir); *************** *** 171,177 **** } /* check for lock */ ! if(!lock_mtab()) { /* don't use err() for this */ fprintf(stderr, "mount: A lock-file exists, mount denied.\n"); exit(1); --- 193,199 ---- } /* check for lock */ ! if(!opt_nomtab && !lock_mtab()) { /* don't use err() for this */ fprintf(stderr, "mount: A lock-file exists, mount denied.\n"); exit(1); *************** *** 292,298 **** mp->mnt_type, opt_std, opt_nostd); #endif ! if(strcmp(mp->mnt_dir, "/") == 0) { if(opt_verbose) fprintf(stderr, "mount: root already mounted by kernel\n"); } else { --- 314,320 ---- mp->mnt_type, opt_std, opt_nostd); #endif ! if(strcmp(mp->mnt_dir, "/") == 0 && !(opt_std & MS_REMOUNT)) { if(opt_verbose) fprintf(stderr, "mount: root already mounted by kernel\n"); } else { *************** *** 324,330 **** } } /* if(!opt_fakemtab) */ ! if(!opt_nomtab) { if(!(mtab = setmntent(MTAB_FILE, "a"))) { fprintf(stderr, "mount: open(%s) failed.\n", MTAB_FILE); return 1; --- 346,352 ---- } } /* if(!opt_fakemtab) */ ! if(!opt_nomtab && !(opt_std & MS_REMOUNT)) { if(!(mtab = setmntent(MTAB_FILE, "a"))) { fprintf(stderr, "mount: open(%s) failed.\n", MTAB_FILE); return 1; *************** *** 391,396 **** --- 413,419 ---- else if(!strcmp(opt, MNTOPT_NODEV)) opt_std |= MS_NODEV; else if(!strcmp(opt, MNTOPT_NOEXEC)) opt_std |= MS_NOEXEC; else if(!strcmp(opt, MNTOPT_SYNC)) opt_std |= MS_SYNC; + else if(!strcmp(opt, MNTOPT_REMOUNT)) opt_std |= MS_REMOUNT; else { /* non-standard options are put in a comma-sep. string */ strcat(opt_nostd, opt); *** mount.8.old Mon Apr 26 12:28:50 1993 --- mount.8 Sun Jul 11 23:16:32 1993 *************** *** 50,56 **** Fake an entry in /etc/mtab without actually mounting anything. .TP \-n ! Do not write an entry in /etc/mtab for the mount. .TP \-p Print the entry that would otherwise have been written to /etc/mtab on stdout. --- 50,59 ---- Fake an entry in /etc/mtab without actually mounting anything. .TP \-n ! Do not write an entry in /etc/mtab for the mount. This option also causes ! the lockfile, /etc/mtab~, to be ignored, since no changes will be made to ! /etc/mtab anyway. This is particularly useful if you're trying to re-mount ! your root filesystem from read-only to read-write. .TP \-p Print the entry that would otherwise have been written to /etc/mtab on stdout. *************** *** 110,115 **** --- 113,122 ---- .BR sync : Always keep the mounted volume sync'ed. + + .BR remount : + Apply the other specified options to an already-mounted filesystem. + .RE .PP If \-u is given, or the caller of -- Send submissions for comp.os.linux.announce to: linux-announce@tc.cornell.edu