2009-08-28 Vladimir Serbinenko <phcoder@gmail.com>

Split befs.mod and afs.mod into *_be.mod and *.mod

	* conf/common.rmk (grub_probe_SOURCES): Add afs_be.c and befs_be.c.
	(grub_fstest_SOURCES): Likewise.
	(pkglib_MODULES): Add afs_be.mod and befs_be.mod.
	(afs_be_mod_SOURCES): New variable.
	(afs_be_mod_CFLAGS): Likewise.
	(afs_be_mod_LDFLAGS): Likewise.
	(befs_be_mod_SOURCES): Likewise.
	(befs_be_mod_CFLAGS): Likewise.
	(befs_be_mod_LDFLAGS): Likewise.
	* conf/i386-coreboot.rmk (grub_emu_SOURCES): Add afs_be.c and befs_be.c.
	* conf/i386-efi.rmk (grub_emu_SOURCES): Likewise.
	* conf/i386-ieee1275.rmk (grub_emu_SOURCES): Likewise.
	* conf/i386-pc.rmk (grub_setup_SOURCES): Likewise.
	(grub_emu_SOURCES): Likewise.
	* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise.
	* conf/sparc64-ieee1275.rmk (grub_emu_SOURCES): Likewise.
	* conf/x86_64-efi.rmk (grub_emu_SOURCES): Likewise.
	* fs/afs_be.c: New file.
	* fs/befs_be.c: New file.
	* fs/afs.c (GRUB_AFS_FSNAME_SUFFIX): New definition.
	(GRUB_AFS_FSNAME): Use GRUB_AFS_FSNAME_SUFFIX.
	(U16): Replaced with ...
	(grub_afs_to_cpu16): ...this. All users updated.
	(U32): Replaced with ...
	(grub_afs_to_cpu32): ...this. All users updated.
	(U64): Replaced with ...
	(grub_afs_to_cpu64): ...this. All users updated.
	(GRUB_AFS_BO_LITTLE_ENDIAN): Remove.
	(GRUB_AFS_BO_BIG_ENDIAN): Likewise.
	(grub_afs_validate_sblock): Check only one endiannness.
	(GRUB_MOD_INIT (befs)) [MODE_BIGENDIAN && MODE_BFS]: Rename to ..
	(GRUB_MOD_INIT (befs_be)) [MODE_BIGENDIAN && MODE_BFS]: ... this.
	(GRUB_MOD_INIT (afs)) [MODE_BIGENDIAN && !MODE_BFS]: Rename to ..
	(GRUB_MOD_INIT (afs_be)) [MODE_BIGENDIAN && !MODE_BFS]: ... this.
	(GRUB_MOD_FINI (befs)) [MODE_BIGENDIAN && MODE_BFS]: Rename to ..
	(GRUB_MOD_FINI (befs_be)) [MODE_BIGENDIAN && MODE_BFS]: ... this.
	(GRUB_MOD_FINI (afs)) [MODE_BIGENDIAN && !MODE_BFS]: Rename to ..
	(GRUB_MOD_FINI (afs_be)) [MODE_BIGENDIAN && !MODE_BFS]: ... this.
This commit is contained in:
phcoder 2009-08-28 13:01:26 +00:00
parent 32a716555d
commit 6e2a90859a
12 changed files with 156 additions and 102 deletions

View file

