]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
misc: use libmnt_table reference counter
authorKarel Zak <kzak@redhat.com>
Wed, 21 Aug 2013 14:07:51 +0000 (16:07 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 21 Aug 2013 14:07:51 +0000 (16:07 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
disk-utils/fsck.c
misc-utils/findmnt.c
misc-utils/lsblk.c
misc-utils/lslocks.c
sys-utils/eject.c
sys-utils/mount.c
sys-utils/mountpoint.c
sys-utils/swapon-common.c
sys-utils/umount.c

index 3fa47815e32e326241ff5e5f052ca20c34e090d8..1d05faf549f1898807453d2c91fbc0b588ac8311 100644 (file)
@@ -1577,7 +1577,7 @@ int main(int argc, char *argv[])
        status |= wait_many(FLAG_WAIT_ALL);
        free(fsck_path);
        mnt_unref_cache(mntcache);
-       mnt_free_table(fstab);
-       mnt_free_table(mtab);
+       mnt_unref_table(fstab);
+       mnt_unref_table(mtab);
        return status;
 }
index aba7075df5eb62f900f1389a77828540ff9535a3..3da9012310f6cadef241976b2be26fcfb41a78e2 100644 (file)
@@ -806,7 +806,7 @@ static struct libmnt_table *parse_tabfiles(char **files,
                        break;
                }
                if (rc) {
-                       mnt_free_table(tb);
+                       mnt_unref_table(tb);
                        warn(_("can't read %s"), path);
                        return NULL;
                }
@@ -1087,7 +1087,7 @@ static int poll_table(struct libmnt_table *tb, const char *tabfile,
 
        rc = 0;
 done:
-       mnt_free_table(tb_new);
+       mnt_unref_table(tb_new);
        mnt_free_tabdiff(diff);
        mnt_free_iter(itr);
        if (f)
@@ -1496,8 +1496,9 @@ int main(int argc, char *argv[])
 leave:
        tt_free_table(tt);
 
-       mnt_free_table(tb);
+       mnt_unref_table(tb);
        mnt_unref_cache(cache);
+
        free(tabfiles);
 #ifdef HAVE_LIBUDEV
        udev_unref(udev);
index b5cdf6c4566559cb31b6e1c2dac55d6234bf492d..69e76922954a91742f444da558e2d483ffbb2ef2 100644 (file)
@@ -1604,8 +1604,9 @@ int main(int argc, char *argv[])
 
 leave:
        tt_free_table(lsblk->tt);
-       mnt_free_table(mtab);
-       mnt_free_table(swaps);
+
+       mnt_unref_table(mtab);
+       mnt_unref_table(swaps);
        mnt_unref_cache(mntcache);
 #ifdef HAVE_LIBUDEV
        udev_unref(udev);
index de3094a01850326f73abcd7afc032d9e00f8ac45..c2ad18dd15c8256a5773ffa73a0c353ad232fa20 100644 (file)
@@ -592,6 +592,6 @@ int main(int argc, char *argv[])
        if (!rc && !list_empty(&locks))
                rc = show_locks(&locks, tt_flags);
 
-       mnt_free_table(tab);
+       mnt_unref_table(tab);
        return rc;
 }
index b8e16c320466891b648f679ba0e068a6d0bd70c4..03744c7e70c5452b798c9a6bad3f2fa2bbfd5753 100644 (file)
@@ -106,7 +106,6 @@ static long int c_arg;
 static long int x_arg;
 
 struct libmnt_table *mtab;
-struct libmnt_cache *cache;
 
 static void vinfo(const char *fmt, va_list va)
 {
@@ -725,13 +724,15 @@ static int device_get_mountpoint(char **devname, char **mnt)
        *mnt = NULL;
 
        if (!mtab) {
+               struct libmnt_cache *cache;
+
                mtab = mnt_new_table();
                if (!mtab)
                        err(EXIT_FAILURE, _("failed to initialize libmount table"));
 
-               if (!cache)
-                       cache = mnt_new_cache();
+               cache = mnt_new_cache();
                mnt_table_set_cache(mtab, cache);
+               mnt_unref_cache(cache);
 
                if (p_option)
                        rc = mnt_table_parse_file(mtab, _PATH_PROC_MOUNTINFO);
@@ -1147,8 +1148,7 @@ int main(int argc, char **argv)
        free(device);
        free(mountpoint);
 
-       mnt_free_table(mtab);
-       mnt_unref_cache(cache);
+       mnt_unref_table(mtab);
 
        return EXIT_SUCCESS;
 }
index 9d97849059604e0ba1479b311521722ab6a48a11..fa1ce15c313dbcc631f1bcf1bf29bfa4d9e4d9d8 100644 (file)
@@ -641,6 +641,8 @@ static struct libmnt_table *append_fstab(struct libmnt_context *cxt,
 
                mnt_table_set_parser_errcb(fstab, table_parser_errcb);
                mnt_context_set_fstab(cxt, fstab);
+
+               mnt_unref_table(fstab); /* reference is handled by @cxt now */
        }
 
        if (mnt_table_parse_fstab(fstab, path))
@@ -1078,7 +1080,6 @@ int main(int argc, char **argv)
                success_message(cxt);
 done:
        mnt_free_context(cxt);
-       mnt_free_table(fstab);
        return rc;
 }
 
index 4f6dbbd3fbaf6b9528a177c272c90e6185f17141..cba5f0125b5579313638331aa7ded30169080b8e 100644 (file)
@@ -91,7 +91,7 @@ static int dir_to_device(const char *spec, dev_t *dev)
                rc = 0;
        }
 
-       mnt_free_table(tb);
+       mnt_unref_table(tb);
        return rc;
 }
 
index 5c95ef3424d685522b470122ef7503f1734f738d..6dd7bacb134195b12b38f1f94f9786f8e709648d 100644 (file)
@@ -41,8 +41,8 @@ struct libmnt_table *get_swaps(void)
 
 void free_tables(void)
 {
-       mnt_free_table(swaps);
-       mnt_free_table(fstab);
+       mnt_unref_table(swaps);
+       mnt_unref_table(fstab);
 }
 
 int match_swap(struct libmnt_fs *fs, void *data __attribute__((unused)))
index c3b8187cef5c36d33d0451b11ad7cefac809d24c..b8e4b7fe6733a3712291aecf63164d0ab2073540 100644 (file)
@@ -317,7 +317,7 @@ static struct libmnt_table *new_mountinfo(struct libmnt_context *cxt)
 
        if (mnt_table_parse_file(tb, _PATH_PROC_MOUNTINFO)) {
                warn(_("failed to parse %s"), _PATH_PROC_MOUNTINFO);
-               mnt_free_table(tb);
+               mnt_unref_table(tb);
                tb = NULL;
        }
 
@@ -400,7 +400,7 @@ static int umount_recursive(struct libmnt_context *cxt, const char *spec)
                                _("%s: not found"), spec);
        }
 
-       mnt_free_table(tb);
+       mnt_unref_table(tb);
        return rc;
 }
 
@@ -459,7 +459,7 @@ static int umount_alltargets(struct libmnt_context *cxt, const char *spec, int r
        }
 
        mnt_free_iter(itr);
-       mnt_free_table(tb);
+       mnt_unref_table(tb);
 
        return rc;
 }