76 lines
2.0 KiB
Diff
76 lines
2.0 KiB
Diff
commit c3085df65fe18c9f6077e1903a6ead19a4318d6d
|
|
Author: Karel Zak <kzak@redhat.com>
|
|
Date: Mon Aug 27 19:26:07 2012 +0200
|
|
|
|
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>
|
|
|
|
diff --git a/libmount/src/tab_update.c b/libmount/src/tab_update.c
|
|
index caabd05..4f04c8e 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)
|