lib/deltas: Some style porting
Just a few functions to keep up momentum. Closes: #964 Approved by: jlebon
This commit is contained in:
parent
21cb4d1715
commit
c2b6afe5b9
|
|
@ -165,31 +165,30 @@ _ostree_repo_static_delta_part_have_all_objects (OstreeRepo *repo,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gboolean ret = FALSE;
|
|
||||||
guint8 *checksums_data;
|
guint8 *checksums_data;
|
||||||
guint i,n_checksums;
|
guint n_checksums;
|
||||||
gboolean have_object = TRUE;
|
gboolean have_object = TRUE;
|
||||||
|
|
||||||
if (!_ostree_static_delta_parse_checksum_array (checksum_array,
|
if (!_ostree_static_delta_parse_checksum_array (checksum_array,
|
||||||
&checksums_data,
|
&checksums_data,
|
||||||
&n_checksums,
|
&n_checksums,
|
||||||
error))
|
error))
|
||||||
goto out;
|
return FALSE;
|
||||||
|
|
||||||
for (i = 0; i < n_checksums; i++)
|
for (guint i = 0; i < n_checksums; i++)
|
||||||
{
|
{
|
||||||
guint8 objtype = *checksums_data;
|
guint8 objtype = *checksums_data;
|
||||||
const guint8 *csum = checksums_data + 1;
|
const guint8 *csum = checksums_data + 1;
|
||||||
char tmp_checksum[OSTREE_SHA256_STRING_LEN+1];
|
char tmp_checksum[OSTREE_SHA256_STRING_LEN+1];
|
||||||
|
|
||||||
if (G_UNLIKELY(!ostree_validate_structureof_objtype (objtype, error)))
|
if (G_UNLIKELY(!ostree_validate_structureof_objtype (objtype, error)))
|
||||||
goto out;
|
return FALSE;
|
||||||
|
|
||||||
ostree_checksum_inplace_from_bytes (csum, tmp_checksum);
|
ostree_checksum_inplace_from_bytes (csum, tmp_checksum);
|
||||||
|
|
||||||
if (!ostree_repo_has_object (repo, (OstreeObjectType) objtype, tmp_checksum,
|
if (!ostree_repo_has_object (repo, (OstreeObjectType) objtype, tmp_checksum,
|
||||||
&have_object, cancellable, error))
|
&have_object, cancellable, error))
|
||||||
goto out;
|
return FALSE;
|
||||||
|
|
||||||
if (!have_object)
|
if (!have_object)
|
||||||
break;
|
break;
|
||||||
|
|
@ -197,10 +196,8 @@ _ostree_repo_static_delta_part_have_all_objects (OstreeRepo *repo,
|
||||||
checksums_data += OSTREE_STATIC_DELTA_OBJTYPE_CSUM_LEN;
|
checksums_data += OSTREE_STATIC_DELTA_OBJTYPE_CSUM_LEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = TRUE;
|
|
||||||
*out_have_all = have_object;
|
*out_have_all = have_object;
|
||||||
out:
|
return TRUE;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -223,57 +220,43 @@ ostree_repo_static_delta_execute_offline (OstreeRepo *self,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gboolean ret = FALSE;
|
|
||||||
guint i, n;
|
|
||||||
const char *dir_or_file_path = NULL;
|
|
||||||
glnx_fd_close int meta_fd = -1;
|
|
||||||
glnx_fd_close int dfd = -1;
|
|
||||||
g_autoptr(GVariant) meta = NULL;
|
|
||||||
g_autoptr(GVariant) headers = NULL;
|
|
||||||
g_autoptr(GVariant) metadata = NULL;
|
|
||||||
g_autoptr(GVariant) fallback = NULL;
|
|
||||||
g_autofree char *to_checksum = NULL;
|
|
||||||
g_autofree char *from_checksum = NULL;
|
|
||||||
g_autofree char *basename = NULL;
|
g_autofree char *basename = NULL;
|
||||||
|
|
||||||
dir_or_file_path = gs_file_get_path_cached (dir_or_file);
|
const char *dir_or_file_path = gs_file_get_path_cached (dir_or_file);
|
||||||
|
|
||||||
/* First, try opening it as a directory */
|
/* First, try opening it as a directory */
|
||||||
dfd = glnx_opendirat_with_errno (AT_FDCWD, dir_or_file_path, TRUE);
|
glnx_fd_close int dfd = glnx_opendirat_with_errno (AT_FDCWD, dir_or_file_path, TRUE);
|
||||||
if (dfd < 0)
|
if (dfd < 0)
|
||||||
{
|
{
|
||||||
if (errno != ENOTDIR)
|
if (errno != ENOTDIR)
|
||||||
{
|
return glnx_throw_errno_prefix (error, "openat(O_DIRECTORY)");
|
||||||
glnx_set_error_from_errno (error);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_autofree char *dir = dirname (g_strdup (dir_or_file_path));
|
g_autofree char *dir = dirname (g_strdup (dir_or_file_path));
|
||||||
basename = g_path_get_basename (dir_or_file_path);
|
basename = g_path_get_basename (dir_or_file_path);
|
||||||
|
|
||||||
if (!glnx_opendirat (AT_FDCWD, dir, TRUE, &dfd, error))
|
if (!glnx_opendirat (AT_FDCWD, dir, TRUE, &dfd, error))
|
||||||
goto out;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
basename = g_strdup ("superblock");
|
basename = g_strdup ("superblock");
|
||||||
|
|
||||||
meta_fd = openat (dfd, basename, O_RDONLY | O_CLOEXEC);
|
glnx_fd_close int meta_fd = openat (dfd, basename, O_RDONLY | O_CLOEXEC);
|
||||||
if (meta_fd < 0)
|
if (meta_fd < 0)
|
||||||
{
|
return glnx_throw_errno_prefix (error, "openat(%s)", basename);
|
||||||
glnx_set_error_from_errno (error);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
g_autoptr(GVariant) meta = NULL;
|
||||||
if (!ot_util_variant_map_fd (meta_fd, 0, G_VARIANT_TYPE (OSTREE_STATIC_DELTA_SUPERBLOCK_FORMAT),
|
if (!ot_util_variant_map_fd (meta_fd, 0, G_VARIANT_TYPE (OSTREE_STATIC_DELTA_SUPERBLOCK_FORMAT),
|
||||||
FALSE, &meta, error))
|
FALSE, &meta, error))
|
||||||
goto out;
|
return FALSE;
|
||||||
|
|
||||||
/* Parsing OSTREE_STATIC_DELTA_SUPERBLOCK_FORMAT */
|
/* Parsing OSTREE_STATIC_DELTA_SUPERBLOCK_FORMAT */
|
||||||
|
|
||||||
metadata = g_variant_get_child_value (meta, 0);
|
g_autoptr(GVariant) metadata = g_variant_get_child_value (meta, 0);
|
||||||
|
|
||||||
|
g_autofree char *to_checksum = NULL;
|
||||||
|
g_autofree char *from_checksum = NULL;
|
||||||
/* Write the to-commit object */
|
/* Write the to-commit object */
|
||||||
{
|
{
|
||||||
g_autoptr(GVariant) to_csum_v = NULL;
|
g_autoptr(GVariant) to_csum_v = NULL;
|
||||||
|
|
@ -284,31 +267,27 @@ ostree_repo_static_delta_execute_offline (OstreeRepo *self,
|
||||||
|
|
||||||
to_csum_v = g_variant_get_child_value (meta, 3);
|
to_csum_v = g_variant_get_child_value (meta, 3);
|
||||||
if (!ostree_validate_structureof_csum_v (to_csum_v, error))
|
if (!ostree_validate_structureof_csum_v (to_csum_v, error))
|
||||||
goto out;
|
return FALSE;
|
||||||
to_checksum = ostree_checksum_from_bytes_v (to_csum_v);
|
to_checksum = ostree_checksum_from_bytes_v (to_csum_v);
|
||||||
|
|
||||||
from_csum_v = g_variant_get_child_value (meta, 2);
|
from_csum_v = g_variant_get_child_value (meta, 2);
|
||||||
if (g_variant_n_children (from_csum_v) > 0)
|
if (g_variant_n_children (from_csum_v) > 0)
|
||||||
{
|
{
|
||||||
if (!ostree_validate_structureof_csum_v (from_csum_v, error))
|
if (!ostree_validate_structureof_csum_v (from_csum_v, error))
|
||||||
goto out;
|
return FALSE;
|
||||||
from_checksum = ostree_checksum_from_bytes_v (from_csum_v);
|
from_checksum = ostree_checksum_from_bytes_v (from_csum_v);
|
||||||
|
|
||||||
if (!ostree_repo_has_object (self, OSTREE_OBJECT_TYPE_COMMIT, from_checksum,
|
if (!ostree_repo_has_object (self, OSTREE_OBJECT_TYPE_COMMIT, from_checksum,
|
||||||
&have_from_commit, cancellable, error))
|
&have_from_commit, cancellable, error))
|
||||||
goto out;
|
return FALSE;
|
||||||
|
|
||||||
if (!have_from_commit)
|
if (!have_from_commit)
|
||||||
{
|
return glnx_throw (error, "Commit %s, which is the delta source, is not in repository", from_checksum);
|
||||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
|
||||||
"Commit %s, which is the delta source, is not in repository", from_checksum);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ostree_repo_has_object (self, OSTREE_OBJECT_TYPE_COMMIT, to_checksum,
|
if (!ostree_repo_has_object (self, OSTREE_OBJECT_TYPE_COMMIT, to_checksum,
|
||||||
&have_to_commit, cancellable, error))
|
&have_to_commit, cancellable, error))
|
||||||
goto out;
|
return FALSE;
|
||||||
|
|
||||||
if (!have_to_commit)
|
if (!have_to_commit)
|
||||||
{
|
{
|
||||||
|
|
@ -321,27 +300,23 @@ ostree_repo_static_delta_execute_offline (OstreeRepo *self,
|
||||||
detached_data,
|
detached_data,
|
||||||
cancellable,
|
cancellable,
|
||||||
error))
|
error))
|
||||||
goto out;
|
return FALSE;
|
||||||
|
|
||||||
to_commit = g_variant_get_child_value (meta, 4);
|
to_commit = g_variant_get_child_value (meta, 4);
|
||||||
if (!ostree_repo_write_metadata (self, OSTREE_OBJECT_TYPE_COMMIT,
|
if (!ostree_repo_write_metadata (self, OSTREE_OBJECT_TYPE_COMMIT,
|
||||||
to_checksum, to_commit, NULL,
|
to_checksum, to_commit, NULL,
|
||||||
cancellable, error))
|
cancellable, error))
|
||||||
goto out;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fallback = g_variant_get_child_value (meta, 7);
|
g_autoptr(GVariant) fallback = g_variant_get_child_value (meta, 7);
|
||||||
if (g_variant_n_children (fallback) > 0)
|
if (g_variant_n_children (fallback) > 0)
|
||||||
{
|
return glnx_throw (error, "Cannot execute delta offline: contains nonempty http fallback entries");
|
||||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
|
||||||
"Cannot execute delta offline: contains nonempty http fallback entries");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
headers = g_variant_get_child_value (meta, 6);
|
g_autoptr(GVariant) headers = g_variant_get_child_value (meta, 6);
|
||||||
n = g_variant_n_children (headers);
|
const guint n = g_variant_n_children (headers);
|
||||||
for (i = 0; i < n; i++)
|
for (guint i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
guint32 version;
|
guint32 version;
|
||||||
guint64 size;
|
guint64 size;
|
||||||
|
|
@ -349,29 +324,21 @@ ostree_repo_static_delta_execute_offline (OstreeRepo *self,
|
||||||
const guchar *csum;
|
const guchar *csum;
|
||||||
char checksum[OSTREE_SHA256_STRING_LEN+1];
|
char checksum[OSTREE_SHA256_STRING_LEN+1];
|
||||||
gboolean have_all;
|
gboolean have_all;
|
||||||
g_autoptr(GInputStream) part_in = NULL;
|
|
||||||
g_autoptr(GVariant) inline_part_data = NULL;
|
|
||||||
g_autoptr(GVariant) header = NULL;
|
|
||||||
g_autoptr(GVariant) csum_v = NULL;
|
g_autoptr(GVariant) csum_v = NULL;
|
||||||
g_autoptr(GVariant) objects = NULL;
|
g_autoptr(GVariant) objects = NULL;
|
||||||
g_autoptr(GVariant) part = NULL;
|
g_autoptr(GVariant) part = NULL;
|
||||||
g_autofree char *deltapart_path = NULL;
|
g_autofree char *deltapart_path = NULL;
|
||||||
OstreeStaticDeltaOpenFlags delta_open_flags =
|
OstreeStaticDeltaOpenFlags delta_open_flags =
|
||||||
skip_validation ? OSTREE_STATIC_DELTA_OPEN_FLAGS_SKIP_CHECKSUM : 0;
|
skip_validation ? OSTREE_STATIC_DELTA_OPEN_FLAGS_SKIP_CHECKSUM : 0;
|
||||||
|
g_autoptr(GVariant) header = g_variant_get_child_value (headers, i);
|
||||||
header = g_variant_get_child_value (headers, i);
|
|
||||||
g_variant_get (header, "(u@aytt@ay)", &version, &csum_v, &size, &usize, &objects);
|
g_variant_get (header, "(u@aytt@ay)", &version, &csum_v, &size, &usize, &objects);
|
||||||
|
|
||||||
if (version > OSTREE_DELTAPART_VERSION)
|
if (version > OSTREE_DELTAPART_VERSION)
|
||||||
{
|
return glnx_throw (error, "Delta part has too new version %u", version);
|
||||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
|
||||||
"Delta part has too new version %u", version);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_ostree_repo_static_delta_part_have_all_objects (self, objects, &have_all,
|
if (!_ostree_repo_static_delta_part_have_all_objects (self, objects, &have_all,
|
||||||
cancellable, error))
|
cancellable, error))
|
||||||
goto out;
|
return FALSE;
|
||||||
|
|
||||||
/* If we already have these objects, don't bother executing the
|
/* If we already have these objects, don't bother executing the
|
||||||
* static delta.
|
* static delta.
|
||||||
|
|
@ -381,13 +348,14 @@ ostree_repo_static_delta_execute_offline (OstreeRepo *self,
|
||||||
|
|
||||||
csum = ostree_checksum_bytes_peek_validate (csum_v, error);
|
csum = ostree_checksum_bytes_peek_validate (csum_v, error);
|
||||||
if (!csum)
|
if (!csum)
|
||||||
goto out;
|
return FALSE;
|
||||||
ostree_checksum_inplace_from_bytes (csum, checksum);
|
ostree_checksum_inplace_from_bytes (csum, checksum);
|
||||||
|
|
||||||
deltapart_path =
|
deltapart_path =
|
||||||
_ostree_get_relative_static_delta_part_path (from_checksum, to_checksum, i);
|
_ostree_get_relative_static_delta_part_path (from_checksum, to_checksum, i);
|
||||||
|
|
||||||
inline_part_data = g_variant_lookup_value (metadata, deltapart_path, G_VARIANT_TYPE("(yay)"));
|
g_autoptr(GInputStream) part_in = NULL;
|
||||||
|
g_autoptr(GVariant) inline_part_data = g_variant_lookup_value (metadata, deltapart_path, G_VARIANT_TYPE("(yay)"));
|
||||||
if (inline_part_data)
|
if (inline_part_data)
|
||||||
{
|
{
|
||||||
g_autoptr(GBytes) inline_part_bytes = g_variant_get_data_as_bytes (inline_part_data);
|
g_autoptr(GBytes) inline_part_bytes = g_variant_get_data_as_bytes (inline_part_data);
|
||||||
|
|
@ -405,18 +373,14 @@ ostree_repo_static_delta_execute_offline (OstreeRepo *self,
|
||||||
NULL,
|
NULL,
|
||||||
&part,
|
&part,
|
||||||
cancellable, error))
|
cancellable, error))
|
||||||
goto out;
|
return FALSE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_autofree char *relpath = g_strdup_printf ("%u", i); /* TODO avoid malloc here */
|
g_autofree char *relpath = g_strdup_printf ("%u", i); /* TODO avoid malloc here */
|
||||||
glnx_fd_close int part_fd = openat (dfd, relpath, O_RDONLY | O_CLOEXEC);
|
glnx_fd_close int part_fd = openat (dfd, relpath, O_RDONLY | O_CLOEXEC);
|
||||||
if (part_fd < 0)
|
if (part_fd < 0)
|
||||||
{
|
return glnx_throw_errno_prefix (error, "Opening deltapart '%s'", relpath);
|
||||||
glnx_set_error_from_errno (error);
|
|
||||||
g_prefix_error (error, "Opening deltapart '%s': ", deltapart_path);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
part_in = g_unix_input_stream_new (part_fd, FALSE);
|
part_in = g_unix_input_stream_new (part_fd, FALSE);
|
||||||
|
|
||||||
|
|
@ -425,20 +389,15 @@ ostree_repo_static_delta_execute_offline (OstreeRepo *self,
|
||||||
checksum,
|
checksum,
|
||||||
&part,
|
&part,
|
||||||
cancellable, error))
|
cancellable, error))
|
||||||
goto out;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_ostree_static_delta_part_execute (self, objects, part, skip_validation,
|
if (!_ostree_static_delta_part_execute (self, objects, part, skip_validation,
|
||||||
NULL, cancellable, error))
|
NULL, cancellable, error))
|
||||||
{
|
return glnx_prefix_error (error, "Executing delta part %i", i);
|
||||||
g_prefix_error (error, "Executing delta part %i: ", i);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = TRUE;
|
return TRUE;
|
||||||
out:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
|
@ -781,35 +740,30 @@ _ostree_repo_static_delta_delete (OstreeRepo *self,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gboolean ret = FALSE;
|
|
||||||
g_autofree char *from = NULL;
|
g_autofree char *from = NULL;
|
||||||
g_autofree char *to = NULL;
|
g_autofree char *to = NULL;
|
||||||
g_autofree char *deltadir = NULL;
|
|
||||||
struct stat buf;
|
|
||||||
|
|
||||||
if (!_ostree_parse_delta_name (delta_id, &from, &to, error))
|
if (!_ostree_parse_delta_name (delta_id, &from, &to, error))
|
||||||
goto out;
|
return FALSE;
|
||||||
|
|
||||||
deltadir = _ostree_get_relative_static_delta_path (from, to, NULL);
|
|
||||||
|
|
||||||
|
g_autofree char *deltadir = _ostree_get_relative_static_delta_path (from, to, NULL);
|
||||||
|
struct stat buf;
|
||||||
if (fstatat (self->repo_dir_fd, deltadir, &buf, 0) != 0)
|
if (fstatat (self->repo_dir_fd, deltadir, &buf, 0) != 0)
|
||||||
{
|
{
|
||||||
if (errno == ENOENT)
|
if (errno == ENOENT)
|
||||||
|
{
|
||||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
|
||||||
"Can't find delta %s", delta_id);
|
"Can't find delta %s", delta_id);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
glnx_set_error_from_errno (error);
|
return glnx_throw_errno_prefix (error, "fstatat(%s)", deltadir);
|
||||||
|
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!glnx_shutil_rm_rf_at (self->repo_dir_fd, deltadir,
|
if (!glnx_shutil_rm_rf_at (self->repo_dir_fd, deltadir,
|
||||||
cancellable, error))
|
cancellable, error))
|
||||||
goto out;
|
return FALSE;
|
||||||
|
|
||||||
ret = TRUE;
|
return TRUE;
|
||||||
out:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
|
@ -852,28 +806,27 @@ _ostree_repo_static_delta_dump (OstreeRepo *self,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gboolean ret = FALSE;
|
|
||||||
g_autofree char *from = NULL;
|
g_autofree char *from = NULL;
|
||||||
g_autofree char *to = NULL;
|
g_autofree char *to = NULL;
|
||||||
g_autofree char *superblock_path = NULL;
|
g_autofree char *superblock_path = NULL;
|
||||||
g_autoptr(GVariant) delta_superblock = NULL;
|
g_autoptr(GVariant) delta_superblock = NULL;
|
||||||
guint64 total_size = 0, total_usize = 0;
|
guint64 total_size = 0, total_usize = 0;
|
||||||
guint64 total_fallback_size = 0, total_fallback_usize = 0;
|
guint64 total_fallback_size = 0, total_fallback_usize = 0;
|
||||||
guint i;
|
|
||||||
OstreeDeltaEndianness endianness;
|
OstreeDeltaEndianness endianness;
|
||||||
gboolean swap_endian = FALSE;
|
gboolean swap_endian = FALSE;
|
||||||
|
|
||||||
if (!_ostree_parse_delta_name (delta_id, &from, &to, error))
|
if (!_ostree_parse_delta_name (delta_id, &from, &to, error))
|
||||||
goto out;
|
return FALSE;
|
||||||
|
|
||||||
superblock_path = _ostree_get_relative_static_delta_superblock_path (from, to);
|
superblock_path = _ostree_get_relative_static_delta_superblock_path (from, to);
|
||||||
|
|
||||||
if (!ot_util_variant_map_at (self->repo_dir_fd, superblock_path,
|
if (!ot_util_variant_map_at (self->repo_dir_fd, superblock_path,
|
||||||
(GVariantType*)OSTREE_STATIC_DELTA_SUPERBLOCK_FORMAT,
|
(GVariantType*)OSTREE_STATIC_DELTA_SUPERBLOCK_FORMAT,
|
||||||
OT_VARIANT_MAP_TRUSTED, &delta_superblock, error))
|
OT_VARIANT_MAP_TRUSTED, &delta_superblock, error))
|
||||||
goto out;
|
return FALSE;
|
||||||
|
|
||||||
g_print ("Delta: %s\n", delta_id);
|
g_print ("Delta: %s\n", delta_id);
|
||||||
|
|
||||||
{ const char *endianness_description;
|
{ const char *endianness_description;
|
||||||
gboolean was_heuristic;
|
gboolean was_heuristic;
|
||||||
|
|
||||||
|
|
@ -906,23 +859,21 @@ _ostree_repo_static_delta_dump (OstreeRepo *self,
|
||||||
|
|
||||||
g_print ("Endianness: %s\n", endianness_description);
|
g_print ("Endianness: %s\n", endianness_description);
|
||||||
}
|
}
|
||||||
{ guint64 ts;
|
guint64 ts;
|
||||||
g_variant_get_child (delta_superblock, 1, "t", &ts);
|
g_variant_get_child (delta_superblock, 1, "t", &ts);
|
||||||
g_print ("Timestamp: %" G_GUINT64_FORMAT "\n", GUINT64_FROM_BE (ts));
|
g_print ("Timestamp: %" G_GUINT64_FORMAT "\n", GUINT64_FROM_BE (ts));
|
||||||
}
|
|
||||||
{ g_autoptr(GVariant) recurse = NULL;
|
g_autoptr(GVariant) recurse = NULL;
|
||||||
g_variant_get_child (delta_superblock, 5, "@ay", &recurse);
|
g_variant_get_child (delta_superblock, 5, "@ay", &recurse);
|
||||||
g_print ("Number of parents: %u\n", (guint)(g_variant_get_size (recurse) / (OSTREE_SHA256_DIGEST_LEN * 2)));
|
g_print ("Number of parents: %u\n", (guint)(g_variant_get_size (recurse) / (OSTREE_SHA256_DIGEST_LEN * 2)));
|
||||||
}
|
|
||||||
{ g_autoptr(GVariant) fallback = NULL;
|
|
||||||
guint n_fallback;
|
|
||||||
|
|
||||||
|
g_autoptr(GVariant) fallback = NULL;
|
||||||
g_variant_get_child (delta_superblock, 7, "@a" OSTREE_STATIC_DELTA_FALLBACK_FORMAT, &fallback);
|
g_variant_get_child (delta_superblock, 7, "@a" OSTREE_STATIC_DELTA_FALLBACK_FORMAT, &fallback);
|
||||||
n_fallback = g_variant_n_children (fallback);
|
const guint n_fallback = g_variant_n_children (fallback);
|
||||||
|
|
||||||
g_print ("Number of fallback entries: %u\n", n_fallback);
|
g_print ("Number of fallback entries: %u\n", n_fallback);
|
||||||
|
|
||||||
for (i = 0; i < n_fallback; i++)
|
for (guint i = 0; i < n_fallback; i++)
|
||||||
{
|
{
|
||||||
guint64 size, usize;
|
guint64 size, usize;
|
||||||
g_autoptr(GVariant) checksum_v = NULL;
|
g_autoptr(GVariant) checksum_v = NULL;
|
||||||
|
|
@ -940,21 +891,20 @@ _ostree_repo_static_delta_dump (OstreeRepo *self,
|
||||||
g_print ("Total Fallback Size: %" G_GUINT64_FORMAT " (%s)\n", total_fallback_size, sizestr);
|
g_print ("Total Fallback Size: %" G_GUINT64_FORMAT " (%s)\n", total_fallback_size, sizestr);
|
||||||
g_print ("Total Fallback Uncompressed Size: %" G_GUINT64_FORMAT " (%s)\n", total_fallback_usize, usizestr);
|
g_print ("Total Fallback Uncompressed Size: %" G_GUINT64_FORMAT " (%s)\n", total_fallback_usize, usizestr);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
{ g_autoptr(GVariant) meta_entries = NULL;
|
g_autoptr(GVariant) meta_entries = NULL;
|
||||||
guint n_parts;
|
guint n_parts;
|
||||||
|
|
||||||
g_variant_get_child (delta_superblock, 6, "@a" OSTREE_STATIC_DELTA_META_ENTRY_FORMAT, &meta_entries);
|
g_variant_get_child (delta_superblock, 6, "@a" OSTREE_STATIC_DELTA_META_ENTRY_FORMAT, &meta_entries);
|
||||||
n_parts = g_variant_n_children (meta_entries);
|
n_parts = g_variant_n_children (meta_entries);
|
||||||
g_print ("Number of parts: %u\n", n_parts);
|
g_print ("Number of parts: %u\n", n_parts);
|
||||||
|
|
||||||
for (i = 0; i < n_parts; i++)
|
for (guint i = 0; i < n_parts; i++)
|
||||||
{
|
{
|
||||||
if (!show_one_part (self, swap_endian, from, to, meta_entries, i,
|
if (!show_one_part (self, swap_endian, from, to, meta_entries, i,
|
||||||
&total_size, &total_usize,
|
&total_size, &total_usize,
|
||||||
cancellable, error))
|
cancellable, error))
|
||||||
goto out;
|
return FALSE;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{ g_autofree char *sizestr = g_format_size (total_size);
|
{ g_autofree char *sizestr = g_format_size (total_size);
|
||||||
|
|
@ -962,6 +912,7 @@ _ostree_repo_static_delta_dump (OstreeRepo *self,
|
||||||
g_print ("Total Part Size: %" G_GUINT64_FORMAT " (%s)\n", total_size, sizestr);
|
g_print ("Total Part Size: %" G_GUINT64_FORMAT " (%s)\n", total_size, sizestr);
|
||||||
g_print ("Total Part Uncompressed Size: %" G_GUINT64_FORMAT " (%s)\n", total_usize, usizestr);
|
g_print ("Total Part Uncompressed Size: %" G_GUINT64_FORMAT " (%s)\n", total_usize, usizestr);
|
||||||
}
|
}
|
||||||
|
|
||||||
{ guint64 overall_size = total_size + total_fallback_size;
|
{ guint64 overall_size = total_size + total_fallback_size;
|
||||||
guint64 overall_usize = total_usize + total_fallback_usize;
|
guint64 overall_usize = total_usize + total_fallback_usize;
|
||||||
g_autofree char *sizestr = g_format_size (overall_size);
|
g_autofree char *sizestr = g_format_size (overall_size);
|
||||||
|
|
@ -970,7 +921,5 @@ _ostree_repo_static_delta_dump (OstreeRepo *self,
|
||||||
g_print ("Total Uncompressed Size: %" G_GUINT64_FORMAT " (%s)\n", overall_usize, usizestr);
|
g_print ("Total Uncompressed Size: %" G_GUINT64_FORMAT " (%s)\n", overall_usize, usizestr);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = TRUE;
|
return TRUE;
|
||||||
out:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue