diff options
author | Colin Walters <walters@verbum.org> | 2023-05-01 14:24:29 -0400 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2023-05-02 08:42:19 -0400 |
commit | 453aed97f688c606622562145fa1f7c10096ba14 (patch) | |
tree | 8059e3887665735f14b31a44402d5d578fcdd876 /src/libostree/ostree-impl-system-generator.c | |
parent | a917813bb82b6ec7083da24064439b656971748d (diff) | |
download | ostree-453aed97f688c606622562145fa1f7c10096ba14.tar.gz |
tree-wide: Run clang-format
This is a one-time tree wide reformatting to ensure consistency
going forward.
Diffstat (limited to 'src/libostree/ostree-impl-system-generator.c')
-rw-r--r-- | src/libostree/ostree-impl-system-generator.c | 77 |
1 files changed, 38 insertions, 39 deletions
diff --git a/src/libostree/ostree-impl-system-generator.c b/src/libostree/ostree-impl-system-generator.c index da4654b9..8404d189 100644 --- a/src/libostree/ostree-impl-system-generator.c +++ b/src/libostree/ostree-impl-system-generator.c @@ -19,24 +19,24 @@ #include "config.h" -#include <glib-unix.h> -#include <gio/gunixoutputstream.h> #include <errno.h> +#include <gio/gunixoutputstream.h> +#include <glib-unix.h> #include <stdio.h> #ifdef HAVE_LIBMOUNT #include <libmount.h> #endif -#include <sys/statvfs.h> -#include <stdbool.h> #include "otutil.h" +#include <stdbool.h> +#include <sys/statvfs.h> -#include "ostree.h" -#include "ostree-core-private.h" #include "ostree-cmd-private.h" +#include "ostree-core-private.h" +#include "ostree.h" #ifdef HAVE_LIBMOUNT typedef FILE OtLibMountFile; -G_DEFINE_AUTOPTR_CLEANUP_FUNC(OtLibMountFile, endmntent) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (OtLibMountFile, endmntent) /* Taken from systemd path-util.c */ static bool @@ -46,7 +46,7 @@ is_path (const char *p) } /* Taken from systemd path-util.c */ -static char* +static char * path_kill_slashes (char *path) { char *f, *t; @@ -91,8 +91,7 @@ path_kill_slashes (char *path) * mounted yet. */ static char * -stateroot_from_ostree_cmdline (const char *ostree_cmdline, - GError **error) +stateroot_from_ostree_cmdline (const char *ostree_cmdline, GError **error) { static GRegex *regex; static gsize regex_initialized; @@ -103,7 +102,7 @@ stateroot_from_ostree_cmdline (const char *ostree_cmdline, g_once_init_leave (®ex_initialized, 1); } - g_autoptr(GMatchInfo) match = NULL; + g_autoptr (GMatchInfo) match = NULL; if (!g_regex_match (regex, ostree_cmdline, 0, &match)) return glnx_null_throw (error, "Failed to parse %s", ostree_cmdline); @@ -113,10 +112,8 @@ stateroot_from_ostree_cmdline (const char *ostree_cmdline, /* Forcibly enable our internal units, since we detected ostree= on the kernel cmdline */ static gboolean -require_internal_units (const char *normal_dir, - const char *early_dir, - const char *late_dir, - GError **error) +require_internal_units (const char *normal_dir, const char *early_dir, const char *late_dir, + GError **error) { #ifdef SYSTEM_DATA_UNIT_PATH GCancellable *cancellable = NULL; @@ -125,16 +122,23 @@ require_internal_units (const char *normal_dir, if (!glnx_opendirat (AT_FDCWD, normal_dir, TRUE, &normal_dir_dfd, error)) return FALSE; - if (!glnx_shutil_mkdir_p_at (normal_dir_dfd, "local-fs.target.requires", 0755, cancellable, error)) + if (!glnx_shutil_mkdir_p_at (normal_dir_dfd, "local-fs.target.requires", 0755, cancellable, + error)) return FALSE; - if (symlinkat (SYSTEM_DATA_UNIT_PATH "/ostree-remount.service", normal_dir_dfd, "local-fs.target.requires/ostree-remount.service") < 0) + if (symlinkat (SYSTEM_DATA_UNIT_PATH "/ostree-remount.service", normal_dir_dfd, + "local-fs.target.requires/ostree-remount.service") + < 0) return glnx_throw_errno_prefix (error, "symlinkat"); if (!glnx_shutil_mkdir_p_at (normal_dir_dfd, "multi-user.target.wants", 0755, cancellable, error)) return FALSE; - if (symlinkat (SYSTEM_DATA_UNIT_PATH "/ostree-finalize-staged.path", normal_dir_dfd, "multi-user.target.wants/ostree-finalize-staged.path") < 0) + if (symlinkat (SYSTEM_DATA_UNIT_PATH "/ostree-finalize-staged.path", normal_dir_dfd, + "multi-user.target.wants/ostree-finalize-staged.path") + < 0) return glnx_throw_errno_prefix (error, "symlinkat"); - if (symlinkat (SYSTEM_DATA_UNIT_PATH "/ostree-boot-complete.service", normal_dir_dfd, "multi-user.target.wants/ostree-boot-complete.service") < 0) + if (symlinkat (SYSTEM_DATA_UNIT_PATH "/ostree-boot-complete.service", normal_dir_dfd, + "multi-user.target.wants/ostree-boot-complete.service") + < 0) return glnx_throw_errno_prefix (error, "symlinkat"); return TRUE; @@ -145,11 +149,8 @@ require_internal_units (const char *normal_dir, /* Generate var.mount */ static gboolean -fstab_generator (const char *ostree_cmdline, - const char *normal_dir, - const char *early_dir, - const char *late_dir, - GError **error) +fstab_generator (const char *ostree_cmdline, const char *normal_dir, const char *early_dir, + const char *late_dir, GError **error) { #ifdef HAVE_LIBMOUNT /* Not currently cancellable, but define a var in case we care later */ @@ -164,7 +165,7 @@ fstab_generator (const char *ostree_cmdline, return FALSE; /* Load /etc/fstab if it exists, and look for a /var mount */ - g_autoptr(OtLibMountFile) fstab = setmntent (fstab_path, "re"); + g_autoptr (OtLibMountFile) fstab = setmntent (fstab_path, "re"); gboolean found_var_mnt = FALSE; if (!fstab) { @@ -204,11 +205,12 @@ fstab_generator (const char *ostree_cmdline, /* Generate our bind mount unit */ const char *stateroot_var_path = glnx_strjoina ("/sysroot/ostree/deploy/", stateroot, "/var"); - g_auto(GLnxTmpfile) tmpf = { 0, }; - if (!glnx_open_tmpfile_linkable_at (normal_dir_dfd, ".", O_WRONLY | O_CLOEXEC, - &tmpf, error)) + g_auto (GLnxTmpfile) tmpf = { + 0, + }; + if (!glnx_open_tmpfile_linkable_at (normal_dir_dfd, ".", O_WRONLY | O_CLOEXEC, &tmpf, error)) return FALSE; - g_autoptr(GOutputStream) outstream = g_unix_output_stream_new (tmpf.fd, FALSE); + g_autoptr (GOutputStream) outstream = g_unix_output_stream_new (tmpf.fd, FALSE); gsize bytes_written; /* This code is inspired by systemd's fstab-generator.c. * @@ -226,8 +228,7 @@ fstab_generator (const char *ostree_cmdline, "Where=%s\n" "What=%s\n" "Options=bind\n", - var_path, - stateroot_var_path)) + var_path, stateroot_var_path)) return FALSE; if (!g_output_stream_flush (outstream, cancellable, error)) return FALSE; @@ -236,8 +237,8 @@ fstab_generator (const char *ostree_cmdline, if (!glnx_fchmod (tmpf.fd, 0644, error)) return FALSE; /* Error out if somehow it already exists, that'll help us debug conflicts */ - if (!glnx_link_tmpfile_at (&tmpf, GLNX_LINK_TMPFILE_NOREPLACE, - normal_dir_dfd, "var.mount", error)) + if (!glnx_link_tmpfile_at (&tmpf, GLNX_LINK_TMPFILE_NOREPLACE, normal_dir_dfd, "var.mount", + error)) return FALSE; /* And ensure it's required; newer systemd will auto-inject fs dependencies @@ -245,7 +246,8 @@ fstab_generator (const char *ostree_cmdline, * need this. It's what the fstab generator does. And my mother always said, * listen to the fstab generator. */ - if (!glnx_shutil_mkdir_p_at (normal_dir_dfd, "local-fs.target.requires", 0755, cancellable, error)) + if (!glnx_shutil_mkdir_p_at (normal_dir_dfd, "local-fs.target.requires", 0755, cancellable, + error)) return FALSE; if (symlinkat ("../var.mount", normal_dir_dfd, "local-fs.target.requires/var.mount") < 0) return glnx_throw_errno_prefix (error, "symlinkat"); @@ -258,11 +260,8 @@ fstab_generator (const char *ostree_cmdline, /* Implementation of ostree-system-generator */ gboolean -_ostree_impl_system_generator (const char *ostree_cmdline, - const char *normal_dir, - const char *early_dir, - const char *late_dir, - GError **error) +_ostree_impl_system_generator (const char *ostree_cmdline, const char *normal_dir, + const char *early_dir, const char *late_dir, GError **error) { if (!require_internal_units (normal_dir, early_dir, late_dir, error)) return FALSE; |