diff options
author | Karel Zak | 2011-01-10 12:43:32 +0100 |
---|---|---|
committer | Karel Zak | 2011-01-10 13:04:39 +0100 |
commit | 18781f4713a330b6738ad95ff2bb10ce4710fbad (patch) | |
tree | 98ade9ee7e430216017010610967b6a0558cfabb /mount | |
parent | lsblk: use "RM" for removable (diff) | |
download | kernel-qcow2-util-linux-18781f4713a330b6738ad95ff2bb10ce4710fbad.tar.gz kernel-qcow2-util-linux-18781f4713a330b6738ad95ff2bb10ce4710fbad.tar.xz kernel-qcow2-util-linux-18781f4713a330b6738ad95ff2bb10ce4710fbad.zip |
mount: canonicalize paths in HAVE_LIBMOUNT_MOUNT code
Reported-by: silvan minghetti <bu1137@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'mount')
-rw-r--r-- | mount/mount.c | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/mount/mount.c b/mount/mount.c index 2528fa6f9..ae137f0b5 100644 --- a/mount/mount.c +++ b/mount/mount.c @@ -1323,14 +1323,15 @@ verbose_mount_info(const char *spec, const char *node, const char *type, { struct my_mntent mnt; - mnt.mnt_fsname = is_pseudo_fs(type) ? xstrdup(spec) : canonicalize(spec); + mnt.mnt_fsname = is_pseudo_fs(type) ? spec : canonicalize(spec); mnt.mnt_dir = canonicalize (node); mnt.mnt_type = type; mnt.mnt_opts = opts; print_one (&mnt); - my_free(mnt.mnt_fsname); + if (spec != mnt.mnt_fsname) + my_free(mnt.mnt_fsname); my_free(mnt.mnt_dir); } @@ -1339,26 +1340,33 @@ prepare_mtab_entry(const char *spec, const char *node, const char *type, const char *opts, unsigned long flags) { mnt_fs *fs = mnt_new_fs(); + int rc = -1; if (!mtab_update) mtab_update = mnt_new_update(); - if (!mtab_update || !fs) - goto nothing; - mnt_fs_set_source(fs, spec); - mnt_fs_set_target(fs, node); - mnt_fs_set_fstype(fs, type); - mnt_fs_set_options(fs, opts); + if (mtab_update && fs) { + char *cn_spec = is_pseudo_fs(type) ? spec : canonicalize(spec); + char *cn_node = canonicalize(node); - if (mnt_update_set_fs(mtab_update, flags, NULL, fs)) - goto nothing; + mnt_fs_set_source(fs, cn_spec); + mnt_fs_set_target(fs, cn_node); + mnt_fs_set_fstype(fs, type); + mnt_fs_set_options(fs, opts); + + rc = mnt_update_set_fs(mtab_update, flags, NULL, fs); + + if (spec != cn_spec) + free(cn_spec); + free(cn_node); + } mnt_free_fs(fs); - return; -nothing: - mnt_free_update(mtab_update); - mnt_free_fs(fs); - mtab_update = NULL; + + if (rc) { + mnt_free_update(mtab_update); + mtab_update = NULL; + } } static void update_mtab_entry(int flags) |