diff options
Diffstat (limited to 'src/libostree/ostree-sysroot-deploy.c')
-rw-r--r-- | src/libostree/ostree-sysroot-deploy.c | 1566 |
1 files changed, 708 insertions, 858 deletions
diff --git a/src/libostree/ostree-sysroot-deploy.c b/src/libostree/ostree-sysroot-deploy.c index 0bd119fa..b87866ff 100644 --- a/src/libostree/ostree-sysroot-deploy.c +++ b/src/libostree/ostree-sysroot-deploy.c @@ -19,17 +19,17 @@ #include "config.h" +#include <err.h> #include <gio/gunixinputstream.h> #include <gio/gunixoutputstream.h> #include <glib-unix.h> +#include <stdbool.h> #include <stdint.h> -#include <sys/mount.h> -#include <sys/statvfs.h> -#include <sys/socket.h> #include <sys/ioctl.h> -#include <stdbool.h> +#include <sys/mount.h> #include <sys/poll.h> -#include <err.h> +#include <sys/socket.h> +#include <sys/statvfs.h> #ifdef HAVE_LIBMOUNT #include <libmount.h> @@ -38,21 +38,25 @@ #include <systemd/sd-journal.h> #endif -#include "otutil.h" -#include "ostree.h" -#include "ostree-repo-private.h" -#include "ostree-sysroot-private.h" -#include "ostree-sepolicy-private.h" -#include "ostree-deployment-private.h" +#include "libglnx.h" #include "ostree-core-private.h" +#include "ostree-deployment-private.h" #include "ostree-linuxfsutil.h" -#include "libglnx.h" +#include "ostree-repo-private.h" +#include "ostree-sepolicy-private.h" +#include "ostree-sysroot-private.h" +#include "ostree.h" +#include "otutil.h" #ifdef HAVE_LIBSYSTEMD -#define OSTREE_VARRELABEL_ID SD_ID128_MAKE(da,67,9b,08,ac,d3,45,04,b7,89,d9,6f,81,8e,a7,81) -#define OSTREE_CONFIGMERGE_ID SD_ID128_MAKE(d3,86,3b,ae,c1,3e,44,49,ab,03,84,68,4a,8a,f3,a7) -#define OSTREE_DEPLOYMENT_COMPLETE_ID SD_ID128_MAKE(dd,44,0e,3e,54,90,83,b6,3d,0e,fc,7d,c1,52,55,f1) -#define OSTREE_DEPLOYMENT_FINALIZING_ID SD_ID128_MAKE(e8,64,6c,d6,3d,ff,46,25,b7,79,09,a8,e7,a4,09,94) +#define OSTREE_VARRELABEL_ID \ + SD_ID128_MAKE (da, 67, 9b, 08, ac, d3, 45, 04, b7, 89, d9, 6f, 81, 8e, a7, 81) +#define OSTREE_CONFIGMERGE_ID \ + SD_ID128_MAKE (d3, 86, 3b, ae, c1, 3e, 44, 49, ab, 03, 84, 68, 4a, 8a, f3, a7) +#define OSTREE_DEPLOYMENT_COMPLETE_ID \ + SD_ID128_MAKE (dd, 44, 0e, 3e, 54, 90, 83, b6, 3d, 0e, fc, 7d, c1, 52, 55, f1) +#define OSTREE_DEPLOYMENT_FINALIZING_ID \ + SD_ID128_MAKE (e8, 64, 6c, d6, 3d, ff, 46, 25, b7, 79, 09, a8, e7, a4, 09, 94) #endif /* @@ -60,11 +64,8 @@ * symlink. */ static gboolean -symlink_at_replace (const char *oldpath, - int parent_dfd, - const char *newpath, - GCancellable *cancellable, - GError **error) +symlink_at_replace (const char *oldpath, int parent_dfd, const char *newpath, + GCancellable *cancellable, GError **error) { /* Possibly in the future generate a temporary random name here, * would need to move "generate a temporary name" code into @@ -73,7 +74,7 @@ symlink_at_replace (const char *oldpath, g_autofree char *temppath = g_strconcat (newpath, ".tmp", NULL); /* Clean up any stale temporary links */ - (void) unlinkat (parent_dfd, temppath, 0); + (void)unlinkat (parent_dfd, temppath, 0); /* Create the temp link */ if (TEMP_FAILURE_RETRY (symlinkat (oldpath, parent_dfd, temppath)) < 0) @@ -87,8 +88,7 @@ symlink_at_replace (const char *oldpath, } static GLnxFileCopyFlags -sysroot_flags_to_copy_flags (GLnxFileCopyFlags defaults, - OstreeSysrootDebugFlags sysrootflags) +sysroot_flags_to_copy_flags (GLnxFileCopyFlags defaults, OstreeSysrootDebugFlags sysrootflags) { if (sysrootflags & OSTREE_SYSROOT_DEBUG_NO_XATTRS) defaults |= GLNX_FILE_COPY_NOXATTRS; @@ -100,14 +100,9 @@ sysroot_flags_to_copy_flags (GLnxFileCopyFlags defaults, * hardlink if we're on the same partition. */ static gboolean -install_into_boot (OstreeRepo *repo, - OstreeSePolicy *sepolicy, - int src_dfd, - const char *src_subpath, - int dest_dfd, - const char *dest_subpath, - GCancellable *cancellable, - GError **error) +install_into_boot (OstreeRepo *repo, OstreeSePolicy *sepolicy, int src_dfd, const char *src_subpath, + int dest_dfd, const char *dest_subpath, GCancellable *cancellable, + GError **error) { if (linkat (src_dfd, src_subpath, dest_dfd, dest_subpath, 0) == 0) return TRUE; /* Note early return */ @@ -124,27 +119,30 @@ install_into_boot (OstreeRepo *repo, return FALSE; /* Be sure we relabel when copying the kernel, as in current - * e.g. Fedora it might be labeled module_object_t or usr_t, - * but policy may not allow other processes to read from that - * like kdump. - * See also https://github.com/fedora-selinux/selinux-policy/commit/747f4e6775d773ab74efae5aa37f3e5e7f0d4aca - * This means we also drop xattrs but...I doubt anyone uses - * non-SELinux xattrs for the kernel anyways aside from perhaps - * IMA but that's its own story. - */ - g_auto(OstreeSepolicyFsCreatecon) fscreatecon = { 0, }; + * e.g. Fedora it might be labeled module_object_t or usr_t, + * but policy may not allow other processes to read from that + * like kdump. + * See also + * https://github.com/fedora-selinux/selinux-policy/commit/747f4e6775d773ab74efae5aa37f3e5e7f0d4aca + * This means we also drop xattrs but...I doubt anyone uses + * non-SELinux xattrs for the kernel anyways aside from perhaps + * IMA but that's its own story. + */ + g_auto (OstreeSepolicyFsCreatecon) fscreatecon = { + 0, + }; const char *boot_path = glnx_strjoina ("/boot/", glnx_basename (dest_subpath)); - if (!_ostree_sepolicy_preparefscreatecon (&fscreatecon, sepolicy, - boot_path, S_IFREG | 0644, + if (!_ostree_sepolicy_preparefscreatecon (&fscreatecon, sepolicy, boot_path, S_IFREG | 0644, error)) return FALSE; - g_auto(GLnxTmpfile) tmp_dest = { 0, }; - if (!glnx_open_tmpfile_linkable_at (dest_dfd, ".", O_WRONLY | O_CLOEXEC, - &tmp_dest, error)) + g_auto (GLnxTmpfile) tmp_dest = { + 0, + }; + if (!glnx_open_tmpfile_linkable_at (dest_dfd, ".", O_WRONLY | O_CLOEXEC, &tmp_dest, error)) return FALSE; - if (glnx_regfile_copy_bytes (src_fd, tmp_dest.fd, (off_t) -1) < 0) + if (glnx_regfile_copy_bytes (src_fd, tmp_dest.fd, (off_t)-1) < 0) return glnx_throw_errno_prefix (error, "regfile copy"); /* Kernel data should always be root-owned */ @@ -176,15 +174,11 @@ install_into_boot (OstreeRepo *repo, /* Copy ownership, mode, and xattrs from source directory to destination */ static gboolean -dirfd_copy_attributes_and_xattrs (int src_parent_dfd, - const char *src_name, - int src_dfd, - int dest_dfd, - OstreeSysrootDebugFlags flags, - GCancellable *cancellable, - GError **error) +dirfd_copy_attributes_and_xattrs (int src_parent_dfd, const char *src_name, int src_dfd, + int dest_dfd, OstreeSysrootDebugFlags flags, + GCancellable *cancellable, GError **error) { - g_autoptr(GVariant) xattrs = NULL; + g_autoptr (GVariant) xattrs = NULL; /* Clone all xattrs first, so we get the SELinux security context * right. This will allow other users access if they have ACLs, but @@ -192,11 +186,9 @@ dirfd_copy_attributes_and_xattrs (int src_parent_dfd, */ if (!(flags & OSTREE_SYSROOT_DEBUG_NO_XATTRS)) { - if (!glnx_dfd_name_get_all_xattrs (src_parent_dfd, src_name, - &xattrs, cancellable, error)) + if (!glnx_dfd_name_get_all_xattrs (src_parent_dfd, src_name, &xattrs, cancellable, error)) return FALSE; - if (!glnx_fd_set_all_xattrs (dest_dfd, xattrs, - cancellable, error)) + if (!glnx_fd_set_all_xattrs (dest_dfd, xattrs, cancellable, error)) return FALSE; } @@ -214,20 +206,19 @@ dirfd_copy_attributes_and_xattrs (int src_parent_dfd, static gint str_sort_cb (gconstpointer name_ptr_a, gconstpointer name_ptr_b) { - const gchar *name_a = *((const gchar **) name_ptr_a); - const gchar *name_b = *((const gchar **) name_ptr_b); + const gchar *name_a = *((const gchar **)name_ptr_a); + const gchar *name_b = *((const gchar **)name_ptr_b); return g_strcmp0 (name_a, name_b); } static gboolean -checksum_dir_recurse (int dfd, - const char *path, - OtChecksum *checksum, - GCancellable *cancellable, - GError **error) +checksum_dir_recurse (int dfd, const char *path, OtChecksum *checksum, GCancellable *cancellable, + GError **error) { - g_auto(GLnxDirFdIterator) dfditer = { 0, }; + g_auto (GLnxDirFdIterator) dfditer = { + 0, + }; g_autoptr (GPtrArray) d_entries = g_ptr_array_new_with_free_func (g_free); if (!glnx_dirfd_iterator_init_at (dfd, path, TRUE, &dfditer, error)) @@ -249,20 +240,19 @@ checksum_dir_recurse (int dfd, /* File systems do not guarantee dir entry order, make sure this is * reproducable */ - g_ptr_array_sort(d_entries, str_sort_cb); + g_ptr_array_sort (d_entries, str_sort_cb); - for (gint i=0; i < d_entries->len; i++) + for (gint i = 0; i < d_entries->len; i++) { const gchar *d_name = (gchar *)g_ptr_array_index (d_entries, i); struct stat stbuf; - if (!glnx_fstatat (dfditer.fd, d_name, &stbuf, - AT_SYMLINK_NOFOLLOW, error)) + if (!glnx_fstatat (dfditer.fd, d_name, &stbuf, AT_SYMLINK_NOFOLLOW, error)) return FALSE; if (S_ISDIR (stbuf.st_mode)) { - if (!checksum_dir_recurse(dfditer.fd, d_name, checksum, cancellable, error)) + if (!checksum_dir_recurse (dfditer.fd, d_name, checksum, cancellable, error)) return FALSE; } else @@ -273,26 +263,23 @@ checksum_dir_recurse (int dfd, return FALSE; if (fd != -1) { - g_autoptr(GInputStream) in = g_unix_input_stream_new (g_steal_fd (&fd), TRUE); + g_autoptr (GInputStream) in = g_unix_input_stream_new (g_steal_fd (&fd), TRUE); if (!ot_gio_splice_update_checksum (NULL, in, checksum, cancellable, error)) return FALSE; } } - } return TRUE; } static gboolean -copy_dir_recurse (int src_parent_dfd, - int dest_parent_dfd, - const char *name, - OstreeSysrootDebugFlags flags, - GCancellable *cancellable, - GError **error) -{ - g_auto(GLnxDirFdIterator) src_dfd_iter = { 0, }; +copy_dir_recurse (int src_parent_dfd, int dest_parent_dfd, const char *name, + OstreeSysrootDebugFlags flags, GCancellable *cancellable, GError **error) +{ + g_auto (GLnxDirFdIterator) src_dfd_iter = { + 0, + }; glnx_autofd int dest_dfd = -1; struct dirent *dent; @@ -306,8 +293,8 @@ copy_dir_recurse (int src_parent_dfd, if (!glnx_opendirat (dest_parent_dfd, name, TRUE, &dest_dfd, error)) return FALSE; - if (!dirfd_copy_attributes_and_xattrs (src_parent_dfd, name, src_dfd_iter.fd, dest_dfd, - flags, cancellable, error)) + if (!dirfd_copy_attributes_and_xattrs (src_parent_dfd, name, src_dfd_iter.fd, dest_dfd, flags, + cancellable, error)) return glnx_prefix_error (error, "Copying attributes of %s", name); while (TRUE) @@ -319,20 +306,19 @@ copy_dir_recurse (int src_parent_dfd, if (dent == NULL) break; - if (!glnx_fstatat (src_dfd_iter.fd, dent->d_name, &child_stbuf, - AT_SYMLINK_NOFOLLOW, error)) + if (!glnx_fstatat (src_dfd_iter.fd, dent->d_name, &child_stbuf, AT_SYMLINK_NOFOLLOW, error)) return FALSE; if (S_ISDIR (child_stbuf.st_mode)) { - if (!copy_dir_recurse (src_dfd_iter.fd, dest_dfd, dent->d_name, - flags, cancellable, error)) + if (!copy_dir_recurse (src_dfd_iter.fd, dest_dfd, dent->d_name, flags, cancellable, + error)) return FALSE; } else { - if (!glnx_file_copy_at (src_dfd_iter.fd, dent->d_name, &child_stbuf, - dest_dfd, dent->d_name, + if (!glnx_file_copy_at (src_dfd_iter.fd, dent->d_name, &child_stbuf, dest_dfd, + dent->d_name, sysroot_flags_to_copy_flags (GLNX_FILE_COPY_OVERWRITE, flags), cancellable, error)) return glnx_prefix_error (error, "Copying %s", dent->d_name); @@ -346,14 +332,9 @@ copy_dir_recurse (int src_parent_dfd, * they're created. */ static gboolean -ensure_directory_from_template (int orig_etc_fd, - int modified_etc_fd, - int new_etc_fd, - const char *path, - int *out_dfd, - OstreeSysrootDebugFlags flags, - GCancellable *cancellable, - GError **error) +ensure_directory_from_template (int orig_etc_fd, int modified_etc_fd, int new_etc_fd, + const char *path, int *out_dfd, OstreeSysrootDebugFlags flags, + GCancellable *cancellable, GError **error) { glnx_autofd int src_dfd = -1; glnx_autofd int target_dfd = -1; @@ -365,7 +346,7 @@ ensure_directory_from_template (int orig_etc_fd, return FALSE; /* Create with mode 0700, we'll fchmod/fchown later */ - again: +again: if (mkdirat (new_etc_fd, path, 0700) != 0) { if (errno == EEXIST) @@ -398,8 +379,8 @@ ensure_directory_from_template (int orig_etc_fd, if (!glnx_opendirat (new_etc_fd, path, TRUE, &target_dfd, error)) return FALSE; - if (!dirfd_copy_attributes_and_xattrs (modified_etc_fd, path, src_dfd, target_dfd, - flags, cancellable, error)) + if (!dirfd_copy_attributes_and_xattrs (modified_etc_fd, path, src_dfd, target_dfd, flags, + cancellable, error)) return FALSE; if (out_dfd) @@ -412,13 +393,8 @@ ensure_directory_from_template (int orig_etc_fd, * or a directory. Directories will be copied recursively. */ static gboolean -copy_modified_config_file (int orig_etc_fd, - int modified_etc_fd, - int new_etc_fd, - const char *path, - OstreeSysrootDebugFlags flags, - GCancellable *cancellable, - GError **error) +copy_modified_config_file (int orig_etc_fd, int modified_etc_fd, int new_etc_fd, const char *path, + OstreeSysrootDebugFlags flags, GCancellable *cancellable, GError **error) { struct stat modified_stbuf; struct stat new_stbuf; @@ -431,8 +407,8 @@ copy_modified_config_file (int orig_etc_fd, { g_autofree char *parent = g_path_get_dirname (path); - if (!ensure_directory_from_template (orig_etc_fd, modified_etc_fd, new_etc_fd, - parent, &dest_parent_dfd, flags, cancellable, error)) + if (!ensure_directory_from_template (orig_etc_fd, modified_etc_fd, new_etc_fd, parent, + &dest_parent_dfd, flags, cancellable, error)) return FALSE; } else @@ -449,13 +425,14 @@ copy_modified_config_file (int orig_etc_fd, if (errno != ENOENT) return glnx_throw_errno_prefix (error, "fstatat"); } - else if (S_ISDIR(new_stbuf.st_mode)) + else if (S_ISDIR (new_stbuf.st_mode)) { - if (!S_ISDIR(modified_stbuf.st_mode)) + if (!S_ISDIR (modified_stbuf.st_mode)) { return g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, "Modified config file newly defaults to directory '%s', cannot merge", - path), FALSE; + path), + FALSE; } else { @@ -473,21 +450,20 @@ copy_modified_config_file (int orig_etc_fd, if (S_ISDIR (modified_stbuf.st_mode)) { - if (!copy_dir_recurse (modified_etc_fd, new_etc_fd, path, flags, - cancellable, error)) + if (!copy_dir_recurse (modified_etc_fd, new_etc_fd, path, flags, cancellable, error)) return FALSE; } else if (S_ISLNK (modified_stbuf.st_mode) || S_ISREG (modified_stbuf.st_mode)) { - if (!glnx_file_copy_at (modified_etc_fd, path, &modified_stbuf, - new_etc_fd, path, + if (!glnx_file_copy_at (modified_etc_fd, path, &modified_stbuf, new_etc_fd, path, sysroot_flags_to_copy_flags (GLNX_FILE_COPY_OVERWRITE, flags), cancellable, error)) return glnx_prefix_error (error, "Copying %s", path); } else { - ot_journal_print (LOG_INFO, "Ignoring non-regular/non-symlink file found during /etc merge: %s", path); + ot_journal_print (LOG_INFO, + "Ignoring non-regular/non-symlink file found during /etc merge: %s", path); } return TRUE; @@ -511,12 +487,9 @@ copy_modified_config_file (int orig_etc_fd, * changed in @new_etc, the modified version always wins. */ static gboolean -merge_configuration_from (OstreeSysroot *sysroot, - OstreeDeployment *merge_deployment, - OstreeDeployment *new_deployment, - int new_deployment_dfd, - GCancellable *cancellable, - GError **error) +merge_configuration_from (OstreeSysroot *sysroot, OstreeDeployment *merge_deployment, + OstreeDeployment *new_deployment, int new_deployment_dfd, + GCancellable *cancellable, GError **error) { GLNX_AUTO_PREFIX_ERROR ("During /etc merge", error); const OstreeSysrootDebugFlags flags = sysroot->debug_flags; @@ -524,19 +497,21 @@ merge_configuration_from (OstreeSysroot *sysroot, g_assert (merge_deployment != NULL && new_deployment != NULL); g_assert (new_deployment_dfd != -1); - g_autofree char *merge_deployment_path = ostree_sysroot_get_deployment_dirpath (sysroot, merge_deployment); + g_autofree char *merge_deployment_path + = ostree_sysroot_get_deployment_dirpath (sysroot, merge_deployment); glnx_autofd int merge_deployment_dfd = -1; - if (!glnx_opendirat (sysroot->sysroot_fd, merge_deployment_path, FALSE, - &merge_deployment_dfd, error)) + if (!glnx_opendirat (sysroot->sysroot_fd, merge_deployment_path, FALSE, &merge_deployment_dfd, + error)) return FALSE; /* TODO: get rid of GFile usage here */ - g_autoptr(GFile) orig_etc = ot_fdrel_to_gfile (merge_deployment_dfd, "usr/etc"); - g_autoptr(GFile) modified_etc = ot_fdrel_to_gfile (merge_deployment_dfd, "etc"); + g_autoptr (GFile) orig_etc = ot_fdrel_to_gfile (merge_deployment_dfd, "usr/etc"); + g_autoptr (GFile) modified_etc = ot_fdrel_to_gfile (merge_deployment_dfd, "etc"); /* Return values for below */ - g_autoptr(GPtrArray) modified = g_ptr_array_new_with_free_func ((GDestroyNotify) ostree_diff_item_unref); - g_autoptr(GPtrArray) removed = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref); - g_autoptr(GPtrArray) added = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref); + g_autoptr (GPtrArray) modified + = g_ptr_array_new_with_free_func ((GDestroyNotify)ostree_diff_item_unref); + g_autoptr (GPtrArray) removed = g_ptr_array_new_with_free_func ((GDestroyNotify)g_object_unref); + g_autoptr (GPtrArray) added = g_ptr_array_new_with_free_func ((GDestroyNotify)g_object_unref); /* For now, ignore changes to xattrs; the problem is that * security.selinux will be different between the /usr/etc labels * and the ones in the real /etc, so they all show up as different. @@ -545,20 +520,17 @@ merge_configuration_from (OstreeSysroot *sysroot, * file, to have that change persist across upgrades, you must also * modify the content of the file. */ - if (!ostree_diff_dirs (OSTREE_DIFF_FLAGS_IGNORE_XATTRS, - orig_etc, modified_etc, modified, removed, added, - cancellable, error)) + if (!ostree_diff_dirs (OSTREE_DIFF_FLAGS_IGNORE_XATTRS, orig_etc, modified_etc, modified, removed, + added, cancellable, error)) return glnx_prefix_error (error, "While computing configuration diff"); - { g_autofree char *msg = - g_strdup_printf ("Copying /etc changes: %u modified, %u removed, %u added", - modified->len, removed->len, added->len); - ot_journal_send ("MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(OSTREE_CONFIGMERGE_ID), - "MESSAGE=%s", msg, - "ETC_N_MODIFIED=%u", modified->len, - "ETC_N_REMOVED=%u", removed->len, - "ETC_N_ADDED=%u", added->len, - NULL); + { + g_autofree char *msg + = g_strdup_printf ("Copying /etc changes: %u modified, %u removed, %u added", modified->len, + removed->len, added->len); + ot_journal_send ("MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL (OSTREE_CONFIGMERGE_ID), + "MESSAGE=%s", msg, "ETC_N_MODIFIED=%u", modified->len, "ETC_N_REMOVED=%u", + removed->len, "ETC_N_ADDED=%u", added->len, NULL); _ostree_sysroot_emit_journal_msg (sysroot, msg); } @@ -591,8 +563,8 @@ merge_configuration_from (OstreeSysroot *sysroot, g_assert (path); - if (!copy_modified_config_file (orig_etc_fd, modified_etc_fd, new_etc_fd, path, - flags, cancellable, error)) + if (!copy_modified_config_file (orig_etc_fd, modified_etc_fd, new_etc_fd, path, flags, + cancellable, error)) return FALSE; } for (guint i = 0; i < added->len; i++) @@ -602,8 +574,8 @@ merge_configuration_from (OstreeSysroot *sysroot, g_assert (path); - if (!copy_modified_config_file (orig_etc_fd, modified_etc_fd, new_etc_fd, path, - flags, cancellable, error)) + if (!copy_modified_config_file (orig_etc_fd, modified_etc_fd, new_etc_fd, path, flags, + cancellable, error)) return FALSE; } @@ -615,17 +587,13 @@ merge_configuration_from (OstreeSysroot *sysroot, * A dfd for the result is returned in @out_deployment_dfd. */ static gboolean -checkout_deployment_tree (OstreeSysroot *sysroot, - OstreeRepo *repo, - OstreeDeployment *deployment, - int *out_deployment_dfd, - GCancellable *cancellable, - GError **error) +checkout_deployment_tree (OstreeSysroot *sysroot, OstreeRepo *repo, OstreeDeployment *deployment, + int *out_deployment_dfd, GCancellable *cancellable, GError **error) { GLNX_AUTO_PREFIX_ERROR ("Checking out deployment tree", error); /* Find the directory with deployments for this stateroot */ - g_autofree char *osdeploy_path = - g_strconcat ("ostree/deploy/", ostree_deployment_get_osname (deployment), "/deploy", NULL); + g_autofree char *osdeploy_path + = g_strconcat ("ostree/deploy/", ostree_deployment_get_osname (deployment), "/deploy", NULL); if (!glnx_shutil_mkdir_p_at (sysroot->sysroot_fd, osdeploy_path, 0775, cancellable, error)) return FALSE; @@ -635,24 +603,22 @@ checkout_deployment_tree (OstreeSysroot *sysroot, /* Clean up anything that was there before, from e.g. an interrupted checkout */ const char *csum = ostree_deployment_get_csum (deployment); - g_autofree char *checkout_target_name = - g_strdup_printf ("%s.%d", csum, ostree_deployment_get_deployserial (deployment)); + g_autofree char *checkout_target_name + = g_strdup_printf ("%s.%d", csum, ostree_deployment_get_deployserial (deployment)); if (!glnx_shutil_rm_rf_at (osdeploy_dfd, checkout_target_name, cancellable, error)) return FALSE; /* Generate hardlink farm, then opendir it */ OstreeRepoCheckoutAtOptions checkout_opts = { .process_passthrough_whiteouts = TRUE }; - if (!ostree_repo_checkout_at (repo, &checkout_opts, osdeploy_dfd, - checkout_target_name, csum, + if (!ostree_repo_checkout_at (repo, &checkout_opts, osdeploy_dfd, checkout_target_name, csum, cancellable, error)) return FALSE; - return glnx_opendirat (osdeploy_dfd, checkout_target_name, TRUE, out_deployment_dfd, - error); + return glnx_opendirat (osdeploy_dfd, checkout_target_name, TRUE, out_deployment_dfd, error); } static char * -ptrarray_path_join (GPtrArray *path) +ptrarray_path_join (GPtrArray *path) { GString *path_buf; @@ -676,49 +642,36 @@ ptrarray_path_join (GPtrArray *path) } static gboolean -relabel_one_path (OstreeSysroot *sysroot, - OstreeSePolicy *sepolicy, - GFile *path, - GFileInfo *info, - GPtrArray *path_parts, - GCancellable *cancellable, - GError **error) +relabel_one_path (OstreeSysroot *sysroot, OstreeSePolicy *sepolicy, GFile *path, GFileInfo *info, + GPtrArray *path_parts, GCancellable *cancellable, GError **error) { gboolean ret = FALSE; g_autofree char *relpath = NULL; relpath = ptrarray_path_join (path_parts); - if (!ostree_sepolicy_restorecon (sepolicy, relpath, - info, path, - OSTREE_SEPOLICY_RESTORECON_FLAGS_ALLOW_NOLABEL, - NULL, + if (!ostree_sepolicy_restorecon (sepolicy, relpath, info, path, + OSTREE_SEPOLICY_RESTORECON_FLAGS_ALLOW_NOLABEL, NULL, cancellable, error)) goto out; ret = TRUE; - out: +out: return ret; } static gboolean -relabel_recursively (OstreeSysroot *sysroot, - OstreeSePolicy *sepolicy, - GFile *dir, - GFileInfo *dir_info, - GPtrArray *path_parts, - GCancellable *cancellable, - GError **error) +relabel_recursively (OstreeSysroot *sysroot, OstreeSePolicy *sepolicy, GFile *dir, + GFileInfo *dir_info, GPtrArray *path_parts, GCancellable *cancellable, + GError **error) { gboolean ret = FALSE; - g_autoptr(GFileEnumerator) direnum = NULL; + g_autoptr (GFileEnumerator) direnum = NULL; - if (!relabel_one_path (sysroot, sepolicy, dir, dir_info, path_parts, - cancellable, error)) + if (!relabel_one_path (sysroot, sepolicy, dir, dir_info, path_parts, cancellable, error)) goto out; direnum = g_file_enumerate_children (dir, OSTREE_GIO_FAST_QUERYINFO, - G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, - cancellable, error); + G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, cancellable, error); if (!direnum) goto out; @@ -728,25 +681,24 @@ relabel_recursively (OstreeSysroot *sysroot, GFile *child; GFileType ftype; - if (!g_file_enumerator_iterate (direnum, &file_info, &child, - cancellable, error)) + if (!g_file_enumerator_iterate (direnum, &file_info, &child, cancellable, error)) goto out; if (file_info == NULL) break; - g_ptr_array_add (path_parts, (char*)g_file_info_get_name (file_info)); + g_ptr_array_add (path_parts, (char *)g_file_info_get_name (file_info)); ftype = g_file_info_get_file_type (file_info); if (ftype == G_FILE_TYPE_DIRECTORY) { - if (!relabel_recursively (sysroot, sepolicy, child, file_info, path_parts, - cancellable, error)) + if (!relabel_recursively (sysroot, sepolicy, child, file_info, path_parts, cancellable, + error)) goto out; } else { - if (!relabel_one_path (sysroot, sepolicy, child, file_info, path_parts, - cancellable, error)) + if (!relabel_one_path (sysroot, sepolicy, child, file_info, path_parts, cancellable, + error)) goto out; } @@ -754,30 +706,23 @@ relabel_recursively (OstreeSysroot *sysroot, } ret = TRUE; - out: +out: return ret; } static gboolean -selinux_relabel_dir (OstreeSysroot *sysroot, - OstreeSePolicy *sepolicy, - GFile *dir, - const char *prefix, - GCancellable *cancellable, - GError **error) -{ - - g_autoptr(GFileInfo) root_info = - g_file_query_info (dir, OSTREE_GIO_FAST_QUERYINFO, - G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, - cancellable, error); +selinux_relabel_dir (OstreeSysroot *sysroot, OstreeSePolicy *sepolicy, GFile *dir, + const char *prefix, GCancellable *cancellable, GError **error) +{ + + g_autoptr (GFileInfo) root_info = g_file_query_info ( + dir, OSTREE_GIO_FAST_QUERYINFO, G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, cancellable, error); if (!root_info) return FALSE; - g_autoptr(GPtrArray) path_parts = g_ptr_array_new (); - g_ptr_array_add (path_parts, (char*)prefix); - if (!relabel_recursively (sysroot, sepolicy, dir, root_info, path_parts, - cancellable, error)) + g_autoptr (GPtrArray) path_parts = g_ptr_array_new (); + g_ptr_array_add (path_parts, (char *)prefix); + if (!relabel_recursively (sysroot, sepolicy, dir, root_info, path_parts, cancellable, error)) return glnx_prefix_error (error, "Relabeling /%s", prefix); return TRUE; @@ -787,11 +732,8 @@ selinux_relabel_dir (OstreeSysroot *sysroot, * https://github.com/ostreedev/ostree/pull/872 */ static gboolean -selinux_relabel_var_if_needed (OstreeSysroot *sysroot, - OstreeSePolicy *sepolicy, - int os_deploy_dfd, - GCancellable *cancellable, - GError **error) +selinux_relabel_var_if_needed (OstreeSysroot *sysroot, OstreeSePolicy *sepolicy, int os_deploy_dfd, + GCancellable *cancellable, GError **error) { /* This is a bit of a hack; we should change the code at some * point in the distant future to only create (and label) /var @@ -803,34 +745,32 @@ selinux_relabel_var_if_needed (OstreeSysroot *sysroot, return FALSE; if (errno == ENOENT) { - { g_autofree char *msg = - g_strdup_printf ("Relabeling /var (no stamp file '%s' found)", selabeled); - ot_journal_send ("MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(OSTREE_VARRELABEL_ID), - "MESSAGE=%s", msg, - NULL); + { + g_autofree char *msg + = g_strdup_printf ("Relabeling /var (no stamp file '%s' found)", selabeled); + ot_journal_send ("MESSAGE_ID=" SD_ID128_FORMAT_STR, + SD_ID128_FORMAT_VAL (OSTREE_VARRELABEL_ID), "MESSAGE=%s", msg, NULL); _ostree_sysroot_emit_journal_msg (sysroot, msg); } - g_autoptr(GFile) deployment_var_path = ot_fdrel_to_gfile (os_deploy_dfd, "var"); - if (!selinux_relabel_dir (sysroot, sepolicy, - deployment_var_path, "var", - cancellable, error)) + g_autoptr (GFile) deployment_var_path = ot_fdrel_to_gfile (os_deploy_dfd, "var"); + if (!selinux_relabel_dir (sysroot, sepolicy, deployment_var_path, "var", cancellable, error)) { g_prefix_error (error, "Relabeling /var: "); return FALSE; } - { g_auto(OstreeSepolicyFsCreatecon) con = { 0, }; + { + g_auto (OstreeSepolicyFsCreatecon) con = { + 0, + }; const char *selabeled_abspath = glnx_strjoina ("/", selabeled); - if (!_ostree_sepolicy_preparefscreatecon (&con, sepolicy, - selabeled_abspath, - 0644, error)) + if (!_ostree_sepolicy_preparefscreatecon (&con, sepolicy, selabeled_abspath, 0644, error)) return FALSE; - if (!glnx_file_replace_contents_at (os_deploy_dfd, selabeled, (guint8*)"", 0, - GLNX_FILE_REPLACE_DATASYNC_NEW, - cancellable, error)) + if (!glnx_file_replace_contents_at (os_deploy_dfd, selabeled, (guint8 *)"", 0, + GLNX_FILE_REPLACE_DATASYNC_NEW, cancellable, error)) return FALSE; } } @@ -842,12 +782,8 @@ selinux_relabel_var_if_needed (OstreeSysroot *sysroot, * merge_configuration_from(). */ static gboolean -prepare_deployment_etc (OstreeSysroot *sysroot, - OstreeRepo *repo, - OstreeDeployment *deployment, - int deployment_dfd, - GCancellable *cancellable, - GError **error) +prepare_deployment_etc (OstreeSysroot *sysroot, OstreeRepo *repo, OstreeDeployment *deployment, + int deployment_dfd, GCancellable *cancellable, GError **error) { GLNX_AUTO_PREFIX_ERROR ("Preparing /etc", error); @@ -861,8 +797,8 @@ prepare_deployment_etc (OstreeSysroot *sysroot, if (etc_exists) { - if (usretc_exists) - return glnx_throw (error, "Tree contains both /etc and /usr/etc"); + if (usretc_exists) + return glnx_throw (error, "Tree contains both /etc and /usr/etc"); /* Compatibility hack */ if (!glnx_renameat (deployment_dfd, "etc", deployment_dfd, "usr/etc", error)) return FALSE; @@ -874,26 +810,23 @@ prepare_deployment_etc (OstreeSysroot *sysroot, /* We need copies of /etc from /usr/etc (so admins can use vi), and if * SELinux is enabled, we need to relabel. */ - OstreeRepoCheckoutAtOptions etc_co_opts = { .force_copy = TRUE, - .subpath = "/usr/etc", - .sepolicy_prefix = "/etc"}; + OstreeRepoCheckoutAtOptions etc_co_opts + = { .force_copy = TRUE, .subpath = "/usr/etc", .sepolicy_prefix = "/etc" }; /* Here, we initialize SELinux policy from the /usr/etc inside * the root - this is before we've finalized the configuration * merge into /etc. */ - g_autoptr(OstreeSePolicy) sepolicy = ostree_sepolicy_new_at (deployment_dfd, cancellable, error); + g_autoptr (OstreeSePolicy) sepolicy + = ostree_sepolicy_new_at (deployment_dfd, cancellable, error); if (!sepolicy) return FALSE; if (ostree_sepolicy_get_name (sepolicy) != NULL) etc_co_opts.sepolicy = sepolicy; /* Copy usr/etc → etc */ - if (!ostree_repo_checkout_at (repo, &etc_co_opts, - deployment_dfd, "etc", - ostree_deployment_get_csum (deployment), - cancellable, error)) + if (!ostree_repo_checkout_at (repo, &etc_co_opts, deployment_dfd, "etc", + ostree_deployment_get_csum (deployment), cancellable, error)) return FALSE; - } return TRUE; @@ -903,44 +836,36 @@ prepare_deployment_etc (OstreeSysroot *sysroot, * the assumption the caller may be writing multiple. */ static gboolean -write_origin_file_internal (OstreeSysroot *sysroot, - OstreeSePolicy *sepolicy, - OstreeDeployment *deployment, - GKeyFile *new_origin, - GLnxFileReplaceFlags flags, - GCancellable *cancellable, - GError **error) +write_origin_file_internal (OstreeSysroot *sysroot, OstreeSePolicy *sepolicy, + OstreeDeployment *deployment, GKeyFile *new_origin, + GLnxFileReplaceFlags flags, GCancellable *cancellable, GError **error) { if (!_ostree_sysroot_ensure_writable (sysroot, error)) return FALSE; GLNX_AUTO_PREFIX_ERROR ("Writing out origin file", error); - GKeyFile *origin = - new_origin ? new_origin : ostree_deployment_get_origin (deployment); + GKeyFile *origin = new_origin ? new_origin : ostree_deployment_get_origin (deployment); if (origin) { - g_auto(OstreeSepolicyFsCreatecon) con = { 0, }; - if (!_ostree_sepolicy_preparefscreatecon (&con, sepolicy, - "/etc/ostree/remotes.d/dummy.conf", + g_auto (OstreeSepolicyFsCreatecon) con = { + 0, + }; + if (!_ostree_sepolicy_preparefscreatecon (&con, sepolicy, "/etc/ostree/remotes.d/dummy.conf", 0644, error)) return FALSE; - g_autofree char *origin_path = - g_strdup_printf ("ostree/deploy/%s/deploy/%s.%d.origin", - ostree_deployment_get_osname (deployment), - ostree_deployment_get_csum (deployment), - ostree_deployment_get_deployserial (deployment)); + g_autofree char *origin_path = g_strdup_printf ( + "ostree/deploy/%s/deploy/%s.%d.origin", ostree_deployment_get_osname (deployment), + ostree_deployment_get_csum (deployment), ostree_deployment_get_deployserial (deployment)); gsize len; g_autofree char *contents = g_key_file_to_data (origin, &len, error); if (!contents) return FALSE; - if (!glnx_file_replace_contents_at (sysroot->sysroot_fd, - origin_path, (guint8*)contents, len, - flags, - cancellable, error)) + if (!glnx_file_replace_contents_at (sysroot->sysroot_fd, origin_path, (guint8 *)contents, len, + flags, cancellable, error)) return FALSE; } @@ -960,20 +885,16 @@ write_origin_file_internal (OstreeSysroot *sysroot, * this function will write the current origin of @deployment. */ gboolean -ostree_sysroot_write_origin_file (OstreeSysroot *sysroot, - OstreeDeployment *deployment, - GKeyFile *new_origin, - GCancellable *cancellable, - GError **error) -{ - g_autoptr(GFile) rootfs = g_file_new_for_path ("/"); - g_autoptr(OstreeSePolicy) sepolicy = ostree_sepolicy_new (rootfs, cancellable, error); +ostree_sysroot_write_origin_file (OstreeSysroot *sysroot, OstreeDeployment *deployment, + GKeyFile *new_origin, GCancellable *cancellable, GError **error) +{ + g_autoptr (GFile) rootfs = g_file_new_for_path ("/"); + g_autoptr (OstreeSePolicy) sepolicy = ostree_sepolicy_new (rootfs, cancellable, error); if (!sepolicy) return FALSE; if (!write_origin_file_internal (sysroot, sepolicy, deployment, new_origin, - GLNX_FILE_REPLACE_DATASYNC_NEW, - cancellable, error)) + GLNX_FILE_REPLACE_DATASYNC_NEW, cancellable, error)) return FALSE; if (!_ostree_sysroot_bump_mtime (sysroot, error)) @@ -982,8 +903,9 @@ ostree_sysroot_write_origin_file (OstreeSysroot *sysroot, return TRUE; } -typedef struct { - int boot_dfd; +typedef struct +{ + int boot_dfd; char *kernel_srcpath; char *kernel_namever; char *kernel_hmac_srcpath; @@ -1013,9 +935,9 @@ _ostree_kernel_layout_free (OstreeKernelLayout *layout) g_free (layout->bootcsum); g_free (layout); } -G_DEFINE_AUTOPTR_CLEANUP_FUNC(OstreeKernelLayout, _ostree_kernel_layout_free); +G_DEFINE_AUTOPTR_CLEANUP_FUNC (OstreeKernelLayout, _ostree_kernel_layout_free); -static OstreeKernelLayout* +static OstreeKernelLayout * _ostree_kernel_layout_new (void) { OstreeKernelLayout *ret = g_new0 (OstreeKernelLayout, 1); @@ -1025,18 +947,18 @@ _ostree_kernel_layout_new (void) /* See get_kernel_from_tree() below */ static gboolean -get_kernel_from_tree_usrlib_modules (OstreeSysroot *sysroot, - int deployment_dfd, - OstreeKernelLayout **out_layout, - GCancellable *cancellable, - GError **error) +get_kernel_from_tree_usrlib_modules (OstreeSysroot *sysroot, int deployment_dfd, + OstreeKernelLayout **out_layout, GCancellable *cancellable, + GError **error) { g_autofree char *kver = NULL; /* Look in usr/lib/modules */ - g_auto(GLnxDirFdIterator) mod_dfditer = { 0, }; + g_auto (GLnxDirFdIterator) mod_dfditer = { + 0, + }; gboolean exists; - if (!ot_dfd_iter_init_allow_noent (deployment_dfd, "usr/lib/modules", &mod_dfditer, - &exists, error)) + if (!ot_dfd_iter_init_allow_noent (deployment_dfd, "usr/lib/modules", &mod_dfditer, &exists, + error)) return FALSE; if (!exists) { @@ -1045,10 +967,10 @@ get_kernel_from_tree_usrlib_modules (OstreeSysroot *sysroot, return TRUE; } - g_autoptr(OstreeKernelLayout) ret_layout = _ostree_kernel_layout_new (); + g_autoptr (OstreeKernelLayout) ret_layout = _ostree_kernel_layout_new (); /* Reusable buffer for path string */ - g_autoptr(GString) pathbuf = g_string_new (""); + g_autoptr (GString) pathbuf = g_string_new (""); /* Loop until we find something that looks like a valid /usr/lib/modules/$kver */ while (ret_layout->boot_dfd == -1) { @@ -1095,13 +1017,15 @@ get_kernel_from_tree_usrlib_modules (OstreeSysroot *sysroot, } /* We found a module directory, compute the checksum */ - g_auto(OtChecksum) checksum = { 0, }; + g_auto (OtChecksum) checksum = { + 0, + }; ot_checksum_init (&checksum); glnx_autofd int fd = -1; /* Checksum the kernel */ if (!glnx_openat_rdonly (ret_layout->boot_dfd, "vmlinuz", TRUE, &fd, error)) return FALSE; - g_autoptr(GInputStream) in = g_unix_input_stream_new (fd, FALSE); + g_autoptr (GInputStream) in = g_unix_input_stream_new (fd, FALSE); if (!ot_gio_splice_update_checksum (NULL, in, &checksum, cancellable, error)) return FALSE; g_clear_object (&in); @@ -1111,9 +1035,9 @@ get_kernel_from_tree_usrlib_modules (OstreeSysroot *sysroot, * for this, let's be a bit conservative and support both `initramfs.img` and * `initramfs`. */ - const char *initramfs_paths[] = {"initramfs.img", "initramfs"}; + const char *initramfs_paths[] = { "initramfs.img", "initramfs" }; const char *initramfs_path = NULL; - for (guint i = 0; i < G_N_ELEMENTS(initramfs_paths); i++) + for (guint i = 0; i < G_N_ELEMENTS (initramfs_paths); i++) { initramfs_path = initramfs_paths[i]; if (!ot_openat_ignore_enoent (ret_layout->boot_dfd, initramfs_path, &fd, error)) @@ -1155,8 +1079,8 @@ get_kernel_from_tree_usrlib_modules (OstreeSysroot *sysroot, if (!no_dtb) { /* Check for /usr/lib/modules/$kver/devicetree first, if it does not - * exist check for /usr/lib/modules/$kver/dtb/ directory. - */ + * exist check for /usr/lib/modules/$kver/dtb/ directory. + */ if (!ot_openat_ignore_enoent (ret_layout->boot_dfd, "devicetree", &fd, error)) return FALSE; if (fd != -1) @@ -1180,7 +1104,8 @@ get_kernel_from_tree_usrlib_modules (OstreeSysroot *sysroot, ret_layout->devicetree_srcpath = g_strdup ("dtb"); ret_layout->devicetree_namever = NULL; - if (!checksum_dir_recurse(ret_layout->boot_dfd, "dtb", &checksum, cancellable, error)) + if (!checksum_dir_recurse (ret_layout->boot_dfd, "dtb", &checksum, cancellable, + error)) return FALSE; } } @@ -1194,11 +1119,13 @@ get_kernel_from_tree_usrlib_modules (OstreeSysroot *sysroot, if (errno == 0) { ret_layout->kernel_hmac_srcpath = g_strdup (".vmlinuz.hmac"); - /* Name it as dracut expects it: https://github.com/dracutdevs/dracut/blob/225e4b94cbdb702cf512490dcd2ad9ca5f5b22c1/modules.d/01fips/fips.sh#L129 */ + /* Name it as dracut expects it: + * https://github.com/dracutdevs/dracut/blob/225e4b94cbdb702cf512490dcd2ad9ca5f5b22c1/modules.d/01fips/fips.sh#L129 + */ ret_layout->kernel_hmac_namever = g_strdup_printf (".%s.hmac", ret_layout->kernel_namever); } - char hexdigest[OSTREE_SHA256_STRING_LEN+1]; + char hexdigest[OSTREE_SHA256_STRING_LEN + 1]; ot_checksum_get_hexdigest (&checksum, hexdigest, sizeof (hexdigest)); ret_layout->bootcsum = g_strdup (hexdigest); @@ -1208,16 +1135,14 @@ get_kernel_from_tree_usrlib_modules (OstreeSysroot *sysroot, /* See get_kernel_from_tree() below */ static gboolean -get_kernel_from_tree_legacy_layouts (int deployment_dfd, - OstreeKernelLayout **out_layout, - GCancellable *cancellable, - GError **error) +get_kernel_from_tree_legacy_layouts (int deployment_dfd, OstreeKernelLayout **out_layout, + GCancellable *cancellable, GError **error) { - const char *legacy_paths[] = {"usr/lib/ostree-boot", "boot"}; + const char *legacy_paths[] = { "usr/lib/ostree-boot", "boot" }; g_autofree char *kernel_checksum = NULL; g_autofree char *initramfs_checksum = NULL; g_autofree char *devicetree_checksum = NULL; - g_autoptr(OstreeKernelLayout) ret_layout = _ostree_kernel_layout_new (); + g_autoptr (OstreeKernelLayout) ret_layout = _ostree_kernel_layout_new (); for (guint i = 0; i < G_N_ELEMENTS (legacy_paths); i++) { @@ -1242,7 +1167,9 @@ get_kernel_from_tree_legacy_layouts (int deployment_dfd, /* ret_layout->boot_dfd will point to either /usr/lib/ostree-boot or /boot, let's * inspect it. */ - g_auto(GLnxDirFdIterator) dfditer = { 0, }; + g_auto (GLnxDirFdIterator) dfditer = { + 0, + }; if (!glnx_dirfd_iterator_init_at (ret_layout->boot_dfd, ".", FALSE, &dfditer, error)) return FALSE; @@ -1297,9 +1224,8 @@ get_kernel_from_tree_legacy_layouts (int deployment_dfd, } /* If we found a kernel, an initramfs and a devicetree, break out of the loop */ - if (ret_layout->kernel_srcpath != NULL && - ret_layout->initramfs_srcpath != NULL && - ret_layout->devicetree_srcpath != NULL) + if (ret_layout->kernel_srcpath != NULL && ret_layout->initramfs_srcpath != NULL + && ret_layout->devicetree_srcpath != NULL) break; } @@ -1353,17 +1279,15 @@ get_kernel_from_tree_legacy_layouts (int deployment_dfd, * initramfs there, so we need to look in /usr/lib/ostree-boot first. */ static gboolean -get_kernel_from_tree (OstreeSysroot *sysroot, - int deployment_dfd, - OstreeKernelLayout **out_layout, - GCancellable *cancellable, - GError **error) +get_kernel_from_tree (OstreeSysroot *sysroot, int deployment_dfd, OstreeKernelLayout **out_layout, + GCancellable *cancellable, GError **error) { - g_autoptr(OstreeKernelLayout) usrlib_modules_layout = NULL; - g_autoptr(OstreeKernelLayout) legacy_layout = NULL; + g_autoptr (OstreeKernelLayout) usrlib_modules_layout = NULL; + g_autoptr (OstreeKernelLayout) legacy_layout = NULL; /* First, gather from usr/lib/modules/$kver if it exists */ - if (!get_kernel_from_tree_usrlib_modules (sysroot, deployment_dfd, &usrlib_modules_layout, cancellable, error)) + if (!get_kernel_from_tree_usrlib_modules (sysroot, deployment_dfd, &usrlib_modules_layout, + cancellable, error)) return FALSE; /* Gather the legacy layout */ @@ -1393,9 +1317,8 @@ get_kernel_from_tree (OstreeSysroot *sysroot, return TRUE; } } - else if (usrlib_modules_layout != NULL && - usrlib_modules_layout->initramfs_srcpath == NULL && - legacy_layout->initramfs_srcpath != NULL) + else if (usrlib_modules_layout != NULL && usrlib_modules_layout->initramfs_srcpath == NULL + && legacy_layout->initramfs_srcpath != NULL) { /* Does the module path not have an initramfs, but the legacy does? Prefer * the latter then, to make rpm-ostree work as is today. @@ -1428,10 +1351,7 @@ get_kernel_from_tree (OstreeSysroot *sysroot, * https://github.com/ostreedev/ostree/pull/1049 */ static gboolean -fsfreeze_thaw_cycle (OstreeSysroot *self, - int rootfs_dfd, - GCancellable *cancellable, - GError **error) +fsfreeze_thaw_cycle (OstreeSysroot *self, int rootfs_dfd, GCancellable *cancellable, GError **error) { GLNX_AUTO_PREFIX_ERROR ("During fsfreeze-thaw", error); @@ -1445,7 +1365,7 @@ fsfreeze_thaw_cycle (OstreeSysroot *self, if (pid < 0) return glnx_throw_errno_prefix (error, "fork"); - const gboolean debug_fifreeze = (self->debug_flags & OSTREE_SYSROOT_DEBUG_TEST_FIFREEZE)>0; + const gboolean debug_fifreeze = (self->debug_flags & OSTREE_SYSROOT_DEBUG_TEST_FIFREEZE) > 0; char c = '!'; if (pid == 0) /* Child watchdog/unfreezer process. */ { @@ -1571,14 +1491,16 @@ fsfreeze_thaw_cycle (OstreeSysroot *self, return TRUE; } -typedef struct { +typedef struct +{ guint64 root_syncfs_msec; guint64 boot_syncfs_msec; guint64 extra_syncfs_msec; } SyncStats; -typedef struct { - int ref_count; /* atomic */ +typedef struct +{ + int ref_count; /* atomic */ bool success; GMutex mutex; GCond cond; @@ -1615,10 +1537,8 @@ sync_in_thread (void *ptr) * `sync()`. */ static gboolean -full_system_sync (OstreeSysroot *self, - SyncStats *out_stats, - GCancellable *cancellable, - GError **error) +full_system_sync (OstreeSysroot *self, SyncStats *out_stats, GCancellable *cancellable, + GError **error) { GLNX_AUTO_PREFIX_ERROR ("Full sync", error); guint64 start_msec = g_get_monotonic_time () / 1000; @@ -1628,7 +1548,7 @@ full_system_sync (OstreeSysroot *self, out_stats->root_syncfs_msec = (end_msec - start_msec); - if (!_ostree_sysroot_ensure_boot_fd (self, error)) + if (!_ostree_sysroot_ensure_boot_fd (self, error)) return FALSE; start_msec = g_get_monotonic_time () / 1000; @@ -1694,11 +1614,8 @@ full_system_sync (OstreeSysroot *self, * These new links are made active by swap_bootlinks(). */ static gboolean -create_new_bootlinks (OstreeSysroot *self, - int bootversion, - GPtrArray *new_deployments, - GCancellable *cancellable, - GError **error) +create_new_bootlinks (OstreeSysroot *self, int bootversion, GPtrArray *new_deployments, + GCancellable *cancellable, GError **error) { GLNX_AUTO_PREFIX_ERROR ("Creating new current bootlinks", error); glnx_autofd int ostree_dfd = -1; @@ -1720,7 +1637,8 @@ create_new_bootlinks (OstreeSysroot *self, /* Create the "subbootdir", which is a directory holding a symlink farm pointing to * deployments per-osname. */ - g_autofree char *ostree_subbootdir_name = g_strdup_printf ("boot.%d.%d", bootversion, new_subbootversion); + g_autofree char *ostree_subbootdir_name + = g_strdup_printf ("boot.%d.%d", bootversion, new_subbootversion); if (!glnx_shutil_rm_rf_at (ostree_dfd, ostree_subbootdir_name, cancellable, error)) return FALSE; if (!glnx_shutil_mkdir_p_at (ostree_dfd, ostree_subbootdir_name, 0755, cancellable, error)) @@ -1733,17 +1651,17 @@ create_new_bootlinks (OstreeSysroot *self, for (guint i = 0; i < new_deployments->len; i++) { OstreeDeployment *deployment = new_deployments->pdata[i]; - g_autofree char *bootlink_parent = g_strconcat (ostree_deployment_get_osname (deployment), - "/", - ostree_deployment_get_bootcsum (deployment), - NULL); - g_autofree char *bootlink_pathname = g_strdup_printf ("%s/%d", bootlink_parent, ostree_deployment_get_bootserial (deployment)); - g_autofree char *bootlink_target = g_strdup_printf ("../../../deploy/%s/deploy/%s.%d", - ostree_deployment_get_osname (deployment), - ostree_deployment_get_csum (deployment), - ostree_deployment_get_deployserial (deployment)); - - if (!glnx_shutil_mkdir_p_at (ostree_subbootdir_dfd, bootlink_parent, 0755, cancellable, error)) + g_autofree char *bootlink_parent + = g_strconcat (ostree_deployment_get_osname (deployment), "/", + ostree_deployment_get_bootcsum (deployment), NULL); + g_autofree char *bootlink_pathname = g_strdup_printf ( + "%s/%d", bootlink_parent, ostree_deployment_get_bootserial (deployment)); + g_autofree char *bootlink_target = g_strdup_printf ( + "../../../deploy/%s/deploy/%s.%d", ostree_deployment_get_osname (deployment), + ostree_deployment_get_csum (deployment), ostree_deployment_get_deployserial (deployment)); + + if (!glnx_shutil_mkdir_p_at (ostree_subbootdir_dfd, bootlink_parent, 0755, cancellable, + error)) return FALSE; if (!symlink_at_replace (bootlink_target, ostree_subbootdir_dfd, bootlink_pathname, @@ -1757,12 +1675,8 @@ create_new_bootlinks (OstreeSysroot *self, /* Rename into place symlinks created via create_new_bootlinks(). */ static gboolean -swap_bootlinks (OstreeSysroot *self, - int bootversion, - GPtrArray *new_deployments, - char **out_subbootdir, - GCancellable *cancellable, - GError **error) +swap_bootlinks (OstreeSysroot *self, int bootversion, GPtrArray *new_deployments, + char **out_subbootdir, GCancellable *cancellable, GError **error) { GLNX_AUTO_PREFIX_ERROR ("Swapping new version bootlinks", error); glnx_autofd int ostree_dfd = -1; @@ -1781,9 +1695,10 @@ swap_bootlinks (OstreeSysroot *self, int new_subbootversion = old_subbootversion == 0 ? 1 : 0; g_autofree char *ostree_bootdir_name = g_strdup_printf ("boot.%d", bootversion); - g_autofree char *ostree_subbootdir_name = g_strdup_printf ("boot.%d.%d", bootversion, new_subbootversion); - if (!symlink_at_replace (ostree_subbootdir_name, ostree_dfd, ostree_bootdir_name, - cancellable, error)) + g_autofree char *ostree_subbootdir_name + = g_strdup_printf ("boot.%d.%d", bootversion, new_subbootversion); + if (!symlink_at_replace (ostree_subbootdir_name, ostree_dfd, ostree_bootdir_name, cancellable, + error)) return FALSE; if (out_subbootdir) *out_subbootdir = g_steal_pointer (&ostree_subbootdir_name); @@ -1791,8 +1706,7 @@ swap_bootlinks (OstreeSysroot *self, } static GHashTable * -parse_os_release (const char *contents, - const char *split) +parse_os_release (const char *contents, const char *split) { g_autofree char **lines = g_strsplit (contents, split, -1); GHashTable *ret = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); @@ -1825,44 +1739,37 @@ parse_os_release (const char *contents, * /boot/loader/entries. */ static gboolean -install_deployment_kernel (OstreeSysroot *sysroot, - int new_bootversion, - OstreeDeployment *deployment, - guint n_deployments, - gboolean show_osname, - GCancellable *cancellable, - GError **error) +install_deployment_kernel (OstreeSysroot *sysroot, int new_bootversion, + OstreeDeployment *deployment, guint n_deployments, gboolean show_osname, + GCancellable *cancellable, GError **error) { GLNX_AUTO_PREFIX_ERROR ("Installing kernel", error); OstreeBootconfigParser *bootconfig = ostree_deployment_get_bootconfig (deployment); g_autofree char *deployment_dirpath = ostree_sysroot_get_deployment_dirpath (sysroot, deployment); glnx_autofd int deployment_dfd = -1; - if (!glnx_opendirat (sysroot->sysroot_fd, deployment_dirpath, FALSE, - &deployment_dfd, error)) + if (!glnx_opendirat (sysroot->sysroot_fd, deployment_dirpath, FALSE, &deployment_dfd, error)) return FALSE; /* We need to label the kernels */ - g_autoptr(OstreeSePolicy) sepolicy = ostree_sepolicy_new_at (deployment_dfd, cancellable, error); + g_autoptr (OstreeSePolicy) sepolicy = ostree_sepolicy_new_at (deployment_dfd, cancellable, error); if (!sepolicy) return FALSE; /* Find the kernel/initramfs/devicetree in the tree */ - g_autoptr(OstreeKernelLayout) kernel_layout = NULL; - if (!get_kernel_from_tree (sysroot, deployment_dfd, &kernel_layout, - cancellable, error)) + g_autoptr (OstreeKernelLayout) kernel_layout = NULL; + if (!get_kernel_from_tree (sysroot, deployment_dfd, &kernel_layout, cancellable, error)) return FALSE; - if (!_ostree_sysroot_ensure_boot_fd (sysroot, error)) + if (!_ostree_sysroot_ensure_boot_fd (sysroot, error)) return FALSE; const char *osname = ostree_deployment_get_osname (deployment); const char *bootcsum = ostree_deployment_get_bootcsum (deployment); g_autofree char *bootcsumdir = g_strdup_printf ("ostree/%s-%s", osname, bootcsum); g_autofree char *bootconfdir = g_strdup_printf ("loader.%d/entries", new_bootversion); - g_autofree char *bootconf_name = g_strdup_printf ("ostree-%d-%s.conf", - n_deployments - ostree_deployment_get_index (deployment), - osname); + g_autofree char *bootconf_name = g_strdup_printf ( + "ostree-%d-%s.conf", n_deployments - ostree_deployment_get_index (deployment), osname); if (!glnx_shutil_mkdir_p_at (sysroot->boot_fd, bootcsumdir, 0775, cancellable, error)) return FALSE; @@ -1885,9 +1792,9 @@ install_deployment_kernel (OstreeSysroot *sysroot, return FALSE; if (errno == ENOENT) { - if (!install_into_boot (repo, sepolicy, kernel_layout->boot_dfd, kernel_layout->kernel_srcpath, - bootcsum_dfd, kernel_layout->kernel_namever, - cancellable, error)) + if (!install_into_boot (repo, sepolicy, kernel_layout->boot_dfd, + kernel_layout->kernel_srcpath, bootcsum_dfd, + kernel_layout->kernel_namever, cancellable, error)) return FALSE; } @@ -1897,13 +1804,14 @@ install_deployment_kernel (OstreeSysroot *sysroot, if (kernel_layout->initramfs_srcpath) { g_assert (kernel_layout->initramfs_namever); - if (!glnx_fstatat_allow_noent (bootcsum_dfd, kernel_layout->initramfs_namever, &stbuf, 0, error)) + if (!glnx_fstatat_allow_noent (bootcsum_dfd, kernel_layout->initramfs_namever, &stbuf, 0, + error)) return FALSE; if (errno == ENOENT) { - if (!install_into_boot (repo, sepolicy, kernel_layout->boot_dfd, kernel_layout->initramfs_srcpath, - bootcsum_dfd, kernel_layout->initramfs_namever, - cancellable, error)) + if (!install_into_boot (repo, sepolicy, kernel_layout->boot_dfd, + kernel_layout->initramfs_srcpath, bootcsum_dfd, + kernel_layout->initramfs_namever, cancellable, error)) return FALSE; } } @@ -1913,33 +1821,36 @@ install_deployment_kernel (OstreeSysroot *sysroot, /* If devicetree_namever is set a single device tree is deployed */ if (kernel_layout->devicetree_namever) { - if (!glnx_fstatat_allow_noent (bootcsum_dfd, kernel_layout->devicetree_namever, &stbuf, 0, error)) + if (!glnx_fstatat_allow_noent (bootcsum_dfd, kernel_layout->devicetree_namever, &stbuf, 0, + error)) return FALSE; if (errno == ENOENT) { - if (!install_into_boot (repo, sepolicy, kernel_layout->boot_dfd, kernel_layout->devicetree_srcpath, - bootcsum_dfd, kernel_layout->devicetree_namever, - cancellable, error)) + if (!install_into_boot (repo, sepolicy, kernel_layout->boot_dfd, + kernel_layout->devicetree_srcpath, bootcsum_dfd, + kernel_layout->devicetree_namever, cancellable, error)) return FALSE; } } else { - if (!copy_dir_recurse (kernel_layout->boot_dfd, bootcsum_dfd, kernel_layout->devicetree_srcpath, - sysroot->debug_flags, cancellable, error)) + if (!copy_dir_recurse (kernel_layout->boot_dfd, bootcsum_dfd, + kernel_layout->devicetree_srcpath, sysroot->debug_flags, + cancellable, error)) return FALSE; } } if (kernel_layout->kernel_hmac_srcpath) { - if (!glnx_fstatat_allow_noent (bootcsum_dfd, kernel_layout->kernel_hmac_namever, &stbuf, 0, error)) + if (!glnx_fstatat_allow_noent (bootcsum_dfd, kernel_layout->kernel_hmac_namever, &stbuf, 0, + error)) return FALSE; if (errno == ENOENT) { - if (!install_into_boot (repo, sepolicy, kernel_layout->boot_dfd, kernel_layout->kernel_hmac_srcpath, - bootcsum_dfd, kernel_layout->kernel_hmac_namever, - cancellable, error)) + if (!install_into_boot (repo, sepolicy, kernel_layout->boot_dfd, + kernel_layout->kernel_hmac_srcpath, bootcsum_dfd, + kernel_layout->kernel_hmac_namever, cancellable, error)) return FALSE; } } @@ -1952,16 +1863,16 @@ install_deployment_kernel (OstreeSysroot *sysroot, if (errno == ENOENT) { - if (!install_into_boot (repo, sepolicy, kernel_layout->boot_dfd, kernel_layout->aboot_srcpath, - bootcsum_dfd, kernel_layout->aboot_namever, - cancellable, error)) + if (!install_into_boot (repo, sepolicy, kernel_layout->boot_dfd, + kernel_layout->aboot_srcpath, bootcsum_dfd, + kernel_layout->aboot_namever, cancellable, error)) return FALSE; } } /* NOTE: if adding more things in bootcsum_dfd, also update get_kernel_layout_size() */ - g_autoptr(GPtrArray) overlay_initrds = NULL; + g_autoptr (GPtrArray) overlay_initrds = NULL; for (char **it = _ostree_deployment_get_overlay_initrds (deployment); it && *it; it++) { char *checksum = *it; @@ -1973,8 +1884,8 @@ install_deployment_kernel (OstreeSysroot *sysroot, * across different boocsums). Eventually, it'd be nice to have an OSTree repo in * /boot itself and drop the boocsum dir concept entirely. */ - g_autofree char *destpath = - g_strdup_printf ("%s%s/%s.img", bootprefix, _OSTREE_SYSROOT_BOOT_INITRAMFS_OVERLAYS, checksum); + g_autofree char *destpath = g_strdup_printf ( + "%s%s/%s.img", bootprefix, _OSTREE_SYSROOT_BOOT_INITRAMFS_OVERLAYS, checksum); const char *rel_destpath = destpath + 1; /* lazily allocate array and create dir so we don't pollute /boot if not needed */ @@ -1991,8 +1902,8 @@ install_deployment_kernel (OstreeSysroot *sysroot, return FALSE; if (errno == ENOENT) { - g_autofree char *srcpath = - g_strdup_printf (_OSTREE_SYSROOT_RUNSTATE_STAGED_INITRDS_DIR "/%s", checksum); + g_autofree char *srcpath + = g_strdup_printf (_OSTREE_SYSROOT_RUNSTATE_STAGED_INITRDS_DIR "/%s", checksum); if (!install_into_boot (repo, sepolicy, AT_FDCWD, srcpath, sysroot->boot_fd, rel_destpath, cancellable, error)) return FALSE; @@ -2020,11 +1931,11 @@ install_deployment_kernel (OstreeSysroot *sysroot, return glnx_prefix_error (error, "Reading /usr/lib/os-release"); } - g_autoptr(GHashTable) osrelease_values = parse_os_release (contents, "\n"); + g_autoptr (GHashTable) osrelease_values = parse_os_release (contents, "\n"); /* title */ const char *val = g_hash_table_lookup (osrelease_values, "PRETTY_NAME"); if (val == NULL) - val = g_hash_table_lookup (osrelease_values, "ID"); + val = g_hash_table_lookup (osrelease_values, "ID"); if (val == NULL) return glnx_throw (error, "No PRETTY_NAME or ID in /etc/os-release"); @@ -2033,24 +1944,24 @@ install_deployment_kernel (OstreeSysroot *sysroot, { /* Try extracting a version for this deployment. */ const char *csum = ostree_deployment_get_csum (deployment); - g_autoptr(GVariant) variant = NULL; - g_autoptr(GVariant) metadata = NULL; + g_autoptr (GVariant) variant = NULL; + g_autoptr (GVariant) metadata = NULL; /* XXX Copying ot_admin_checksum_version() + bits from * ot-admin-builtin-status.c. Maybe this should be * public API in libostree? */ - if (ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT, csum, - &variant, NULL)) + if (ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT, csum, &variant, NULL)) { metadata = g_variant_get_child_value (variant, 0); - (void) g_variant_lookup (metadata, OSTREE_COMMIT_META_KEY_VERSION, "s", &deployment_version); + (void)g_variant_lookup (metadata, OSTREE_COMMIT_META_KEY_VERSION, "s", + &deployment_version); } } /* XXX The SYSLINUX bootloader backend actually parses the title string * (specifically, it looks for the substring "(ostree"), so further * changes to the title format may require updating that backend. */ - g_autoptr(GString) title_key = g_string_new (val); + g_autoptr (GString) title_key = g_string_new (val); if (deployment_version && *deployment_version && !strstr (val, deployment_version)) { g_string_append_c (title_key, ' '); @@ -2068,36 +1979,39 @@ install_deployment_kernel (OstreeSysroot *sysroot, g_string_append_c (title_key, ')'); ostree_bootconfig_parser_set (bootconfig, "title", title_key->str); - g_autofree char *version_key = g_strdup_printf ("%d", n_deployments - ostree_deployment_get_index (deployment)); + g_autofree char *version_key + = g_strdup_printf ("%d", n_deployments - ostree_deployment_get_index (deployment)); ostree_bootconfig_parser_set (bootconfig, OSTREE_COMMIT_META_KEY_VERSION, version_key); - g_autofree char * boot_relpath = g_strconcat (bootprefix, bootcsumdir, "/", kernel_layout->kernel_namever, NULL); + g_autofree char *boot_relpath + = g_strconcat (bootprefix, bootcsumdir, "/", kernel_layout->kernel_namever, NULL); ostree_bootconfig_parser_set (bootconfig, "linux", boot_relpath); val = ostree_bootconfig_parser_get (bootconfig, "options"); - g_autoptr(OstreeKernelArgs) kargs = ostree_kernel_args_from_string (val); + g_autoptr (OstreeKernelArgs) kargs = ostree_kernel_args_from_string (val); if (kernel_layout->initramfs_namever) { - g_autofree char * initrd_boot_relpath = - g_strconcat (bootprefix, bootcsumdir, "/", kernel_layout->initramfs_namever, NULL); + g_autofree char *initrd_boot_relpath + = g_strconcat (bootprefix, bootcsumdir, "/", kernel_layout->initramfs_namever, NULL); ostree_bootconfig_parser_set (bootconfig, "initrd", initrd_boot_relpath); if (overlay_initrds) { g_ptr_array_add (overlay_initrds, NULL); - ostree_bootconfig_parser_set_overlay_initrds (bootconfig, (char**)overlay_initrds->pdata); + ostree_bootconfig_parser_set_overlay_initrds (bootconfig, + (char **)overlay_initrds->pdata); } } else { g_autofree char *prepare_root_arg = NULL; - prepare_root_arg = g_strdup_printf ("init=/ostree/boot.%d/%s/%s/%d/usr/lib/ostree/ostree-prepare-root", - new_bootversion, osname, bootcsum, - ostree_deployment_get_bootserial (deployment)); + prepare_root_arg = g_strdup_printf ( + "init=/ostree/boot.%d/%s/%s/%d/usr/lib/ostree/ostree-prepare-root", new_bootversion, + osname, bootcsum, ostree_deployment_get_bootserial (deployment)); ostree_kernel_args_replace_take (kargs, g_steal_pointer (&prepare_root_arg)); } - const char* aboot_fn = NULL; + const char *aboot_fn = NULL; if (kernel_layout->aboot_namever) { aboot_fn = kernel_layout->aboot_namever; @@ -2109,21 +2023,24 @@ install_deployment_kernel (OstreeSysroot *sysroot, if (aboot_fn) { - g_autofree char * aboot_relpath = g_strconcat ("/", bootcsumdir, "/", aboot_fn, NULL); + g_autofree char *aboot_relpath = g_strconcat ("/", bootcsumdir, "/", aboot_fn, NULL); ostree_bootconfig_parser_set (bootconfig, "aboot", aboot_relpath); } else { - g_autofree char * aboot_relpath = g_strconcat ("/", deployment_dirpath, "/usr/lib/ostree-boot/aboot.img", NULL); + g_autofree char *aboot_relpath + = g_strconcat ("/", deployment_dirpath, "/usr/lib/ostree-boot/aboot.img", NULL); ostree_bootconfig_parser_set (bootconfig, "aboot", aboot_relpath); } - g_autofree char * abootcfg_relpath = g_strconcat ("/", deployment_dirpath, "/usr/lib/ostree-boot/aboot.cfg", NULL); + g_autofree char *abootcfg_relpath + = g_strconcat ("/", deployment_dirpath, "/usr/lib/ostree-boot/aboot.cfg", NULL); ostree_bootconfig_parser_set (bootconfig, "abootcfg", abootcfg_relpath); if (kernel_layout->devicetree_namever) { - g_autofree char * dt_boot_relpath = g_strconcat (bootprefix, bootcsumdir, "/", kernel_layout->devicetree_namever, NULL); + g_autofree char *dt_boot_relpath + = g_strconcat (bootprefix, bootcsumdir, "/", kernel_layout->devicetree_namever, NULL); ostree_bootconfig_parser_set (bootconfig, "devicetree", dt_boot_relpath); } else if (kernel_layout->devicetree_srcpath) @@ -2132,14 +2049,15 @@ install_deployment_kernel (OstreeSysroot *sysroot, * want to point to a whole directory of device trees. * See: https://github.com/ostreedev/ostree/issues/1900 */ - g_autofree char * dt_boot_relpath = g_strconcat (bootprefix, bootcsumdir, "/", kernel_layout->devicetree_srcpath, NULL); + g_autofree char *dt_boot_relpath + = g_strconcat (bootprefix, bootcsumdir, "/", kernel_layout->devicetree_srcpath, NULL); ostree_bootconfig_parser_set (bootconfig, "fdtdir", dt_boot_relpath); } /* Note this is parsed in ostree-impl-system-generator.c */ - g_autofree char *ostree_kernel_arg = g_strdup_printf ("ostree=/ostree/boot.%d/%s/%s/%d", - new_bootversion, osname, bootcsum, - ostree_deployment_get_bootserial (deployment)); + g_autofree char *ostree_kernel_arg + = g_strdup_printf ("ostree=/ostree/boot.%d/%s/%s/%d", new_bootversion, osname, bootcsum, + ostree_deployment_get_bootserial (deployment)); ostree_kernel_args_replace_take (kargs, g_steal_pointer (&ostree_kernel_arg)); g_autofree char *options_key = ostree_kernel_args_to_string (kargs); @@ -2148,7 +2066,7 @@ install_deployment_kernel (OstreeSysroot *sysroot, /* Only append to this BLS config if: * - this is not the default deployment */ - /* If deployment was prepended, it is the new default */ + /* If deployment was prepended, it is the new default */ gboolean is_new_default = (ostree_deployment_get_index (deployment) == 0); gboolean allow_append = !is_new_default; if (allow_append) @@ -2163,8 +2081,7 @@ install_deployment_kernel (OstreeSysroot *sysroot, return FALSE; if (!ostree_bootconfig_parser_write_at (ostree_deployment_get_bootconfig (deployment), - bootconf_dfd, bootconf_name, - cancellable, error)) + bootconf_dfd, bootconf_name, cancellable, error)) return FALSE; return TRUE; @@ -2175,15 +2092,12 @@ install_deployment_kernel (OstreeSysroot *sysroot, * rename it into place. */ static gboolean -prepare_new_bootloader_link (OstreeSysroot *sysroot, - int current_bootversion, - int new_bootversion, - GCancellable *cancellable, - GError **error) +prepare_new_bootloader_link (OstreeSysroot *sysroot, int current_bootversion, int new_bootversion, + GCancellable *cancellable, GError **error) { GLNX_AUTO_PREFIX_ERROR ("Preparing final bootloader swap", error); - g_assert ((current_bootversion == 0 && new_bootversion == 1) || - (current_bootversion == 1 && new_bootversion == 0)); + g_assert ((current_bootversion == 0 && new_bootversion == 1) + || (current_bootversion == 1 && new_bootversion == 0)); /* This allows us to support both /boot on a seperate filesystem to / as well * as on the same filesystem. */ @@ -2195,8 +2109,7 @@ prepare_new_bootloader_link (OstreeSysroot *sysroot, /* We shouldn't actually need to replace but it's easier to reuse that code */ - if (!symlink_at_replace (new_target, sysroot->sysroot_fd, "boot/loader.tmp", - cancellable, error)) + if (!symlink_at_replace (new_target, sysroot->sysroot_fd, "boot/loader.tmp", cancellable, error)) return FALSE; return TRUE; @@ -2204,19 +2117,15 @@ prepare_new_bootloader_link (OstreeSysroot *sysroot, /* Update the /boot/loader symlink to point to /boot/loader.$new_bootversion */ static gboolean -swap_bootloader (OstreeSysroot *sysroot, - OstreeBootloader *bootloader, - int current_bootversion, - int new_bootversion, - GCancellable *cancellable, - GError **error) +swap_bootloader (OstreeSysroot *sysroot, OstreeBootloader *bootloader, int current_bootversion, + int new_bootversion, GCancellable *cancellable, GError **error) { GLNX_AUTO_PREFIX_ERROR ("Final bootloader swap", error); - g_assert ((current_bootversion == 0 && new_bootversion == 1) || - (current_bootversion == 1 && new_bootversion == 0)); + g_assert ((current_bootversion == 0 && new_bootversion == 1) + || (current_bootversion == 1 && new_bootversion == 0)); - if (!_ostree_sysroot_ensure_boot_fd (sysroot, error)) + if (!_ostree_sysroot_ensure_boot_fd (sysroot, error)) return FALSE; /* The symlink was already written, and we used syncfs() to ensure @@ -2254,10 +2163,9 @@ swap_bootloader (OstreeSysroot *sysroot, * per-bootchecksum. It's used by the symbolic links after the bootloader. */ static void -assign_bootserials (GPtrArray *deployments) +assign_bootserials (GPtrArray *deployments) { - g_autoptr(GHashTable) serials = - g_hash_table_new_full (g_str_hash, g_str_equal, NULL, NULL); + g_autoptr (GHashTable) serials = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, NULL); for (guint i = 0; i < deployments->len; i++) { @@ -2265,36 +2173,34 @@ assign_bootserials (GPtrArray *deployments) const char *bootcsum = ostree_deployment_get_bootcsum (deployment); /* Note that not-found maps to NULL which converts to zero */ guint count = GPOINTER_TO_UINT (g_hash_table_lookup (serials, bootcsum)); - g_hash_table_replace (serials, (char*) bootcsum, - GUINT_TO_POINTER (count + 1)); + g_hash_table_replace (serials, (char *)bootcsum, GUINT_TO_POINTER (count + 1)); ostree_deployment_set_bootserial (deployment, count); } } -static char* +static char * get_deployment_nonostree_kargs (OstreeDeployment *deployment) { /* pick up kernel arguments but filter out ostree= */ OstreeBootconfigParser *bootconfig = ostree_deployment_get_bootconfig (deployment); const char *boot_options = ostree_bootconfig_parser_get (bootconfig, "options"); - g_autoptr(OstreeKernelArgs) kargs = ostree_kernel_args_from_string (boot_options); + g_autoptr (OstreeKernelArgs) kargs = ostree_kernel_args_from_string (boot_options); ostree_kernel_args_replace (kargs, "ostree"); return ostree_kernel_args_to_string (kargs); } -static char* -get_deployment_ostree_version (OstreeRepo *repo, - OstreeDeployment *deployment) +static char * +get_deployment_ostree_version (OstreeRepo *repo, OstreeDeployment *deployment) { const char *csum = ostree_deployment_get_csum (deployment); g_autofree char *version = NULL; - g_autoptr(GVariant) variant = NULL; + g_autoptr (GVariant) variant = NULL; if (ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT, csum, &variant, NULL)) { - g_autoptr(GVariant) metadata = g_variant_get_child_value (variant, 0); - (void) g_variant_lookup (metadata, OSTREE_COMMIT_META_KEY_VERSION, "s", &version); + g_autoptr (GVariant) metadata = g_variant_get_child_value (variant, 0); + (void)g_variant_lookup (metadata, OSTREE_COMMIT_META_KEY_VERSION, "s", &version); } return g_steal_pointer (&version); @@ -2310,9 +2216,7 @@ get_deployment_ostree_version (OstreeRepo *repo, * bootloader perspective. */ static gboolean -deployment_bootconfigs_equal (OstreeRepo *repo, - OstreeDeployment *a, - OstreeDeployment *b) +deployment_bootconfigs_equal (OstreeRepo *repo, OstreeDeployment *a, OstreeDeployment *b) { /* same kernel & initramfs? */ const char *a_bootcsum = ostree_deployment_get_bootcsum (a); @@ -2345,11 +2249,9 @@ deployment_bootconfigs_equal (OstreeRepo *repo, * the OSTree API to find deployments. */ static gboolean -cleanup_legacy_current_symlinks (OstreeSysroot *self, - GCancellable *cancellable, - GError **error) +cleanup_legacy_current_symlinks (OstreeSysroot *self, GCancellable *cancellable, GError **error) { - g_autoptr(GString) buf = g_string_new (""); + g_autoptr (GString) buf = g_string_new (""); for (guint i = 0; i < self->deployments->len; i++) { @@ -2377,14 +2279,12 @@ cleanup_legacy_current_symlinks (OstreeSysroot *self, * version will perform post-deployment cleanup by default. */ gboolean -ostree_sysroot_write_deployments (OstreeSysroot *self, - GPtrArray *new_deployments, - GCancellable *cancellable, - GError **error) +ostree_sysroot_write_deployments (OstreeSysroot *self, GPtrArray *new_deployments, + GCancellable *cancellable, GError **error) { OstreeSysrootWriteDeploymentsOpts opts = { .do_postclean = TRUE }; - return ostree_sysroot_write_deployments_with_options (self, new_deployments, &opts, - cancellable, error); + return ostree_sysroot_write_deployments_with_options (self, new_deployments, &opts, cancellable, + error); } /* Handle writing out a new bootloader config. One reason this needs to be a @@ -2392,22 +2292,18 @@ ostree_sysroot_write_deployments (OstreeSysroot *self, * rw. */ static gboolean -write_deployments_bootswap (OstreeSysroot *self, - GPtrArray *new_deployments, - OstreeSysrootWriteDeploymentsOpts *opts, - OstreeBootloader *bootloader, - SyncStats *out_syncstats, - char **out_subbootdir, - GCancellable *cancellable, - GError **error) +write_deployments_bootswap (OstreeSysroot *self, GPtrArray *new_deployments, + OstreeSysrootWriteDeploymentsOpts *opts, OstreeBootloader *bootloader, + SyncStats *out_syncstats, char **out_subbootdir, + GCancellable *cancellable, GError **error) { const int new_bootversion = self->bootversion ? 0 : 1; - g_autofree char* new_loader_entries_dir = g_strdup_printf ("boot/loader.%d/entries", new_bootversion); + g_autofree char *new_loader_entries_dir + = g_strdup_printf ("boot/loader.%d/entries", new_bootversion); if (!glnx_shutil_rm_rf_at (self->sysroot_fd, new_loader_entries_dir, cancellable, error)) return FALSE; - if (!glnx_shutil_mkdir_p_at (self->sysroot_fd, new_loader_entries_dir, 0755, - cancellable, error)) + if (!glnx_shutil_mkdir_p_at (self->sysroot_fd, new_loader_entries_dir, 0755, cancellable, error)) return FALSE; /* Only show the osname in bootloader titles if there are multiple @@ -2427,42 +2323,35 @@ write_deployments_bootswap (OstreeSysroot *self, for (guint i = 0; i < new_deployments->len; i++) { OstreeDeployment *deployment = new_deployments->pdata[i]; - if (!install_deployment_kernel (self, new_bootversion, - deployment, new_deployments->len, + if (!install_deployment_kernel (self, new_bootversion, deployment, new_deployments->len, show_osname, cancellable, error)) return FALSE; } /* Create and swap bootlinks for *new* version */ - if (!create_new_bootlinks (self, new_bootversion, - new_deployments, - cancellable, error)) + if (!create_new_bootlinks (self, new_bootversion, new_deployments, cancellable, error)) return FALSE; g_autofree char *new_subbootdir = NULL; - if (!swap_bootlinks (self, new_bootversion, new_deployments, &new_subbootdir, - cancellable, error)) + if (!swap_bootlinks (self, new_bootversion, new_deployments, &new_subbootdir, cancellable, error)) return FALSE; - g_debug ("Using bootloader: %s", bootloader ? - g_type_name (G_TYPE_FROM_INSTANCE (bootloader)) : "(none)"); + g_debug ("Using bootloader: %s", + bootloader ? g_type_name (G_TYPE_FROM_INSTANCE (bootloader)) : "(none)"); if (bootloader) { - if (!_ostree_bootloader_write_config (bootloader, new_bootversion, - new_deployments, cancellable, - error)) + if (!_ostree_bootloader_write_config (bootloader, new_bootversion, new_deployments, + cancellable, error)) return glnx_prefix_error (error, "Bootloader write config"); } - if (!prepare_new_bootloader_link (self, self->bootversion, new_bootversion, - cancellable, error)) + if (!prepare_new_bootloader_link (self, self->bootversion, new_bootversion, cancellable, error)) return FALSE; if (!full_system_sync (self, out_syncstats, cancellable, error)) return FALSE; - if (!swap_bootloader (self, bootloader, self->bootversion, new_bootversion, - cancellable, error)) + if (!swap_bootloader (self, bootloader, self->bootversion, new_bootversion, cancellable, error)) return FALSE; if (out_subbootdir) @@ -2472,9 +2361,7 @@ write_deployments_bootswap (OstreeSysroot *self, /* Actions taken after writing deployments is complete */ static gboolean -write_deployments_finish (OstreeSysroot *self, - GCancellable *cancellable, - GError **error) +write_deployments_finish (OstreeSysroot *self, GCancellable *cancellable, GError **error) { if (!_ostree_sysroot_bump_mtime (self, error)) return FALSE; @@ -2490,10 +2377,7 @@ write_deployments_finish (OstreeSysroot *self, } static gboolean -add_file_size_if_nonnull (int dfd, - const char *path, - guint64 *inout_size, - GError **error) +add_file_size_if_nonnull (int dfd, const char *path, guint64 *inout_size, GError **error) { if (path == NULL) return TRUE; @@ -2509,47 +2393,48 @@ add_file_size_if_nonnull (int dfd, /* calculates the total size of the bootcsum dir in /boot after we would copy * it. This reflects the logic in install_deployment_kernel(). */ static gboolean -get_kernel_layout_size (OstreeSysroot *self, - OstreeDeployment *deployment, - guint64 *out_size, - GCancellable *cancellable, - GError **error) +get_kernel_layout_size (OstreeSysroot *self, OstreeDeployment *deployment, guint64 *out_size, + GCancellable *cancellable, GError **error) { g_autofree char *deployment_dirpath = ostree_sysroot_get_deployment_dirpath (self, deployment); glnx_autofd int deployment_dfd = -1; - if (!glnx_opendirat (self->sysroot_fd, deployment_dirpath, FALSE, - &deployment_dfd, error)) + if (!glnx_opendirat (self->sysroot_fd, deployment_dirpath, FALSE, &deployment_dfd, error)) return FALSE; - g_autoptr(OstreeKernelLayout) kernel_layout = NULL; - if (!get_kernel_from_tree (self, deployment_dfd, &kernel_layout, - cancellable, error)) + g_autoptr (OstreeKernelLayout) kernel_layout = NULL; + if (!get_kernel_from_tree (self, deployment_dfd, &kernel_layout, cancellable, error)) return FALSE; guint64 bootdir_size = 0; - if (!add_file_size_if_nonnull (kernel_layout->boot_dfd, kernel_layout->kernel_srcpath, &bootdir_size, error)) + if (!add_file_size_if_nonnull (kernel_layout->boot_dfd, kernel_layout->kernel_srcpath, + &bootdir_size, error)) return FALSE; - if (!add_file_size_if_nonnull (kernel_layout->boot_dfd, kernel_layout->initramfs_srcpath, &bootdir_size, error)) + if (!add_file_size_if_nonnull (kernel_layout->boot_dfd, kernel_layout->initramfs_srcpath, + &bootdir_size, error)) return FALSE; if (kernel_layout->devicetree_srcpath) { /* These conditionals mirror the logic in install_deployment_kernel(). */ if (kernel_layout->devicetree_namever) { - if (!add_file_size_if_nonnull (kernel_layout->boot_dfd, kernel_layout->devicetree_srcpath, &bootdir_size, error)) + if (!add_file_size_if_nonnull (kernel_layout->boot_dfd, kernel_layout->devicetree_srcpath, + &bootdir_size, error)) return FALSE; } else { guint64 dirsize = 0; - if (!ot_get_dir_size (kernel_layout->boot_dfd, kernel_layout->devicetree_srcpath, &dirsize, cancellable, error)) + if (!ot_get_dir_size (kernel_layout->boot_dfd, kernel_layout->devicetree_srcpath, + &dirsize, cancellable, error)) return FALSE; bootdir_size += dirsize; } } - if (!add_file_size_if_nonnull (kernel_layout->boot_dfd, kernel_layout->kernel_hmac_srcpath, &bootdir_size, error)) + if (!add_file_size_if_nonnull (kernel_layout->boot_dfd, kernel_layout->kernel_hmac_srcpath, + &bootdir_size, error)) return FALSE; - if (!add_file_size_if_nonnull (kernel_layout->boot_dfd, kernel_layout->aboot_srcpath, &bootdir_size, error)) + if (!add_file_size_if_nonnull (kernel_layout->boot_dfd, kernel_layout->aboot_srcpath, + &bootdir_size, error)) return FALSE; *out_size = bootdir_size; @@ -2561,10 +2446,8 @@ get_kernel_layout_size (OstreeSysroot *self, * getting rotated out (e.g. the current rollback) would free up sufficient * space. If so, call ostree_sysroot_write_deployments() to delete them. */ static gboolean -auto_early_prune_old_deployments (OstreeSysroot *self, - GPtrArray *new_deployments, - GCancellable *cancellable, - GError **error) +auto_early_prune_old_deployments (OstreeSysroot *self, GPtrArray *new_deployments, + GCancellable *cancellable, GError **error) { /* If we're not booted into a deployment, then this is some kind of e.g. disk * creation/provisioning. The situation isn't as dire, so let's not resort to @@ -2588,12 +2471,14 @@ auto_early_prune_old_deployments (OstreeSysroot *self, return FALSE; /* tracks all the bootcsums currently in /boot */ - g_autoptr(GHashTable) current_bootcsums = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); + g_autoptr (GHashTable) current_bootcsums + = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); /* tracks all the bootcsums of new_deployments */ - g_autoptr(GHashTable) new_bootcsums = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); + g_autoptr (GHashTable) new_bootcsums + = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); - g_auto(GStrv) bootdirs = NULL; + g_auto (GStrv) bootdirs = NULL; if (!_ostree_sysroot_list_all_boot_directories (self, &bootdirs, cancellable, error)) return glnx_prefix_error (error, "listing bootcsum directories in bootfs"); @@ -2623,12 +2508,14 @@ auto_early_prune_old_deployments (OstreeSysroot *self, * size aware too for better accuracy, which is awkward since the * function itself is generic over directories and doesn't consider * e.g. mount points from different filesystems. */ - g_printerr ("bootcsum %s size exceeds %u; disabling auto-prune optimization\n", bootdir, G_MAXUINT); + g_printerr ("bootcsum %s size exceeds %u; disabling auto-prune optimization\n", bootdir, + G_MAXUINT); return TRUE; } g_assert_cmpuint (bootdir_size, >, 0); - g_hash_table_insert (current_bootcsums, g_steal_pointer (&bootcsum), GUINT_TO_POINTER (bootdir_size)); + g_hash_table_insert (current_bootcsums, g_steal_pointer (&bootcsum), + GUINT_TO_POINTER (bootdir_size)); } /* total size of all bootcsums dirs that aren't already in /boot */ @@ -2654,8 +2541,9 @@ auto_early_prune_old_deployments (OstreeSysroot *self, /* see similar logic in previous loop */ if (bootdir_size > G_MAXUINT) { - g_printerr ("deployment %s kernel layout size exceeds %u; disabling auto-prune optimization\n", - ostree_deployment_get_csum (deployment), G_MAXUINT); + g_printerr ( + "deployment %s kernel layout size exceeds %u; disabling auto-prune optimization\n", + ostree_deployment_get_csum (deployment), G_MAXUINT); return TRUE; } @@ -2696,7 +2584,7 @@ auto_early_prune_old_deployments (OstreeSysroot *self, g_printerr ("Insufficient space left in bootfs; updating bootloader in two steps\n"); /* Auto-pruning can salvage the situation. Calculate the set of deployments in common. */ - g_autoptr(GPtrArray) common_deployments = g_ptr_array_new (); + g_autoptr (GPtrArray) common_deployments = g_ptr_array_new (); for (guint i = 0; i < self->deployments->len; i++) { OstreeDeployment *deployment = self->deployments->pdata[i]; @@ -2719,8 +2607,10 @@ auto_early_prune_old_deployments (OstreeSysroot *self, * common deployments. To be safe, disable auto-pruning to make recursion * impossible (though the logic in this function shouldn't kick in anyway in * that recursive call). Disable cleaning since it's an intermediate stage. */ - OstreeSysrootWriteDeploymentsOpts opts = { .do_postclean = FALSE, .disable_auto_early_prune = TRUE }; - if (!ostree_sysroot_write_deployments_with_options (self, common_deployments, &opts, cancellable, error)) + OstreeSysrootWriteDeploymentsOpts opts + = { .do_postclean = FALSE, .disable_auto_early_prune = TRUE }; + if (!ostree_sysroot_write_deployments_with_options (self, common_deployments, &opts, cancellable, + error)) return FALSE; /* clean up /boot */ @@ -2748,11 +2638,9 @@ auto_early_prune_old_deployments (OstreeSysroot *self, * Since: 2017.4 */ gboolean -ostree_sysroot_write_deployments_with_options (OstreeSysroot *self, - GPtrArray *new_deployments, +ostree_sysroot_write_deployments_with_options (OstreeSysroot *self, GPtrArray *new_deployments, OstreeSysrootWriteDeploymentsOpts *opts, - GCancellable *cancellable, - GError **error) + GCancellable *cancellable, GError **error) { g_assert (self->loadstate == OSTREE_SYSROOT_LOAD_STATE_LOADED); @@ -2761,8 +2649,8 @@ ostree_sysroot_write_deployments_with_options (OstreeSysroot *self, /* for now, this is gated on an environment variable */ const gboolean opted_in = (self->opt_flags & OSTREE_SYSROOT_GLOBAL_OPT_EARLY_PRUNE) > 0; - if (opted_in && !opts->disable_auto_early_prune && - !auto_early_prune_old_deployments (self, new_deployments, cancellable, error)) + if (opted_in && !opts->disable_auto_early_prune + && !auto_early_prune_old_deployments (self, new_deployments, cancellable, error)) return FALSE; /* Dealing with the staged deployment is quite tricky here. This function is @@ -2773,7 +2661,7 @@ ostree_sysroot_write_deployments_with_options (OstreeSysroot *self, * silently dropped. */ - g_autoptr(GPtrArray) new_deployments_copy = g_ptr_array_new (); + g_autoptr (GPtrArray) new_deployments_copy = g_ptr_array_new (); gboolean removed_staged = (self->staged_deployment != NULL); if (new_deployments->len > 0) { @@ -2882,7 +2770,8 @@ ostree_sysroot_write_deployments_with_options (OstreeSysroot *self, if (ostree_deployment_equal (deployment, self->booted_deployment)) found_booted_deployment = TRUE; - g_autoptr(GFile) deployment_root = ostree_sysroot_get_deployment_directory (self, deployment); + g_autoptr (GFile) deployment_root + = ostree_sysroot_get_deployment_directory (self, deployment); if (!g_file_query_exists (deployment_root, NULL)) return glnx_throw (error, "Unable to find expected deployment root: %s", gs_file_get_path_cached (deployment_root)); @@ -2894,22 +2783,21 @@ ostree_sysroot_write_deployments_with_options (OstreeSysroot *self, return glnx_throw (error, "Attempting to remove booted deployment"); gboolean bootloader_is_atomic = FALSE; - SyncStats syncstats = { 0, }; - g_autoptr(OstreeBootloader) bootloader = NULL; + SyncStats syncstats = { + 0, + }; + g_autoptr (OstreeBootloader) bootloader = NULL; g_autofree char *new_subbootdir = NULL; if (!requires_new_bootversion) { - if (!create_new_bootlinks (self, self->bootversion, - new_deployments, - cancellable, error)) + if (!create_new_bootlinks (self, self->bootversion, new_deployments, cancellable, error)) return FALSE; if (!full_system_sync (self, &syncstats, cancellable, error)) return FALSE; - if (!swap_bootlinks (self, self->bootversion, - new_deployments, &new_subbootdir, - cancellable, error)) + if (!swap_bootlinks (self, self->bootversion, new_deployments, &new_subbootdir, cancellable, + error)) return FALSE; bootloader_is_atomic = TRUE; @@ -2921,29 +2809,28 @@ ostree_sysroot_write_deployments_with_options (OstreeSysroot *self, bootloader_is_atomic = bootloader != NULL && _ostree_bootloader_is_atomic (bootloader); - if (!write_deployments_bootswap (self, new_deployments, opts, bootloader, - &syncstats, &new_subbootdir, cancellable, error)) + if (!write_deployments_bootswap (self, new_deployments, opts, bootloader, &syncstats, + &new_subbootdir, cancellable, error)) return FALSE; } - { g_autofree char *msg = - g_strdup_printf ("%s; bootconfig swap: %s; bootversion: %s, deployment count change: %i", - (bootloader_is_atomic ? "Transaction complete" : "Bootloader updated"), - requires_new_bootversion ? "yes" : "no", - new_subbootdir, - new_deployments->len - self->deployments->len); + { + g_autofree char *msg + = g_strdup_printf ("%s; bootconfig swap: %s; bootversion: %s, deployment count change: %i", + (bootloader_is_atomic ? "Transaction complete" : "Bootloader updated"), + requires_new_bootversion ? "yes" : "no", new_subbootdir, + new_deployments->len - self->deployments->len); const gchar *bootloader_config = ostree_repo_get_bootloader (ostree_sysroot_repo (self)); - ot_journal_send ("MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(OSTREE_DEPLOYMENT_COMPLETE_ID), - "MESSAGE=%s", msg, - "OSTREE_BOOTLOADER=%s", bootloader ? _ostree_bootloader_get_name (bootloader) : "none", - "OSTREE_BOOTLOADER_CONFIG=%s", bootloader_config, - "OSTREE_BOOTLOADER_ATOMIC=%s", bootloader_is_atomic ? "yes" : "no", - "OSTREE_DID_BOOTSWAP=%s", requires_new_bootversion ? "yes" : "no", - "OSTREE_N_DEPLOYMENTS=%u", new_deployments->len, - "OSTREE_SYNCFS_ROOT_MSEC=%" G_GUINT64_FORMAT, syncstats.root_syncfs_msec, - "OSTREE_SYNCFS_BOOT_MSEC=%" G_GUINT64_FORMAT, syncstats.boot_syncfs_msec, - "OSTREE_SYNCFS_EXTRA_MSEC=%" G_GUINT64_FORMAT, syncstats.extra_syncfs_msec, - NULL); + ot_journal_send ( + "MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL (OSTREE_DEPLOYMENT_COMPLETE_ID), + "MESSAGE=%s", msg, "OSTREE_BOOTLOADER=%s", + bootloader ? _ostree_bootloader_get_name (bootloader) : "none", + "OSTREE_BOOTLOADER_CONFIG=%s", bootloader_config, "OSTREE_BOOTLOADER_ATOMIC=%s", + bootloader_is_atomic ? "yes" : "no", "OSTREE_DID_BOOTSWAP=%s", + requires_new_bootversion ? "yes" : "no", "OSTREE_N_DEPLOYMENTS=%u", new_deployments->len, + "OSTREE_SYNCFS_ROOT_MSEC=%" G_GUINT64_FORMAT, syncstats.root_syncfs_msec, + "OSTREE_SYNCFS_BOOT_MSEC=%" G_GUINT64_FORMAT, syncstats.boot_syncfs_msec, + "OSTREE_SYNCFS_EXTRA_MSEC=%" G_GUINT64_FORMAT, syncstats.extra_syncfs_msec, NULL); _ostree_sysroot_emit_journal_msg (self, msg); } @@ -2962,23 +2849,17 @@ ostree_sysroot_write_deployments_with_options (OstreeSysroot *self, } static gboolean -allocate_deployserial (OstreeSysroot *self, - const char *osname, - const char *revision, - int *out_deployserial, - GCancellable *cancellable, - GError **error) +allocate_deployserial (OstreeSysroot *self, const char *osname, const char *revision, + int *out_deployserial, GCancellable *cancellable, GError **error) { int new_deployserial = 0; - g_autoptr(GPtrArray) tmp_current_deployments = - g_ptr_array_new_with_free_func (g_object_unref); + g_autoptr (GPtrArray) tmp_current_deployments = g_ptr_array_new_with_free_func (g_object_unref); glnx_autofd int deploy_dfd = -1; if (!glnx_opendirat (self->sysroot_fd, "ostree/deploy", TRUE, &deploy_dfd, error)) return FALSE; - if (!_ostree_sysroot_list_deployment_dirs_for_os (deploy_dfd, osname, - tmp_current_deployments, + if (!_ostree_sysroot_list_deployment_dirs_for_os (deploy_dfd, osname, tmp_current_deployments, cancellable, error)) return FALSE; @@ -2989,7 +2870,8 @@ allocate_deployserial (OstreeSysroot *self, if (strcmp (ostree_deployment_get_csum (deployment), revision) != 0) continue; - new_deployserial = MAX(new_deployserial, ostree_deployment_get_deployserial (deployment)+1); + new_deployserial + = MAX (new_deployserial, ostree_deployment_get_deployserial (deployment) + 1); } *out_deployserial = new_deployserial; @@ -2998,12 +2880,12 @@ allocate_deployserial (OstreeSysroot *self, void _ostree_deployment_set_bootconfig_from_kargs (OstreeDeployment *deployment, - char **override_kernel_argv) + char **override_kernel_argv) { /* Create an empty boot configuration; we will merge things into * it as we go. */ - g_autoptr(OstreeBootconfigParser) bootconfig = ostree_bootconfig_parser_new (); + g_autoptr (OstreeBootconfigParser) bootconfig = ostree_bootconfig_parser_new (); ostree_deployment_set_bootconfig (deployment, bootconfig); /* After this, install_deployment_kernel() will set the other boot @@ -3011,7 +2893,7 @@ _ostree_deployment_set_bootconfig_from_kargs (OstreeDeployment *deployment, */ if (override_kernel_argv) { - g_autoptr(OstreeKernelArgs) kargs = ostree_kernel_args_new (); + g_autoptr (OstreeKernelArgs) kargs = ostree_kernel_args_new (); ostree_kernel_args_append_argv (kargs, override_kernel_argv); g_autofree char *new_options = ostree_kernel_args_to_string (kargs); ostree_bootconfig_parser_set (bootconfig, "options", new_options); @@ -3022,13 +2904,12 @@ _ostree_deployment_set_bootconfig_from_kargs (OstreeDeployment *deployment, // that are likely to fail later. This function only returns // a hard error if something unexpected (e.g. I/O error) occurs. static gboolean -lint_deployment_fs (OstreeSysroot *self, - OstreeDeployment *deployment, - int deployment_dfd, - GCancellable *cancellable, - GError **error) +lint_deployment_fs (OstreeSysroot *self, OstreeDeployment *deployment, int deployment_dfd, + GCancellable *cancellable, GError **error) { - g_auto(GLnxDirFdIterator) dfd_iter = { 0, }; + g_auto (GLnxDirFdIterator) dfd_iter = { + 0, + }; glnx_autofd int dest_dfd = -1; gboolean exists; @@ -3043,9 +2924,10 @@ lint_deployment_fs (OstreeSysroot *self, if (dent == NULL) break; - fprintf (stderr, "note: Deploying commit %s which contains content in /var/%s that will be ignored.\n", - ostree_deployment_get_csum (deployment), - dent->d_name); + fprintf ( + stderr, + "note: Deploying commit %s which contains content in /var/%s that will be ignored.\n", + ostree_deployment_get_csum (deployment), dent->d_name); } return TRUE; @@ -3055,14 +2937,10 @@ lint_deployment_fs (OstreeSysroot *self, * hardlink farm checkout, but we also compute some initial state. */ static gboolean -sysroot_initialize_deployment (OstreeSysroot *self, - const char *osname, - const char *revision, - GKeyFile *origin, - OstreeSysrootDeployTreeOpts *opts, - OstreeDeployment **out_new_deployment, - GCancellable *cancellable, - GError **error) +sysroot_initialize_deployment (OstreeSysroot *self, const char *osname, const char *revision, + GKeyFile *origin, OstreeSysrootDeployTreeOpts *opts, + OstreeDeployment **out_new_deployment, GCancellable *cancellable, + GError **error) { g_assert (osname != NULL || self->booted_deployment != NULL); @@ -3072,31 +2950,28 @@ sysroot_initialize_deployment (OstreeSysroot *self, OstreeRepo *repo = ostree_sysroot_repo (self); gint new_deployserial; - if (!allocate_deployserial (self, osname, revision, &new_deployserial, - cancellable, error)) + if (!allocate_deployserial (self, osname, revision, &new_deployserial, cancellable, error)) return FALSE; - g_autoptr(OstreeDeployment) new_deployment = - ostree_deployment_new (0, osname, revision, new_deployserial, NULL, -1); + g_autoptr (OstreeDeployment) new_deployment + = ostree_deployment_new (0, osname, revision, new_deployserial, NULL, -1); ostree_deployment_set_origin (new_deployment, origin); /* Check out the userspace tree onto the filesystem */ glnx_autofd int deployment_dfd = -1; - if (!checkout_deployment_tree (self, repo, new_deployment, &deployment_dfd, - cancellable, error)) + if (!checkout_deployment_tree (self, repo, new_deployment, &deployment_dfd, cancellable, error)) return FALSE; - g_autoptr(OstreeKernelLayout) kernel_layout = NULL; - if (!get_kernel_from_tree (self, deployment_dfd, &kernel_layout, - cancellable, error)) + g_autoptr (OstreeKernelLayout) kernel_layout = NULL; + if (!get_kernel_from_tree (self, deployment_dfd, &kernel_layout, cancellable, error)) return FALSE; _ostree_deployment_set_bootcsum (new_deployment, kernel_layout->bootcsum); - _ostree_deployment_set_bootconfig_from_kargs (new_deployment, opts ? opts->override_kernel_argv : NULL); + _ostree_deployment_set_bootconfig_from_kargs (new_deployment, + opts ? opts->override_kernel_argv : NULL); _ostree_deployment_set_overlay_initrds (new_deployment, opts ? opts->overlay_initrds : NULL); - if (!prepare_deployment_etc (self, repo, new_deployment, deployment_dfd, - cancellable, error)) + if (!prepare_deployment_etc (self, repo, new_deployment, deployment_dfd, cancellable, error)) return FALSE; if (!lint_deployment_fs (self, new_deployment, deployment_dfd, cancellable, error)) @@ -3116,14 +2991,11 @@ sysroot_initialize_deployment (OstreeSysroot *self, * nor (relatedly) the case of upgrading a separate stateroot. */ static gboolean -get_var_dfd (OstreeSysroot *self, - int osdeploy_dfd, - OstreeDeployment *deployment, - int *ret_fd, - GError **error) +get_var_dfd (OstreeSysroot *self, int osdeploy_dfd, OstreeDeployment *deployment, int *ret_fd, + GError **error) { - const char *booted_stateroot = - self->booted_deployment ? ostree_deployment_get_osname (self->booted_deployment) : NULL; + const char *booted_stateroot + = self->booted_deployment ? ostree_deployment_get_osname (self->booted_deployment) : NULL; int base_dfd; const char *base_path; @@ -3151,8 +3023,8 @@ get_var_dfd (OstreeSysroot *self, static void child_setup_fchdir (gpointer data) { - int fd = (int) (uintptr_t) data; - int rc __attribute__((unused)); + int fd = (int)(uintptr_t)data; + int rc __attribute__ ((unused)); rc = fchdir (fd); } @@ -3161,35 +3033,65 @@ child_setup_fchdir (gpointer data) * Derived from rpm-ostree's rust/src/bwrap.rs */ static gboolean -run_in_deployment (int deployment_dfd, - const gchar * const *child_argv, - gsize child_argc, - gint *exit_status, - gchar **stdout, - GError **error) +run_in_deployment (int deployment_dfd, const gchar *const *child_argv, gsize child_argc, + gint *exit_status, gchar **stdout, GError **error) { - static const gchar * const COMMON_ARGV[] = { + static const gchar *const COMMON_ARGV[] = { "/usr/bin/bwrap", - "--dev", "/dev", "--proc", "/proc", "--dir", "/run", "--dir", "/tmp", - "--chdir", "/", + "--dev", + "/dev", + "--proc", + "/proc", + "--dir", + "/run", + "--dir", + "/tmp", + "--chdir", + "/", "--die-with-parent", "--unshare-pid", "--unshare-uts", "--unshare-ipc", "--unshare-cgroup-try", - "--ro-bind", "/sys/block", "/sys/block", - "--ro-bind", "/sys/bus", "/sys/bus", - "--ro-bind", "/sys/class", "/sys/class", - "--ro-bind", "/sys/dev", "/sys/dev", - "--ro-bind", "/sys/devices", "/sys/devices", - "--bind", "usr", "/usr", - "--bind", "etc", "/etc", - "--bind", "var", "/var", - "--symlink", "/usr/lib", "/lib", - "--symlink", "/usr/lib32", "/lib32", - "--symlink", "/usr/lib64", "/lib64", - "--symlink", "/usr/bin", "/bin", - "--symlink", "/usr/sbin", "/sbin", + "--ro-bind", + "/sys/block", + "/sys/block", + "--ro-bind", + "/sys/bus", + "/sys/bus", + "--ro-bind", + "/sys/class", + "/sys/class", + "--ro-bind", + "/sys/dev", + "/sys/dev", + "--ro-bind", + "/sys/devices", + "/sys/devices", + "--bind", + "usr", + "/usr", + "--bind", + "etc", + "/etc", + "--bind", + "var", + "/var", + "--symlink", + "/usr/lib", + "/lib", + "--symlink", + "/usr/lib32", + "/lib32", + "--symlink", + "/usr/lib64", + "/lib64", + "--symlink", + "/usr/bin", + "/bin", + "--symlink", + "/usr/sbin", + "/sbin", }; static const gsize COMMON_ARGC = sizeof (COMMON_ARGV) / sizeof (*COMMON_ARGV); @@ -3198,18 +3100,17 @@ run_in_deployment (int deployment_dfd, g_autofree gchar **args_raw = NULL; for (i = 0; i < COMMON_ARGC; i++) - g_ptr_array_add (args, (gchar *) COMMON_ARGV[i]); + g_ptr_array_add (args, (gchar *)COMMON_ARGV[i]); for (i = 0; i < child_argc; i++) - g_ptr_array_add (args, (gchar *) child_argv[i]); + g_ptr_array_add (args, (gchar *)child_argv[i]); g_ptr_array_add (args, NULL); - args_raw = (gchar **) g_ptr_array_free (args, FALSE); + args_raw = (gchar **)g_ptr_array_free (args, FALSE); return g_spawn_sync (NULL, args_raw, NULL, 0, &child_setup_fchdir, - (gpointer) (uintptr_t) deployment_dfd, - stdout, NULL, exit_status, error); + (gpointer)(uintptr_t)deployment_dfd, stdout, NULL, exit_status, error); } /* @@ -3223,8 +3124,8 @@ sysroot_finalize_selinux_policy (int deployment_dfd, GError **error) gint exit_status; g_autofree gchar *stdout = NULL; - if (!glnx_fstatat_allow_noent (deployment_dfd, "etc/selinux/config", &stbuf, - AT_SYMLINK_NOFOLLOW, error)) + if (!glnx_fstatat_allow_noent (deployment_dfd, "etc/selinux/config", &stbuf, AT_SYMLINK_NOFOLLOW, + error)) return FALSE; /* Skip the SELinux policy refresh if /etc/selinux/config doesn't exist. */ @@ -3235,39 +3136,35 @@ sysroot_finalize_selinux_policy (int deployment_dfd, GError **error) * Skip the SELinux policy refresh if the --refresh * flag is not supported by semodule. */ - static const gchar * const SEMODULE_HELP_ARGV[] = { - "semodule", "--help" - }; - static const gsize SEMODULE_HELP_ARGC = sizeof (SEMODULE_HELP_ARGV) / sizeof (*SEMODULE_HELP_ARGV); - if (!run_in_deployment (deployment_dfd, SEMODULE_HELP_ARGV, - SEMODULE_HELP_ARGC, &exit_status, &stdout, error)) + static const gchar *const SEMODULE_HELP_ARGV[] = { "semodule", "--help" }; + static const gsize SEMODULE_HELP_ARGC + = sizeof (SEMODULE_HELP_ARGV) / sizeof (*SEMODULE_HELP_ARGV); + if (!run_in_deployment (deployment_dfd, SEMODULE_HELP_ARGV, SEMODULE_HELP_ARGC, &exit_status, + &stdout, error)) return FALSE; if (!g_spawn_check_exit_status (exit_status, error)) return glnx_prefix_error (error, "failed to run semodule"); - if (!strstr(stdout, "--refresh")) + if (!strstr (stdout, "--refresh")) { ot_journal_print (LOG_INFO, "semodule does not have --refresh"); return TRUE; } - static const gchar * const SEMODULE_REBUILD_ARGV[] = { - "semodule", "-N", "--refresh" - }; - static const gsize SEMODULE_REBUILD_ARGC = sizeof (SEMODULE_REBUILD_ARGV) / sizeof (*SEMODULE_REBUILD_ARGV); + static const gchar *const SEMODULE_REBUILD_ARGV[] = { "semodule", "-N", "--refresh" }; + static const gsize SEMODULE_REBUILD_ARGC + = sizeof (SEMODULE_REBUILD_ARGV) / sizeof (*SEMODULE_REBUILD_ARGV); - if (!run_in_deployment (deployment_dfd, SEMODULE_REBUILD_ARGV, - SEMODULE_REBUILD_ARGC, &exit_status, NULL, error)) + if (!run_in_deployment (deployment_dfd, SEMODULE_REBUILD_ARGV, SEMODULE_REBUILD_ARGC, + &exit_status, NULL, error)) return FALSE; return g_spawn_check_exit_status (exit_status, error); } #endif /* HAVE_SELINUX */ static gboolean -sysroot_finalize_deployment (OstreeSysroot *self, - OstreeDeployment *deployment, - OstreeDeployment *merge_deployment, - GCancellable *cancellable, - GError **error) +sysroot_finalize_deployment (OstreeSysroot *self, OstreeDeployment *deployment, + OstreeDeployment *merge_deployment, GCancellable *cancellable, + GError **error) { g_autofree char *deployment_path = ostree_sysroot_get_deployment_dirpath (self, deployment); glnx_autofd int deployment_dfd = -1; @@ -3281,13 +3178,13 @@ sysroot_finalize_deployment (OstreeSysroot *self, * finalize-staged path, they're set by OstreeSysroot when reading the staged GVariant. */ if (merge_deployment && ostree_bootconfig_parser_get (bootconfig, "options") == NULL) { - OstreeBootconfigParser *merge_bootconfig = ostree_deployment_get_bootconfig (merge_deployment); + OstreeBootconfigParser *merge_bootconfig + = ostree_deployment_get_bootconfig (merge_deployment); if (merge_bootconfig) { const char *kargs = ostree_bootconfig_parser_get (merge_bootconfig, "options"); ostree_bootconfig_parser_set (bootconfig, "options", kargs); } - } if (merge_deployment) @@ -3303,7 +3200,8 @@ sysroot_finalize_deployment (OstreeSysroot *self, #endif /* HAVE_SELINUX */ } - const char *osdeploypath = glnx_strjoina ("ostree/deploy/", ostree_deployment_get_osname (deployment)); + const char *osdeploypath + = glnx_strjoina ("ostree/deploy/", ostree_deployment_get_osname (deployment)); glnx_autofd int os_deploy_dfd = -1; if (!glnx_opendirat (self->sysroot_fd, osdeploypath, TRUE, &os_deploy_dfd, error)) return FALSE; @@ -3320,7 +3218,7 @@ sysroot_finalize_deployment (OstreeSysroot *self, if (!ot_ensure_unlinked_at (var_dfd, ".updated", error)) return FALSE; - g_autoptr(OstreeSePolicy) sepolicy = ostree_sepolicy_new_at (deployment_dfd, cancellable, error); + g_autoptr (OstreeSePolicy) sepolicy = ostree_sepolicy_new_at (deployment_dfd, cancellable, error); if (!sepolicy) return FALSE; @@ -3332,15 +3230,13 @@ sysroot_finalize_deployment (OstreeSysroot *self, */ if (!write_origin_file_internal (self, sepolicy, deployment, ostree_deployment_get_origin (deployment), - GLNX_FILE_REPLACE_NODATASYNC, - cancellable, error)) + GLNX_FILE_REPLACE_NODATASYNC, cancellable, error)) return FALSE; /* Seal it */ if (!(self->debug_flags & OSTREE_SYSROOT_DEBUG_MUTABLE_DEPLOYMENTS)) { - if (!ostree_sysroot_deployment_set_mutable (self, deployment, FALSE, - cancellable, error)) + if (!ostree_sysroot_deployment_set_mutable (self, deployment, FALSE, cancellable, error)) return FALSE; } @@ -3368,26 +3264,23 @@ sysroot_finalize_deployment (OstreeSysroot *self, * Since: 2020.7 */ gboolean -ostree_sysroot_deploy_tree_with_options (OstreeSysroot *self, - const char *osname, - const char *revision, - GKeyFile *origin, - OstreeDeployment *provided_merge_deployment, +ostree_sysroot_deploy_tree_with_options (OstreeSysroot *self, const char *osname, + const char *revision, GKeyFile *origin, + OstreeDeployment *provided_merge_deployment, OstreeSysrootDeployTreeOpts *opts, OstreeDeployment **out_new_deployment, - GCancellable *cancellable, - GError **error) + GCancellable *cancellable, GError **error) { if (!_ostree_sysroot_ensure_writable (self, error)) return FALSE; - g_autoptr(OstreeDeployment) deployment = NULL; - if (!sysroot_initialize_deployment (self, osname, revision, origin, opts, - &deployment, cancellable, error)) + g_autoptr (OstreeDeployment) deployment = NULL; + if (!sysroot_initialize_deployment (self, osname, revision, origin, opts, &deployment, + cancellable, error)) return FALSE; - if (!sysroot_finalize_deployment (self, deployment, provided_merge_deployment, - cancellable, error)) + if (!sysroot_finalize_deployment (self, deployment, provided_merge_deployment, cancellable, + error)) return FALSE; *out_new_deployment = g_steal_pointer (&deployment); @@ -3401,7 +3294,8 @@ ostree_sysroot_deploy_tree_with_options (OstreeSysroot *self, * @revision: Checksum to add * @origin: (nullable): Origin to use for upgrades * @provided_merge_deployment: (nullable): Use this deployment for merge path - * @override_kernel_argv: (nullable) (array zero-terminated=1) (element-type utf8): Use these as kernel arguments; if %NULL, inherit options from provided_merge_deployment + * @override_kernel_argv: (nullable) (array zero-terminated=1) (element-type utf8): Use these as + * kernel arguments; if %NULL, inherit options from provided_merge_deployment * @out_new_deployment: (out): The new deployment path * @cancellable: Cancellable * @error: Error @@ -3411,15 +3305,10 @@ ostree_sysroot_deploy_tree_with_options (OstreeSysroot *self, * Since: 2018.5 */ gboolean -ostree_sysroot_deploy_tree (OstreeSysroot *self, - const char *osname, - const char *revision, - GKeyFile *origin, - OstreeDeployment *provided_merge_deployment, - char **override_kernel_argv, - OstreeDeployment **out_new_deployment, - GCancellable *cancellable, - GError **error) +ostree_sysroot_deploy_tree (OstreeSysroot *self, const char *osname, const char *revision, + GKeyFile *origin, OstreeDeployment *provided_merge_deployment, + char **override_kernel_argv, OstreeDeployment **out_new_deployment, + GCancellable *cancellable, GError **error) { OstreeSysrootDeployTreeOpts opts = { .override_kernel_argv = override_kernel_argv }; return ostree_sysroot_deploy_tree_with_options (self, osname, revision, origin, @@ -3433,13 +3322,11 @@ ostree_sysroot_deploy_tree (OstreeSysroot *self, static GVariant * serialize_deployment_to_variant (OstreeDeployment *deployment) { - g_auto(GVariantBuilder) builder = OT_VARIANT_BUILDER_INITIALIZER; - g_variant_builder_init (&builder, (GVariantType*)"a{sv}"); - g_autofree char *name = - g_strdup_printf ("%s.%d", ostree_deployment_get_csum (deployment), - ostree_deployment_get_deployserial (deployment)); - g_variant_builder_add (&builder, "{sv}", "name", - g_variant_new_string (name)); + g_auto (GVariantBuilder) builder = OT_VARIANT_BUILDER_INITIALIZER; + g_variant_builder_init (&builder, (GVariantType *)"a{sv}"); + g_autofree char *name = g_strdup_printf ("%s.%d", ostree_deployment_get_csum (deployment), + ostree_deployment_get_deployserial (deployment)); + g_variant_builder_add (&builder, "{sv}", "name", g_variant_new_string (name)); g_variant_builder_add (&builder, "{sv}", "osname", g_variant_new_string (ostree_deployment_get_osname (deployment))); g_variant_builder_add (&builder, "{sv}", "bootcsum", @@ -3449,10 +3336,7 @@ serialize_deployment_to_variant (OstreeDeployment *deployment) } static gboolean -require_str_key (GVariantDict *dict, - const char *name, - const char **ret, - GError **error) +require_str_key (GVariantDict *dict, const char *name, const char **ret, GError **error) { if (!g_variant_dict_lookup (dict, name, "&s", ret)) return glnx_throw (error, "Missing key: %s", name); @@ -3464,10 +3348,9 @@ require_str_key (GVariantDict *dict, * higher level code. */ OstreeDeployment * -_ostree_sysroot_deserialize_deployment_from_variant (GVariant *v, - GError **error) +_ostree_sysroot_deserialize_deployment_from_variant (GVariant *v, GError **error) { - g_autoptr(GVariantDict) dict = g_variant_dict_new (v); + g_autoptr (GVariantDict) dict = g_variant_dict_new (v); const char *name = NULL; if (!require_str_key (dict, "name", &name, error)) return FALSE; @@ -3481,11 +3364,9 @@ _ostree_sysroot_deserialize_deployment_from_variant (GVariant *v, gint deployserial; if (!_ostree_sysroot_parse_deploy_path_name (name, &checksum, &deployserial, error)) return NULL; - return ostree_deployment_new (-1, osname, checksum, deployserial, - bootcsum, -1); + return ostree_deployment_new (-1, osname, checksum, deployserial, bootcsum, -1); } - /** * ostree_sysroot_stage_overlay_initrd: * @self: Sysroot @@ -3501,17 +3382,14 @@ _ostree_sysroot_deserialize_deployment_from_variant (GVariant *v, * Since: 2020.7 */ gboolean -ostree_sysroot_stage_overlay_initrd (OstreeSysroot *self, - int fd, - char **out_checksum, - GCancellable *cancellable, - GError **error) +ostree_sysroot_stage_overlay_initrd (OstreeSysroot *self, int fd, char **out_checksum, + GCancellable *cancellable, GError **error) { g_assert (fd != -1); g_assert (out_checksum != NULL); - if (!glnx_shutil_mkdir_p_at (AT_FDCWD, _OSTREE_SYSROOT_RUNSTATE_STAGED_INITRDS_DIR, - 0755, cancellable, error)) + if (!glnx_shutil_mkdir_p_at (AT_FDCWD, _OSTREE_SYSROOT_RUNSTATE_STAGED_INITRDS_DIR, 0755, + cancellable, error)) return FALSE; glnx_autofd int staged_initrds_dfd = -1; @@ -3519,30 +3397,31 @@ ostree_sysroot_stage_overlay_initrd (OstreeSysroot *self, &staged_initrds_dfd, error)) return FALSE; - g_auto(GLnxTmpfile) overlay_initrd = { 0, }; + g_auto (GLnxTmpfile) overlay_initrd = { + 0, + }; if (!glnx_open_tmpfile_linkable_at (staged_initrds_dfd, ".", O_WRONLY | O_CLOEXEC, &overlay_initrd, error)) return FALSE; - char checksum[_OSTREE_SHA256_STRING_LEN+1]; + char checksum[_OSTREE_SHA256_STRING_LEN + 1]; { - g_autoptr(GOutputStream) output = g_unix_output_stream_new (overlay_initrd.fd, FALSE); - g_autoptr(GInputStream) input = g_unix_input_stream_new (fd, FALSE); + g_autoptr (GOutputStream) output = g_unix_output_stream_new (overlay_initrd.fd, FALSE); + g_autoptr (GInputStream) input = g_unix_input_stream_new (fd, FALSE); g_autofree guchar *digest = NULL; if (!ot_gio_splice_get_checksum (output, input, &digest, cancellable, error)) return FALSE; - ot_bin2hex (checksum, (guint8*)digest, _OSTREE_SHA256_DIGEST_LEN); + ot_bin2hex (checksum, (guint8 *)digest, _OSTREE_SHA256_DIGEST_LEN); } - if (!glnx_link_tmpfile_at (&overlay_initrd, GLNX_LINK_TMPFILE_REPLACE, - staged_initrds_dfd, checksum, error)) + if (!glnx_link_tmpfile_at (&overlay_initrd, GLNX_LINK_TMPFILE_REPLACE, staged_initrds_dfd, + checksum, error)) return FALSE; *out_checksum = g_strdup (checksum); return TRUE; } - /** * ostree_sysroot_stage_tree: * @self: Sysroot @@ -3550,7 +3429,8 @@ ostree_sysroot_stage_overlay_initrd (OstreeSysroot *self, * @revision: Checksum to add * @origin: (allow-none): Origin to use for upgrades * @merge_deployment: (allow-none): Use this deployment for merge path - * @override_kernel_argv: (allow-none) (array zero-terminated=1) (element-type utf8): Use these as kernel arguments; if %NULL, inherit options from provided_merge_deployment + * @override_kernel_argv: (allow-none) (array zero-terminated=1) (element-type utf8): Use these as + * kernel arguments; if %NULL, inherit options from provided_merge_deployment * @out_new_deployment: (out): The new deployment path * @cancellable: Cancellable * @error: Error @@ -3560,23 +3440,16 @@ ostree_sysroot_stage_overlay_initrd (OstreeSysroot *self, * Since: 2018.5 */ gboolean -ostree_sysroot_stage_tree (OstreeSysroot *self, - const char *osname, - const char *revision, - GKeyFile *origin, - OstreeDeployment *merge_deployment, - char **override_kernel_argv, - OstreeDeployment **out_new_deployment, - GCancellable *cancellable, - GError **error) +ostree_sysroot_stage_tree (OstreeSysroot *self, const char *osname, const char *revision, + GKeyFile *origin, OstreeDeployment *merge_deployment, + char **override_kernel_argv, OstreeDeployment **out_new_deployment, + GCancellable *cancellable, GError **error) { OstreeSysrootDeployTreeOpts opts = { .override_kernel_argv = override_kernel_argv }; - return ostree_sysroot_stage_tree_with_options (self, osname, revision, origin, - merge_deployment, &opts, - out_new_deployment, cancellable, error); + return ostree_sysroot_stage_tree_with_options (self, osname, revision, origin, merge_deployment, + &opts, out_new_deployment, cancellable, error); } - /** * ostree_sysroot_stage_tree_with_options: * @self: Sysroot @@ -3595,15 +3468,12 @@ ostree_sysroot_stage_tree (OstreeSysroot *self, * Since: 2020.7 */ gboolean -ostree_sysroot_stage_tree_with_options (OstreeSysroot *self, - const char *osname, - const char *revision, - GKeyFile *origin, - OstreeDeployment *merge_deployment, +ostree_sysroot_stage_tree_with_options (OstreeSysroot *self, const char *osname, + const char *revision, GKeyFile *origin, + OstreeDeployment *merge_deployment, OstreeSysrootDeployTreeOpts *opts, OstreeDeployment **out_new_deployment, - GCancellable *cancellable, - GError **error) + GCancellable *cancellable, GError **error) { if (!_ostree_sysroot_ensure_writable (self, error)) return FALSE; @@ -3612,7 +3482,7 @@ ostree_sysroot_stage_tree_with_options (OstreeSysroot *self, if (booted_deployment == NULL) return glnx_prefix_error (error, "Cannot stage deployment"); - g_autoptr(OstreeDeployment) deployment = NULL; + g_autoptr (OstreeDeployment) deployment = NULL; if (!sysroot_initialize_deployment (self, osname, revision, origin, opts, &deployment, cancellable, error)) return FALSE; @@ -3621,18 +3491,18 @@ ostree_sysroot_stage_tree_with_options (OstreeSysroot *self, * now (i.e. using /usr/etc policy, not /etc); in practice we don't really * expect people to customize the label for it. */ - { g_autofree char *deployment_path = ostree_sysroot_get_deployment_dirpath (self, deployment); + { + g_autofree char *deployment_path = ostree_sysroot_get_deployment_dirpath (self, deployment); glnx_autofd int deployment_dfd = -1; - if (!glnx_opendirat (self->sysroot_fd, deployment_path, FALSE, - &deployment_dfd, error)) + if (!glnx_opendirat (self->sysroot_fd, deployment_path, FALSE, &deployment_dfd, error)) return FALSE; - g_autoptr(OstreeSePolicy) sepolicy = ostree_sepolicy_new_at (deployment_dfd, cancellable, error); + g_autoptr (OstreeSePolicy) sepolicy + = ostree_sepolicy_new_at (deployment_dfd, cancellable, error); if (!sepolicy) return FALSE; if (!write_origin_file_internal (self, sepolicy, deployment, ostree_deployment_get_origin (deployment), - GLNX_FILE_REPLACE_NODATASYNC, - cancellable, error)) + GLNX_FILE_REPLACE_NODATASYNC, cancellable, error)) return FALSE; } @@ -3641,30 +3511,29 @@ ostree_sysroot_stage_tree_with_options (OstreeSysroot *self, */ /* "target" is the staged deployment */ - g_autoptr(GVariantBuilder) builder = g_variant_builder_new ((GVariantType*)"a{sv}"); - g_variant_builder_add (builder, "{sv}", "target", - serialize_deployment_to_variant (deployment)); + g_autoptr (GVariantBuilder) builder = g_variant_builder_new ((GVariantType *)"a{sv}"); + g_variant_builder_add (builder, "{sv}", "target", serialize_deployment_to_variant (deployment)); if (merge_deployment) g_variant_builder_add (builder, "{sv}", "merge-deployment", serialize_deployment_to_variant (merge_deployment)); if (opts && opts->override_kernel_argv) - g_variant_builder_add (builder, "{sv}", "kargs", - g_variant_new_strv ((const char *const*)opts->override_kernel_argv, -1)); + g_variant_builder_add ( + builder, "{sv}", "kargs", + g_variant_new_strv ((const char *const *)opts->override_kernel_argv, -1)); if (opts && opts->overlay_initrds) g_variant_builder_add (builder, "{sv}", "overlay-initrds", - g_variant_new_strv ((const char *const*)opts->overlay_initrds, -1)); + g_variant_new_strv ((const char *const *)opts->overlay_initrds, -1)); const char *parent = dirname (strdupa (_OSTREE_SYSROOT_RUNSTATE_STAGED)); if (!glnx_shutil_mkdir_p_at (AT_FDCWD, parent, 0755, cancellable, error)) return FALSE; - g_autoptr(GVariant) state = g_variant_ref_sink (g_variant_builder_end (builder)); + g_autoptr (GVariant) state = g_variant_ref_sink (g_variant_builder_end (builder)); if (!glnx_file_replace_contents_at (AT_FDCWD, _OSTREE_SYSROOT_RUNSTATE_STAGED, g_variant_get_data (state), g_variant_get_size (state), - GLNX_FILE_REPLACE_NODATASYNC, - cancellable, error)) + GLNX_FILE_REPLACE_NODATASYNC, cancellable, error)) return FALSE; /* If we have a previous one, clean it up */ @@ -3693,9 +3562,8 @@ ostree_sysroot_stage_tree_with_options (OstreeSysroot *self, /* Invoked at shutdown time by ostree-finalize-staged.service */ static gboolean -_ostree_sysroot_finalize_staged_inner (OstreeSysroot *self, - GCancellable *cancellable, - GError **error) +_ostree_sysroot_finalize_staged_inner (OstreeSysroot *self, GCancellable *cancellable, + GError **error) { /* It's totally fine if there's no staged deployment; perhaps down the line * though we could teach the ostree cmdline to tell systemd to activate the @@ -3708,38 +3576,32 @@ _ostree_sysroot_finalize_staged_inner (OstreeSysroot *self, } /* Check if finalization is locked. */ - if (!glnx_fstatat_allow_noent (AT_FDCWD, _OSTREE_SYSROOT_RUNSTATE_STAGED_LOCKED, - NULL, 0, error)) + if (!glnx_fstatat_allow_noent (AT_FDCWD, _OSTREE_SYSROOT_RUNSTATE_STAGED_LOCKED, NULL, 0, error)) return FALSE; if (errno == 0) { - ot_journal_print (LOG_INFO, "Not finalizing; found " - _OSTREE_SYSROOT_RUNSTATE_STAGED_LOCKED); + ot_journal_print (LOG_INFO, "Not finalizing; found " _OSTREE_SYSROOT_RUNSTATE_STAGED_LOCKED); return TRUE; } /* Notice we send this *after* the trivial `return TRUE` above; this msg implies we've * committed to finalizing the deployment. */ - ot_journal_send ("MESSAGE_ID=" SD_ID128_FORMAT_STR, - SD_ID128_FORMAT_VAL(OSTREE_DEPLOYMENT_FINALIZING_ID), - "MESSAGE=Finalizing staged deployment", - "OSTREE_OSNAME=%s", - ostree_deployment_get_osname (self->staged_deployment), - "OSTREE_CHECKSUM=%s", - ostree_deployment_get_csum (self->staged_deployment), - "OSTREE_DEPLOYSERIAL=%u", - ostree_deployment_get_deployserial (self->staged_deployment), - NULL); + ot_journal_send ("MESSAGE_ID=" SD_ID128_FORMAT_STR, + SD_ID128_FORMAT_VAL (OSTREE_DEPLOYMENT_FINALIZING_ID), + "MESSAGE=Finalizing staged deployment", "OSTREE_OSNAME=%s", + ostree_deployment_get_osname (self->staged_deployment), "OSTREE_CHECKSUM=%s", + ostree_deployment_get_csum (self->staged_deployment), "OSTREE_DEPLOYSERIAL=%u", + ostree_deployment_get_deployserial (self->staged_deployment), NULL); g_assert (self->staged_deployment_data); - g_autoptr(OstreeDeployment) merge_deployment = NULL; - g_autoptr(GVariant) merge_deployment_v = NULL; + g_autoptr (OstreeDeployment) merge_deployment = NULL; + g_autoptr (GVariant) merge_deployment_v = NULL; if (g_variant_lookup (self->staged_deployment_data, "merge-deployment", "@a{sv}", &merge_deployment_v)) { - g_autoptr(OstreeDeployment) merge_deployment_stub = - _ostree_sysroot_deserialize_deployment_from_variant (merge_deployment_v, error); + g_autoptr (OstreeDeployment) merge_deployment_stub + = _ostree_sysroot_deserialize_deployment_from_variant (merge_deployment_v, error); if (!merge_deployment_stub) return FALSE; for (guint i = 0; i < self->deployments->len; i++) @@ -3764,14 +3626,14 @@ _ostree_sysroot_finalize_staged_inner (OstreeSysroot *self, if (!glnx_unlinkat (AT_FDCWD, _OSTREE_SYSROOT_RUNSTATE_STAGED, 0, error)) return FALSE; - if (!sysroot_finalize_deployment (self, self->staged_deployment, merge_deployment, - cancellable, error)) + if (!sysroot_finalize_deployment (self, self->staged_deployment, merge_deployment, cancellable, + error)) return FALSE; /* Now, take ownership of the staged state, as normally the API below strips * it out. */ - g_autoptr(OstreeDeployment) staged = g_steal_pointer (&self->staged_deployment); + g_autoptr (OstreeDeployment) staged = g_steal_pointer (&self->staged_deployment); staged->staged = FALSE; g_ptr_array_remove_index (self->deployments, 0); @@ -3781,11 +3643,10 @@ _ostree_sysroot_finalize_staged_inner (OstreeSysroot *self, * shutdown, and also because e.g. rpm-ostree wants to own the cleanup * process. */ - OstreeSysrootSimpleWriteDeploymentFlags flags = - OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_NO_CLEAN; - if (!ostree_sysroot_simple_write_deployment (self, ostree_deployment_get_osname (staged), - staged, merge_deployment, flags, - cancellable, error)) + OstreeSysrootSimpleWriteDeploymentFlags flags + = OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_NO_CLEAN; + if (!ostree_sysroot_simple_write_deployment (self, ostree_deployment_get_osname (staged), staged, + merge_deployment, flags, cancellable, error)) return FALSE; /* Do the basic cleanup that may impact /boot, but not the repo pruning */ @@ -3801,23 +3662,23 @@ _ostree_sysroot_finalize_staged_inner (OstreeSysroot *self, /* Invoked at shutdown time by ostree-finalize-staged.service */ gboolean -_ostree_sysroot_finalize_staged (OstreeSysroot *self, - GCancellable *cancellable, - GError **error) +_ostree_sysroot_finalize_staged (OstreeSysroot *self, GCancellable *cancellable, GError **error) { - g_autoptr(GError) finalization_error = NULL; + g_autoptr (GError) finalization_error = NULL; if (!_ostree_sysroot_ensure_boot_fd (self, error)) return FALSE; if (!_ostree_sysroot_finalize_staged_inner (self, cancellable, &finalization_error)) { - g_autoptr(GError) writing_error = NULL; + g_autoptr (GError) writing_error = NULL; g_assert_cmpint (self->boot_fd, !=, -1); if (!glnx_file_replace_contents_at (self->boot_fd, _OSTREE_FINALIZE_STAGED_FAILURE_PATH, - (guint8*)finalization_error->message, -1, - 0, cancellable, &writing_error)) + (guint8 *)finalization_error->message, -1, 0, cancellable, + &writing_error)) { - // We somehow failed to write the failure message...that's not great. Maybe ENOSPC on /boot. - g_printerr ("Failed to write %s: %s\n", _OSTREE_FINALIZE_STAGED_FAILURE_PATH, writing_error->message); + // We somehow failed to write the failure message...that's not great. Maybe ENOSPC on + // /boot. + g_printerr ("Failed to write %s: %s\n", _OSTREE_FINALIZE_STAGED_FAILURE_PATH, + writing_error->message); } g_propagate_error (error, g_steal_pointer (&finalization_error)); return FALSE; @@ -3826,7 +3687,8 @@ _ostree_sysroot_finalize_staged (OstreeSysroot *self, { /* we may have failed in a previous invocation on this boot, but we were * rerun again (likely manually) and passed this time; nuke any stamp */ - if (!glnx_shutil_rm_rf_at (self->boot_fd, _OSTREE_FINALIZE_STAGED_FAILURE_PATH, cancellable, error)) + if (!glnx_shutil_rm_rf_at (self->boot_fd, _OSTREE_FINALIZE_STAGED_FAILURE_PATH, cancellable, + error)) return FALSE; } return TRUE; @@ -3834,16 +3696,15 @@ _ostree_sysroot_finalize_staged (OstreeSysroot *self, /* Invoked at bootup time by ostree-boot-complete.service */ gboolean -_ostree_sysroot_boot_complete (OstreeSysroot *self, - GCancellable *cancellable, - GError **error) +_ostree_sysroot_boot_complete (OstreeSysroot *self, GCancellable *cancellable, GError **error) { if (!_ostree_sysroot_ensure_boot_fd (self, error)) return FALSE; glnx_autofd int failure_fd = -1; g_assert_cmpint (self->boot_fd, !=, -1); - if (!ot_openat_ignore_enoent (self->boot_fd, _OSTREE_FINALIZE_STAGED_FAILURE_PATH, &failure_fd, error)) + if (!ot_openat_ignore_enoent (self->boot_fd, _OSTREE_FINALIZE_STAGED_FAILURE_PATH, &failure_fd, + error)) return FALSE; // If we didn't find a failure log, then there's nothing to do right now. // (Actually this unit shouldn't even be invoked, but we may do more in the future) @@ -3853,8 +3714,9 @@ _ostree_sysroot_boot_complete (OstreeSysroot *self, if (failure_data == NULL) return glnx_prefix_error (error, "Reading from %s", _OSTREE_FINALIZE_STAGED_FAILURE_PATH); // Remove the file; we don't want to continually error out. - (void) unlinkat (self->boot_fd, _OSTREE_FINALIZE_STAGED_FAILURE_PATH, 0); - return glnx_throw (error, "ostree-finalize-staged.service failed on previous boot: %s", failure_data); + (void)unlinkat (self->boot_fd, _OSTREE_FINALIZE_STAGED_FAILURE_PATH, 0); + return glnx_throw (error, "ostree-finalize-staged.service failed on previous boot: %s", + failure_data); } /** @@ -3869,11 +3731,8 @@ _ostree_sysroot_boot_complete (OstreeSysroot *self, * values in @new_kargs. */ gboolean -ostree_sysroot_deployment_set_kargs (OstreeSysroot *self, - OstreeDeployment *deployment, - char **new_kargs, - GCancellable *cancellable, - GError **error) +ostree_sysroot_deployment_set_kargs (OstreeSysroot *self, OstreeDeployment *deployment, + char **new_kargs, GCancellable *cancellable, GError **error) { if (!_ostree_sysroot_ensure_writable (self, error)) return FALSE; @@ -3881,15 +3740,15 @@ ostree_sysroot_deployment_set_kargs (OstreeSysroot *self, /* For now; instead of this do a redeployment */ g_assert (!ostree_deployment_is_staged (deployment)); - g_autoptr(OstreeDeployment) new_deployment = ostree_deployment_clone (deployment); + g_autoptr (OstreeDeployment) new_deployment = ostree_deployment_clone (deployment); OstreeBootconfigParser *new_bootconfig = ostree_deployment_get_bootconfig (new_deployment); - g_autoptr(OstreeKernelArgs) kargs = ostree_kernel_args_new (); + g_autoptr (OstreeKernelArgs) kargs = ostree_kernel_args_new (); ostree_kernel_args_append_argv (kargs, new_kargs); g_autofree char *new_options = ostree_kernel_args_to_string (kargs); ostree_bootconfig_parser_set (new_bootconfig, "options", new_options); - g_autoptr(GPtrArray) new_deployments = g_ptr_array_new_with_free_func (g_object_unref); + g_autoptr (GPtrArray) new_deployments = g_ptr_array_new_with_free_func (g_object_unref); for (guint i = 0; i < self->deployments->len; i++) { OstreeDeployment *cur = self->deployments->pdata[i]; @@ -3899,8 +3758,7 @@ ostree_sysroot_deployment_set_kargs (OstreeSysroot *self, g_ptr_array_add (new_deployments, g_object_ref (cur)); } - if (!ostree_sysroot_write_deployments (self, new_deployments, - cancellable, error)) + if (!ostree_sysroot_write_deployments (self, new_deployments, cancellable, error)) return FALSE; return TRUE; @@ -3917,11 +3775,9 @@ ostree_sysroot_deployment_set_kargs (OstreeSysroot *self, * Replace the kernel arguments of @deployment with the values in @kargs_str. */ gboolean -ostree_sysroot_deployment_set_kargs_in_place (OstreeSysroot *self, - OstreeDeployment *deployment, - char *kargs_str, - GCancellable *cancellable, - GError **error) +ostree_sysroot_deployment_set_kargs_in_place (OstreeSysroot *self, OstreeDeployment *deployment, + char *kargs_str, GCancellable *cancellable, + GError **error) { if (!ostree_sysroot_initialize (self, error)) return FALSE; @@ -3938,25 +3794,23 @@ ostree_sysroot_deployment_set_kargs_in_place (OstreeSysroot *self, if (!glnx_openat_rdonly (AT_FDCWD, _OSTREE_SYSROOT_RUNSTATE_STAGED, TRUE, &fd, error)) return FALSE; - g_autoptr(GBytes) contents = ot_fd_readall_or_mmap (fd, 0, error); + g_autoptr (GBytes) contents = ot_fd_readall_or_mmap (fd, 0, error); if (!contents) return FALSE; - g_autoptr(GVariant) staged_deployment_data = - g_variant_new_from_bytes ((GVariantType*)"a{sv}", contents, TRUE); - g_autoptr(GVariantDict) staged_deployment_dict = - g_variant_dict_new (staged_deployment_data); + g_autoptr (GVariant) staged_deployment_data + = g_variant_new_from_bytes ((GVariantType *)"a{sv}", contents, TRUE); + g_autoptr (GVariantDict) staged_deployment_dict = g_variant_dict_new (staged_deployment_data); - g_autoptr(OstreeKernelArgs) kargs = ostree_kernel_args_from_string (kargs_str); - g_auto(GStrv) kargs_strv = ostree_kernel_args_to_strv (kargs); + g_autoptr (OstreeKernelArgs) kargs = ostree_kernel_args_from_string (kargs_str); + g_auto (GStrv) kargs_strv = ostree_kernel_args_to_strv (kargs); g_variant_dict_insert (staged_deployment_dict, "kargs", "^a&s", kargs_strv); - g_autoptr(GVariant) new_staged_deployment_data = g_variant_dict_end (staged_deployment_dict); + g_autoptr (GVariant) new_staged_deployment_data = g_variant_dict_end (staged_deployment_dict); if (!glnx_file_replace_contents_at (fd, _OSTREE_SYSROOT_RUNSTATE_STAGED, g_variant_get_data (new_staged_deployment_data), g_variant_get_size (new_staged_deployment_data), - GLNX_FILE_REPLACE_NODATASYNC, - cancellable, error)) + GLNX_FILE_REPLACE_NODATASYNC, cancellable, error)) return FALSE; } else @@ -3964,18 +3818,16 @@ ostree_sysroot_deployment_set_kargs_in_place (OstreeSysroot *self, OstreeBootconfigParser *new_bootconfig = ostree_deployment_get_bootconfig (deployment); ostree_bootconfig_parser_set (new_bootconfig, "options", kargs_str); - g_autofree char *bootconf_name = - g_strdup_printf ("ostree-%d-%s.conf", - self->deployments->len - ostree_deployment_get_index (deployment), - ostree_deployment_get_osname (deployment)); + g_autofree char *bootconf_name = g_strdup_printf ( + "ostree-%d-%s.conf", self->deployments->len - ostree_deployment_get_index (deployment), + ostree_deployment_get_osname (deployment)); g_autofree char *bootconfdir = g_strdup_printf ("loader.%d/entries", self->bootversion); glnx_autofd int bootconf_dfd = -1; if (!glnx_opendirat (self->boot_fd, bootconfdir, TRUE, &bootconf_dfd, error)) return FALSE; - if (!ostree_bootconfig_parser_write_at (new_bootconfig, - bootconf_dfd, bootconf_name, + if (!ostree_bootconfig_parser_write_at (new_bootconfig, bootconf_dfd, bootconf_name, cancellable, error)) return FALSE; } @@ -3996,11 +3848,9 @@ ostree_sysroot_deployment_set_kargs_in_place (OstreeSysroot *self, * layering additional non-OSTree content. */ gboolean -ostree_sysroot_deployment_set_mutable (OstreeSysroot *self, - OstreeDeployment *deployment, - gboolean is_mutable, - GCancellable *cancellable, - GError **error) +ostree_sysroot_deployment_set_mutable (OstreeSysroot *self, OstreeDeployment *deployment, + gboolean is_mutable, GCancellable *cancellable, + GError **error) { if (!_ostree_sysroot_ensure_writable (self, error)) return FALSE; |