]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
misc: use libmnt_cache reference counting
authorKarel Zak <kzak@redhat.com>
Wed, 21 Aug 2013 12:38:38 +0000 (14:38 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 21 Aug 2013 12:38:38 +0000 (14:38 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
disk-utils/fsck.c
misc-utils/findmnt.c
misc-utils/lsblk.c
sys-utils/eject.c
sys-utils/mount.c
sys-utils/mountpoint.c
sys-utils/swapoff.c
sys-utils/swapon.c

index e479d58844be891e3c1764fc0e0aef705db82fe9..3fa47815e32e326241ff5e5f052ca20c34e090d8 100644 (file)
@@ -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;
index 8ccceda96bbc0ad80c42f86146ec151d130faed0..aba7075df5eb62f900f1389a77828540ff9535a3 100644 (file)
@@ -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);
index 4f4350587aedb91a60eb0bfd8f7438418986f3f8..b5cdf6c4566559cb31b6e1c2dac55d6234bf492d 100644 (file)
@@ -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
index 5bcde68ca66d4d863bc5a6156f5eb854be03cbef..b8e16c320466891b648f679ba0e068a6d0bd70c4 100644 (file)
@@ -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;
 }
index 0998b011021212265e50500ab020c7c25baec4fa..9d97849059604e0ba1479b311521722ab6a48a11 100644 (file)
@@ -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) &&
index c86e94b12a9ca7852e68bdc805e4c65b61703fcf..4f6dbbd3fbaf6b9528a177c272c90e6185f17141 100644 (file)
@@ -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;
 }
 
index 0bd85ac9c70d01a47f748577886133e87c6650d5..182ce9592bb6e5611ffa6595886c96f0fd52e2e5 100644 (file)
@@ -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;
 }
index 4b4b7160cb82d6bd5b5bbefbeecb237e2ecd3c9d..cc9bdbc836413ba00720becaccebdfebc89555a9 100644 (file)
@@ -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;
 }