uefi: Check that EFI system partition is mounted (Fixes: #436)

If the ESP isn't mounted it's possible that the update may look
succesful on the Linux side, but certain to fail later.
This commit is contained in:
Mario Limonciello 2018-03-13 22:08:39 -05:00 committed by Richard Hughes
parent e30c6e14cd
commit 937299d72b

View File

@ -377,6 +377,30 @@ fu_plugin_uefi_update_splash (GError **error)
return fu_plugin_uefi_update_resource (re, 0, image_bmp, error);
}
static gboolean
fu_plugin_uefi_esp_mounted (FuPlugin *plugin, GError **error)
{
FuPluginData *data = fu_plugin_get_data (plugin);
g_autofree gchar *contents = NULL;
g_auto(GStrv) lines = NULL;
gsize length;
if (!g_file_get_contents ("/proc/mounts", &contents, &length, error))
return FALSE;
lines = g_strsplit (contents, "\n", 0);
for (guint i = 0; lines[i] != NULL; i++) {
if (lines[i] != NULL && g_strrstr (lines[i], data->esp_path))
return TRUE;
}
g_set_error (error,
FWUPD_ERROR,
FWUPD_ERROR_NOT_SUPPORTED,
"EFI System partition %s is not mounted",
data->esp_path);
return FALSE;
}
gboolean
fu_plugin_update (FuPlugin *plugin,
FuDevice *device,
@ -403,6 +427,10 @@ fu_plugin_update (FuPlugin *plugin,
str = _("Installing firmware update…");
g_assert (str != NULL);
/* make sure that the ESP is mounted */
if (!fu_plugin_uefi_esp_mounted (plugin, error))
return FALSE;
/* perform the update */
g_debug ("Performing UEFI capsule update");
fu_device_set_status (device, FWUPD_STATUS_SCHEDULING);