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