* - A bitmap of which inodes have bad fields. (inode_bad_map)
* - A bitmap of which inodes are in bad blocks. (inode_bb_map)
* - A bitmap of which inodes are imagic inodes. (inode_imagic_map)
+ * - A bitmap of which inodes are casefolded. (inode_casefold_map)
* - A bitmap of which blocks are in use. (block_found_map)
* - A bitmap of which blocks are in use by two inodes (block_dup_map)
* - The data blocks of the directory inodes. (dir_map)
ctx->flags |= E2F_FLAG_ABORT;
return;
}
+ if (casefold_fs) {
+ pctx.errcode =
+ e2fsck_allocate_inode_bitmap(fs,
+ _("inode casefold map"),
+ EXT2FS_BMAP64_RBTREE,
+ "inode_casefold_map",
+ &ctx->inode_casefold_map);
+ if (pctx.errcode) {
+ pctx.num = 1;
+ fix_problem(ctx, PR_1_ALLOCATE_IBITMAP_ERROR, &pctx);
+ ctx->flags |= E2F_FLAG_ABORT;
+ return;
+ }
+ }
pctx.errcode = e2fsck_setup_icount(ctx, "inode_link_info", 0, NULL,
&ctx->inode_link_info);
if (pctx.errcode) {
add_encrypted_file(ctx, &pctx) < 0)
goto clear_inode;
+ if (casefold_fs && inode->i_flags & EXT4_CASEFOLD_FL)
+ ext2fs_mark_inode_bitmap2(ctx->inode_casefold_map, ino);
+
if (LINUX_S_ISDIR(inode->i_mode)) {
ext2fs_mark_inode_bitmap2(ctx->inode_dir_map, ino);
e2fsck_add_dir_info(ctx, ino, 0);
* - The inode_bad_map bitmap
* - The inode_dir_map bitmap
* - The encrypted_file_info
+ * - The inode_casefold_map bitmap
*
* Pass 2 frees the following data structures
* - The inode_bad_map bitmap
* - The inode_reg_map bitmap
* - The encrypted_file_info
+ * - The inode_casefold_map bitmap
*/
#define _GNU_SOURCE 1 /* get strnlen() */
ext2fs_free_inode_bitmap(ctx->inode_reg_map);
ctx->inode_reg_map = 0;
}
+ if (ctx->inode_casefold_map) {
+ ext2fs_free_inode_bitmap(ctx->inode_casefold_map);
+ ctx->inode_casefold_map = 0;
+ }
destroy_encrypted_file_info(ctx);
clear_problem_context(&pctx);
return 0;
}
+static int encoded_check_name(e2fsck_t ctx,
+ struct ext2_dir_entry *dirent,
+ struct problem_context *pctx)
+{
+ const struct ext2fs_nls_table *tbl = ctx->fs->encoding;
+ int ret;
+ int len = ext2fs_dirent_name_len(dirent);
+ char *pos, *end;
+
+ ret = ext2fs_check_encoded_name(tbl, dirent->name, len, &pos);
+ if (ret < 0) {
+ fatal_error(ctx, _("NLS is broken."));
+ } else if(ret > 0) {
+ ret = fix_problem(ctx, PR_2_BAD_ENCODED_NAME, pctx);
+ if (ret) {
+ end = &dirent->name[len];
+ for (; *pos && pos != end; pos++)
+ *pos = '.';
+ }
+ }
+
+ return (ret || check_name(ctx, dirent, pctx));
+}
+
/*
* Check the directory filetype (if present)
*/
size_t max_block_size;
int hash_flags = 0;
static char *eop_read_dirblock = NULL;
+ int cf_dir = 0;
cd = (struct check_dir_struct *) priv_data;
ibuf = buf = cd->buf;
ctx = cd->ctx;
+ /* We only want filename encoding verification on strict
+ * mode. */
+ if (ext2fs_test_inode_bitmap2(ctx->inode_casefold_map, ino) &&
+ (ctx->fs->super->s_encoding_flags & EXT4_ENC_STRICT_MODE_FL))
+ cf_dir = 1;
+
if (ctx->flags & E2F_FLAG_RUN_RETURN)
return DIRENT_ABORT;
if (check_filetype(ctx, dirent, ino, &cd->pctx))
dir_modified++;
- if (dir_encpolicy_id == NO_ENCRYPTION_POLICY) {
- /* Unencrypted directory */
- if (check_name(ctx, dirent, &cd->pctx))
- dir_modified++;
- } else {
+ if (dir_encpolicy_id != NO_ENCRYPTION_POLICY) {
/* Encrypted directory */
if (dot_state > 1 &&
check_encrypted_dirent(ctx, dirent,
dir_modified++;
goto next;
}
+ } else if (cf_dir) {
+ /* Casefolded directory */
+ if (encoded_check_name(ctx, dirent, &cd->pctx))
+ dir_modified++;
+ } else {
+ /* Unencrypted and uncasefolded directory */
+ if (check_name(ctx, dirent, &cd->pctx))
+ dir_modified++;
}
if (dx_db) {