[Ocfs2-tools-devel] [PATCH 09/11] ocfs2-tools: add xattr support in fsck.ocfs2

Joel Becker Joel.Becker at oracle.com
Wed Mar 11 19:10:37 PDT 2009


On Wed, Mar 11, 2009 at 04:07:15PM +0800, Tiger Yang wrote:
> Joel Becker wrote:
>> 	First, change the above code to merely check a *maximum* count.
>> That is, instead of returning 0 when count >= max_count, you just return
>> max_count.  Then instead of comparing "if (xh->xh_cout != count)", you
>> compare "if (xh->xh_count > count)".  if it happens, you set xh_count to
>> count, which will be an upper bound.  That is, as long as xh_count is
>> less than or equal to the detected count, we can trust xh_count.  Call
>> this check_xattr_count_bounds().
>> 	Next, you use this updated xh_count to check the entries.  This
>> is safe, because your xh_count is either the same as the detected count
>> or less.

>
> I have tried your suggestion. At first get the maximum count and then  
> check entry with it. But I found a problem. In check_entry, when we  
> found a entry is invalid, we will remove it, but the entry count is the  
> maximum count, so memmove operation will ruin the xattr's name and value.
> Because of this, I think we should try our best to get the reasonable  
> count before check entry. If we still couldn't get the count, we have to  
> remove all xattr entry by set count to zero. check_entry with wrong  
> count will cause other problem.

	You use xh_count when checking the entries, not the max_count.
Your max_count is only to ensure that xh_count isn't too large.

Joel

-- 

"The trouble with being punctual is that nobody's there to
 appreciate it."
	- Franklin P. Jones

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