]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2007-08-02 Marco Gerards <marco@gnu.org>
authormarco_g <marco_g@localhost>
Thu, 2 Aug 2007 17:24:06 +0000 (17:24 +0000)
committermarco_g <marco_g@localhost>
Thu, 2 Aug 2007 17:24:06 +0000 (17:24 +0000)
* 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.

ChangeLog
conf/i386-pc.mk
conf/i386-pc.rmk
disk/host.c [new file with mode: 0644]
fs/affs.c
fs/hfsplus.c
fs/sfs.c
fs/xfs.c
include/grub/disk.h
util/grub-emu.c
util/hostfs.c [new file with mode: 0644]

index 3f50ad897a696d786d64179942f652638f9e687a..1a68b800cde6bb1574bc51ddf7dd42aa2dc656d5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2007-08-02  Marco Gerards  <marco@gnu.org>
+
+       * 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.
+
 2007-07-24  Jerone Young  <jerone@gmail.com>
 
         * conf/i386-pc.rmk: Add Multiboot loader and multiboot 2 to multiboot
index cc67b891d672cd02bab0eb8e0137569e656de825..5ee235ac78eb942eb623f20298611691ea4ea04d 100644 (file)
@@ -502,7 +502,7 @@ grub_emu_SOURCES = commands/boot.c commands/cat.c commands/cmp.c    \
        commands/search.c commands/blocklist.c                          \
        commands/i386/pc/halt.c commands/i386/pc/reboot.c               \
        commands/i386/cpuid.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                                                       \
@@ -516,14 +516,14 @@ grub_emu_SOURCES = commands/boot.c commands/cat.c commands/cmp.c  \
        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
