diff --git a/src/switchroot/ostree-prepare-root.c b/src/switchroot/ostree-prepare-root.c index 586fcfdaf2..0003314875 100644 --- a/src/switchroot/ostree-prepare-root.c +++ b/src/switchroot/ostree-prepare-root.c @@ -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[]) { @@ -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); @@ -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)