diff --git a/man/ostree-prepare-root.xml b/man/ostree-prepare-root.xml
index 8726ccf18a..a6b3090b7e 100644
--- a/man/ostree-prepare-root.xml
+++ b/man/ostree-prepare-root.xml
@@ -114,6 +114,13 @@ License along with this library. If not, see .
A boolean value; the default is false. If this is set to true, then the /sysroot mount point is mounted read-only.
+
+
+
+ sysroot.etc
+ A string value; the default is persitent. If this is set to transient, then the /sysroot mount point is mounted transiently i.e. a non-persistent location.
+
+
diff --git a/src/switchroot/ostree-prepare-root.c b/src/switchroot/ostree-prepare-root.c
index 2ae4d452bc..586fcfdaf2 100644
--- a/src/switchroot/ostree-prepare-root.c
+++ b/src/switchroot/ostree-prepare-root.c
@@ -330,8 +330,10 @@ load_composefs_config (GError **error)
static gboolean
find_etc (const char **out_path, GError **error)
{
+ struct stat stbuf;
+
// Look for /etc
- if (fstatat (AT_FDCWD, "etc") == 0)
+ if (!glnx_fstatat_allow_noent (AT_FDCWD, "etc", &stbuf, AT_SYMLINK_NOFOLLOW, error))
{
*out_path = "etc";
return TRUE;
@@ -342,7 +344,7 @@ find_etc (const char **out_path, GError **error)
}
// Look for /usr/etc
- if (fstatat (AT_FDCWD, "usr/etc") == 0)
+ if (!glnx_fstatat_allow_noent (AT_FDCWD, "usr/etc", &stbuf, AT_SYMLINK_NOFOLLOW, error))
{
*out_path = "usr/etc";
return TRUE;
@@ -352,7 +354,7 @@ find_etc (const char **out_path, GError **error)
return glnx_throw_errno_prefix (error, "failed to stat etc");
}
*out_path = NULL;
- return TRUE;
+ return FALSE;
}
int
@@ -600,9 +602,9 @@ main (int argc, char *argv[])
g_autofree char *etc_config = NULL;
if (!ot_keyfile_get_value_with_default (config, SYSROOT_KEY, ETC_KEY, "persistent", &etc_config,
- error))
+ &error))
errx (EXIT_FAILURE, "failed to parse %s.%s: %s", SYSROOT_KEY, ETC_KEY, error->message);
- bool etc_transient = FALSE;
+ bool etc_transient = false;
if (g_str_equal (etc_config, "persistent"))
etc_transient = false;
else if (g_str_equal (etc_config, "transient"))
@@ -634,11 +636,10 @@ main (int argc, char *argv[])
if (!find_etc (&etc_lower, &error))
errx (EXIT_FAILURE, "Failed to find etc: %s", error->message);
- if (etc_lower)
- {
- g_autofree char etc_ovl_options
- = g_strdup_printf ("lowerdir=%s,upperdir=%s,workdir=%s", etc_lower, upper, work);
- if (g_str_equal (""))
+ g_autofree char *etc_ovl_options
+ = g_strdup_printf ("lowerdir=%s,upperdir=%s,workdir=%s", etc_lower, upper, work);
+ if (mount ("overlay", TMP_SYSROOT "/etc", "overlay", MS_SILENT, etc_ovl_options) < 0)
+ err (EXIT_FAILURE, "failed to mount transient etc overlayfs");
}
else
{