From 14a6e6d8d081b11217785d7c37b0c0a8c661000c Mon Sep 17 00:00:00 2001 From: Luca BRUNO Date: Wed, 2 Mar 2022 16:45:01 +0000 Subject: lib/repo: read split xattrs content from file-xattrs-link objects --- src/libostree/ostree-repo.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c index 71a01d59..a27591b3 100644 --- a/src/libostree/ostree-repo.c +++ b/src/libostree/ostree-repo.c @@ -4176,6 +4176,32 @@ repo_load_file_archive (OstreeRepo *self, } } +static GVariant * +_ostree_repo_read_xattrs_file_link (OstreeRepo *self, + const char *checksum, + GCancellable *cancellable, + GError **error) +{ + g_assert (self != NULL); + g_assert (checksum != NULL); + + char xattr_path[_OSTREE_LOOSE_PATH_MAX]; + _ostree_loose_path (xattr_path, checksum, OSTREE_OBJECT_TYPE_FILE_XATTRS_LINK, self->mode); + + g_autoptr(GVariant) xattrs = NULL; + glnx_autofd int fd = -1; + if (!glnx_openat_rdonly (self->objects_dir_fd, xattr_path, FALSE, &fd, error)) + return FALSE; + + g_assert (fd >= 0); + if (!ot_variant_read_fd (fd, 0, G_VARIANT_TYPE ("a(ayay)"), TRUE, + &xattrs, error)) + return glnx_prefix_error_null (error, "Deserializing xattrs content"); + + g_assert (xattrs != NULL); + return g_steal_pointer (&xattrs); +} + gboolean _ostree_repo_load_file_bare (OstreeRepo *self, const char *checksum, @@ -4310,6 +4336,15 @@ _ostree_repo_load_file_bare (OstreeRepo *self, return FALSE; } } + else if (self->mode == OSTREE_REPO_MODE_BARE_SPLIT_XATTRS) + { + if (out_xattrs) + { + ret_xattrs = _ostree_repo_read_xattrs_file_link(self, checksum, cancellable, error); + if (ret_xattrs == NULL) + return FALSE; + } + } else { g_assert_not_reached (); -- cgit v1.2.1