]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2008-05-30 Pavel Roskin <proski@gnu.org>
authorproski <proski@localhost>
Fri, 30 May 2008 21:55:31 +0000 (21:55 +0000)
committerproski <proski@localhost>
Fri, 30 May 2008 21:55:31 +0000 (21:55 +0000)
* util/biosdisk.c (linux_find_partition): Simplify logic and
make the code more universal.  Keep special processing for
devfs, but use a simple rule for all other devices.  If the
device ends with a number, append 'p' and the partition number.
Otherwise, append only the partition number.

ChangeLog
util/biosdisk.c

index d230581d41a70c140e3582d3638edc97d494a807..376b5dd502012a499e3e5461c0deec2c75fad939 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-05-30  Pavel Roskin  <proski@gnu.org>
+
+       * util/biosdisk.c (linux_find_partition): Simplify logic and
+       make the code more universal.  Keep special processing for
+       devfs, but use a simple rule for all other devices.  If the
+       device ends with a number, append 'p' and the partition number.
+       Otherwise, append only the partition number.
+
 2008-05-30  Robert Millan  <rmh@aybabtu.com>
 
        * util/update-grub.in (GRUB_DISABLE_LINUX_UUID): Export variable.
index 2e1cec3586fd36a3b5be2bff449196a1c069cb5e..3a81e5fde9f7afcd4f5939c62247c95c0317f6d9 100644 (file)
@@ -215,57 +215,28 @@ linux_find_partition (char *dev, unsigned long sector)
   char real_dev[PATH_MAX];
 
   strcpy(real_dev, dev);
-  
+
   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, "vd", 2) == 0
-           || strncmp (real_dev + 5, "sd", 2) == 0)
-          && real_dev[7] >= 'a' && real_dev[7] <= 'z')
-    {
-      p = real_dev + sizeof("/dev/hda")-1;
-      format = "%d";
-    }
-  else if (strncmp (real_dev + 5, "rd/c", 4) == 0)     /* dac960 */
+  else if (real_dev[len - 1] >= '0' && real_dev[len - 1] <= '9')
     {
-      p = strchr (real_dev + 9, 'd');
-      if (! p)
-       return 0;
-
-      p++;
-      while (*p && isdigit (*p))
-       p++;
-
+      p = real_dev + len;
       format = "p%d";
     }
-  else if (strncmp (real_dev + 5, "cciss/c", sizeof("cciss/c")-1) == 0)
-    {
-      p = strchr (real_dev + 5 + sizeof("cciss/c")-1, 'd');
-      if (! p)
-       return 0;
-
-      p++;
-      while (*p && isdigit (*p))
-       p++;
-
-      format = "p%d";
-    }
-  else if (strncmp (real_dev + 5, "mmcblk", sizeof("mmcblk")-1) == 0)
+  else
     {
-      p = real_dev + sizeof("/dev/mmcblk0")-1;
-      format = "p%d";
+      p = real_dev + len;
+      format = "%d";
     }
-  else
-    return 0;
 
   for (i = 1; i < 10000; i++)
     {
       int fd;
       struct hd_geometry hdg;
-      
+
       sprintf (p, format, i);
       fd = open (real_dev, O_RDONLY);
       if (fd == -1)
@@ -278,7 +249,7 @@ linux_find_partition (char *dev, unsigned long sector)
        }
 
       close (fd);
-      
+
       if (hdg.start == sector)
        {
          strcpy (dev, real_dev);