]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/shared/generator.h
Merge pull request #11152 from keszybz/meson-user-unit-symlinks
[thirdparty/systemd.git] / src / shared / generator.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 #include <stdio.h>
5
6 #include "main-func.h"
7
8 int generator_open_unit_file(
9 const char *dest,
10 const char *source,
11 const char *name,
12 FILE **file);
13
14 int generator_add_symlink(const char *root, const char *dst, const char *dep_type, const char *src);
15
16 int generator_write_fsck_deps(
17 FILE *f,
18 const char *dir,
19 const char *what,
20 const char *where,
21 const char *type);
22
23 int generator_write_timeouts(
24 const char *dir,
25 const char *what,
26 const char *where,
27 const char *opts,
28 char **filtered);
29
30 int generator_write_device_deps(
31 const char *dir,
32 const char *what,
33 const char *where,
34 const char *opts);
35
36 int generator_write_initrd_root_device_deps(
37 const char *dir,
38 const char *what);
39
40 int generator_hook_up_mkswap(
41 const char *dir,
42 const char *what);
43 int generator_hook_up_mkfs(
44 const char *dir,
45 const char *what,
46 const char *where,
47 const char *type);
48 int generator_hook_up_growfs(
49 const char *dir,
50 const char *where,
51 const char *target);
52
53 void log_setup_generator(void);
54
55 /* Similar to DEFINE_MAIN_FUNCTION, but initializes logging and assigns positional arguments. */
56 #define DEFINE_MAIN_GENERATOR_FUNCTION(impl) \
57 _DEFINE_MAIN_FUNCTION( \
58 ({ \
59 log_setup_generator(); \
60 if (argc > 1 && argc != 4) \
61 return log_error_errno(SYNTHETIC_ERRNO(EINVAL), \
62 "This program takes zero or three arguments."); \
63 }), \
64 impl(argc > 1 ? argv[1] : "/tmp", \
65 argc > 1 ? argv[2] : "/tmp", \
66 argc > 1 ? argv[3] : "/tmp"), \
67 r < 0 ? EXIT_FAILURE : EXIT_SUCCESS)