]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* include/grub/disk.h (grub_disk): Remove has_partitions.
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Mon, 13 Sep 2010 21:59:22 +0000 (23:59 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Mon, 13 Sep 2010 21:59:22 +0000 (23:59 +0200)
All users updated.
* disk/loopback.c (grub_loopback): Remove has_partitions.
All users updated.
(options): Remove partitions. All users updated.
* util/grub-fstest.c (fstest): Don't pass "-p" to loopback.
* util/i386/pc/grub-setup.c (setup): copy partition table only when
actual partition table is found.

21 files changed:
ChangeLog
grub-core/disk/ata.c
grub-core/disk/efi/efidisk.c
grub-core/disk/host.c
grub-core/disk/i386/pc/biosdisk.c
grub-core/disk/ieee1275/nand.c
grub-core/disk/ieee1275/ofdisk.c
grub-core/disk/loopback.c
grub-core/disk/lvm.c
grub-core/disk/memdisk.c
grub-core/disk/raid.c
grub-core/disk/scsi.c
grub-core/fs/i386/pc/pxe.c
grub-core/kern/device.c
grub-core/kern/disk.c
grub-core/kern/emu/hostdisk.c
grub-core/normal/completion.c
grub-core/normal/misc.c
include/grub/disk.h
util/grub-fstest.c
util/i386/pc/grub-setup.c

index 10ba630290f7a9ad79a14d0d391cf3ec90c601f5..6e29c939e290fee73094360012bafbbb5eb73d58 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2010-09-13  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * include/grub/disk.h (grub_disk): Remove has_partitions.
+       All users updated.
+       * disk/loopback.c (grub_loopback): Remove has_partitions.
+       All users updated.
+       (options): Remove partitions. All users updated.
+       * util/grub-fstest.c (fstest): Don't pass "-p" to loopback.
+       * util/i386/pc/grub-setup.c (setup): copy partition table only when
+       actual partition table is found.
+
 2010-09-13  Vladimir Serbinenko  <phcoder@gmail.com>
 
        Remove readability checks (too many false negatives).
index cfd58a6d5f6906e7a1761d29a259c1786110715a..fe677e2a02412cab69f18e565ab122078bbd6baa 100644 (file)
@@ -723,7 +723,6 @@ grub_ata_open (const char *name, grub_disk_t disk)
 
   disk->id = (unsigned long) dev;
 
-  disk->has_partitions = 1;
   disk->data = dev;
 
   return 0;
index f9c6f3153d0012108f5b738b1696af13fe6e82f5..7aec1efe8699f80df6843438996945194d5cd316 100644 (file)
@@ -514,16 +514,12 @@ grub_efidisk_open (const char *name, struct grub_disk *disk)
   switch (name[0])
     {
     case 'f':
-      disk->has_partitions = 0;
       d = get_device (fd_devices, num);
       break;
     case 'c':
-      /* FIXME: a CDROM should have partitions, but not implemented yet.  */
-      disk->has_partitions = 0;
       d = get_device (cd_devices, num);
       break;
     case 'h':
-      disk->has_partitions = 1;
       d = get_device (hd_devices, num);
       break;
     default:
index c4f3e715063974807eeb0b1449558ef6ba533f0a..c5196629336e13d89bf0a909f114618b008f5d00 100644 (file)
@@ -43,7 +43,6 @@ grub_host_open (const char *name, grub_disk_t disk)
   disk->total_sectors = 0;
   disk->id = (unsigned long) "host";
 
-  disk->has_partitions = 0;
   disk->data = 0;
 
   return GRUB_ERR_NONE;
index 9c02096936b32e52880e706a041ad346bd319e61..f6962645571dac6d5ae6eb7d8ee94203567399d9 100644 (file)
@@ -327,7 +327,6 @@ grub_biosdisk_open (const char *name, grub_disk_t disk)
   if (drive < 0)
     return grub_errno;
 
-  disk->has_partitions = 1;
   disk->id = drive;
 
   data = (struct grub_biosdisk_data *) grub_zalloc (sizeof (*data));
index df2ee81f39ebe7feb86757903826d7eef33eee52..a2c717cdb5603bf02cae2adafe76c7eff57f73ce 100644 (file)
@@ -113,7 +113,6 @@ grub_nand_open (const char *name, grub_disk_t disk)
 
   disk->id = dev_ihandle;
 
-  disk->has_partitions = 0;
   disk->data = data;
 
   return 0;
index 3d9976257209aace5e929a0e7b514289f48aa80d..85c34609e8afa331ad46b5544b7b778e89d53521 100644 (file)
@@ -256,8 +256,6 @@ grub_ofdisk_open (const char *name, grub_disk_t disk)
     disk->data = op->devpath;
   }
 
-  /* XXX: Read this, somehow.  */
-  disk->has_partitions = 1;
   return 0;
 }
 
