repart: add support for Format=empty

This is a new meta value for the `Format=` option, which is equivalent
as specifying `Label=_empty` and `NoAuto=1` for compatibility with
sd-sysupdate.

Closes: https://github.com/systemd/systemd/issues/34596
This commit is contained in:
Michael Ferrari
2025-06-30 10:11:16 +02:00
committed by Lennart Poettering
parent 878c2b28df
commit 381304a209
2 changed files with 16 additions and 0 deletions
+3
View File
@@ -417,6 +417,9 @@
required for the minimal file system of the specified type (or 4KiB if the minimal size is not required for the minimal file system of the specified type (or 4KiB if the minimal size is not
known).</para> known).</para>
<para>This also takes a special meta value <literal>empty</literal>. If specified this is equivalent
to specifying <literal>Label=_empty</literal> and <literal>NoAuto=1</literal>.</para>
<para>This option has no effect if the partition already exists.</para> <para>This option has no effect if the partition already exists.</para>
<para>Similarly to the behaviour of <varname>CopyBlocks=</varname>, the file system is formatted <para>Similarly to the behaviour of <varname>CopyBlocks=</varname>, the file system is formatted
+13
View File
@@ -2633,6 +2633,19 @@ static int partition_read_definition(Partition *p, const char *path, const char
} }
} }
if (streq_ptr(p->format, "empty")) {
p->format = mfree(p->format);
if (p->no_auto < 0)
p->no_auto = true;
if (!p->new_label) {
p->new_label = strdup("_empty");
if (!p->new_label)
return log_oom();
}
}
if (p->minimize != MINIMIZE_OFF && !p->format && p->verity != VERITY_HASH) if (p->minimize != MINIMIZE_OFF && !p->format && p->verity != VERITY_HASH)
return log_syntax(NULL, LOG_ERR, path, 1, SYNTHETIC_ERRNO(EINVAL), return log_syntax(NULL, LOG_ERR, path, 1, SYNTHETIC_ERRNO(EINVAL),
"Minimize= can only be enabled if Format= or Verity=hash are set."); "Minimize= can only be enabled if Format= or Verity=hash are set.");