summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak2013-08-21 14:38:38 +0200
committerKarel Zak2013-08-21 14:38:38 +0200
commit6195f9e6fab612694ff97e66f9b276b913aa2d24 (patch)
treee20e772ab6cf20504268c1e776f3cfe6913fd21f
parentlibmount: add reference counting to libmnt_cache (diff)
downloadkernel-qcow2-util-linux-6195f9e6fab612694ff97e66f9b276b913aa2d24.tar.gz
kernel-qcow2-util-linux-6195f9e6fab612694ff97e66f9b276b913aa2d24.tar.xz
kernel-qcow2-util-linux-6195f9e6fab612694ff97e66f9b276b913aa2d24.zip
misc: use libmnt_cache reference counting
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--disk-utils/fsck.c2
-rw-r--r--misc-utils/findmnt.c2
-rw-r--r--misc-utils/lsblk.c2
-rw-r--r--sys-utils/eject.c5
-rw-r--r--sys-utils/mount.c5
-rw-r--r--sys-utils/mountpoint.c2
-rw-r--r--sys-utils/swapoff.c2
-rw-r--r--sys-utils/swapon.c2
8 files changed, 11 insertions, 11 deletions
diff --git a/disk-utils/fsck.c b/disk-utils/fsck.c
index e479d5884..3fa47815e 100644
--- a/disk-utils/fsck.c
+++ b/disk-utils/fsck.c
@@ -1576,7 +1576,7 @@ int main(int argc, char *argv[])
}
status |= wait_many(FLAG_WAIT_ALL);
free(fsck_path);
- mnt_free_cache(mntcache);
+ mnt_unref_cache(mntcache);
mnt_free_table(fstab);
mnt_free_table(mtab);
return status;
diff --git a/misc-utils/findmnt.c b/misc-utils/findmnt.c
index 8ccceda96..aba7075df 100644
--- a/misc-utils/findmnt.c
+++ b/misc-utils/findmnt.c
@@ -1497,7 +1497,7 @@ leave:
tt_free_table(tt);
mnt_free_table(tb);
- mnt_free_cache(cache);
+ mnt_unref_cache(cache);
free(tabfiles);
#ifdef HAVE_LIBUDEV
udev_unref(udev);
diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c
index 4f4350587..b5cdf6c45 100644
--- a/misc-utils/lsblk.c
+++ b/misc-utils/lsblk.c
@@ -1606,7 +1606,7 @@ leave:
tt_free_table(lsblk->tt);
mnt_free_table(mtab);
mnt_free_table(swaps);
- mnt_free_cache(mntcache);
+ mnt_unref_cache(mntcache);
#ifdef HAVE_LIBUDEV
udev_unref(udev);
#endif
diff --git a/sys-utils/eject.c b/sys-utils/eject.c
index 5bcde68ca..b8e16c320 100644
--- a/sys-utils/eject.c
+++ b/sys-utils/eject.c
@@ -729,7 +729,8 @@ static int device_get_mountpoint(char **devname, char **mnt)
if (!mtab)
err(EXIT_FAILURE, _("failed to initialize libmount table"));
- cache = mnt_new_cache();
+ if (!cache)
+ cache = mnt_new_cache();
mnt_table_set_cache(mtab, cache);
if (p_option)
@@ -1147,7 +1148,7 @@ int main(int argc, char **argv)
free(mountpoint);
mnt_free_table(mtab);
- mnt_free_cache(cache);
+ mnt_unref_cache(cache);
return EXIT_SUCCESS;
}
diff --git a/sys-utils/mount.c b/sys-utils/mount.c
index 0998b0110..9d9784905 100644
--- a/sys-utils/mount.c
+++ b/sys-utils/mount.c
@@ -163,7 +163,7 @@ static void print_all(struct libmnt_context *cxt, char *pattern, int show_label)
free(xsrc);
}
- mnt_free_cache(cache);
+ mnt_unref_cache(cache);
mnt_free_iter(itr);
}
@@ -990,8 +990,7 @@ int main(int argc, char **argv)
* make a connection between the fstab and the canonicalization
* cache.
*/
- struct libmnt_cache *cache = mnt_context_get_cache(cxt);
- mnt_table_set_cache(fstab, cache);
+ mnt_table_set_cache(fstab, mnt_context_get_cache(cxt));
}
if (!mnt_context_get_source(cxt) &&
diff --git a/sys-utils/mountpoint.c b/sys-utils/mountpoint.c
index c86e94b12..4f6dbbd3f 100644
--- a/sys-utils/mountpoint.c
+++ b/sys-utils/mountpoint.c
@@ -83,6 +83,7 @@ static int dir_to_device(const char *spec, dev_t *dev)
/* to canonicalize all necessary paths */
cache = mnt_new_cache();
mnt_table_set_cache(tb, cache);
+ mnt_unref_cache(cache);
fs = mnt_table_find_target(tb, spec, MNT_ITER_BACKWARD);
if (fs && mnt_fs_get_target(fs)) {
@@ -91,7 +92,6 @@ static int dir_to_device(const char *spec, dev_t *dev)
}
mnt_free_table(tb);
- mnt_free_cache(cache);
return rc;
}
diff --git a/sys-utils/swapoff.c b/sys-utils/swapoff.c
index 0bd85ac9c..182ce9592 100644
--- a/sys-utils/swapoff.c
+++ b/sys-utils/swapoff.c
@@ -190,7 +190,7 @@ int main(int argc, char *argv[])
status |= swapoff_all();
free_tables();
- mnt_free_cache(mntcache);
+ mnt_unref_cache(mntcache);
return status;
}
diff --git a/sys-utils/swapon.c b/sys-utils/swapon.c
index 4b4b7160c..cc9bdbc83 100644
--- a/sys-utils/swapon.c
+++ b/sys-utils/swapon.c
@@ -816,7 +816,7 @@ int main(int argc, char *argv[])
status |= do_swapon(*argv++, priority, discard, !CANONIC);
free_tables();
- mnt_free_cache(mntcache);
+ mnt_unref_cache(mntcache);
return status;
}