fs/ext4/hash-test.c

Source file repositories/reference/linux-study-clean/fs/ext4/hash-test.c

File Facts

System
Linux kernel
Corpus path
fs/ext4/hash-test.c
Extension
.c
Size
15166 bytes
Lines
568
Domain
Core OS
Bucket
VFS And Filesystem Core
Inferred role
Core OS: implementation source
Status
source implementation candidate

Why This File Exists

Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.

Dependency Surface

Detected Declarations

Annotated Snippet

struct ext4_dirhash_test_case {
	const char *name;
	u32 hash_version;
	const char *input;
	int len;
	u32 seed[4];
	bool use_seed;
	u32 expected_hash;
	u32 expected_minor_hash;
};

static const struct ext4_dirhash_test_case ext4_dirhash_test_cases[] = {
	{
		.name = "legacy_abc",
		.hash_version = DX_HASH_LEGACY,
		.input = "abc",
		.len = 3,
		.use_seed = false,
		.expected_hash = 0x75afd992,
		.expected_minor_hash = 0x00000000,
	},
	{
		.name = "legacy_unsigned_abc",
		.hash_version = DX_HASH_LEGACY_UNSIGNED,
		.input = "abc",
		.len = 3,
		.use_seed = false,
		.expected_hash = 0x75afd992,
		.expected_minor_hash = 0x00000000,
	},
	{
		.name = "half_md4_abc",
		.hash_version = DX_HASH_HALF_MD4,
		.input = "abc",
		.len = 3,
		.use_seed = false,
		.expected_hash = 0xd196a868,
		.expected_minor_hash = 0xc420eb28,
	},
	{
		.name = "half_md4_unsigned_abc",
		.hash_version = DX_HASH_HALF_MD4_UNSIGNED,
		.input = "abc",
		.len = 3,
		.use_seed = false,
		.expected_hash = 0xd196a868,
		.expected_minor_hash = 0xc420eb28,
	},
	{
		.name = "tea_abc",
		.hash_version = DX_HASH_TEA,
		.input = "abc",
		.len = 3,
		.use_seed = false,
		.expected_hash = 0xb1435ec4,
		.expected_minor_hash = 0x3f7eaa0e,
	},
	{
		.name = "tea_unsigned_abc",
		.hash_version = DX_HASH_TEA_UNSIGNED,
		.input = "abc",
		.len = 3,
		.use_seed = false,
		.expected_hash = 0xb1435ec4,
		.expected_minor_hash = 0x3f7eaa0e,
	},
	{
		.name = "empty_half_md4",
		.hash_version = DX_HASH_HALF_MD4,
		.input = "",
		.len = 0,
		.use_seed = false,
		.expected_hash = 0xefcdab88,
		.expected_minor_hash = 0x98badcfe,
	},
	{
		.name = "half_md4_31bytes",
		.hash_version = DX_HASH_HALF_MD4,
		.input = "1234567890123456789012345678901",
		.len = 31,
		.use_seed = false,
		.expected_hash = 0xc4db1f78,
		.expected_minor_hash = 0xea23921b,
	},
	{
		.name = "half_md4_32bytes",
		.hash_version = DX_HASH_HALF_MD4,
		.input = "12345678901234567890123456789012",
		.len = 32,
		.use_seed = false,

Annotation

Implementation Notes