mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 15:06:14 +01:00
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
This commit is contained in:
parent
b7ffc07d98
commit
53ed1804e2
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user