lib/repo: read split xattrs content from file-xattrs-link objects

This commit is contained in:
Luca BRUNO 2022-03-02 16:45:01 +00:00
parent 08e98e9042
commit 14a6e6d8d0
No known key found for this signature in database
GPG Key ID: A9834A2252078E4E

View File

@ -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 ();