@ -1,3 +1,46 @@
2009-08-28 Vladimir Serbinenko <phcoder@gmail.com>
Split befs.mod and afs.mod into *_be.mod and *.mod
* conf/common.rmk (grub_probe_SOURCES): Add afs_be.c and befs_be.c.
(grub_fstest_SOURCES): Likewise.
(pkglib_MODULES): Add afs_be.mod and befs_be.mod.
(afs_be_mod_SOURCES): New variable.
(afs_be_mod_CFLAGS): Likewise.
(afs_be_mod_LDFLAGS): Likewise.
(befs_be_mod_SOURCES): Likewise.
(befs_be_mod_CFLAGS): Likewise.
(befs_be_mod_LDFLAGS): Likewise.
* conf/i386-coreboot.rmk (grub_emu_SOURCES): Add afs_be.c and befs_be.c.
* conf/i386-efi.rmk (grub_emu_SOURCES): Likewise.
* conf/i386-ieee1275.rmk (grub_emu_SOURCES): Likewise.
* conf/i386-pc.rmk (grub_setup_SOURCES): Likewise.
(grub_emu_SOURCES): Likewise.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise.
* conf/sparc64-ieee1275.rmk (grub_emu_SOURCES): Likewise.
* conf/x86_64-efi.rmk (grub_emu_SOURCES): Likewise.
* fs/afs_be.c: New file.
* fs/befs_be.c: New file.
* fs/afs.c (GRUB_AFS_FSNAME_SUFFIX): New definition.
(GRUB_AFS_FSNAME): Use GRUB_AFS_FSNAME_SUFFIX.
(U16): Replaced with ...
(grub_afs_to_cpu16): ...this. All users updated.
(U32): Replaced with ...
(grub_afs_to_cpu32): ...this. All users updated.
(U64): Replaced with ...
(grub_afs_to_cpu64): ...this. All users updated.
(GRUB_AFS_BO_LITTLE_ENDIAN): Remove.
(GRUB_AFS_BO_BIG_ENDIAN): Likewise.
(grub_afs_validate_sblock): Check only one endiannness.
(GRUB_MOD_INIT (befs)) [MODE_BIGENDIAN && MODE_BFS]: Rename to ..
(GRUB_MOD_INIT (befs_be)) [MODE_BIGENDIAN && MODE_BFS]: ... this.
(GRUB_MOD_INIT (afs)) [MODE_BIGENDIAN && !MODE_BFS]: Rename to ..
(GRUB_MOD_INIT (afs_be)) [MODE_BIGENDIAN && !MODE_BFS]: ... this.
(GRUB_MOD_FINI (befs)) [MODE_BIGENDIAN && MODE_BFS]: Rename to ..
(GRUB_MOD_FINI (befs_be)) [MODE_BIGENDIAN && MODE_BFS]: ... this.
(GRUB_MOD_FINI (afs)) [MODE_BIGENDIAN && !MODE_BFS]: Rename to ..
(GRUB_MOD_FINI (afs_be)) [MODE_BIGENDIAN && !MODE_BFS]: ... this.
2009-08-26 Bean <bean123ch@gmail.com> 2009-08-26 Bean <bean123ch@gmail.com>
* fs/xfs.c (GRUB_XFS_INO_INOINAG): Replace 1L with 1LL to support * fs/xfs.c (GRUB_XFS_INO_INOINAG): Replace 1L with 1LL to support

View file

@ -17,7 +17,8 @@ grub_probe_SOURCES = util/grub-probe.c \
fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \ fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \
fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \ fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \
fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \ fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \
fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c \
fs/befs.c fs/befs_be.c fs/tar.c \
\ \
partmap/msdos.c partmap/apple.c partmap/sun.c partmap/gpt.c\ partmap/msdos.c partmap/apple.c partmap/sun.c partmap/gpt.c\
kern/fs.c kern/env.c fs/fshelp.c \ kern/fs.c kern/env.c fs/fshelp.c \
@ -38,7 +39,8 @@ grub_fstest_SOURCES = util/grub-fstest.c util/hostfs.c util/misc.c \
fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \ fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \
fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \ fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \
fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \ fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \
fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c fs/befs.c \
fs/befs_be.c fs/tar.c \
\ \
kern/partition.c partmap/msdos.c partmap/apple.c partmap/sun.c \ kern/partition.c partmap/msdos.c partmap/apple.c partmap/sun.c \
partmap/gpt.c \ partmap/gpt.c \
@ -177,7 +179,7 @@ CLEANFILES += grub-dumpbios
pkglib_MODULES += fshelp.mod fat.mod ufs1.mod ufs2.mod ext2.mod ntfs.mod \ pkglib_MODULES += fshelp.mod fat.mod ufs1.mod ufs2.mod ext2.mod ntfs.mod \
ntfscomp.mod minix.mod hfs.mod jfs.mod iso9660.mod xfs.mod \ ntfscomp.mod minix.mod hfs.mod jfs.mod iso9660.mod xfs.mod \
affs.mod sfs.mod hfsplus.mod reiserfs.mod cpio.mod tar.mod \ affs.mod sfs.mod hfsplus.mod reiserfs.mod cpio.mod tar.mod \
udf.mod afs.mod befs.mod udf.mod afs.mod afs_be.mod befs.mod befs_be.mod
# For fshelp.mod. # For fshelp.mod.
fshelp_mod_SOURCES = fs/fshelp.c fshelp_mod_SOURCES = fs/fshelp.c
@ -279,11 +281,21 @@ afs_mod_SOURCES = fs/afs.c
afs_mod_CFLAGS = $(COMMON_CFLAGS) afs_mod_CFLAGS = $(COMMON_CFLAGS)
afs_mod_LDFLAGS = $(COMMON_LDFLAGS) afs_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For afs_be.mod.
afs_be_mod_SOURCES = fs/afs_be.c
afs_be_mod_CFLAGS = $(COMMON_CFLAGS)
afs_be_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For befs.mod. # For befs.mod.
befs_mod_SOURCES = fs/befs.c befs_mod_SOURCES = fs/befs.c
befs_mod_CFLAGS = $(COMMON_CFLAGS) befs_mod_CFLAGS = $(COMMON_CFLAGS)
befs_mod_LDFLAGS = $(COMMON_LDFLAGS) befs_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For befs_be.mod.
befs_be_mod_SOURCES = fs/befs_be.c
befs_be_mod_CFLAGS = $(COMMON_CFLAGS)
befs_be_mod_LDFLAGS = $(COMMON_LDFLAGS)
# Partition maps. # Partition maps.
pkglib_MODULES += part_amiga.mod pkglib_MODULES += part_amiga.mod

