From 520ae21bb747ac3008d0bd80783c24a1eaffab9c Mon Sep 17 00:00:00 2001 From: proski Date: Fri, 30 May 2008 21:55:31 +0000 Subject: [PATCH] 2008-05-30 Pavel Roskin * 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 | 8 ++++++++ util/biosdisk.c | 47 +++++++++-------------------------------------- 2 files changed, 17 insertions(+), 38 deletions(-) diff --git a/ChangeLog b/ChangeLog index d230581d4..376b5dd50 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-05-30 Pavel Roskin + + * 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 * util/update-grub.in (GRUB_DISABLE_LINUX_UUID): Export variable. diff --git a/util/biosdisk.c b/util/biosdisk.c index 2e1cec358..3a81e5fde 100644 --- a/util/biosdisk.c +++ b/util/biosdisk.c @@ -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') + else if (real_dev[len - 1] >= '0' && real_dev[len - 1] <= '9') { - p = real_dev + sizeof("/dev/hda")-1; - format = "%d"; - } - else if (strncmp (real_dev + 5, "rd/c", 4) == 0) /* dac960 */ - { - p = strchr (real_dev + 9, 'd'); - if (! p) - return 0; - - p++; - while (*p && isdigit (*p)) - p++; - - 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) - { - p = real_dev + sizeof("/dev/mmcblk0")-1; + p = real_dev + len; format = "p%d"; } else - return 0; + { + p = real_dev + len; + format = "%d"; + } 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);