]> git.pld-linux.org Git - packages/util-linux.git/blame - util-linux-2.12q-update-mtab-when-moving.patch
- optimize in a way that nothing is done if config is empty
[packages/util-linux.git] / util-linux-2.12q-update-mtab-when-moving.patch
CommitLineData
17438604
ER
1Running `mount --move /foo /bar` would leave the old /foo entry in /etc/mtab
2and create a new /bar entry with wrong info.
3
4http://bugs.gentoo.org/104697
5
6--- mount/mount.c
7+++ mount/mount.c
8@@ -665,6 +665,25 @@
9 else {
10 mntFILE *mfp;
11
12+ /* when moving a mount point, we have to make sure the mtab
13+ * gets updated properly. We get info about the old mount
14+ * point, copy it to the new mount point, and then delete
15+ * the old mount point. */
16+ if (flags & MS_MOVE) {
17+ const char *olddir = mnt.mnt_fsname;
18+ struct mntentchn *oldmc = oldmc = getmntfile(olddir);
19+ if (oldmc != NULL) {
20+ mnt.mnt_fsname = strdup(oldmc->m.mnt_fsname);
21+ mnt.mnt_type = oldmc->m.mnt_type;
22+ mnt.mnt_opts = oldmc->m.mnt_opts;
23+ mnt.mnt_freq = oldmc->m.mnt_freq;
24+ mnt.mnt_passno = oldmc->m.mnt_passno;
25+ }
26+ update_mtab(olddir, NULL);
27+ if (oldmc != NULL)
28+ my_free(olddir);
29+ }
30+
31 lock_mtab();
32 mfp = my_setmntent(MOUNTED, "a+");
33 if (mfp == NULL || mfp->mntent_fp == NULL) {
This page took 0.053318 seconds and 4 git commands to generate.