Debian Codegraph @

src/sysupdate/sysupdate-instance.h

raw
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include "sd-id128.h"
5
6 #include "sysupdate-forward.h"
7 #include "sysupdate-partition.h"
8
9 typedef struct InstanceMetadata {
10 /* Various bits of metadata for each instance, that is either derived from the filename/GPT label or
11 * from metadata of the file/partition itself */
12 char *version;
13 sd_id128_t partition_uuid;
14 bool partition_uuid_set;
15 uint64_t partition_flags; /* GPT partition flags */
16 bool partition_flags_set;
17 usec_t mtime;
18 mode_t mode;
19 uint64_t size; /* uncompressed size of the file */
20 uint64_t tries_done, tries_left; /* for boot assessment counters */
21 int no_auto;
22 int read_only;
23 int growfs;
24 uint8_t sha256sum[32]; /* SHA256 sum of the download (i.e. compressed) file */
25 bool sha256sum_set;
26 } InstanceMetadata;
27
28 #define INSTANCE_METADATA_NULL \
29 { \
30 .mtime = USEC_INFINITY, \
31 .mode = MODE_INVALID, \
32 .size = UINT64_MAX, \
33 .tries_done = UINT64_MAX, \
34 .tries_left = UINT64_MAX, \
35 .no_auto = -1, \
36 .read_only = -1, \
37 .growfs = -1, \
38 }
39
40 struct Instance {
41 /* A pointer back to the resource this belongs to */
42 Resource *resource;
43
44 /* Metadata of this version */
45 InstanceMetadata metadata;
46
47 /* Where we found the instance */
48 char *path; /* includes the `.sysupdate.partial.` (etc.) prefix, if applicable */
49 PartitionInfo partition_info;
50
51 bool is_partial;
52 bool is_pending;
53 };
54
55 void instance_metadata_destroy(InstanceMetadata *m);
56
57 int instance_new(Resource *rr, const char *path, const InstanceMetadata *f, Instance **ret);
58 Instance *instance_free(Instance *i);
59
60 DEFINE_TRIVIAL_CLEANUP_FUNC(Instance*, instance_free);