Skip to contentSkip to conversation

Linux I2O devices

PATCH In review Robert Millan 2 participants 6 messages Sep 17, 2006 – Sep 21, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Linux I2O devices

Support for Linux I2O devices (imported from GRUB Legacy).

2006-09-17 Robert Millan <[email protected]>

Import from GRUB Legacy (lib/device.c):
* util/i386/pc/grub-mkdevicemap.c (get_i2o_disk_name): New function. (init_device_map) [__linux__]: Add support for I2O devices.

Signature · 4 lines
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.

2006-09-17 Robert Millan <[email protected]>

Import from GRUB Legacy (lib/device.c):
* util/i386/pc/grub-mkdevicemap.c (get_i2o_disk_name): New function. (init_device_map) [__linux__]: Add support for I2O devices.

Index: util/i386/pc/grub-mkdevicemap.c
===================================================================
RCS file: /sources/grub/grub2/util/i386/pc/grub-mkdevicemap.c,v retrieving revision 1.3

i386/pc/grub-mkdevicemap.c +23 -0
diff -u -r1.3 grub-mkdevicemap.c
@@ -277,6 +277,12 @@
 {
   sprintf (name, "/dev/ataraid/d%c", unit + '0');
 }
+
+static void
+get_i2o_disk_name (char *name, char unit)
+{
+  sprintf (name, "/dev/i2o/hd%c", unit);
+}
 #endif
 
 /* Check if DEVICE can be read. If an error occurs, return zero,
@@ -482,6 +488,23 @@
 	  }
       }
   }
+    
+  /* This is for I2O - we have /dev/i2o/hd<logical drive><partition> */
+  {
+    char unit;
+
+    for (unit = 'a'; unit < 'f'; unit++)
+      {
+	char name[24];
+    
+	get_i2o_disk_name (name, unit);
+	if (check_device (name))
+	  {
+	    fprintf (fp, "(hd%d)\t%s\n", num_hd, name);
+	    num_hd++;
+	  }
+      }
+  }
 #endif /* __linux__ */
 
  finish:
#1 lore raw

I overlooked that biosdisk.c seems to be doing more specific checks on the pathname now.

  if (have_devfs () && strcmp (real_dev + len - 5, "/disc") == 0)
    {
      p = real_dev + len - 4;
      format = "part%d";
    }
  else if ((strncmp (real_dev + 5, "hd", 2) == 0
            || strncmp (real_dev + 5, "sd", 2) == 0)
           && real_dev[7] >= 'a' && real_dev[7] <= 'z')
    {
      p = real_dev + 8;
      format = "%d";
    }
  else if (strncmp (real_dev + 5, "rd/c", 4) == 0)
    {
      p = strchr (real_dev + 9, 'd');
      if (! p)
        return 0;
      p++;
      while (*p && isdigit (*p))
        p++;

      format = "p%d";
    }
  else
    {
      free (real_dev);
      return 0;
    }

For I2O we have /dev/i2o/hd[a-z][0-9]. There's also a big family of device sets using this scheme (/dev/*/hd[a-z][0-9]). Unless the second "if" can be made the default option, we'll have to add knowledge of every of these device paths here?

Quoted 70 lines · Robert Millan

Support for Linux I2O devices (imported from GRUB Legacy).

2006-09-17 Robert Millan <[email protected]>

Import from GRUB Legacy (lib/device.c):
* util/i386/pc/grub-mkdevicemap.c (get_i2o_disk_name): New function. (init_device_map) [__linux__]: Add support for I2O devices.

Signature · 16 lines
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.

2006-09-17  Robert Millan  <[email protected]>

	Import from GRUB Legacy (lib/device.c):
	* util/i386/pc/grub-mkdevicemap.c (get_i2o_disk_name): New function.
	(init_device_map) [__linux__]: Add support for I2O devices.

