Skip to contentSkip to conversation

patch[3/3] FEATURE DIRDATA - e2fs package changes for dirdata feature.

PATCH pravin shelar 1 participant 1 message Aug 28, 2009

lore
Share & tools
lore
#0 lore raw

changes to e2fs to handle extended dirent data feature.

Thanks,
Pravin.

lib/blkid/probe.h +1 -0
Index: b/lib/blkid/probe.h
===================================================================
@@ -119,6 +119,7 @@ struct ext2_super_block {
 #define EXT4_FEATURE_INCOMPAT_64BIT		0x0080
 #define EXT4_FEATURE_INCOMPAT_MMP		0x0100
 #define EXT4_FEATURE_INCOMPAT_FLEX_BG		0x0200
+#define EXT4_FEATURE_INCOMPAT_DIRDATA		0x1000
 
 #define EXT2_FEATURE_RO_COMPAT_SUPP	(EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
 					 EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
lib/e2p/feature.c +2 -0
Index: b/lib/e2p/feature.c
===================================================================
@@ -75,6 +75,8 @@ static struct feature feature_list[] = {
 			"flex_bg"},
 	{       E2P_FEATURE_INCOMPAT, EXT4_FEATURE_INCOMPAT_MMP,
 			"mmp" },
+	{       E2P_FEATURE_INCOMPAT, EXT4_FEATURE_INCOMPAT_DIRDATA,
+			"dirdata" },
 	{	0, 0, 0 },
 };
 
lib/ext2fs/ext2_fs.h +62 -3

83 lines not on this page · raw message

lib/ext2fs/ext2fs.h +22 -2
Index: b/lib/ext2fs/ext2fs.h
===================================================================
@@ -553,7 +553,8 @@ typedef struct ext2_icount *ext2_icount_
 					 EXT3_FEATURE_INCOMPAT_RECOVER|\
 					 EXT3_FEATURE_INCOMPAT_EXTENTS|\
 					 EXT4_FEATURE_INCOMPAT_FLEX_BG|\
-					 EXT4_FEATURE_INCOMPAT_MMP)
+					 EXT4_FEATURE_INCOMPAT_MMP| \
+					 EXT4_FEATURE_INCOMPAT_DIRDATA)
 #else
 #define EXT2_LIB_FEATURE_INCOMPAT_SUPP	(EXT2_FEATURE_INCOMPAT_FILETYPE|\
 					 EXT3_FEATURE_INCOMPAT_JOURNAL_DEV|\
@@ -561,7 +562,8 @@ typedef struct ext2_icount *ext2_icount_
 					 EXT3_FEATURE_INCOMPAT_RECOVER|\
 					 EXT3_FEATURE_INCOMPAT_EXTENTS|\
 					 EXT4_FEATURE_INCOMPAT_FLEX_BG|\
-					 EXT4_FEATURE_INCOMPAT_MMP)
+					 EXT4_FEATURE_INCOMPAT_MMP| \
+					 EXT4_FEATURE_INCOMPAT_DIRDATA)
 #endif
 #define EXT2_LIB_FEATURE_RO_COMPAT_SUPP	(EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER|\
 					 EXT4_FEATURE_RO_COMPAT_HUGE_FILE|\
@@ -1422,6 +1424,24 @@ _INLINE_ unsigned int ext2fs_div_ceil(un
 		return 0;
 	return ((a - 1) / b) + 1;
 }
+
+_INLINE_ struct ext2_dx_root_info* get_ext2_dx_root_info(ext2_filsys fs, char *buf)
+{
+        struct ext2_dir_entry_2 * de = (struct ext2_dir_entry_2 *) buf;
+
+        if (!(fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_DIRDATA))
+                return (struct ext2_dx_root_info *)(buf +
+			 __EXT4_DIR_REC_LEN(1) +__EXT4_DIR_REC_LEN(2));
+
+        /* get dotdot first */
+        de = (struct ext2_dir_entry_2 *)((char *)de + de->rec_len);
+
+        /* dx root info is after dotdot entry */
+        de = (struct ext2_dir_entry_2 *)((char *)de + EXT4_DIR_REC_LEN(de));
+
+        return (struct ext2_dx_root_info*) de;
+}
+
 #undef _INLINE_
 #endif
 
