Skip to content

Commit

Permalink
remove find_etc
Browse files Browse the repository at this point in the history
  • Loading branch information
pwallrab committed Aug 8, 2023
1 parent 86b831d commit 905bf97
Showing 1 changed file with 7 additions and 37 deletions.
44 changes: 7 additions & 37 deletions src/switchroot/ostree-prepare-root.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,36 +327,6 @@ load_composefs_config (GError **error)
return g_steal_pointer (&ret);
}

static gboolean
find_etc (const char **out_path, GError **error)
{
struct stat stbuf;

// Look for /etc
if (!glnx_fstatat_allow_noent (AT_FDCWD, "etc", &stbuf, AT_SYMLINK_NOFOLLOW, error))
{
*out_path = "etc";
return TRUE;
}
else if (errno != ENOENT)
{
return glnx_throw_errno_prefix (error, "failed to stat etc");
}

// Look for /usr/etc
if (!glnx_fstatat_allow_noent (AT_FDCWD, "usr/etc", &stbuf, AT_SYMLINK_NOFOLLOW, error))
{
*out_path = "usr/etc";
return TRUE;
}
else if (errno != ENOENT)
{
return glnx_throw_errno_prefix (error, "failed to stat etc");
}
*out_path = NULL;
return FALSE;
}

int
main (int argc, char *argv[])
{
Expand Down Expand Up @@ -624,17 +594,17 @@ main (int argc, char *argv[])
{
if (etc_transient)
{
/* Do we have a persistent overlayfs for /usr? If so, mount it now. */
g_autofree char *etc_ovldir
= g_build_filename (OTCORE_RUN_OSTREE_PRIVATE, "etc-transient", NULL);
if (mkdirat (AT_FDCWD, etc_ovldir, 0700) < 0)
err (EXIT_FAILURE, "Failed to create %s", etc_ovldir);
err (EXIT_FAILURE, "failed to create %s", etc_ovldir);
g_autofree char *upper = g_build_filename (etc_ovldir, "upper", NULL);
if (mkdirat (AT_FDCWD, upper, 0700) < 0)
err (EXIT_FAILURE, "failed to create %s", upper);
g_autofree char *work = g_build_filename (etc_ovldir, "work", NULL);

const char *etc_lower = NULL;
if (!find_etc (&etc_lower, &error))
errx (EXIT_FAILURE, "Failed to find etc: %s", error->message);
if (mkdirat (AT_FDCWD, work, 0700) < 0)
err (EXIT_FAILURE, "failed to create %s", work);
g_autofree char *etc_lower = TMP_SYSROOT "/usr/etc";

g_autofree char *etc_ovl_options
= g_strdup_printf ("lowerdir=%s,upperdir=%s,workdir=%s", etc_lower, upper, work);
Expand Down Expand Up @@ -725,7 +695,7 @@ main (int argc, char *argv[])
const guint8 *buf = g_variant_get_data (metadata) ?: (guint8 *)"";
if (!glnx_file_replace_contents_at (AT_FDCWD, OTCORE_RUN_BOOTED, buf,
g_variant_get_size (metadata), 0, NULL, &error))
errx (EXIT_FAILURE, "Writing %s: %s", OTCORE_RUN_BOOTED, error->message);
errx (EXIT_FAILURE, "writing %s: %s", OTCORE_RUN_BOOTED, error->message);
}

if (chdir (TMP_SYSROOT) < 0)
Expand Down

0 comments on commit 905bf97

Please sign in to comment.