All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Vladimir 'phcoder' Serbinenko" <phcoder@gmail.com>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: [PATCH] Remove has_paritions
Date: Fri, 28 Aug 2009 21:25:15 +0200	[thread overview]
Message-ID: <d7ead6de0908281225p3f83624fg6b6bdecfe024d28@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 106 bytes --]

-- 
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git

[-- Attachment #2: nopart.diff --]
[-- Type: text/plain, Size: 13136 bytes --]

diff --git a/Changelog.phcoder b/Changelog.phcoder
new file mode 100644
index 0000000..978faf6
--- /dev/null
+++ b/Changelog.phcoder
@@ -0,0 +1,10 @@
+2009-07-26  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.
+	* util/grub-fstest.c (fstest): Don't pass "-p" to loopback.
+	(options): Remove partitions. All users updated.
+	* util/i386/pc/grub-setup.c (setup): copy parition table only when
+	actual partition table is found.
diff --git a/disk/ata.c b/disk/ata.c
index 78d3965..73b07be 100644
--- a/disk/ata.c
+++ b/disk/ata.c
@@ -683,7 +683,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;
diff --git a/disk/efi/efidisk.c b/disk/efi/efidisk.c
index de84859..fd1fae4 100644
--- a/disk/efi/efidisk.c
+++ b/disk/efi/efidisk.c
@@ -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:
diff --git a/disk/fs_file.c b/disk/fs_file.c
index e095682..19dabef 100644
--- a/disk/fs_file.c
+++ b/disk/fs_file.c
@@ -76,7 +76,6 @@ grub_fs_file_open (const char *name, grub_disk_t disk)
     return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no matching file found");
 
   disk->total_sectors = dev->disk->total_sectors;
-  disk->has_partitions = 0;
   if (dev->disk->partition)
     {
       disk->partition = grub_malloc (sizeof (*disk->partition));
diff --git a/disk/fs_uuid.c b/disk/fs_uuid.c
index 6901dba..aabebdf 100644
--- a/disk/fs_uuid.c
+++ b/disk/fs_uuid.c
@@ -88,7 +88,6 @@ grub_fs_uuid_open (const char *name, grub_disk_t disk)
     return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no matching UUID found");
 
   disk->total_sectors = dev->disk->total_sectors;
-  disk->has_partitions = 0;
   if (dev->disk->partition)
     {
       disk->partition = grub_malloc (sizeof (*disk->partition));
diff --git a/disk/host.c b/disk/host.c
index c4f3e71..c519662 100644
--- a/disk/host.c
+++ b/disk/host.c
@@ -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;
diff --git a/disk/i386/pc/biosdisk.c b/disk/i386/pc/biosdisk.c
index 0a6137f..115e2c1 100644
--- a/disk/i386/pc/biosdisk.c
+++ b/disk/i386/pc/biosdisk.c
@@ -106,7 +106,6 @@ grub_biosdisk_open (const char *name, grub_disk_t disk)
   if (drive < 0)
     return grub_errno;
 
-  disk->has_partitions = ((drive & 0x80) && (drive != cd_drive));
   disk->id = drive;
 
   data = (struct grub_biosdisk_data *) grub_zalloc (sizeof (*data));
diff --git a/disk/ieee1275/nand.c b/disk/ieee1275/nand.c
index 37427f8..9d96d51 100644
--- a/disk/ieee1275/nand.c
+++ b/disk/ieee1275/nand.c
@@ -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;
diff --git a/disk/ieee1275/ofdisk.c b/disk/ieee1275/ofdisk.c
index ca257d6..e749259 100644
--- a/disk/ieee1275/ofdisk.c
+++ b/disk/ieee1275/ofdisk.c
@@ -208,8 +208,6 @@ grub_ofdisk_open (const char *name, grub_disk_t disk)
 
   disk->id = (unsigned long) op;
 
-  /* XXX: Read this, somehow.  */
-  disk->has_partitions = 1;
   disk->data = (void *) (unsigned long) dev_ihandle;
   return 0;
 
diff --git a/disk/loopback.c b/disk/loopback.c
index 2980518..d98dbb2 100644
--- a/disk/loopback.c
+++ b/disk/loopback.c
@@ -28,7 +28,6 @@ struct grub_loopback
 {
   char *devname;
   char *filename;
-  int has_partitions;
   struct grub_loopback *next;
 };
 
@@ -37,7 +36,6 @@ static struct grub_loopback *loopback_list;
 static const struct grub_arg_option options[] =
   {
     {"delete", 'd', 0, "delete the loopback device entry", 0, 0},
-    {"partitions", 'p', 0, "simulate a hard drive with partitions", 0, 0},
     {0, 0, 0, 0, 0, 0}
   };
 
@@ -107,9 +105,6 @@ grub_cmd_loopback (grub_extcmd_t cmd, int argc, char **args)
       grub_free (newdev->filename);
       newdev->filename = newname;
 
-      /* Set has_partitions when `--partitions' was used.  */
-      newdev->has_partitions = state[1].set;
-
       return 0;
     }
 
@@ -133,9 +128,6 @@ grub_cmd_loopback (grub_extcmd_t cmd, int argc, char **args)
       return grub_errno;
     }
 
-  /* 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;
@@ -178,7 +170,6 @@ grub_loopback_open (const char *name, grub_disk_t disk)
 			 / GRUB_DISK_SECTOR_SIZE);
   disk->id = (unsigned long) dev;
 
-  disk->has_partitions = dev->has_partitions;
   disk->data = file;
 
   return 0;
@@ -245,7 +236,7 @@ GRUB_MOD_INIT(loop)
 {
   cmd = grub_register_extcmd ("loopback", grub_cmd_loopback,
 			      GRUB_COMMAND_FLAG_BOTH,
-			      "loopback [-d|-p] DEVICENAME FILE",
+			      "loopback [-d] DEVICENAME FILE",
 			      "Make a device of a file.", options);
   grub_disk_dev_register (&grub_loopback_dev);
 }
diff --git a/disk/lvm.c b/disk/lvm.c
index 126b494..59bf2d7 100644
--- a/disk/lvm.c
+++ b/disk/lvm.c
@@ -97,7 +97,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;
diff --git a/disk/memdisk.c b/disk/memdisk.c
index 4a04708..d93752f 100644
--- a/disk/memdisk.c
+++ b/disk/memdisk.c
@@ -42,7 +42,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;
 }
diff --git a/disk/raid.c b/disk/raid.c
index c720fb3..fc12683 100644
--- a/disk/raid.c
+++ b/disk/raid.c
@@ -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;
 
diff --git a/disk/scsi.c b/disk/scsi.c
index 24ebdb6..85d53b3 100644
--- a/disk/scsi.c
+++ b/disk/scsi.c
@@ -283,11 +283,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;
-
       err = grub_scsi_read_capacity (scsi);
       if (err)
 	{
diff --git a/fs/i386/pc/pxe.c b/fs/i386/pc/pxe.c
index 4032e12..1a99ad4 100644
--- a/fs/i386/pc/pxe.c
+++ b/fs/i386/pc/pxe.c
@@ -65,7 +65,6 @@ grub_pxe_open (const char *name, grub_disk_t disk)
   disk->total_sectors = 0;
   disk->id = (unsigned long) "pxe";
 
-  disk->has_partitions = 0;
   disk->data = 0;
 
   return GRUB_ERR_NONE;
diff --git a/include/grub/disk.h b/include/grub/disk.h
index de71bb5..31d0e1a 100644
--- a/include/grub/disk.h
+++ b/include/grub/disk.h
@@ -98,9 +98,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;
 
diff --git a/kern/device.c b/kern/device.c
index 83ae3dc..b9c340e 100644
--- a/kern/device.c
+++ b/kern/device.c
@@ -100,7 +100,7 @@ grub_device_iterate (int (*hook) (const char *name))
       if (! dev)
 	return 0;
 
-      if (dev->disk && dev->disk->has_partitions)
+      if (dev->disk)
 	{
 	  struct part_ent *p;
 	  int ret = 0;
diff --git a/kern/disk.c b/kern/disk.c
index e463626..5fe1bcf 100644
--- a/kern/disk.c
+++ b/kern/disk.c
@@ -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)
diff --git a/normal/completion.c b/normal/completion.c
index 4b38e33..7b3de44 100644
--- a/normal/completion.c
+++ b/normal/completion.c
@@ -161,14 +161,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;
 	}
     }
@@ -216,7 +225,7 @@ complete_device (void)
 
       if (dev)
 	{
-	  if (dev->disk && dev->disk->has_partitions)
+	  if (dev->disk)
 	    {
 	      if (grub_partition_iterate (dev->disk, iterate_partition))
 		{
diff --git a/normal/misc.c b/normal/misc.c
index 0a1a2f0..cddd1d3 100644
--- a/normal/misc.c
+++ b/normal/misc.c
@@ -94,10 +94,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 ("Unknown filesystem");
       else
-	grub_printf ("Partition table");
+	grub_printf ("Unknown filesystem");
 
       grub_device_close (dev);
     }
diff --git a/util/grub-fstest.c b/util/grub-fstest.c
index 1bb3706..d522e53 100644
--- a/util/grub-fstest.c
+++ b/util/grub-fstest.c
@@ -277,7 +277,7 @@ fstest (char **images, int num_disks, int cmd, int n, char **args)
 {
   char host_file[128];
   char loop_name[8];
-  char *argv[3] = { "-p", loop_name, host_file};
+  char *argv[2] = { loop_name, host_file};
   int i;
 
   for (i = 0; i < num_disks; i++)
@@ -288,7 +288,7 @@ fstest (char **images, int num_disks, int cmd, int n, char **args)
       grub_sprintf (loop_name, "loop%d", i);
       grub_sprintf (host_file, "(host)%s", images[i]);
 
-      if (execute_command ("loopback", 3, argv))
+      if (execute_command ("loopback", 2, argv))
         grub_util_error ("loopback command fails.");
     }
 
diff --git a/util/hostdisk.c b/util/hostdisk.c
index a06ecca..384d5cb 100644
--- a/util/hostdisk.c
+++ b/util/hostdisk.c
@@ -170,7 +170,6 @@ grub_util_biosdisk_open (const char *name, grub_disk_t disk)
     return grub_error (GRUB_ERR_BAD_DEVICE,
 		       "no mapping exists for `%s'", name);
 
-  disk->has_partitions = 1;
   disk->id = drive;
 
   /* Get the size.  */
diff --git a/util/i386/pc/grub-setup.c b/util/i386/pc/grub-setup.c
index ccfbd1d..8a2f914 100644
--- a/util/i386/pc/grub-setup.c
+++ b/util/i386/pc/grub-setup.c
@@ -256,14 +256,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.  */
@@ -307,12 +299,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.");
@@ -338,8 +324,17 @@ 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);
+
   grub_partition_iterate (dest_dev->disk, (strcmp (dest_partmap, "part_msdos") ?
-					   find_usable_region_gpt : find_usable_region_msdos));
+					   find_usable_region_gpt
+					   : find_usable_region_msdos));
 
   if (embed_region.end == embed_region.start)
     {

             reply	other threads:[~2009-08-28 19:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-28 19:25 Vladimir 'phcoder' Serbinenko [this message]
2009-08-30 13:33 ` [PATCH] Remove has_paritions Robert Millan
2009-08-30 13:44   ` Vladimir 'phcoder' Serbinenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d7ead6de0908281225p3f83624fg6b6bdecfe024d28@mail.gmail.com \
    --to=phcoder@gmail.com \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.