2005-10-09 Marco Gerards <mgerards@xs4all.nl>

Add support for the SFS filesystem.

	* fs/sfs.c: New file.

	* DISTLIST: Added `fs/sfs.c'.

	* conf/i386-pc.rmk (grub_setup_SOURCES): Add `fs/sfs.c'.
	(grub_probefs_SOURCES): Likewise.
	(grub_emu_SOURCES): Likewise.
	(pkgdata_MODULES): Add `sfs.mod'.
	(sfs_mod_SOURCES): New variable.
	(sfs_mod_CFLAGS): Likewise.
	(sfs_mod_LDFLAGS): Likewise.

	* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Add `fs/sfs.c'.
	(pkgdata_MODULES): Add `sfs.mod'.
	(sfs_mod_SOURCES): New variable.
	(sfs_mod_CFLAGS): Likewise.

	* util/grub-emu.c (main): Call `grub_sfs_init' and
	`grub_sfs_fini'.

	* include/grub/fs.h (grub_sfs_init): New prototype.
	(grub_sfs_fini): Likewise.
This commit is contained in:
marco_g 2005-10-09 13:03:53 +00:00
parent 5a2e94fb1c
commit 9a90987706
8 changed files with 765 additions and 20 deletions

View file

@ -1,3 +1,30 @@
2005-10-09 Marco Gerards <mgerards@xs4all.nl>
Add support for the SFS filesystem.
* fs/sfs.c: New file.
* DISTLIST: Added `fs/sfs.c'.
* conf/i386-pc.rmk (grub_setup_SOURCES): Add `fs/sfs.c'.
(grub_probefs_SOURCES): Likewise.
(grub_emu_SOURCES): Likewise.
(pkgdata_MODULES): Add `sfs.mod'.
(sfs_mod_SOURCES): New variable.
(sfs_mod_CFLAGS): Likewise.
(sfs_mod_LDFLAGS): Likewise.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Add `fs/sfs.c'.
(pkgdata_MODULES): Add `sfs.mod'.
(sfs_mod_SOURCES): New variable.
(sfs_mod_CFLAGS): Likewise.
* util/grub-emu.c (main): Call `grub_sfs_init' and
`grub_sfs_fini'.
* include/grub/fs.h (grub_sfs_init): New prototype.
(grub_sfs_fini): Likewise.
2005-10-07 Marco Gerards <mgerards@xs4all.nl> 2005-10-07 Marco Gerards <mgerards@xs4all.nl>
Add support for the AFFS filesystem. Add support for the AFFS filesystem.

View file

@ -64,6 +64,7 @@ fs/iso9660.c
fs/jfs.c fs/jfs.c
fs/minix.c fs/minix.c
fs/ufs.c fs/ufs.c
fs/sfs.c
fs/xfs.c fs/xfs.c
hello/hello.c hello/hello.c
include/grub/arg.h include/grub/arg.h

View file

