summaryrefslogtreecommitdiff
path: root/src/libostree/ostree-repo-commit.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libostree/ostree-repo-commit.c')
-rw-r--r--src/libostree/ostree-repo-commit.c1828
1 files changed, 766 insertions, 1062 deletions
diff --git a/src/libostree/ostree-repo-commit.c b/src/libostree/ostree-repo-commit.c
index 32119c47..5cda047c 100644
--- a/src/libostree/ostree-repo-commit.c
+++ b/src/libostree/ostree-repo-commit.c
@@ -22,28 +22,28 @@
#include "config.h"
-#include <glib-unix.h>
-#include <sys/statvfs.h>
+#include <ext2fs/ext2_fs.h>
#include <gio/gfiledescriptorbased.h>
#include <gio/gunixinputstream.h>
#include <gio/gunixoutputstream.h>
-#include <sys/xattr.h>
+#include <glib-unix.h>
#include <glib/gprintf.h>
#include <sys/ioctl.h>
-#include <ext2fs/ext2_fs.h>
+#include <sys/statvfs.h>
+#include <sys/xattr.h>
-#include "otutil.h"
-#include "ostree.h"
+#include "ostree-checksum-input-stream.h"
#include "ostree-core-private.h"
+#include "ostree-repo-file-enumerator.h"
#include "ostree-repo-private.h"
#include "ostree-sepolicy-private.h"
-#include "ostree-repo-file-enumerator.h"
-#include "ostree-checksum-input-stream.h"
#include "ostree-varint.h"
+#include "ostree.h"
+#include "otutil.h"
/* The standardized version of BTRFS_IOC_CLONE */
#ifndef FICLONE
-#define FICLONE _IOW(0x94, 9, int)
+#define FICLONE _IOW (0x94, 9, int)
#endif
/* Understanding ostree's fsync strategy
@@ -97,10 +97,8 @@ commit_tmp_dfd (OstreeRepo *self)
* is quite old, but Git also uses it for example.
*/
gboolean
-_ostree_repo_ensure_loose_objdir_at (int dfd,
- const char *loose_path,
- GCancellable *cancellable,
- GError **error)
+_ostree_repo_ensure_loose_objdir_at (int dfd, const char *loose_path, GCancellable *cancellable,
+ GError **error)
{
char loose_prefix[3];
@@ -120,22 +118,16 @@ _ostree_repo_ensure_loose_objdir_at (int dfd,
/* This GVariant is the header for content objects (regfiles and symlinks) */
static GVariant *
-create_file_metadata (guint32 uid,
- guint32 gid,
- guint32 mode,
- GVariant *xattrs)
+create_file_metadata (guint32 uid, guint32 gid, guint32 mode, GVariant *xattrs)
{
GVariant *ret_metadata = NULL;
- g_autoptr(GVariant) tmp_xattrs = NULL;
+ g_autoptr (GVariant) tmp_xattrs = NULL;
if (xattrs == NULL)
tmp_xattrs = g_variant_ref_sink (g_variant_new_array (G_VARIANT_TYPE ("(ayay)"), NULL, 0));
- ret_metadata = g_variant_new ("(uuu@a(ayay))",
- GUINT32_TO_BE (uid),
- GUINT32_TO_BE (gid),
- GUINT32_TO_BE (mode),
- xattrs ? xattrs : tmp_xattrs);
+ ret_metadata = g_variant_new ("(uuu@a(ayay))", GUINT32_TO_BE (uid), GUINT32_TO_BE (gid),
+ GUINT32_TO_BE (mode), xattrs ? xattrs : tmp_xattrs);
g_variant_ref_sink (ret_metadata);
return ret_metadata;
@@ -143,19 +135,14 @@ create_file_metadata (guint32 uid,
/* bare-user repositories store file metadata as a user xattr */
gboolean
-_ostree_write_bareuser_metadata (int fd,
- guint32 uid,
- guint32 gid,
- guint32 mode,
- GVariant *xattrs,
- GError **error)
+_ostree_write_bareuser_metadata (int fd, guint32 uid, guint32 gid, guint32 mode, GVariant *xattrs,
+ GError **error)
{
- g_autoptr(GVariant) filemeta = create_file_metadata (uid, gid, mode, xattrs);
+ g_autoptr (GVariant) filemeta = create_file_metadata (uid, gid, mode, xattrs);
- if (TEMP_FAILURE_RETRY (fsetxattr (fd, "user.ostreemeta",
- (char*)g_variant_get_data (filemeta),
- g_variant_get_size (filemeta),
- 0)) != 0)
+ if (TEMP_FAILURE_RETRY (fsetxattr (fd, "user.ostreemeta", (char *)g_variant_get_data (filemeta),
+ g_variant_get_size (filemeta), 0))
+ != 0)
return glnx_throw_errno_prefix (error, "fsetxattr(user.ostreemeta)");
return TRUE;
@@ -173,7 +160,7 @@ ot_security_smack_reset_dfd_name (int dfd, const char *name)
char buf[PATH_MAX];
/* See glnx-xattrs.c */
snprintf (buf, sizeof (buf), "/proc/self/fd/%d/%s", dfd, name);
- (void) lremovexattr (buf, XATTR_NAME_SMACK);
+ (void)lremovexattr (buf, XATTR_NAME_SMACK);
#endif
}
@@ -181,32 +168,27 @@ static void
ot_security_smack_reset_fd (int fd)
{
#ifdef WITH_SMACK
- (void) fremovexattr (fd, XATTR_NAME_SMACK);
+ (void)fremovexattr (fd, XATTR_NAME_SMACK);
#endif
}
/* Given an O_TMPFILE regular file, link it into place. */
gboolean
-_ostree_repo_commit_tmpf_final (OstreeRepo *self,
- const char *checksum,
- OstreeObjectType objtype,
- GLnxTmpfile *tmpf,
- GCancellable *cancellable,
- GError **error)
+_ostree_repo_commit_tmpf_final (OstreeRepo *self, const char *checksum, OstreeObjectType objtype,
+ GLnxTmpfile *tmpf, GCancellable *cancellable, GError **error)
{
char tmpbuf[_OSTREE_LOOSE_PATH_MAX];
_ostree_loose_path (tmpbuf, checksum, objtype, self->mode);
int dest_dfd = commit_dest_dfd (self);
- if (!_ostree_repo_ensure_loose_objdir_at (dest_dfd, tmpbuf,
- cancellable, error))
+ if (!_ostree_repo_ensure_loose_objdir_at (dest_dfd, tmpbuf, cancellable, error))
return FALSE;
if (!_ostree_tmpf_fsverity (self, tmpf, error))
return FALSE;
- if (!glnx_link_tmpfile_at (tmpf, GLNX_LINK_TMPFILE_NOREPLACE_IGNORE_EXIST,
- dest_dfd, tmpbuf, error))
+ if (!glnx_link_tmpfile_at (tmpf, GLNX_LINK_TMPFILE_NOREPLACE_IGNORE_EXIST, dest_dfd, tmpbuf,
+ error))
return FALSE;
/* We're done with the fd */
glnx_tmpfile_clear (tmpf);
@@ -217,24 +199,18 @@ _ostree_repo_commit_tmpf_final (OstreeRepo *self,
* rename it into place.
*/
static gboolean
-commit_path_final (OstreeRepo *self,
- const char *checksum,
- OstreeObjectType objtype,
- OtCleanupUnlinkat *tmp_path,
- GCancellable *cancellable,
- GError **error)
+commit_path_final (OstreeRepo *self, const char *checksum, OstreeObjectType objtype,
+ OtCleanupUnlinkat *tmp_path, GCancellable *cancellable, GError **error)
{
/* The final renameat() */
char tmpbuf[_OSTREE_LOOSE_PATH_MAX];
_ostree_loose_path (tmpbuf, checksum, objtype, self->mode);
int dest_dfd = commit_dest_dfd (self);
- if (!_ostree_repo_ensure_loose_objdir_at (dest_dfd, tmpbuf,
- cancellable, error))
+ if (!_ostree_repo_ensure_loose_objdir_at (dest_dfd, tmpbuf, cancellable, error))
return FALSE;
- if (renameat (tmp_path->dfd, tmp_path->path,
- dest_dfd, tmpbuf) == -1)
+ if (renameat (tmp_path->dfd, tmp_path->path, dest_dfd, tmpbuf) == -1)
{
if (errno != EEXIST)
return glnx_throw_errno_prefix (error, "Storing file '%s'", tmp_path->path);
@@ -249,21 +225,14 @@ commit_path_final (OstreeRepo *self,
return TRUE;
}
-
/* Given either a file or symlink, apply the final metadata to it depending on
* the repository mode. Note that @checksum is assumed to have been validated by
* the caller.
*/
static gboolean
-commit_loose_regfile_object (OstreeRepo *self,
- const char *checksum,
- GLnxTmpfile *tmpf,
- guint32 uid,
- guint32 gid,
- guint32 mode,
- GVariant *xattrs,
- GCancellable *cancellable,
- GError **error)
+commit_loose_regfile_object (OstreeRepo *self, const char *checksum, GLnxTmpfile *tmpf, guint32 uid,
+ guint32 gid, guint32 mode, GVariant *xattrs, GCancellable *cancellable,
+ GError **error)
{
if (self->mode == OSTREE_REPO_MODE_BARE)
{
@@ -318,7 +287,8 @@ commit_loose_regfile_object (OstreeRepo *self,
* to determine whether or not source files need to be compiled,
* set the modification time to OSTREE_TIMESTAMP.
*/
- const struct timespec times[2] = { { OSTREE_TIMESTAMP, UTIME_OMIT }, { OSTREE_TIMESTAMP, 0} };
+ const struct timespec times[2]
+ = { { OSTREE_TIMESTAMP, UTIME_OMIT }, { OSTREE_TIMESTAMP, 0 } };
if (TEMP_FAILURE_RETRY (futimens (tmpf->fd, times)) < 0)
return glnx_throw_errno_prefix (error, "futimens");
}
@@ -332,8 +302,8 @@ commit_loose_regfile_object (OstreeRepo *self,
return glnx_throw_errno_prefix (error, "fsync");
}
- if (!_ostree_repo_commit_tmpf_final (self, checksum, OSTREE_OBJECT_TYPE_FILE,
- tmpf, cancellable, error))
+ if (!_ostree_repo_commit_tmpf_final (self, checksum, OSTREE_OBJECT_TYPE_FILE, tmpf, cancellable,
+ error))
return FALSE;
return TRUE;
@@ -348,9 +318,7 @@ typedef struct
} OstreeContentSizeCacheEntry;
static OstreeContentSizeCacheEntry *
-content_size_cache_entry_new (OstreeObjectType objtype,
- goffset unpacked,
- goffset archived)
+content_size_cache_entry_new (OstreeObjectType objtype, goffset unpacked, goffset archived)
{
OstreeContentSizeCacheEntry *entry = g_slice_new0 (OstreeContentSizeCacheEntry);
@@ -369,8 +337,7 @@ content_size_cache_entry_free (gpointer entry)
}
void
-_ostree_repo_setup_generate_sizes (OstreeRepo *self,
- OstreeRepoCommitModifier *modifier)
+_ostree_repo_setup_generate_sizes (OstreeRepo *self, OstreeRepoCommitModifier *modifier)
{
if (modifier && modifier->flags & OSTREE_REPO_COMMIT_MODIFIER_FLAGS_GENERATE_SIZES)
{
@@ -391,14 +358,12 @@ static void
repo_ensure_size_entries (OstreeRepo *self)
{
if (G_UNLIKELY (self->object_sizes == NULL))
- self->object_sizes = g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free, content_size_cache_entry_free);
+ self->object_sizes
+ = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, content_size_cache_entry_free);
}
static gboolean
-repo_has_size_entry (OstreeRepo *self,
- OstreeObjectType objtype,
- const gchar *checksum)
+repo_has_size_entry (OstreeRepo *self, OstreeObjectType objtype, const gchar *checksum)
{
/* Only file, dirtree and dirmeta objects appropriate for size metadata */
if (objtype > OSTREE_OBJECT_TYPE_DIR_META)
@@ -409,28 +374,23 @@ repo_has_size_entry (OstreeRepo *self,
}
static void
-repo_store_size_entry (OstreeRepo *self,
- OstreeObjectType objtype,
- const gchar *checksum,
- goffset unpacked,
- goffset archived)
+repo_store_size_entry (OstreeRepo *self, OstreeObjectType objtype, const gchar *checksum,
+ goffset unpacked, goffset archived)
{
/* Only file, dirtree and dirmeta objects appropriate for size metadata */
if (objtype > OSTREE_OBJECT_TYPE_DIR_META)
return;
repo_ensure_size_entries (self);
- g_hash_table_replace (self->object_sizes,
- g_strdup (checksum),
+ g_hash_table_replace (self->object_sizes, g_strdup (checksum),
content_size_cache_entry_new (objtype, unpacked, archived));
}
static int
-compare_ascii_checksums_for_sorting (gconstpointer a_pp,
- gconstpointer b_pp)
+compare_ascii_checksums_for_sorting (gconstpointer a_pp, gconstpointer b_pp)
{
- char *a = *((char**)a_pp);
- char *b = *((char**)b_pp);
+ char *a = *((char **)a_pp);
+ char *b = *((char **)b_pp);
return strcmp (a, b);
}
@@ -439,24 +399,22 @@ compare_ascii_checksums_for_sorting (gconstpointer a_pp,
* Create sizes metadata GVariant and add it to the metadata variant given.
*/
static GVariant *
-add_size_index_to_metadata (OstreeRepo *self,
- GVariant *original_metadata)
+add_size_index_to_metadata (OstreeRepo *self, GVariant *original_metadata)
{
- g_autoptr(GVariantBuilder) builder = NULL;
+ g_autoptr (GVariantBuilder) builder = NULL;
/* original_metadata may be NULL */
builder = ot_util_variant_builder_from_variant (original_metadata, G_VARIANT_TYPE ("a{sv}"));
- if (self->object_sizes &&
- g_hash_table_size (self->object_sizes) > 0)
+ if (self->object_sizes && g_hash_table_size (self->object_sizes) > 0)
{
GVariantBuilder index_builder;
g_variant_builder_init (&index_builder,
G_VARIANT_TYPE ("a" _OSTREE_OBJECT_SIZES_ENTRY_SIGNATURE));
/* Sort the checksums so we can bsearch if desired */
- g_autoptr(GPtrArray) sorted_keys = g_ptr_array_new ();
- GLNX_HASH_TABLE_FOREACH (self->object_sizes, const char*, e_checksum)
+ g_autoptr (GPtrArray) sorted_keys = g_ptr_array_new ();
+ GLNX_HASH_TABLE_FOREACH (self->object_sizes, const char *, e_checksum)
g_ptr_array_add (sorted_keys, (gpointer)e_checksum);
g_ptr_array_sort (sorted_keys, compare_ascii_checksums_for_sorting);
@@ -464,19 +422,19 @@ add_size_index_to_metadata (OstreeRepo *self,
{
guint8 csum[OSTREE_SHA256_DIGEST_LEN];
const char *e_checksum = sorted_keys->pdata[i];
- g_autoptr(GString) buffer = g_string_new (NULL);
+ g_autoptr (GString) buffer = g_string_new (NULL);
ostree_checksum_inplace_to_bytes (e_checksum, csum);
- g_string_append_len (buffer, (char*)csum, sizeof (csum));
+ g_string_append_len (buffer, (char *)csum, sizeof (csum));
- OstreeContentSizeCacheEntry *e_size =
- g_hash_table_lookup (self->object_sizes, e_checksum);
+ OstreeContentSizeCacheEntry *e_size
+ = g_hash_table_lookup (self->object_sizes, e_checksum);
_ostree_write_varuint64 (buffer, e_size->archived);
_ostree_write_varuint64 (buffer, e_size->unpacked);
- g_string_append_c (buffer, (gchar) e_size->objtype);
+ g_string_append_c (buffer, (gchar)e_size->objtype);
g_variant_builder_add (&index_builder, "@ay",
- ot_gvariant_new_bytearray ((guint8*)buffer->str, buffer->len));
+ ot_gvariant_new_bytearray ((guint8 *)buffer->str, buffer->len));
}
g_variant_builder_add (builder, "{sv}", "ostree.sizes",
@@ -490,9 +448,7 @@ add_size_index_to_metadata (OstreeRepo *self,
}
static gboolean
-throw_min_free_space_error (OstreeRepo *self,
- guint64 bytes_required,
- GError **error)
+throw_min_free_space_error (OstreeRepo *self, guint64 bytes_required, GError **error)
{
const char *err_msg = NULL;
g_autofree char *err_msg_owned = NULL;
@@ -500,18 +456,22 @@ throw_min_free_space_error (OstreeRepo *self,
if (bytes_required > 0)
{
g_autofree char *formatted_required = g_format_size (bytes_required);
- err_msg = err_msg_owned = g_strdup_printf ("would be exceeded, at least %s requested", formatted_required);
+ err_msg = err_msg_owned
+ = g_strdup_printf ("would be exceeded, at least %s requested", formatted_required);
}
else
- err_msg = "would be exceeded";
+ err_msg = "would be exceeded";
if (self->min_free_space_mb > 0)
- return glnx_throw (error, "min-free-space-size %" G_GUINT64_FORMAT "MB %s", self->min_free_space_mb, err_msg);
+ return glnx_throw (error, "min-free-space-size %" G_GUINT64_FORMAT "MB %s",
+ self->min_free_space_mb, err_msg);
else
- return glnx_throw (error, "min-free-space-percent '%u%%' %s", self->min_free_space_percent, err_msg);
+ return glnx_throw (error, "min-free-space-percent '%u%%' %s", self->min_free_space_percent,
+ err_msg);
}
-typedef struct {
+typedef struct
+{
gboolean initialized;
GLnxTmpfile tmpf;
char *expected_checksum;
@@ -530,23 +490,17 @@ G_STATIC_ASSERT (sizeof (OstreeRepoBareContent) >= sizeof (OstreeRealRepoBareCon
* to be used also by the dfd_iter commit path.
*/
gboolean
-_ostree_repo_bare_content_open (OstreeRepo *self,
- const char *expected_checksum,
- guint64 content_len,
- guint uid,
- guint gid,
- guint mode,
- GVariant *xattrs,
- OstreeRepoBareContent *out_regwrite,
- GCancellable *cancellable,
- GError **error)
+_ostree_repo_bare_content_open (OstreeRepo *self, const char *expected_checksum,
+ guint64 content_len, guint uid, guint gid, guint mode,
+ GVariant *xattrs, OstreeRepoBareContent *out_regwrite,
+ GCancellable *cancellable, GError **error)
{
- OstreeRealRepoBareContent *real = (OstreeRealRepoBareContent*) out_regwrite;
+ OstreeRealRepoBareContent *real = (OstreeRealRepoBareContent *)out_regwrite;
g_assert (!real->initialized);
real->initialized = TRUE;
g_assert (S_ISREG (mode));
- if (!glnx_open_tmpfile_linkable_at (commit_tmp_dfd (self), ".", O_WRONLY|O_CLOEXEC,
- &real->tmpf, error))
+ if (!glnx_open_tmpfile_linkable_at (commit_tmp_dfd (self), ".", O_WRONLY | O_CLOEXEC, &real->tmpf,
+ error))
return FALSE;
ot_checksum_init (&real->checksum);
real->expected_checksum = g_strdup (expected_checksum);
@@ -558,22 +512,19 @@ _ostree_repo_bare_content_open (OstreeRepo *self,
real->xattrs = xattrs ? g_variant_ref (xattrs) : NULL;
/* Initialize the checksum with the header info */
- g_autoptr(GFileInfo) finfo = _ostree_mode_uidgid_to_gfileinfo (mode, uid, gid);
- g_autoptr(GBytes) header = _ostree_file_header_new (finfo, xattrs);
+ g_autoptr (GFileInfo) finfo = _ostree_mode_uidgid_to_gfileinfo (mode, uid, gid);
+ g_autoptr (GBytes) header = _ostree_file_header_new (finfo, xattrs);
ot_checksum_update_bytes (&real->checksum, header);
return TRUE;
}
gboolean
-_ostree_repo_bare_content_write (OstreeRepo *repo,
- OstreeRepoBareContent *barewrite,
- const guint8 *buf,
- size_t len,
- GCancellable *cancellable,
- GError **error)
+_ostree_repo_bare_content_write (OstreeRepo *repo, OstreeRepoBareContent *barewrite,
+ const guint8 *buf, size_t len, GCancellable *cancellable,
+ GError **error)
{
- OstreeRealRepoBareContent *real = (OstreeRealRepoBareContent*) barewrite;
+ OstreeRealRepoBareContent *real = (OstreeRealRepoBareContent *)barewrite;
g_assert (real->initialized);
ot_checksum_update (&real->checksum, buf, len);
if (glnx_loop_write (real->tmpf.fd, buf, len) < 0)
@@ -582,14 +533,11 @@ _ostree_repo_bare_content_write (OstreeRepo *repo,
}
gboolean
-_ostree_repo_bare_content_commit (OstreeRepo *self,
- OstreeRepoBareContent *barewrite,
- char *checksum_buf,
- size_t buflen,
- GCancellable *cancellable,
- GError **error)
+_ostree_repo_bare_content_commit (OstreeRepo *self, OstreeRepoBareContent *barewrite,
+ char *checksum_buf, size_t buflen, GCancellable *cancellable,
+ GError **error)
{
- OstreeRealRepoBareContent *real = (OstreeRealRepoBareContent*) barewrite;
+ OstreeRealRepoBareContent *real = (OstreeRealRepoBareContent *)barewrite;
g_assert (real->initialized);
if ((self->min_free_space_percent > 0 || self->min_free_space_mb > 0) && self->in_transaction)
@@ -615,16 +563,13 @@ _ostree_repo_bare_content_commit (OstreeRepo *self,
ot_checksum_get_hexdigest (&real->checksum, checksum_buf, buflen);
- if (real->expected_checksum &&
- !_ostree_compare_object_checksum (OSTREE_OBJECT_TYPE_FILE,
- real->expected_checksum, checksum_buf,
- error))
+ if (real->expected_checksum
+ && !_ostree_compare_object_checksum (OSTREE_OBJECT_TYPE_FILE, real->expected_checksum,
+ checksum_buf, error))
return FALSE;
- if (!commit_loose_regfile_object (self, checksum_buf,
- &real->tmpf, real->uid, real->gid,
- real->mode, real->xattrs,
- cancellable, error))
+ if (!commit_loose_regfile_object (self, checksum_buf, &real->tmpf, real->uid, real->gid,
+ real->mode, real->xattrs, cancellable, error))
return FALSE;
/* Let's have a guarantee that after commit the object is cleaned up */
@@ -635,7 +580,7 @@ _ostree_repo_bare_content_commit (OstreeRepo *self,
void
_ostree_repo_bare_content_cleanup (OstreeRepoBareContent *regwrite)
{
- OstreeRealRepoBareContent *real = (OstreeRealRepoBareContent*) regwrite;
+ OstreeRealRepoBareContent *real = (OstreeRealRepoBareContent *)regwrite;
if (!real->initialized)
return;
glnx_tmpfile_clear (&real->tmpf);
@@ -650,16 +595,15 @@ _ostree_repo_bare_content_cleanup (OstreeRepoBareContent *regwrite)
* and content objects in all bare-type repos.
*/
static gboolean
-create_regular_tmpfile_linkable_with_content (OstreeRepo *self,
- guint64 length,
- GInputStream *input,
- GLnxTmpfile *out_tmpf,
- GCancellable *cancellable,
+create_regular_tmpfile_linkable_with_content (OstreeRepo *self, guint64 length, GInputStream *input,
+ GLnxTmpfile *out_tmpf, GCancellable *cancellable,
GError **error)
{
- g_auto(GLnxTmpfile) tmpf = { 0, };
- if (!glnx_open_tmpfile_linkable_at (commit_tmp_dfd (self), ".", O_WRONLY|O_CLOEXEC,
- &tmpf, error))
+ g_auto (GLnxTmpfile) tmpf = {
+ 0,
+ };
+ if (!glnx_open_tmpfile_linkable_at (commit_tmp_dfd (self), ".", O_WRONLY | O_CLOEXEC, &tmpf,
+ error))
return FALSE;
if (!glnx_try_fallocate (tmpf.fd, 0, length, error))
@@ -667,7 +611,7 @@ create_regular_tmpfile_linkable_with_content (OstreeRepo *self,
if (G_IS_FILE_DESCRIPTOR_BASED (input))
{
- int infd = g_file_descriptor_based_get_fd ((GFileDescriptorBased*) input);
+ int infd = g_file_descriptor_based_get_fd ((GFileDescriptorBased *)input);
if (glnx_regfile_copy_bytes (infd, tmpf.fd, (off_t)length) < 0)
return glnx_throw_errno_prefix (error, "regfile copy");
}
@@ -678,17 +622,20 @@ create_regular_tmpfile_linkable_with_content (OstreeRepo *self,
* e.g. 10 bytes but is actually gigabytes.
* - Due to GLib bugs that pointlessly calls `poll()` on the output fd for every write
*/
- gsize buf_size = MIN(length, 1048576);
- g_autofree gchar * buf = g_malloc(buf_size);
+ gsize buf_size = MIN (length, 1048576);
+ g_autofree gchar *buf = g_malloc (buf_size);
guint64 remaining = length;
while (remaining > 0)
{
- const gssize bytes_read =
- g_input_stream_read (input, buf, MIN (remaining, buf_size), cancellable, error);
+ const gssize bytes_read
+ = g_input_stream_read (input, buf, MIN (remaining, buf_size), cancellable, error);
if (bytes_read < 0)
return FALSE;
else if (bytes_read == 0)
- return glnx_throw (error, "Unexpected EOF with %" G_GUINT64_FORMAT "/%" G_GUINT64_FORMAT " bytes remaining", remaining, length);
+ return glnx_throw (error,
+ "Unexpected EOF with %" G_GUINT64_FORMAT "/%" G_GUINT64_FORMAT
+ " bytes remaining",
+ remaining, length);
if (glnx_loop_write (tmpf.fd, buf, bytes_read) < 0)
return glnx_throw_errno_prefix (error, "write");
remaining -= bytes_read;
@@ -698,7 +645,8 @@ create_regular_tmpfile_linkable_with_content (OstreeRepo *self,
if (!glnx_fchmod (tmpf.fd, 0644, error))
return FALSE;
- *out_tmpf = tmpf; tmpf.initialized = FALSE;
+ *out_tmpf = tmpf;
+ tmpf.initialized = FALSE;
return TRUE;
}
@@ -709,17 +657,20 @@ _check_support_reflink (OstreeRepo *dest, gboolean *supported, GError **error)
if (g_atomic_int_get (&dest->fs_support_reflink) == 0)
{
glnx_autofd int src_fd = -1;
- g_auto(GLnxTmpfile) dest_tmpf = { 0, };
+ g_auto (GLnxTmpfile) dest_tmpf = {
+ 0,
+ };
if (!glnx_openat_rdonly (dest->repo_dir_fd, "config", TRUE, &src_fd, error))
return FALSE;
- if (!glnx_open_tmpfile_linkable_at (commit_tmp_dfd (dest), ".", O_WRONLY|O_CLOEXEC,
+ if (!glnx_open_tmpfile_linkable_at (commit_tmp_dfd (dest), ".", O_WRONLY | O_CLOEXEC,
&dest_tmpf, error))
return FALSE;
if (ioctl (dest_tmpf.fd, FICLONE, src_fd) == 0)
g_atomic_int_set (&dest->fs_support_reflink, 1);
- else if (errno == EOPNOTSUPP) /* Ignore other kind of errors as they might be temporary failures */
+ else if (errno
+ == EOPNOTSUPP) /* Ignore other kind of errors as they might be temporary failures */
g_atomic_int_set (&dest->fs_support_reflink, -1);
}
*supported = g_atomic_int_get (&dest->fs_support_reflink) >= 0;
@@ -727,12 +678,8 @@ _check_support_reflink (OstreeRepo *dest, gboolean *supported, GError **error)
}
static gboolean
-_create_payload_link (OstreeRepo *self,
- const char *checksum,
- const char *payload_checksum,
- GFileInfo *file_info,
- GCancellable *cancellable,
- GError **error)
+_create_payload_link (OstreeRepo *self, const char *checksum, const char *payload_checksum,
+ GFileInfo *file_info, GCancellable *cancellable, GError **error)
{
gboolean reflinks_supported = FALSE;
@@ -743,7 +690,8 @@ _create_payload_link (OstreeRepo *self,
return TRUE;
if (g_file_info_get_file_type (file_info) != G_FILE_TYPE_REGULAR
- || !G_IN_SET(self->mode, OSTREE_REPO_MODE_BARE, OSTREE_REPO_MODE_BARE_USER, OSTREE_REPO_MODE_BARE_USER_ONLY))
+ || !G_IN_SET (self->mode, OSTREE_REPO_MODE_BARE, OSTREE_REPO_MODE_BARE_USER,
+ OSTREE_REPO_MODE_BARE_USER_ONLY))
return TRUE;
if (payload_checksum == NULL || g_file_info_get_size (file_info) < self->payload_link_threshold)
@@ -751,7 +699,8 @@ _create_payload_link (OstreeRepo *self,
char target_buf[_OSTREE_LOOSE_PATH_MAX + _OSTREE_PAYLOAD_LINK_PREFIX_LEN];
strcpy (target_buf, _OSTREE_PAYLOAD_LINK_PREFIX);
- _ostree_loose_path (target_buf + _OSTREE_PAYLOAD_LINK_PREFIX_LEN, checksum, OSTREE_OBJECT_TYPE_FILE, self->mode);
+ _ostree_loose_path (target_buf + _OSTREE_PAYLOAD_LINK_PREFIX_LEN, checksum,
+ OSTREE_OBJECT_TYPE_FILE, self->mode);
if (symlinkat (target_buf, commit_tmp_dfd (self), payload_checksum) < 0)
{
@@ -760,8 +709,10 @@ _create_payload_link (OstreeRepo *self,
}
else
{
- g_auto(OtCleanupUnlinkat) tmp_unlinker = { commit_tmp_dfd (self), g_strdup (payload_checksum) };
- if (!commit_path_final (self, payload_checksum, OSTREE_OBJECT_TYPE_PAYLOAD_LINK, &tmp_unlinker, cancellable, error))
+ g_auto (OtCleanupUnlinkat) tmp_unlinker
+ = { commit_tmp_dfd (self), g_strdup (payload_checksum) };
+ if (!commit_path_final (self, payload_checksum, OSTREE_OBJECT_TYPE_PAYLOAD_LINK,
+ &tmp_unlinker, cancellable, error))
return FALSE;
}
@@ -769,17 +720,14 @@ _create_payload_link (OstreeRepo *self,
}
static gboolean
-_import_payload_link (OstreeRepo *dest_repo,
- OstreeRepo *src_repo,
- const char *checksum,
- GCancellable *cancellable,
- GError **error)
+_import_payload_link (OstreeRepo *dest_repo, OstreeRepo *src_repo, const char *checksum,
+ GCancellable *cancellable, GError **error)
{
gboolean reflinks_supported = FALSE;
g_autofree char *payload_checksum = NULL;
- g_autoptr(GInputStream) is = NULL;
+ g_autoptr (GInputStream) is = NULL;
glnx_unref_object OtChecksumInstream *checksum_payload = NULL;
- g_autoptr(GFileInfo) file_info = NULL;
+ g_autoptr (GFileInfo) file_info = NULL;
/* The two repositories are on different devices */
if (src_repo->device != dest_repo->device)
@@ -791,7 +739,8 @@ _import_payload_link (OstreeRepo *dest_repo,
if (!reflinks_supported)
return TRUE;
- if (!G_IN_SET(dest_repo->mode, OSTREE_REPO_MODE_BARE, OSTREE_REPO_MODE_BARE_USER, OSTREE_REPO_MODE_BARE_USER_ONLY))
+ if (!G_IN_SET (dest_repo->mode, OSTREE_REPO_MODE_BARE, OSTREE_REPO_MODE_BARE_USER,
+ OSTREE_REPO_MODE_BARE_USER_ONLY))
return TRUE;
if (!ostree_repo_load_file (src_repo, checksum, &is, &file_info, NULL, cancellable, error))
@@ -807,7 +756,7 @@ _import_payload_link (OstreeRepo *dest_repo,
while (remaining)
{
char buf[8192];
- gssize ret = g_input_stream_read ((GInputStream *) checksum_payload, buf,
+ gssize ret = g_input_stream_read ((GInputStream *)checksum_payload, buf,
MIN (sizeof (buf), remaining), cancellable, error);
if (ret < 0)
return FALSE;
@@ -815,17 +764,14 @@ _import_payload_link (OstreeRepo *dest_repo,
}
payload_checksum = ot_checksum_instream_get_string (checksum_payload);
- return _create_payload_link (dest_repo, checksum, payload_checksum, file_info, cancellable, error);
+ return _create_payload_link (dest_repo, checksum, payload_checksum, file_info, cancellable,
+ error);
}
static gboolean
-_try_clone_from_payload_link (OstreeRepo *self,
- OstreeRepo *dest_repo,
- const char *payload_checksum,
- GFileInfo *file_info,
- GLnxTmpfile *tmpf,
- GCancellable *cancellable,
- GError **error)
+_try_clone_from_payload_link (OstreeRepo *self, OstreeRepo *dest_repo, const char *payload_checksum,
+ GFileInfo *file_info, GLnxTmpfile *tmpf, GCancellable *cancellable,
+ GError **error)
{
gboolean reflinks_supported = FALSE;
int dfd_searches[] = { -1, self->objects_dir_fd };
@@ -848,13 +794,14 @@ _try_clone_from_payload_link (OstreeRepo *self,
char loose_path_buf[_OSTREE_LOOSE_PATH_MAX];
char loose_path_target_buf[_OSTREE_LOOSE_PATH_MAX];
char target_buf[_OSTREE_LOOSE_PATH_MAX + _OSTREE_PAYLOAD_LINK_PREFIX_LEN];
- char target_checksum[OSTREE_SHA256_STRING_LEN+1];
+ char target_checksum[OSTREE_SHA256_STRING_LEN + 1];
int dfd = dfd_searches[i];
ssize_t size;
if (dfd == -1)
continue;
- _ostree_loose_path (loose_path_buf, payload_checksum, OSTREE_OBJECT_TYPE_PAYLOAD_LINK, self->mode);
+ _ostree_loose_path (loose_path_buf, payload_checksum, OSTREE_OBJECT_TYPE_PAYLOAD_LINK,
+ self->mode);
size = TEMP_FAILURE_RETRY (readlinkat (dfd, loose_path_buf, target_buf, sizeof (target_buf)));
if (size < 0)
@@ -867,15 +814,18 @@ _try_clone_from_payload_link (OstreeRepo *self,
if (size < OSTREE_SHA256_STRING_LEN + _OSTREE_PAYLOAD_LINK_PREFIX_LEN)
return glnx_throw (error, "invalid data size for %s", loose_path_buf);
- sprintf (target_checksum, "%.2s%.62s", target_buf + _OSTREE_PAYLOAD_LINK_PREFIX_LEN, target_buf + _OSTREE_PAYLOAD_LINK_PREFIX_LEN + 3);
+ sprintf (target_checksum, "%.2s%.62s", target_buf + _OSTREE_PAYLOAD_LINK_PREFIX_LEN,
+ target_buf + _OSTREE_PAYLOAD_LINK_PREFIX_LEN + 3);
- _ostree_loose_path (loose_path_target_buf, target_checksum, OSTREE_OBJECT_TYPE_FILE, self->mode);
+ _ostree_loose_path (loose_path_target_buf, target_checksum, OSTREE_OBJECT_TYPE_FILE,
+ self->mode);
if (!ot_openat_ignore_enoent (dfd, loose_path_target_buf, &fdf, error))
return FALSE;
if (fdf < 0)
{
- /* If the link is referring to an object that doesn't exist anymore in the repository, just unlink it. */
+ /* If the link is referring to an object that doesn't exist anymore in the repository,
+ * just unlink it. */
if (!glnx_unlinkat (dfd, loose_path_buf, 0, error))
return FALSE;
}
@@ -889,7 +839,8 @@ _try_clone_from_payload_link (OstreeRepo *self,
}
}
if (self->parent_repo)
- return _try_clone_from_payload_link (self->parent_repo, dest_repo, payload_checksum, file_info, tmpf, cancellable, error);
+ return _try_clone_from_payload_link (self->parent_repo, dest_repo, payload_checksum, file_info,
+ tmpf, cancellable, error);
return TRUE;
}
@@ -901,14 +852,9 @@ _try_clone_from_payload_link (OstreeRepo *self,
* knows the checksum.
*/
static gboolean
-write_content_object (OstreeRepo *self,
- const char *expected_checksum,
- GInputStream *input,
- GFileInfo *file_info,
- GVariant *xattrs,
- guchar **out_csum,
- GCancellable *cancellable,
- GError **error)
+write_content_object (OstreeRepo *self, const char *expected_checksum, GInputStream *input,
+ GFileInfo *file_info, GVariant *xattrs, guchar **out_csum,
+ GCancellable *cancellable, GError **error)
{
g_assert (expected_checksum != NULL || out_csum != NULL);
@@ -918,12 +864,12 @@ write_content_object (OstreeRepo *self,
return FALSE;
OstreeRepoMode repo_mode = ostree_repo_get_mode (self);
- if (repo_mode == OSTREE_REPO_MODE_BARE_SPLIT_XATTRS &&
- g_getenv ("OSTREE_EXP_WRITE_BARE_SPLIT_XATTRS") == NULL)
+ if (repo_mode == OSTREE_REPO_MODE_BARE_SPLIT_XATTRS
+ && g_getenv ("OSTREE_EXP_WRITE_BARE_SPLIT_XATTRS") == NULL)
return glnx_throw (error, "Not allowed due to repo mode");
- GInputStream *file_input; /* Unowned alias */
- g_autoptr(GInputStream) file_input_owned = NULL; /* We need a temporary for bare-user symlinks */
+ GInputStream *file_input; /* Unowned alias */
+ g_autoptr (GInputStream) file_input_owned = NULL; /* We need a temporary for bare-user symlinks */
glnx_unref_object OtChecksumInstream *checksum_input = NULL;
glnx_unref_object OtChecksumInstream *checksum_payload_input = NULL;
const GFileType object_file_type = g_file_info_get_file_type (file_info);
@@ -936,32 +882,34 @@ write_content_object (OstreeRepo *self,
* checksum over the data we actually use.
*/
gboolean reflinks_supported = FALSE;
- g_autoptr(GBytes) header = _ostree_file_header_new (file_info, xattrs);
+ g_autoptr (GBytes) header = _ostree_file_header_new (file_info, xattrs);
size_t len;
const guint8 *buf = g_bytes_get_data (header, &len);
/* Give a null input if there's no content */
- g_autoptr(GInputStream) null_input = NULL;
+ g_autoptr (GInputStream) null_input = NULL;
if (!input)
{
null_input = input = g_memory_input_stream_new_from_data ("", 0, NULL);
- (void) null_input; /* quiet static analysis */
+ (void)null_input; /* quiet static analysis */
}
- checksum_input = ot_checksum_instream_new_with_start (input, G_CHECKSUM_SHA256,
- buf, len);
+ checksum_input = ot_checksum_instream_new_with_start (input, G_CHECKSUM_SHA256, buf, len);
if (!_check_support_reflink (self, &reflinks_supported, error))
return FALSE;
- if (xattrs == NULL || !G_IN_SET(self->mode, OSTREE_REPO_MODE_BARE, OSTREE_REPO_MODE_BARE_USER, OSTREE_REPO_MODE_BARE_USER_ONLY) || object_file_type != G_FILE_TYPE_REGULAR ||
- !reflinks_supported)
- file_input = (GInputStream*)checksum_input;
+ if (xattrs == NULL
+ || !G_IN_SET (self->mode, OSTREE_REPO_MODE_BARE, OSTREE_REPO_MODE_BARE_USER,
+ OSTREE_REPO_MODE_BARE_USER_ONLY)
+ || object_file_type != G_FILE_TYPE_REGULAR || !reflinks_supported)
+ file_input = (GInputStream *)checksum_input;
else
{
/* The payload checksum-input reads from the full object checksum-input; this
* means it skips the header.
*/
- checksum_payload_input = ot_checksum_instream_new ((GInputStream*)checksum_input, G_CHECKSUM_SHA256);
- file_input = (GInputStream*)checksum_payload_input;
+ checksum_payload_input
+ = ot_checksum_instream_new ((GInputStream *)checksum_input, G_CHECKSUM_SHA256);
+ file_input = (GInputStream *)checksum_payload_input;
}
}
else
@@ -986,7 +934,7 @@ write_content_object (OstreeRepo *self,
if (repo_mode == OSTREE_REPO_MODE_BARE_USER && object_file_type == G_FILE_TYPE_SYMBOLIC_LINK)
{
const char *target_str = g_file_info_get_symlink_target (file_info);
- g_autoptr(GBytes) target = g_bytes_new (target_str, strlen (target_str) + 1);
+ g_autoptr (GBytes) target = g_bytes_new (target_str, strlen (target_str) + 1);
/* Include the terminating zero so we can e.g. mmap this file */
file_input = file_input_owned = g_memory_input_stream_new_from_bytes (target);
@@ -1024,44 +972,47 @@ write_content_object (OstreeRepo *self,
*
* We use GLnxTmpfile for regular files, and OtCleanupUnlinkat for symlinks.
*/
- g_auto(OtCleanupUnlinkat) tmp_unlinker = { commit_tmp_dfd (self), NULL };
- g_auto(GLnxTmpfile) tmpf = { 0, };
+ g_auto (OtCleanupUnlinkat) tmp_unlinker = { commit_tmp_dfd (self), NULL };
+ g_auto (GLnxTmpfile) tmpf = {
+ 0,
+ };
goffset unpacked_size = 0;
/* Is it a symlink physically? */
if (phys_object_is_symlink)
{
/* This will not be hit for bare-user or archive */
- g_assert (self->mode == OSTREE_REPO_MODE_BARE || self->mode == OSTREE_REPO_MODE_BARE_USER_ONLY);
+ g_assert (self->mode == OSTREE_REPO_MODE_BARE
+ || self->mode == OSTREE_REPO_MODE_BARE_USER_ONLY);
if (!_ostree_make_temporary_symlink_at (commit_tmp_dfd (self),
g_file_info_get_symlink_target (file_info),
- &tmp_unlinker.path,
- cancellable, error))
+ &tmp_unlinker.path, cancellable, error))
return FALSE;
}
else if (repo_mode != OSTREE_REPO_MODE_ARCHIVE)
{
- if (!create_regular_tmpfile_linkable_with_content (self, size, file_input,
- &tmpf, cancellable, error))
+ if (!create_regular_tmpfile_linkable_with_content (self, size, file_input, &tmpf, cancellable,
+ error))
return FALSE;
}
else
{
- g_autoptr(GConverter) zlib_compressor = NULL;
- g_autoptr(GOutputStream) compressed_out_stream = NULL;
- g_autoptr(GOutputStream) temp_out = NULL;
+ g_autoptr (GConverter) zlib_compressor = NULL;
+ g_autoptr (GOutputStream) compressed_out_stream = NULL;
+ g_autoptr (GOutputStream) temp_out = NULL;
g_assert (repo_mode == OSTREE_REPO_MODE_ARCHIVE);
- if (!glnx_open_tmpfile_linkable_at (commit_tmp_dfd (self), ".", O_WRONLY|O_CLOEXEC,
- &tmpf, error))
+ if (!glnx_open_tmpfile_linkable_at (commit_tmp_dfd (self), ".", O_WRONLY | O_CLOEXEC, &tmpf,
+ error))
return FALSE;
temp_out = g_unix_output_stream_new (tmpf.fd, FALSE);
- g_autoptr(GBytes) file_meta_header = _ostree_zlib_file_header_new (file_info, xattrs);
+ g_autoptr (GBytes) file_meta_header = _ostree_zlib_file_header_new (file_info, xattrs);
gsize file_meta_len;
- const guint8* file_meta_buf = g_bytes_get_data (file_meta_header, &file_meta_len);
+ const guint8 *file_meta_buf = g_bytes_get_data (file_meta_header, &file_meta_len);
- { gsize bytes_written;
+ {
+ gsize bytes_written;
if (!g_output_stream_write_all (temp_out, file_meta_buf, file_meta_len, &bytes_written,
cancellable, error))
return FALSE;
@@ -1069,13 +1020,14 @@ write_content_object (OstreeRepo *self,
if (g_file_info_get_file_type (file_info) == G_FILE_TYPE_REGULAR)
{
- zlib_compressor = (GConverter*)g_zlib_compressor_new (G_ZLIB_COMPRESSOR_FORMAT_RAW, self->zlib_compression_level);
+ zlib_compressor = (GConverter *)g_zlib_compressor_new (G_ZLIB_COMPRESSOR_FORMAT_RAW,
+ self->zlib_compression_level);
compressed_out_stream = g_converter_output_stream_new (temp_out, zlib_compressor);
/* Don't close the base; we'll do that later */
- g_filter_output_stream_set_close_base_stream ((GFilterOutputStream*)compressed_out_stream, FALSE);
+ g_filter_output_stream_set_close_base_stream (
+ (GFilterOutputStream *)compressed_out_stream, FALSE);
- if (g_output_stream_splice (compressed_out_stream, file_input,
- 0, cancellable, error) < 0)
+ if (g_output_stream_splice (compressed_out_stream, file_input, 0, cancellable, error) < 0)
return FALSE;
unpacked_size = g_file_info_get_size (file_info);
@@ -1103,8 +1055,8 @@ write_content_object (OstreeRepo *self,
actual_checksum = actual_checksum_owned = ot_checksum_instream_get_string (checksum_input);
if (expected_checksum)
{
- if (!_ostree_compare_object_checksum (OSTREE_OBJECT_TYPE_FILE, expected_checksum, actual_checksum,
- error))
+ if (!_ostree_compare_object_checksum (OSTREE_OBJECT_TYPE_FILE, expected_checksum,
+ actual_checksum, error))
return FALSE;
}
@@ -1115,24 +1067,23 @@ write_content_object (OstreeRepo *self,
g_assert (actual_checksum != NULL); /* Pacify static analysis */
/* Update size metadata if configured and entry missing */
- if (self->generate_sizes &&
- !repo_has_size_entry (self, OSTREE_OBJECT_TYPE_FILE, actual_checksum))
+ if (self->generate_sizes && !repo_has_size_entry (self, OSTREE_OBJECT_TYPE_FILE, actual_checksum))
{
struct stat stbuf;
if (!glnx_fstat (tmpf.fd, &stbuf, error))
return FALSE;
- repo_store_size_entry (self, OSTREE_OBJECT_TYPE_FILE, actual_checksum,
- unpacked_size, stbuf.st_size);
+ repo_store_size_entry (self, OSTREE_OBJECT_TYPE_FILE, actual_checksum, unpacked_size,
+ stbuf.st_size);
}
/* See whether or not we have the object, now that we know the
* checksum.
*/
gboolean have_obj;
- if (!_ostree_repo_has_loose_object (self, actual_checksum, OSTREE_OBJECT_TYPE_FILE,
- &have_obj, cancellable, error))
+ if (!_ostree_repo_has_loose_object (self, actual_checksum, OSTREE_OBJECT_TYPE_FILE, &have_obj,
+ cancellable, error))
return FALSE;
/* If we already have it, just update the stats. */
if (have_obj)
@@ -1141,7 +1092,8 @@ write_content_object (OstreeRepo *self,
self->txn.stats.content_objects_total++;
g_mutex_unlock (&self->txn_lock);
- if (!_create_payload_link (self, actual_checksum, actual_payload_checksum, file_info, cancellable, error))
+ if (!_create_payload_link (self, actual_checksum, actual_payload_checksum, file_info,
+ cancellable, error))
return FALSE;
if (out_csum)
@@ -1168,15 +1120,16 @@ write_content_object (OstreeRepo *self,
* Note, this does not apply for bare-user repos, as they store symlinks
* as regular files.
*/
- if (G_UNLIKELY (fchownat (tmp_unlinker.dfd, tmp_unlinker.path,
- uid, gid, AT_SYMLINK_NOFOLLOW) == -1))
+ if (G_UNLIKELY (
+ fchownat (tmp_unlinker.dfd, tmp_unlinker.path, uid, gid, AT_SYMLINK_NOFOLLOW)
+ == -1))
return glnx_throw_errno_prefix (error, "fchownat");
if (xattrs != NULL)
{
ot_security_smack_reset_dfd_name (tmp_unlinker.dfd, tmp_unlinker.path);
- if (!glnx_dfd_name_set_all_xattrs (tmp_unlinker.dfd, tmp_unlinker.path,
- xattrs, cancellable, error))
+ if (!glnx_dfd_name_set_all_xattrs (tmp_unlinker.dfd, tmp_unlinker.path, xattrs,
+ cancellable, error))
return FALSE;
}
}
@@ -1186,25 +1139,26 @@ write_content_object (OstreeRepo *self,
g_assert_not_reached ();
}
- if (!commit_path_final (self, actual_checksum, OSTREE_OBJECT_TYPE_FILE,
- &tmp_unlinker, cancellable, error))
+ if (!commit_path_final (self, actual_checksum, OSTREE_OBJECT_TYPE_FILE, &tmp_unlinker,
+ cancellable, error))
return FALSE;
}
else
{
/* Check if a file with the same payload is present in the repository,
and in case try to reflink it */
- if (actual_payload_checksum && !_try_clone_from_payload_link (self, self, actual_payload_checksum, file_info, &tmpf, cancellable, error))
+ if (actual_payload_checksum
+ && !_try_clone_from_payload_link (self, self, actual_payload_checksum, file_info, &tmpf,
+ cancellable, error))
return FALSE;
/* This path is for regular files */
- if (!commit_loose_regfile_object (self, actual_checksum, &tmpf,
- uid, gid, mode,
- xattrs,
+ if (!commit_loose_regfile_object (self, actual_checksum, &tmpf, uid, gid, mode, xattrs,
cancellable, error))
return FALSE;
- if (!_create_payload_link (self, actual_checksum, actual_payload_checksum, file_info, cancellable, error))
+ if (!_create_payload_link (self, actual_checksum, actual_payload_checksum, file_info,
+ cancellable, error))
return FALSE;
}
@@ -1238,22 +1192,19 @@ write_content_object (OstreeRepo *self,
* security.selinux xattr on setuid binaries and the like to live on).
*/
static gboolean
-adopt_and_commit_regfile (OstreeRepo *self,
- int dfd,
- const char *name,
- GFileInfo *finfo,
- GVariant *xattrs,
- char *out_checksum_buf,
- GCancellable *cancellable,
- GError **error)
+adopt_and_commit_regfile (OstreeRepo *self, int dfd, const char *name, GFileInfo *finfo,
+ GVariant *xattrs, char *out_checksum_buf, GCancellable *cancellable,
+ GError **error)
{
g_assert (G_IN_SET (self->mode, OSTREE_REPO_MODE_BARE, OSTREE_REPO_MODE_BARE_USER_ONLY));
GLNX_AUTO_PREFIX_ERROR ("Commit regfile (adopt)", error);
- g_autoptr(GBytes) header = _ostree_file_header_new (finfo, xattrs);
+ g_autoptr (GBytes) header = _ostree_file_header_new (finfo, xattrs);
- g_auto(OtChecksum) hasher = { 0, };
+ g_auto (OtChecksum) hasher = {
+ 0,
+ };
ot_checksum_init (&hasher);
ot_checksum_update_bytes (&hasher, header);
@@ -1268,7 +1219,7 @@ adopt_and_commit_regfile (OstreeRepo *self,
* Turns out bigger block size is better; down the line we should use their
* same heuristics.
*/
- char buf[16*1024];
+ char buf[16 * 1024];
while (TRUE)
{
ssize_t bytes_read = read (fd, buf, sizeof (buf));
@@ -1277,10 +1228,10 @@ adopt_and_commit_regfile (OstreeRepo *self,
if (bytes_read == 0)
break;
- ot_checksum_update (&hasher, (guint8*)buf, bytes_read);
+ ot_checksum_update (&hasher, (guint8 *)buf, bytes_read);
}
- ot_checksum_get_hexdigest (&hasher, out_checksum_buf, OSTREE_SHA256_STRING_LEN+1);
+ ot_checksum_get_hexdigest (&hasher, out_checksum_buf, OSTREE_SHA256_STRING_LEN + 1);
const char *checksum = out_checksum_buf;
/* TODO: dedup this with commit_path_final() */
@@ -1291,8 +1242,7 @@ adopt_and_commit_regfile (OstreeRepo *self,
const guint64 src_inode = g_file_info_get_attribute_uint64 (finfo, "unix::inode");
int dest_dfd = commit_dest_dfd (self);
- if (!_ostree_repo_ensure_loose_objdir_at (dest_dfd, loose_path,
- cancellable, error))
+ if (!_ostree_repo_ensure_loose_objdir_at (dest_dfd, loose_path, cancellable, error))
return FALSE;
struct stat dest_stbuf;
@@ -1305,9 +1255,7 @@ adopt_and_commit_regfile (OstreeRepo *self,
* "If oldpath and newpath are existing hard links referring to the same file,
* then rename() does nothing, and returns a success status."
*/
- if (errno != ENOENT
- && src_dev == dest_stbuf.st_dev
- && src_inode == dest_stbuf.st_ino)
+ if (errno != ENOENT && src_dev == dest_stbuf.st_dev && src_inode == dest_stbuf.st_ino)
{
if (!glnx_unlinkat (dfd, name, 0, error))
return FALSE;
@@ -1337,13 +1285,8 @@ adopt_and_commit_regfile (OstreeRepo *self,
/* Main driver for writing a metadata (non-content) object. */
static gboolean
-write_metadata_object (OstreeRepo *self,
- OstreeObjectType objtype,
- const char *expected_checksum,
- GBytes *buf,
- guchar **out_csum,
- GCancellable *cancellable,
- GError **error)
+write_metadata_object (OstreeRepo *self, OstreeObjectType objtype, const char *expected_checksum,
+ GBytes *buf, guchar **out_csum, GCancellable *cancellable, GError **error)
{
g_assert (expected_checksum != NULL || out_csum != NULL);
@@ -1362,7 +1305,7 @@ write_metadata_object (OstreeRepo *self,
* *original* sha256 to say what commit was being killed.
*/
const gboolean is_tombstone = (objtype == OSTREE_OBJECT_TYPE_TOMBSTONE_COMMIT);
- char actual_checksum[OSTREE_SHA256_STRING_LEN+1];
+ char actual_checksum[OSTREE_SHA256_STRING_LEN + 1];
if (is_tombstone)
{
g_assert (expected_checksum != NULL);
@@ -1370,15 +1313,17 @@ write_metadata_object (OstreeRepo *self,
}
else
{
- g_auto(OtChecksum) checksum = { 0, };
+ g_auto (OtChecksum) checksum = {
+ 0,
+ };
ot_checksum_init (&checksum);
gsize len;
- const guint8*bufdata = g_bytes_get_data (buf, &len);
+ const guint8 *bufdata = g_bytes_get_data (buf, &len);
ot_checksum_update (&checksum, bufdata, len);
ot_checksum_get_hexdigest (&checksum, actual_checksum, sizeof (actual_checksum));
gboolean have_obj;
- if (!_ostree_repo_has_loose_object (self, actual_checksum, objtype, &have_obj,
- cancellable, error))
+ if (!_ostree_repo_has_loose_object (self, actual_checksum, objtype, &have_obj, cancellable,
+ error))
return FALSE;
/* If we already have the object, we just need to update the tried-to-commit
* stat for metadata and be done here.
@@ -1386,8 +1331,7 @@ write_metadata_object (OstreeRepo *self,
if (have_obj)
{
/* Update size metadata if needed */
- if (self->generate_sizes &&
- !repo_has_size_entry (self, objtype, actual_checksum))
+ if (self->generate_sizes && !repo_has_size_entry (self, objtype, actual_checksum))
repo_store_size_entry (self, objtype, actual_checksum, len, len);
g_mutex_lock (&self->txn_lock);
@@ -1412,14 +1356,15 @@ write_metadata_object (OstreeRepo *self,
const guint8 *bufp = g_bytes_get_data (buf, &len);
/* Update size metadata if needed */
- if (self->generate_sizes &&
- !repo_has_size_entry (self, objtype, actual_checksum))
+ if (self->generate_sizes && !repo_has_size_entry (self, objtype, actual_checksum))
repo_store_size_entry (self, objtype, actual_checksum, len, len);
/* Write the metadata to a temporary file */
- g_auto(GLnxTmpfile) tmpf = { 0, };
- if (!glnx_open_tmpfile_linkable_at (commit_tmp_dfd (self), ".", O_WRONLY|O_CLOEXEC,
- &tmpf, error))
+ g_auto (GLnxTmpfile) tmpf = {
+ 0,
+ };
+ if (!glnx_open_tmpfile_linkable_at (commit_tmp_dfd (self), ".", O_WRONLY | O_CLOEXEC, &tmpf,
+ error))
return FALSE;
if (!glnx_try_fallocate (tmpf.fd, 0, len, error))
return FALSE;
@@ -1429,8 +1374,7 @@ write_metadata_object (OstreeRepo *self,
return FALSE;
/* And commit it into place */
- if (!_ostree_repo_commit_tmpf_final (self, actual_checksum, objtype,
- &tmpf, cancellable, error))
+ if (!_ostree_repo_commit_tmpf_final (self, actual_checksum, objtype, &tmpf, cancellable, error))
return FALSE;
if (objtype == OSTREE_OBJECT_TYPE_COMMIT)
@@ -1438,11 +1382,8 @@ write_metadata_object (OstreeRepo *self,
GError *local_error = NULL;
/* If we are writing a commit, be sure there is no tombstone for it.
We may have deleted the commit and now we are trying to pull it again. */
- if (!ostree_repo_delete_object (self,
- OSTREE_OBJECT_TYPE_TOMBSTONE_COMMIT,
- actual_checksum,
- cancellable,
- &local_error))
+ if (!ostree_repo_delete_object (self, OSTREE_OBJECT_TYPE_TOMBSTONE_COMMIT, actual_checksum,
+ cancellable, &local_error))
{
if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
g_clear_error (&local_error);
@@ -1469,21 +1410,21 @@ write_metadata_object (OstreeRepo *self,
* (device,inode) → checksum map.
*/
static gboolean
-scan_one_loose_devino (OstreeRepo *self,
- int object_dir_fd,
- GHashTable *devino_cache,
- GCancellable *cancellable,
- GError **error)
+scan_one_loose_devino (OstreeRepo *self, int object_dir_fd, GHashTable *devino_cache,
+ GCancellable *cancellable, GError **error)
{
- g_auto(GLnxDirFdIterator) dfd_iter = { 0, };
- if (!glnx_dirfd_iterator_init_at (object_dir_fd, ".", FALSE,
- &dfd_iter, error))
+ g_auto (GLnxDirFdIterator) dfd_iter = {
+ 0,
+ };
+ if (!glnx_dirfd_iterator_init_at (object_dir_fd, ".", FALSE, &dfd_iter, error))
return FALSE;
while (TRUE)
{
struct dirent *dent;
- g_auto(GLnxDirFdIterator) child_dfd_iter = { 0, };
+ g_auto (GLnxDirFdIterator) child_dfd_iter = {
+ 0,
+ };
if (!glnx_dirfd_iterator_next_dent (&dfd_iter, &dent, cancellable, error))
return FALSE;
@@ -1494,8 +1435,7 @@ scan_one_loose_devino (OstreeRepo *self,
if (strlen (dent->d_name) != 2)
continue;
- if (!glnx_dirfd_iterator_init_at (dfd_iter.fd, dent->d_name, FALSE,
- &child_dfd_iter, error))
+ if (!glnx_dirfd_iterator_init_at (dfd_iter.fd, dent->d_name, FALSE, &child_dfd_iter, error))
return FALSE;
while (TRUE)
@@ -1532,8 +1472,8 @@ scan_one_loose_devino (OstreeRepo *self,
continue;
struct stat stbuf;
- if (!glnx_fstatat (child_dfd_iter.fd, child_dent->d_name,
- &stbuf, AT_SYMLINK_NOFOLLOW, error))
+ if (!glnx_fstatat (child_dfd_iter.fd, child_dent->d_name, &stbuf, AT_SYMLINK_NOFOLLOW,
+ error))
return FALSE;
OstreeDevIno *key = g_new (OstreeDevIno, 1);
@@ -1541,7 +1481,7 @@ scan_one_loose_devino (OstreeRepo *self,
key->ino = stbuf.st_ino;
memcpy (key->checksum, dent->d_name, 2);
memcpy (key->checksum + 2, name, 62);
- key->checksum[sizeof(key->checksum)-1] = '\0';
+ key->checksum[sizeof (key->checksum) - 1] = '\0';
g_hash_table_add (devino_cache, key);
}
}
@@ -1551,10 +1491,8 @@ scan_one_loose_devino (OstreeRepo *self,
/* Used by ostree_repo_scan_hardlinks(); see that function for more information. */
static gboolean
-scan_loose_devino (OstreeRepo *self,
- GHashTable *devino_cache,
- GCancellable *cancellable,
- GError **error)
+scan_loose_devino (OstreeRepo *self, GHashTable *devino_cache, GCancellable *cancellable,
+ GError **error)
{
if (self->parent_repo)
{
@@ -1562,16 +1500,14 @@ scan_loose_devino (OstreeRepo *self,
return FALSE;
}
- if (self->mode == OSTREE_REPO_MODE_ARCHIVE &&
- self->uncompressed_objects_dir_fd != -1)
+ if (self->mode == OSTREE_REPO_MODE_ARCHIVE && self->uncompressed_objects_dir_fd != -1)
{
if (!scan_one_loose_devino (self, self->uncompressed_objects_dir_fd, devino_cache,
cancellable, error))
return FALSE;
}
- if (!scan_one_loose_devino (self, self->objects_dir_fd,
- devino_cache, cancellable, error))
+ if (!scan_one_loose_devino (self, self->objects_dir_fd, devino_cache, cancellable, error))
return FALSE;
return TRUE;
@@ -1580,10 +1516,8 @@ scan_loose_devino (OstreeRepo *self,
/* Loook up a (device,inode) pair in our cache, and see if it maps to a known
* checksum. */
static const char *
-devino_cache_lookup (OstreeRepo *self,
- OstreeRepoCommitModifier *modifier,
- guint32 device,
- guint32 inode)
+devino_cache_lookup (OstreeRepo *self, OstreeRepoCommitModifier *modifier, guint32 device,
+ guint32 inode)
{
OstreeDevIno dev_ino_key;
OstreeDevIno *dev_ino_val;
@@ -1629,9 +1563,7 @@ devino_cache_lookup (OstreeRepo *self,
* Multithreading: This function is *not* MT safe.
*/
gboolean
-ostree_repo_scan_hardlinks (OstreeRepo *self,
- GCancellable *cancellable,
- GError **error)
+ostree_repo_scan_hardlinks (OstreeRepo *self, GCancellable *cancellable, GError **error)
{
g_assert (self != NULL);
g_assert (OSTREE_IS_REPO (self));
@@ -1640,7 +1572,7 @@ ostree_repo_scan_hardlinks (OstreeRepo *self,
return glnx_throw (error, "Failed to scan hardlinks, not in a transaction");
if (!self->loose_object_devino_hash)
- self->loose_object_devino_hash = (GHashTable*)ostree_repo_devino_cache_new ();
+ self->loose_object_devino_hash = (GHashTable *)ostree_repo_devino_cache_new ();
g_hash_table_remove_all (self->loose_object_devino_hash);
return scan_loose_devino (self, self->loose_object_devino_hash, cancellable, error);
}
@@ -1673,10 +1605,8 @@ ostree_repo_scan_hardlinks (OstreeRepo *self,
* active at a time.
*/
gboolean
-ostree_repo_prepare_transaction (OstreeRepo *self,
- gboolean *out_transaction_resume,
- GCancellable *cancellable,
- GError **error)
+ostree_repo_prepare_transaction (OstreeRepo *self, gboolean *out_transaction_resume,
+ GCancellable *cancellable, GError **error)
{
g_assert (self != NULL);
g_assert (OSTREE_IS_REPO (self));
@@ -1689,13 +1619,12 @@ ostree_repo_prepare_transaction (OstreeRepo *self,
/* Set up to abort the transaction if we return early from this function.
* We can't call _ostree_repo_auto_transaction_start() here, because that
* would be a circular dependency; use the lower-level version instead. */
- g_autoptr(OstreeRepoAutoTransaction) txn = _ostree_repo_auto_transaction_new (self);
+ g_autoptr (OstreeRepoAutoTransaction) txn = _ostree_repo_auto_transaction_new (self);
g_assert (txn != NULL);
memset (&self->txn.stats, 0, sizeof (OstreeRepoTransactionStats));
- self->txn_locked = ostree_repo_lock_push (self, OSTREE_REPO_LOCK_SHARED,
- cancellable, error);
+ self->txn_locked = ostree_repo_lock_push (self, OSTREE_REPO_LOCK_SHARED, cancellable, error);
if (!self->txn_locked)
return FALSE;
@@ -1738,16 +1667,14 @@ ostree_repo_prepare_transaction (OstreeRepo *self,
g_mutex_unlock (&self->txn_lock);
gboolean ret_transaction_resume = FALSE;
- if (!_ostree_repo_allocate_tmpdir (self->tmp_dir_fd,
- self->stagedir_prefix,
- &self->commit_stagedir,
- &self->commit_stagedir_lock,
- &ret_transaction_resume,
- cancellable, error))
+ if (!_ostree_repo_allocate_tmpdir (self->tmp_dir_fd, self->stagedir_prefix,
+ &self->commit_stagedir, &self->commit_stagedir_lock,
+ &ret_transaction_resume, cancellable, error))
return FALSE;
/* Success: do not abort the transaction when returning. */
- g_clear_object (&txn->repo); (void) txn;
+ g_clear_object (&txn->repo);
+ (void)txn;
if (out_transaction_resume)
*out_transaction_resume = ret_transaction_resume;
@@ -1756,15 +1683,15 @@ ostree_repo_prepare_transaction (OstreeRepo *self,
/* Synchronize the directories holding the objects */
static gboolean
-fsync_object_dirs (OstreeRepo *self,
- GCancellable *cancellable,
- GError **error)
+fsync_object_dirs (OstreeRepo *self, GCancellable *cancellable, GError **error)
{
GLNX_AUTO_PREFIX_ERROR ("fsync objdirs", error);
- g_auto(GLnxDirFdIterator) dfd_iter = { 0, };
+ g_auto (GLnxDirFdIterator) dfd_iter = {
+ 0,
+ };
if (self->disable_fsync)
- return TRUE; /* No fsync? Nothing to do then. */
+ return TRUE; /* No fsync? Nothing to do then. */
if (!glnx_dirfd_iterator_init_at (self->objects_dir_fd, ".", FALSE, &dfd_iter, error))
return FALSE;
@@ -1782,8 +1709,7 @@ fsync_object_dirs (OstreeRepo *self,
continue;
glnx_autofd int target_dir_fd = -1;
- if (!glnx_opendirat (self->objects_dir_fd, dent->d_name, FALSE,
- &target_dir_fd, error))
+ if (!glnx_opendirat (self->objects_dir_fd, dent->d_name, FALSE, &target_dir_fd, error))
return FALSE;
/* This synchronizes the directory to ensure all the objects we wrote
* are there. We need to do this before removing the .commitpartial
@@ -1807,12 +1733,12 @@ fsync_object_dirs (OstreeRepo *self,
* https://github.com/ostreedev/ostree/issues/1184
*/
static gboolean
-rename_pending_loose_objects (OstreeRepo *self,
- GCancellable *cancellable,
- GError **error)
+rename_pending_loose_objects (OstreeRepo *self, GCancellable *cancellable, GError **error)
{
GLNX_AUTO_PREFIX_ERROR ("rename pending", error);
- g_auto(GLnxDirFdIterator) dfd_iter = { 0, };
+ g_auto (GLnxDirFdIterator) dfd_iter = {
+ 0,
+ };
if (!glnx_dirfd_iterator_init_at (self->commit_stagedir.fd, ".", FALSE, &dfd_iter, error))
return FALSE;
@@ -1833,9 +1759,10 @@ rename_pending_loose_objects (OstreeRepo *self,
if (strlen (dent->d_name) != 2)
continue;
- g_auto(GLnxDirFdIterator) child_dfd_iter = { 0, };
- if (!glnx_dirfd_iterator_init_at (dfd_iter.fd, dent->d_name, FALSE,
- &child_dfd_iter, error))
+ g_auto (GLnxDirFdIterator) child_dfd_iter = {
+ 0,
+ };
+ if (!glnx_dirfd_iterator_init_at (dfd_iter.fd, dent->d_name, FALSE, &child_dfd_iter, error))
return FALSE;
char loose_objpath[_OSTREE_LOOSE_PATH_MAX];
@@ -1853,14 +1780,14 @@ rename_pending_loose_objects (OstreeRepo *self,
if (child_dent == NULL)
break;
- g_strlcpy (loose_objpath + 3, child_dent->d_name, sizeof (loose_objpath)-3);
+ g_strlcpy (loose_objpath + 3, child_dent->d_name, sizeof (loose_objpath) - 3);
if (!_ostree_repo_ensure_loose_objdir_at (self->objects_dir_fd, loose_objpath,
cancellable, error))
return FALSE;
- if (!glnx_renameat (child_dfd_iter.fd, loose_objpath + 3,
- self->objects_dir_fd, loose_objpath, error))
+ if (!glnx_renameat (child_dfd_iter.fd, loose_objpath + 3, self->objects_dir_fd,
+ loose_objpath, error))
return FALSE;
}
}
@@ -1872,16 +1799,15 @@ rename_pending_loose_objects (OstreeRepo *self,
* ostree_repo_prepare_transaction().
*/
static gboolean
-cleanup_txn_dir (OstreeRepo *self,
- int dfd,
- const char *path,
- GCancellable *cancellable,
- GError **error)
+cleanup_txn_dir (OstreeRepo *self, int dfd, const char *path, GCancellable *cancellable,
+ GError **error)
{
const char *errprefix = glnx_strjoina ("Cleaning up txn dir ", path);
GLNX_AUTO_PREFIX_ERROR (errprefix, error);
- g_auto(GLnxLockFile) lockfile = { 0, };
+ g_auto (GLnxLockFile) lockfile = {
+ 0,
+ };
gboolean did_lock;
/* Try to lock, but if we don't get it, move on */
@@ -1914,14 +1840,14 @@ cleanup_txn_dir (OstreeRepo *self,
* https://github.com/ostreedev/ostree/issues/713
*/
static gboolean
-cleanup_tmpdir (OstreeRepo *self,
- GCancellable *cancellable,
- GError **error)
+cleanup_tmpdir (OstreeRepo *self, GCancellable *cancellable, GError **error)
{
GLNX_AUTO_PREFIX_ERROR ("tmpdir cleanup", error);
const guint64 curtime_secs = g_get_real_time () / 1000000;
- g_auto(GLnxDirFdIterator) dfd_iter = { 0, };
+ g_auto (GLnxDirFdIterator) dfd_iter = {
+ 0,
+ };
if (!glnx_dirfd_iterator_init_at (self->tmp_dir_fd, ".", TRUE, &dfd_iter, error))
return FALSE;
@@ -1984,10 +1910,9 @@ ensure_txn_refs (OstreeRepo *self)
if (self->txn.refs == NULL)
self->txn.refs = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
if (self->txn.collection_refs == NULL)
- self->txn.collection_refs = g_hash_table_new_full (ostree_collection_ref_hash,
- ostree_collection_ref_equal,
- (GDestroyNotify) ostree_collection_ref_free,
- g_free);
+ self->txn.collection_refs
+ = g_hash_table_new_full (ostree_collection_ref_hash, ostree_collection_ref_equal,
+ (GDestroyNotify)ostree_collection_ref_free, g_free);
}
/**
@@ -2009,11 +1934,8 @@ ensure_txn_refs (OstreeRepo *self)
* Since: 2019.4
*/
gboolean
-ostree_repo_mark_commit_partial_reason (OstreeRepo *self,
- const char *checksum,
- gboolean is_partial,
- OstreeRepoCommitState in_state,
- GError **error)
+ostree_repo_mark_commit_partial_reason (OstreeRepo *self, const char *checksum, gboolean is_partial,
+ OstreeRepoCommitState in_state, GError **error)
{
g_autofree char *commitpartial_path = _ostree_get_commitpartial_path (checksum);
if (is_partial)
@@ -2059,14 +1981,11 @@ ostree_repo_mark_commit_partial_reason (OstreeRepo *self,
* Since: 2017.15
*/
gboolean
-ostree_repo_mark_commit_partial (OstreeRepo *self,
- const char *checksum,
- gboolean is_partial,
- GError **error)
+ostree_repo_mark_commit_partial (OstreeRepo *self, const char *checksum, gboolean is_partial,
+ GError **error)
{
return ostree_repo_mark_commit_partial_reason (self, checksum, is_partial,
- OSTREE_REPO_COMMIT_STATE_NORMAL,
- error);
+ OSTREE_REPO_COMMIT_STATE_NORMAL, error);
}
/**
@@ -2082,9 +2001,7 @@ ostree_repo_mark_commit_partial (OstreeRepo *self,
* Multithreading: Since v2017.15 this function is MT safe.
*/
void
-ostree_repo_transaction_set_refspec (OstreeRepo *self,
- const char *refspec,
- const char *checksum)
+ostree_repo_transaction_set_refspec (OstreeRepo *self, const char *refspec, const char *checksum)
{
g_assert (self != NULL);
g_assert (OSTREE_IS_REPO (self));
@@ -2126,9 +2043,7 @@ ostree_repo_transaction_set_refspec (OstreeRepo *self,
* Multithreading: Since v2017.15 this function is MT safe.
*/
void
-ostree_repo_transaction_set_ref (OstreeRepo *self,
- const char *remote,
- const char *ref,
+ostree_repo_transaction_set_ref (OstreeRepo *self, const char *remote, const char *ref,
const char *checksum)
{
g_assert (self != NULL);
@@ -2169,9 +2084,8 @@ ostree_repo_transaction_set_ref (OstreeRepo *self,
* Since: 2018.6
*/
void
-ostree_repo_transaction_set_collection_ref (OstreeRepo *self,
- const OstreeCollectionRef *ref,
- const char *checksum)
+ostree_repo_transaction_set_collection_ref (OstreeRepo *self, const OstreeCollectionRef *ref,
+ const char *checksum)
{
g_assert (self != NULL);
g_assert (OSTREE_IS_REPO (self));
@@ -2184,8 +2098,8 @@ ostree_repo_transaction_set_collection_ref (OstreeRepo *self,
g_mutex_lock (&self->txn_lock);
ensure_txn_refs (self);
- g_hash_table_replace (self->txn.collection_refs,
- ostree_collection_ref_dup (ref), g_strdup (checksum));
+ g_hash_table_replace (self->txn.collection_refs, ostree_collection_ref_dup (ref),
+ g_strdup (checksum));
g_mutex_unlock (&self->txn_lock);
}
@@ -2205,16 +2119,11 @@ ostree_repo_transaction_set_collection_ref (OstreeRepo *self,
* Multithreading: This function is MT safe.
*/
gboolean
-ostree_repo_set_ref_immediate (OstreeRepo *self,
- const char *remote,
- const char *ref,
- const char *checksum,
- GCancellable *cancellable,
- GError **error)
+ostree_repo_set_ref_immediate (OstreeRepo *self, const char *remote, const char *ref,
+ const char *checksum, GCancellable *cancellable, GError **error)
{
- const OstreeCollectionRef _ref = { NULL, (gchar *) ref };
- return _ostree_repo_write_ref (self, remote, &_ref, checksum, NULL,
- cancellable, error);
+ const OstreeCollectionRef _ref = { NULL, (gchar *)ref };
+ return _ostree_repo_write_ref (self, remote, &_ref, checksum, NULL, cancellable, error);
}
/**
@@ -2231,16 +2140,11 @@ ostree_repo_set_ref_immediate (OstreeRepo *self,
* Since: 2017.10
*/
gboolean
-ostree_repo_set_alias_ref_immediate (OstreeRepo *self,
- const char *remote,
- const char *ref,
- const char *target,
- GCancellable *cancellable,
- GError **error)
+ostree_repo_set_alias_ref_immediate (OstreeRepo *self, const char *remote, const char *ref,
+ const char *target, GCancellable *cancellable, GError **error)
{
- const OstreeCollectionRef _ref = { NULL, (gchar *) ref };
- return _ostree_repo_write_ref (self, remote, &_ref, NULL, target,
- cancellable, error);
+ const OstreeCollectionRef _ref = { NULL, (gchar *)ref };
+ return _ostree_repo_write_ref (self, remote, &_ref, NULL, target, cancellable, error);
}
/**
@@ -2259,11 +2163,9 @@ ostree_repo_set_alias_ref_immediate (OstreeRepo *self,
* Since: 2018.6
*/
gboolean
-ostree_repo_set_collection_ref_immediate (OstreeRepo *self,
- const OstreeCollectionRef *ref,
- const char *checksum,
- GCancellable *cancellable,
- GError **error)
+ostree_repo_set_collection_ref_immediate (OstreeRepo *self, const OstreeCollectionRef *ref,
+ const char *checksum, GCancellable *cancellable,
+ GError **error)
{
g_assert (self != NULL);
g_assert (OSTREE_IS_REPO (self));
@@ -2273,8 +2175,7 @@ ostree_repo_set_collection_ref_immediate (OstreeRepo *self,
if (checksum != NULL && !ostree_validate_checksum_string (checksum, error))
return FALSE;
- return _ostree_repo_write_ref (self, NULL, ref, checksum, NULL,
- cancellable, error);
+ return _ostree_repo_write_ref (self, NULL, ref, checksum, NULL, cancellable, error);
}
/**
@@ -2297,10 +2198,8 @@ ostree_repo_set_collection_ref_immediate (OstreeRepo *self,
* active at a time.
*/
gboolean
-ostree_repo_commit_transaction (OstreeRepo *self,
- OstreeRepoTransactionStats *out_stats,
- GCancellable *cancellable,
- GError **error)
+ostree_repo_commit_transaction (OstreeRepo *self, OstreeRepoTransactionStats *out_stats,
+ GCancellable *cancellable, GError **error)
{
g_assert (self != NULL);
g_assert (OSTREE_IS_REPO (self));
@@ -2316,8 +2215,7 @@ ostree_repo_commit_transaction (OstreeRepo *self,
/* FIXME: Added OSTREE_SUPPRESS_SYNCFS since valgrind in el7 doesn't know
* about `syncfs`...we should delete this later.
*/
- if (!self->disable_fsync &&
- g_getenv ("OSTREE_SUPPRESS_SYNCFS") == NULL)
+ if (!self->disable_fsync && g_getenv ("OSTREE_SUPPRESS_SYNCFS") == NULL)
{
if (syncfs (self->tmp_dir_fd) < 0)
return glnx_throw_errno_prefix (error, "syncfs");
@@ -2352,9 +2250,8 @@ ostree_repo_commit_transaction (OstreeRepo *self,
/* Update the summary if auto-update-summary is set, because doing so was
* delayed for each ref change during the transaction.
*/
- if (!self->txn.disable_auto_summary &&
- (self->txn.refs || self->txn.collection_refs) &&
- !_ostree_repo_maybe_regenerate_summary (self, cancellable, error))
+ if (!self->txn.disable_auto_summary && (self->txn.refs || self->txn.collection_refs)
+ && !_ostree_repo_maybe_regenerate_summary (self, cancellable, error))
return FALSE;
g_clear_pointer (&self->txn.refs, g_hash_table_destroy);
@@ -2390,14 +2287,12 @@ ostree_repo_commit_transaction (OstreeRepo *self,
* transaction will do nothing and return successfully.
*/
gboolean
-ostree_repo_abort_transaction (OstreeRepo *self,
- GCancellable *cancellable,
- GError **error)
+ostree_repo_abort_transaction (OstreeRepo *self, GCancellable *cancellable, GError **error)
{
g_assert (self != NULL);
g_assert (OSTREE_IS_REPO (self));
- g_autoptr(GError) cleanup_error = NULL;
+ g_autoptr (GError) cleanup_error = NULL;
/* Always ignore the cancellable to avoid the chance that, if it gets
* canceled, the transaction may not be fully cleaned up.
@@ -2460,32 +2355,27 @@ ostree_repo_abort_transaction (OstreeRepo *self,
* computed checksum.
*/
gboolean
-ostree_repo_write_metadata (OstreeRepo *self,
- OstreeObjectType objtype,
- const char *expected_checksum,
- GVariant *object,
- guchar **out_csum,
- GCancellable *cancellable,
- GError **error)
+ostree_repo_write_metadata (OstreeRepo *self, OstreeObjectType objtype,
+ const char *expected_checksum, GVariant *object, guchar **out_csum,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GVariant) normalized = NULL;
+ g_autoptr (GVariant) normalized = NULL;
/* First, if we have an expected checksum, see if we already have this
* object. This mirrors the same logic in ostree_repo_write_content().
*/
if (expected_checksum)
{
gboolean have_obj;
- if (!_ostree_repo_has_loose_object (self, expected_checksum, objtype, &have_obj,
- cancellable, error))
+ if (!_ostree_repo_has_loose_object (self, expected_checksum, objtype, &have_obj, cancellable,
+ error))
return FALSE;
if (have_obj)
{
/* Update size metadata if needed */
- if (self->generate_sizes &&
- !repo_has_size_entry (self, objtype, expected_checksum))
+ if (self->generate_sizes && !repo_has_size_entry (self, objtype, expected_checksum))
{
/* Make sure we have a fully serialized object */
- g_autoptr(GVariant) trusted = g_variant_get_normal_form (object);
+ g_autoptr (GVariant) trusted = g_variant_get_normal_form (object);
gsize size = g_variant_get_size (trusted);
repo_store_size_entry (self, objtype, expected_checksum, size, size);
}
@@ -2508,9 +2398,9 @@ ostree_repo_write_metadata (OstreeRepo *self,
if (!_ostree_validate_structureof_metadata (objtype, object, error))
return FALSE;
- g_autoptr(GBytes) vdata = g_variant_get_data_as_bytes (normalized);
- if (!write_metadata_object (self, objtype, expected_checksum,
- vdata, out_csum, cancellable, error))
+ g_autoptr (GBytes) vdata = g_variant_get_data_as_bytes (normalized);
+ if (!write_metadata_object (self, objtype, expected_checksum, vdata, out_csum, cancellable,
+ error))
return FALSE;
return TRUE;
@@ -2530,27 +2420,25 @@ ostree_repo_write_metadata (OstreeRepo *self,
* trusted.
*/
gboolean
-ostree_repo_write_metadata_stream_trusted (OstreeRepo *self,
- OstreeObjectType objtype,
- const char *checksum,
- GInputStream *object_input,
- guint64 length,
- GCancellable *cancellable,
- GError **error)
+ostree_repo_write_metadata_stream_trusted (OstreeRepo *self, OstreeObjectType objtype,
+ const char *checksum, GInputStream *object_input,
+ guint64 length, GCancellable *cancellable,
+ GError **error)
{
/* This is all pretty ridiculous, but we're keeping this API for backwards
* compatibility, it doesn't really need to be fast.
*/
- g_autoptr(GMemoryOutputStream) tmpbuf = (GMemoryOutputStream*)g_memory_output_stream_new_resizable ();
- if (g_output_stream_splice ((GOutputStream*)tmpbuf, object_input,
- G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET, cancellable, error) < 0)
+ g_autoptr (GMemoryOutputStream) tmpbuf
+ = (GMemoryOutputStream *)g_memory_output_stream_new_resizable ();
+ if (g_output_stream_splice ((GOutputStream *)tmpbuf, object_input,
+ G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET, cancellable, error)
+ < 0)
return FALSE;
- g_autoptr(GBytes) tmpb = g_memory_output_stream_steal_as_bytes (tmpbuf);
+ g_autoptr (GBytes) tmpb = g_memory_output_stream_steal_as_bytes (tmpbuf);
- g_autoptr(GVariant) tmpv = g_variant_new_from_bytes (ostree_metadata_variant_type (objtype),
- tmpb, TRUE);
- return ostree_repo_write_metadata_trusted (self, objtype, checksum, tmpv,
- cancellable, error);
+ g_autoptr (GVariant) tmpv
+ = g_variant_new_from_bytes (ostree_metadata_variant_type (objtype), tmpb, TRUE);
+ return ostree_repo_write_metadata_trusted (self, objtype, checksum, tmpv, cancellable, error);
}
/**
@@ -2566,19 +2454,14 @@ ostree_repo_write_metadata_stream_trusted (OstreeRepo *self,
* trusted.
*/
gboolean
-ostree_repo_write_metadata_trusted (OstreeRepo *self,
- OstreeObjectType type,
- const char *checksum,
- GVariant *variant,
- GCancellable *cancellable,
- GError **error)
+ostree_repo_write_metadata_trusted (OstreeRepo *self, OstreeObjectType type, const char *checksum,
+ GVariant *variant, GCancellable *cancellable, GError **error)
{
- return ostree_repo_write_metadata (self, type,
- checksum, variant, NULL,
- cancellable, error);
+ return ostree_repo_write_metadata (self, type, checksum, variant, NULL, cancellable, error);
}
-typedef struct {
+typedef struct
+{
OstreeRepo *repo;
OstreeObjectType objtype;
char *expected_checksum;
@@ -2601,18 +2484,13 @@ write_metadata_async_data_free (gpointer user_data)
}
static void
-write_metadata_thread (GTask *task,
- GObject *object,
- gpointer datap,
- GCancellable *cancellable)
+write_metadata_thread (GTask *task, GObject *object, gpointer datap, GCancellable *cancellable)
{
GError *error = NULL;
WriteMetadataAsyncData *data = datap;
- if (!ostree_repo_write_metadata (data->repo, data->objtype, data->expected_checksum,
- data->object,
- &data->result_csum,
- cancellable, &error))
+ if (!ostree_repo_write_metadata (data->repo, data->objtype, data->expected_checksum, data->object,
+ &data->result_csum, cancellable, &error))
g_task_return_error (task, error);
else
g_task_return_pointer (task, data, NULL);
@@ -2632,15 +2510,12 @@ write_metadata_thread (GTask *task,
* the checksum @expected_checksum will be verified.
*/
void
-ostree_repo_write_metadata_async (OstreeRepo *self,
- OstreeObjectType objtype,
- const char *expected_checksum,
- GVariant *object,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
+ostree_repo_write_metadata_async (OstreeRepo *self, OstreeObjectType objtype,
+ const char *expected_checksum, GVariant *object,
+ GCancellable *cancellable, GAsyncReadyCallback callback,
+ gpointer user_data)
{
- g_autoptr(GTask) task = NULL;
+ g_autoptr (GTask) task = NULL;
WriteMetadataAsyncData *asyncdata;
asyncdata = g_new0 (WriteMetadataAsyncData, 1);
@@ -2666,10 +2541,8 @@ ostree_repo_write_metadata_async (OstreeRepo *self,
* Complete a call to ostree_repo_write_metadata_async().
*/
gboolean
-ostree_repo_write_metadata_finish (OstreeRepo *self,
- GAsyncResult *result,
- guchar **out_csum,
- GError **error)
+ostree_repo_write_metadata_finish (OstreeRepo *self, GAsyncResult *result, guchar **out_csum,
+ GError **error)
{
WriteMetadataAsyncData *data;
@@ -2693,20 +2566,16 @@ ostree_repo_write_metadata_finish (OstreeRepo *self,
* Return its (binary) checksum in @out_csum.
*/
gboolean
-_ostree_repo_write_directory_meta (OstreeRepo *self,
- GFileInfo *file_info,
- GVariant *xattrs,
- guchar **out_csum,
- GCancellable *cancellable,
- GError **error)
+_ostree_repo_write_directory_meta (OstreeRepo *self, GFileInfo *file_info, GVariant *xattrs,
+ guchar **out_csum, GCancellable *cancellable, GError **error)
{
if (g_cancellable_set_error_if_cancelled (cancellable, error))
return FALSE;
- g_autoptr(GVariant) dirmeta = ostree_create_directory_metadata (file_info, xattrs);
- return ostree_repo_write_metadata (self, OSTREE_OBJECT_TYPE_DIR_META, NULL,
- dirmeta, out_csum, cancellable, error);
+ g_autoptr (GVariant) dirmeta = ostree_create_directory_metadata (file_info, xattrs);
+ return ostree_repo_write_metadata (self, OSTREE_OBJECT_TYPE_DIR_META, NULL, dirmeta, out_csum,
+ cancellable, error);
}
/**
@@ -2725,15 +2594,11 @@ _ostree_repo_write_directory_meta (OstreeRepo *self,
* disk, for example.
*/
gboolean
-ostree_repo_write_content_trusted (OstreeRepo *self,
- const char *checksum,
- GInputStream *object_input,
- guint64 length,
- GCancellable *cancellable,
- GError **error)
+ostree_repo_write_content_trusted (OstreeRepo *self, const char *checksum,
+ GInputStream *object_input, guint64 length,
+ GCancellable *cancellable, GError **error)
{
- return ostree_repo_write_content (self, checksum, object_input, length,
- NULL, cancellable, error);
+ return ostree_repo_write_content (self, checksum, object_input, length, NULL, cancellable, error);
}
/**
@@ -2751,13 +2616,9 @@ ostree_repo_write_content_trusted (OstreeRepo *self,
* be returned as @out_csum.
*/
gboolean
-ostree_repo_write_content (OstreeRepo *self,
- const char *expected_checksum,
- GInputStream *object_input,
- guint64 length,
- guchar **out_csum,
- GCancellable *cancellable,
- GError **error)
+ostree_repo_write_content (OstreeRepo *self, const char *expected_checksum,
+ GInputStream *object_input, guint64 length, guchar **out_csum,
+ GCancellable *cancellable, GError **error)
{
/* First, if we have an expected checksum, see if we already have this
* object. This mirrors the same logic in ostree_repo_write_metadata().
@@ -2768,9 +2629,8 @@ ostree_repo_write_content (OstreeRepo *self,
if (expected_checksum && !self->generate_sizes)
{
gboolean have_obj;
- if (!_ostree_repo_has_loose_object (self, expected_checksum,
- OSTREE_OBJECT_TYPE_FILE, &have_obj,
- cancellable, error))
+ if (!_ostree_repo_has_loose_object (self, expected_checksum, OSTREE_OBJECT_TYPE_FILE,
+ &have_obj, cancellable, error))
return FALSE;
if (have_obj)
{
@@ -2781,16 +2641,14 @@ ostree_repo_write_content (OstreeRepo *self,
}
/* Parse the stream */
- g_autoptr(GInputStream) file_input = NULL;
- g_autoptr(GVariant) xattrs = NULL;
- g_autoptr(GFileInfo) file_info = NULL;
- if (!ostree_content_stream_parse (FALSE, object_input, length, FALSE,
- &file_input, &file_info, &xattrs,
- cancellable, error))
+ g_autoptr (GInputStream) file_input = NULL;
+ g_autoptr (GVariant) xattrs = NULL;
+ g_autoptr (GFileInfo) file_info = NULL;
+ if (!ostree_content_stream_parse (FALSE, object_input, length, FALSE, &file_input, &file_info,
+ &xattrs, cancellable, error))
return FALSE;
- return write_content_object (self, expected_checksum,
- file_input, file_info, xattrs, out_csum,
+ return write_content_object (self, expected_checksum, file_input, file_info, xattrs, out_csum,
cancellable, error);
}
@@ -2818,24 +2676,16 @@ ostree_repo_write_content (OstreeRepo *self,
*/
_OSTREE_PUBLIC
char *
-ostree_repo_write_regfile_inline (OstreeRepo *self,
- const char *expected_checksum,
- guint32 uid,
- guint32 gid,
- guint32 mode,
- GVariant *xattrs,
- const guint8* buf,
- gsize len,
- GCancellable *cancellable,
- GError **error)
+ostree_repo_write_regfile_inline (OstreeRepo *self, const char *expected_checksum, guint32 uid,
+ guint32 gid, guint32 mode, GVariant *xattrs, const guint8 *buf,
+ gsize len, GCancellable *cancellable, GError **error)
{
- g_autoptr(GInputStream) memin = g_memory_input_stream_new_from_data (buf, len, NULL);
- g_autoptr(GFileInfo) finfo = _ostree_mode_uidgid_to_gfileinfo (mode, uid, gid);
+ g_autoptr (GInputStream) memin = g_memory_input_stream_new_from_data (buf, len, NULL);
+ g_autoptr (GFileInfo) finfo = _ostree_mode_uidgid_to_gfileinfo (mode, uid, gid);
g_file_info_set_size (finfo, len);
- g_autofree guint8* csum = NULL;
- if (!write_content_object (self, expected_checksum,
- memin, finfo, xattrs, &csum,
- cancellable, error))
+ g_autofree guint8 *csum = NULL;
+ if (!write_content_object (self, expected_checksum, memin, finfo, xattrs, &csum, cancellable,
+ error))
return NULL;
return ostree_checksum_from_bytes (csum);
}
@@ -2860,23 +2710,17 @@ ostree_repo_write_regfile_inline (OstreeRepo *self,
* Since: 2021.2
*/
char *
-ostree_repo_write_symlink (OstreeRepo *self,
- const char *expected_checksum,
- guint32 uid,
- guint32 gid,
- GVariant *xattrs,
- const char *symlink_target,
- GCancellable *cancellable,
- GError **error)
+ostree_repo_write_symlink (OstreeRepo *self, const char *expected_checksum, guint32 uid,
+ guint32 gid, GVariant *xattrs, const char *symlink_target,
+ GCancellable *cancellable, GError **error)
{
g_assert (symlink_target != NULL);
- g_autoptr(GFileInfo) finfo = _ostree_mode_uidgid_to_gfileinfo (S_IFLNK | 0777, uid, gid);
+ g_autoptr (GFileInfo) finfo = _ostree_mode_uidgid_to_gfileinfo (S_IFLNK | 0777, uid, gid);
g_file_info_set_attribute_byte_string (finfo, "standard::symlink-target", symlink_target);
- g_autofree guint8* csum = NULL;
- if (!write_content_object (self, expected_checksum,
- NULL, finfo, xattrs, &csum,
- cancellable, error))
+ g_autofree guint8 *csum = NULL;
+ if (!write_content_object (self, expected_checksum, NULL, finfo, xattrs, &csum, cancellable,
+ error))
return NULL;
return ostree_checksum_from_bytes (csum);
}
@@ -2899,22 +2743,20 @@ ostree_repo_write_symlink (OstreeRepo *self,
* Since: 2021.2
*/
OstreeContentWriter *
-ostree_repo_write_regfile (OstreeRepo *self,
- const char *expected_checksum,
- guint32 uid,
- guint32 gid,
- guint32 mode,
- guint64 content_len,
- GVariant *xattrs,
- GError **error)
+ostree_repo_write_regfile (OstreeRepo *self, const char *expected_checksum, guint32 uid,
+ guint32 gid, guint32 mode, guint64 content_len, GVariant *xattrs,
+ GError **error)
{
if (self->mode == OSTREE_REPO_MODE_ARCHIVE)
- return glnx_null_throw (error, "Cannot currently use ostree_repo_write_regfile() on an archive mode repository");
+ return glnx_null_throw (
+ error, "Cannot currently use ostree_repo_write_regfile() on an archive mode repository");
- return _ostree_content_writer_new (self, expected_checksum, uid, gid, mode, content_len, xattrs, error);
+ return _ostree_content_writer_new (self, expected_checksum, uid, gid, mode, content_len, xattrs,
+ error);
}
-typedef struct {
+typedef struct
+{
OstreeRepo *repo;
char *expected_checksum;
GInputStream *object;
@@ -2938,18 +2780,14 @@ write_content_async_data_free (gpointer user_data)
}
static void
-write_content_thread (GTask *task,
- GObject *object,
- gpointer datap,
- GCancellable *cancellable)
+write_content_thread (GTask *task, GObject *object, gpointer datap, GCancellable *cancellable)
{
GError *error = NULL;
WriteContentAsyncData *data = datap;
- if (!ostree_repo_write_content (data->repo, data->expected_checksum,
- data->object, data->file_object_length,
- &data->result_csum,
- cancellable, &error))
+ if (!ostree_repo_write_content (data->repo, data->expected_checksum, data->object,
+ data->file_object_length, &data->result_csum, cancellable,
+ &error))
g_task_return_error (task, error);
else
g_task_return_pointer (task, data, NULL);
@@ -2969,15 +2807,11 @@ write_content_thread (GTask *task,
* checksum @expected_checksum will be verified.
*/
void
-ostree_repo_write_content_async (OstreeRepo *self,
- const char *expected_checksum,
- GInputStream *object,
- guint64 length,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
+ostree_repo_write_content_async (OstreeRepo *self, const char *expected_checksum,
+ GInputStream *object, guint64 length, GCancellable *cancellable,
+ GAsyncReadyCallback callback, gpointer user_data)
{
- g_autoptr(GTask) task = NULL;
+ g_autoptr (GTask) task = NULL;
WriteContentAsyncData *asyncdata;
asyncdata = g_new0 (WriteContentAsyncData, 1);
@@ -3004,10 +2838,8 @@ ostree_repo_write_content_async (OstreeRepo *self,
* Completes an invocation of ostree_repo_write_content_async().
*/
gboolean
-ostree_repo_write_content_finish (OstreeRepo *self,
- GAsyncResult *result,
- guchar **out_csum,
- GError **error)
+ostree_repo_write_content_finish (OstreeRepo *self, GAsyncResult *result, guchar **out_csum,
+ GError **error)
{
WriteContentAsyncData *data;
@@ -3029,7 +2861,7 @@ static GVariant *
create_empty_gvariant_dict (void)
{
GVariantBuilder builder;
- g_variant_builder_init (&builder, G_VARIANT_TYPE("a{sv}"));
+ g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
return g_variant_builder_end (&builder);
}
@@ -3054,21 +2886,15 @@ create_empty_gvariant_dict (void)
* `SOURCE_DATE_EPOCH` environment flag.
*/
gboolean
-ostree_repo_write_commit (OstreeRepo *self,
- const char *parent,
- const char *subject,
- const char *body,
- GVariant *metadata,
- OstreeRepoFile *root,
- char **out_commit,
- GCancellable *cancellable,
- GError **error)
+ostree_repo_write_commit (OstreeRepo *self, const char *parent, const char *subject,
+ const char *body, GVariant *metadata, OstreeRepoFile *root,
+ char **out_commit, GCancellable *cancellable, GError **error)
{
gint64 timestamp = 0;
const gchar *env_timestamp = g_getenv ("SOURCE_DATE_EPOCH");
if (env_timestamp == NULL)
{
- g_autoptr(GDateTime) now = g_date_time_new_now_utc ();
+ g_autoptr (GDateTime) now = g_date_time_new_now_utc ();
timestamp = g_date_time_to_unix (now);
}
else
@@ -3082,8 +2908,7 @@ ostree_repo_write_commit (OstreeRepo *self,
return glnx_throw (error, "Failed to convert SOURCE_DATE_EPOCH");
}
- return ostree_repo_write_commit_with_time (self, parent, subject, body,
- metadata, root, timestamp,
+ return ostree_repo_write_commit_with_time (self, parent, subject, body, metadata, root, timestamp,
out_commit, cancellable, error);
}
@@ -3105,40 +2930,31 @@ ostree_repo_write_commit (OstreeRepo *self,
* and @root_metadata_checksum.
*/
gboolean
-ostree_repo_write_commit_with_time (OstreeRepo *self,
- const char *parent,
- const char *subject,
- const char *body,
- GVariant *metadata,
- OstreeRepoFile *root,
- guint64 time,
- char **out_commit,
- GCancellable *cancellable,
- GError **error)
+ostree_repo_write_commit_with_time (OstreeRepo *self, const char *parent, const char *subject,
+ const char *body, GVariant *metadata, OstreeRepoFile *root,
+ guint64 time, char **out_commit, GCancellable *cancellable,
+ GError **error)
{
OstreeRepoFile *repo_root = OSTREE_REPO_FILE (root);
/* Add sizes information to our metadata object */
- g_autoptr(GVariant) new_metadata = add_size_index_to_metadata (self, metadata);
-
- g_autoptr(GVariant) commit =
- g_variant_new ("(@a{sv}@ay@a(say)sst@ay@ay)",
- new_metadata ? new_metadata : create_empty_gvariant_dict (),
- parent ? ostree_checksum_to_bytes_v (parent) : ot_gvariant_new_bytearray (NULL, 0),
- g_variant_new_array (G_VARIANT_TYPE ("(say)"), NULL, 0),
- subject ? subject : "", body ? body : "",
- GUINT64_TO_BE (time),
- ostree_checksum_to_bytes_v (ostree_repo_file_tree_get_contents_checksum (repo_root)),
- ostree_checksum_to_bytes_v (ostree_repo_file_tree_get_metadata_checksum (repo_root)));
+ g_autoptr (GVariant) new_metadata = add_size_index_to_metadata (self, metadata);
+
+ g_autoptr (GVariant) commit = g_variant_new (
+ "(@a{sv}@ay@a(say)sst@ay@ay)", new_metadata ? new_metadata : create_empty_gvariant_dict (),
+ parent ? ostree_checksum_to_bytes_v (parent) : ot_gvariant_new_bytearray (NULL, 0),
+ g_variant_new_array (G_VARIANT_TYPE ("(say)"), NULL, 0), subject ? subject : "",
+ body ? body : "", GUINT64_TO_BE (time),
+ ostree_checksum_to_bytes_v (ostree_repo_file_tree_get_contents_checksum (repo_root)),
+ ostree_checksum_to_bytes_v (ostree_repo_file_tree_get_metadata_checksum (repo_root)));
g_variant_ref_sink (commit);
g_autofree guchar *commit_csum = NULL;
- if (!ostree_repo_write_metadata (self, OSTREE_OBJECT_TYPE_COMMIT, NULL,
- commit, &commit_csum,
+ if (!ostree_repo_write_metadata (self, OSTREE_OBJECT_TYPE_COMMIT, NULL, commit, &commit_csum,
cancellable, error))
return FALSE;
g_autofree char *ret_commit = ostree_checksum_from_bytes (commit_csum);
- ot_transfer_out_value(out_commit, &ret_commit);
+ ot_transfer_out_value (out_commit, &ret_commit);
return TRUE;
}
@@ -3146,7 +2962,8 @@ ostree_repo_write_commit_with_time (OstreeRepo *self,
* ostree_repo_read_commit_detached_metadata:
* @self: Repo
* @checksum: ASCII SHA256 commit checksum
- * @out_metadata: (out) (nullable) (transfer full): Metadata associated with commit in with format "a{sv}", or %NULL if none exists
+ * @out_metadata: (out) (nullable) (transfer full): Metadata associated with commit in with format
+ * "a{sv}", or %NULL if none exists
* @cancellable: Cancellable
* @error: Error
*
@@ -3155,11 +2972,9 @@ ostree_repo_write_commit_with_time (OstreeRepo *self,
* to %NULL.
*/
gboolean
-ostree_repo_read_commit_detached_metadata (OstreeRepo *self,
- const char *checksum,
- GVariant **out_metadata,
- GCancellable *cancellable,
- GError **error)
+ostree_repo_read_commit_detached_metadata (OstreeRepo *self, const char *checksum,
+ GVariant **out_metadata, GCancellable *cancellable,
+ GError **error)
{
g_assert (out_metadata != NULL);
@@ -3172,20 +2987,17 @@ ostree_repo_read_commit_detached_metadata (OstreeRepo *self,
if (!ot_openat_ignore_enoent (self->commit_stagedir.fd, buf, &fd, error))
return FALSE;
if (fd != -1)
- return ot_variant_read_fd (fd, 0, G_VARIANT_TYPE ("a{sv}"), TRUE,
- out_metadata, error);
+ return ot_variant_read_fd (fd, 0, G_VARIANT_TYPE ("a{sv}"), TRUE, out_metadata, error);
}
glnx_autofd int fd = -1;
if (!ot_openat_ignore_enoent (self->objects_dir_fd, buf, &fd, error))
return FALSE;
if (fd != -1)
- return ot_variant_read_fd (fd, 0, G_VARIANT_TYPE ("a{sv}"), TRUE,
- out_metadata, error);
+ return ot_variant_read_fd (fd, 0, G_VARIANT_TYPE ("a{sv}"), TRUE, out_metadata, error);
if (self->parent_repo)
- return ostree_repo_read_commit_detached_metadata (self->parent_repo,
- checksum, out_metadata,
+ return ostree_repo_read_commit_detached_metadata (self->parent_repo, checksum, out_metadata,
cancellable, error);
/* Nothing found */
*out_metadata = NULL;
@@ -3196,7 +3008,8 @@ ostree_repo_read_commit_detached_metadata (OstreeRepo *self,
* ostree_repo_write_commit_detached_metadata:
* @self: Repo
* @checksum: ASCII SHA256 commit checksum
- * @metadata: (nullable): Metadata to associate with commit in with format "a{sv}", or %NULL to delete
+ * @metadata: (nullable): Metadata to associate with commit in with format "a{sv}", or %NULL to
+ * delete
* @cancellable: Cancellable
* @error: Error
*
@@ -3205,11 +3018,9 @@ ostree_repo_read_commit_detached_metadata (OstreeRepo *self,
* data will be deleted.
*/
gboolean
-ostree_repo_write_commit_detached_metadata (OstreeRepo *self,
- const char *checksum,
- GVariant *metadata,
- GCancellable *cancellable,
- GError **error)
+ostree_repo_write_commit_detached_metadata (OstreeRepo *self, const char *checksum,
+ GVariant *metadata, GCancellable *cancellable,
+ GError **error)
{
int dest_dfd;
if (self->in_transaction)
@@ -3217,11 +3028,10 @@ ostree_repo_write_commit_detached_metadata (OstreeRepo *self,
else
dest_dfd = self->objects_dir_fd;
- if (!_ostree_repo_ensure_loose_objdir_at (dest_dfd, checksum,
- cancellable, error))
+ if (!_ostree_repo_ensure_loose_objdir_at (dest_dfd, checksum, cancellable, error))
return FALSE;
- g_autoptr(GVariant) normalized = NULL;
+ g_autoptr (GVariant) normalized = NULL;
gsize normalized_size = 0;
const guint8 *data = NULL;
if (metadata != NULL)
@@ -3232,13 +3042,12 @@ ostree_repo_write_commit_detached_metadata (OstreeRepo *self,
}
if (data == NULL)
- data = (guint8*)"";
+ data = (guint8 *)"";
char pathbuf[_OSTREE_LOOSE_PATH_MAX];
_ostree_loose_path (pathbuf, checksum, OSTREE_OBJECT_TYPE_COMMIT_META, self->mode);
- if (!glnx_file_replace_contents_at (dest_dfd, pathbuf,
- data, normalized_size,
- 0, cancellable, error))
+ if (!glnx_file_replace_contents_at (dest_dfd, pathbuf, data, normalized_size, 0, cancellable,
+ error))
{
g_prefix_error (error, "Unable to write detached metadata: ");
return FALSE;
@@ -3251,9 +3060,8 @@ ostree_repo_write_commit_detached_metadata (OstreeRepo *self,
* content objects and subdirectories. The input hashes will be sorted
*/
static GVariant *
-create_tree_variant_from_hashes (GHashTable *file_checksums,
- GHashTable *dir_contents_checksums,
- GHashTable *dir_metadata_checksums)
+create_tree_variant_from_hashes (GHashTable *file_checksums, GHashTable *dir_contents_checksums,
+ GHashTable *dir_metadata_checksums)
{
GVariantBuilder files_builder;
g_variant_builder_init (&files_builder, G_VARIANT_TYPE ("a(say)"));
@@ -3261,12 +3069,12 @@ create_tree_variant_from_hashes (GHashTable *file_checksums,
g_variant_builder_init (&dirs_builder, G_VARIANT_TYPE ("a(sayay)"));
GSList *sorted_filenames = NULL;
- GLNX_HASH_TABLE_FOREACH (file_checksums, const char*, name)
+ GLNX_HASH_TABLE_FOREACH (file_checksums, const char *, name)
{
/* Should have been validated earlier, but be paranoid */
g_assert (ot_util_filename_validate (name, NULL));
- sorted_filenames = g_slist_prepend (sorted_filenames, (char*)name);
+ sorted_filenames = g_slist_prepend (sorted_filenames, (char *)name);
}
sorted_filenames = g_slist_sort (sorted_filenames, (GCompareFunc)strcmp);
for (GSList *iter = sorted_filenames; iter; iter = iter->next)
@@ -3275,14 +3083,13 @@ create_tree_variant_from_hashes (GHashTable *file_checksums,
const char *value;
value = g_hash_table_lookup (file_checksums, name);
- g_variant_builder_add (&files_builder, "(s@ay)", name,
- ostree_checksum_to_bytes_v (value));
+ g_variant_builder_add (&files_builder, "(s@ay)", name, ostree_checksum_to_bytes_v (value));
}
g_slist_free (sorted_filenames);
sorted_filenames = NULL;
- GLNX_HASH_TABLE_FOREACH (dir_metadata_checksums, const char*, name)
- sorted_filenames = g_slist_prepend (sorted_filenames, (char*)name);
+ GLNX_HASH_TABLE_FOREACH (dir_metadata_checksums, const char *, name)
+ sorted_filenames = g_slist_prepend (sorted_filenames, (char *)name);
sorted_filenames = g_slist_sort (sorted_filenames, (GCompareFunc)strcmp);
for (GSList *iter = sorted_filenames; iter; iter = iter->next)
@@ -3299,10 +3106,9 @@ create_tree_variant_from_hashes (GHashTable *file_checksums,
g_slist_free (sorted_filenames);
sorted_filenames = NULL;
- GVariant *serialized_tree =
- g_variant_new ("(@a(say)@a(sayay))",
- g_variant_builder_end (&files_builder),
- g_variant_builder_end (&dirs_builder));
+ GVariant *serialized_tree
+ = g_variant_new ("(@a(say)@a(sayay))", g_variant_builder_end (&files_builder),
+ g_variant_builder_end (&dirs_builder));
return g_variant_ref_sink (serialized_tree);
}
@@ -3311,11 +3117,9 @@ create_tree_variant_from_hashes (GHashTable *file_checksums,
* will simply be another reference (with incremented refcount) to @file_info.
*/
OstreeRepoCommitFilterResult
-_ostree_repo_commit_modifier_apply (OstreeRepo *self,
- OstreeRepoCommitModifier *modifier,
- const char *path,
- GFileInfo *file_info,
- GFileInfo **out_modified_info)
+_ostree_repo_commit_modifier_apply (OstreeRepo *self, OstreeRepoCommitModifier *modifier,
+ const char *path, GFileInfo *file_info,
+ GFileInfo **out_modified_info)
{
gboolean canonicalize_perms = FALSE;
gboolean has_filter = FALSE;
@@ -3376,7 +3180,7 @@ _ostree_repo_commit_modifier_apply (OstreeRepo *self,
/* Convert @path into a string */
static char *
-ptrarray_path_join (GPtrArray *path)
+ptrarray_path_join (GPtrArray *path)
{
GString *path_buf = g_string_new ("");
@@ -3397,36 +3201,30 @@ ptrarray_path_join (GPtrArray *path)
}
static gboolean
-get_final_xattrs (OstreeRepo *self,
- OstreeRepoCommitModifier *modifier,
- const char *relpath,
- GFileInfo *file_info,
- GFile *path,
- int dfd,
- const char *dfd_subpath,
- GVariant *source_xattrs,
- GVariant **out_xattrs,
- gboolean *out_modified,
- GCancellable *cancellable,
- GError **error)
+get_final_xattrs (OstreeRepo *self, OstreeRepoCommitModifier *modifier, const char *relpath,
+ GFileInfo *file_info, GFile *path, int dfd, const char *dfd_subpath,
+ GVariant *source_xattrs, GVariant **out_xattrs, gboolean *out_modified,
+ GCancellable *cancellable, GError **error)
{
/* track whether the returned xattrs differ from the file on disk */
gboolean modified = TRUE;
- const gboolean skip_xattrs = (modifier &&
- (modifier->flags & (OSTREE_REPO_COMMIT_MODIFIER_FLAGS_SKIP_XATTRS |
- OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CANONICAL_PERMISSIONS)) > 0) ||
- self->mode == OSTREE_REPO_MODE_BARE_USER_ONLY;
+ const gboolean skip_xattrs = (modifier
+ && (modifier->flags
+ & (OSTREE_REPO_COMMIT_MODIFIER_FLAGS_SKIP_XATTRS
+ | OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CANONICAL_PERMISSIONS))
+ > 0)
+ || self->mode == OSTREE_REPO_MODE_BARE_USER_ONLY;
/* fetch on-disk xattrs if needed & not disabled */
- g_autoptr(GVariant) original_xattrs = NULL;
+ g_autoptr (GVariant) original_xattrs = NULL;
if (!skip_xattrs && !self->disable_xattrs)
{
if (source_xattrs)
original_xattrs = g_variant_ref (source_xattrs);
else if (path && OSTREE_IS_REPO_FILE (path))
{
- if (!ostree_repo_file_get_xattrs (OSTREE_REPO_FILE (path), &original_xattrs,
- cancellable, error))
+ if (!ostree_repo_file_get_xattrs (OSTREE_REPO_FILE (path), &original_xattrs, cancellable,
+ error))
return FALSE;
}
else if (path)
@@ -3453,11 +3251,10 @@ get_final_xattrs (OstreeRepo *self,
g_assert (original_xattrs);
}
- g_autoptr(GVariant) ret_xattrs = NULL;
+ g_autoptr (GVariant) ret_xattrs = NULL;
if (modifier && modifier->xattr_callback)
{
- ret_xattrs = modifier->xattr_callback (self, relpath, file_info,
- modifier->xattr_user_data);
+ ret_xattrs = modifier->xattr_callback (self, relpath, file_info, modifier->xattr_user_data);
}
/* if callback returned NULL or didn't exist, default to on-disk state */
@@ -3479,25 +3276,23 @@ get_final_xattrs (OstreeRepo *self,
}
else if (label)
{
- g_autoptr(GVariantBuilder) builder = NULL;
+ g_autoptr (GVariantBuilder) builder = NULL;
if (ret_xattrs)
{
/* drop out any existing SELinux policy from the set, so we don't end up
* counting it twice in the checksum */
- GVariant* new_ret_xattrs = _ostree_filter_selinux_xattr (ret_xattrs);
+ GVariant *new_ret_xattrs = _ostree_filter_selinux_xattr (ret_xattrs);
g_variant_unref (ret_xattrs);
ret_xattrs = new_ret_xattrs;
}
/* ret_xattrs may be NULL */
- builder = ot_util_variant_builder_from_variant (ret_xattrs,
- G_VARIANT_TYPE ("a(ayay)"));
+ builder = ot_util_variant_builder_from_variant (ret_xattrs, G_VARIANT_TYPE ("a(ayay)"));
- g_variant_builder_add_value (builder,
- g_variant_new ("(@ay@ay)",
- g_variant_new_bytestring ("security.selinux"),
- g_variant_new_bytestring (label)));
+ g_variant_builder_add_value (
+ builder, g_variant_new ("(@ay@ay)", g_variant_new_bytestring ("security.selinux"),
+ g_variant_new_bytestring (label)));
if (ret_xattrs)
g_variant_unref (ret_xattrs);
@@ -3516,24 +3311,19 @@ get_final_xattrs (OstreeRepo *self,
return TRUE;
}
-static gboolean
-write_directory_to_mtree_internal (OstreeRepo *self,
- GFile *dir,
- OstreeMutableTree *mtree,
- OstreeRepoCommitModifier *modifier,
- GPtrArray *path,
- GCancellable *cancellable,
- GError **error);
-static gboolean
-write_dfd_iter_to_mtree_internal (OstreeRepo *self,
- GLnxDirFdIterator *src_dfd_iter,
- OstreeMutableTree *mtree,
- OstreeRepoCommitModifier *modifier,
- GPtrArray *path,
- GCancellable *cancellable,
- GError **error);
-
-typedef enum {
+static gboolean write_directory_to_mtree_internal (OstreeRepo *self, GFile *dir,
+ OstreeMutableTree *mtree,
+ OstreeRepoCommitModifier *modifier,
+ GPtrArray *path, GCancellable *cancellable,
+ GError **error);
+static gboolean write_dfd_iter_to_mtree_internal (OstreeRepo *self, GLnxDirFdIterator *src_dfd_iter,
+ OstreeMutableTree *mtree,
+ OstreeRepoCommitModifier *modifier,
+ GPtrArray *path, GCancellable *cancellable,
+ GError **error);
+
+typedef enum
+{
WRITE_DIR_CONTENT_FLAGS_NONE = 0,
WRITE_DIR_CONTENT_FLAGS_CAN_ADOPT = 1,
} WriteDirContentFlags;
@@ -3544,17 +3334,11 @@ typedef enum {
* write_directory_to_mtree_internal (dir_enum case) which will do the actual
* dirmeta + dirent iteration. */
static gboolean
-write_dir_entry_to_mtree_internal (OstreeRepo *self,
- OstreeRepoFile *repo_dir,
- GFileEnumerator *dir_enum,
- GLnxDirFdIterator *dfd_iter,
- WriteDirContentFlags writeflags,
- GFileInfo *child_info,
- OstreeMutableTree *mtree,
- OstreeRepoCommitModifier *modifier,
- GPtrArray *path,
- GCancellable *cancellable,
- GError **error)
+write_dir_entry_to_mtree_internal (OstreeRepo *self, OstreeRepoFile *repo_dir,
+ GFileEnumerator *dir_enum, GLnxDirFdIterator *dfd_iter,
+ WriteDirContentFlags writeflags, GFileInfo *child_info,
+ OstreeMutableTree *mtree, OstreeRepoCommitModifier *modifier,
+ GPtrArray *path, GCancellable *cancellable, GError **error)
{
g_assert (dir_enum != NULL || dfd_iter != NULL);
g_assert (g_file_info_get_file_type (child_info) == G_FILE_TYPE_DIRECTORY);
@@ -3565,17 +3349,17 @@ write_dir_entry_to_mtree_internal (OstreeRepo *self,
* more complexity in this function, and it'd mostly only be useful when
* operating on local filesystems anyways.
*/
- const gboolean delete_after_commit = dfd_iter && modifier &&
- (modifier->flags & OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CONSUME);
+ const gboolean delete_after_commit
+ = dfd_iter && modifier && (modifier->flags & OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CONSUME);
/* Build the full path which we need for callbacks */
- g_ptr_array_add (path, (char*)name);
+ g_ptr_array_add (path, (char *)name);
g_autofree char *child_relpath = ptrarray_path_join (path);
/* Call the filter */
- g_autoptr(GFileInfo) modified_info = NULL;
- OstreeRepoCommitFilterResult filter_result =
- _ostree_repo_commit_modifier_apply (self, modifier, child_relpath, child_info, &modified_info);
+ g_autoptr (GFileInfo) modified_info = NULL;
+ OstreeRepoCommitFilterResult filter_result = _ostree_repo_commit_modifier_apply (
+ self, modifier, child_relpath, child_info, &modified_info);
if (filter_result != OSTREE_REPO_COMMIT_FILTER_ALLOW)
{
@@ -3590,41 +3374,40 @@ write_dir_entry_to_mtree_internal (OstreeRepo *self,
return TRUE;
}
- g_autoptr(GFile) child = NULL;
+ g_autoptr (GFile) child = NULL;
if (dir_enum != NULL)
child = g_file_enumerator_get_child (dir_enum, child_info);
- g_autoptr(OstreeMutableTree) child_mtree = NULL;
+ g_autoptr (OstreeMutableTree) child_mtree = NULL;
if (!ostree_mutable_tree_ensure_dir (mtree, name, &child_mtree, error))
return FALSE;
/* Finally, recurse on the dir */
if (dir_enum != NULL)
{
- if (!write_directory_to_mtree_internal (self, child, child_mtree,
- modifier, path,
- cancellable, error))
+ if (!write_directory_to_mtree_internal (self, child, child_mtree, modifier, path, cancellable,
+ error))
return FALSE;
}
else if (repo_dir)
{
g_assert (dir_enum != NULL);
g_debug ("Adding: %s", gs_file_get_path_cached (child));
- if (!ostree_mutable_tree_replace_file (mtree, name,
- ostree_repo_file_get_checksum ((OstreeRepoFile*) child),
- error))
+ if (!ostree_mutable_tree_replace_file (
+ mtree, name, ostree_repo_file_get_checksum ((OstreeRepoFile *)child), error))
return FALSE;
}
else
{
g_assert (dfd_iter != NULL);
- g_auto(GLnxDirFdIterator) child_dfd_iter = { 0, };
+ g_auto (GLnxDirFdIterator) child_dfd_iter = {
+ 0,
+ };
if (!glnx_dirfd_iterator_init_at (dfd_iter->fd, name, FALSE, &child_dfd_iter, error))
return FALSE;
- if (!write_dfd_iter_to_mtree_internal (self, &child_dfd_iter, child_mtree,
- modifier, path,
+ if (!write_dfd_iter_to_mtree_internal (self, &child_dfd_iter, child_mtree, modifier, path,
cancellable, error))
return FALSE;
@@ -3644,17 +3427,11 @@ write_dir_entry_to_mtree_internal (OstreeRepo *self,
* the mtree.
*/
static gboolean
-write_content_to_mtree_internal (OstreeRepo *self,
- OstreeRepoFile *repo_dir,
- GFileEnumerator *dir_enum,
- GLnxDirFdIterator *dfd_iter,
- WriteDirContentFlags writeflags,
- GFileInfo *child_info,
- OstreeMutableTree *mtree,
- OstreeRepoCommitModifier *modifier,
- GPtrArray *path,
- GCancellable *cancellable,
- GError **error)
+write_content_to_mtree_internal (OstreeRepo *self, OstreeRepoFile *repo_dir,
+ GFileEnumerator *dir_enum, GLnxDirFdIterator *dfd_iter,
+ WriteDirContentFlags writeflags, GFileInfo *child_info,
+ OstreeMutableTree *mtree, OstreeRepoCommitModifier *modifier,
+ GPtrArray *path, GCancellable *cancellable, GError **error)
{
g_assert (dir_enum != NULL || dfd_iter != NULL);
@@ -3664,16 +3441,18 @@ write_content_to_mtree_internal (OstreeRepo *self,
/* Load flags into boolean constants for ease of readability (we also need to
* NULL-check modifier)
*/
- const gboolean canonical_permissions = self->mode == OSTREE_REPO_MODE_BARE_USER_ONLY ||
- (modifier && (modifier->flags & OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CANONICAL_PERMISSIONS));
- const gboolean devino_canonical = modifier &&
- (modifier->flags & OSTREE_REPO_COMMIT_MODIFIER_FLAGS_DEVINO_CANONICAL);
+ const gboolean canonical_permissions
+ = self->mode == OSTREE_REPO_MODE_BARE_USER_ONLY
+ || (modifier
+ && (modifier->flags & OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CANONICAL_PERMISSIONS));
+ const gboolean devino_canonical
+ = modifier && (modifier->flags & OSTREE_REPO_COMMIT_MODIFIER_FLAGS_DEVINO_CANONICAL);
/* We currently only honor the CONSUME flag in the dfd_iter case to avoid even
* more complexity in this function, and it'd mostly only be useful when
* operating on local filesystems anyways.
*/
- const gboolean delete_after_commit = dfd_iter && modifier &&
- (modifier->flags & OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CONSUME);
+ const gboolean delete_after_commit
+ = dfd_iter && modifier && (modifier->flags & OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CONSUME);
/* See if we have a devino hit; this is used below in a few places. */
const char *loose_checksum = NULL;
@@ -3703,7 +3482,7 @@ write_content_to_mtree_internal (OstreeRepo *self,
}
/* Build the full path which we need for callbacks */
- g_ptr_array_add (path, (char*)name);
+ g_ptr_array_add (path, (char *)name);
g_autofree char *child_relpath = ptrarray_path_join (path);
/* For bare-user repos we'll reload our file info from the object
@@ -3712,8 +3491,8 @@ write_content_to_mtree_internal (OstreeRepo *self,
* Basically we're making sure that we pick up "real" uid/gid and any xattrs
* there.
*/
- g_autoptr(GVariant) source_xattrs = NULL;
- g_autoptr(GFileInfo) source_child_info = NULL;
+ g_autoptr (GVariant) source_xattrs = NULL;
+ g_autoptr (GFileInfo) source_child_info = NULL;
if (loose_checksum && self->mode == OSTREE_REPO_MODE_BARE_USER)
{
if (!ostree_repo_load_file (self, loose_checksum, NULL, &source_child_info, &source_xattrs,
@@ -3723,9 +3502,9 @@ write_content_to_mtree_internal (OstreeRepo *self,
}
/* Call the filter */
- g_autoptr(GFileInfo) modified_info = NULL;
- OstreeRepoCommitFilterResult filter_result =
- _ostree_repo_commit_modifier_apply (self, modifier, child_relpath, child_info, &modified_info);
+ g_autoptr (GFileInfo) modified_info = NULL;
+ OstreeRepoCommitFilterResult filter_result = _ostree_repo_commit_modifier_apply (
+ self, modifier, child_relpath, child_info, &modified_info);
const gboolean child_info_was_modified = !_ostree_gfileinfo_equal (child_info, modified_info);
if (filter_result != OSTREE_REPO_COMMIT_FILTER_ALLOW)
@@ -3750,7 +3529,7 @@ write_content_to_mtree_internal (OstreeRepo *self,
return glnx_throw (error, "Unsupported file type for file: '%s'", child_relpath);
}
- g_autoptr(GFile) child = NULL;
+ g_autoptr (GFile) child = NULL;
if (dir_enum != NULL)
child = g_file_enumerator_get_child (dir_enum, child_info);
@@ -3770,13 +3549,12 @@ write_content_to_mtree_internal (OstreeRepo *self,
return FALSE;
}
- g_autoptr(GVariant) xattrs = NULL;
+ g_autoptr (GVariant) xattrs = NULL;
gboolean xattrs_were_modified;
if (dir_enum != NULL)
{
- if (!get_final_xattrs (self, modifier, child_relpath, child_info, child,
- -1, name, source_xattrs, &xattrs, &xattrs_were_modified,
- cancellable, error))
+ if (!get_final_xattrs (self, modifier, child_relpath, child_info, child, -1, name,
+ source_xattrs, &xattrs, &xattrs_were_modified, cancellable, error))
return FALSE;
}
else
@@ -3786,9 +3564,8 @@ write_content_to_mtree_internal (OstreeRepo *self,
*/
int xattr_fd_arg = (file_input_fd != -1) ? file_input_fd : dfd_iter->fd;
const char *xattr_path_arg = (file_input_fd != -1) ? NULL : name;
- if (!get_final_xattrs (self, modifier, child_relpath, child_info, child,
- xattr_fd_arg, xattr_path_arg, source_xattrs,
- &xattrs, &xattrs_were_modified,
+ if (!get_final_xattrs (self, modifier, child_relpath, child_info, child, xattr_fd_arg,
+ xattr_path_arg, source_xattrs, &xattrs, &xattrs_were_modified,
cancellable, error))
return FALSE;
}
@@ -3799,11 +3576,9 @@ write_content_to_mtree_internal (OstreeRepo *self,
/* A big prerequisite list of conditions for whether or not we can
* "adopt", i.e. just checksum and rename() into place
*/
- const gboolean can_adopt_basic =
- file_type == G_FILE_TYPE_REGULAR
- && dfd_iter != NULL
- && delete_after_commit
- && ((writeflags & WRITE_DIR_CONTENT_FLAGS_CAN_ADOPT) > 0);
+ const gboolean can_adopt_basic = file_type == G_FILE_TYPE_REGULAR && dfd_iter != NULL
+ && delete_after_commit
+ && ((writeflags & WRITE_DIR_CONTENT_FLAGS_CAN_ADOPT) > 0);
gboolean can_adopt = can_adopt_basic;
/* If basic prerquisites are met, check repo mode specific ones */
if (can_adopt)
@@ -3826,8 +3601,7 @@ write_content_to_mtree_internal (OstreeRepo *self,
/* The very fast path - we have a devino cache hit, nothing to write */
if (loose_checksum && !modified_file_meta)
{
- if (!ostree_mutable_tree_replace_file (mtree, name, loose_checksum,
- error))
+ if (!ostree_mutable_tree_replace_file (mtree, name, loose_checksum, error))
return FALSE;
g_mutex_lock (&self->txn_lock);
@@ -3837,9 +3611,9 @@ write_content_to_mtree_internal (OstreeRepo *self,
/* Next fast path - we can "adopt" the file */
else if (can_adopt)
{
- char checksum[OSTREE_SHA256_STRING_LEN+1];
- if (!adopt_and_commit_regfile (self, dfd_iter->fd, name, modified_info, xattrs,
- checksum, cancellable, error))
+ char checksum[OSTREE_SHA256_STRING_LEN + 1];
+ if (!adopt_and_commit_regfile (self, dfd_iter->fd, name, modified_info, xattrs, checksum,
+ cancellable, error))
return FALSE;
if (!ostree_mutable_tree_replace_file (mtree, name, checksum, error))
return FALSE;
@@ -3847,14 +3621,14 @@ write_content_to_mtree_internal (OstreeRepo *self,
}
else
{
- g_autoptr(GInputStream) file_input = NULL;
+ g_autoptr (GInputStream) file_input = NULL;
if (file_type == G_FILE_TYPE_REGULAR)
{
if (dir_enum != NULL)
{
g_assert (child != NULL);
- file_input = (GInputStream*)g_file_read (child, cancellable, error);
+ file_input = (GInputStream *)g_file_read (child, cancellable, error);
if (!file_input)
return FALSE;
}
@@ -3866,14 +3640,13 @@ write_content_to_mtree_internal (OstreeRepo *self,
}
g_autofree guchar *child_file_csum = NULL;
- if (!write_content_object (self, NULL, file_input, modified_info, xattrs,
- &child_file_csum, cancellable, error))
+ if (!write_content_object (self, NULL, file_input, modified_info, xattrs, &child_file_csum,
+ cancellable, error))
return FALSE;
- char tmp_checksum[OSTREE_SHA256_STRING_LEN+1];
+ char tmp_checksum[OSTREE_SHA256_STRING_LEN + 1];
ostree_checksum_inplace_from_bytes (child_file_csum, tmp_checksum);
- if (!ostree_mutable_tree_replace_file (mtree, name, tmp_checksum,
- error))
+ if (!ostree_mutable_tree_replace_file (mtree, name, tmp_checksum, error))
return FALSE;
}
@@ -3894,13 +3667,9 @@ write_content_to_mtree_internal (OstreeRepo *self,
/* Handles the dirmeta for the given GFile dir and then calls
* write_{dir_entry,content}_to_mtree_internal() for each directory entry. */
static gboolean
-write_directory_to_mtree_internal (OstreeRepo *self,
- GFile *dir,
- OstreeMutableTree *mtree,
- OstreeRepoCommitModifier *modifier,
- GPtrArray *path,
- GCancellable *cancellable,
- GError **error)
+write_directory_to_mtree_internal (OstreeRepo *self, GFile *dir, OstreeMutableTree *mtree,
+ OstreeRepoCommitModifier *modifier, GPtrArray *path,
+ GCancellable *cancellable, GError **error)
{
OstreeRepoCommitFilterResult filter_result;
OstreeRepoFile *repo_dir = NULL;
@@ -3911,7 +3680,7 @@ write_directory_to_mtree_internal (OstreeRepo *self,
/* If the directory is already in the repository, we can try to
* reuse checksums to skip checksumming. */
if (dir && OSTREE_IS_REPO_FILE (dir) && modifier == NULL)
- repo_dir = (OstreeRepoFile *) dir;
+ repo_dir = (OstreeRepoFile *)dir;
if (repo_dir)
{
@@ -3920,24 +3689,23 @@ write_directory_to_mtree_internal (OstreeRepo *self,
/* ostree_mutable_tree_fill_from_dirtree returns FALSE if mtree isn't
* empty: in which case we're responsible for merging the trees. */
- if (ostree_mutable_tree_fill_empty_from_dirtree (mtree,
- ostree_repo_file_get_repo (repo_dir),
- ostree_repo_file_tree_get_contents_checksum (repo_dir),
- ostree_repo_file_get_checksum (repo_dir)))
+ if (ostree_mutable_tree_fill_empty_from_dirtree (
+ mtree, ostree_repo_file_get_repo (repo_dir),
+ ostree_repo_file_tree_get_contents_checksum (repo_dir),
+ ostree_repo_file_get_checksum (repo_dir)))
return TRUE;
- ostree_mutable_tree_set_metadata_checksum (mtree, ostree_repo_file_tree_get_metadata_checksum (repo_dir));
+ ostree_mutable_tree_set_metadata_checksum (
+ mtree, ostree_repo_file_tree_get_metadata_checksum (repo_dir));
filter_result = OSTREE_REPO_COMMIT_FILTER_ALLOW;
}
else
{
- g_autoptr(GVariant) xattrs = NULL;
+ g_autoptr (GVariant) xattrs = NULL;
- g_autoptr(GFileInfo) child_info =
- g_file_query_info (dir, OSTREE_GIO_FAST_QUERYINFO,
- G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
- cancellable, error);
+ g_autoptr (GFileInfo) child_info = g_file_query_info (
+ dir, OSTREE_GIO_FAST_QUERYINFO, G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, cancellable, error);
if (!child_info)
return FALSE;
@@ -3945,13 +3713,14 @@ write_directory_to_mtree_internal (OstreeRepo *self,
if (modifier != NULL)
relpath = ptrarray_path_join (path);
- g_autoptr(GFileInfo) modified_info = NULL;
- filter_result = _ostree_repo_commit_modifier_apply (self, modifier, relpath, child_info, &modified_info);
+ g_autoptr (GFileInfo) modified_info = NULL;
+ filter_result = _ostree_repo_commit_modifier_apply (self, modifier, relpath, child_info,
+ &modified_info);
if (filter_result == OSTREE_REPO_COMMIT_FILTER_ALLOW)
{
- if (!get_final_xattrs (self, modifier, relpath, child_info, dir, -1, NULL,
- NULL, &xattrs, NULL, cancellable, error))
+ if (!get_final_xattrs (self, modifier, relpath, child_info, dir, -1, NULL, NULL, &xattrs,
+ NULL, cancellable, error))
return FALSE;
g_autofree guchar *child_file_csum = NULL;
@@ -3966,12 +3735,11 @@ write_directory_to_mtree_internal (OstreeRepo *self,
if (filter_result == OSTREE_REPO_COMMIT_FILTER_ALLOW)
{
- g_autoptr(GFileEnumerator) dir_enum = NULL;
+ g_autoptr (GFileEnumerator) dir_enum = NULL;
- dir_enum = g_file_enumerate_children ((GFile*)dir, OSTREE_GIO_FAST_QUERYINFO,
- G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
- cancellable,
- error);
+ dir_enum
+ = g_file_enumerate_children ((GFile *)dir, OSTREE_GIO_FAST_QUERYINFO,
+ G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, cancellable, error);
if (!dir_enum)
return FALSE;
@@ -3979,8 +3747,7 @@ write_directory_to_mtree_internal (OstreeRepo *self,
{
GFileInfo *child_info;
- if (!g_file_enumerator_iterate (dir_enum, &child_info, NULL,
- cancellable, error))
+ if (!g_file_enumerator_iterate (dir_enum, &child_info, NULL, cancellable, error))
return FALSE;
if (child_info == NULL)
break;
@@ -3988,19 +3755,15 @@ write_directory_to_mtree_internal (OstreeRepo *self,
if (g_file_info_get_file_type (child_info) == G_FILE_TYPE_DIRECTORY)
{
if (!write_dir_entry_to_mtree_internal (self, repo_dir, dir_enum, NULL,
- WRITE_DIR_CONTENT_FLAGS_NONE,
- child_info,
- mtree, modifier, path,
- cancellable, error))
+ WRITE_DIR_CONTENT_FLAGS_NONE, child_info,
+ mtree, modifier, path, cancellable, error))
return FALSE;
}
else
{
if (!write_content_to_mtree_internal (self, repo_dir, dir_enum, NULL,
- WRITE_DIR_CONTENT_FLAGS_NONE,
- child_info,
- mtree, modifier, path,
- cancellable, error))
+ WRITE_DIR_CONTENT_FLAGS_NONE, child_info, mtree,
+ modifier, path, cancellable, error))
return FALSE;
}
}
@@ -4012,16 +3775,12 @@ write_directory_to_mtree_internal (OstreeRepo *self,
/* Handles the dirmeta for the dir described by src_dfd_iter and then calls
* write_{dir_entry,content}_to_mtree_internal() for each directory entry. */
static gboolean
-write_dfd_iter_to_mtree_internal (OstreeRepo *self,
- GLnxDirFdIterator *src_dfd_iter,
- OstreeMutableTree *mtree,
- OstreeRepoCommitModifier *modifier,
- GPtrArray *path,
- GCancellable *cancellable,
- GError **error)
+write_dfd_iter_to_mtree_internal (OstreeRepo *self, GLnxDirFdIterator *src_dfd_iter,
+ OstreeMutableTree *mtree, OstreeRepoCommitModifier *modifier,
+ GPtrArray *path, GCancellable *cancellable, GError **error)
{
- g_autoptr(GFileInfo) modified_info = NULL;
- g_autoptr(GVariant) xattrs = NULL;
+ g_autoptr (GFileInfo) modified_info = NULL;
+ g_autoptr (GVariant) xattrs = NULL;
g_autofree guchar *child_file_csum = NULL;
g_autofree char *relpath = NULL;
OstreeRepoCommitFilterResult filter_result;
@@ -4031,11 +3790,12 @@ write_dfd_iter_to_mtree_internal (OstreeRepo *self,
return FALSE;
{
- g_autoptr(GFileInfo) child_info = _ostree_stbuf_to_gfileinfo (&dir_stbuf);
+ g_autoptr (GFileInfo) child_info = _ostree_stbuf_to_gfileinfo (&dir_stbuf);
if (modifier != NULL)
{
relpath = ptrarray_path_join (path);
- filter_result = _ostree_repo_commit_modifier_apply (self, modifier, relpath, child_info, &modified_info);
+ filter_result = _ostree_repo_commit_modifier_apply (self, modifier, relpath, child_info,
+ &modified_info);
}
else
{
@@ -4046,8 +3806,8 @@ write_dfd_iter_to_mtree_internal (OstreeRepo *self,
if (filter_result == OSTREE_REPO_COMMIT_FILTER_ALLOW)
{
- if (!get_final_xattrs (self, modifier, relpath, modified_info, NULL, src_dfd_iter->fd,
- NULL, NULL, &xattrs, NULL, cancellable, error))
+ if (!get_final_xattrs (self, modifier, relpath, modified_info, NULL, src_dfd_iter->fd, NULL,
+ NULL, &xattrs, NULL, cancellable, error))
return FALSE;
if (!_ostree_repo_write_directory_meta (self, modified_info, xattrs, &child_file_csum,
@@ -4081,15 +3841,13 @@ write_dfd_iter_to_mtree_internal (OstreeRepo *self,
if (!glnx_fstatat (src_dfd_iter->fd, dent->d_name, &stbuf, AT_SYMLINK_NOFOLLOW, error))
return FALSE;
- g_autoptr(GFileInfo) child_info = _ostree_stbuf_to_gfileinfo (&stbuf);
+ g_autoptr (GFileInfo) child_info = _ostree_stbuf_to_gfileinfo (&stbuf);
g_file_info_set_name (child_info, dent->d_name);
if (S_ISDIR (stbuf.st_mode))
{
- if (!write_dir_entry_to_mtree_internal (self, NULL, NULL, src_dfd_iter,
- flags, child_info,
- mtree, modifier, path,
- cancellable, error))
+ if (!write_dir_entry_to_mtree_internal (self, NULL, NULL, src_dfd_iter, flags, child_info,
+ mtree, modifier, path, cancellable, error))
return FALSE;
/* We handled the dir, move onto the next */
@@ -4100,21 +3858,18 @@ write_dfd_iter_to_mtree_internal (OstreeRepo *self,
;
else if (S_ISLNK (stbuf.st_mode))
{
- if (!ot_readlinkat_gfile_info (src_dfd_iter->fd, dent->d_name,
- child_info, cancellable, error))
+ if (!ot_readlinkat_gfile_info (src_dfd_iter->fd, dent->d_name, child_info, cancellable,
+ error))
return FALSE;
}
else
{
- return glnx_throw (error, "Not a regular file or symlink: %s",
- dent->d_name);
+ return glnx_throw (error, "Not a regular file or symlink: %s", dent->d_name);
}
/* Write a content object, we handled directories above */
- if (!write_content_to_mtree_internal (self, NULL, NULL, src_dfd_iter,
- flags, child_info,
- mtree, modifier, path,
- cancellable, error))
+ if (!write_content_to_mtree_internal (self, NULL, NULL, src_dfd_iter, flags, child_info,
+ mtree, modifier, path, cancellable, error))
return FALSE;
}
@@ -4134,28 +3889,24 @@ write_dfd_iter_to_mtree_internal (OstreeRepo *self,
* overlaying the resulting filesystem hierarchy into @mtree.
*/
gboolean
-ostree_repo_write_directory_to_mtree (OstreeRepo *self,
- GFile *dir,
- OstreeMutableTree *mtree,
- OstreeRepoCommitModifier *modifier,
- GCancellable *cancellable,
- GError **error)
+ostree_repo_write_directory_to_mtree (OstreeRepo *self, GFile *dir, OstreeMutableTree *mtree,
+ OstreeRepoCommitModifier *modifier, GCancellable *cancellable,
+ GError **error)
{
/* Short cut local files */
if (g_file_is_native (dir))
{
- if (!ostree_repo_write_dfd_to_mtree (self, AT_FDCWD, gs_file_get_path_cached (dir),
- mtree, modifier, cancellable, error))
+ if (!ostree_repo_write_dfd_to_mtree (self, AT_FDCWD, gs_file_get_path_cached (dir), mtree,
+ modifier, cancellable, error))
return FALSE;
}
else
{
_ostree_repo_setup_generate_sizes (self, modifier);
- g_autoptr(GPtrArray) path = g_ptr_array_new ();
- if (!write_directory_to_mtree_internal (self, dir, mtree, modifier, path,
- cancellable, error))
+ g_autoptr (GPtrArray) path = g_ptr_array_new ();
+ if (!write_directory_to_mtree_internal (self, dir, mtree, modifier, path, cancellable, error))
return FALSE;
}
@@ -4177,23 +3928,21 @@ ostree_repo_write_directory_to_mtree (OstreeRepo *self,
* resulting filesystem hierarchy into @mtree.
*/
gboolean
-ostree_repo_write_dfd_to_mtree (OstreeRepo *self,
- int dfd,
- const char *path,
- OstreeMutableTree *mtree,
- OstreeRepoCommitModifier *modifier,
- GCancellable *cancellable,
- GError **error)
+ostree_repo_write_dfd_to_mtree (OstreeRepo *self, int dfd, const char *path,
+ OstreeMutableTree *mtree, OstreeRepoCommitModifier *modifier,
+ GCancellable *cancellable, GError **error)
{
_ostree_repo_setup_generate_sizes (self, modifier);
- g_auto(GLnxDirFdIterator) dfd_iter = { 0, };
+ g_auto (GLnxDirFdIterator) dfd_iter = {
+ 0,
+ };
if (!glnx_dirfd_iterator_init_at (dfd, path, FALSE, &dfd_iter, error))
return FALSE;
- g_autoptr(GPtrArray) pathbuilder = g_ptr_array_new ();
- if (!write_dfd_iter_to_mtree_internal (self, &dfd_iter, mtree, modifier, pathbuilder,
- cancellable, error))
+ g_autoptr (GPtrArray) pathbuilder = g_ptr_array_new ();
+ if (!write_dfd_iter_to_mtree_internal (self, &dfd_iter, mtree, modifier, pathbuilder, cancellable,
+ error))
return FALSE;
/* And now finally remove the toplevel; see also the handling for this flag in
@@ -4201,8 +3950,8 @@ ostree_repo_write_dfd_to_mtree (OstreeRepo *self,
* try to remove `.` (since we'd get EINVAL); that's what's used in
* rpm-ostree.
*/
- const gboolean delete_after_commit = modifier &&
- (modifier->flags & OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CONSUME);
+ const gboolean delete_after_commit
+ = modifier && (modifier->flags & OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CONSUME);
if (delete_after_commit && !g_str_equal (path, "."))
{
if (!glnx_unlinkat (dfd, path, AT_REMOVEDIR, error))
@@ -4225,14 +3974,11 @@ ostree_repo_write_dfd_to_mtree (OstreeRepo *self,
* the @mtree represented.
*/
gboolean
-ostree_repo_write_mtree (OstreeRepo *self,
- OstreeMutableTree *mtree,
- GFile **out_file,
- GCancellable *cancellable,
- GError **error)
+ostree_repo_write_mtree (OstreeRepo *self, OstreeMutableTree *mtree, GFile **out_file,
+ GCancellable *cancellable, GError **error)
{
const char *contents_checksum, *metadata_checksum;
- g_autoptr(GFile) ret_file = NULL;
+ g_autoptr (GFile) ret_file = NULL;
if (!ostree_mutable_tree_check_error (mtree, error))
return glnx_prefix_error (error, "mtree");
@@ -4248,44 +3994,44 @@ ostree_repo_write_mtree (OstreeRepo *self,
}
else
{
- g_autoptr(GHashTable) dir_metadata_checksums = NULL;
- g_autoptr(GHashTable) dir_contents_checksums = NULL;
- g_autoptr(GVariant) serialized_tree = NULL;
+ g_autoptr (GHashTable) dir_metadata_checksums = NULL;
+ g_autoptr (GHashTable) dir_contents_checksums = NULL;
+ g_autoptr (GVariant) serialized_tree = NULL;
g_autofree guchar *contents_csum = NULL;
- char contents_checksum_buf[OSTREE_SHA256_STRING_LEN+1];
+ char contents_checksum_buf[OSTREE_SHA256_STRING_LEN + 1];
- dir_contents_checksums = g_hash_table_new_full (g_str_hash, g_str_equal,
- (GDestroyNotify)g_free, (GDestroyNotify)g_free);
- dir_metadata_checksums = g_hash_table_new_full (g_str_hash, g_str_equal,
- (GDestroyNotify)g_free, (GDestroyNotify)g_free);
+ dir_contents_checksums = g_hash_table_new_full (
+ g_str_hash, g_str_equal, (GDestroyNotify)g_free, (GDestroyNotify)g_free);
+ dir_metadata_checksums = g_hash_table_new_full (
+ g_str_hash, g_str_equal, (GDestroyNotify)g_free, (GDestroyNotify)g_free);
- GLNX_HASH_TABLE_FOREACH_KV (ostree_mutable_tree_get_subdirs (mtree),
- const char*, name, OstreeMutableTree*, child_dir)
+ GLNX_HASH_TABLE_FOREACH_KV (ostree_mutable_tree_get_subdirs (mtree), const char *, name,
+ OstreeMutableTree *, child_dir)
{
- g_autoptr(GFile) child_file = NULL;
- if (!ostree_repo_write_mtree (self, child_dir, &child_file,
- cancellable, error))
+ g_autoptr (GFile) child_file = NULL;
+ if (!ostree_repo_write_mtree (self, child_dir, &child_file, cancellable, error))
return FALSE;
g_hash_table_replace (dir_contents_checksums, g_strdup (name),
- g_strdup (ostree_repo_file_tree_get_contents_checksum (OSTREE_REPO_FILE (child_file))));
+ g_strdup (ostree_repo_file_tree_get_contents_checksum (
+ OSTREE_REPO_FILE (child_file))));
g_hash_table_replace (dir_metadata_checksums, g_strdup (name),
- g_strdup (ostree_repo_file_tree_get_metadata_checksum (OSTREE_REPO_FILE (child_file))));
+ g_strdup (ostree_repo_file_tree_get_metadata_checksum (
+ OSTREE_REPO_FILE (child_file))));
}
- serialized_tree = create_tree_variant_from_hashes (ostree_mutable_tree_get_files (mtree),
- dir_contents_checksums,
- dir_metadata_checksums);
+ serialized_tree = create_tree_variant_from_hashes (
+ ostree_mutable_tree_get_files (mtree), dir_contents_checksums, dir_metadata_checksums);
- if (!ostree_repo_write_metadata (self, OSTREE_OBJECT_TYPE_DIR_TREE, NULL,
- serialized_tree, &contents_csum,
- cancellable, error))
+ if (!ostree_repo_write_metadata (self, OSTREE_OBJECT_TYPE_DIR_TREE, NULL, serialized_tree,
+ &contents_csum, cancellable, error))
return FALSE;
ostree_checksum_inplace_from_bytes (contents_csum, contents_checksum_buf);
ostree_mutable_tree_set_contents_checksum (mtree, contents_checksum_buf);
- ret_file = G_FILE (_ostree_repo_file_new_root (self, contents_checksum_buf, metadata_checksum));
+ ret_file
+ = G_FILE (_ostree_repo_file_new_root (self, contents_checksum_buf, metadata_checksum));
}
if (out_file)
@@ -4303,10 +4049,9 @@ ostree_repo_write_mtree (OstreeRepo *self,
* Returns: (transfer full): A new commit modifier.
*/
OstreeRepoCommitModifier *
-ostree_repo_commit_modifier_new (OstreeRepoCommitModifierFlags flags,
- OstreeRepoCommitFilter commit_filter,
- gpointer user_data,
- GDestroyNotify destroy_notify)
+ostree_repo_commit_modifier_new (OstreeRepoCommitModifierFlags flags,
+ OstreeRepoCommitFilter commit_filter, gpointer user_data,
+ GDestroyNotify destroy_notify)
{
OstreeRepoCommitModifier *modifier = g_new0 (OstreeRepoCommitModifier, 1);
@@ -4362,10 +4107,9 @@ ostree_repo_commit_modifier_unref (OstreeRepoCommitModifier *modifier)
* repository.
*/
void
-ostree_repo_commit_modifier_set_xattr_callback (OstreeRepoCommitModifier *modifier,
- OstreeRepoCommitModifierXattrCallback callback,
- GDestroyNotify destroy,
- gpointer user_data)
+ostree_repo_commit_modifier_set_xattr_callback (OstreeRepoCommitModifier *modifier,
+ OstreeRepoCommitModifierXattrCallback callback,
+ GDestroyNotify destroy, gpointer user_data)
{
modifier->xattr_callback = callback;
modifier->xattr_destroy = destroy;
@@ -4387,8 +4131,8 @@ ostree_repo_commit_modifier_set_xattr_callback (OstreeRepoCommitModifier *modif
* policy wins.
*/
void
-ostree_repo_commit_modifier_set_sepolicy (OstreeRepoCommitModifier *modifier,
- OstreeSePolicy *sepolicy)
+ostree_repo_commit_modifier_set_sepolicy (OstreeRepoCommitModifier *modifier,
+ OstreeSePolicy *sepolicy)
{
g_clear_object (&modifier->sepolicy);
modifier->sepolicy = sepolicy ? g_object_ref (sepolicy) : NULL;
@@ -4409,13 +4153,12 @@ ostree_repo_commit_modifier_set_sepolicy (OstreeRepoCommitModifier
* Since: 2020.4
*/
gboolean
-ostree_repo_commit_modifier_set_sepolicy_from_commit (OstreeRepoCommitModifier *modifier,
- OstreeRepo *repo,
- const char *rev,
- GCancellable *cancellable,
- GError **error)
+ostree_repo_commit_modifier_set_sepolicy_from_commit (OstreeRepoCommitModifier *modifier,
+ OstreeRepo *repo, const char *rev,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(OstreeSePolicy) policy = ostree_sepolicy_new_from_commit (repo, rev, cancellable, error);
+ g_autoptr (OstreeSePolicy) policy
+ = ostree_sepolicy_new_from_commit (repo, rev, cancellable, error);
if (!policy)
return FALSE;
ostree_repo_commit_modifier_set_sepolicy (modifier, policy);
@@ -4441,55 +4184,50 @@ ostree_repo_commit_modifier_set_sepolicy_from_commit (OstreeRepoCommitModifier
* Since: 2017.13
*/
void
-ostree_repo_commit_modifier_set_devino_cache (OstreeRepoCommitModifier *modifier,
- OstreeRepoDevInoCache *cache)
+ostree_repo_commit_modifier_set_devino_cache (OstreeRepoCommitModifier *modifier,
+ OstreeRepoDevInoCache *cache)
{
- modifier->devino_cache = g_hash_table_ref ((GHashTable*)cache);
+ modifier->devino_cache = g_hash_table_ref ((GHashTable *)cache);
}
OstreeRepoDevInoCache *
ostree_repo_devino_cache_ref (OstreeRepoDevInoCache *cache)
{
- g_hash_table_ref ((GHashTable*)cache);
+ g_hash_table_ref ((GHashTable *)cache);
return cache;
}
void
ostree_repo_devino_cache_unref (OstreeRepoDevInoCache *cache)
{
- g_hash_table_unref ((GHashTable*)cache);
+ g_hash_table_unref ((GHashTable *)cache);
}
-G_DEFINE_BOXED_TYPE(OstreeRepoDevInoCache, ostree_repo_devino_cache,
- ostree_repo_devino_cache_ref,
- ostree_repo_devino_cache_unref);
+G_DEFINE_BOXED_TYPE (OstreeRepoDevInoCache, ostree_repo_devino_cache, ostree_repo_devino_cache_ref,
+ ostree_repo_devino_cache_unref);
-G_DEFINE_BOXED_TYPE(OstreeRepoCommitModifier, ostree_repo_commit_modifier,
- ostree_repo_commit_modifier_ref,
- ostree_repo_commit_modifier_unref);
+G_DEFINE_BOXED_TYPE (OstreeRepoCommitModifier, ostree_repo_commit_modifier,
+ ostree_repo_commit_modifier_ref, ostree_repo_commit_modifier_unref);
/* Special case between bare-user and bare-user-only,
* mostly for https://github.com/flatpak/flatpak/issues/845
* see below for any more comments.
*/
static gboolean
-import_is_bareuser_only_conversion (OstreeRepo *src_repo,
- OstreeRepo *dest_repo,
+import_is_bareuser_only_conversion (OstreeRepo *src_repo, OstreeRepo *dest_repo,
OstreeObjectType objtype)
{
return src_repo->mode == OSTREE_REPO_MODE_BARE_USER
- && dest_repo->mode == OSTREE_REPO_MODE_BARE_USER_ONLY
- && objtype == OSTREE_OBJECT_TYPE_FILE;
+ && dest_repo->mode == OSTREE_REPO_MODE_BARE_USER_ONLY
+ && objtype == OSTREE_OBJECT_TYPE_FILE;
}
/* Returns TRUE if we can potentially just call link() to copy an object;
* if untrusted the repos must be owned by the same uid.
*/
static gboolean
-import_via_reflink_is_possible (OstreeRepo *src_repo,
- OstreeRepo *dest_repo,
- OstreeObjectType objtype,
- gboolean trusted)
+import_via_reflink_is_possible (OstreeRepo *src_repo, OstreeRepo *dest_repo,
+ OstreeObjectType objtype, gboolean trusted)
{
/* Untrusted pulls require matching ownership */
if (!trusted && (src_repo->owner_uid != dest_repo->owner_uid))
@@ -4497,8 +4235,7 @@ import_via_reflink_is_possible (OstreeRepo *src_repo,
/* Equal modes are always compatible, and metadata
* is identical between all modes.
*/
- if (src_repo->mode == dest_repo->mode ||
- OSTREE_OBJECT_TYPE_IS_META (objtype))
+ if (src_repo->mode == dest_repo->mode || OSTREE_OBJECT_TYPE_IS_META (objtype))
return TRUE;
/* And now a special case between bare-user and bare-user-only,
* mostly for https://github.com/flatpak/flatpak/issues/845
@@ -4512,23 +4249,18 @@ import_via_reflink_is_possible (OstreeRepo *src_repo,
* to @self.
*/
static gboolean
-copy_detached_metadata (OstreeRepo *self,
- OstreeRepo *source,
- const char *checksum,
- GCancellable *cancellable,
- GError **error)
+copy_detached_metadata (OstreeRepo *self, OstreeRepo *source, const char *checksum,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GVariant) detached_meta = NULL;
- if (!ostree_repo_read_commit_detached_metadata (source,
- checksum, &detached_meta,
- cancellable, error))
+ g_autoptr (GVariant) detached_meta = NULL;
+ if (!ostree_repo_read_commit_detached_metadata (source, checksum, &detached_meta, cancellable,
+ error))
return FALSE;
if (detached_meta)
{
- if (!ostree_repo_write_commit_detached_metadata (self,
- checksum, detached_meta,
- cancellable, error))
+ if (!ostree_repo_write_commit_detached_metadata (self, checksum, detached_meta, cancellable,
+ error))
return FALSE;
}
@@ -4540,24 +4272,19 @@ copy_detached_metadata (OstreeRepo *self,
* we're not verifying the checksum.
*/
static gboolean
-import_one_object_direct (OstreeRepo *dest_repo,
- OstreeRepo *src_repo,
- const char *checksum,
- OstreeObjectType objtype,
- gboolean *out_was_supported,
- GCancellable *cancellable,
- GError **error)
+import_one_object_direct (OstreeRepo *dest_repo, OstreeRepo *src_repo, const char *checksum,
+ OstreeObjectType objtype, gboolean *out_was_supported,
+ GCancellable *cancellable, GError **error)
{
- const char *errprefix = glnx_strjoina ("Importing ", checksum, ".",
- ostree_object_type_to_string (objtype));
+ const char *errprefix
+ = glnx_strjoina ("Importing ", checksum, ".", ostree_object_type_to_string (objtype));
GLNX_AUTO_PREFIX_ERROR (errprefix, error);
char loose_path_buf[_OSTREE_LOOSE_PATH_MAX];
_ostree_loose_path (loose_path_buf, checksum, objtype, dest_repo->mode);
/* hardlinks require the owner to match and to be on the same device */
- const gboolean can_hardlink =
- src_repo->owner_uid == dest_repo->owner_uid &&
- src_repo->device == dest_repo->device;
+ const gboolean can_hardlink
+ = src_repo->owner_uid == dest_repo->owner_uid && src_repo->device == dest_repo->device;
/* Find our target dfd */
int dest_dfd;
@@ -4597,8 +4324,8 @@ import_one_object_direct (OstreeRepo *dest_repo,
{
struct stat stbuf;
- if (!glnx_fstatat (src_repo->objects_dir_fd, loose_path_buf,
- &stbuf, AT_SYMLINK_NOFOLLOW, error))
+ if (!glnx_fstatat (src_repo->objects_dir_fd, loose_path_buf, &stbuf, AT_SYMLINK_NOFOLLOW,
+ error))
return FALSE;
/* Let's punt for symlinks right now, it's more complicated */
@@ -4613,17 +4340,17 @@ import_one_object_direct (OstreeRepo *dest_repo,
* in the future we should add flags for those things?
*/
glnx_autofd int src_fd = -1;
- if (!glnx_openat_rdonly (src_repo->objects_dir_fd, loose_path_buf,
- FALSE, &src_fd, error))
+ if (!glnx_openat_rdonly (src_repo->objects_dir_fd, loose_path_buf, FALSE, &src_fd, error))
return FALSE;
/* Open a tmpfile for dest */
- 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");
/* Only chown for true bare repos */
@@ -4637,18 +4364,17 @@ import_one_object_direct (OstreeRepo *dest_repo,
* bare-user-only. We also only do this for content
* objects.
*/
- const gboolean src_is_bare_or_bare_user =
- G_IN_SET (src_repo->mode, OSTREE_REPO_MODE_BARE, OSTREE_REPO_MODE_BARE_USER);
- if (src_is_bare_or_bare_user && !OSTREE_OBJECT_TYPE_IS_META(objtype))
+ const gboolean src_is_bare_or_bare_user
+ = G_IN_SET (src_repo->mode, OSTREE_REPO_MODE_BARE, OSTREE_REPO_MODE_BARE_USER);
+ if (src_is_bare_or_bare_user && !OSTREE_OBJECT_TYPE_IS_META (objtype))
{
if (src_repo->mode == OSTREE_REPO_MODE_BARE)
{
- g_autoptr(GVariant) xattrs = NULL;
+ g_autoptr (GVariant) xattrs = NULL;
xattrs = ostree_fs_get_all_xattrs (src_fd, cancellable, error);
if (!xattrs)
return FALSE;
- if (!glnx_fd_set_all_xattrs (tmp_dest.fd, xattrs,
- cancellable, error))
+ if (!glnx_fd_set_all_xattrs (tmp_dest.fd, xattrs, cancellable, error))
return FALSE;
}
else if (dest_repo->mode == OSTREE_REPO_MODE_BARE_USER_ONLY)
@@ -4664,14 +4390,14 @@ import_one_object_direct (OstreeRepo *dest_repo,
g_assert (src_repo->mode == dest_repo->mode);
/* bare-user; we just want ostree.usermeta */
- g_autoptr(GBytes) bytes =
- glnx_fgetxattr_bytes (src_fd, "user.ostreemeta", error);
+ g_autoptr (GBytes) bytes = glnx_fgetxattr_bytes (src_fd, "user.ostreemeta", error);
if (bytes == NULL)
return FALSE;
if (TEMP_FAILURE_RETRY (fsetxattr (tmp_dest.fd, "user.ostreemeta",
- (char*)g_bytes_get_data (bytes, NULL),
- g_bytes_get_size (bytes), 0)) != 0)
+ (char *)g_bytes_get_data (bytes, NULL),
+ g_bytes_get_size (bytes), 0))
+ != 0)
return glnx_throw_errno_prefix (error, "fsetxattr");
}
}
@@ -4687,11 +4413,11 @@ import_one_object_direct (OstreeRepo *dest_repo,
struct timespec ts[2];
ts[0] = stbuf.st_atim;
ts[1] = stbuf.st_mtim;
- (void) futimens (tmp_dest.fd, ts);
+ (void)futimens (tmp_dest.fd, ts);
}
- if (!_ostree_repo_commit_tmpf_final (dest_repo, checksum, objtype,
- &tmp_dest, cancellable, error))
+ if (!_ostree_repo_commit_tmpf_final (dest_repo, checksum, objtype, &tmp_dest, cancellable,
+ error))
return FALSE;
}
@@ -4713,13 +4439,9 @@ import_one_object_direct (OstreeRepo *dest_repo,
* with flags; may make this public API later.
*/
gboolean
-_ostree_repo_import_object (OstreeRepo *self,
- OstreeRepo *source,
- OstreeObjectType objtype,
- const char *checksum,
- OstreeRepoImportFlags flags,
- GCancellable *cancellable,
- GError **error)
+_ostree_repo_import_object (OstreeRepo *self, OstreeRepo *source, OstreeObjectType objtype,
+ const char *checksum, OstreeRepoImportFlags flags,
+ GCancellable *cancellable, GError **error)
{
const gboolean trusted = (flags & _OSTREE_REPO_IMPORT_FLAGS_TRUSTED) > 0;
/* Implements OSTREE_REPO_PULL_FLAGS_BAREUSERONLY_FILES which was designed for flatpak */
@@ -4727,8 +4449,8 @@ _ostree_repo_import_object (OstreeRepo *self,
/* A special case between bare-user and bare-user-only,
* mostly for https://github.com/flatpak/flatpak/issues/845
*/
- const gboolean is_bareuseronly_conversion =
- import_is_bareuser_only_conversion (source, self, objtype);
+ const gboolean is_bareuseronly_conversion
+ = import_is_bareuser_only_conversion (source, self, objtype);
gboolean try_direct = TRUE;
/* If we need to do bareuseronly verification, or we're potentially doing a
@@ -4737,10 +4459,8 @@ _ostree_repo_import_object (OstreeRepo *self,
*/
if ((verify_bareuseronly || is_bareuseronly_conversion) && !OSTREE_OBJECT_TYPE_IS_META (objtype))
{
- g_autoptr(GFileInfo) src_finfo = NULL;
- if (!ostree_repo_load_file (source, checksum,
- NULL, &src_finfo, NULL,
- cancellable, error))
+ g_autoptr (GFileInfo) src_finfo = NULL;
+ if (!ostree_repo_load_file (source, checksum, NULL, &src_finfo, NULL, cancellable, error))
return FALSE;
if (verify_bareuseronly)
@@ -4778,14 +4498,12 @@ _ostree_repo_import_object (OstreeRepo *self,
*/
if (!trusted)
{
- if (!ostree_repo_fsck_object (source, objtype, checksum,
- cancellable, error))
+ if (!ostree_repo_fsck_object (source, objtype, checksum, cancellable, error))
return FALSE;
}
gboolean direct_was_supported = FALSE;
- if (!import_one_object_direct (self, source, checksum, objtype,
- &direct_was_supported,
+ if (!import_one_object_direct (self, source, checksum, objtype, &direct_was_supported,
cancellable, error))
return FALSE;
@@ -4801,8 +4519,7 @@ _ostree_repo_import_object (OstreeRepo *self,
/* First, do we have the object already? */
gboolean has_object;
- if (!ostree_repo_has_object (self, objtype, checksum, &has_object,
- cancellable, error))
+ if (!ostree_repo_has_object (self, objtype, checksum, &has_object, cancellable, error))
return FALSE;
/* If we have it, we're done */
if (has_object)
@@ -4818,7 +4535,7 @@ _ostree_repo_import_object (OstreeRepo *self,
if (OSTREE_OBJECT_TYPE_IS_META (objtype))
{
/* Metadata object */
- g_autoptr(GVariant) variant = NULL;
+ g_autoptr (GVariant) variant = NULL;
if (objtype == OSTREE_OBJECT_TYPE_COMMIT)
{
@@ -4827,34 +4544,28 @@ _ostree_repo_import_object (OstreeRepo *self,
return FALSE;
}
- if (!ostree_repo_load_variant (source, objtype, checksum,
- &variant, error))
+ if (!ostree_repo_load_variant (source, objtype, checksum, &variant, error))
return FALSE;
/* Note this one also now verifies structure in the !trusted case */
g_autofree guchar *real_csum = NULL;
- if (!ostree_repo_write_metadata (self, objtype,
- checksum, variant,
- trusted ? NULL : &real_csum,
- cancellable, error))
+ if (!ostree_repo_write_metadata (self, objtype, checksum, variant,
+ trusted ? NULL : &real_csum, cancellable, error))
return FALSE;
}
else
{
/* Content object */
guint64 length;
- g_autoptr(GInputStream) object_stream = NULL;
+ g_autoptr (GInputStream) object_stream = NULL;
- if (!ostree_repo_load_object_stream (source, objtype, checksum,
- &object_stream, &length,
+ if (!ostree_repo_load_object_stream (source, objtype, checksum, &object_stream, &length,
cancellable, error))
return FALSE;
g_autofree guchar *real_csum = NULL;
- if (!ostree_repo_write_content (self, checksum,
- object_stream, length,
- trusted ? NULL : &real_csum,
- cancellable, error))
+ if (!ostree_repo_write_content (self, checksum, object_stream, length,
+ trusted ? NULL : &real_csum, cancellable, error))
return FALSE;
}
@@ -4873,17 +4584,13 @@ ostree_repo_transaction_stats_free (OstreeRepoTransactionStats *stats)
return g_free (stats);
}
-G_DEFINE_BOXED_TYPE(OstreeRepoTransactionStats, ostree_repo_transaction_stats,
- ostree_repo_transaction_stats_copy,
- ostree_repo_transaction_stats_free);
-
+G_DEFINE_BOXED_TYPE (OstreeRepoTransactionStats, ostree_repo_transaction_stats,
+ ostree_repo_transaction_stats_copy, ostree_repo_transaction_stats_free);
gboolean
-_ostree_repo_transaction_write_repo_metadata (OstreeRepo *self,
- GVariant *additional_metadata,
- char **out_checksum,
- GCancellable *cancellable,
- GError **error)
+_ostree_repo_transaction_write_repo_metadata (OstreeRepo *self, GVariant *additional_metadata,
+ char **out_checksum, GCancellable *cancellable,
+ GError **error)
{
g_assert (self != NULL);
g_assert (OSTREE_IS_REPO (self));
@@ -4893,49 +4600,46 @@ _ostree_repo_transaction_write_repo_metadata (OstreeRepo *self,
if (collection_id == NULL)
return glnx_throw (error, "Repository must have collection ID to write repo metadata");
- OstreeCollectionRef collection_ref = { (gchar *) collection_id,
- (gchar *) OSTREE_REPO_METADATA_REF };
+ OstreeCollectionRef collection_ref
+ = { (gchar *)collection_id, (gchar *)OSTREE_REPO_METADATA_REF };
g_autofree char *old_checksum = NULL;
- if (!ostree_repo_resolve_rev (self, OSTREE_REPO_METADATA_REF, TRUE,
- &old_checksum, error))
+ if (!ostree_repo_resolve_rev (self, OSTREE_REPO_METADATA_REF, TRUE, &old_checksum, error))
return FALSE;
/* Add bindings to the commit metadata. */
- g_autoptr(GVariantDict) metadata_dict = g_variant_dict_new (additional_metadata);
- g_variant_dict_insert (metadata_dict, OSTREE_COMMIT_META_KEY_COLLECTION_BINDING,
- "s", collection_ref.collection_id);
- g_variant_dict_insert_value (metadata_dict, OSTREE_COMMIT_META_KEY_REF_BINDING,
- g_variant_new_strv ((const gchar * const *) &collection_ref.ref_name, 1));
- g_autoptr(GVariant) metadata = g_variant_dict_end (metadata_dict);
+ g_autoptr (GVariantDict) metadata_dict = g_variant_dict_new (additional_metadata);
+ g_variant_dict_insert (metadata_dict, OSTREE_COMMIT_META_KEY_COLLECTION_BINDING, "s",
+ collection_ref.collection_id);
+ g_variant_dict_insert_value (
+ metadata_dict, OSTREE_COMMIT_META_KEY_REF_BINDING,
+ g_variant_new_strv ((const gchar *const *)&collection_ref.ref_name, 1));
+ g_autoptr (GVariant) metadata = g_variant_dict_end (metadata_dict);
/* Set up an empty mtree. */
- g_autoptr(OstreeMutableTree) mtree = ostree_mutable_tree_new ();
+ g_autoptr (OstreeMutableTree) mtree = ostree_mutable_tree_new ();
glnx_unref_object GFileInfo *fi = g_file_info_new ();
g_file_info_set_attribute_uint32 (fi, "unix::uid", 0);
g_file_info_set_attribute_uint32 (fi, "unix::gid", 0);
g_file_info_set_attribute_uint32 (fi, "unix::mode", (0755 | S_IFDIR));
- g_autoptr(GVariant) dirmeta = ostree_create_directory_metadata (fi, NULL /* xattrs */);
+ g_autoptr (GVariant) dirmeta = ostree_create_directory_metadata (fi, NULL /* xattrs */);
g_autofree guchar *csum_raw = NULL;
- if (!ostree_repo_write_metadata (self, OSTREE_OBJECT_TYPE_DIR_META, NULL,
- dirmeta, &csum_raw, cancellable, error))
+ if (!ostree_repo_write_metadata (self, OSTREE_OBJECT_TYPE_DIR_META, NULL, dirmeta, &csum_raw,
+ cancellable, error))
return FALSE;
g_autofree char *csum = ostree_checksum_from_bytes (csum_raw);
ostree_mutable_tree_set_metadata_checksum (mtree, csum);
- g_autoptr(OstreeRepoFile) repo_file = NULL;
- if (!ostree_repo_write_mtree (self, mtree, (GFile **) &repo_file, cancellable, error))
+ g_autoptr (OstreeRepoFile) repo_file = NULL;
+ if (!ostree_repo_write_mtree (self, mtree, (GFile **)&repo_file, cancellable, error))
return FALSE;
g_autofree gchar *new_checksum = NULL;
- if (!ostree_repo_write_commit (self, old_checksum,
- NULL /* subject */, NULL /* body */,
- metadata, repo_file,
- &new_checksum,
- cancellable, error))
+ if (!ostree_repo_write_commit (self, old_checksum, NULL /* subject */, NULL /* body */, metadata,
+ repo_file, &new_checksum, cancellable, error))
return FALSE;
ostree_repo_transaction_set_collection_ref (self, &collection_ref, new_checksum);