ext2fs_free_mem(&ctx->invalid_inode_table_flag);
ctx->invalid_inode_table_flag = 0;
}
- if (ctx->encrypted_dirs) {
- ext2fs_u32_list_free(ctx->encrypted_dirs);
- ctx->encrypted_dirs = 0;
- }
+ if (ctx->casefolded_dirs) {
+ ext2fs_u32_list_free(ctx->casefolded_dirs);
+ ctx->casefolded_dirs = 0;
+ }
if (ctx->inode_count) {
ext2fs_free_icount(ctx->inode_count);
ctx->inode_count = 0;
int ext_attr_ver;
profile_t profile;
int blocks_per_page;
- ext2_u32_list encrypted_dirs;
+ ext2_u32_list casefolded_dirs;
/* Reserve blocks for root and l+f re-creation */
blk64_t root_repair_block, lnf_repair_block;
static void alloc_bb_map(e2fsck_t ctx);
static void alloc_imagic_map(e2fsck_t ctx);
static void mark_inode_bad(e2fsck_t ctx, ino_t ino);
-static void add_encrypted_dir(e2fsck_t ctx, ino_t ino);
+ static void add_casefolded_dir(e2fsck_t ctx, ino_t ino);
static void handle_fs_bad_blocks(e2fsck_t ctx);
static void process_inodes(e2fsck_t ctx, char *block_buf);
static EXT2_QSORT_TYPE process_inode_cmp(const void *a, const void *b);
ext2fs_mark_inode_bitmap2(ctx->inode_dir_map, ino);
e2fsck_add_dir_info(ctx, ino, 0);
ctx->fs_directory_count++;
- if (inode->i_flags & EXT4_ENCRYPT_FL)
- add_encrypted_dir(ctx, ino);
+ if (inode->i_flags & EXT4_CASEFOLD_FL)
+ add_casefolded_dir(ctx, ino);
} else if (LINUX_S_ISREG (inode->i_mode)) {
ext2fs_mark_inode_bitmap2(ctx->inode_reg_map, ino);
ctx->fs_regular_count++;
ext2fs_mark_inode_bitmap2(ctx->inode_bad_map, ino);
}
-static void add_encrypted_dir(e2fsck_t ctx, ino_t ino)
-{
- struct problem_context pctx;
-
- if (!ctx->encrypted_dirs) {
- pctx.errcode = ext2fs_u32_list_create(&ctx->encrypted_dirs, 0);
- if (pctx.errcode)
- goto error;
- }
- pctx.errcode = ext2fs_u32_list_add(ctx->encrypted_dirs, ino);
- if (pctx.errcode == 0)
- return;
-error:
- fix_problem(ctx, PR_1_ALLOCATE_ENCRYPTED_DIRLIST, &pctx);
- /* Should never get here */
- ctx->flags |= E2F_FLAG_ABORT;
-}
-
+ static void add_casefolded_dir(e2fsck_t ctx, ino_t ino)
+ {
+ struct problem_context pctx;
+
+ if (!ctx->casefolded_dirs) {
+ pctx.errcode = ext2fs_u32_list_create(&ctx->casefolded_dirs, 0);
+ if (pctx.errcode)
+ goto error;
+ }
+ pctx.errcode = ext2fs_u32_list_add(ctx->casefolded_dirs, ino);
+ if (pctx.errcode == 0)
+ return;
+ error:
+ fix_problem(ctx, PR_1_ALLOCATE_CASEFOLDED_DIRLIST, &pctx);
+ /* Should never get here */
+ ctx->flags |= E2F_FLAG_ABORT;
+ }
+
/*
* This procedure will allocate the inode "bb" (badblock) map table
*/
ext2fs_free_inode_bitmap(ctx->inode_reg_map);
ctx->inode_reg_map = 0;
}
- if (ctx->encrypted_dirs) {
- ext2fs_u32_list_free(ctx->encrypted_dirs);
- ctx->encrypted_dirs = 0;
+ if (ctx->inode_casefold_map) {
+ ext2fs_free_inode_bitmap(ctx->inode_casefold_map);
+ ctx->inode_casefold_map = 0;
}
+ destroy_encrypted_file_info(ctx);
+ if (ctx->casefolded_dirs) {
+ ext2fs_u32_list_free(ctx->casefolded_dirs);
+ ctx->casefolded_dirs = 0;
+ }
clear_problem_context(&pctx);
if (ctx->large_files) {
int is_leaf = 1;
size_t inline_data_size = 0;
int filetype = 0;
- int encrypted = 0;
+ __u32 dir_encpolicy_id = NO_ENCRYPTION_POLICY;
+ int hash_in_dirent = 0;
+ int casefolded = 0;
size_t max_block_size;
int hash_flags = 0;
static char *eop_read_dirblock = NULL;
} else
max_block_size = fs->blocksize - de_csum_size;
- if (ctx->encrypted_dirs)
- encrypted = ext2fs_u32_list_test(ctx->encrypted_dirs, ino);
+ dir_encpolicy_id = find_encryption_policy(ctx, ino);
+
+ if (cf_dir) {
+ dict_init(&de_dict, DICTCOUNT_T_MAX, dict_de_cf_cmp);
+ dict_set_cmp_context(&de_dict, (void *)ctx->fs->encoding);
+ } else {
+ dict_init(&de_dict, DICTCOUNT_T_MAX, dict_de_cmp);
+ }
+ if (ctx->casefolded_dirs)
+ casefolded = ext2fs_u32_list_test(ctx->casefolded_dirs, ino);
- hash_in_dirent = encrypted && casefolded;
++ hash_in_dirent = (casefolded &&
++ (dir_encpolicy_id != NO_ENCRYPTION_POLICY));
- dict_init(&de_dict, DICTCOUNT_T_MAX, dict_de_cmp);
prev = 0;
do {
dgrp_t group;
N_("@d %p has the casefold flag, but the\ncasefold feature is not enabled. "),
PROMPT_CLEAR_FLAG, 0, 0, 0, 0 },
+ /* Inode has encrypt flag but no encryption extended attribute */
+ { PR_1_MISSING_ENCRYPTION_XATTR,
+ N_("@i %i has encrypt flag but no encryption @a.\n"),
+ PROMPT_CLEAR_FLAG, 0, 0, 0, 0 },
+
+ /* Encrypted inode has corrupt encryption extended attribute */
+ { PR_1_CORRUPT_ENCRYPTION_XATTR,
+ N_("Encrypted @i %i has corrupt encryption @a.\n"),
+ PROMPT_CLEAR_INODE, 0, 0, 0, 0 },
+
+ /* Htree directory should use SipHash but does not */
+ { PR_1_HTREE_NEEDS_SIPHASH,
+ N_("@h %i uses hash version (%N), but should use SipHash (6) \n"),
+ PROMPT_CLEAR_HTREE, PR_PREEN_OK, 0, 0, 0 },
+
+ /* Htree directory uses SipHash but should not */
+ { PR_1_HTREE_CANNOT_SIPHASH,
+ N_("@h %i uses SipHash, but should not. "),
+ PROMPT_CLEAR_HTREE, PR_PREEN_OK, 0, 0, 0 },
+
++
/* Pass 1b errors */
/* Pass 1B: Rescan for duplicate/bad blocks */
N_("Encrypted @E is too short.\n"),
PROMPT_CLEAR, 0, 0, 0, 0 },
+ /* Encrypted directory contains unencrypted file */
+ { PR_2_UNENCRYPTED_FILE,
+ N_("Encrypted @E references unencrypted @i %Di.\n"),
+ PROMPT_CLEAR, 0, 0, 0, 0 },
+
+ /* Encrypted directory contains file with different encryption policy */
+ { PR_2_INCONSISTENT_ENCRYPTION_POLICY,
+ N_("Encrypted @E references @i %Di, which has a different encryption policy.\n"),
+ PROMPT_CLEAR, 0, 0, 0, 0 },
+
+ /* Casefolded directory entry has illegal characters in its name */
+ { PR_2_BAD_ENCODED_NAME,
+ N_("@E has illegal UTF-8 characters in its name.\n"),
+ PROMPT_FIX, 0, 0, 0, 0 },
+
+ /* Non-unique filename found, but can't rename */
+ { PR_2_NON_UNIQUE_FILE_NO_RENAME,
+ N_("Duplicate filename @E found. "),
+ PROMPT_CLEAR, 0, 0, 0, 0 },
+
++
/* Pass 3 errors */
/* Pass 3: Checking directory connectivity */
/* Casefold flag set, but file system is missing the casefold feature */
#define PR_1_CASEFOLD_FEATURE 0x010089
+/* Inode has encrypt flag but no encryption extended attribute */
+#define PR_1_MISSING_ENCRYPTION_XATTR 0x01008A
+
+/* Encrypted inode has corrupt encryption extended attribute */
+#define PR_1_CORRUPT_ENCRYPTION_XATTR 0x01008B
+
+ /* Error allocating memory for casefolded directory list */
+ #define PR_1_ALLOCATE_CASEFOLDED_DIRLIST 0x01008C
+
+ /* Htree directory should use SipHash but does not */
+ #define PR_1_HTREE_NEEDS_SIPHASH 0x01008D
+
+ /* Htree directory uses SipHash but should not */
+ #define PR_1_HTREE_CANNOT_SIPHASH 0x01008E
+
+
/*
* Pass 1b errors
*/
static int feature_64bit;
static int fsck_requested;
static char *undo_file;
+ int enabling_casefold;
-int journal_size, journal_flags;
+int journal_size, journal_fc_size, journal_flags;
char *journal_device;
static blk64_t journal_location = ~0LL;