Host filesystem access
Hi,
Here is a patch to make it possible to access the host filesystem from grub-emu. This is especially useful for debugging purposes and will make my life easier ;-).
This also adds a dummy disk which is used to give the host filesystem a name. It is not particularly clean, but adding this as a network is even worse. This can be used to access host filesystems on other systems as well.
I will commit this after the weekend, if no-one objects.
--
Marco
2007-05-17 Marco Gerards <[email protected]>
* conf/i386-pc.rmk (grub_emu_SOURCES): Add disk/host.c' and util/hostfs.c'.
* disk/host.c: New file.
* util/hostfs.c: Likewise.
* fs/hfsplus.c (grub_hfsplus_mount): When reading out of disk, return `GRUB_ERR_BAD_FS'.
* fs/sfs.c (grub_sfs_mount): Likewise.
* fs/xfs.c (grub_xfs_mount): Likewise.
* include/grub/disk.h (enum grub_disk_dev_id): Add `GRUB_DISK_DEVICE_HOST_ID'.
* util/grub-emu.c (main): Initialize and de-initialize hostfs.
Index: conf/i386-pc.rmk
===================================================================
RCS file: /sources/grub/grub2/conf/i386-pc.rmk,v
retrieving revision 1.77
i386-pc.rmk +2 -2
@@ -90,7 +90,7 @@ grub_emu_SOURCES = commands/boot.c comma commands/terminal.c commands/ls.c commands/test.c \ commands/search.c commands/blocklist.c \ commands/i386/pc/halt.c commands/i386/pc/reboot.c \ - disk/loopback.c disk/raid.c disk/lvm.c \ + disk/host.c disk/loopback.c disk/raid.c disk/lvm.c \ fs/affs.c fs/ext2.c fs/fat.c fs/fshelp.c fs/hfs.c fs/iso9660.c \ fs/jfs.c fs/minix.c fs/sfs.c fs/ufs.c fs/xfs.c fs/hfsplus.c \ io/gzio.c \
@@ -104,7 +104,7 @@ grub_emu_SOURCES = commands/boot.c comma normal/menu.c normal/menu_entry.c normal/misc.c normal/script.c \ partmap/amiga.c partmap/apple.c partmap/pc.c partmap/sun.c \ partmap/acorn.c partmap/gpt.c \ - util/console.c util/grub-emu.c util/misc.c \ + util/console.c util/hostfs.c util/grub-emu.c util/misc.c \ util/biosdisk.c util/getroot.c \ util/i386/pc/misc.c grub_emu_init.c
Index: disk/host.c
===================================================================
RCS file: disk/host.c
host.c new file +94 -0
94 lines not on this page · raw message
Index: fs/affs.c
===================================================================
RCS file: /sources/grub/grub2/fs/affs.c,v
retrieving revision 1.4
affs.c +3 -0
@@ -249,6 +249,9 @@ grub_affs_mount (grub_disk_t disk)return data; fail: +if (grub_errno ==GRUB_ERR_OUT_OF_RANGE ) +grub_error (GRUB_ERR_BAD_FS ,"not a affs filesystem" ); +grub_free (data);grub_free (rootblock);return 0 ;
Index: fs/hfsplus.c
===================================================================
RCS file: /sources/grub/grub2/fs/hfsplus.c,v
retrieving revision 1.8
hfsplus.c +4 -0
@@ -482,6 +482,10 @@ grub_hfsplus_mount (grub_disk_t disk)return data; fail: + +if (grub_errno ==GRUB_ERR_OUT_OF_RANGE ) +grub_error (GRUB_ERR_BAD_FS ,"not a hfsplus filesystem" ); +grub_free (data);return 0 ; }
Index: fs/sfs.c
===================================================================
RCS file: /sources/grub/grub2/fs/sfs.c,v
retrieving revision 1.5
sfs.c +3 -0
@@ -317,6 +317,9 @@ grub_sfs_mount (grub_disk_t disk)return data; fail: +if (grub_errno ==GRUB_ERR_OUT_OF_RANGE ) +grub_error (GRUB_ERR_BAD_FS ,"not a sfs filesystem" ); +grub_free (data);grub_free (rootobjc_data);return 0 ;
Index: fs/xfs.c
===================================================================
RCS file: /sources/grub/grub2/fs/xfs.c,v
retrieving revision 1.8
xfs.c +3 -0
@@ -515,6 +515,9 @@ grub_xfs_mount (grub_disk_t disk)return data; fail: +if (grub_errno ==GRUB_ERR_OUT_OF_RANGE ) +grub_error (GRUB_ERR_BAD_FS ,"not an xfs filesystem" ); +grub_free (data);return 0 ;
Index: include/grub/disk.h
===================================================================
RCS file: /sources/grub/grub2/include/grub/disk.h,v retrieving revision 1.12
grub/disk.h +2 -1
@@ -34,7 +34,8 @@ enum grub_disk_dev_idGRUB_DISK_DEVICE_LOOPBACK_ID ,GRUB_DISK_DEVICE_EFIDISK_ID ,GRUB_DISK_DEVICE_RAID_ID , - GRUB_DISK_DEVICE_LVM_ID +GRUB_DISK_DEVICE_LVM_ID , + GRUB_DISK_DEVICE_HOST_ID };struct grub_disk ;
Index: util/grub-emu.c
===================================================================
RCS file: /sources/grub/grub2/util/grub-emu.c,v
retrieving revision 1.34
grub-emu.c +4 -0
@@ -185,6 +185,8 @@ main (int argc, char *argv[])/* XXX: This is a bit unportable. */ grub_util_biosdisk_init (args.dev_map); +grub_hostfs_init (); +grub_init_all ();/* Make sure that there is a root device. */
@@ -210,6 +212,8 @@ main (int argc, char *argv[])grub_fini_all (); +grub_hostfs_fini (); +grub_machine_fini ();return 0 ;
Index: util/hostfs.c
===================================================================
RCS file: util/hostfs.c
hostfs.c new file +131 -0
131 lines not on this page · raw message
Review
Quoted 3 lines · Marco Gerards
(quoted diff) +3
-0+ grub_error (GRUB_ERR_BAD_FS, "not a affs filesystem"); + grub_error (GRUB_ERR_BAD_FS, "not a hfsplus filesystem"); + grub_error (GRUB_ERR_BAD_FS, "not a sfs filesystem");
I think these should be "an" (but not sure about all them, any native English speaker around?).
grub-emu.c main (int argc, char *argv[]) · line 190
Quoted 10 lines
diff -u -p -u -p -r1.34
grub-emu.cgrub-emu.c +2
-0@@ -185,6 +185,8 @@ main (int argc, char *argv[])/* XXX: This is a bit unportable. */ grub_util_biosdisk_init (args.dev_map); +grub_hostfs_init (); +grub_init_all ();
I find it counter-intuitive that grub_init_all doesn't imply grub_hostfs_init; if there's a design reason for this, maybe the function should be renamed ? (how about grub_filesystems_init + grub_partmaps_init ?)
Signature · 4 lines
Robert Millan My spam trap is [email protected]. Note: this address is only intended for spam harvesters. Writing to it will get you added to my black list.
Quoted 7 lines · Robert Millan
Review
Quoted 3 lines · Marco Gerards
(quoted diff) +3
-0+ grub_error (GRUB_ERR_BAD_FS, "not a affs filesystem"); + grub_error (GRUB_ERR_BAD_FS, "not a hfsplus filesystem"); + grub_error (GRUB_ERR_BAD_FS, "not a sfs filesystem");I think these should be "an" (but not sure about all them, any native English speaker around?).
Ehm, yes, I think so :-)
Quoted 7 lines
Quoted 7 lines
diff -u -p -u -p -r1.34
grub-emu.cgrub-emu.c +0
-0@@ -185,6 +185,8 @@ main (int argc, char *argv[])/* XXX: This is a bit unportable. */ grub_util_biosdisk_init (args.dev_map);
Quoted 7 lines
grub-emu.c main (int argc, char *argv[]) · line 190
Quoted 3 lines
grub-emu.c +2
-0+grub_hostfs_init (); +grub_init_all ();I find it counter-intuitive that
grub_init_alldoesn't implygrub_hostfs_init; if there's a design reason for this, maybe the function should be renamed ? (how aboutgrub_filesystems_init+grub_partmaps_init?)
The reason why I did this is that hostfs is not a module. grub_init_all initializes all modules, there is no way you can split this up in an easy way.
The main thing I had some doubts on was if the dummy disk driver is way too ugly or not.
--
Marco
Quoted 8 lines · Marco Gerards
Quoted 4 lines
I find it counter-intuitive that
grub_init_alldoesn't implygrub_hostfs_init; if there's a design reason for this, maybe the function should be renamed ? (how aboutgrub_filesystems_init+grub_partmaps_init?)The reason why I did this is that hostfs is not a module.
grub_init_allinitializes all modules, there is no way you can split this up in an easy way.
But it could be renamed to grub_init_all_modules :-)
Signature · 4 lines
Robert Millan My spam trap is [email protected]. Note: this address is only intended for spam harvesters. Writing to it will get you added to my black list.
Quoted 7 lines · Robert Millan
Review
Quoted 3 lines · Marco Gerards
(quoted diff) +3
-0+ grub_error (GRUB_ERR_BAD_FS, "not a affs filesystem"); + grub_error (GRUB_ERR_BAD_FS, "not a hfsplus filesystem"); + grub_error (GRUB_ERR_BAD_FS, "not a sfs filesystem");I think these should be "an" (but not sure about all them, any native English speaker around?).
If the file system types are read as acronyms then they will start with a vowel sound and it sounds more natural to use 'an'. I am not sure what the offical grammer rule is though.
"affs filesystem" is filesystem doubled anyway. How about ".. filesystem is not of type hffs"?
Jan
Quoted 24 lines · Bruno Wolff III
Quoted 9 lines · Robert Millan
Review
Quoted 4 lines · Marco Gerards
(quoted diff) +3
-0+ grub_error (GRUB_ERR_BAD_FS, "not a affs filesystem"); + grub_error (GRUB_ERR_BAD_FS, "not a hfsplus filesystem"); + grub_error (GRUB_ERR_BAD_FS, "not a sfs filesystem");I think these should be "an" (but not sure about all them, any native English speaker around?).
If the file system types are read as acronyms then they will start with a vowel sound and it sounds more natural to use 'an'. I am not sure what the offical grammer rule is though.
_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 2 lines · Jan C. Kleinsorge
"affs filesystem" is filesystem doubled anyway. How about ".. filesystem is not of type hffs"?
Some acronyms appear to be designed on purpose to produce RAS syndrome... (GPT comes to mind here).
Maybe we should just accept it ;-)
Signature · 4 lines
Robert Millan My spam trap is [email protected]. Note: this address is only intended for spam harvesters. Writing to it will get you added to my black list.
Marco Gerards <[email protected]> writes:
Hi,
Quoted 10 lines
Here is a patch to make it possible to access the host filesystem from grub-emu. This is especially useful for debugging purposes and will make my life easier ;-).
This also adds a dummy disk which is used to give the host filesystem a name. It is not particularly clean, but adding this as a network is even worse. This can be used to access host filesystems on other systems as well.
I will commit this after the weekend, if no-one objects.
Actually, I have completely forgotten about this. It's has been committed now.
--
Marco