-CLEANFILES += grub-emu grub_emu-commands_boot.o grub_emu-commands_cat.o grub_emu-commands_cmp.o grub_emu-commands_configfile.o grub_emu-commands_echo.o grub_emu-commands_help.o grub_emu-commands_terminal.o grub_emu-commands_ls.o grub_emu-commands_test.o grub_emu-commands_search.o grub_emu-commands_blocklist.o grub_emu-commands_i386_pc_halt.o grub_emu-commands_i386_pc_reboot.o grub_emu-commands_i386_cpuid.o grub_emu-disk_loopback.o grub_emu-disk_raid.o grub_emu-disk_lvm.o grub_emu-fs_affs.o grub_emu-fs_ext2.o grub_emu-fs_fat.o grub_emu-fs_fshelp.o grub_emu-fs_hfs.o grub_emu-fs_iso9660.o grub_emu-fs_jfs.o grub_emu-fs_minix.o grub_emu-fs_sfs.o grub_emu-fs_ufs.o grub_emu-fs_xfs.o grub_emu-fs_hfsplus.o grub_emu-io_gzio.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_elf.o grub_emu-kern_env.o grub_emu-kern_err.o grub_emu-normal_execute.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-normal_lexer.o grub_emu-kern_loader.o grub_emu-kern_main.o grub_emu-kern_misc.o grub_emu-kern_parser.o grub_emu-grub_script_tab.o grub_emu-kern_partition.o grub_emu-kern_rescue.o grub_emu-kern_term.o grub_emu-normal_arg.o grub_emu-normal_cmdline.o grub_emu-normal_command.o grub_emu-normal_function.o grub_emu-normal_completion.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-normal_menu_entry.o grub_emu-normal_misc.o grub_emu-normal_script.o grub_emu-partmap_amiga.o grub_emu-partmap_apple.o grub_emu-partmap_pc.o grub_emu-partmap_sun.o grub_emu-partmap_acorn.o grub_emu-partmap_gpt.o grub_emu-util_console.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_biosdisk.o grub_emu-util_getroot.o grub_emu-util_i386_pc_misc.o grub_emu-grub_emu_init.o
-MOSTLYCLEANFILES += grub_emu-commands_boot.d grub_emu-commands_cat.d grub_emu-commands_cmp.d grub_emu-commands_configfile.d grub_emu-commands_echo.d grub_emu-commands_help.d grub_emu-commands_terminal.d grub_emu-commands_ls.d grub_emu-commands_test.d grub_emu-commands_search.d grub_emu-commands_blocklist.d grub_emu-commands_i386_pc_halt.d grub_emu-commands_i386_pc_reboot.d grub_emu-commands_i386_cpuid.d grub_emu-disk_loopback.d grub_emu-disk_raid.d grub_emu-disk_lvm.d grub_emu-fs_affs.d grub_emu-fs_ext2.d grub_emu-fs_fat.d grub_emu-fs_fshelp.d grub_emu-fs_hfs.d grub_emu-fs_iso9660.d grub_emu-fs_jfs.d grub_emu-fs_minix.d grub_emu-fs_sfs.d grub_emu-fs_ufs.d grub_emu-fs_xfs.d grub_emu-fs_hfsplus.d grub_emu-io_gzio.d grub_emu-kern_device.d grub_emu-kern_disk.d grub_emu-kern_dl.d grub_emu-kern_elf.d grub_emu-kern_env.d grub_emu-kern_err.d grub_emu-normal_execute.d grub_emu-kern_file.d grub_emu-kern_fs.d grub_emu-normal_lexer.d grub_emu-kern_loader.d grub_emu-kern_main.d grub_emu-kern_misc.d grub_emu-kern_parser.d grub_emu-grub_script_tab.d grub_emu-kern_partition.d grub_emu-kern_rescue.d grub_emu-kern_term.d grub_emu-normal_arg.d grub_emu-normal_cmdline.d grub_emu-normal_command.d grub_emu-normal_function.d grub_emu-normal_completion.d grub_emu-normal_main.d grub_emu-normal_menu.d grub_emu-normal_menu_entry.d grub_emu-normal_misc.d grub_emu-normal_script.d grub_emu-partmap_amiga.d grub_emu-partmap_apple.d grub_emu-partmap_pc.d grub_emu-partmap_sun.d grub_emu-partmap_acorn.d grub_emu-partmap_gpt.d grub_emu-util_console.d grub_emu-util_grub_emu.d grub_emu-util_misc.d grub_emu-util_biosdisk.d grub_emu-util_getroot.d grub_emu-util_i386_pc_misc.d grub_emu-grub_emu_init.d
+CLEANFILES += grub-emu grub_emu-commands_boot.o grub_emu-commands_cat.o grub_emu-commands_cmp.o grub_emu-commands_configfile.o grub_emu-commands_echo.o grub_emu-commands_help.o grub_emu-commands_terminal.o grub_emu-commands_ls.o grub_emu-commands_test.o grub_emu-commands_search.o grub_emu-commands_blocklist.o grub_emu-commands_i386_pc_halt.o grub_emu-commands_i386_pc_reboot.o grub_emu-commands_i386_cpuid.o grub_emu-disk_host.o grub_emu-disk_loopback.o grub_emu-disk_raid.o grub_emu-disk_lvm.o grub_emu-fs_affs.o grub_emu-fs_ext2.o grub_emu-fs_fat.o grub_emu-fs_fshelp.o grub_emu-fs_hfs.o grub_emu-fs_iso9660.o grub_emu-fs_jfs.o grub_emu-fs_minix.o grub_emu-fs_sfs.o grub_emu-fs_ufs.o grub_emu-fs_xfs.o grub_emu-fs_hfsplus.o grub_emu-io_gzio.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_elf.o grub_emu-kern_env.o grub_emu-kern_err.o grub_emu-normal_execute.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-normal_lexer.o grub_emu-kern_loader.o grub_emu-kern_main.o grub_emu-kern_misc.o grub_emu-kern_parser.o grub_emu-grub_script_tab.o grub_emu-kern_partition.o grub_emu-kern_rescue.o grub_emu-kern_term.o grub_emu-normal_arg.o grub_emu-normal_cmdline.o grub_emu-normal_command.o grub_emu-normal_function.o grub_emu-normal_completion.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-normal_menu_entry.o grub_emu-normal_misc.o grub_emu-normal_script.o grub_emu-partmap_amiga.o grub_emu-partmap_apple.o grub_emu-partmap_pc.o grub_emu-partmap_sun.o grub_emu-partmap_acorn.o grub_emu-partmap_gpt.o grub_emu-util_console.o grub_emu-util_hostfs.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_biosdisk.o grub_emu-util_getroot.o grub_emu-util_i386_pc_misc.o grub_emu-grub_emu_init.o
+MOSTLYCLEANFILES += grub_emu-commands_boot.d grub_emu-commands_cat.d grub_emu-commands_cmp.d grub_emu-commands_configfile.d grub_emu-commands_echo.d grub_emu-commands_help.d grub_emu-commands_terminal.d grub_emu-commands_ls.d grub_emu-commands_test.d grub_emu-commands_search.d grub_emu-commands_blocklist.d grub_emu-commands_i386_pc_halt.d grub_emu-commands_i386_pc_reboot.d grub_emu-commands_i386_cpuid.d grub_emu-disk_host.d grub_emu-disk_loopback.d grub_emu-disk_raid.d grub_emu-disk_lvm.d grub_emu-fs_affs.d grub_emu-fs_ext2.d grub_emu-fs_fat.d grub_emu-fs_fshelp.d grub_emu-fs_hfs.d grub_emu-fs_iso9660.d grub_emu-fs_jfs.d grub_emu-fs_minix.d grub_emu-fs_sfs.d grub_emu-fs_ufs.d grub_emu-fs_xfs.d grub_emu-fs_hfsplus.d grub_emu-io_gzio.d grub_emu-kern_device.d grub_emu-kern_disk.d grub_emu-kern_dl.d grub_emu-kern_elf.d grub_emu-kern_env.d grub_emu-kern_err.d grub_emu-normal_execute.d grub_emu-kern_file.d grub_emu-kern_fs.d grub_emu-normal_lexer.d grub_emu-kern_loader.d grub_emu-kern_main.d grub_emu-kern_misc.d grub_emu-kern_parser.d grub_emu-grub_script_tab.d grub_emu-kern_partition.d grub_emu-kern_rescue.d grub_emu-kern_term.d grub_emu-normal_arg.d grub_emu-normal_cmdline.d grub_emu-normal_command.d grub_emu-normal_function.d grub_emu-normal_completion.d grub_emu-normal_main.d grub_emu-normal_menu.d grub_emu-normal_menu_entry.d grub_emu-normal_misc.d grub_emu-normal_script.d grub_emu-partmap_amiga.d grub_emu-partmap_apple.d grub_emu-partmap_pc.d grub_emu-partmap_sun.d grub_emu-partmap_acorn.d grub_emu-partmap_gpt.d grub_emu-util_console.d grub_emu-util_hostfs.d grub_emu-util_grub_emu.d grub_emu-util_misc.d grub_emu-util_biosdisk.d grub_emu-util_getroot.d grub_emu-util_i386_pc_misc.d grub_emu-grub_emu_init.d
 
