summaryrefslogtreecommitdiffstats
path: root/sys-utils
diff options
context:
space:
mode:
authorKarel Zak2013-08-21 16:07:51 +0200
committerKarel Zak2013-08-21 16:07:51 +0200
commit50fccba1ab7097bcb69048bbe929ab739be3fc1e (patch)
treea0682409c49b721e7dc9e3082fc92b909586f7c2 /sys-utils
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>
Diffstat (limited to 'sys-utils')
-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
5 files changed, 13 insertions, 12 deletions
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;
}