All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Set size of partition correctly in grub_disk_open()
@ 2006-07-05 20:54 Jeroen Dekkers
  2006-07-08 16:07 ` Yoshinori K. Okuji
  0 siblings, 1 reply; 11+ messages in thread
From: Jeroen Dekkers @ 2006-07-05 20:54 UTC (permalink / raw)
  To: grub-devel

Hi,

When we open a partition grub_disk_open() sets disk->total_sectors to
the size of the disk, not the size of the partition. We also don't
check whether we grub_partition_probe() actually finds a
partition. See the patch below.

Jeroen Dekkers


2006-07-05  Jeroen Dekkers  <jeroen@dekkers.cx>

	* kern/disk.c (grub_disk_open): Check whether
	grub_partition_probe() finds a partition. Set disk->total_sectors
	to the size of the partition if we open a partition.

Index: kern/disk.c
===================================================================
RCS file: /cvsroot/grub/grub2/kern/disk.c,v
retrieving revision 1.13
diff -u -p -r1.13 disk.c
--- kern/disk.c	4 Jun 2006 15:56:54 -0000	1.13
+++ kern/disk.c	5 Jul 2006 20:51:18 -0000
@@ -1,6 +1,6 @@
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2002,2003,2004  Free Software Foundation, Inc.
+ *  Copyright (C) 2002,2003,2004,2006  Free Software Foundation, Inc.
  *
  *  GRUB is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -265,7 +265,16 @@ grub_disk_open (const char *name)
   disk->dev = dev;
 
   if (p)
-    disk->partition = grub_partition_probe (disk, p + 1);
+    {
+      disk->partition = grub_partition_probe (disk, p + 1);
+      if (! disk->partition)
+	{
+	  grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no such partition");
+	  goto fail;
+	}
+      
+      disk->total_sectors = grub_partition_get_len (disk->partition);
+    }
 
   /* The cache will be invalidated about 2 seconds after a device was
      closed.  */



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2006-07-11 17:06 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-05 20:54 [PATCH] Set size of partition correctly in grub_disk_open() Jeroen Dekkers
2006-07-08 16:07 ` Yoshinori K. Okuji
2006-07-08 20:39   ` Jeroen Dekkers
2006-07-08 21:10     ` Yoshinori K. Okuji
2006-07-08 23:35       ` Jeroen Dekkers
2006-07-09  1:11         ` Yoshinori K. Okuji
2006-07-09 12:01           ` Jeroen Dekkers
2006-07-09 13:29             ` Yoshinori K. Okuji
2006-07-09 14:38               ` Tomáš Ebenlendr
2006-07-09 21:37               ` Jeroen Dekkers
2006-07-11 17:06                 ` Yoshinori K. Okuji

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.