2020-11-09 05:23:58 +01:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
2014-03-05 22:26:10 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2018-12-04 11:49:42 +01:00
|
|
|
#include "main-func.h"
|
|
|
|
|
2017-12-09 19:23:26 +01:00
|
|
|
int generator_open_unit_file(
|
|
|
|
const char *dest,
|
|
|
|
const char *source,
|
|
|
|
const char *name,
|
|
|
|
FILE **file);
|
|
|
|
|
2018-12-20 12:10:36 +01:00
|
|
|
int generator_add_symlink(const char *dir, const char *dst, const char *dep_type, const char *src);
|
2017-07-10 05:31:47 +02:00
|
|
|
|
2015-05-02 19:01:29 +02:00
|
|
|
int generator_write_fsck_deps(
|
|
|
|
FILE *f,
|
|
|
|
const char *dir,
|
|
|
|
const char *what,
|
|
|
|
const char *where,
|
|
|
|
const char *type);
|
|
|
|
|
|
|
|
int generator_write_timeouts(
|
|
|
|
const char *dir,
|
|
|
|
const char *what,
|
|
|
|
const char *where,
|
|
|
|
const char *opts,
|
|
|
|
char **filtered);
|
2016-05-12 18:42:39 +02:00
|
|
|
|
2019-12-19 17:38:55 +01:00
|
|
|
int generator_write_blockdev_dependency(
|
|
|
|
FILE *f,
|
|
|
|
const char *what);
|
|
|
|
|
|
|
|
int generator_write_cryptsetup_unit_section(
|
|
|
|
FILE *f,
|
|
|
|
const char *source);
|
|
|
|
|
|
|
|
int generator_write_cryptsetup_service_section(
|
|
|
|
FILE *f,
|
|
|
|
const char *name,
|
|
|
|
const char *what,
|
|
|
|
const char *password,
|
|
|
|
const char *options);
|
|
|
|
|
2017-01-24 17:04:32 +01:00
|
|
|
int generator_write_device_deps(
|
2017-11-21 23:18:05 +01:00
|
|
|
const char *dir,
|
|
|
|
const char *what,
|
|
|
|
const char *where,
|
|
|
|
const char *opts);
|
2017-01-24 17:04:32 +01:00
|
|
|
|
2016-05-12 18:42:39 +02:00
|
|
|
int generator_write_initrd_root_device_deps(
|
|
|
|
const char *dir,
|
|
|
|
const char *what);
|
2017-11-21 23:18:05 +01:00
|
|
|
|
|
|
|
int generator_hook_up_mkswap(
|
|
|
|
const char *dir,
|
|
|
|
const char *what);
|
|
|
|
int generator_hook_up_mkfs(
|
|
|
|
const char *dir,
|
|
|
|
const char *what,
|
|
|
|
const char *where,
|
|
|
|
const char *type);
|
2017-11-29 20:02:11 +01:00
|
|
|
int generator_hook_up_growfs(
|
|
|
|
const char *dir,
|
|
|
|
const char *where,
|
|
|
|
const char *target);
|
2018-11-19 21:32:11 +01:00
|
|
|
|
2018-12-20 15:52:52 +01:00
|
|
|
int generator_enable_remount_fs_service(const char *dir);
|
|
|
|
|
2018-11-19 21:32:11 +01:00
|
|
|
void log_setup_generator(void);
|
2018-12-04 11:49:42 +01:00
|
|
|
|
|
|
|
/* Similar to DEFINE_MAIN_FUNCTION, but initializes logging and assigns positional arguments. */
|
|
|
|
#define DEFINE_MAIN_GENERATOR_FUNCTION(impl) \
|
|
|
|
_DEFINE_MAIN_FUNCTION( \
|
|
|
|
({ \
|
|
|
|
log_setup_generator(); \
|
|
|
|
if (argc > 1 && argc != 4) \
|
|
|
|
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), \
|
|
|
|
"This program takes zero or three arguments."); \
|
|
|
|
}), \
|
|
|
|
impl(argc > 1 ? argv[1] : "/tmp", \
|
|
|
|
argc > 1 ? argv[2] : "/tmp", \
|
|
|
|
argc > 1 ? argv[3] : "/tmp"), \
|
|
|
|
r < 0 ? EXIT_FAILURE : EXIT_SUCCESS)
|