Resolve the device returned by grub_find_root_device_from_mountinfo or
find_root_device_from_libzfs using grub_find_device. Reported by: Roderich Schupp.
This commit is contained in:
parent
6b978c4f04
commit
bd1a414714
1 changed files with 23 additions and 11 deletions
|
@ -467,7 +467,7 @@ grub_find_device (const char *path, dev_t dev)
|
||||||
char *
|
char *
|
||||||
grub_guess_root_device (const char *dir)
|
grub_guess_root_device (const char *dir)
|
||||||
{
|
{
|
||||||
char *os_dev;
|
char *os_dev = NULL;
|
||||||
#ifdef __GNU__
|
#ifdef __GNU__
|
||||||
file_t file;
|
file_t file;
|
||||||
mach_port_t *ports;
|
mach_port_t *ports;
|
||||||
|
@ -526,30 +526,42 @@ grub_guess_root_device (const char *dir)
|
||||||
mach_port_deallocate (mach_task_self (), file);
|
mach_port_deallocate (mach_task_self (), file);
|
||||||
#else /* !__GNU__ */
|
#else /* !__GNU__ */
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
dev_t dev;
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
os_dev = grub_find_root_device_from_mountinfo (dir, NULL);
|
if (!os_dev)
|
||||||
if (os_dev)
|
os_dev = grub_find_root_device_from_mountinfo (dir, NULL);
|
||||||
return os_dev;
|
|
||||||
#endif /* __linux__ */
|
#endif /* __linux__ */
|
||||||
|
|
||||||
#if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR)
|
#if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR)
|
||||||
os_dev = find_root_device_from_libzfs (dir);
|
if (!os_dev)
|
||||||
if (os_dev)
|
os_dev = find_root_device_from_libzfs (dir);
|
||||||
return os_dev;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (stat (dir, &st) < 0)
|
if (os_dev)
|
||||||
grub_util_error ("cannot stat `%s'", dir);
|
{
|
||||||
|
if (stat (os_dev, &st) >= 0)
|
||||||
|
dev = st.st_rdev;
|
||||||
|
else
|
||||||
|
grub_util_error ("cannot stat `%s'", os_dev);
|
||||||
|
free (os_dev);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (stat (dir, &st) >= 0)
|
||||||
|
dev = st.st_dev;
|
||||||
|
else
|
||||||
|
grub_util_error ("cannot stat `%s'", dir);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __CYGWIN__
|
#ifdef __CYGWIN__
|
||||||
/* Cygwin specific function. */
|
/* Cygwin specific function. */
|
||||||
os_dev = grub_find_device (dir, st.st_dev);
|
os_dev = grub_find_device (dir, dev);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
/* This might be truly slow, but is there any better way? */
|
/* This might be truly slow, but is there any better way? */
|
||||||
os_dev = grub_find_device ("/dev", st.st_dev);
|
os_dev = grub_find_device ("/dev", dev);
|
||||||
#endif
|
#endif
|
||||||
#endif /* !__GNU__ */
|
#endif /* !__GNU__ */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue