summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndrej Holy <oholy@redhat.com>2017-05-05 12:33:58 +0200
committerOndrej Holy <oholy@redhat.com>2017-05-09 14:28:48 +0200
commit53ed1804e255c78dd4938fe53d27edf90844bdf1 (patch)
tree5b6d1cf2fdca970a89e301b627602c82458f1343
parentb7ffc07d9893949b218d4057d896e7ba943c1b8b (diff)
downloadglib-53ed1804e255c78dd4938fe53d27edf90844bdf1.tar.gz
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
-rw-r--r--gio/gunixmounts.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/gio/gunixmounts.c b/gio/gunixmounts.c
index c7effd607..d20d144e9 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);
}