misc/mke2fs.c +2 -1
Index: b/misc/mke2fs.c
===================================================================
@@ -842,7 +842,8 @@ static __u32 ok_features[3] = {
 		EXT3_FEATURE_INCOMPAT_JOURNAL_DEV|
 		EXT2_FEATURE_INCOMPAT_META_BG|
 		EXT4_FEATURE_INCOMPAT_FLEX_BG|
-		EXT4_FEATURE_INCOMPAT_MMP,
+		EXT4_FEATURE_INCOMPAT_MMP|
+		EXT4_FEATURE_INCOMPAT_DIRDATA,
 	/* R/O compat */
 	EXT2_FEATURE_RO_COMPAT_LARGE_FILE|
 		EXT4_FEATURE_RO_COMPAT_HUGE_FILE|
misc/tune2fs.c +4 -2
Index: b/misc/tune2fs.c
===================================================================
@@ -125,7 +125,8 @@ static __u32 ok_features[3] = {
 	EXT2_FEATURE_INCOMPAT_FILETYPE |
 		EXT3_FEATURE_INCOMPAT_EXTENTS |
 		EXT4_FEATURE_INCOMPAT_FLEX_BG |
-		EXT4_FEATURE_INCOMPAT_MMP,
+		EXT4_FEATURE_INCOMPAT_MMP|
+		EXT4_FEATURE_INCOMPAT_DIRDATA,
 	/* R/O compat */
 	EXT2_FEATURE_RO_COMPAT_LARGE_FILE |
 		EXT4_FEATURE_RO_COMPAT_HUGE_FILE|
@@ -143,7 +144,8 @@ static __u32 clear_ok_features[3] = {
 	/* Incompat */
 	EXT2_FEATURE_INCOMPAT_FILETYPE |
 		EXT4_FEATURE_INCOMPAT_FLEX_BG |
-		EXT4_FEATURE_INCOMPAT_MMP,
+		EXT4_FEATURE_INCOMPAT_MMP|
+		EXT4_FEATURE_INCOMPAT_DIRDATA,
 	/* R/O compat */
 	EXT2_FEATURE_RO_COMPAT_LARGE_FILE |
 		EXT4_FEATURE_RO_COMPAT_HUGE_FILE|
e2fsck/pass1.c +1 -1
Index: b/e2fsck/pass1.c
===================================================================
@@ -1845,7 +1845,7 @@ static int handle_htree(e2fsck_t ctx, st
 	}
 
 	/* XXX should check that beginning matches a directory */
-	root = (struct ext2_dx_root_info *) (block_buf + 24);
+	root = get_ext2_dx_root_info(fs, block_buf);
 
 	if ((root->reserved_zero || root->info_length < 8) &&
 	    fix_problem(ctx, PR_1_HTREE_BADROOT, pctx))
e2fsck/pass2.c +68 -12

176 lines not on this page · raw message

e2fsck/pass3.c +7 -0
Index: b/e2fsck/pass3.c
===================================================================
@@ -606,6 +606,7 @@ static int fix_dotdot_proc(struct ext2_d
 	struct fix_dotdot_struct *fp = (struct fix_dotdot_struct *) priv_data;
 	errcode_t	retval;
 	struct problem_context pctx;
+	__u16 dirdata = 0;
 
 	if ((dirent->name_len & 0xFF) != 2)
 		return 0;
@@ -625,6 +626,9 @@ static int fix_dotdot_proc(struct ext2_d
 		fix_problem(fp->ctx, PR_3_ADJUST_INODE, &pctx);
 	}
 	dirent->inode = fp->parent;
+
+	dirdata  = dirent->name_len & (~EXT2_FT_MASK << 8);
+
 	if (fp->ctx->fs->super->s_feature_incompat &
 	    EXT2_FEATURE_INCOMPAT_FILETYPE)
 		dirent->name_len = (dirent->name_len & 0xFF) |
@@ -632,6 +636,9 @@ static int fix_dotdot_proc(struct ext2_d
 	else
 		dirent->name_len = dirent->name_len & 0xFF;
 
+	if (fp->ctx->fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_DIRDATA)
+		dirent->name_len |= dirdata;
+
 	fp->done++;
 	return DIRENT_ABORT | DIRENT_CHANGED;
 }
e2fsck/problem.c +5 -0
Index: b/e2fsck/problem.c
===================================================================
@@ -1374,6 +1374,11 @@ static struct e2fsck_problem problem_tab
 	  N_("@i %i is badly corrupt (badness value = %N).  "),
 	  PROMPT_CLEAR, PR_PREEN_OK },
 
+        /* Directory dirdata flag set */
+        { PR_2_CLEAR_DIRDATA,
+          N_("@E dirdata length set incorrectly.\n"),
+          PROMPT_CLEAR, PR_PREEN_OK },
+
 	/* Pass 3 errors */
 
 	/* Pass 3: Checking directory connectivity */
e2fsck/problem.h +3 -0
Index: b/e2fsck/problem.h
===================================================================
@@ -825,6 +825,9 @@ struct problem_context {
 /* Inode completely corrupt */
 #define PR_2_INODE_TOOBAD		0x020049
 
+/* Directory dirdata flag set */
+#define PR_2_CLEAR_DIRDATA		0x02f000
+
 /*
  * Pass 3 errors
  */
tests/f_dirdata/expect.1 new file +15 -0
Index: b/tests/f_dirdata/expect.1
===================================================================
@@ -0,0 +1,15 @@
+Pass 1: Checking inodes, blocks, and sizes
+Pass 2: Checking directory structure
+Entry 'foobar2' in /ROOT/dir1 (439) dirdata length set incorrectly.
+Clear? yes
+
+Entry 'foobar1' in /ROOT/dir1 (439) dirdata length set incorrectly.
+Clear? yes
+
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
+test_filesys: 543/5000 files (0.9% non-contiguous), 1731/5000 blocks
+Exit status is 1
tests/f_dirdata/expect.2 new file +7 -0
Index: b/tests/f_dirdata/expect.2
===================================================================
@@ -0,0 +1,7 @@
+Pass 1: Checking inodes, blocks, and sizes
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+test_filesys: 543/5000 files (0.9% non-contiguous), 1731/5000 blocks
+Exit status is 0
tests/f_dirdata/name new file +1 -0
Index: b/tests/f_dirdata/name
===================================================================
@@ -0,0 +1 @@
+corrupted dirdata length.