forked from pengutronix/genimage
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimage-erofs.c
More file actions
81 lines (67 loc) · 2.15 KB
/
image-erofs.c
File metadata and controls
81 lines (67 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
* Copyright (c) 2024 Sebastian Muxel <sebastian.muxel@entner-electronics.com>, Entner Electronics
* (c) 2025 Michael Olbrich <m.olbrich@pengutronix.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <confuse.h>
#include <errno.h>
#include <string.h>
#include "genimage.h"
struct erofs {
const char *label;
};
static int erofs_generate(struct image *image)
{
struct erofs *erofs = image->handler_priv;
char *extraargs = cfg_getstr(image->imagesec, "extraargs");
const char *fs_timestamp = cfg_getstr(image->imagesec, "fs-timestamp");
int ret;
ret = systemp(image, "%s %s%s%s %s%s %s '%s' '%s'",
get_opt("mkfserofs"),
erofs->label ? "-L '" : "",
erofs->label ? erofs->label : "",
erofs->label ? "'" : "",
fs_timestamp ? "-T " : "",
fs_timestamp ? fs_timestamp : "",
extraargs,
imageoutfile(image),
mountpath(image));
return ret;
}
static int erofs_setup(struct image *image, cfg_t *cfg)
{
struct erofs *erofs = xzalloc(sizeof(*erofs));
const char *label = cfg_getstr(image->imagesec, "label");
if (label && label[0] == '\0')
label = NULL;
if (label && strlen(label) > 15) {
image_error(image, "Label '%s' is longer that allowes (15 bytes)\n", label);
return -EINVAL;
}
erofs->label = label;
image->handler_priv = erofs;
return 0;
}
static cfg_opt_t erofs_opts[] = {
CFG_STR("extraargs", "", CFGF_NONE),
CFG_STR("label", NULL, CFGF_NONE),
CFG_STR("fs-timestamp", NULL, CFGF_NONE),
CFG_END()
};
struct image_handler erofs_handler = {
.type = "erofs",
.generate = erofs_generate,
.setup = erofs_setup,
.opts = erofs_opts,
};