grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Set size of partition correctly in grub_disk_open()


From: Jeroen Dekkers
Subject: [PATCH] Set size of partition correctly in grub_disk_open()
Date: Wed, 05 Jul 2006 22:54:51 +0200
User-agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (Shijō) APEL/10.6 Emacs/22.0.50 (x86_64-pc-linux-gnu) MULE/5.0 (SAKAKI)

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  <address@hidden>

        * 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.  */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]