repart: Add support for reading mkfs options from environment

This commit is contained in:
Daan De Meyer
2023-03-10 09:33:39 +01:00
committed by Lennart Poettering
parent e0e818bb14
commit 4b8ce14f6c
5 changed files with 48 additions and 23 deletions
+21
View File
@@ -520,3 +520,24 @@ int make_filesystem(
return 0;
}
int mkfs_options_from_env(const char *component, const char *fstype, char ***ret) {
_cleanup_(strv_freep) char **l = NULL;
const char *e;
char *n;
assert(component);
assert(fstype);
assert(ret);
n = strjoina("SYSTEMD_", component, "_MKFS_OPTIONS_", fstype);
e = getenv(ascii_strupper(n));
if (e) {
l = strv_split(e, NULL);
if (!l)
return -ENOMEM;
}
*ret = TAKE_PTR(l);
return 0;
}
+2
View File
@@ -20,3 +20,5 @@ int make_filesystem(
bool discard,
uint64_t sector_size,
char * const *extra_mkfs_args);
int mkfs_options_from_env(const char *component, const char *fstype, char ***ret);