summaryrefslogtreecommitdiffstats
path: root/libmount/src/tab_update.c
diff options
context:
space:
mode:
authorKarel Zak2012-08-27 19:26:07 +0200
committerKarel Zak2012-08-27 19:26:07 +0200
commitc3085df65fe18c9f6077e1903a6ead19a4318d6d (patch)
tree71407b2d1c981e11eb7e8bab425008115d75bf3b /libmount/src/tab_update.c
parentlibblkid: rewrite ntfs prober (diff)
downloadkernel-qcow2-util-linux-c3085df65fe18c9f6077e1903a6ead19a4318d6d.tar.gz
kernel-qcow2-util-linux-c3085df65fe18c9f6077e1903a6ead19a4318d6d.tar.xz
kernel-qcow2-util-linux-c3085df65fe18c9f6077e1903a6ead19a4318d6d.zip
libmount: remount does not add entry to mtab file
# mount -n -o ro /dev/sda1 / # mount -o remount,rw /dev/sda1 / For the backward compatibility the command mount(8) should to add a new entry to the file /etc/mtab on remount if the original entry not found (because previous mount has been called with -n). Reported-by: <frinnst> on IRC Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src/tab_update.c')
-rw-r--r--libmount/src/tab_update.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/libmount/src/tab_update.c b/libmount/src/tab_update.c
index caabd05c2..4f04c8ecd 100644
--- a/libmount/src/tab_update.c
+++ b/libmount/src/tab_update.c
@@ -562,6 +562,17 @@ leave:
return rc;
}
+static int add_file_entry(struct libmnt_table *tb, struct libmnt_update *upd)
+{
+ struct libmnt_fs *fs = mnt_copy_fs(NULL, upd->fs);
+
+ if (!fs)
+ return -ENOMEM;
+
+ mnt_table_add_fs(tb, fs);
+ return update_table(upd, tb);
+}
+
static int update_add_entry(struct libmnt_update *upd, struct libmnt_lock *lc)
{
struct libmnt_table *tb;
@@ -579,16 +590,8 @@ static int update_add_entry(struct libmnt_update *upd, struct libmnt_lock *lc)
tb = __mnt_new_table_from_file(upd->filename,
upd->userspace_only ? MNT_FMT_UTAB : MNT_FMT_MTAB);
- if (tb) {
- struct libmnt_fs *fs = mnt_copy_fs(NULL, upd->fs);
- if (!fs)
- rc = -ENOMEM;
- else {
- mnt_table_add_fs(tb, fs);
- rc = update_table(upd, tb);
- }
- }
-
+ if (tb)
+ rc = add_file_entry(tb, upd);
if (lc)
mnt_unlock_file(lc);
@@ -621,7 +624,6 @@ static int update_remove_entry(struct libmnt_update *upd, struct libmnt_lock *lc
mnt_free_fs(rem);
}
}
-
if (lc)
mnt_unlock_file(lc);
@@ -691,7 +693,8 @@ static int update_modify_options(struct libmnt_update *upd, struct libmnt_lock *
rc = mnt_fs_set_options(cur, mnt_fs_get_options(fs));
if (!rc)
rc = update_table(upd, tb);
- }
+ } else
+ rc = add_file_entry(tb, upd); /* not found, add new */
}
if (lc)