]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* Makefile.util.def: Add partmap/msdos.c to common library.
authorAndrey Borzenkov <arvidjaar@gmail.com>
Mon, 25 Feb 2013 21:11:06 +0000 (22:11 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Mon, 25 Feb 2013 21:11:06 +0000 (22:11 +0100)
* include/grub/msdos_partition.h: Add GRUB_PC_PARTITION_TYPE_LDM
* grub-core/disk/ldm.c: Check for existence of
GRUB_PC_PARTITION_TYPE_LDM.

ChangeLog
Makefile.util.def
grub-core/disk/ldm.c
include/grub/msdos_partition.h

index ff5a5580159a6f2c1917a041c1c848e9c1140333..107c049cea5bd195ce0e5fe5345901aab4a2824e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2013-02-25  Andrey Borzenkov <arvidjaar@gmail.com>
+
+       * Makefile.util.def: Add partmap/msdos.c to common library.
+       * include/grub/msdos_partition.h: Add GRUB_PC_PARTITION_TYPE_LDM
+       * grub-core/disk/ldm.c: Check for existence of
+       GRUB_PC_PARTITION_TYPE_LDM.
+
 2013-02-25  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * grub-core/normal/misc.c (grub_normal_print_device_info): Use KiB to display
index 3ee5e4ebb0590086b06f6503e50cc80e6dc1f6fb..1ccf39049878ddd8a5d661cc58397e5e275cd7e9 100644 (file)
@@ -32,6 +32,7 @@ library = {
   common = grub-core/disk/ldm.c;
   common = grub-core/disk/diskfilter.c;
   common = grub-core/partmap/gpt.c;
+  common = grub-core/partmap/msdos.c;
 };
 
 library = {
@@ -110,7 +111,6 @@ library = {
   common = grub-core/partmap/acorn.c;
   common = grub-core/partmap/amiga.c;
   common = grub-core/partmap/apple.c;
-  common = grub-core/partmap/msdos.c;
   common = grub-core/partmap/sun.c;
   common = grub-core/partmap/plan.c;
   common = grub-core/partmap/dvh.c;
index b92433d425b37d9453a90570c5870145f3b8cd89..a2e26b26268cbf1e6885f6c2a715734719dc67b1 100644 (file)
@@ -22,6 +22,7 @@
 #include <grub/err.h>
 #include <grub/misc.h>
 #include <grub/diskfilter.h>
+#include <grub/msdos_partition.h>
 #include <grub/gpt_partition.h>
 #include <grub/i18n.h>
 
@@ -103,6 +104,37 @@ read_int (grub_uint8_t *in, grub_size_t s)
   return ret;
 }
 
+static int
+check_ldm_partition (grub_disk_t disk __attribute__ ((unused)), const grub_partition_t p, void *data)
+{
+  int *has_ldm = data;
+
+  if (p->number >= 4)
+    return 1;
+  if (p->msdostype == GRUB_PC_PARTITION_TYPE_LDM)
+    {
+      *has_ldm = 1;
+      return 1;
+    }
+  return 0;
+}
+
+static int
+msdos_has_ldm_partition (grub_disk_t dsk)
+{
+  grub_err_t err;
+  int has_ldm = 0;
+
+  err = grub_partition_msdos_iterate (dsk, check_ldm_partition, &has_ldm);
+  if (err)
+    {
+      grub_errno = GRUB_ERR_NONE;
+      return 0;
+    }
+
+  return has_ldm;
+}
+
 static const grub_gpt_part_type_t ldm_type = GRUB_GPT_PARTITION_TYPE_LDM;
 
 /* Helper for gpt_ldm_sector.  */
@@ -760,17 +792,20 @@ grub_ldm_detect (grub_disk_t disk,
 
   {
     int i;
+    int has_ldm = msdos_has_ldm_partition (disk);
     for (i = 0; i < 3; i++)
       {
        grub_disk_addr_t sector = LDM_LABEL_SECTOR;
        switch (i)
          {
          case 0:
+           if (!has_ldm)
+             continue;
            sector = LDM_LABEL_SECTOR;
            break;
          case 1:
            /* LDM is never inside a partition.  */
-           if (disk->partition)
+           if (!has_ldm || disk->partition)
              continue;
            sector = grub_disk_get_size (disk);
            if (sector == GRUB_DISK_SIZE_UNKNOWN)
@@ -871,6 +906,7 @@ int
 grub_util_is_ldm (grub_disk_t disk)
 {
   int i;
+  int has_ldm = msdos_has_ldm_partition (disk);
   for (i = 0; i < 3; i++)
     {
       grub_disk_addr_t sector = LDM_LABEL_SECTOR;
@@ -880,11 +916,13 @@ grub_util_is_ldm (grub_disk_t disk)
       switch (i)
        {
        case 0:
+         if (!has_ldm)
+           continue;
          sector = LDM_LABEL_SECTOR;
          break;
        case 1:
          /* LDM is never inside a partition.  */
-         if (disk->partition)
+         if (!has_ldm || disk->partition)
            continue;
          sector = grub_disk_get_size (disk);
          if (sector == GRUB_DISK_SIZE_UNKNOWN)
index 1e9b65eee39ce67bfab722430227051e5a3b0c62..92f8539828ed197237db3a1163eafd068c5c947f 100644 (file)
@@ -43,6 +43,7 @@
 #define GRUB_PC_PARTITION_TYPE_FAT16_LBA       0xe
 #define GRUB_PC_PARTITION_TYPE_WIN95_EXTENDED  0xf
 #define GRUB_PC_PARTITION_TYPE_PLAN9            0x39
+#define GRUB_PC_PARTITION_TYPE_LDM             0x42
 #define GRUB_PC_PARTITION_TYPE_EZD             0x55
 #define GRUB_PC_PARTITION_TYPE_MINIX           0x80
 #define GRUB_PC_PARTITION_TYPE_LINUX_MINIX     0x81