View file

@ -117,7 +117,8 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \
fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \ fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \
fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \ fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \
fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \ fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \
fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c \
fs/befs.c fs/befs_be.c fs/tar.c \
\ \
fs/fshelp.c \ fs/fshelp.c \
io/gzio.c \ io/gzio.c \

View file

@ -45,7 +45,8 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \
fs/affs.c fs/cpio.c fs/ext2.c fs/fat.c fs/hfs.c \ fs/affs.c fs/cpio.c fs/ext2.c fs/fat.c fs/hfs.c \
fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \ fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \
fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \ fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \
fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c \
fs/befs.c fs/befs_be.c fs/tar.c \
\ \
io/gzio.c \ io/gzio.c \
kern/device.c kern/disk.c kern/dl.c kern/elf.c kern/env.c \ kern/device.c kern/disk.c kern/dl.c kern/elf.c kern/env.c \

View file

@ -72,7 +72,8 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \
fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \ fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \
fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \ fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \
fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \ fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \
fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c fs/befs.c \
fs/befs_be.c fs/tar.c \
\ \
fs/fshelp.c \ fs/fshelp.c \
io/gzio.c \ io/gzio.c \

View file

@ -102,7 +102,8 @@ grub_setup_SOURCES = util/i386/pc/grub-setup.c util/hostdisk.c \
fs/affs.c fs/cpio.c fs/ext2.c fs/fat.c fs/hfs.c \ fs/affs.c fs/cpio.c fs/ext2.c fs/fat.c fs/hfs.c \
fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \ fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \
fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \ fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \
fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c \
fs/befs.c fs/befs_be.c fs/tar.c \
\ \
partmap/msdos.c partmap/gpt.c \ partmap/msdos.c partmap/gpt.c \
\ \
@ -147,7 +148,8 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \
fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \ fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \
fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \ fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \
fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \ fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \
fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c \
fs/befs.c fs/befs_be.c fs/tar.c \
\ \
util/console.c util/hostfs.c util/grub-emu.c util/misc.c \ util/console.c util/hostfs.c util/grub-emu.c util/misc.c \
util/hostdisk.c util/getroot.c \ util/hostdisk.c util/getroot.c \

View file

@ -52,7 +52,8 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \
fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \ fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \
fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \ fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \
fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \ fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \
fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c \
fs/befs.c fs/befs_be.c fs/tar.c \
\ \
io/gzio.c \ io/gzio.c \
kern/device.c kern/disk.c kern/dl.c kern/elf.c kern/env.c \ kern/device.c kern/disk.c kern/dl.c kern/elf.c kern/env.c \

View file

@ -78,7 +78,8 @@ grub_setup_SOURCES = util/sparc64/ieee1275/grub-setup.c util/hostdisk.c \
fs/affs.c fs/cpio.c fs/ext2.c fs/fat.c fs/hfs.c \ fs/affs.c fs/cpio.c fs/ext2.c fs/fat.c fs/hfs.c \
fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \ fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \
fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \ fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \
fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c \
fs/befs.c fs/befs_be.c fs/tar.c \
\ \
partmap/amiga.c partmap/apple.c partmap/msdos.c \ partmap/amiga.c partmap/apple.c partmap/msdos.c \
partmap/sun.c partmap/acorn.c \ partmap/sun.c partmap/acorn.c \
@ -109,7 +110,8 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \
fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \ fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \
fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \ fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \
fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \ fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \
fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/befs.c fs/tar.c \ fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c \
fs/befs.c fs/befs_be.c fs/tar.c \
\ \
io/gzio.c \ io/gzio.c \
kern/device.c kern/disk.c kern/dl.c kern/elf.c kern/env.c \ kern/device.c kern/disk.c kern/dl.c kern/elf.c kern/env.c \

