summaryrefslogtreecommitdiff
path: root/lib/ext2fs/initialize.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2006-11-11 22:32:35 -0500
committerTheodore Ts'o <tytso@mit.edu>2006-11-11 22:32:35 -0500
commitf77704e416fca7dbe4cc91abba674d2ae3c14f6f (patch)
tree1a927102301da898881d0dc788d493381f61f463 /lib/ext2fs/initialize.c
parent52325593b1979509dc3f18232b50359e311268cc (diff)
downloade2fsprogs-f77704e416fca7dbe4cc91abba674d2ae3c14f6f.tar.gz
Add directory hashed signed/unsigned hint to superblock
The e2fsprogs and kernel implementation of directory hash tree has a bug which causes the implementation to be dependent on whether characters are signed or unsigned. Platforms such as the PowerPC, Arm, and S/390 have signed characters by default, which means that hash directories on those systems are incompatible with hash directories on other systems, such as the x86. To fix this we add a new flags field to the superblock, and define two new bits in that field to indicate whether or not the directory should be signed or unsigned. If the bits are not set, e2fsck and fixed kernels will set them to the signed/unsigned value of the currently running platform, and then respect those bits when calculating the directory hash. This allows compatibility with current filesystems, as well as allowing cross-architectural compatibility. Addresses Debian Bug: #389772 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'lib/ext2fs/initialize.c')
-rw-r--r--lib/ext2fs/initialize.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/ext2fs/initialize.c b/lib/ext2fs/initialize.c
index 98351f8c..9cc3d121 100644
--- a/lib/ext2fs/initialize.c
+++ b/lib/ext2fs/initialize.c
@@ -105,6 +105,7 @@ errcode_t ext2fs_initialize(const char *name, int flags,
int rsv_gdt;
int io_flags;
char *buf;
+ char c;
if (!param || !param->s_blocks_count)
return EXT2_ET_INVALID_ARGUMENT;
@@ -373,6 +374,13 @@ ipg_retry:
fs->group_desc[i].bg_used_dirs_count = 0;
}
+ c = (char) 255;
+ if (((int) c) == -1) {
+ super->s_flags |= EXT2_FLAGS_SIGNED_HASH;
+ } else {
+ super->s_flags |= EXT2_FLAGS_UNSIGNED_HASH;
+ }
+
ext2fs_mark_super_dirty(fs);
ext2fs_mark_bb_dirty(fs);
ext2fs_mark_ib_dirty(fs);