Handle all possible disk device names for NetBSD.

This commit is contained in:
Grégoire Sutre 2010-06-03 00:47:22 +02:00
parent 0819fec8a1
commit 9d9b583350
2 changed files with 33 additions and 14 deletions

View file

@ -1,3 +1,9 @@
2010-06-02 Grégoire Sutre <gregoire.sutre@gmail.com>
* kern/emu/hostdisk.c (convert_system_partition_to_system_disk)
[__NetBSD__]: Handle all device names matching /dev/r[a-z]+[0-9][a-z].
(find_partition_start) [__NetBSD__]: Correct error messages for NetBSD.
2010-06-02 Colin Watson <cjwatson@ubuntu.com> 2010-06-02 Colin Watson <cjwatson@ubuntu.com>
* docs/grub.texi (Simple configuration): Fix copy-and-paste typo. * docs/grub.texi (Simple configuration): Fix copy-and-paste typo.

View file

@ -413,7 +413,11 @@ devmapper_fail:
if (fd == -1) if (fd == -1)
{ {
grub_error (GRUB_ERR_BAD_DEVICE, grub_error (GRUB_ERR_BAD_DEVICE,
# if !defined(__NetBSD__)
"cannot open `%s' while attempting to get disk geometry", dev); "cannot open `%s' while attempting to get disk geometry", dev);
# else /* defined(__NetBSD__) */
"cannot open `%s' while attempting to get disk label", dev);
# endif /* !defined(__NetBSD__) */
return 0; return 0;
} }
@ -425,7 +429,11 @@ devmapper_fail:
# endif /* !defined(__NetBSD__) */ # endif /* !defined(__NetBSD__) */
{ {
grub_error (GRUB_ERR_BAD_DEVICE, grub_error (GRUB_ERR_BAD_DEVICE,
# if !defined(__NetBSD__)
"cannot get disk geometry of `%s'", dev); "cannot get disk geometry of `%s'", dev);
# else /* defined(__NetBSD__) */
"cannot get disk label of `%s'", dev);
# endif /* !defined(__NetBSD__) */
close (fd); close (fd);
return 0; return 0;
} }
@ -1256,22 +1264,28 @@ devmapper_out:
return path; return path;
#elif defined(__NetBSD__) #elif defined(__NetBSD__)
/* NetBSD uses "/dev/r[wsc]d[0-9]+[a-z]". */ /* NetBSD uses "/dev/r[a-z]+[0-9][a-z]". */
char *path = xstrdup (os_dev); char *path = xstrdup (os_dev);
if (strncmp ("/dev/rwd", path, 8) == 0 || if (strncmp ("/dev/r", path, sizeof("/dev/r") - 1) == 0 &&
strncmp ("/dev/rsd", path, 8) == 0 || (path[sizeof("/dev/r") - 1] >= 'a' && path[sizeof("/dev/r") - 1] <= 'z') &&
strncmp ("/dev/rcd", path, 8) == 0) strncmp ("fd", path + sizeof("/dev/r") - 1, sizeof("fd") - 1) != 0) /* not a floppy device name */
{ {
char *q; char *p;
q = path + strlen(path) - 1; /* last character */ for (p = path + sizeof("/dev/r"); *p >= 'a' && *p <= 'z'; p++);
if (grub_isalpha(*q) && grub_isdigit(*(q-1))) if (grub_isdigit(*p))
{ {
int rawpart = -1; p++;
if ((*p >= 'a' && *p <= 'z') && (*(p+1) == '\0'))
{
/* path matches the required regular expression and
p points to its last character. */
int rawpart = -1;
# ifdef HAVE_GETRAWPARTITION # ifdef HAVE_GETRAWPARTITION
rawpart = getrawpartition(); rawpart = getrawpartition();
# endif /* HAVE_GETRAWPARTITION */ # endif /* HAVE_GETRAWPARTITION */
if (rawpart >= 0) if (rawpart >= 0)
*q = 'a' + rawpart; *p = 'a' + rawpart;
}
} }
} }
return path; return path;
@ -1429,8 +1443,7 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
return name; return name;
# else /* defined(__NetBSD__) */ # else /* defined(__NetBSD__) */
/* Since os_dev and convert_system_partition_to_system_disk (os_dev) are /* Since os_dev and convert_system_partition_to_system_disk (os_dev) are
* different, we know that os_dev is of the form /dev/r[wsc]d[0-9]+[a-z] * different, we know that os_dev cannot be a floppy device. */
* and in particular it cannot be a floppy device. */
# endif /* !defined(__NetBSD__) */ # endif /* !defined(__NetBSD__) */
start = find_partition_start (os_dev); start = find_partition_start (os_dev);