mirror of
https://gitee.com/openharmony/third_party_f2fs-tools
synced 2024-11-23 10:10:00 +00:00
f2fs-tools: Casefolded Encryption support
This adds support for casefolded and encrypted directories. Fsck cannot check the hashes of such directories because it would require access to the encryption key to generate the siphash Signed-off-by: Daniel Rosenberg <drosen@google.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
parent
64750e90d6
commit
7f3767ee8d
@ -1303,6 +1303,10 @@ static int f2fs_check_hash_code(int encoding, int casefolded,
|
||||
struct f2fs_dir_entry *dentry,
|
||||
const unsigned char *name, u32 len, int enc_name)
|
||||
{
|
||||
/* Casefolded Encrypted names require a key to compute siphash */
|
||||
if (enc_name && casefolded)
|
||||
return 0;
|
||||
|
||||
f2fs_hash_t hash_code = f2fs_dentry_hash(encoding, casefolded, name, len);
|
||||
/* fix hash_code made by old buggy code */
|
||||
if (dentry->hash_code != hash_code) {
|
||||
|
@ -3052,12 +3052,6 @@ static int tune_sb_features(struct f2fs_sb_info *sbi)
|
||||
int sb_changed = 0;
|
||||
struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi);
|
||||
|
||||
if (c.feature & cpu_to_le32(F2FS_FEATURE_ENCRYPT) &&
|
||||
c.feature & cpu_to_le32(F2FS_FEATURE_CASEFOLD)) {
|
||||
ERR_MSG("ERROR: Cannot set both encrypt and casefold. Skipping.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!(sb->feature & cpu_to_le32(F2FS_FEATURE_ENCRYPT)) &&
|
||||
c.feature & cpu_to_le32(F2FS_FEATURE_ENCRYPT)) {
|
||||
sb->feature |= cpu_to_le32(F2FS_FEATURE_ENCRYPT);
|
||||
|
@ -517,10 +517,6 @@ static int f2fs_prepare_super_block(void)
|
||||
memcpy(sb->init_version, c.version, VERSION_LEN);
|
||||
|
||||
if (c.feature & cpu_to_le32(F2FS_FEATURE_CASEFOLD)) {
|
||||
if (c.feature & cpu_to_le32(F2FS_FEATURE_ENCRYPT)) {
|
||||
MSG(0, "\tError: Casefolding and encryption are not compatible\n");
|
||||
return -1;
|
||||
}
|
||||
set_sb(s_encoding, c.s_encoding);
|
||||
set_sb(s_encoding_flags, c.s_encoding_flags);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user