index 878369e5f1a7a1376cbcbb15bbe3de2c858bf3e5..c8ee52580a0b847b436922b2dd35bd95715ef272 100644 (file)
@@ -29,7 +29,6 @@ struct grub_loopback
 {
   char *devname;
   grub_file_t file;
-  int has_partitions;
   struct grub_loopback *next;
 };
 
@@ -38,7 +37,6 @@ static struct grub_loopback *loopback_list;
 static const struct grub_arg_option options[] =
   {
     {"delete", 'd', 0, N_("Delete the loopback device entry."), 0, 0},
-    {"partitions", 'p', 0, N_("Simulate a hard drive with partitions."), 0, 0},
     {0, 0, 0, 0, 0, 0}
   };
 
@@ -106,9 +104,6 @@ grub_cmd_loopback (grub_extcmd_context_t ctxt, int argc, char **args)
       grub_file_close (newdev->file);
       newdev->file = file;
 
-      /* Set has_partitions when `--partitions' was used.  */
-      newdev->has_partitions = state[1].set;
-
       return 0;
     }
 
@@ -126,9 +121,6 @@ grub_cmd_loopback (grub_extcmd_context_t ctxt, int argc, char **args)
 
   newdev->file = file;
 
-  /* Set has_partitions when `--partitions' was used.  */
-  newdev->has_partitions = state[1].set;
-
   /* Add the new entry to the list.  */
   newdev->next = loopback_list;
   loopback_list = newdev;
@@ -174,7 +166,6 @@ grub_loopback_open (const char *name, grub_disk_t disk)
     disk->total_sectors = GRUB_DISK_SIZE_UNKNOWN;
   disk->id = (unsigned long) dev;
 
-  disk->has_partitions = dev->has_partitions;
   disk->data = dev->file;
 
   return 0;
index 3981d98117211e1ad8d48c905b6013609caea321..94cf9a1aa33c1256337848828d6189343da7514c 100644 (file)
@@ -150,7 +150,6 @@ grub_lvm_open (const char *name, grub_disk_t disk)
   if (! lv)
     return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "unknown LVM device %s", name);
 
-  disk->has_partitions = 0;
   disk->id = lv->number;
   disk->data = lv;
   disk->total_sectors = lv->size;
@@ -280,7 +279,11 @@ grub_lvm_scan_device (const char *name)
 
   disk = grub_disk_open (name);
   if (!disk)
-    return 0;
+    {
+      if (grub_errno == GRUB_ERR_OUT_OF_RANGE)
+       grub_errno = GRUB_ERR_NONE;
+      return 0;
+    }
 
   /* Search for label. */
   for (i = 0; i < GRUB_LVM_LABEL_SCAN_SECTORS; i++)
@@ -725,6 +728,8 @@ grub_lvm_scan_device (const char *name)
   grub_free (metadatabuf);
  fail:
   grub_disk_close (disk);
+  if (grub_errno == GRUB_ERR_OUT_OF_RANGE)
+    grub_errno = GRUB_ERR_NONE;
   return 0;
 }
 
index 2e8885020be9c901c0c3e25aae77acd5cc7aa095..e00280dd7bfd92cffcc6ae566ae73ee40fe0099c 100644 (file)
@@ -41,7 +41,6 @@ grub_memdisk_open (const char *name, grub_disk_t disk)
 
   disk->total_sectors = memdisk_size / GRUB_DISK_SECTOR_SIZE;
   disk->id = (unsigned long) "mdsk";
-  disk->has_partitions = 0;
 
   return GRUB_ERR_NONE;
 }
index 51a4b00e218b8df8dfb84b759e22b39499f139fc..2fd6aa9dec3bcf379f65cf5abff9003a11d4d122 100644 (file)
@@ -126,7 +126,6 @@ grub_raid_open (const char *name, grub_disk_t disk)
     return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "unknown RAID device %s",
                        name);
 
-  disk->has_partitions = 1;
   disk->id = array->number;
   disk->data = array;
 