-grub-emu: $(grub_emu_DEPENDENCIES) grub_emu-commands_boot.o grub_emu-commands_cat.o grub_emu-commands_cmp.o grub_emu-commands_configfile.o grub_emu-commands_echo.o grub_emu-commands_help.o grub_emu-commands_terminal.o grub_emu-commands_ls.o grub_emu-commands_test.o grub_emu-commands_search.o grub_emu-commands_blocklist.o grub_emu-commands_i386_pc_halt.o grub_emu-commands_i386_pc_reboot.o grub_emu-commands_i386_cpuid.o grub_emu-disk_loopback.o grub_emu-disk_raid.o grub_emu-disk_lvm.o grub_emu-fs_affs.o grub_emu-fs_ext2.o grub_emu-fs_fat.o grub_emu-fs_fshelp.o grub_emu-fs_hfs.o grub_emu-fs_iso9660.o grub_emu-fs_jfs.o grub_emu-fs_minix.o grub_emu-fs_sfs.o grub_emu-fs_ufs.o grub_emu-fs_xfs.o grub_emu-fs_hfsplus.o grub_emu-io_gzio.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_elf.o grub_emu-kern_env.o grub_emu-kern_err.o grub_emu-normal_execute.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-normal_lexer.o grub_emu-kern_loader.o grub_emu-kern_main.o grub_emu-kern_misc.o grub_emu-kern_parser.o grub_emu-grub_script_tab.o grub_emu-kern_partition.o grub_emu-kern_rescue.o grub_emu-kern_term.o grub_emu-normal_arg.o grub_emu-normal_cmdline.o grub_emu-normal_command.o grub_emu-normal_function.o grub_emu-normal_completion.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-normal_menu_entry.o grub_emu-normal_misc.o grub_emu-normal_script.o grub_emu-partmap_amiga.o grub_emu-partmap_apple.o grub_emu-partmap_pc.o grub_emu-partmap_sun.o grub_emu-partmap_acorn.o grub_emu-partmap_gpt.o grub_emu-util_console.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_biosdisk.o grub_emu-util_getroot.o grub_emu-util_i386_pc_misc.o grub_emu-grub_emu_init.o
-       $(CC) -o $@ grub_emu-commands_boot.o grub_emu-commands_cat.o grub_emu-commands_cmp.o grub_emu-commands_configfile.o grub_emu-commands_echo.o grub_emu-commands_help.o grub_emu-commands_terminal.o grub_emu-commands_ls.o grub_emu-commands_test.o grub_emu-commands_search.o grub_emu-commands_blocklist.o grub_emu-commands_i386_pc_halt.o grub_emu-commands_i386_pc_reboot.o grub_emu-commands_i386_cpuid.o grub_emu-disk_loopback.o grub_emu-disk_raid.o grub_emu-disk_lvm.o grub_emu-fs_affs.o grub_emu-fs_ext2.o grub_emu-fs_fat.o grub_emu-fs_fshelp.o grub_emu-fs_hfs.o grub_emu-fs_iso9660.o grub_emu-fs_jfs.o grub_emu-fs_minix.o grub_emu-fs_sfs.o grub_emu-fs_ufs.o grub_emu-fs_xfs.o grub_emu-fs_hfsplus.o grub_emu-io_gzio.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_elf.o grub_emu-kern_env.o grub_emu-kern_err.o grub_emu-normal_execute.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-normal_lexer.o grub_emu-kern_loader.o grub_emu-kern_main.o grub_emu-kern_misc.o grub_emu-kern_parser.o grub_emu-grub_script_tab.o grub_emu-kern_partition.o grub_emu-kern_rescue.o grub_emu-kern_term.o grub_emu-normal_arg.o grub_emu-normal_cmdline.o grub_emu-normal_command.o grub_emu-normal_function.o grub_emu-normal_completion.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-normal_menu_entry.o grub_emu-normal_misc.o grub_emu-normal_script.o grub_emu-partmap_amiga.o grub_emu-partmap_apple.o grub_emu-partmap_pc.o grub_emu-partmap_sun.o grub_emu-partmap_acorn.o grub_emu-partmap_gpt.o grub_emu-util_console.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_biosdisk.o grub_emu-util_getroot.o grub_emu-util_i386_pc_misc.o grub_emu-grub_emu_init.o $(LDFLAGS) $(grub_emu_LDFLAGS)
+grub-emu: $(grub_emu_DEPENDENCIES) grub_emu-commands_boot.o grub_emu-commands_cat.o grub_emu-commands_cmp.o grub_emu-commands_configfile.o grub_emu-commands_echo.o grub_emu-commands_help.o grub_emu-commands_terminal.o grub_emu-commands_ls.o grub_emu-commands_test.o grub_emu-commands_search.o grub_emu-commands_blocklist.o grub_emu-commands_i386_pc_halt.o grub_emu-commands_i386_pc_reboot.o grub_emu-commands_i386_cpuid.o grub_emu-disk_host.o grub_emu-disk_loopback.o grub_emu-disk_raid.o grub_emu-disk_lvm.o grub_emu-fs_affs.o grub_emu-fs_ext2.o grub_emu-fs_fat.o grub_emu-fs_fshelp.o grub_emu-fs_hfs.o grub_emu-fs_iso9660.o grub_emu-fs_jfs.o grub_emu-fs_minix.o grub_emu-fs_sfs.o grub_emu-fs_ufs.o grub_emu-fs_xfs.o grub_emu-fs_hfsplus.o grub_emu-io_gzio.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_elf.o grub_emu-kern_env.o grub_emu-kern_err.o grub_emu-normal_execute.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-normal_lexer.o grub_emu-kern_loader.o grub_emu-kern_main.o grub_emu-kern_misc.o grub_emu-kern_parser.o grub_emu-grub_script_tab.o grub_emu-kern_partition.o grub_emu-kern_rescue.o grub_emu-kern_term.o grub_emu-normal_arg.o grub_emu-normal_cmdline.o grub_emu-normal_command.o grub_emu-normal_function.o grub_emu-normal_completion.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-normal_menu_entry.o grub_emu-normal_misc.o grub_emu-normal_script.o grub_emu-partmap_amiga.o grub_emu-partmap_apple.o grub_emu-partmap_pc.o grub_emu-partmap_sun.o grub_emu-partmap_acorn.o grub_emu-partmap_gpt.o grub_emu-util_console.o grub_emu-util_hostfs.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_biosdisk.o grub_emu-util_getroot.o grub_emu-util_i386_pc_misc.o grub_emu-grub_emu_init.o
+       $(CC) -o $@ grub_emu-commands_boot.o grub_emu-commands_cat.o grub_emu-commands_cmp.o grub_emu-commands_configfile.o grub_emu-commands_echo.o grub_emu-commands_help.o grub_emu-commands_terminal.o grub_emu-commands_ls.o grub_emu-commands_test.o grub_emu-commands_search.o grub_emu-commands_blocklist.o grub_emu-commands_i386_pc_halt.o grub_emu-commands_i386_pc_reboot.o grub_emu-commands_i386_cpuid.o grub_emu-disk_host.o grub_emu-disk_loopback.o grub_emu-disk_raid.o grub_emu-disk_lvm.o grub_emu-fs_affs.o grub_emu-fs_ext2.o grub_emu-fs_fat.o grub_emu-fs_fshelp.o grub_emu-fs_hfs.o grub_emu-fs_iso9660.o grub_emu-fs_jfs.o grub_emu-fs_minix.o grub_emu-fs_sfs.o grub_emu-fs_ufs.o grub_emu-fs_xfs.o grub_emu-fs_hfsplus.o grub_emu-io_gzio.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_elf.o grub_emu-kern_env.o grub_emu-kern_err.o grub_emu-normal_execute.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-normal_lexer.o grub_emu-kern_loader.o grub_emu-kern_main.o grub_emu-kern_misc.o grub_emu-kern_parser.o grub_emu-grub_script_tab.o grub_emu-kern_partition.o grub_emu-kern_rescue.o grub_emu-kern_term.o grub_emu-normal_arg.o grub_emu-normal_cmdline.o grub_emu-normal_command.o grub_emu-normal_function.o grub_emu-normal_completion.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-normal_menu_entry.o grub_emu-normal_misc.o grub_emu-normal_script.o grub_emu-partmap_amiga.o grub_emu-partmap_apple.o grub_emu-partmap_pc.o grub_emu-partmap_sun.o grub_emu-partmap_acorn.o grub_emu-partmap_gpt.o grub_emu-util_console.o grub_emu-util_hostfs.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_biosdisk.o grub_emu-util_getroot.o grub_emu-util_i386_pc_misc.o grub_emu-grub_emu_init.o $(LDFLAGS) $(grub_emu_LDFLAGS)
 
 grub_emu-commands_boot.o: commands/boot.c
        $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -MD -c -o $@ $<
