[RESEND v2 09/13] mke2fs/tune2fs: add dirdata feature support
From: Artem Blagodarenko <hidden>
Date: 2026-09-03 22:02:54
Subsystem:
library code, the rest · Maintainers:
Andrew Morton, Linus Torvalds
From: Artem Blagodarenko <redacted> Add user-facing feature support for dirdata in filesystem creation and modification tools. Users can now create filesystems with the dirdata feature or enable it on existing filesystems. Usage examples: mke2fs -O dirdata /dev/sda1 # Create filesystem with dirdata tune2fs -O dirdata /dev/sda1 # Enable dirdata on existing filesystem Signed-off-by: Andreas Dilger <redacted> Signed-off-by: Pravin Shelar <redacted> Signed-off-by: Artem Blagodarenko <redacted> Reviewed-by: Andreas Dilger <redacted> --- e2fsck/pass2.c | 3 +-- lib/ext2fs/dirblock.c | 7 ++++--- lib/ext2fs/ext2fs.h | 2 +- misc/mke2fs.c | 1 + misc/tune2fs.c | 2 ++ 5 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c
index 938942a80..9a0f6f772 100644
--- a/e2fsck/pass2.c
+++ b/e2fsck/pass2.c@@ -435,8 +435,7 @@ void ext2_fix_dirent_dirdata(struct ext2_dir_entry *de) int e2fsck_check_dirent_data(e2fsck_t ctx, struct ext2_dir_entry *de, unsigned int offset, struct problem_context *pctx) { - if (!(ctx->fs->super->s_feature_incompat & - EXT4_FEATURE_INCOMPAT_DIRDATA)) { + if (!ext2fs_has_feature_dirdata(ctx->fs->super)) { if ((de->name_len >> 8) & ~EXT2_FT_MASK) { /* clear dirent extra data flags. */ if (fix_problem(ctx, PR_2_CLEAR_DIRDATA, pctx)) {
diff --git a/lib/ext2fs/dirblock.c b/lib/ext2fs/dirblock.c
index d1d5a9e7f..fa7cc83ff 100644
--- a/lib/ext2fs/dirblock.c
+++ b/lib/ext2fs/dirblock.c@@ -74,13 +74,14 @@ int ext2_get_dirdata_field_size(struct ext2_dir_entry *de, dirdata_flags >>= 1; } - /* add NUL terminator byte to dirdata length */ - return dlen + (dlen != 0); + return dlen; } int ext2_get_dirdata_size(struct ext2_dir_entry *de) { - return ext2_get_dirdata_field_size(de, ~EXT2_FT_MASK); + int size = ext2_get_dirdata_field_size(de, ~EXT2_FT_MASK); + /* Add 1 becasue NULL after the name */ + return size + (size ? 1 : 0); } errcode_t ext2fs_read_dir_block2(ext2_filsys fs, blk_t block,
diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h
index cf12716e3..b14ba0a34 100644
--- a/lib/ext2fs/ext2fs.h
+++ b/lib/ext2fs/ext2fs.h@@ -2276,7 +2276,7 @@ _INLINE_ struct ext2_dx_root_info *ext2fs_get_dx_root_info(ext2_filsys fs, de = (struct ext2_dir_entry *)((char *)de + de->rec_len); /* dx root info is after dotdot entry */ - de = EXT2_NEXT_DIRENT(de); + de = (struct ext2_dir_entry *)((char *)de + EXT2_DIRENT_REC_LEN(de)); return (struct ext2_dx_root_info *)de; }
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index dd8c53d90..2bcb7036e 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c@@ -1279,6 +1279,7 @@ static __u32 ok_features[3] = { EXT4_FEATURE_INCOMPAT_FLEX_BG| EXT4_FEATURE_INCOMPAT_EA_INODE| EXT4_FEATURE_INCOMPAT_MMP | + EXT4_FEATURE_INCOMPAT_DIRDATA| EXT4_FEATURE_INCOMPAT_64BIT| EXT4_FEATURE_INCOMPAT_INLINE_DATA| EXT4_FEATURE_INCOMPAT_ENCRYPT |
diff --git a/misc/tune2fs.c b/misc/tune2fs.c
index 3db57632c..c5a40c5c9 100644
--- a/misc/tune2fs.c
+++ b/misc/tune2fs.c@@ -192,6 +192,7 @@ static __u32 ok_features[3] = { EXT4_FEATURE_INCOMPAT_FLEX_BG | EXT4_FEATURE_INCOMPAT_EA_INODE| EXT4_FEATURE_INCOMPAT_MMP | + EXT4_FEATURE_INCOMPAT_DIRDATA | EXT4_FEATURE_INCOMPAT_64BIT | EXT4_FEATURE_INCOMPAT_ENCRYPT | EXT4_FEATURE_INCOMPAT_CSUM_SEED |
@@ -222,6 +223,7 @@ static __u32 clear_ok_features[3] = { EXT2_FEATURE_INCOMPAT_FILETYPE | EXT4_FEATURE_INCOMPAT_FLEX_BG | EXT4_FEATURE_INCOMPAT_MMP | + EXT4_FEATURE_INCOMPAT_DIRDATA | EXT4_FEATURE_INCOMPAT_64BIT | EXT4_FEATURE_INCOMPAT_CSUM_SEED | EXT4_FEATURE_INCOMPAT_CASEFOLD,
--
2.43.7