mirror of
https://github.com/ostreedev/ostree.git
synced 2025-02-11 21:58:44 +03:00
lib/sysroot-deploy: Port a kernel finding logic to new style
Prep for more work here. Closes: #1053 Approved by: jlebon
This commit is contained in:
parent
596fc2967e
commit
8b60f63f58
@ -876,38 +876,33 @@ get_kernel_from_tree (int deployment_dfd,
|
|||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gboolean ret = FALSE;
|
|
||||||
glnx_fd_close int ret_boot_dfd = -1;
|
|
||||||
g_auto(GLnxDirFdIterator) dfditer = { 0, };
|
|
||||||
g_autofree char *ret_kernel_name = NULL;
|
g_autofree char *ret_kernel_name = NULL;
|
||||||
g_autofree char *ret_initramfs_name = NULL;
|
g_autofree char *ret_initramfs_name = NULL;
|
||||||
g_autofree char *kernel_checksum = NULL;
|
g_autofree char *kernel_checksum = NULL;
|
||||||
g_autofree char *initramfs_checksum = NULL;
|
g_autofree char *initramfs_checksum = NULL;
|
||||||
|
|
||||||
ret_boot_dfd = glnx_opendirat_with_errno (deployment_dfd, "usr/lib/ostree-boot", TRUE);
|
glnx_fd_close int ret_boot_dfd = glnx_opendirat_with_errno (deployment_dfd, "usr/lib/ostree-boot", TRUE);
|
||||||
if (ret_boot_dfd == -1)
|
if (ret_boot_dfd == -1)
|
||||||
{
|
{
|
||||||
if (errno != ENOENT)
|
if (errno != ENOENT)
|
||||||
{
|
return glnx_throw_errno_prefix (error, "%s", "openat(usr/lib/ostree-boot)");
|
||||||
glnx_set_prefix_error_from_errno (error, "%s", "openat");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!glnx_opendirat (deployment_dfd, "boot", TRUE, &ret_boot_dfd, error))
|
if (!glnx_opendirat (deployment_dfd, "boot", TRUE, &ret_boot_dfd, error))
|
||||||
goto out;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_auto(GLnxDirFdIterator) dfditer = { 0, };
|
||||||
if (!glnx_dirfd_iterator_init_at (ret_boot_dfd, ".", FALSE, &dfditer, error))
|
if (!glnx_dirfd_iterator_init_at (ret_boot_dfd, ".", FALSE, &dfditer, error))
|
||||||
goto out;
|
return FALSE;
|
||||||
|
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
struct dirent *dent;
|
struct dirent *dent;
|
||||||
|
|
||||||
if (!glnx_dirfd_iterator_next_dent (&dfditer, &dent, cancellable, error))
|
if (!glnx_dirfd_iterator_next_dent (&dfditer, &dent, cancellable, error))
|
||||||
goto out;
|
return FALSE;
|
||||||
|
|
||||||
if (dent == NULL)
|
if (dent == NULL)
|
||||||
break;
|
break;
|
||||||
@ -941,7 +936,7 @@ get_kernel_from_tree (int deployment_dfd,
|
|||||||
{
|
{
|
||||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
|
||||||
"Failed to find boot/vmlinuz-<CHECKSUM> in tree");
|
"Failed to find boot/vmlinuz-<CHECKSUM> in tree");
|
||||||
goto out;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret_initramfs_name != NULL)
|
if (ret_initramfs_name != NULL)
|
||||||
@ -950,17 +945,14 @@ get_kernel_from_tree (int deployment_dfd,
|
|||||||
{
|
{
|
||||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
|
||||||
"Mismatched kernel checksum vs initrd in tree");
|
"Mismatched kernel checksum vs initrd in tree");
|
||||||
goto out;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*out_boot_dfd = ret_boot_dfd;
|
*out_boot_dfd = glnx_steal_fd (&ret_boot_dfd);
|
||||||
ret_boot_dfd = -1;
|
|
||||||
*out_kernel_name = g_steal_pointer (&ret_kernel_name);
|
*out_kernel_name = g_steal_pointer (&ret_kernel_name);
|
||||||
*out_initramfs_name = g_steal_pointer (&ret_initramfs_name);
|
*out_initramfs_name = g_steal_pointer (&ret_initramfs_name);
|
||||||
ret = TRUE;
|
return TRUE;
|
||||||
out:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
Loading…
x
Reference in New Issue
Block a user