View file

@ -43,7 +43,7 @@ grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \
fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \ fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \
fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \ fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \
fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \ fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \
fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c \ fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c \
\ \
io/gzio.c \ io/gzio.c \
kern/device.c kern/disk.c kern/dl.c kern/elf.c kern/env.c \ kern/device.c kern/disk.c kern/dl.c kern/elf.c kern/env.c \

165
fs/afs.c
View file

@ -26,10 +26,16 @@
#include <grub/types.h> #include <grub/types.h>
#include <grub/fshelp.h> #include <grub/fshelp.h>
#ifdef MODE_BFS #ifdef MODE_BIGENDIAN
#define GRUB_AFS_FSNAME "befs" #define GRUB_AFS_FSNAME_SUFFIX "_be"
#else #else
#define GRUB_AFS_FSNAME "afs" #define GRUB_AFS_FSNAME_SUFFIX ""
#endif
#ifdef MODE_BFS
#define GRUB_AFS_FSNAME "befs" GRUB_AFS_FSNAME_SUFFIX
#else
#define GRUB_AFS_FSNAME "afs" GRUB_AFS_FSNAME_SUFFIX
#endif #endif
#define GRUB_AFS_DIRECT_BLOCK_COUNT 12 #define GRUB_AFS_DIRECT_BLOCK_COUNT 12
@ -65,14 +71,15 @@
#define GRUB_AFS_NULL_VAL ((grub_afs_bvalue_t)-1) #define GRUB_AFS_NULL_VAL ((grub_afs_bvalue_t)-1)
#define U16(sb, u) (((sb)->byte_order == GRUB_AFS_BO_LITTLE_ENDIAN) ? \ #ifdef MODE_BIGENDIAN
grub_le_to_cpu16 (u) : grub_be_to_cpu16 (u)) #define grub_afs_to_cpu16(x) grub_be_to_cpu16 (x)
#define grub_afs_to_cpu32(x) grub_be_to_cpu32 (x)
#define U32(sb, u) (((sb)->byte_order == GRUB_AFS_BO_LITTLE_ENDIAN) ? \ #define grub_afs_to_cpu64(x) grub_be_to_cpu64 (x)
grub_le_to_cpu32 (u) : grub_be_to_cpu32 (u)) #else
#define grub_afs_to_cpu16(x) grub_le_to_cpu16 (x)
#define U64(sb, u) (((sb)->byte_order == GRUB_AFS_BO_LITTLE_ENDIAN) ? \ #define grub_afs_to_cpu32(x) grub_le_to_cpu32 (x)
grub_le_to_cpu64 (u) : grub_be_to_cpu64 (u)) #define grub_afs_to_cpu64(x) grub_le_to_cpu64 (x)
#endif
#ifdef MODE_BFS #ifdef MODE_BFS
#define B_KEY_INDEX_ALIGN 8 #define B_KEY_INDEX_ALIGN 8
@ -90,12 +97,6 @@
((char *) B_KEY_INDEX_OFFSET (node) + \ ((char *) B_KEY_INDEX_OFFSET (node) + \
node->key_count * 2)) node->key_count * 2))
enum
{
GRUB_AFS_BO_LITTLE_ENDIAN,
GRUB_AFS_BO_BIG_ENDIAN
};
typedef grub_uint64_t grub_afs_off_t; typedef grub_uint64_t grub_afs_off_t;
typedef grub_uint64_t grub_afs_bigtime; typedef grub_uint64_t grub_afs_bigtime;
typedef grub_uint64_t grub_afs_bvalue_t; typedef grub_uint64_t grub_afs_bvalue_t;
@ -154,6 +155,9 @@ struct grub_afs_btree
} __attribute__ ((packed)); } __attribute__ ((packed));
#endif #endif
/* Beware that following structure describes AtheFS and if you write code
which uses currently unused fields check it with both AtheFS and BeFS.
*/
struct grub_afs_sblock struct grub_afs_sblock
{ {
char name[32]; char name[32];
@ -227,8 +231,8 @@ static grub_afs_off_t
grub_afs_run_to_num (struct grub_afs_sblock *sb, grub_afs_run_to_num (struct grub_afs_sblock *sb,
struct grub_afs_blockrun *run) struct grub_afs_blockrun *run)
{ {
return ((grub_afs_off_t) U32 (sb, run->group) * sb->block_per_group + return ((grub_afs_off_t) grub_afs_to_cpu32 (run->group)
U16 (sb, run->start)); * sb->block_per_group + grub_afs_to_cpu16 (run->start));
} }
static grub_err_t static grub_err_t
@ -248,25 +252,25 @@ grub_afs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
struct grub_afs_sblock *sb = &node->data->sblock; struct grub_afs_sblock *sb = &node->data->sblock;
struct grub_afs_datastream *ds = &node->inode.stream; struct grub_afs_datastream *ds = &node->inode.stream;
if (fileblock < U64 (sb, ds->max_direct_range)) if (fileblock < grub_afs_to_cpu64 (ds->max_direct_range))
{ {
int i; int i;
for (i = 0; i < GRUB_AFS_DIRECT_BLOCK_COUNT; i++) for (i = 0; i < GRUB_AFS_DIRECT_BLOCK_COUNT; i++)
{ {
if (fileblock < U16 (sb, ds->direct[i].len)) if (fileblock < grub_afs_to_cpu16 (ds->direct[i].len))
return grub_afs_run_to_num (sb, &ds->direct[i]) + fileblock; return grub_afs_run_to_num (sb, &ds->direct[i]) + fileblock;
fileblock -= U16 (sb, ds->direct[i].len); fileblock -= grub_afs_to_cpu16 (ds->direct[i].len);
} }
} }
else if (fileblock < U64 (sb, ds->max_indirect_range)) else if (fileblock < grub_afs_to_cpu64 (ds->max_indirect_range))
{ {
int ptrs_per_blk = sb->block_size / sizeof (struct grub_afs_blockrun); int ptrs_per_blk = sb->block_size / sizeof (struct grub_afs_blockrun);
struct grub_afs_blockrun indir[ptrs_per_blk]; struct grub_afs_blockrun indir[ptrs_per_blk];
grub_afs_off_t blk = grub_afs_run_to_num (sb, &ds->indirect); grub_afs_off_t blk = grub_afs_run_to_num (sb, &ds->indirect);
int i; int i;
fileblock -= U64 (sb, ds->max_direct_range); fileblock -= grub_afs_to_cpu64 (ds->max_direct_range);
for (i = 0; i < ds->indirect.len; i++, blk++) for (i = 0; i < ds->indirect.len; i++, blk++)
{ {
int j; int j;
@ -279,10 +283,10 @@ grub_afs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
for (j = 0; j < ptrs_per_blk; j++) for (j = 0; j < ptrs_per_blk; j++)
{ {
if (fileblock < U16 (sb, indir[j].len)) if (fileblock < grub_afs_to_cpu16 (indir[j].len))
return grub_afs_run_to_num (sb, &indir[j]) + fileblock; return grub_afs_run_to_num (sb, &indir[j]) + fileblock;
fileblock -= U16 (sb, indir[j].len); fileblock -= grub_afs_to_cpu16 (indir[j].len);
} }
} }
} }
@ -292,7 +296,7 @@ grub_afs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
struct grub_afs_blockrun indir[ptrs_per_blk]; struct grub_afs_blockrun indir[ptrs_per_blk];
/* ([idblk][idptr]) ([dblk][dptr]) [blk] */ /* ([idblk][idptr]) ([dblk][dptr]) [blk] */
int cur_pos = fileblock - U64 (sb, ds->max_indirect_range); int cur_pos = fileblock - grub_afs_to_cpu64 (ds->max_indirect_range);
int dptr_size = GRUB_AFS_BLOCKS_PER_DI_RUN; int dptr_size = GRUB_AFS_BLOCKS_PER_DI_RUN;
int dblk_size = dptr_size * ptrs_per_blk; int dblk_size = dptr_size * ptrs_per_blk;
@ -334,8 +338,7 @@ grub_afs_read_file (grub_fshelp_node_t node,
{ {
return grub_fshelp_read_file (node->data->disk, node, read_hook, return grub_fshelp_read_file (node->data->disk, node, read_hook,
pos, len, buf, grub_afs_read_block, pos, len, buf, grub_afs_read_block,
U64 (&node->data->sblock, grub_afs_to_cpu64 (node->inode.stream.size),
node->inode.stream.size),
node->data->sblock.block_shift node->data->sblock.block_shift
- GRUB_DISK_SECTOR_BITS); - GRUB_DISK_SECTOR_BITS);
} }
@ -344,8 +347,7 @@ static char *
grub_afs_read_symlink (grub_fshelp_node_t node) grub_afs_read_symlink (grub_fshelp_node_t node)
{ {
char *ret; char *ret;
struct grub_afs_sblock *sb = &node->data->sblock; grub_afs_off_t size = grub_afs_to_cpu64 (node->inode.stream.size);
grub_afs_off_t size = U64 (sb, node->inode.stream.size);
if (size == 0) if (size == 0)
{ {
@ -374,27 +376,27 @@ grub_afs_iterate_dir (grub_fshelp_node_t dir,
struct grub_afs_btree head; struct grub_afs_btree head;
char node_data [GRUB_AFS_BNODE_SIZE]; char node_data [GRUB_AFS_BNODE_SIZE];
struct grub_afs_bnode *node = (struct grub_afs_bnode *) node_data; struct grub_afs_bnode *node = (struct grub_afs_bnode *) node_data;
struct grub_afs_sblock *sb = &dir->data->sblock;
int i; int i;
if ((dir->inode.stream.size == 0) if ((dir->inode.stream.size == 0)
|| ((U32 (sb, dir->inode.mode) & GRUB_AFS_S_IFMT) != GRUB_AFS_S_IFDIR)) || ((grub_afs_to_cpu32 (dir->inode.mode) & GRUB_AFS_S_IFMT)
!= GRUB_AFS_S_IFDIR))
return 0; return 0;
grub_afs_read_file (dir, 0, 0, sizeof (head), (char *) &head); grub_afs_read_file (dir, 0, 0, sizeof (head), (char *) &head);
if (grub_errno) if (grub_errno)
return 0; return 0;
grub_afs_read_file (dir, 0, U64 (sb, head.root), grub_afs_read_file (dir, 0, grub_afs_to_cpu64 (head.root),
GRUB_AFS_BNODE_SIZE, (char *) node); GRUB_AFS_BNODE_SIZE, (char *) node);
if (grub_errno) if (grub_errno)
return 0; return 0;
for (i = 0; i < (int) U32 (sb, head.tree_depth) - 1; i++) for (i = 0; i < (int) grub_afs_to_cpu32 (head.tree_depth) - 1; i++)
{ {
grub_afs_bvalue_t blk; grub_afs_bvalue_t blk;
blk = U64(sb, B_KEY_VALUE_OFFSET (node) [0]); blk = grub_afs_to_cpu64(B_KEY_VALUE_OFFSET (node) [0]);
grub_afs_read_file (dir, 0, blk, GRUB_AFS_BNODE_SIZE, (char *) node); grub_afs_read_file (dir, 0, blk, GRUB_AFS_BNODE_SIZE, (char *) node);
if (grub_errno) if (grub_errno)
return 0; return 0;
@ -411,8 +413,9 @@ grub_afs_iterate_dir (grub_fshelp_node_t dir,
index = B_KEY_INDEX_OFFSET (node); index = B_KEY_INDEX_OFFSET (node);
key_start = U16 (sb, (cur_key > 0) ? index[cur_key - 1] : 0); key_start = (cur_key > 0)
key_size = U16 (sb, index[cur_key]) - key_start; ? grub_afs_to_cpu16 (index[cur_key - 1]) : 0;
key_size = grub_afs_to_cpu16 (index[cur_key]) - key_start;
if (key_size > 0) if (key_size > 0)
{ {
char filename [key_size + 1]; char filename [key_size + 1];
@ -425,14 +428,15 @@ grub_afs_iterate_dir (grub_fshelp_node_t dir,
fdiro->data = dir->data; fdiro->data = dir->data;
if (grub_afs_read_inode (dir->data, if (grub_afs_read_inode (dir->data,
U64 (sb, B_KEY_VALUE_OFFSET (node) [cur_key]), grub_afs_to_cpu64
(B_KEY_VALUE_OFFSET (node) [cur_key]),
&fdiro->inode)) &fdiro->inode))
return 0; return 0;
grub_memcpy (filename, &node->key_data[key_start], key_size); grub_memcpy (filename, &node->key_data[key_start], key_size);
filename [key_size] = 0; filename [key_size] = 0;
mode = (U32 (sb, fdiro->inode.mode) & GRUB_AFS_S_IFMT); mode = (grub_afs_to_cpu32 (fdiro->inode.mode) & GRUB_AFS_S_IFMT);
if (mode == GRUB_AFS_S_IFDIR) if (mode == GRUB_AFS_S_IFDIR)
type = GRUB_FSHELP_DIR; type = GRUB_FSHELP_DIR;
else if (mode == GRUB_AFS_S_IFREG) else if (mode == GRUB_AFS_S_IFREG)
@ -447,12 +451,12 @@ grub_afs_iterate_dir (grub_fshelp_node_t dir,
} }
cur_key++; cur_key++;
if (cur_key >= U32 (sb, node->key_count)) if (cur_key >= grub_afs_to_cpu32 (node->key_count))
{ {
if (node->right == GRUB_AFS_NULL_VAL) if (node->right == GRUB_AFS_NULL_VAL)
break; break;
grub_afs_read_file (dir, 0, U64 (sb, node->right), grub_afs_read_file (dir, 0, grub_afs_to_cpu64 (node->right),
GRUB_AFS_BNODE_SIZE, (char *) node); GRUB_AFS_BNODE_SIZE, (char *) node);
if (grub_errno) if (grub_errno)
return 0; return 0;
@ -468,47 +472,20 @@ grub_afs_iterate_dir (grub_fshelp_node_t dir,
static int static int
grub_afs_validate_sblock (struct grub_afs_sblock *sb) grub_afs_validate_sblock (struct grub_afs_sblock *sb)
{ {
if (grub_le_to_cpu32 (sb->magic1) == GRUB_AFS_SBLOCK_MAGIC1) if (grub_afs_to_cpu32 (sb->magic1) == GRUB_AFS_SBLOCK_MAGIC1)
{ {
#ifndef MODE_BFS sb->magic2 = grub_afs_to_cpu32 (sb->magic2);
if (grub_le_to_cpu32 (sb->byte_order) != GRUB_AFS_BO_LITTLE_ENDIAN) sb->magic3 = grub_afs_to_cpu32 (sb->magic3);
return 0; sb->block_shift = grub_afs_to_cpu32 (sb->block_shift);
#endif sb->block_size = grub_afs_to_cpu32 (sb->block_size);
sb->used_blocks = grub_afs_to_cpu64 (sb->used_blocks);
sb->byte_order = GRUB_AFS_BO_LITTLE_ENDIAN; sb->num_blocks = grub_afs_to_cpu64 (sb->num_blocks);
sb->magic2 = grub_le_to_cpu32 (sb->magic2); sb->inode_size = grub_afs_to_cpu32 (sb->inode_size);
sb->magic3 = grub_le_to_cpu32 (sb->magic3); sb->alloc_group_count = grub_afs_to_cpu32 (sb->alloc_group_count);
sb->block_shift = grub_le_to_cpu32 (sb->block_shift); sb->alloc_group_shift = grub_afs_to_cpu32 (sb->alloc_group_shift);
sb->block_size = grub_le_to_cpu32 (sb->block_size); sb->block_per_group = grub_afs_to_cpu32 (sb->block_per_group);
sb->used_blocks = grub_le_to_cpu64 (sb->used_blocks); sb->alloc_group_count = grub_afs_to_cpu32 (sb->alloc_group_count);
sb->num_blocks = grub_le_to_cpu64 (sb->num_blocks); sb->log_size = grub_afs_to_cpu32 (sb->log_size);
sb->inode_size = grub_le_to_cpu32 (sb->inode_size);
sb->alloc_group_count = grub_le_to_cpu32 (sb->alloc_group_count);
sb->alloc_group_shift = grub_le_to_cpu32 (sb->alloc_group_shift);
sb->block_per_group = grub_le_to_cpu32 (sb->block_per_group);
sb->alloc_group_count = grub_le_to_cpu32 (sb->alloc_group_count);
sb->log_size = grub_le_to_cpu32 (sb->log_size);
}
else if (grub_be_to_cpu32 (sb->magic1) == GRUB_AFS_SBLOCK_MAGIC1)
{
#ifndef MODE_BFS
if (grub_be_to_cpu32 (sb->byte_order) != GRUB_AFS_BO_BIG_ENDIAN)
return 0;
#endif
sb->byte_order = GRUB_AFS_BO_BIG_ENDIAN;
sb->magic2 = grub_be_to_cpu32 (sb->magic2);
sb->magic3 = grub_be_to_cpu32 (sb->magic3);
sb->block_shift = grub_be_to_cpu32 (sb->block_shift);
sb->block_size = grub_be_to_cpu32 (sb->block_size);
sb->used_blocks = grub_be_to_cpu64 (sb->used_blocks);
sb->num_blocks = grub_be_to_cpu64 (sb->num_blocks);
sb->inode_size = grub_be_to_cpu32 (sb->inode_size);
sb->alloc_group_count = grub_be_to_cpu32 (sb->alloc_group_count);
sb->alloc_group_shift = grub_be_to_cpu32 (sb->alloc_group_shift);
sb->block_per_group = grub_be_to_cpu32 (sb->block_per_group);
sb->alloc_group_count = grub_be_to_cpu32 (sb->alloc_group_count);
sb->log_size = grub_be_to_cpu32 (sb->log_size);
} }
else else
return 0; return 0;
@ -529,8 +506,8 @@ grub_afs_validate_sblock (struct grub_afs_sblock *sb)
|| ((grub_uint32_t) (1 << sb->alloc_group_shift) != || ((grub_uint32_t) (1 << sb->alloc_group_shift) !=
sb->block_per_group * sb->block_size) sb->block_per_group * sb->block_size)
|| (sb->alloc_group_count * sb->block_per_group < sb->num_blocks) || (sb->alloc_group_count * sb->block_per_group < sb->num_blocks)
|| (U16 (sb, sb->log_block.len) != sb->log_size) || (grub_afs_to_cpu16 (sb->log_block.len) != sb->log_size)
|| (U32 (sb, sb->valid_log_blocks) > sb->log_size) || (grub_afs_to_cpu32 (sb->valid_log_blocks) > sb->log_size)
#endif #endif
) )
return 0; return 0;
@ -594,7 +571,7 @@ grub_afs_open (struct grub_file *file, const char *name)
grub_memcpy (data->inode, &fdiro->inode, sizeof (struct grub_afs_inode)); grub_memcpy (data->inode, &fdiro->inode, sizeof (struct grub_afs_inode));
grub_free (fdiro); grub_free (fdiro);
file->size = U64 (&data->sblock, data->inode->stream.size); file->size = grub_afs_to_cpu64 (data->inode->stream.size);
file->data = data; file->data = data;
file->offset = 0; file->offset = 0;
@ -648,10 +625,10 @@ grub_afs_dir (grub_device_t device, const char *path,
info.dir = ((filetype & GRUB_FSHELP_TYPE_MASK) == GRUB_FSHELP_DIR); info.dir = ((filetype & GRUB_FSHELP_TYPE_MASK) == GRUB_FSHELP_DIR);
info.mtimeset = 1; info.mtimeset = 1;
#ifdef MODE_BFS #ifdef MODE_BFS
info.mtime = U64 (&data->sblock, node->inode.modified_time) >> 16; info.mtime = grub_afs_to_cpu64 (node->inode.modified_time) >> 16;
#else #else
info.mtime = grub_divmod64 (U64 (&data->sblock, info.mtime = grub_divmod64 (grub_afs_to_cpu64 (node->inode.modified_time),
node->inode.modified_time), 1000000, 0); 1000000, 0);
#endif #endif
grub_free (node); grub_free (node);
return hook (filename, &info); return hook (filename, &info);
@ -713,8 +690,12 @@ static struct grub_fs grub_afs_fs = {
.next = 0 .next = 0
}; };
#ifdef MODE_BFS #if defined (MODE_BIGENDIAN) && defined (MODE_BFS)
GRUB_MOD_INIT (befs_be)
#elif defined (MODE_BFS)
GRUB_MOD_INIT (befs) GRUB_MOD_INIT (befs)
#elif defined (MODE_BIGENDIAN)
GRUB_MOD_INIT (afs_be)
#else #else
GRUB_MOD_INIT (afs) GRUB_MOD_INIT (afs)
#endif #endif
@ -723,8 +704,12 @@ GRUB_MOD_INIT (afs)
my_mod = mod; my_mod = mod;
} }
#ifdef MODE_BFS #if defined (MODE_BIGENDIAN) && defined (MODE_BFS)
GRUB_MOD_FINI (befs_be)
#elif defined (MODE_BFS)
GRUB_MOD_FINI (befs) GRUB_MOD_FINI (befs)
#elif defined (MODE_BIGENDIAN)
GRUB_MOD_FINI (afs_be)
#else #else
GRUB_MOD_FINI (afs) GRUB_MOD_FINI (afs)
#endif #endif

2
fs/afs_be.c Normal file
View file

@ -0,0 +1,2 @@
#define MODE_BIGENDIAN 1
#include "afs.c"

4
fs/befs_be.c Normal file
View file

@ -0,0 +1,4 @@
/* befs.c - The native BeOS/Haiku file-system. */
#define MODE_BFS 1
#define MODE_BIGENDIAN 1
#include "afs.c"