On -o remount, we need to update the entry in mtab rather than
add a new one. update_mtab does this so use that.
However it might free some strings that shouldn't be freed, so
stop it from calling free - the program will exit soon anyway
so no exit is needed.
static void
my_free(const void *s) {
if (s)
static void
my_free(const void *s) {
if (s)
static void
read_mntentchn(mntFILE *mfp, const char *fnam, struct mntentchn *mc0) {
static void
read_mntentchn(mntFILE *mfp, const char *fnam, struct mntentchn *mc0) {
-update_mtab (const char *dir, struct mntent *instead) {
+update_mtab (const char *dir, struct mntent *instead)
+{
mntFILE *mfp, *mftmp;
const char *fnam = MOUNTED;
struct mntentchn mtabhead; /* dummy */
mntFILE *mfp, *mftmp;
const char *fnam = MOUNTED;
struct mntentchn mtabhead; /* dummy */
+#if 0
+ /* the chain might have strings copied from 'instead',
+ * so we cannot safely free it.
+ * And there is no need anyway because we are going to exit
+ * shortly. So just don't call discard_mntentchn....
+ */
if (fchmod (fileno (mftmp->mntent_fp),
S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) < 0) {
int errsv = errno;
if (fchmod (fileno (mftmp->mntent_fp),
S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) < 0) {
int errsv = errno;
ment.mnt_freq = 0;
ment.mnt_passno= 0;
ment.mnt_freq = 0;
ment.mnt_passno= 0;
+ if(flags & MS_REMOUNT) {
+ update_mtab(ment.mnt_dir, &ment);
+ return 0;
+ }
+
lock_mtab();
if ((mtab = setmntent(MOUNTED, "a+")) == NULL) {
lock_mtab();
if ((mtab = setmntent(MOUNTED, "a+")) == NULL) {