@@ -581,6 +581,10 @@ grub_emu-commands_i386_cpuid.o: commands/i386/cpuid.c
        $(CC) -Icommands/i386 -I$(srcdir)/commands/i386 $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -MD -c -o $@ $<
 -include grub_emu-commands_i386_cpuid.d
 
+grub_emu-disk_host.o: disk/host.c
+       $(CC) -Idisk -I$(srcdir)/disk $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -MD -c -o $@ $<
+-include grub_emu-disk_host.d
+
 grub_emu-disk_loopback.o: disk/loopback.c
        $(CC) -Idisk -I$(srcdir)/disk $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -MD -c -o $@ $<
 -include grub_emu-disk_loopback.d
@@ -785,6 +789,10 @@ grub_emu-util_console.o: util/console.c
        $(CC) -Iutil -I$(srcdir)/util $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -MD -c -o $@ $<
 -include grub_emu-util_console.d
 
+grub_emu-util_hostfs.o: util/hostfs.c
+       $(CC) -Iutil -I$(srcdir)/util $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -MD -c -o $@ $<
+-include grub_emu-util_hostfs.d
+
 grub_emu-util_grub_emu.o: util/grub-emu.c
        $(CC) -Iutil -I$(srcdir)/util $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -MD -c -o $@ $<
 -include grub_emu-util_grub_emu.d
