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.
This commit is contained in:
parent
5786569b41
commit
520ae21bb7
2 changed files with 17 additions and 38 deletions
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue