Skip to contentSkip to conversation

file: ignore host disk in blocklist check

PATCH In review Andrei Borzenkov 3 participants 3 messages Sep 18, 2015 – Nov 4, 2015 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 file: ignore host disk in blocklist check

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.

---
 grub-core/kern/file.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
grub-core/kern/file.c +5 -1
index 24da12b..3367485 100644
@@ -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
Signature · 1 line
tg: (c93d3e6..) u/hostfs-windows (depends on: master)
#2 lore raw

It works!
Thank you!

Quoted 41 lines · Andrei Borzenkov

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.

---
 grub-core/kern/file.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
grub-core/kern/file.c +5 -2
index 24da12b..3367485 100644
@@ -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
--

tg: (c93d3e6..) u/hostfs-windows (depends on: master)

#3 lore raw
In reply to Andrei Borzenkov
Quoted 2 lines · Andrei Borzenkov

It cannot work anyway because host disk cannot be read. This fixes hostfs

access

Quoted 1 line

on native Windows build where filenames start with '\' or do not have

initial

Quoted 3 lines

separator at all (d:\foo).

Issue was observed when running grub-fstest on Windows. On UNIX image

name is

Quoted 3 lines

canonicalized to always start with `/' so this was not noticed.

This has side effect of allowing relative path names on host, but this

already

Quoted 14 lines

was the case with `ls' command, so it just extends it to all commands.

---
 grub-core/kern/file.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
grub-core/kern/file.c +0 -0
index 24da12b..3367485 100644

grub-core/kern/file.c grub_file_open (const char *name) · line 95

Quoted 8 lines
grub-core/kern/file.c +4 -1
@@ -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

I don't particularly like this code but have no better idea. So go ahead, just add a comment why it's needed

Quoted 11 lines
grub-core/kern/file.c +1 -1
+     )
     /* This is a block list.  */
     file->fs = &grub_fs_blocklist;
   else
--

tg: (c93d3e6..) u/hostfs-windows (depends on: master)

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel