}
}
+static int check_mkfs(const Context *context) {
+ int r;
+
+ assert(context);
+
+ LIST_FOREACH(partitions, p, context->partitions) {
+ if (p->dropped)
+ continue;
+
+ if (PARTITION_EXISTS(p)) /* Never format existing partitions */
+ continue;
+
+ if (!p->format)
+ continue;
+
+ if (partition_defer(context, p))
+ continue;
+
+ /* For offline signing case */
+ if (!set_isempty(arg_verity_settings) && partition_designator_is_verity_sig(p->type.designator))
+ continue;
+
+ /* Minimized partitions will use the copy blocks logic so skip those here. */
+ if (p->copy_blocks_fd >= 0)
+ continue;
+
+ /* We don't yet quite know if have_root= will be true, so just pass -1 which
+ * means "not sure". */
+ r = mkfs_find_or_warn(p->format, /* have_root= */ -1, /* ret= */ NULL);
+ if (r < 0)
+ return r;
+ }
+
+ return 0;
+}
+
static int context_mkfs(Context *context) {
int r;
return r;
context->from_scratch = r > 0; /* Starting from scratch */
+ r = check_mkfs(context);
+ if (r < 0)
+ return r;
+
if (arg_can_factory_reset) {
r = context_can_factory_reset(context);
if (r < 0)
return true;
}
-static int mkfs_find_or_warn(const char *fstype, bool have_root, char **ret) {
+int mkfs_find_or_warn(const char *fstype, int have_root, char **ret) {
int r;
assert(fstype);
- if (fstype_is_ro(fstype) && !have_root)
+ if (fstype_is_ro(fstype) && have_root == 0)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"Cannot generate read-only filesystem %s without a source tree.", fstype);
const char *bin = NULL;
if (streq(fstype, "swap")) {
- if (have_root)
+ if (have_root > 0)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"A swap filesystem can't be populated, refusing");
bin = "mkswap";
return 0;
}
- if (have_root && !mkfs_supports_root_option(fstype))
+ if (have_root > 0 && !mkfs_supports_root_option(fstype))
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
"Populating with source tree is not supported for %s", fstype);
r = mkfs_exists(fstype);
} MakeFileSystemFlags;
int mkfs_exists(const char *fstype);
+int mkfs_find_or_warn(const char *fstype, int have_root, char **ret);
int mkfs_supports_root_option(const char *fstype);