| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
#pragma once |
| 3 |
|
| 4 |
#include "shared-forward.h" |
| 5 |
#include "main-func.h" |
| 6 |
|
| 7 |
int generator_open_unit_file_full(const char *dir, const char *source, const char *filename, FILE **ret_file, char **ret_final_path, char **ret_temp_path); |
| 8 |
static inline int generator_open_unit_file(const char *dir, const char *source, const char *filename, FILE **ret_file) { |
| 9 |
return generator_open_unit_file_full(dir, source, filename, ret_file, NULL, NULL); |
| 10 |
} |
| 11 |
|
| 12 |
int generator_add_symlink_full(const char *dir, const char *dst, const char *dep_type, const char *src, const char *instance); |
| 13 |
static inline int generator_add_symlink(const char *dir, const char *dst, const char *dep_type, const char *src) { |
| 14 |
return generator_add_symlink_full(dir, dst, dep_type, src, NULL); |
| 15 |
} |
| 16 |
|
| 17 |
int generator_write_fsck_deps( |
| 18 |
FILE *f, |
| 19 |
const char *dir, |
| 20 |
const char *what, |
| 21 |
const char *where, |
| 22 |
const char *type, |
| 23 |
const char *options); |
| 24 |
|
| 25 |
int generator_write_device_timeout( |
| 26 |
const char *dir, |
| 27 |
const char *what, |
| 28 |
const char *opts, |
| 29 |
char **filtered); |
| 30 |
|
| 31 |
int generator_write_unit_timeout( |
| 32 |
FILE *f, |
| 33 |
const char *where, |
| 34 |
const char *opts, |
| 35 |
const char *filter, |
| 36 |
const char *unit_setting); |
| 37 |
static inline int generator_write_mount_timeout(FILE *f, const char *where, const char *opts) { |
| 38 |
return generator_write_unit_timeout(f, where, opts, |
| 39 |
"x-systemd.mount-timeout\0", "TimeoutSec"); |
| 40 |
} |
| 41 |
|
| 42 |
int generator_write_blockdev_dependency(FILE *f, const char *what); |
| 43 |
|
| 44 |
int generator_write_network_device_deps( |
| 45 |
const char *dir, |
| 46 |
const char *what, |
| 47 |
const char *where, |
| 48 |
const char *opts); |
| 49 |
|
| 50 |
int generator_write_initrd_root_device_deps(const char *dir, const char *what); |
| 51 |
|
| 52 |
int generator_hook_up_mkswap( |
| 53 |
const char *dir, |
| 54 |
const char *what); |
| 55 |
int generator_hook_up_mkfs( |
| 56 |
const char *dir, |
| 57 |
const char *what, |
| 58 |
const char *where, |
| 59 |
const char *type); |
| 60 |
int generator_hook_up_growfs( |
| 61 |
const char *dir, |
| 62 |
const char *where, |
| 63 |
const char *target); |
| 64 |
int generator_hook_up_pcrfs( |
| 65 |
const char *dir, |
| 66 |
const char *where, |
| 67 |
const char *target); |
| 68 |
int generator_hook_up_validatefs( |
| 69 |
const char *dir, |
| 70 |
const char *where, |
| 71 |
const char *target); |
| 72 |
int generator_hook_up_quotacheck( |
| 73 |
const char *dir, |
| 74 |
const char *what, |
| 75 |
const char *where, |
| 76 |
const char *target, |
| 77 |
const char *fstype); |
| 78 |
int generator_hook_up_quotaon( |
| 79 |
const char *dir, |
| 80 |
const char *where, |
| 81 |
const char *target); |
| 82 |
|
| 83 |
int generator_write_cryptsetup_unit_section(FILE *f, const char *source); |
| 84 |
int generator_write_cryptsetup_service_section( |
| 85 |
FILE *f, |
| 86 |
const char *name, |
| 87 |
const char *what, |
| 88 |
const char *key_file, |
| 89 |
const char *options); |
| 90 |
|
| 91 |
int generator_write_veritysetup_unit_section(FILE *f, const char *source); |
| 92 |
int generator_write_veritysetup_service_section( |
| 93 |
FILE *f, |
| 94 |
const char *name, |
| 95 |
const char *data_what, |
| 96 |
const char *hash_what, |
| 97 |
const char *roothash, |
| 98 |
const char *options); |
| 99 |
|
| 100 |
int generator_enable_remount_fs_service(const char *dir); |
| 101 |
|
| 102 |
void log_setup_generator(void); |
| 103 |
|
| 104 |
bool generator_soft_rebooted(void); |
| 105 |
|
| 106 |
/* Similar to DEFINE_MAIN_FUNCTION, but initializes logging and assigns positional arguments. */ |
| 107 |
#define DEFINE_MAIN_GENERATOR_FUNCTION(impl) \ |
| 108 |
_DEFINE_MAIN_FUNCTION( \ |
| 109 |
({ \ |
| 110 |
log_setup_generator(); \ |
| 111 |
if (!IN_SET(argc, 2, 4)) \ |
| 112 |
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), \ |
| 113 |
"This program takes one or three arguments."); \ |
| 114 |
}), \ |
| 115 |
impl(argv[1], \ |
| 116 |
argv[argc == 4 ? 2 : 1], \ |
| 117 |
argv[argc == 4 ? 3 : 1]), \ |
| 118 |
exit_failure_if_negative) |
| 119 |
|
| 120 |
typedef enum GptAutoRoot { |
| 121 |
GPT_AUTO_ROOT_OFF = 0, /* root= set to something else */ |
| 122 |
GPT_AUTO_ROOT_ON, /* root= set explicitly to "gpt-auto" */ |
| 123 |
GPT_AUTO_ROOT_FORCE, /* root= set explicitly to "gpt-auto-force" → ignores factory reset mode */ |
| 124 |
GPT_AUTO_ROOT_DISSECT, /* root= set to "dissect" */ |
| 125 |
GPT_AUTO_ROOT_DISSECT_FORCE, /* root= set to "dissect-force" → ignores factory reset mode */ |
| 126 |
_GPT_AUTO_ROOT_MAX, |
| 127 |
_GPT_AUTO_ROOT_INVALID = -EINVAL, |
| 128 |
} GptAutoRoot; |
| 129 |
|
| 130 |
GptAutoRoot parse_gpt_auto_root(const char *switch_name, const char *value); |