[Ocfs2-tools-devel] [PATCH 3/4] Ocfs2-tools: Fix bug for fswreck to handle corruption of inlined directory correctly.

Joel Becker Joel.Becker at oracle.com
Thu Jun 25 12:04:56 PDT 2009


On Wed, Jun 24, 2009 at 06:44:14PM +0800, Tristan Ye wrote:
> There is a known issue that inline-data didn't work correctly in fswreck's
> directory codes somehow, where it tries to add dirents to dirblocks even for
> inlined dirs. Therefore, corruptions using add_ent_to_dir() should really use
> ocfs2_link() instead to cover the inlined dirs, as well, the corruptions which
> directly modify dirents also have to consider inlined case(it should be doable
> with ocfs2_dir_iterate()).
> 
> Signed-off-by: Tristan Ye <tristan.ye at oracle.com>

	This looks quite good.  One comment.


> +	if (dcs->oldname && ((dirent->name_len & 0xFF) != dcs->namelen))
> +		return 0;
> +	if (dcs->oldname && strncmp(dcs->oldname, dirent->name,
> +				    dirent->name_len & 0xFF))
> +		return 0;

	I'd create a helper at the top of the file:

static int corrupt_match_dirent(struct dirent_corrupt_struct *dcs,
				struct ocfs2_dir_entry *dirnet)
{
	if (!dcs->oldname)
		return 1;
	if (((dirent->name_len & 0xFF) != dcs->namelen))
		return 0;
	if (strncmp(dcs->oldname, dirent->name, dirent->name_len & 0xFF))
		return 0;
	return 1;
}

	This way you don't have to repeat the comparisons (with the
magic 0xFF) in every function.

Joel

-- 

"We will have to repent in this generation not merely for the
 vitriolic words and actions of the bad people, but for the 
 appalling silence of the good people."
	- Rev. Dr. Martin Luther King, Jr.

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127



More information about the Ocfs2-tools-devel mailing list