summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaan De Meyer <daan.j.demeyer@gmail.com>2023-08-15 10:31:47 +0200
committerDaan De Meyer <daan.j.demeyer@gmail.com>2023-08-15 12:32:36 +0200
commitffd9d75cde509e617f5867c64c74f9ac23279603 (patch)
treedaa49946cd82f26d36e80d94f42c1ddb236d6e64
parentMerge pull request #28812 from DaanDeMeyer/sector-size (diff)
downloadsystemd-ffd9d75cde509e617f5867c64c74f9ac23279603.tar.xz
systemd-ffd9d75cde509e617f5867c64c74f9ac23279603.zip
repart: Allow using Subvolumes= with automatic --offline
If we fail to allocate a loopback device and subvolumes are configured, we fail instead of falling back to a regular file.
-rw-r--r--src/partition/repart.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/partition/repart.c b/src/partition/repart.c
index 7621d32a53..09b84e5080 100644
--- a/src/partition/repart.c
+++ b/src/partition/repart.c
@@ -1756,9 +1756,9 @@ static int partition_read_definition(Partition *p, const char *path, const char
"SizeMinBytes=/SizeMaxBytes= cannot be used with Verity=%s",
verity_mode_to_string(p->verity));
- if (!strv_isempty(p->subvolumes) && arg_offline != 0)
+ if (!strv_isempty(p->subvolumes) && arg_offline > 0)
return log_syntax(NULL, LOG_ERR, path, 1, SYNTHETIC_ERRNO(EOPNOTSUPP),
- "Subvolumes= can only be used with --offline=no");
+ "Subvolumes= cannot be used with --offline=yes");
/* Verity partitions are read only, let's imply the RO flag hence, unless explicitly configured otherwise. */
if ((IN_SET(p->type.designator,
@@ -3494,7 +3494,7 @@ static int partition_target_prepare(
if (arg_offline <= 0) {
r = loop_device_make(whole_fd, O_RDWR, p->offset, size, context->sector_size, 0, LOCK_EX, &d);
- if (r < 0 && (arg_offline == 0 || (r != -ENOENT && !ERRNO_IS_PRIVILEGE(r))))
+ if (r < 0 && (arg_offline == 0 || (r != -ENOENT && !ERRNO_IS_PRIVILEGE(r)) || !strv_isempty(p->subvolumes)))
return log_error_errno(r, "Failed to make loopback device of future partition %" PRIu64 ": %m", p->partno);
if (r >= 0) {
t->loop = TAKE_PTR(d);
@@ -6022,7 +6022,7 @@ static int context_minimize(Context *context) {
if (arg_offline <= 0) {
r = loop_device_make(fd, O_RDWR, 0, UINT64_MAX, context->sector_size, 0, LOCK_EX, &d);
- if (r < 0 && (arg_offline == 0 || (r != -ENOENT && !ERRNO_IS_PRIVILEGE(r))))
+ if (r < 0 && (arg_offline == 0 || (r != -ENOENT && !ERRNO_IS_PRIVILEGE(r)) || !strv_isempty(p->subvolumes)))
return log_error_errno(r, "Failed to make loopback device of %s: %m", temp);
}
@@ -6125,7 +6125,7 @@ static int context_minimize(Context *context) {
if (arg_offline <= 0) {
r = loop_device_make(fd, O_RDWR, 0, UINT64_MAX, context->sector_size, 0, LOCK_EX, &d);
- if (r < 0 && (arg_offline == 0 || (r != -ENOENT && !ERRNO_IS_PRIVILEGE(r))))
+ if (r < 0 && (arg_offline == 0 || (r != -ENOENT && !ERRNO_IS_PRIVILEGE(r)) || !strv_isempty(p->subvolumes)))
return log_error_errno(r, "Failed to make loopback device of %s: %m", temp);
}