[glib] gunixmounts: Speed up mtab processing with libmount
- From: Ondrej Holy <oholy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] gunixmounts: Speed up mtab processing with libmount
- Date: Tue, 9 May 2017 12:29:47 +0000 (UTC)
commit 53ed1804e255c78dd4938fe53d27edf90844bdf1
Author: Ondrej Holy <oholy redhat com>
Date: Fri May 5 12:33:58 2017 +0200
gunixmounts: Speed up mtab processing with libmount
libmnt_context is useless. It contains cache which is useful for searching,
but it isn't used in our case. Let's use mnt_context_parse_mtab instead
directly and the mtab processing will be faster.
https://bugzilla.gnome.org/show_bug.cgi?id=781867
gio/gunixmounts.c | 16 ++++++----------
1 files changed, 6 insertions(+), 10 deletions(-)
---
diff --git a/gio/gunixmounts.c b/gio/gunixmounts.c
index c7effd6..d20d144 100644
--- a/gio/gunixmounts.c
+++ b/gio/gunixmounts.c
@@ -391,15 +391,13 @@ static GList *
_g_get_unix_mounts (void)
{
struct libmnt_table *table = NULL;
- struct libmnt_context *ctxt = NULL;
struct libmnt_iter* iter = NULL;
struct libmnt_fs *fs = NULL;
GUnixMountEntry *mount_entry = NULL;
GList *return_list = NULL;
- ctxt = mnt_new_context ();
- mnt_context_get_mtab (ctxt, &table);
- if (!table)
+ table = mnt_new_table ();
+ if (mnt_table_parse_mtab (table, NULL) < 0)
goto out;
iter = mnt_new_iter (MNT_ITER_FORWARD);
@@ -435,7 +433,7 @@ _g_get_unix_mounts (void)
mnt_free_iter (iter);
out:
- mnt_free_context (ctxt);
+ mnt_unref_table (table);
return g_list_reverse (return_list);
}
@@ -875,15 +873,13 @@ static GList *
_g_get_unix_mount_points (void)
{
struct libmnt_table *table = NULL;
- struct libmnt_context *ctxt = NULL;
struct libmnt_iter* iter = NULL;
struct libmnt_fs *fs = NULL;
GUnixMountPoint *mount_point = NULL;
GList *return_list = NULL;
- ctxt = mnt_new_context ();
- mnt_context_get_fstab (ctxt, &table);
- if (!table)
+ table = mnt_new_table ();
+ if (mnt_table_parse_mtab (table, NULL) < 0)
goto out;
iter = mnt_new_iter (MNT_ITER_FORWARD);
@@ -953,7 +949,7 @@ _g_get_unix_mount_points (void)
mnt_free_iter (iter);
out:
- mnt_free_context (ctxt);
+ mnt_unref_table (table);
return g_list_reverse (return_list);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]