index b71709aeb00e8e3b212209d2a2d42cacff4dd82a..9adf67a33e426fab197216673e71fc552c02b13b 100644 (file)
@@ -94,7 +94,7 @@ grub_emu_SOURCES = commands/boot.c commands/cat.c commands/cmp.c      \
        commands/search.c commands/blocklist.c                          \
        commands/i386/pc/halt.c commands/i386/pc/reboot.c               \
        commands/i386/cpuid.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                                                       \
@@ -108,7 +108,7 @@ grub_emu_SOURCES = commands/boot.c commands/cat.c commands/cmp.c    \
        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
 
diff --git a/disk/host.c b/disk/host.c
new file mode 100644 (file)
index 0000000..5b3c4f0
--- /dev/null
@@ -0,0 +1,93 @@
+/* host.c - Dummy disk driver to provide access to the hosts filesystem  */
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2007  Free Software Foundation, Inc.
+ *
+ *  GRUB is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  GRUB is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* When using the disk, make a reference to this module.  Otherwise
+   the user will end up with a useless module :-).  */
+
+#include <grub/dl.h>
+#include <grub/disk.h>
+
+int grub_disk_host_i_want_a_reference;
+
+static int
+grub_host_iterate (int (*hook) (const char *name))
+{
+  if (hook ("host"))
+    return 1;
+  return 0;
+}
+
+static grub_err_t
+grub_host_open (const char *name __attribute((unused)), grub_disk_t disk)
+{
+  disk->total_sectors = 0;
+  disk->id = (int) "host";
+  
+  disk->has_partitions = 0;
+  disk->data = 0;
+
+  return GRUB_ERR_NONE;
+}
+
+static void
+grub_host_close (grub_disk_t disk __attribute((unused)))
+{
+}
+
+static grub_err_t
+grub_host_read (grub_disk_t disk __attribute((unused)),
+               grub_disk_addr_t sector __attribute((unused)),
+               grub_size_t size __attribute((unused)),
+               char *buf __attribute((unused)))
+{
+  return GRUB_ERR_OUT_OF_RANGE;
+}
+
+static grub_err_t
+grub_host_write (grub_disk_t disk __attribute ((unused)),
+                    grub_disk_addr_t sector __attribute ((unused)),
+                    grub_size_t size __attribute ((unused)),
+                    const char *buf __attribute ((unused)))
+{
+  return GRUB_ERR_OUT_OF_RANGE;
+}
+
+static struct grub_disk_dev grub_host_dev =
+  {
+    /* The only important line in this file :-) */
+    .name = "host",
+    .id = GRUB_DISK_DEVICE_HOST_ID,
+    .iterate = grub_host_iterate,
+    .open = grub_host_open,
+    .close = grub_host_close,
+    .read = grub_host_read,
+    .write = grub_host_write,
+    .next = 0
+  };
+
+GRUB_MOD_INIT(host)
+{
+  (void) mod;                  /* To stop warning. */
+  grub_disk_dev_register (&grub_host_dev);
+}
+
+GRUB_MOD_FINI(host)
+{
+  grub_disk_dev_unregister (&grub_host_dev);
+}
index 46a9ef18a3f2ea3beef30c03834a99f18c49c53a..e19f878c3efee3b88010ddbf707ad4b41e289201 100644 (file)
--- a/fs/affs.c
+++ b/fs/affs.c
@@ -248,6 +248,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 an affs filesystem");
+
   grub_free (data);
   grub_free (rootblock);
   return 0;
