| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
#pragma once |
| 21 |
|
| 22 |
#include "ostree-core.h" |
| 23 |
|
| 24 |
G_BEGIN_DECLS |
| 25 |
|
| 26 |
|
| 27 |
#define OSTREE_STATIC_DELTA_PART_MAX_SIZE_BYTES (16 * 1024 * 1024) |
| 28 |
|
| 29 |
#define OSTREE_STATIC_DELTA_OBJTYPE_CSUM_LEN 33 |
| 30 |
|
| 31 |
#define OSTREE_SUMMARY_STATIC_DELTAS "ostree.static-deltas" |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
#define OSTREE_STATIC_DELTA_PART_PAYLOAD_FORMAT_V0 "(a(uuu)aa(ayay)ayay)" |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
#define OSTREE_STATIC_DELTA_META_ENTRY_FORMAT "(uayttay)" |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
#define OSTREE_STATIC_DELTA_FALLBACK_FORMAT "(yaytt)" |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
#define OSTREE_STATIC_DELTA_SUPERBLOCK_FORMAT \ |
| 103 |
"(a{sv}tayay" OSTREE_COMMIT_GVARIANT_STRING "aya" OSTREE_STATIC_DELTA_META_ENTRY_FORMAT \ |
| 104 |
"a" OSTREE_STATIC_DELTA_FALLBACK_FORMAT ")" |
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
#define OSTREE_STATIC_DELTA_SIGNED_FORMAT "(taya{sv})" |
| 122 |
|
| 123 |
#define OSTREE_STATIC_DELTA_SIGNED_MAGIC 0x4F535453474E4454 |
| 124 |
|
| 125 |
typedef enum |
| 126 |
{ |
| 127 |
OSTREE_STATIC_DELTA_OPEN_FLAGS_NONE = 0, |
| 128 |
OSTREE_STATIC_DELTA_OPEN_FLAGS_SKIP_CHECKSUM = (1 << 0), |
| 129 |
OSTREE_STATIC_DELTA_OPEN_FLAGS_VARIANT_TRUSTED = (1 << 1) |
| 130 |
} OstreeStaticDeltaOpenFlags; |
| 131 |
|
| 132 |
typedef enum |
| 133 |
{ |
| 134 |
OSTREE_STATIC_DELTA_OP_OPEN_SPLICE_AND_CLOSE = 'S', |
| 135 |
OSTREE_STATIC_DELTA_OP_OPEN = 'o', |
| 136 |
OSTREE_STATIC_DELTA_OP_WRITE = 'w', |
| 137 |
OSTREE_STATIC_DELTA_OP_SET_READ_SOURCE = 'r', |
| 138 |
OSTREE_STATIC_DELTA_OP_UNSET_READ_SOURCE = 'R', |
| 139 |
OSTREE_STATIC_DELTA_OP_CLOSE = 'c', |
| 140 |
OSTREE_STATIC_DELTA_OP_BSPATCH = 'B' |
| 141 |
} OstreeStaticDeltaOpCode; |
| 142 |
#define OSTREE_STATIC_DELTA_N_OPS 7 |
| 143 |
|
| 144 |
gboolean _ostree_static_delta_part_open (GInputStream *part_in, GBytes *inline_part_bytes, |
| 145 |
OstreeStaticDeltaOpenFlags flags, |
| 146 |
const char *expected_checksum, GVariant **out_part, |
| 147 |
GCancellable *cancellable, GError **error); |
| 148 |
|
| 149 |
typedef struct |
| 150 |
{ |
| 151 |
guint n_ops_executed[OSTREE_STATIC_DELTA_N_OPS]; |
| 152 |
} OstreeDeltaExecuteStats; |
| 153 |
|
| 154 |
gboolean _ostree_static_delta_part_execute (OstreeRepo *repo, GVariant *header, |
| 155 |
GVariant *part_payload, gboolean stats_only, |
| 156 |
OstreeDeltaExecuteStats *stats, |
| 157 |
GCancellable *cancellable, GError **error); |
| 158 |
|
| 159 |
void _ostree_static_delta_part_execute_async (OstreeRepo *repo, GVariant *header, |
| 160 |
GVariant *part_payload, GCancellable *cancellable, |
| 161 |
GAsyncReadyCallback callback, gpointer user_data); |
| 162 |
|
| 163 |
gboolean _ostree_static_delta_part_execute_finish (OstreeRepo *repo, GAsyncResult *result, |
| 164 |
GError **error); |
| 165 |
|
| 166 |
gboolean _ostree_static_delta_parse_checksum_array (GVariant *array, guint8 **out_checksums_array, |
| 167 |
guint *out_n_checksums, GError **error); |
| 168 |
|
| 169 |
gboolean _ostree_repo_static_delta_part_have_all_objects (OstreeRepo *repo, |
| 170 |
GVariant *checksum_array, |
| 171 |
gboolean *out_have_all, |
| 172 |
GCancellable *cancellable, |
| 173 |
GError **error); |
| 174 |
|
| 175 |
typedef struct |
| 176 |
{ |
| 177 |
char *checksum; |
| 178 |
guint64 size; |
| 179 |
GPtrArray *basenames; |
| 180 |
} OstreeDeltaContentSizeNames; |
| 181 |
|
| 182 |
void _ostree_delta_content_sizenames_free (gpointer v); |
| 183 |
|
| 184 |
gboolean _ostree_delta_compute_similar_objects (OstreeRepo *repo, GVariant *from_commit, |
| 185 |
GVariant *to_commit, |
| 186 |
GHashTable *new_reachable_regfile_content, |
| 187 |
guint similarity_percent_threshold, |
| 188 |
GHashTable **out_modified_regfile_content, |
| 189 |
GCancellable *cancellable, GError **error); |
| 190 |
|
| 191 |
gboolean _ostree_repo_static_delta_query_exists (OstreeRepo *repo, const char *delta_id, |
| 192 |
gboolean *out_exists, GCancellable *cancellable, |
| 193 |
GError **error); |
| 194 |
GVariant *_ostree_repo_static_delta_superblock_digest (OstreeRepo *repo, const char *from, |
| 195 |
const char *to, GCancellable *cancellable, |
| 196 |
GError **error); |
| 197 |
|
| 198 |
gboolean _ostree_repo_static_delta_dump (OstreeRepo *repo, const char *delta_id, |
| 199 |
GCancellable *cancellable, GError **error); |
| 200 |
|
| 201 |
gboolean _ostree_repo_static_delta_delete (OstreeRepo *repo, const char *delta_id, |
| 202 |
GCancellable *cancellable, GError **error); |
| 203 |
gboolean _ostree_repo_static_delta_reindex (OstreeRepo *repo, const char *opt_to_commit, |
| 204 |
GCancellable *cancellable, GError **error); |
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
static inline guint32 |
| 212 |
maybe_swap_endian_u32 (gboolean swap, guint32 v) |
| 213 |
{ |
| 214 |
if (!swap) |
| 215 |
return v; |
| 216 |
return GUINT32_SWAP_LE_BE (v); |
| 217 |
} |
| 218 |
|
| 219 |
static inline guint64 |
| 220 |
maybe_swap_endian_u64 (gboolean swap, guint64 v) |
| 221 |
{ |
| 222 |
if (!swap) |
| 223 |
return v; |
| 224 |
return GUINT64_SWAP_LE_BE (v); |
| 225 |
} |
| 226 |
|
| 227 |
typedef enum |
| 228 |
{ |
| 229 |
OSTREE_DELTA_ENDIAN_BIG, |
| 230 |
OSTREE_DELTA_ENDIAN_LITTLE, |
| 231 |
OSTREE_DELTA_ENDIAN_INVALID |
| 232 |
} OstreeDeltaEndianness; |
| 233 |
|
| 234 |
OstreeDeltaEndianness _ostree_delta_get_endianness (GVariant *superblock, |
| 235 |
gboolean *out_was_heuristic); |
| 236 |
|
| 237 |
gboolean _ostree_delta_needs_byteswap (GVariant *superblock); |
| 238 |
|
| 239 |
G_END_DECLS |