summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--man/repart.d.xml10
-rw-r--r--src/nspawn/nspawn-settings.c29
-rw-r--r--src/nspawn/nspawn-settings.h1
-rw-r--r--src/partition/repart.c15
-rw-r--r--src/shared/conf-parser.c30
-rw-r--r--src/shared/conf-parser.h1
6 files changed, 49 insertions, 37 deletions
diff --git a/man/repart.d.xml b/man/repart.d.xml
index 4993608670..f2c155e200 100644
--- a/man/repart.d.xml
+++ b/man/repart.d.xml
@@ -218,6 +218,16 @@
</varlistentry>
<varlistentry>
+ <term><varname>UUID=</varname></term>
+
+ <listitem><para>The UUID to assign to the partition if none is assigned yet. Note that this
+ setting is not used for matching. It is also not used when a UUID is already set for an existing
+ partition. It is thus only used when a partition is newly created or when an existing one had a
+ all-zero UUID set. If not specified a UUID derived from the partition type is automatically
+ used.</para></listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><varname>Priority=</varname></term>
<listitem><para>A numeric priority to assign to this partition, in the range -2147483648…2147483647,
diff --git a/src/nspawn/nspawn-settings.c b/src/nspawn/nspawn-settings.c
index 4b1115b6e8..4e1cb3835c 100644
--- a/src/nspawn/nspawn-settings.c
+++ b/src/nspawn/nspawn-settings.c
@@ -295,35 +295,6 @@ int config_parse_capability(
return 0;
}
-int config_parse_id128(
- const char *unit,
- const char *filename,
- unsigned line,
- const char *section,
- unsigned section_line,
- const char *lvalue,
- int ltype,
- const char *rvalue,
- void *data,
- void *userdata) {
-
- sd_id128_t t, *result = data;
- int r;
-
- assert(filename);
- assert(lvalue);
- assert(rvalue);
-
- r = sd_id128_from_string(rvalue, &t);
- if (r < 0) {
- log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse 128bit ID/UUID, ignoring: %s", rvalue);
- return 0;
- }
-
- *result = t;
- return 0;
-}
-
int config_parse_pivot_root(
const char *unit,
const char *filename,
diff --git a/src/nspawn/nspawn-settings.h b/src/nspawn/nspawn-settings.h
index 6f2c1141e6..24f98fd7ef 100644
--- a/src/nspawn/nspawn-settings.h
+++ b/src/nspawn/nspawn-settings.h
@@ -234,7 +234,6 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(Settings*, settings_free);
const struct ConfigPerfItem* nspawn_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
CONFIG_PARSER_PROTOTYPE(config_parse_capability);
-CONFIG_PARSER_PROTOTYPE(config_parse_id128);
CONFIG_PARSER_PROTOTYPE(config_parse_expose_port);
CONFIG_PARSER_PROTOTYPE(config_parse_volatile_mode);
CONFIG_PARSER_PROTOTYPE(config_parse_pivot_root);
diff --git a/src/partition/repart.c b/src/partition/repart.c
index 46e82eaf90..16cb5e45c4 100644
--- a/src/partition/repart.c
+++ b/src/partition/repart.c
@@ -963,6 +963,7 @@ static int partition_read_definition(Partition *p, const char *path) {
ConfigTableItem table[] = {
{ "Partition", "Type", config_parse_type, 0, &p->type_uuid },
{ "Partition", "Label", config_parse_label, 0, &p->new_label },
+ { "Partition", "UUID", config_parse_id128, 0, &p->new_uuid },
{ "Partition", "Priority", config_parse_int32, 0, &p->priority },
{ "Partition", "Weight", config_parse_weight, 0, &p->weight },
{ "Partition", "PaddingWeight", config_parse_weight, 0, &p->padding_weight },
@@ -2232,13 +2233,12 @@ static int context_acquire_partition_uuids_and_labels(Context *context) {
assert(context);
LIST_FOREACH(partitions, p, context->partitions) {
- assert(sd_id128_is_null(p->new_uuid));
-
/* Never touch foreign partitions */
if (PARTITION_IS_FOREIGN(p)) {
p->new_uuid = p->current_uuid;
if (p->current_label) {
+ free(p->new_label);
p->new_label = strdup(p->current_label);
if (!p->new_label)
return log_oom();
@@ -2249,20 +2249,21 @@ static int context_acquire_partition_uuids_and_labels(Context *context) {
if (!sd_id128_is_null(p->current_uuid))
p->new_uuid = p->current_uuid; /* Never change initialized UUIDs */
- else {
+ else if (sd_id128_is_null(p->new_uuid)) {
+ /* Not explicitly set by user! */
r = partition_acquire_uuid(context, p, &p->new_uuid);
if (r < 0)
return r;
}
- if (p->new_label) /* Explicitly set by user? */
- continue;
-
if (!isempty(p->current_label)) {
+ free(p->new_label);
p->new_label = strdup(p->current_label); /* never change initialized labels */
if (!p->new_label)
return log_oom();
- } else {
+ } else if (!p->new_label) {
+ /* Not explicitly set by user! */
+
r = partition_acquire_label(context, p, &p->new_label);
if (r < 0)
return r;
diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c
index 23cb3b65b6..e685ecbff7 100644
--- a/src/shared/conf-parser.c
+++ b/src/shared/conf-parser.c
@@ -23,6 +23,7 @@
#include "path-util.h"
#include "process-util.h"
#include "rlimit-util.h"
+#include "sd-id128.h"
#include "signal-util.h"
#include "socket-util.h"
#include "string-util.h"
@@ -648,6 +649,35 @@ int config_parse_bool(const char* unit,
return 0;
}
+int config_parse_id128(
+ const char *unit,
+ const char *filename,
+ unsigned line,
+ const char *section,
+ unsigned section_line,
+ const char *lvalue,
+ int ltype,
+ const char *rvalue,
+ void *data,
+ void *userdata) {
+
+ sd_id128_t t, *result = data;
+ int r;
+
+ assert(filename);
+ assert(lvalue);
+ assert(rvalue);
+
+ r = sd_id128_from_string(rvalue, &t);
+ if (r < 0)
+ log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse 128bit ID/UUID, ignoring: %s", rvalue);
+ else if (sd_id128_is_null(t))
+ log_syntax(unit, LOG_ERR, filename, line, 0, "128bit ID/UUID is all 0, ignoring: %s", rvalue);
+
+ *result = t;
+ return 0;
+}
+
int config_parse_tristate(
const char* unit,
const char *filename,
diff --git a/src/shared/conf-parser.h b/src/shared/conf-parser.h
index 59e74590ca..82c692af10 100644
--- a/src/shared/conf-parser.h
+++ b/src/shared/conf-parser.h
@@ -122,6 +122,7 @@ CONFIG_PARSER_PROTOTYPE(config_parse_iec_size);
CONFIG_PARSER_PROTOTYPE(config_parse_si_uint64);
CONFIG_PARSER_PROTOTYPE(config_parse_iec_uint64);
CONFIG_PARSER_PROTOTYPE(config_parse_bool);
+CONFIG_PARSER_PROTOTYPE(config_parse_id128);
CONFIG_PARSER_PROTOTYPE(config_parse_tristate);
CONFIG_PARSER_PROTOTYPE(config_parse_string);
CONFIG_PARSER_PROTOTYPE(config_parse_path);