@ -313,12 +313,12 @@ grub_mkimage_LDFLAGS = $(LIBLZO)
grub_setup_SOURCES = util/i386/pc/grub-setup.c util/i386/pc/biosdisk.c \ grub_setup_SOURCES = util/i386/pc/grub-setup.c util/i386/pc/biosdisk.c \
util/misc.c util/i386/pc/getroot.c kern/device.c kern/disk.c \ util/misc.c util/i386/pc/getroot.c kern/device.c kern/disk.c \
kern/err.c kern/misc.c fs/fat.c fs/ext2.c fs/xfs.c fs/affs.c \ kern/err.c kern/misc.c fs/fat.c fs/ext2.c fs/xfs.c fs/affs.c \
kern/partition.c partmap/pc.c \ fs/sfs.c kern/partition.c partmap/pc.c \
fs/ufs.c fs/minix.c fs/hfs.c fs/jfs.c kern/file.c kern/fs.c kern/env.c fs/fshelp.c fs/ufs.c fs/minix.c fs/hfs.c fs/jfs.c kern/file.c kern/fs.c kern/env.c fs/fshelp.c
CLEANFILES += grub-setup grub_setup-util_i386_pc_grub_setup.o grub_setup-util_i386_pc_biosdisk.o grub_setup-util_misc.o grub_setup-util_i386_pc_getroot.o grub_setup-kern_device.o grub_setup-kern_disk.o grub_setup-kern_err.o grub_setup-kern_misc.o grub_setup-fs_fat.o grub_setup-fs_ext2.o grub_setup-fs_xfs.o grub_setup-fs_affs.o grub_setup-kern_partition.o grub_setup-partmap_pc.o grub_setup-fs_ufs.o grub_setup-fs_minix.o grub_setup-fs_hfs.o grub_setup-fs_jfs.o grub_setup-kern_file.o grub_setup-kern_fs.o grub_setup-kern_env.o grub_setup-fs_fshelp.o CLEANFILES += grub-setup grub_setup-util_i386_pc_grub_setup.o grub_setup-util_i386_pc_biosdisk.o grub_setup-util_misc.o grub_setup-util_i386_pc_getroot.o grub_setup-kern_device.o grub_setup-kern_disk.o grub_setup-kern_err.o grub_setup-kern_misc.o grub_setup-fs_fat.o grub_setup-fs_ext2.o grub_setup-fs_xfs.o grub_setup-fs_affs.o grub_setup-fs_sfs.o grub_setup-kern_partition.o grub_setup-partmap_pc.o grub_setup-fs_ufs.o grub_setup-fs_minix.o grub_setup-fs_hfs.o grub_setup-fs_jfs.o grub_setup-kern_file.o grub_setup-kern_fs.o grub_setup-kern_env.o grub_setup-fs_fshelp.o
MOSTLYCLEANFILES += grub_setup-util_i386_pc_grub_setup.d grub_setup-util_i386_pc_biosdisk.d grub_setup-util_misc.d grub_setup-util_i386_pc_getroot.d grub_setup-kern_device.d grub_setup-kern_disk.d grub_setup-kern_err.d grub_setup-kern_misc.d grub_setup-fs_fat.d grub_setup-fs_ext2.d grub_setup-fs_xfs.d grub_setup-fs_affs.d grub_setup-kern_partition.d grub_setup-partmap_pc.d grub_setup-fs_ufs.d grub_setup-fs_minix.d grub_setup-fs_hfs.d grub_setup-fs_jfs.d grub_setup-kern_file.d grub_setup-kern_fs.d grub_setup-kern_env.d grub_setup-fs_fshelp.d MOSTLYCLEANFILES += grub_setup-util_i386_pc_grub_setup.d grub_setup-util_i386_pc_biosdisk.d grub_setup-util_misc.d grub_setup-util_i386_pc_getroot.d grub_setup-kern_device.d grub_setup-kern_disk.d grub_setup-kern_err.d grub_setup-kern_misc.d grub_setup-fs_fat.d grub_setup-fs_ext2.d grub_setup-fs_xfs.d grub_setup-fs_affs.d grub_setup-fs_sfs.d grub_setup-kern_partition.d grub_setup-partmap_pc.d grub_setup-fs_ufs.d grub_setup-fs_minix.d grub_setup-fs_hfs.d grub_setup-fs_jfs.d grub_setup-kern_file.d grub_setup-kern_fs.d grub_setup-kern_env.d grub_setup-fs_fshelp.d
grub-setup: grub_setup-util_i386_pc_grub_setup.o grub_setup-util_i386_pc_biosdisk.o grub_setup-util_misc.o grub_setup-util_i386_pc_getroot.o grub_setup-kern_device.o grub_setup-kern_disk.o grub_setup-kern_err.o grub_setup-kern_misc.o grub_setup-fs_fat.o grub_setup-fs_ext2.o grub_setup-fs_xfs.o grub_setup-fs_affs.o grub_setup-kern_partition.o grub_setup-partmap_pc.o grub_setup-fs_ufs.o grub_setup-fs_minix.o grub_setup-fs_hfs.o grub_setup-fs_jfs.o grub_setup-kern_file.o grub_setup-kern_fs.o grub_setup-kern_env.o grub_setup-fs_fshelp.o grub-setup: grub_setup-util_i386_pc_grub_setup.o grub_setup-util_i386_pc_biosdisk.o grub_setup-util_misc.o grub_setup-util_i386_pc_getroot.o grub_setup-kern_device.o grub_setup-kern_disk.o grub_setup-kern_err.o grub_setup-kern_misc.o grub_setup-fs_fat.o grub_setup-fs_ext2.o grub_setup-fs_xfs.o grub_setup-fs_affs.o grub_setup-fs_sfs.o grub_setup-kern_partition.o grub_setup-partmap_pc.o grub_setup-fs_ufs.o grub_setup-fs_minix.o grub_setup-fs_hfs.o grub_setup-fs_jfs.o grub_setup-kern_file.o grub_setup-kern_fs.o grub_setup-kern_env.o grub_setup-fs_fshelp.o
$(BUILD_CC) -o $@ $^ $(BUILD_LDFLAGS) $(grub_setup_LDFLAGS) $(BUILD_CC) -o $@ $^ $(BUILD_LDFLAGS) $(grub_setup_LDFLAGS)
grub_setup-util_i386_pc_grub_setup.o: util/i386/pc/grub-setup.c grub_setup-util_i386_pc_grub_setup.o: util/i386/pc/grub-setup.c
@ -417,6 +417,14 @@ grub_setup-fs_affs.d: fs/affs.c
-include grub_setup-fs_affs.d -include grub_setup-fs_affs.d
grub_setup-fs_sfs.o: fs/sfs.c
$(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_setup_CFLAGS) -c -o $@ $<
grub_setup-fs_sfs.d: fs/sfs.c
set -e; $(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_setup_CFLAGS) -M $< | sed 's,sfs\.o[ :]*,grub_setup-fs_sfs.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include grub_setup-fs_sfs.d
grub_setup-kern_partition.o: kern/partition.c grub_setup-kern_partition.o: kern/partition.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_setup_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_setup_CFLAGS) -c -o $@ $<
@ -529,11 +537,11 @@ grub_probefs_SOURCES = util/i386/pc/grub-probefs.c \
kern/device.c kern/disk.c kern/err.c kern/misc.c fs/fat.c \ kern/device.c kern/disk.c kern/err.c kern/misc.c fs/fat.c \
fs/ext2.c kern/partition.c partmap/pc.c fs/ufs.c fs/minix.c \ fs/ext2.c kern/partition.c partmap/pc.c fs/ufs.c fs/minix.c \
fs/hfs.c fs/jfs.c kern/fs.c kern/env.c fs/fshelp.c fs/xfs.c \ fs/hfs.c fs/jfs.c kern/fs.c kern/env.c fs/fshelp.c fs/xfs.c \
fs/affs.c fs/affs.c fs/sfs.c
CLEANFILES += grub-probefs grub_probefs-util_i386_pc_grub_probefs.o grub_probefs-util_i386_pc_biosdisk.o grub_probefs-util_misc.o grub_probefs-util_i386_pc_getroot.o grub_probefs-kern_device.o grub_probefs-kern_disk.o grub_probefs-kern_err.o grub_probefs-kern_misc.o grub_probefs-fs_fat.o grub_probefs-fs_ext2.o grub_probefs-kern_partition.o grub_probefs-partmap_pc.o grub_probefs-fs_ufs.o grub_probefs-fs_minix.o grub_probefs-fs_hfs.o grub_probefs-fs_jfs.o grub_probefs-kern_fs.o grub_probefs-kern_env.o grub_probefs-fs_fshelp.o grub_probefs-fs_xfs.o grub_probefs-fs_affs.o CLEANFILES += grub-probefs grub_probefs-util_i386_pc_grub_probefs.o grub_probefs-util_i386_pc_biosdisk.o grub_probefs-util_misc.o grub_probefs-util_i386_pc_getroot.o grub_probefs-kern_device.o grub_probefs-kern_disk.o grub_probefs-kern_err.o grub_probefs-kern_misc.o grub_probefs-fs_fat.o grub_probefs-fs_ext2.o grub_probefs-kern_partition.o grub_probefs-partmap_pc.o grub_probefs-fs_ufs.o grub_probefs-fs_minix.o grub_probefs-fs_hfs.o grub_probefs-fs_jfs.o grub_probefs-kern_fs.o grub_probefs-kern_env.o grub_probefs-fs_fshelp.o grub_probefs-fs_xfs.o grub_probefs-fs_affs.o grub_probefs-fs_sfs.o
MOSTLYCLEANFILES += grub_probefs-util_i386_pc_grub_probefs.d grub_probefs-util_i386_pc_biosdisk.d grub_probefs-util_misc.d grub_probefs-util_i386_pc_getroot.d grub_probefs-kern_device.d grub_probefs-kern_disk.d grub_probefs-kern_err.d grub_probefs-kern_misc.d grub_probefs-fs_fat.d grub_probefs-fs_ext2.d grub_probefs-kern_partition.d grub_probefs-partmap_pc.d grub_probefs-fs_ufs.d grub_probefs-fs_minix.d grub_probefs-fs_hfs.d grub_probefs-fs_jfs.d grub_probefs-kern_fs.d grub_probefs-kern_env.d grub_probefs-fs_fshelp.d grub_probefs-fs_xfs.d grub_probefs-fs_affs.d MOSTLYCLEANFILES += grub_probefs-util_i386_pc_grub_probefs.d grub_probefs-util_i386_pc_biosdisk.d grub_probefs-util_misc.d grub_probefs-util_i386_pc_getroot.d grub_probefs-kern_device.d grub_probefs-kern_disk.d grub_probefs-kern_err.d grub_probefs-kern_misc.d grub_probefs-fs_fat.d grub_probefs-fs_ext2.d grub_probefs-kern_partition.d grub_probefs-partmap_pc.d grub_probefs-fs_ufs.d grub_probefs-fs_minix.d grub_probefs-fs_hfs.d grub_probefs-fs_jfs.d grub_probefs-kern_fs.d grub_probefs-kern_env.d grub_probefs-fs_fshelp.d grub_probefs-fs_xfs.d grub_probefs-fs_affs.d grub_probefs-fs_sfs.d
grub-probefs: grub_probefs-util_i386_pc_grub_probefs.o grub_probefs-util_i386_pc_biosdisk.o grub_probefs-util_misc.o grub_probefs-util_i386_pc_getroot.o grub_probefs-kern_device.o grub_probefs-kern_disk.o grub_probefs-kern_err.o grub_probefs-kern_misc.o grub_probefs-fs_fat.o grub_probefs-fs_ext2.o grub_probefs-kern_partition.o grub_probefs-partmap_pc.o grub_probefs-fs_ufs.o grub_probefs-fs_minix.o grub_probefs-fs_hfs.o grub_probefs-fs_jfs.o grub_probefs-kern_fs.o grub_probefs-kern_env.o grub_probefs-fs_fshelp.o grub_probefs-fs_xfs.o grub_probefs-fs_affs.o grub-probefs: grub_probefs-util_i386_pc_grub_probefs.o grub_probefs-util_i386_pc_biosdisk.o grub_probefs-util_misc.o grub_probefs-util_i386_pc_getroot.o grub_probefs-kern_device.o grub_probefs-kern_disk.o grub_probefs-kern_err.o grub_probefs-kern_misc.o grub_probefs-fs_fat.o grub_probefs-fs_ext2.o grub_probefs-kern_partition.o grub_probefs-partmap_pc.o grub_probefs-fs_ufs.o grub_probefs-fs_minix.o grub_probefs-fs_hfs.o grub_probefs-fs_jfs.o grub_probefs-kern_fs.o grub_probefs-kern_env.o grub_probefs-fs_fshelp.o grub_probefs-fs_xfs.o grub_probefs-fs_affs.o grub_probefs-fs_sfs.o
$(BUILD_CC) -o $@ $^ $(BUILD_LDFLAGS) $(grub_probefs_LDFLAGS) $(BUILD_CC) -o $@ $^ $(BUILD_LDFLAGS) $(grub_probefs_LDFLAGS)
grub_probefs-util_i386_pc_grub_probefs.o: util/i386/pc/grub-probefs.c grub_probefs-util_i386_pc_grub_probefs.o: util/i386/pc/grub-probefs.c
@ -704,6 +712,14 @@ grub_probefs-fs_affs.d: fs/affs.c
-include grub_probefs-fs_affs.d -include grub_probefs-fs_affs.d
grub_probefs-fs_sfs.o: fs/sfs.c
$(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_probefs_CFLAGS) -c -o $@ $<
grub_probefs-fs_sfs.d: fs/sfs.c
set -e; $(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_probefs_CFLAGS) -M $< | sed 's,sfs\.o[ :]*,grub_probefs-fs_sfs.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include grub_probefs-fs_sfs.d
# For grub-emu. # For grub-emu.
grub_emu_SOURCES = commands/boot.c commands/cat.c commands/cmp.c \ grub_emu_SOURCES = commands/boot.c commands/cat.c commands/cmp.c \
@ -712,8 +728,8 @@ grub_emu_SOURCES = commands/boot.c commands/cat.c commands/cmp.c \
commands/timeout.c \ commands/timeout.c \
commands/i386/pc/halt.c commands/i386/pc/reboot.c \ commands/i386/pc/halt.c commands/i386/pc/reboot.c \
disk/loopback.c \ disk/loopback.c \
fs/affs.c fs/ext2.c fs/fat.c fs/fshelp.c fs/hfs.c fs/iso9660.c \ fs/affs.c fs/ext2.c fs/fat.c fs/fshelp.c fs/hfs.c \
fs/jfs.c fs/minix.c fs/ufs.c fs/xfs.c \ fs/iso9660.c fs/jfs.c fs/minix.c fs/sfs.c fs/ufs.c fs/xfs.c \
io/gzio.c \ io/gzio.c \
kern/device.c kern/disk.c kern/dl.c kern/env.c kern/err.c \ kern/device.c kern/disk.c kern/dl.c kern/env.c kern/err.c \
kern/file.c kern/fs.c kern/loader.c kern/main.c kern/misc.c \ kern/file.c kern/fs.c kern/loader.c kern/main.c kern/misc.c \
@ -725,10 +741,10 @@ grub_emu_SOURCES = commands/boot.c commands/cat.c commands/cmp.c \
util/console.c util/grub-emu.c util/misc.c \ util/console.c util/grub-emu.c util/misc.c \
util/i386/pc/biosdisk.c util/i386/pc/getroot.c \ util/i386/pc/biosdisk.c util/i386/pc/getroot.c \
util/i386/pc/misc.c util/i386/pc/misc.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_default.o grub_emu-commands_help.o grub_emu-commands_terminal.o grub_emu-commands_ls.o grub_emu-commands_search.o grub_emu-commands_timeout.o grub_emu-commands_i386_pc_halt.o grub_emu-commands_i386_pc_reboot.o grub_emu-disk_loopback.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_ufs.o grub_emu-fs_xfs.o grub_emu-io_gzio.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_env.o grub_emu-kern_err.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-kern_loader.o grub_emu-kern_main.o grub_emu-kern_misc.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_completion.o grub_emu-normal_context.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-normal_menu_entry.o grub_emu-normal_misc.o grub_emu-partmap_amiga.o grub_emu-partmap_apple.o grub_emu-partmap_pc.o grub_emu-partmap_sun.o grub_emu-util_console.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_i386_pc_biosdisk.o grub_emu-util_i386_pc_getroot.o grub_emu-util_i386_pc_misc.o 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_default.o grub_emu-commands_help.o grub_emu-commands_terminal.o grub_emu-commands_ls.o grub_emu-commands_search.o grub_emu-commands_timeout.o grub_emu-commands_i386_pc_halt.o grub_emu-commands_i386_pc_reboot.o grub_emu-disk_loopback.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-io_gzio.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_env.o grub_emu-kern_err.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-kern_loader.o grub_emu-kern_main.o grub_emu-kern_misc.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_completion.o grub_emu-normal_context.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-normal_menu_entry.o grub_emu-normal_misc.o grub_emu-partmap_amiga.o grub_emu-partmap_apple.o grub_emu-partmap_pc.o grub_emu-partmap_sun.o grub_emu-util_console.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_i386_pc_biosdisk.o grub_emu-util_i386_pc_getroot.o grub_emu-util_i386_pc_misc.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_default.d grub_emu-commands_help.d grub_emu-commands_terminal.d grub_emu-commands_ls.d grub_emu-commands_search.d grub_emu-commands_timeout.d grub_emu-commands_i386_pc_halt.d grub_emu-commands_i386_pc_reboot.d grub_emu-disk_loopback.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_ufs.d grub_emu-fs_xfs.d grub_emu-io_gzio.d grub_emu-kern_device.d grub_emu-kern_disk.d grub_emu-kern_dl.d grub_emu-kern_env.d grub_emu-kern_err.d grub_emu-kern_file.d grub_emu-kern_fs.d grub_emu-kern_loader.d grub_emu-kern_main.d grub_emu-kern_misc.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_completion.d grub_emu-normal_context.d grub_emu-normal_main.d grub_emu-normal_menu.d grub_emu-normal_menu_entry.d grub_emu-normal_misc.d grub_emu-partmap_amiga.d grub_emu-partmap_apple.d grub_emu-partmap_pc.d grub_emu-partmap_sun.d grub_emu-util_console.d grub_emu-util_grub_emu.d grub_emu-util_misc.d grub_emu-util_i386_pc_biosdisk.d grub_emu-util_i386_pc_getroot.d grub_emu-util_i386_pc_misc.d MOSTLYCLEANFILES += grub_emu-commands_boot.d grub_emu-commands_cat.d grub_emu-commands_cmp.d grub_emu-commands_configfile.d grub_emu-commands_default.d grub_emu-commands_help.d grub_emu-commands_terminal.d grub_emu-commands_ls.d grub_emu-commands_search.d grub_emu-commands_timeout.d grub_emu-commands_i386_pc_halt.d grub_emu-commands_i386_pc_reboot.d grub_emu-disk_loopback.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-io_gzio.d grub_emu-kern_device.d grub_emu-kern_disk.d grub_emu-kern_dl.d grub_emu-kern_env.d grub_emu-kern_err.d grub_emu-kern_file.d grub_emu-kern_fs.d grub_emu-kern_loader.d grub_emu-kern_main.d grub_emu-kern_misc.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_completion.d grub_emu-normal_context.d grub_emu-normal_main.d grub_emu-normal_menu.d grub_emu-normal_menu_entry.d grub_emu-normal_misc.d grub_emu-partmap_amiga.d grub_emu-partmap_apple.d grub_emu-partmap_pc.d grub_emu-partmap_sun.d grub_emu-util_console.d grub_emu-util_grub_emu.d grub_emu-util_misc.d grub_emu-util_i386_pc_biosdisk.d grub_emu-util_i386_pc_getroot.d grub_emu-util_i386_pc_misc.d
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_default.o grub_emu-commands_help.o grub_emu-commands_terminal.o grub_emu-commands_ls.o grub_emu-commands_search.o grub_emu-commands_timeout.o grub_emu-commands_i386_pc_halt.o grub_emu-commands_i386_pc_reboot.o grub_emu-disk_loopback.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_ufs.o grub_emu-fs_xfs.o grub_emu-io_gzio.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_env.o grub_emu-kern_err.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-kern_loader.o grub_emu-kern_main.o grub_emu-kern_misc.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_completion.o grub_emu-normal_context.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-normal_menu_entry.o grub_emu-normal_misc.o grub_emu-partmap_amiga.o grub_emu-partmap_apple.o grub_emu-partmap_pc.o grub_emu-partmap_sun.o grub_emu-util_console.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_i386_pc_biosdisk.o grub_emu-util_i386_pc_getroot.o grub_emu-util_i386_pc_misc.o 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_default.o grub_emu-commands_help.o grub_emu-commands_terminal.o grub_emu-commands_ls.o grub_emu-commands_search.o grub_emu-commands_timeout.o grub_emu-commands_i386_pc_halt.o grub_emu-commands_i386_pc_reboot.o grub_emu-disk_loopback.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-io_gzio.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_env.o grub_emu-kern_err.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-kern_loader.o grub_emu-kern_main.o grub_emu-kern_misc.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_completion.o grub_emu-normal_context.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-normal_menu_entry.o grub_emu-normal_misc.o grub_emu-partmap_amiga.o grub_emu-partmap_apple.o grub_emu-partmap_pc.o grub_emu-partmap_sun.o grub_emu-util_console.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_i386_pc_biosdisk.o grub_emu-util_i386_pc_getroot.o grub_emu-util_i386_pc_misc.o
$(BUILD_CC) -o $@ $^ $(BUILD_LDFLAGS) $(grub_emu_LDFLAGS) $(BUILD_CC) -o $@ $^ $(BUILD_LDFLAGS) $(grub_emu_LDFLAGS)
grub_emu-commands_boot.o: commands/boot.c grub_emu-commands_boot.o: commands/boot.c
@ -899,6 +915,14 @@ grub_emu-fs_minix.d: fs/minix.c
-include grub_emu-fs_minix.d -include grub_emu-fs_minix.d
grub_emu-fs_sfs.o: fs/sfs.c
$(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
grub_emu-fs_sfs.d: fs/sfs.c
set -e; $(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,sfs\.o[ :]*,grub_emu-fs_sfs.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include grub_emu-fs_sfs.d
grub_emu-fs_ufs.o: fs/ufs.c grub_emu-fs_ufs.o: fs/ufs.c
$(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
@ -1219,7 +1243,7 @@ pkgdata_MODULES = _chain.mod _linux.mod linux.mod fat.mod ufs.mod \
apple.mod pc.mod sun.mod loopback.mod reboot.mod halt.mod \ apple.mod pc.mod sun.mod loopback.mod reboot.mod halt.mod \
help.mod default.mod timeout.mod configfile.mod vbe.mod \ help.mod default.mod timeout.mod configfile.mod vbe.mod \
vesafb.mod vbetest.mod vbeinfo.mod search.mod gzio.mod \ vesafb.mod vbetest.mod vbeinfo.mod search.mod gzio.mod \
terminfo.mod serial.mod xfs.mod affs.mod terminfo.mod serial.mod xfs.mod affs.mod sfs.mod
# For _chain.mod. # For _chain.mod.
_chain_mod_SOURCES = loader/i386/pc/chainloader.c _chain_mod_SOURCES = loader/i386/pc/chainloader.c
@ -1787,6 +1811,57 @@ fs-affs.lst: fs/affs.c genfslist.sh
affs_mod_CFLAGS = $(COMMON_CFLAGS) affs_mod_CFLAGS = $(COMMON_CFLAGS)
affs_mod_LDFLAGS = $(COMMON_LDFLAGS) affs_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For sfs.mod.
sfs_mod_SOURCES = fs/sfs.c
CLEANFILES += sfs.mod mod-sfs.o mod-sfs.c pre-sfs.o sfs_mod-fs_sfs.o def-sfs.lst und-sfs.lst
MOSTLYCLEANFILES += sfs_mod-fs_sfs.d
DEFSYMFILES += def-sfs.lst
UNDSYMFILES += und-sfs.lst
sfs.mod: pre-sfs.o mod-sfs.o
-rm -f $@
$(LD) $(sfs_mod_LDFLAGS) $(LDFLAGS) -r -d -o $@ $^
$(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
pre-sfs.o: sfs_mod-fs_sfs.o
-rm -f $@
$(LD) $(sfs_mod_LDFLAGS) -r -d -o $@ $^
mod-sfs.o: mod-sfs.c
$(CC) $(CPPFLAGS) $(CFLAGS) $(sfs_mod_CFLAGS) -c -o $@ $<
mod-sfs.c: moddep.lst genmodsrc.sh
sh $(srcdir)/genmodsrc.sh 'sfs' $< > $@ || (rm -f $@; exit 1)
def-sfs.lst: pre-sfs.o
$(NM) -g --defined-only -P -p $< | sed 's/^\([^ ]*\).*/\1 sfs/' > $@
und-sfs.lst: pre-sfs.o
echo 'sfs' > $@
$(NM) -u -P -p $< | cut -f1 -d' ' >> $@
sfs_mod-fs_sfs.o: fs/sfs.c
$(CC) -Ifs -I$(srcdir)/fs $(CPPFLAGS) $(CFLAGS) $(sfs_mod_CFLAGS) -c -o $@ $<
sfs_mod-fs_sfs.d: fs/sfs.c
set -e; $(CC) -Ifs -I$(srcdir)/fs $(CPPFLAGS) $(CFLAGS) $(sfs_mod_CFLAGS) -M $< | sed 's,sfs\.o[ :]*,sfs_mod-fs_sfs.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include sfs_mod-fs_sfs.d
CLEANFILES += cmd-sfs.lst fs-sfs.lst
COMMANDFILES += cmd-sfs.lst
FSFILES += fs-sfs.lst
cmd-sfs.lst: fs/sfs.c gencmdlist.sh
set -e; $(CC) -Ifs -I$(srcdir)/fs $(CPPFLAGS) $(CFLAGS) $(sfs_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh sfs > $@ || (rm -f $@; exit 1)
fs-sfs.lst: fs/sfs.c genfslist.sh
set -e; $(CC) -Ifs -I$(srcdir)/fs $(CPPFLAGS) $(CFLAGS) $(sfs_mod_CFLAGS) -E $< | sh $(srcdir)/genfslist.sh sfs > $@ || (rm -f $@; exit 1)
sfs_mod_CFLAGS = $(COMMON_CFLAGS)
sfs_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For _linux.mod. # For _linux.mod.
_linux_mod_SOURCES = loader/i386/pc/linux.c _linux_mod_SOURCES = loader/i386/pc/linux.c
CLEANFILES += _linux.mod mod-_linux.o mod-_linux.c pre-_linux.o _linux_mod-loader_i386_pc_linux.o def-_linux.lst und-_linux.lst CLEANFILES += _linux.mod mod-_linux.o mod-_linux.c pre-_linux.o _linux_mod-loader_i386_pc_linux.o def-_linux.lst und-_linux.lst

View file

@ -63,7 +63,7 @@ grub_mkimage_LDFLAGS = $(LIBLZO)
grub_setup_SOURCES = util/i386/pc/grub-setup.c util/i386/pc/biosdisk.c \ grub_setup_SOURCES = util/i386/pc/grub-setup.c util/i386/pc/biosdisk.c \
util/misc.c util/i386/pc/getroot.c kern/device.c kern/disk.c \ util/misc.c util/i386/pc/getroot.c kern/device.c kern/disk.c \
kern/err.c kern/misc.c fs/fat.c fs/ext2.c fs/xfs.c fs/affs.c \ kern/err.c kern/misc.c fs/fat.c fs/ext2.c fs/xfs.c fs/affs.c \
kern/partition.c partmap/pc.c \ fs/sfs.c kern/partition.c partmap/pc.c \
fs/ufs.c fs/minix.c fs/hfs.c fs/jfs.c kern/file.c kern/fs.c kern/env.c fs/fshelp.c fs/ufs.c fs/minix.c fs/hfs.c fs/jfs.c kern/file.c kern/fs.c kern/env.c fs/fshelp.c
# For grub-mkdevicemap. # For grub-mkdevicemap.
@ -75,7 +75,7 @@ grub_probefs_SOURCES = util/i386/pc/grub-probefs.c \
kern/device.c kern/disk.c kern/err.c kern/misc.c fs/fat.c \ kern/device.c kern/disk.c kern/err.c kern/misc.c fs/fat.c \
fs/ext2.c kern/partition.c partmap/pc.c fs/ufs.c fs/minix.c \ fs/ext2.c kern/partition.c partmap/pc.c fs/ufs.c fs/minix.c \
fs/hfs.c fs/jfs.c kern/fs.c kern/env.c fs/fshelp.c fs/xfs.c \ fs/hfs.c fs/jfs.c kern/fs.c kern/env.c fs/fshelp.c fs/xfs.c \
fs/affs.c fs/affs.c fs/sfs.c
# For grub-emu. # For grub-emu.
grub_emu_SOURCES = commands/boot.c commands/cat.c commands/cmp.c \ grub_emu_SOURCES = commands/boot.c commands/cat.c commands/cmp.c \
@ -85,7 +85,7 @@ grub_emu_SOURCES = commands/boot.c commands/cat.c commands/cmp.c \
commands/i386/pc/halt.c commands/i386/pc/reboot.c \ commands/i386/pc/halt.c commands/i386/pc/reboot.c \
disk/loopback.c \ disk/loopback.c \
fs/affs.c fs/ext2.c fs/fat.c fs/fshelp.c fs/hfs.c fs/iso9660.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/ufs.c fs/xfs.c \ fs/jfs.c fs/minix.c fs/sfs.c fs/ufs.c fs/xfs.c \
io/gzio.c \ io/gzio.c \
kern/device.c kern/disk.c kern/dl.c kern/env.c kern/err.c \ kern/device.c kern/disk.c kern/dl.c kern/env.c kern/err.c \
kern/file.c kern/fs.c kern/loader.c kern/main.c kern/misc.c \ kern/file.c kern/fs.c kern/loader.c kern/main.c kern/misc.c \
@ -117,7 +117,7 @@ pkgdata_MODULES = _chain.mod _linux.mod linux.mod fat.mod ufs.mod \
apple.mod pc.mod sun.mod loopback.mod reboot.mod halt.mod \ apple.mod pc.mod sun.mod loopback.mod reboot.mod halt.mod \
help.mod default.mod timeout.mod configfile.mod vbe.mod \ help.mod default.mod timeout.mod configfile.mod vbe.mod \
vesafb.mod vbetest.mod vbeinfo.mod search.mod gzio.mod \ vesafb.mod vbetest.mod vbeinfo.mod search.mod gzio.mod \
terminfo.mod serial.mod xfs.mod affs.mod terminfo.mod serial.mod xfs.mod affs.mod sfs.mod
# For _chain.mod. # For _chain.mod.
_chain_mod_SOURCES = loader/i386/pc/chainloader.c _chain_mod_SOURCES = loader/i386/pc/chainloader.c
@ -179,6 +179,11 @@ affs_mod_SOURCES = fs/affs.c
affs_mod_CFLAGS = $(COMMON_CFLAGS) affs_mod_CFLAGS = $(COMMON_CFLAGS)
affs_mod_LDFLAGS = $(COMMON_LDFLAGS) affs_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For sfs.mod.
sfs_mod_SOURCES = fs/sfs.c
sfs_mod_CFLAGS = $(COMMON_CFLAGS)
sfs_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For _linux.mod. # For _linux.mod.
_linux_mod_SOURCES = loader/i386/pc/linux.c _linux_mod_SOURCES = loader/i386/pc/linux.c
_linux_mod_CFLAGS = $(COMMON_CFLAGS) _linux_mod_CFLAGS = $(COMMON_CFLAGS)

View file

@ -40,7 +40,7 @@ grub_emu_SOURCES = commands/boot.c commands/cat.c commands/cmp.c \
commands/ieee1275/halt.c commands/ieee1275/reboot.c \ commands/ieee1275/halt.c commands/ieee1275/reboot.c \
disk/loopback.c \ disk/loopback.c \
fs/affs.c fs/ext2.c fs/fat.c fs/fshelp.c fs/hfs.c fs/iso9660.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/ufs.c fs/xfs.c \ fs/jfs.c fs/minix.c fs/sfs.c fs/ufs.c fs/xfs.c \
io/gzio.c \ io/gzio.c \
kern/device.c kern/disk.c kern/dl.c kern/env.c kern/err.c \ kern/device.c kern/disk.c kern/dl.c kern/env.c kern/err.c \
kern/file.c kern/fs.c kern/loader.c kern/main.c kern/misc.c \ kern/file.c kern/fs.c kern/loader.c kern/main.c kern/misc.c \
@ -77,7 +77,7 @@ pkgdata_MODULES = _linux.mod linux.mod fat.mod ufs.mod ext2.mod minix.mod \
boot.mod cmp.mod cat.mod terminal.mod fshelp.mod amiga.mod apple.mod \ boot.mod cmp.mod cat.mod terminal.mod fshelp.mod amiga.mod apple.mod \
pc.mod suspend.mod loopback.mod help.mod reboot.mod halt.mod sun.mod \ pc.mod suspend.mod loopback.mod help.mod reboot.mod halt.mod sun.mod \
default.mod timeout.mod configfile.mod search.mod gzio.mod xfs.mod \ default.mod timeout.mod configfile.mod search.mod gzio.mod xfs.mod \
affs.mod affs.mod sfs.mod
# For fshelp.mod. # For fshelp.mod.
fshelp_mod_SOURCES = fs/fshelp.c fshelp_mod_SOURCES = fs/fshelp.c
@ -119,6 +119,10 @@ xfs_mod_CFLAGS = $(COMMON_CFLAGS)
affs_mod_SOURCES = fs/affs.c affs_mod_SOURCES = fs/affs.c
affs_mod_CFLAGS = $(COMMON_CFLAGS) affs_mod_CFLAGS = $(COMMON_CFLAGS)
# For sfs.mod.
sfs_mod_SOURCES = fs/sfs.c
sfs_mod_CFLAGS = $(COMMON_CFLAGS)
# For _linux.mod. # For _linux.mod.
_linux_mod_SOURCES = loader/powerpc/ieee1275/linux.c _linux_mod_SOURCES = loader/powerpc/ieee1275/linux.c
_linux_mod_CFLAGS = $(COMMON_CFLAGS) _linux_mod_CFLAGS = $(COMMON_CFLAGS)

629
fs/sfs.c Normal file
View file

@ -0,0 +1,629 @@
/* sfs.c - Amiga Smart FileSystem. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2005 Free Software Foundation, Inc.
*
* This program 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 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <grub/err.h>
#include <grub/file.h>
#include <grub/mm.h>
#include <grub/misc.h>
#include <grub/disk.h>
#include <grub/dl.h>
#include <grub/types.h>
#include <grub/fshelp.h>
/* The common header for a block. */
struct grub_sfs_bheader
{
grub_uint8_t magic[4];
grub_uint32_t chksum;
grub_uint32_t ipointtomyself;
} __attribute__ ((packed));
/* The sfs rootblock. */
struct grub_sfs_rblock
{
struct grub_sfs_bheader header;
grub_uint32_t version;
grub_uint8_t unused1[36];
grub_uint32_t blocksize;
grub_uint8_t unused2[40];
grub_uint8_t unused3[8];
grub_uint32_t rootobject;
grub_uint32_t btree;
} __attribute__ ((packed));
/* A SFS object container. */
struct grub_sfs_obj
{
grub_uint8_t unused1[4];
grub_uint32_t nodeid;
grub_uint8_t unused2[4];
union
{
struct
{
grub_uint32_t first_block;
grub_uint32_t size;
} file __attribute__ ((packed));
struct
{
grub_uint32_t hashtable;
grub_uint32_t dir_objc;
} dir __attribute__ ((packed));
} file_dir;
grub_uint8_t unused3[4];
grub_uint8_t type;
grub_uint8_t filename[1];
grub_uint8_t comment[1];
} __attribute__ ((packed));
#define GRUB_SFS_TYPE_DELETED 32
#define GRUB_SFS_TYPE_SYMLINK 64
#define GRUB_SFS_TYPE_DIR 128
/* A SFS object container. */
struct grub_sfs_objc
{
struct grub_sfs_bheader header;
grub_uint32_t parent;
grub_uint32_t next;
grub_uint32_t prev;
/* The amount of objects depends on the blocksize. */
struct grub_sfs_obj objects[1];
} __attribute__ ((packed));
struct grub_sfs_btree_node
{
grub_uint32_t key;
grub_uint32_t data;
} __attribute__ ((packed));
struct grub_sfs_btree_extent
{
grub_uint32_t key;
grub_uint32_t next;
grub_uint32_t prev;
grub_uint16_t size;
} __attribute__ ((packed));
struct grub_sfs_btree
{
struct grub_sfs_bheader header;
grub_uint16_t nodes;
grub_uint8_t leaf;
grub_uint8_t nodesize;
/* Normally this can be kind of node, but just extents are
supported. */
struct grub_sfs_btree_node node[1];
} __attribute__ ((packed));
struct grub_fshelp_node
{
struct grub_sfs_data *data;
int block;
int size;
};
/* Information about a "mounted" sfs filesystem. */
struct grub_sfs_data
{
struct grub_sfs_rblock rblock;
struct grub_fshelp_node diropen;
grub_disk_t disk;
/* Blocksize in sectors. */
unsigned int blocksize;
/* Label of the filesystem. */
char *label;
};
#ifndef GRUB_UTIL
static grub_dl_t my_mod;
#endif
/* Lookup the extent starting with BLOCK in the filesystem described
by DATA. Return the extent size in SIZE and the following extent
in NEXTEXT. */
static grub_err_t
grub_sfs_read_extent (struct grub_sfs_data *data, unsigned int block,
int *size, int *nextext)
{
char *treeblock;
struct grub_sfs_btree *tree;
int i;
int next;
int prev;
treeblock = grub_malloc (data->blocksize);
if (!block)
return 0;
next = grub_be_to_cpu32 (data->rblock.btree);
tree = (struct grub_sfs_btree *) treeblock;
/* Handle this level in the btree. */
do
{
prev = 0;
grub_disk_read (data->disk, next, 0, data->blocksize, treeblock);
if (grub_errno)
{
grub_free (treeblock);
return grub_errno;
}
for (i = 0; i < tree->nodes; i++)
{
#define EXTNODE(tree, index) \
((struct grub_sfs_btree_node *) (((char *) &(tree)->node[0]) \
+ (index) * (tree)->nodesize))
/* Follow the tree down to the leaf level. */
if ((grub_be_to_cpu32 (EXTNODE(tree, i)->key) >= block)
&& !tree->leaf)
{
next = grub_be_to_cpu32 (EXTNODE (tree, i - 1)->data);
break;
}
/* In case the last node is reached just use that one, it is
the right match. */
if (i + 1 == tree->nodes && !tree->leaf)
{
next = grub_be_to_cpu32 (EXTNODE (tree, i)->data);
break;
}
/* If the leaf level is reached, just find the correct extent. */
if (grub_be_to_cpu32 (EXTNODE (tree, i)->key) == block && tree->leaf)
{
struct grub_sfs_btree_extent *extent;
extent = (struct grub_sfs_btree_extent *) EXTNODE (tree, i);
/* We found a correct leaf. */
*size = grub_be_to_cpu16 (extent->size);
*nextext = grub_be_to_cpu32 (extent->next);
grub_free (treeblock);
return 0;
}
#undef EXTNODE
}
} while (!tree->leaf);
grub_free (treeblock);
return grub_error (GRUB_ERR_FILE_READ_ERROR, "SFS extent not found");
}
static int
grub_sfs_read_block (grub_fshelp_node_t node, int fileblock)
{
int blk = node->block;
int size = 0;
int next = 0;
while (blk)
{
grub_err_t err;
/* In case of the first block we don't have to lookup the
extent, the minimum size is always 1. */
if (fileblock == 0)
return blk;
err = grub_sfs_read_extent (node->data, blk, &size, &next);
if (err)
return 0;
if (fileblock < size)
return fileblock + blk;
fileblock -= size;
blk = next;
}
grub_error (GRUB_ERR_FILE_READ_ERROR,
"reading a SFS block outside the extent");
return 0;
}
/* Read LEN bytes from the file described by DATA starting with byte
POS. Return the amount of read bytes in READ. */
static grub_ssize_t
grub_sfs_read_file (grub_fshelp_node_t node,
void (*read_hook) (unsigned long sector,
unsigned offset, unsigned length),
int pos, unsigned int len, char *buf)
{
return grub_fshelp_read_file (node->data->disk, node, read_hook,
pos, len, buf, grub_sfs_read_block,
node->size, 0);
}
static struct grub_sfs_data *
grub_sfs_mount (grub_disk_t disk)
{
struct grub_sfs_data *data;
struct grub_sfs_objc *rootobjc;
char *rootobjc_data = 0;
unsigned int blk;
data = grub_malloc (sizeof (*data));
if (!data)
return 0;
/* Read the rootblock. */
grub_disk_read (disk, 0, 0, sizeof (struct grub_sfs_rblock),
(char *) &data->rblock);
if (grub_errno)
goto fail;
/* Make sure this is a sfs filesystem. */
if (grub_strncmp (data->rblock.header.magic, "SFS", 4))
{
grub_error (GRUB_ERR_BAD_FS, "not a sfs filesystem");
goto fail;
}
data->blocksize = grub_be_to_cpu32 (data->rblock.blocksize);
rootobjc_data = grub_malloc (data->blocksize);
if (!rootobjc_data)
goto fail;
/* Read the root object container. */
grub_disk_read (disk, grub_be_to_cpu32 (data->rblock.rootobject), 0,
data->blocksize, rootobjc_data);
if (grub_errno)
goto fail;
rootobjc = (struct grub_sfs_objc *) rootobjc_data;
blk = grub_be_to_cpu32 (rootobjc->objects[0].file_dir.dir.dir_objc);
data->diropen.size = 0;
data->diropen.block = blk;
data->diropen.data = data;
data->disk = disk;
data->label = grub_strdup (rootobjc->objects[0].filename);
return data;
fail:
grub_free (data);
grub_free (rootobjc_data);
return 0;
}
static char *
grub_sfs_read_symlink (grub_fshelp_node_t node)
{
struct grub_sfs_data *data = node->data;
char *symlink;
char *block;
block = grub_malloc (data->blocksize);
if (!block)
return 0;
grub_disk_read (data->disk, node->block, 0, data->blocksize, block);
if (grub_errno)
{
grub_free (block);
return 0;
}
/* This is just a wild guess, but it always worked for me. How the
SLNK block looks like is not documented in the SFS docs. */
symlink = grub_strdup (&block[24]);
grub_free (block);
if (!symlink)
return 0;
return symlink;
}
static int
grub_sfs_iterate_dir (grub_fshelp_node_t dir,
int NESTED_FUNC_ATTR
(*hook) (const char *filename,
enum grub_fshelp_filetype filetype,
grub_fshelp_node_t node))
{
struct grub_fshelp_node *node = 0;
struct grub_sfs_data *data = dir->data;
char *objc_data;
struct grub_sfs_objc *objc;
unsigned int next = dir->block;
int pos;
auto int NESTED_FUNC_ATTR grub_sfs_create_node (const char *name, int block,
int size, int type);
int NESTED_FUNC_ATTR grub_sfs_create_node (const char *name, int block,
int size, int type)
{
node = grub_malloc (sizeof (*node));
if (!node)
return 1;
node->data = data;
node->size = size;
node->block = block;
return hook (name, type, node);
}
objc_data = grub_malloc (data->blocksize);
if (!objc_data)
goto fail;
/* The Object container can consist of multiple blocks, iterate over
every block. */
while (next)
{
grub_disk_read (data->disk, next, 0, data->blocksize, objc_data);
if (grub_errno)
goto fail;
objc = (struct grub_sfs_objc *) objc_data;
pos = (char *) &objc->objects[0] - (char *) objc;
/* Iterate over all entries in this block. */
while (pos + sizeof (struct grub_sfs_obj) < data->blocksize)
{
struct grub_sfs_obj *obj;
obj = (struct grub_sfs_obj *) ((char *) objc + pos);
char *filename = obj->filename;
int len;
enum grub_fshelp_filetype type;
unsigned int block;
/* The filename and comment dynamically increase the size of
the object. */
len = grub_strlen (filename);
len += grub_strlen (filename + len + 1);
pos += sizeof (*obj) + len;
/* Round up to a multiple of two bytes. */
pos = ((pos + 1) >> 1) << 1;
if (grub_strlen (filename) == 0)
continue;
/* First check if the file was not deleted. */
if (obj->type & GRUB_SFS_TYPE_DELETED)
continue;
else if (obj->type & GRUB_SFS_TYPE_SYMLINK)
type = GRUB_FSHELP_SYMLINK;
else if (obj->type & GRUB_SFS_TYPE_DIR)
type = GRUB_FSHELP_DIR;
else
type = GRUB_FSHELP_REG;
if (type == GRUB_FSHELP_DIR)
block = grub_be_to_cpu32 (obj->file_dir.dir.dir_objc);
else
block = grub_be_to_cpu32 (obj->file_dir.file.first_block);
if (grub_sfs_create_node (filename, block,
grub_be_to_cpu32 (obj->file_dir.file.size),
type))
{
grub_free (objc_data);
return 1;
}
}
next = grub_be_to_cpu32 (objc->next);
}
fail:
grub_free (objc_data);
return 1;
}
/* Open a file named NAME and initialize FILE. */
static grub_err_t
grub_sfs_open (struct grub_file *file, const char *name)
{
struct grub_sfs_data *data;
struct grub_fshelp_node *fdiro = 0;
#ifndef GRUB_UTIL
grub_dl_ref (my_mod);
#endif
data = grub_sfs_mount (file->device->disk);
if (!data)
goto fail;
grub_fshelp_find_file (name, &data->diropen, &fdiro, grub_sfs_iterate_dir,
grub_sfs_read_symlink, GRUB_FSHELP_REG);
if (grub_errno)
goto fail;
file->size = fdiro->size;
data->diropen = *fdiro;
grub_free (fdiro);
file->data = data;
file->offset = 0;
return 0;
fail:
if (data && fdiro != &data->diropen)
grub_free (fdiro);
grub_free (data->label);
grub_free (data);
#ifndef GRUB_UTIL
grub_dl_unref (my_mod);
#endif
return grub_errno;
}
static grub_err_t
grub_sfs_close (grub_file_t file)
{
grub_free (file->data);
#ifndef GRUB_UTIL
grub_dl_unref (my_mod);
#endif
return GRUB_ERR_NONE;
}
/* Read LEN bytes data from FILE into BUF. */
static grub_ssize_t
grub_sfs_read (grub_file_t file, char *buf, grub_ssize_t len)
{
struct grub_sfs_data *data = (struct grub_sfs_data *) file->data;
int size = grub_sfs_read_file (&data->diropen, file->read_hook,
file->offset, len, buf);
return size;
}
static grub_err_t
grub_sfs_dir (grub_device_t device, const char *path,
int (*hook) (const char *filename, int dir))
{
struct grub_sfs_data *data = 0;
struct grub_fshelp_node *fdiro = 0;
auto int NESTED_FUNC_ATTR iterate (const char *filename,
enum grub_fshelp_filetype filetype,
grub_fshelp_node_t node);
int NESTED_FUNC_ATTR iterate (const char *filename,
enum grub_fshelp_filetype filetype,
grub_fshelp_node_t node)
{
grub_free (node);
if (filetype == GRUB_FSHELP_DIR)
return hook (filename, 1);
else
return hook (filename, 0);
return 0;
}
#ifndef GRUB_UTIL
grub_dl_ref (my_mod);
#endif
data = grub_sfs_mount (device->disk);
if (!data)
goto fail;
grub_fshelp_find_file (path, &data->diropen, &fdiro, grub_sfs_iterate_dir,
grub_sfs_read_symlink, GRUB_FSHELP_DIR);
if (grub_errno)
goto fail;
grub_sfs_iterate_dir (fdiro, iterate);
fail:
if (data && fdiro != &data->diropen)
grub_free (fdiro);
grub_free (data->label);
grub_free (data);
#ifndef GRUB_UTIL
grub_dl_unref (my_mod);
#endif
return grub_errno;
}
static grub_err_t
grub_sfs_label (grub_device_t device, char **label)
{
struct grub_sfs_data *data;
grub_disk_t disk = device->disk;
data = grub_sfs_mount (disk);
if (data)
*label = data->label;
grub_free (data);
return grub_errno;
}
static struct grub_fs grub_sfs_fs =
{
.name = "sfs",
.dir = grub_sfs_dir,
.open = grub_sfs_open,
.read = grub_sfs_read,
.close = grub_sfs_close,
.label = grub_sfs_label,
.next = 0
};
#ifdef GRUB_UTIL
void
grub_sfs_init (void)
{
grub_fs_register (&grub_sfs_fs);
}
void
grub_sfs_fini (void)
{
grub_fs_unregister (&grub_sfs_fs);
}
#else /* ! GRUB_UTIL */
GRUB_MOD_INIT
{
grub_fs_register (&grub_sfs_fs);
my_mod = mod;
}
GRUB_MOD_FINI
{
grub_fs_unregister (&grub_sfs_fs);
}
#endif /* ! GRUB_UTIL */

View file

@ -89,6 +89,8 @@ void grub_xfs_init (void);
void grub_xfs_fini (void); void grub_xfs_fini (void);
void grub_affs_init (void); void grub_affs_init (void);
void grub_affs_fini (void); void grub_affs_fini (void);
void grub_sfs_init (void);
void grub_sfs_fini (void);
void grub_iso9660_init (void); void grub_iso9660_init (void);
#endif /* GRUB_UTIL */ #endif /* GRUB_UTIL */

View file

@ -204,6 +204,7 @@ main (int argc, char *argv[])
grub_hfs_init (); grub_hfs_init ();
grub_jfs_init (); grub_jfs_init ();
grub_xfs_init (); grub_xfs_init ();
grub_sfs_init ();
grub_affs_init (); grub_affs_init ();
grub_ls_init (); grub_ls_init ();
grub_boot_init (); grub_boot_init ();
@ -237,6 +238,7 @@ main (int argc, char *argv[])
grub_util_biosdisk_fini (); grub_util_biosdisk_fini ();
grub_normal_fini (); grub_normal_fini ();
grub_affs_fini (); grub_affs_fini ();
grub_sfs_fini ();
grub_xfs_fini (); grub_xfs_fini ();
grub_ufs_fini (); grub_ufs_fini ();
grub_ext2_fini (); grub_ext2_fini ();