mschorm / rpms / util-linux

Forked from rpms/util-linux 2 years ago
Clone
0c223bc
--- util-linux-2.13-pre6/mount/mount.c.move	2006-06-12 09:19:43.000000000 +0200
0c223bc
+++ util-linux-2.13-pre6/mount/mount.c	2006-06-12 09:45:05.000000000 +0200
0c223bc
@@ -768,6 +768,25 @@
0c223bc
 		else {
0c223bc
 			mntFILE *mfp;
0c223bc
 
0c223bc
+			/* when moving a mount point, we have to make sure the mtab
0c223bc
+			 * gets updated properly.  We get info about the old mount
0c223bc
+			 * point, copy it to the new mount point, and then delete
0c223bc
+			 * the old mount point. */
0c223bc
+			if (flags & MS_MOVE) {
0c223bc
+				const char *olddir = mnt.mnt_fsname;
0c223bc
+				struct mntentchn *oldmc = oldmc = getmntfile(olddir);
0c223bc
+				if (oldmc != NULL) {
0c223bc
+					mnt.mnt_fsname = strdup(oldmc->m.mnt_fsname);
0c223bc
+					mnt.mnt_type = oldmc->m.mnt_type;
0c223bc
+					mnt.mnt_opts = oldmc->m.mnt_opts;
0c223bc
+					mnt.mnt_freq = oldmc->m.mnt_freq;
0c223bc
+					mnt.mnt_passno = oldmc->m.mnt_passno;
0c223bc
+				}
0c223bc
+				update_mtab(olddir, NULL);
0c223bc
+				if (oldmc != NULL)
0c223bc
+					my_free(olddir);
0c223bc
+			}
0c223bc
+
0c223bc
 			lock_mtab();
0c223bc
 			mfp = my_setmntent(MOUNTED, "a+");
0c223bc
 			if (mfp == NULL || mfp->mntent_fp == NULL) {