From 3f1b9160dc8ffc6e7196a24885781e1ba82f9119 Mon Sep 17 00:00:00 2001 From: Chris Leech Date: Tue, 21 Jul 2015 16:15:30 -0700 Subject: [PATCH v2 7/9] iscsid: safe_logout fix device path canonicalization by using libmount cache Fix for the safe_logout options use of libmount. If the cache API isn't used then device name canonicalization doesn't happen, and proper detection of devices mounted by a label doesn't work. --- usr/initiator.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/usr/initiator.c b/usr/initiator.c index 8cd1896..b0f0147 100644 --- a/usr/initiator.c +++ b/usr/initiator.c @@ -2045,12 +2045,14 @@ static int session_unbind(struct iscsi_session *session) } static struct libmnt_table *mtab, *swaps; +static struct libmnt_cache *mntcache; static void libmount_cleanup(void) { mnt_free_table(mtab); mnt_free_table(swaps); - mtab = swaps = NULL; + mnt_free_cache(mntcache); + mtab = swaps = mntcache = NULL; } static int libmount_init(void) @@ -2058,10 +2060,13 @@ static int libmount_init(void) mnt_init_debug(0); mtab = mnt_new_table(); swaps = mnt_new_table(); - if (!mtab || !swaps) { + mntcache = mnt_new_cache(); + if (!mtab || !swaps || !mntcache) { libmount_cleanup(); return -ENOMEM; } + mnt_table_set_cache(mtab, mntcache); + mnt_table_set_cache(swaps, mntcache); mnt_table_parse_mtab(mtab, NULL); mnt_table_parse_swaps(swaps, NULL); return 0; -- 2.5.5