Re: [PATCH]: grub: Partitions can start at zero.

2009-04-30 Thread David Miller
From: Vladimir Serbinenko 
Date: Mon, 20 Apr 2009 18:53:35 +0200

> On Mon, Apr 20, 2009 at 2:30 AM, David Miller  wrote:
> 
>>
>> With Sun partitions, individual partitions can start at disk
>> address zero.  That's right, zero.
>>
>> This works because UFS and EXT{2,3,4} superblocks are offset
>> far enough into the partition that it won't overwrite the
>> disk label nor the boot block.
>>
>> I added an, arguably hackish, heuristic to handle this properly.
>> Basically if the OS device name does not end in a digit we'll believe
>> that a zero hdg.start value can be a partition.
>>
>> If anyone has a better way to handle this, let me know :-)
>>
> What about the way I proposed in thread on implementing nested partitions?

After some discussions with Vladimir on IRC, he agreed that
my change goes in for now until his nested partition work is
ready.

So I have committed this change.

GRUB works on sparc64 right now on the one test system I got
working tonight, a sparc64 virtualized Sun LDOM guest system.
In fact most systems should work as long as they don't have
"," characters in their block device OF path name.

I'm working on that problem now.


___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH]: grub: Partitions can start at zero.

2009-04-22 Thread David Miller
From: Vladimir Serbinenko 
Date: Mon, 20 Apr 2009 18:53:35 +0200

> On Mon, Apr 20, 2009 at 2:30 AM, David Miller  wrote:
> 
>>
>> With Sun partitions, individual partitions can start at disk
>> address zero.  That's right, zero.
>>
>> This works because UFS and EXT{2,3,4} superblocks are offset
>> far enough into the partition that it won't overwrite the
>> disk label nor the boot block.
>>
>> I added an, arguably hackish, heuristic to handle this properly.
>> Basically if the OS device name does not end in a digit we'll believe
>> that a zero hdg.start value can be a partition.
>>
>> If anyone has a better way to handle this, let me know :-)
>>
> What about the way I proposed in thread on implementing nested partitions?

Yes it seems that it should be able to handle this situation.

I cannot say %100 for sure until I see the code you end up
writing, of course :)


___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH]: grub: Partitions can start at zero.

2009-04-21 Thread David Miller
From: Vladimir Serbinenko 
Date: Mon, 20 Apr 2009 18:53:35 +0200

> On Mon, Apr 20, 2009 at 2:30 AM, David Miller  wrote:
> 
>>
>> With Sun partitions, individual partitions can start at disk
>> address zero.  That's right, zero.
>>
>> This works because UFS and EXT{2,3,4} superblocks are offset
>> far enough into the partition that it won't overwrite the
>> disk label nor the boot block.
>>
>> I added an, arguably hackish, heuristic to handle this properly.
>> Basically if the OS device name does not end in a digit we'll believe
>> that a zero hdg.start value can be a partition.
>>
>> If anyone has a better way to handle this, let me know :-)
>>
> What about the way I proposed in thread on implementing nested partitions?

Thanks for your feedback, I'll take a look at this.


___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH]: grub: Partitions can start at zero.

2009-04-20 Thread Vladimir Serbinenko
On Mon, Apr 20, 2009 at 2:30 AM, David Miller  wrote:

>
> With Sun partitions, individual partitions can start at disk
> address zero.  That's right, zero.
>
> This works because UFS and EXT{2,3,4} superblocks are offset
> far enough into the partition that it won't overwrite the
> disk label nor the boot block.
>
> I added an, arguably hackish, heuristic to handle this properly.
> Basically if the OS device name does not end in a digit we'll believe
> that a zero hdg.start value can be a partition.
>
> If anyone has a better way to handle this, let me know :-)
>
What about the way I proposed in thread on implementing nested partitions?

>
> 2009-04-19  David S. Miller  
>
>* util/hostdisk.c (device_is_wholedisk): New function.
>(grub_util_biosdisk_get_grub_dev): Shortcut when hdg.start is
>zero only if device_is_wholedisk() returns true.
> ---
>  util/hostdisk.c |   12 +++-
>  1 files changed, 11 insertions(+), 1 deletions(-)
>
> diff --git a/util/hostdisk.c b/util/hostdisk.c
> index aa41703..b55d7fe 100644
> --- a/util/hostdisk.c
> +++ b/util/hostdisk.c
> @@ -827,6 +827,16 @@ convert_system_partition_to_system_disk (const char
> *os_dev)
>  }
>
>  static int
> +device_is_wholedisk (const char *os_dev)
> +{
> +  int len = strlen (os_dev);
> +
> +  if (os_dev[len - 1] < '0' || os_dev[len - 1] > '9')
> +return 1;
> +  return 0;
> +}
> +
> +static int
>  find_system_device (const char *os_dev)
>  {
>   int i;
> @@ -961,7 +971,7 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
>
> grub_util_info ("%s starts from %lu", os_dev, hdg.start);
>
> -if (hdg.start == 0)
> +if (hdg.start == 0 && device_is_wholedisk (os_dev))
>   return name;
>
> grub_util_info ("opening the device %s", name);
> --
> 1.6.2.3
>
>
>
> ___
> Grub-devel mailing list
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel
>
___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


[PATCH]: grub: Partitions can start at zero.

2009-04-19 Thread David Miller

With Sun partitions, individual partitions can start at disk
address zero.  That's right, zero.

This works because UFS and EXT{2,3,4} superblocks are offset
far enough into the partition that it won't overwrite the
disk label nor the boot block.

I added an, arguably hackish, heuristic to handle this properly.
Basically if the OS device name does not end in a digit we'll believe
that a zero hdg.start value can be a partition.

If anyone has a better way to handle this, let me know :-)

2009-04-19  David S. Miller  

* util/hostdisk.c (device_is_wholedisk): New function.
(grub_util_biosdisk_get_grub_dev): Shortcut when hdg.start is
zero only if device_is_wholedisk() returns true.
---
 util/hostdisk.c |   12 +++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/util/hostdisk.c b/util/hostdisk.c
index aa41703..b55d7fe 100644
--- a/util/hostdisk.c
+++ b/util/hostdisk.c
@@ -827,6 +827,16 @@ convert_system_partition_to_system_disk (const char 
*os_dev)
 }
 
 static int
+device_is_wholedisk (const char *os_dev)
+{
+  int len = strlen (os_dev);
+
+  if (os_dev[len - 1] < '0' || os_dev[len - 1] > '9')
+return 1;
+  return 0;
+}
+
+static int
 find_system_device (const char *os_dev)
 {
   int i;
@@ -961,7 +971,7 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
 
 grub_util_info ("%s starts from %lu", os_dev, hdg.start);
 
-if (hdg.start == 0)
+if (hdg.start == 0 && device_is_wholedisk (os_dev))
   return name;
 
 grub_util_info ("opening the device %s", name);
-- 
1.6.2.3



___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel