]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
gpt-auto-generator: hook in "growfs" for the root fs if the GPT flag 59 says so 30030/head
authorLennart Poettering <lennart@poettering.net>
Wed, 15 Nov 2023 10:14:39 +0000 (11:14 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 15 Nov 2023 12:21:15 +0000 (13:21 +0100)
Fixes: #29791
src/gpt-auto-generator/gpt-auto-generator.c

index b2c78ef4c2b6724c56f88d34ae65f756aeb2e91f..a0c5a733cb1cd261a46fa634a05edf839de9b678 100644 (file)
@@ -665,6 +665,33 @@ static int add_partition_root_rw(DissectedPartition *p) {
         return 0;
 }
 
+static int add_partition_root_growfs(DissectedPartition *p) {
+
+        assert(p);
+        assert(!in_initrd());
+
+        /* Invoked on the main system (not initrd), to honour GPT flag 59 on the root fs (growfs) */
+
+        if (!p->growfs) {
+                log_debug("Root partition not marked for growing the file system in the GPT partition table, not generating drop-in for systemd-growfs-root.service.");
+                return 0;
+        }
+
+        return generator_hook_up_growfs(arg_dest, "/", SPECIAL_LOCAL_FS_TARGET);
+}
+
+static int add_partition_root_flags(DissectedPartition *p) {
+        int r = 0;
+
+        assert(p);
+        assert(!in_initrd());
+
+        RET_GATHER(r, add_partition_root_growfs(p));
+        RET_GATHER(r, add_partition_root_rw(p));
+
+        return r;
+}
+
 #if ENABLE_EFI
 static int add_root_cryptsetup(void) {
 #if HAVE_LIBCRYPTSETUP
@@ -710,8 +737,9 @@ static int add_root_mount(void) {
                         return r;
         }
 
-        /* Note that we do not need to enable systemd-remount-fs.service here. If
-         * /etc/fstab exists, systemd-fstab-generator will pull it in for us. */
+        /* Note that we do not need to enable systemd-remount-fs.service here. If /etc/fstab exists,
+         * systemd-fstab-generator will pull it in for us, and otherwise add_partition_root_flags() will do
+         * it, after the initrd transition. */
 
         r = partition_pick_mount_options(
                         PARTITION_ROOT,
@@ -860,7 +888,7 @@ static int enumerate_partitions(dev_t devnum) {
                                                   "var-tmp", "/var/tmp", "Temporary Data Partition"));
 
         if (m->partitions[PARTITION_ROOT].found)
-                RET_GATHER(r, add_partition_root_rw(m->partitions + PARTITION_ROOT));
+                RET_GATHER(r, add_partition_root_flags(m->partitions + PARTITION_ROOT));
 
         return r;
 }