On Sat, Jul 14, 2007 at 12:16:16AM +0200, Robert Millan wrote:
> On Tue, Jul 10, 2007 at 09:26:27PM +0200, Jordi Mallach wrote:
> > On Tue, Jul 10, 2007 at 04:10:52PM +0200, Robert Millan wrote:
> > > What naming/numbering scheme does this follow when you add more disks?
> > 
> > hd, hd1, hd2. Luckily Mozillion has Firewire disks.
> 
> My Efika counts: hd, hd0 ...
> 
> IEEE 1275 does not seem to cover this.  What scheme should we follow when
> generating device.map ?

Since "hd, hd1, hd2 ..." seems to be much more common, I propose we use that
and let user override it via device.map in case of disparity (which may only
happen in systems with more than 1 disk).

See attached patch.

-- 
Robert Millan

My spam trap is [EMAIL PROTECTED]  Note: this address is only intended
for spam harvesters.  Writing to it will get you added to my black list.
diff -Nur grub2/conf/i386-efi.rmk grub2.new/conf/i386-efi.rmk
--- grub2/conf/i386-efi.rmk	2007-07-22 11:32:51.000000000 +0200
+++ grub2.new/conf/i386-efi.rmk	2007-07-22 11:32:57.000000000 +0200
@@ -24,7 +24,8 @@
 #	kern/fs.c kern/env.c fs/fshelp.c
 
 # For grub-mkdevicemap.
-grub_mkdevicemap_SOURCES = util/grub-mkdevicemap.c util/misc.c
+grub_mkdevicemap_SOURCES = util/grub-mkdevicemap.c util/misc.c		\
+	util/i386/get_disk_name.c
 
 # For grub-probe.
 grub_probe_SOURCES = util/grub-probe.c	\
diff -Nur grub2/conf/i386-pc.rmk grub2.new/conf/i386-pc.rmk
--- grub2/conf/i386-pc.rmk	2007-07-22 11:32:51.000000000 +0200
+++ grub2.new/conf/i386-pc.rmk	2007-07-22 11:32:57.000000000 +0200
@@ -71,7 +71,8 @@
 	util/raid.c util/lvm.c
 
 # For grub-mkdevicemap.
-grub_mkdevicemap_SOURCES = util/grub-mkdevicemap.c util/misc.c
+grub_mkdevicemap_SOURCES = util/grub-mkdevicemap.c util/misc.c		\
+	util/i386/get_disk_name.c
 
 # For grub-probe.
 grub_probe_SOURCES = util/grub-probe.c	\
diff -Nur grub2/conf/powerpc-ieee1275.rmk grub2.new/conf/powerpc-ieee1275.rmk
--- grub2/conf/powerpc-ieee1275.rmk	2007-07-02 21:50:41.000000000 +0200
+++ grub2.new/conf/powerpc-ieee1275.rmk	2007-07-22 11:20:37.000000000 +0200
@@ -36,7 +36,8 @@
         util/resolve.c 
 
 # For grub-mkdevicemap.
-grub_mkdevicemap_SOURCES = util/grub-mkdevicemap.c util/misc.c
+grub_mkdevicemap_SOURCES = util/grub-mkdevicemap.c util/misc.c		\
+	util/ieee1275/get_disk_name.c
 
 # For grub-probe.
 grub_probe_SOURCES = util/grub-probe.c	\
diff -Nur grub2/include/grub/util/misc.h grub2.new/include/grub/util/misc.h
--- grub2/include/grub/util/misc.h	2007-07-22 06:50:10.000000000 +0200
+++ grub2.new/include/grub/util/misc.h	2007-07-22 11:20:37.000000000 +0200
@@ -53,5 +53,6 @@
 void grub_util_write_image (const char *img, size_t size, FILE *out);
 void grub_util_write_image_at (const void *img, size_t size, off_t offset,
 			       FILE *out);
+char *grub_util_get_disk_name (int disk);
 
 #endif /* ! GRUB_UTIL_MISC_HEADER */
