]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
gpt-auto: minor simplificatin handling the no-auto GPT flag
authorLennart Poettering <lennart@poettering.net>
Sun, 6 Sep 2015 21:06:05 +0000 (23:06 +0200)
committerLennart Poettering <lennart@poettering.net>
Sun, 6 Sep 2015 22:12:05 +0000 (00:12 +0200)
Let's query the flags only once, and document why we ignore it for the
ESP.

src/gpt-auto-generator/gpt-auto-generator.c

index 2ab7257a24b63c78b1384531e0b37a5450f7ff1c..cf25d9847f02a0386e43a31543b795bfafa1b066 100644 (file)
@@ -666,6 +666,7 @@ static int enumerate_partitions(dev_t devnum) {
         first = udev_enumerate_get_list_entry(e);
         udev_list_entry_foreach(item, first) {
                 _cleanup_udev_device_unref_ struct udev_device *q;
+                unsigned long long flags;
                 const char *stype, *subnode;
                 sd_id128_t type_id;
                 blkid_partition pp;
@@ -705,10 +706,10 @@ static int enumerate_partitions(dev_t devnum) {
                 if (sd_id128_from_string(stype, &type_id) < 0)
                         continue;
 
+                flags = blkid_partition_get_flags(pp);
+
                 if (sd_id128_equal(type_id, GPT_SWAP)) {
-                        unsigned long long flags;
 
-                        flags = blkid_partition_get_flags(pp);
                         if (flags & GPT_FLAG_NO_AUTO)
                                 continue;
 
@@ -727,6 +728,10 @@ static int enumerate_partitions(dev_t devnum) {
                         if (boot && nr >= boot_nr)
                                 continue;
 
+                        /* Note that we do not honour the "no-auto"
+                         * flag for the ESP, as it is often unset, to
+                         * hide it from Windows. */
+
                         boot_nr = nr;
 
                         r = free_and_strdup(&boot, subnode);
@@ -734,9 +739,7 @@ static int enumerate_partitions(dev_t devnum) {
                                 return log_oom();
 
                 } else if (sd_id128_equal(type_id, GPT_HOME)) {
-                        unsigned long long flags;
 
-                        flags = blkid_partition_get_flags(pp);
                         if (flags & GPT_FLAG_NO_AUTO)
                                 continue;
 
@@ -752,9 +755,7 @@ static int enumerate_partitions(dev_t devnum) {
                                 return log_oom();
 
                 } else if (sd_id128_equal(type_id, GPT_SRV)) {
-                        unsigned long long flags;
 
-                        flags = blkid_partition_get_flags(pp);
                         if (flags & GPT_FLAG_NO_AUTO)
                                 continue;