index 60192bef5b6b7a0f5c047298a386d394fb7c40e4..902ab12c39364daf52cd5069768ce2b41da296f7 100644 (file)
@@ -431,12 +431,6 @@ grub_scsi_open (const char *name, grub_disk_t disk)
                             "unknown SCSI device");
        }
 
-      if (scsi->devtype == grub_scsi_devtype_cdrom)
-       disk->has_partitions = 0;
-      else
-       disk->has_partitions = 1;
-
-
       /* According to USB MS tests specification, issue Test Unit Ready
        * until OK */
       maxtime = grub_get_time_ms () + 5000; /* It is safer value */
index baaff0ffc0e792d6fd0fbb68789ce1093354c8dc..cbb3c7d87edaf0fc19aef3c8c308ec01ff82ed2e 100644 (file)
@@ -176,7 +176,6 @@ grub_pxe_open (const char *name, grub_disk_t disk)
   disk->total_sectors = 0;
   disk->id = (unsigned long) data;
 
-  disk->has_partitions = 0;
   disk->data = data;
 
   return GRUB_ERR_NONE;
index 4273fedfeb5c2c1f0828c1f72533adddc7066212..9554ca76a877946c226e59d9f27861429162f6a6 100644 (file)
@@ -103,7 +103,7 @@ grub_device_iterate (int (*hook) (const char *name))
          return 0;
        }
 
-      if (dev->disk && dev->disk->has_partitions)
+      if (dev->disk)
        {
          struct part_ent *p;
          int ret = 0;
index ccd5f200f9bb9a60858b9331a0ce2143860666e9..7cf29ae7c429ff011b21d73482b4546688449afa 100644 (file)
@@ -281,12 +281,6 @@ grub_disk_open (const char *name)
       goto fail;
     }
 
-  if (p && ! disk->has_partitions)
-    {
-      grub_error (GRUB_ERR_BAD_DEVICE, "no partition on this disk");
-      goto fail;
-    }
-
   disk->dev = dev;
 
   if (p)
index 1eb6cb9d894aa6b037d9d6e241d632148d9e593d..142e93fe2847610185df4cd2e5a358d81b67e69c 100644 (file)
@@ -221,7 +221,6 @@ grub_util_biosdisk_open (const char *name, grub_disk_t disk)
     return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
                       "no mapping exists for `%s'", name);
 
-  disk->has_partitions = 1;
   disk->id = drive;
   disk->data = data = xmalloc (sizeof (struct grub_util_biosdisk_data));
   data->dev = NULL;
index a1e86adb01a9a43b61524d02f25c7d9cc51474ab..f19919d1d63e1c1f2bdd3b95c85dd89a4ae5f3cc 100644 (file)
@@ -160,14 +160,23 @@ iterate_dev (const char *devname)
 
   if (dev)
     {
-      if (dev->disk && dev->disk->has_partitions)
+      char tmp[grub_strlen (devname) + sizeof (",")];
+
+      grub_memcpy (tmp, devname, grub_strlen (devname));
+
+      if (grub_strcmp (devname, current_word) == 0)
        {
-         if (add_completion (devname, ",", GRUB_COMPLETION_TYPE_DEVICE))
+         if (add_completion (devname, ")", GRUB_COMPLETION_TYPE_PARTITION))
            return 1;
+
+         if (dev->disk)
+           if (grub_partition_iterate (dev->disk, iterate_partition))
+             return 1;
        }
       else
        {
-         if (add_completion (devname, ")", GRUB_COMPLETION_TYPE_DEVICE))
+         grub_memcpy (tmp + grub_strlen (devname), "", sizeof (""));
+         if (add_completion (tmp, "", GRUB_COMPLETION_TYPE_DEVICE))
            return 1;
        }
     }