Index: util/i386/pc/grub-mkdevicemap.c
===================================================================
RCS file: /sources/grub/grub2/util/i386/pc/grub-mkdevicemap.c,v
retrieving revision 1.3
diff -u -r1.3 grub-mkdevicemap.c
i386/pc/grub-mkdevicemap.c +23 -0
@@ -277,6 +277,12 @@
 {
   sprintf (name, "/dev/ataraid/d%c", unit + '0');
 }
+
+static void
+get_i2o_disk_name (char *name, char unit)
+{
+  sprintf (name, "/dev/i2o/hd%c", unit);
+}
 #endif
 
 /* Check if DEVICE can be read. If an error occurs, return zero,
@@ -482,6 +488,23 @@
 	  }
       }
   }
+    
+  /* This is for I2O - we have /dev/i2o/hd<logical drive><partition> */
+  {
+    char unit;
+
+    for (unit = 'a'; unit < 'f'; unit++)
+      {
+	char name[24];
+    
+	get_i2o_disk_name (name, unit);
+	if (check_device (name))
+	  {
+	    fprintf (fp, "(hd%d)\t%s\n", num_hd, name);
+	    num_hd++;
+	  }
+      }
+  }
 #endif /* __linux__ */
 
  finish:

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 4 lines
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.
#2 lore raw
Quoted 4 lines · Robert Millan

For I2O we have /dev/i2o/hd[a-z][0-9]. There's also a big family of device sets using this scheme (/dev/*/hd[a-z][0-9]). Unless the second "if" can be made the default option, we'll have to add knowledge of every of these device paths here?

If you think we can make this ugly code simpler and more consistent, let me know... Is there ever any rule in Linux?!

Okuji

#3 lore raw
Quoted 8 lines · Yoshinori K. Okuji
Quoted 4 lines · Robert Millan

For I2O we have /dev/i2o/hd[a-z][0-9]. There's also a big family of device sets using this scheme (/dev/*/hd[a-z][0-9]). Unless the second "if" can be made the default option, we'll have to add knowledge of every of these device paths here?

If you think we can make this ugly code simpler and more consistent, let me know... Is there ever any rule in Linux?!

I think grub legacy did it right. This is the code from lib/device.c:

  strcpy (dev, map[drive]);
  if (have_devfs ())
    {
      if (strcmp (dev + strlen(dev) - 5, "/disc") == 0)
        strcpy (dev + strlen(dev) - 5, "/part");
    }
  else
    {
      if ((strncmp (dev, "/dev/ataraid/", 13) == 0) ||
         (strncmp (dev, "/dev/rd/", 8) == 0))
        strcpy (dev + strlen(dev), "p");
    }
  sprintf (dev + strlen(dev), "%d", ((partition >> 16) & 0xFF) + 1);

There's a generic case that just appends partition suffix at the end. I think this covers the majority of cases, and grub2 doesn't have it.

I'll try to cook up something.

Signature · 4 lines
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.
#4 lore raw
In reply to Robert Millan
Quoted 7 lines · Robert Millan

Support for Linux I2O devices (imported from GRUB Legacy).

2006-09-17 Robert Millan <[email protected]>

Import from GRUB Legacy (lib/device.c):
* util/i386/pc/grub-mkdevicemap.c (get_i2o_disk_name): New function. (init_device_map) [__linux__]: Add support for I2O devices.

That looks okay to me. Thanks.

Okuji

#5 lore raw
Quoted 10 lines · Yoshinori K. Okuji
Quoted 7 lines · Robert Millan

Support for Linux I2O devices (imported from GRUB Legacy).

2006-09-17 Robert Millan <[email protected]>

Import from GRUB Legacy (lib/device.c):
* util/i386/pc/grub-mkdevicemap.c (get_i2o_disk_name): New function. (init_device_map) [__linux__]: Add support for I2O devices.

That looks okay to me. Thanks.

Ok, committed.

Signature · 4 lines
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.