index 55a702c9a25b9142be2b444ad83b99221c1a0ff2..d771ae3019c84caf84271bc696ba4155cde7b37c 100644 (file)
@@ -481,6 +481,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 fc35eaa1596d3b948075eb9f98c03ab6e58708a2..79de60e7aa6d65f328168277bae5d8f03cb44719 100644 (file)
--- a/fs/sfs.c
+++ b/fs/sfs.c
@@ -316,6 +316,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 an sfs filesystem");
+
   grub_free (data);
   grub_free (rootobjc_data);
   return 0;
index 48f682e73ba4ee3f6950c5b062ef47bf4901ad09..e7b529368f416d5b584329ddc3b0355e0a6d3994 100644 (file)
--- a/fs/xfs.c
+++ b/fs/xfs.c
@@ -514,6 +514,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 2fe1cea6e9bfcaf2b1237f6ac53699e1b254b67d..6a067bffb6b839405fe0c4571d108463b8698b24 100644 (file)
@@ -33,7 +33,8 @@ enum grub_disk_dev_id
     GRUB_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 c377ada77c7ebd681799fed30f4bc275c9a107ed..1ac37da5c2a9f8a2412ef464929bfef54f2e0c63 100644 (file)
@@ -175,6 +175,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.  */
@@ -204,6 +206,8 @@ main (int argc, char *argv[])
 
   grub_fini_all ();
 
