Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prepare-root: Add ostree.prepare-root.composefs #3277

Merged
merged 3 commits into from
Jul 12, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
prepare-root: Gather kernel cmdline early
Prep for parsing the composefs config from the kernel cmdline.
No functional changes intended.
  • Loading branch information
cgwalters committed Jul 10, 2024
commit 65ff4041953d815e3e32adb28e8d85b7acb8367b
11 changes: 6 additions & 5 deletions src/switchroot/ostree-prepare-root.c
Original file line number Diff line number Diff line change
@@ -113,14 +113,11 @@ sysroot_is_configured_ro (const char *sysroot)
}

static char *
resolve_deploy_path (const char *root_mountpoint)
resolve_deploy_path (const char *kernel_cmdline, const char *root_mountpoint)
{
char destpath[PATH_MAX];
struct stat stbuf;
char *deploy_path;
g_autofree char *kernel_cmdline = read_proc_cmdline ();
if (!kernel_cmdline)
errx (EXIT_FAILURE, "Failed to read kernel cmdline");

g_autoptr (GError) error = NULL;
g_autofree char *ostree_target = NULL;
@@ -268,6 +265,10 @@ main (int argc, char *argv[])
err (EXIT_FAILURE, "usage: ostree-prepare-root SYSROOT");
const char *root_arg = argv[1];

g_autofree char *kernel_cmdline = read_proc_cmdline ();
if (!kernel_cmdline)
errx (EXIT_FAILURE, "Failed to read kernel cmdline");

// Since several APIs want to operate in terms of file descriptors, let's
// open the initramfs now. Currently this is just used for the config parser.
glnx_autofd int initramfs_rootfs_fd = -1;
@@ -308,7 +309,7 @@ main (int argc, char *argv[])
const char *root_mountpoint = realpath (root_arg, NULL);
if (root_mountpoint == NULL)
err (EXIT_FAILURE, "realpath(\"%s\")", root_arg);
g_autofree char *deploy_path = resolve_deploy_path (root_mountpoint);
g_autofree char *deploy_path = resolve_deploy_path (kernel_cmdline, root_mountpoint);
const char *deploy_directory_name = glnx_basename (deploy_path);
// Note that realpath() should have stripped any trailing `/` which shouldn't
// be in the karg to start with, but we assert here to be sure we have a non-empty