extensions: Make extension tmpfs requirement independent on order

If we sort, or subset the extensions we use, then we can't just
set need_tmpfs on the first one, instead do the checking
for the first one when we're applying the extensions.
This commit is contained in:
Alexander Larsson
2017-02-01 19:42:57 +01:00
parent cc6e72ce57
commit 7f8ad5b3a1
2 changed files with 11 additions and 8 deletions

View File

@@ -2171,6 +2171,8 @@ flatpak_run_add_extension_args (GPtrArray *argv_array,
g_auto(GStrv) parts = NULL;
gboolean is_app;
GList *extensions, *l;
g_autoptr(GHashTable) mounted_tmpfs =
g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
parts = g_strsplit (full_ref, "/", 0);
if (g_strv_length (parts) != 4)
@@ -2191,9 +2193,13 @@ flatpak_run_add_extension_args (GPtrArray *argv_array,
if (ext->needs_tmpfs)
{
g_autofree char *parent = g_path_get_dirname (full_directory);
add_args (argv_array,
"--tmpfs", parent,
NULL);
if (g_hash_table_lookup (mounted_tmpfs, parent) == NULL)
{
add_args (argv_array,
"--tmpfs", parent,
NULL);
g_hash_table_insert (mounted_tmpfs, g_steal_pointer (&parent), "mounted");
}
}
add_args (argv_array,

View File

@@ -3532,7 +3532,6 @@ flatpak_list_extensions (GKeyFile *metakey,
g_auto(GStrv) refs = NULL;
g_auto(GStrv) unmaintained_refs = NULL;
int j;
gboolean needs_tmpfs = TRUE;
refs = flatpak_list_deployed_refs ("runtime", prefix, arch, branch,
NULL, NULL);
@@ -3545,8 +3544,7 @@ flatpak_list_extensions (GKeyFile *metakey,
if (subdir_files)
{
ext = flatpak_extension_new (extension, refs[j], dir_ref, extended_dir, subdir_files, FALSE);
ext->needs_tmpfs = needs_tmpfs;
needs_tmpfs = FALSE; /* Only first subdir needs a tmpfs */
ext->needs_tmpfs = TRUE;
res = g_list_prepend (res, ext);
}
}
@@ -3562,8 +3560,7 @@ flatpak_list_extensions (GKeyFile *metakey,
if (subdir_files)
{
ext = flatpak_extension_new (extension, unmaintained_refs[j], dir_ref, extended_dir, subdir_files, TRUE);
ext->needs_tmpfs = needs_tmpfs;
needs_tmpfs = FALSE; /* Only first subdir needs a tmpfs */
ext->needs_tmpfs = TRUE;
res = g_list_prepend (res, ext);
}
}