diff --git a/man/repart.d.xml b/man/repart.d.xml index 8be41db0ec..87d04d0e93 100644 --- a/man/repart.d.xml +++ b/man/repart.d.xml @@ -837,8 +837,10 @@ partition should be mounted. The second field specifies extra mount options to append to the default mount options. These fields correspond to the second and fourth column of the fstab5 - format. This setting may be specified multiple times to mount the partition multiple times. This can - be used to add mounts for different + format. As a colon is used for separating fields, each field needs to be quoted when it contains + colons. E.g. MountPoint="/path/with:colon":"zstd:1,noatime,lazytime" + This setting may be specified multiple times to mount the partition multiple times. This can be used + to add mounts for different btrfs8 subvolumes located on the same btrfs partition. diff --git a/src/repart/repart.c b/src/repart/repart.c index 961d5d0e33..a1c49b3b02 100644 --- a/src/repart/repart.c +++ b/src/repart/repart.c @@ -7859,7 +7859,7 @@ static int context_fstab(Context *context) { fputs(AUTOMATIC_FSTAB_HEADER_START "\n", f); LIST_FOREACH(partitions, p, context->partitions) { - _cleanup_free_ char *what = NULL, *options = NULL; + _cleanup_free_ char *what = NULL; if (!need_fstab_one(p)) continue; @@ -7869,6 +7869,8 @@ static int context_fstab(Context *context) { return r; FOREACH_ARRAY(mountpoint, p->mountpoints, p->n_mountpoints) { + _cleanup_free_ char *options = NULL; + r = partition_pick_mount_options( p->type.designator, p->format, diff --git a/test/units/TEST-58-REPART.sh b/test/units/TEST-58-REPART.sh index aa472df99a..19f9ca31c9 100755 --- a/test/units/TEST-58-REPART.sh +++ b/test/units/TEST-58-REPART.sh @@ -1375,6 +1375,16 @@ EOF assert_in "${loop}p3 : start= *${start}, size= *${size}, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=DB081670-07AE-48CA-9F5E-813D5E40B976, name=\"linux-generic-2\"" "$output" } +testcase_sector() { + # Valid block sizes on the Linux block layer are >= 512 and <= PAGE_SIZE, and + # must be powers of 2. Which leaves exactly four different ones to test on + # typical hardware + test_sector 512 + test_sector 1024 + test_sector 2048 + test_sector 4096 +} + testcase_dropped_partitions() { local workdir image defs @@ -1618,6 +1628,57 @@ EOF assert_in "${image}2 : start= 286680, size= 532480, type=${esp_guid}" "$output" } +testcase_btrfs() { + local defs imgs output root + + if ! systemd-analyze compare-versions "$(btrfs --version | head -n 1 | awk '{ print $2 }')" ge v6.12; then + echo "btrfs-progs is not installed or older than v6.12, skipping test." + return 0 + fi + + if [[ "$OFFLINE" != "yes" ]]; then + return 0 + fi + + defs="$(mktemp --directory "/tmp/test-repart.defs.XXXXXXXXXX")" + imgs="$(mktemp --directory "/var/tmp/test-repart.imgs.XXXXXXXXXX")" + root="$(mktemp --directory "/var/test-repart.root.XXXXXXXXXX")" + # shellcheck disable=SC2064 + trap "rm -rf '$defs' '$imgs' '$root'" RETURN + chmod 0755 "$defs" + + echo "*** testcase for btrfs ***" + + tee "$defs/root.conf" <= 512 and <= PAGE_SIZE, and -# must be powers of 2. Which leaves exactly four different ones to test on -# typical hardware -test_sector 512 -test_sector 1024 -test_sector 2048 -test_sector 4096 - touch /testok