]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
repart: mkfs.btrfs --subvol option format change
authorNick Labich <nick@labich.org>
Wed, 9 Apr 2025 19:32:11 +0000 (19:32 +0000)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 10 Apr 2025 09:20:59 +0000 (18:20 +0900)
Adapt repart mkfs.btrfs invocation to match the latest format:
(btrfs-progs@8ba72e45c8a6da1275b448ad4912d96e0a2c54b5)

Fixes #37074

src/repart/repart.c

index a1236943cad79c2ba251a5e62c974b8198b89056..f9aa9ac43ca7c8e5c822c0aa513006fda11eded4 100644 (file)
@@ -312,19 +312,6 @@ static SubvolumeFlags subvolume_flags_from_string(const char *s) {
         return flags;
 }
 
-static char* subvolume_flags_to_string(SubvolumeFlags flags) {
-        const char *l[CONST_LOG2U(_SUBVOLUME_FLAGS_MASK + 1) + 1]; /* one string per known flag at most */
-        size_t m = 0;
-
-        if (FLAGS_SET(flags, SUBVOLUME_RO))
-                l[m++] = "ro";
-
-        assert(m < ELEMENTSOF(l));
-        l[m] = NULL;
-
-        return strv_join((char**) l, ",");
-}
-
 typedef struct Subvolume {
         char *path;
         SubvolumeFlags flags;
@@ -6041,21 +6028,15 @@ static int append_btrfs_subvols(char ***l, OrderedHashmap *subvolumes, const cha
         assert(l);
 
         ORDERED_HASHMAP_FOREACH(subvolume, subvolumes) {
-                _cleanup_free_ char *s = NULL, *f = NULL;
-
-                s = strdup(subvolume->path);
-                if (!s)
-                        return log_oom();
+                _cleanup_free_ char *s = NULL;
 
-                f = subvolume_flags_to_string(subvolume->flags);
-                if (!f)
+                if (streq_ptr(subvolume->path, default_subvolume) && !strextend(&s, "default"))
                         return log_oom();
 
-                if (streq_ptr(subvolume->path, default_subvolume) &&
-                    !strextend_with_separator(&f, ",", "default"))
+                if (FLAGS_SET(subvolume->flags, SUBVOLUME_RO) && !strextend_with_separator(&s, "-", "ro"))
                         return log_oom();
 
-                if (!isempty(f) && !strextend_with_separator(&s, ":", f))
+                if (!strextend_with_separator(&s, ":", subvolume->path))
                         return log_oom();
 
                 r = strv_extend_many(l, "--subvol", s);