+  grub_hostfs_fini ();
+
   grub_machine_fini ();
   
   return 0;
diff --git a/util/hostfs.c b/util/hostfs.c
new file mode 100644 (file)
index 0000000..2fdc358
--- /dev/null
@@ -0,0 +1,130 @@
+/* hostfs.c - Dummy filesystem to provide access to the hosts filesystem  */
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2007  Free Software Foundation, Inc.
+ *
+ *  GRUB is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  GRUB is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/fs.h>
+#include <grub/file.h>
+#include <grub/disk.h>
+#include <grub/misc.h>
+
+#include <dirent.h>
+#include <stdio.h>
+
+static grub_err_t
+grub_hostfs_dir (grub_device_t device, const char *path, 
+                int (*hook) (const char *filename, int dir))
+{
+  DIR *dir;
+
+  /* Check if the disk is our dummy disk.  */
+  if (grub_strcmp (device->disk->name, "host"))
+    return grub_error (GRUB_ERR_BAD_FS, "not a hostfs");
+
+  dir = opendir (path);
+  if (! dir)
+    return grub_error (GRUB_ERR_BAD_FILENAME,
+                      "can't open the hostfs directory `%s'", path);
+
+  while (1)
+    {
+      struct dirent *de;
+
+      de = readdir (dir);
+      if (! de)
+       break;
+
+      hook (de->d_name, de->d_type == DT_DIR);
+    }
+
+  closedir (dir);
+
+  return GRUB_ERR_NONE;
+}
+
+/* Open a file named NAME and initialize FILE.  */
+static grub_err_t
+grub_hostfs_open (struct grub_file *file, const char *name)
+{
+  FILE *f;
+
+  f = fopen (name, "r");
+  if (! f)
+    return grub_error (GRUB_ERR_BAD_FILENAME,
+                      "can't open `%s'", name);
+  file->data = f;
+
+  fseek (f, 0, SEEK_END);
+  file->size = ftell (f);
+  fseek (f, 0, SEEK_SET);
+
+  return GRUB_ERR_NONE;
+}
+
+static grub_ssize_t
+grub_hostfs_read (grub_file_t file, char *buf, grub_size_t len)
+{
+  FILE *f;
+
+  f = (FILE *) file->data;
+  int s= fread (buf, 1, len, f);
+
+  return s;
+}
+
+static grub_err_t
+grub_hostfs_close (grub_file_t file)
+{
+  FILE *f;
+
+  f = (FILE *) file->data;
+  fclose (f);
+
+  return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_hostfs_label (grub_device_t device __attribute ((unused)),
+                  char **label __attribute ((unused)))
+{
+  return GRUB_ERR_NONE;
+}
+
+static struct grub_fs grub_hostfs_fs =
+  {
+    .name = "hostfs",
+    .dir = grub_hostfs_dir,
+    .open = grub_hostfs_open,
+    .read = grub_hostfs_read,
+    .close = grub_hostfs_close,
+    .label = grub_hostfs_label,
+    .next = 0
+  };
+
+\f
+
+void
+grub_hostfs_init (void)
+{
+  grub_fs_register (&grub_hostfs_fs);
+}
+
+void
+grub_hostfs_fini (void)
+{
+  grub_fs_unregister (&grub_hostfs_fs);
+}