@@ -200,7 +209,7 @@ complete_device (void)
 
       if (dev)
        {
-         if (dev->disk && dev->disk->has_partitions)
+         if (dev->disk)
            {
              if (grub_partition_iterate (dev->disk, iterate_partition))
                {
index ad408074b02da6d07ee8f33eb18fc184c9b91fad..d81b6d26fca8ce955a4267f0cf82c3f5a8d1ed3f 100644 (file)
@@ -108,10 +108,8 @@ grub_normal_print_device_info (const char *name)
              grub_errno = GRUB_ERR_NONE;
            }
        }
-      else if (! dev->disk->has_partitions || dev->disk->partition)
-       grub_printf ("%s", _("Unknown filesystem"));
       else
-       grub_printf ("%s", _("Partition table"));
+       grub_printf ("%s", _("Not a known filesystem"));
 
       if (dev->disk->partition)
        grub_printf (_(" - Partition start at %u"),
index b41f89b38737a4451ed83e14732864f6b94083cf..e3a0160c47efcc291479461a4805655e6dca9eb6 100644 (file)
@@ -99,9 +99,6 @@ struct grub_disk
   /* The total number of sectors.  */
   grub_uint64_t total_sectors;
 
-  /* If partitions can be stored.  */
-  int has_partitions;
-
   /* The id used by the disk cache manager.  */
   unsigned long id;
 
index 3935ce08b9c4a7b001d2fc9bf5b5a76fd6d57b63..eb7981d3af5adeb7375dd51c978579c273e03f58 100644 (file)
@@ -259,13 +259,11 @@ fstest (char **images, int num_disks, int cmd, int n, char **args)
 {
   char *host_file;
   char *loop_name;
-  char *argv[3];
   int i;
 
-  argv[0] = "-p";
-
   for (i = 0; i < num_disks; i++)
     {
+      char *argv[2];
       loop_name = grub_xasprintf ("loop%d", i);
       if (!loop_name)
        grub_util_error (grub_errmsg);
@@ -274,10 +272,10 @@ fstest (char **images, int num_disks, int cmd, int n, char **args)
       if (!host_file)
        grub_util_error (grub_errmsg);
 
-      argv[1] = loop_name;
-      argv[2] = host_file;
+      argv[0] = loop_name;
+      argv[1] = host_file;
 
-      if (execute_command ("loopback", 3, argv))
+      if (execute_command ("loopback", 2, argv))
         grub_util_error ("loopback command fails");
 
       grub_free (loop_name);
@@ -312,15 +310,16 @@ fstest (char **images, int num_disks, int cmd, int n, char **args)
       execute_command ("blocklist", n, args);
       grub_printf ("\n");
     }
-
-  argv[0] = "-d";
-
+    
   for (i = 0; i < num_disks; i++)
     {
+      char *argv[2];
+
       loop_name = grub_xasprintf ("loop%d", i);
       if (!loop_name)
        grub_util_error (grub_errmsg);
 
+      argv[0] = "-d";      
       argv[1] = loop_name;
 
       execute_command ("loopback", 2, argv);
index 987e2d05a42686fe8116e11ccbc51a6a9bbf548a..b9abfb0c67a2d71ebeeb816613f6e56a36508bcb 100644 (file)
@@ -252,14 +252,6 @@ setup (const char *dir,
          tmp_img + GRUB_BOOT_MACHINE_BPB_START,
          GRUB_BOOT_MACHINE_BPB_END - GRUB_BOOT_MACHINE_BPB_START);
 
-  /* Copy the possible partition table.  */
-  if (dest_dev->disk->has_partitions)
-    memcpy (boot_img + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC,
-           tmp_img + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC,
-           GRUB_BOOT_MACHINE_PART_END - GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC);
-
-  free (tmp_img);
-
   /* If DEST_DRIVE is a hard disk, enable the workaround, which is
      for buggy BIOSes which don't pass boot drive correctly. Instead,
      they pass 0x00 or 0x01 even when booted from 0x80.  */
@@ -300,12 +292,6 @@ setup (const char *dir,
   grub_util_info ("dos partition is %d, bsd partition is %d",
                  dos_part, bsd_part);
 
-  if (! dest_dev->disk->has_partitions)
-    {
-      grub_util_warn (_("Attempting to install GRUB to a partitionless disk.  This is a BAD idea."));
-      goto unable_to_embed;
-    }
-
   if (dest_dev->disk->partition)
     {
       grub_util_warn (_("Attempting to install GRUB to a partition instead of the MBR.  This is a BAD idea."));
@@ -345,6 +331,14 @@ setup (const char *dir,
       goto unable_to_embed;
     }
 
+  /* Copy the partition table.  */
+  if (dest_partmap)
+    memcpy (boot_img + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC,
+           tmp_img + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC,
+           GRUB_BOOT_MACHINE_PART_END - GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC);
+
+  free (tmp_img);
+
   if (strcmp (dest_partmap, "msdos") == 0)
     grub_partition_iterate (dest_dev->disk, find_usable_region_msdos);
   else if (strcmp (dest_partmap, "gpt") == 0)