diff -Nur grub2/util/grub-mkdevicemap.c grub2.new/util/grub-mkdevicemap.c
--- grub2/util/grub-mkdevicemap.c	2007-07-22 06:50:10.000000000 +0200
+++ grub2.new/util/grub-mkdevicemap.c	2007-07-22 11:20:37.000000000 +0200
@@ -402,8 +402,11 @@
 	  
 	  if (realpath (discn, name))
 	    {
+	      char *p;
 	      strcat (name, "/disc");
-	      fprintf (fp, "(hd%d)\t%s\n", num_hd, name);
+	      p = grub_util_get_disk_name (num_hd);
+	      fprintf (fp, "(%s)\t%s\n", p, name);
+	      free (p);
 	    }
 	  
 	  num_hd++;
@@ -421,7 +424,10 @@
       get_ide_disk_name (name, i);
       if (check_device (name))
 	{
-	  fprintf (fp, "(hd%d)\t%s\n", num_hd, name);
+	  char *p;
+	  p = grub_util_get_disk_name (num_hd);
+	  fprintf (fp, "(%s)\t%s\n", p, name);
+	  free (p);
 	  num_hd++;
 	}
     }
@@ -435,7 +441,10 @@
       get_ataraid_disk_name (name, i);
       if (check_device (name))
 	{
-	  fprintf (fp, "(hd%d)\t%s\n", num_hd, name);
+	  char *p;
+	  p = grub_util_get_disk_name (num_hd);
+	  fprintf (fp, "(%s)\t%s\n", p, name);
+	  free (p);
           num_hd++;
         }
     }
@@ -449,7 +458,10 @@
       get_scsi_disk_name (name, i);
       if (check_device (name))
 	{
-	  fprintf (fp, "(hd%d)\t%s\n", num_hd, name);
+	  char *p;
+	  p = grub_util_get_disk_name (num_hd);
+	  fprintf (fp, "(%s)\t%s\n", p, name);
+	  free (p);
 	  num_hd++;
 	}
     }
@@ -472,7 +484,10 @@
 	    get_dac960_disk_name (name, controller, drive);
 	    if (check_device (name))
 	      {
-		fprintf (fp, "(hd%d)\t%s\n", num_hd, name);
+		char *p;
+		p = grub_util_get_disk_name (num_hd);
+		fprintf (fp, "(%s)\t%s\n", p, name);
+		free (p);
 		num_hd++;
 	      }
 	  }
@@ -490,7 +505,10 @@
 	get_i2o_disk_name (name, unit);
 	if (check_device (name))
 	  {
-	    fprintf (fp, "(hd%d)\t%s\n", num_hd, name);
+	    char *p;
+	    p = grub_util_get_disk_name (num_hd);
+	    fprintf (fp, "(%s)\t%s\n", p, name);
+	    free (p);
 	    num_hd++;
 	  }
       }
diff -Nur grub2/util/i386/get_disk_name.c grub2.new/util/i386/get_disk_name.c
--- grub2/util/i386/get_disk_name.c	1970-01-01 01:00:00.000000000 +0100
+++ grub2.new/util/i386/get_disk_name.c	2007-07-22 11:29:07.000000000 +0200
@@ -0,0 +1,31 @@
+/* get_disk_name.c */
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2007 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
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  GRUB is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/util/misc.h>
+
+char *
+grub_util_get_disk_name (int disk)
+{
+  char *p;
+
+  p = xmalloc (16);
+  sprintf (p, "hd%d", disk);
+  
+  return p;
+}
diff -Nur grub2/util/ieee1275/get_disk_name.c grub2.new/util/ieee1275/get_disk_name.c
--- grub2/util/ieee1275/get_disk_name.c	1970-01-01 01:00:00.000000000 +0100
+++ grub2.new/util/ieee1275/get_disk_name.c	2007-07-22 11:26:45.000000000 +0200
@@ -0,0 +1,36 @@
+/* get_disk_name.c */
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2007 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
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  GRUB is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/util/misc.h>
+
+#include <string.h>
+
+char *
+grub_util_get_disk_name (int disk)
+{
+  char *p;
+
+  p = xmalloc (16);
+  sprintf (p, "hd");
+
+  if (disk > 0)
+    sprintf (p + strlen (p), "%d", disk);
+  
+  return p;
+}
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to