]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
file: ignore host disk in blocklist check
authorAndrei Borzenkov <arvidjaar@gmail.com>
Sat, 10 Oct 2015 07:02:20 +0000 (10:02 +0300)
committerAndrei Borzenkov <arvidjaar@gmail.com>
Sat, 10 Oct 2015 07:02:20 +0000 (10:02 +0300)
It cannot work anyway because host disk cannot be read. This fixes hostfs access
on native Windows build where filenames start with '\' or do not have initial
separator at all (d:\foo).

Issue was observed when running grub-fstest on Windows. On UNIX image name is
canonicalized to always start with `/' so this was not noticed.

This has side effect of allowing relative path names on host, but this already
was the case with `ls' command, so it just extends it to all commands.

Reported-By: Arch Stack <archstacker@gmail.com>
Also-By: Arch Stack <archstacker@gmail.com>
grub-core/kern/file.c

index 24da12bb99d12bbde0e2e4673e85ad78ce793558..3367485fb4d373661a09a2bb899d9fe95149d3d8 100644 (file)
@@ -89,7 +89,11 @@ grub_file_open (const char *name)
 
   file->device = device;
 
-  if (device->disk && file_name[0] != '/')
+  if (device->disk && file_name[0] != '/'
+#if defined(GRUB_UTIL) || defined(GRUB_MACHINE_EMU)
+      && grub_strcmp (device->disk->name, "host")
+#endif
+     )
     /* This is a block list.  */
     file->fs = &grub_fs_blocklist;
   else