From: Karel Zak Date: Wed, 21 Aug 2013 12:38:38 +0000 (+0200) Subject: misc: use libmnt_cache reference counting X-Git-Tag: v2.24-rc1~354 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6195f9e6fab612694ff97e66f9b276b913aa2d24;p=thirdparty%2Futil-linux.git misc: use libmnt_cache reference counting Signed-off-by: Karel Zak --- diff --git a/disk-utils/fsck.c b/disk-utils/fsck.c index e479d58844..3fa47815e3 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 8ccceda96b..aba7075df5 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 4f4350587a..b5cdf6c456 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 5bcde68ca6..b8e16c3204 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 0998b01102..9d97849059 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 c86e94b12a..4f6dbbd3fb 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 0bd85ac9c7..182ce9592b 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 4b4b7160cb..cc9bdbc836 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; }