summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak2013-08-21 16:07:51 +0200
committerKarel Zak2013-08-21 16:07:51 +0200
commit50fccba1ab7097bcb69048bbe929ab739be3fc1e (patch)
treea0682409c49b721e7dc9e3082fc92b909586f7c2
parentlibmount: add reference counter to libmnt_table (diff)
downloadkernel-qcow2-util-linux-50fccba1ab7097bcb69048bbe929ab739be3fc1e.tar.gz
kernel-qcow2-util-linux-50fccba1ab7097bcb69048bbe929ab739be3fc1e.tar.xz
kernel-qcow2-util-linux-50fccba1ab7097bcb69048bbe929ab739be3fc1e.zip
misc: use libmnt_table reference counter
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--disk-utils/fsck.c4
-rw-r--r--misc-utils/findmnt.c7
-rw-r--r--misc-utils/lsblk.c5
-rw-r--r--misc-utils/lslocks.c2
-rw-r--r--sys-utils/eject.c10
-rw-r--r--sys-utils/mount.c3
-rw-r--r--sys-utils/mountpoint.c2
-rw-r--r--sys-utils/swapon-common.c4
-rw-r--r--sys-utils/umount.c6
9 files changed, 23 insertions, 20 deletions
diff --git a/disk-utils/fsck.c b/disk-utils/fsck.c
index 3fa47815e..1d05faf54 100644
--- a/disk-utils/fsck.c
+++ b/disk-utils/fsck.c
@@ -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;
}
diff --git a/misc-utils/findmnt.c b/misc-utils/findmnt.c
index aba7075df..3da901231 100644
--- a/misc-utils/findmnt.c
+++ b/misc-utils/findmnt.c
@@ -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);
diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c
index b5cdf6c45..69e769229 100644
--- a/misc-utils/lsblk.c
+++ b/misc-utils/lsblk.c
@@ -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);
diff --git a/misc-utils/lslocks.c b/misc-utils/lslocks.c
index de3094a01..c2ad18dd1 100644
--- a/misc-utils/lslocks.c
+++ b/misc-utils/lslocks.c
@@ -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;
}
diff --git a/sys-utils/eject.c b/sys-utils/eject.c
index b8e16c320..03744c7e7 100644
--- a/sys-utils/eject.c
+++ b/sys-utils/eject.c
@@ -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;
}
diff --git a/sys-utils/mount.c b/sys-utils/mount.c
index 9d9784905..fa1ce15c3 100644
--- a/sys-utils/mount.c
+++ b/sys-utils/mount.c
@@ -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;
}
diff --git a/sys-utils/mountpoint.c b/sys-utils/mountpoint.c
index 4f6dbbd3f..cba5f0125 100644
--- a/sys-utils/mountpoint.c
+++ b/sys-utils/mountpoint.c
@@ -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;
}
diff --git a/sys-utils/swapon-common.c b/sys-utils/swapon-common.c
index 5c95ef342..6dd7bacb1 100644
--- a/sys-utils/swapon-common.c
+++ b/sys-utils/swapon-common.c
@@ -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)))
diff --git a/sys-utils/umount.c b/sys-utils/umount.c
index c3b8187ce..b8e4b7fe6 100644
--- a/sys-utils/umount.c
+++ b/sys-utils/umount.c
@@ -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;
}