| 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 |
|
| 8 |
typedef enum PartitionChange { |
| 9 |
PARTITION_FLAGS = 1 << 0, |
| 10 |
PARTITION_NO_AUTO = 1 << 1, |
| 11 |
PARTITION_READ_ONLY = 1 << 2, |
| 12 |
PARTITION_GROWFS = 1 << 3, |
| 13 |
PARTITION_UUID = 1 << 4, |
| 14 |
PARTITION_LABEL = 1 << 5, |
| 15 |
PARTITION_TYPE = 1 << 6, |
| 16 |
_PARTITION_CHANGE_MAX = (1 << 7) - 1, /* all of the above */ |
| 17 |
_PARTITION_CHANGE_INVALID = -EINVAL, |
| 18 |
} PartitionChange; |
| 19 |
|
| 20 |
typedef struct PartitionInfo { |
| 21 |
size_t partno; |
| 22 |
uint64_t start, size; |
| 23 |
uint64_t flags; |
| 24 |
sd_id128_t type, uuid; |
| 25 |
char *label; |
| 26 |
char *device; /* Note that this might point to some non-existing path in case we operate on a loopback file */ |
| 27 |
bool no_auto; |
| 28 |
bool read_only; |
| 29 |
bool growfs; |
| 30 |
} PartitionInfo; |
| 31 |
|
| 32 |
#define PARTITION_INFO_NULL \ |
| 33 |
{ \ |
| 34 |
.partno = SIZE_MAX, \ |
| 35 |
.start = UINT64_MAX, \ |
| 36 |
.size = UINT64_MAX, \ |
| 37 |
} |
| 38 |
|
| 39 |
void partition_info_destroy(PartitionInfo *p); |
| 40 |
int partition_info_copy(PartitionInfo *dest, const PartitionInfo *src); |
| 41 |
|
| 42 |
int read_partition_info(struct fdisk_context *c, struct fdisk_table *t, size_t i, PartitionInfo *ret); |
| 43 |
|
| 44 |
int gpt_partition_type_uuid_for_sysupdate_partial(sd_id128_t type, sd_id128_t *ret); |
| 45 |
int gpt_partition_type_uuid_for_sysupdate_pending(sd_id128_t type, sd_id128_t *ret); |
| 46 |
|
| 47 |
int find_suitable_partition(const char *device, uint64_t space, sd_id128_t *partition_type, PartitionInfo *ret); |
| 48 |
int patch_partition(const char *device, const PartitionInfo *info, PartitionChange change); |