[Ocfs2-tools-devel] [PATCH 1/1] Add a new method for exclusive option check in tunefs.ocfs2.

Joel Becker Joel.Becker at oracle.com
Tue Nov 6 13:15:44 PST 2007


On Tue, Nov 06, 2007 at 05:00:42PM +0800, Tao Ma wrote:
> In tunefs.ocfs2, we often have some exclusive options that can't
> be done with others, and it is tedious when a new exclusive option
> is going to be added since all other option checks have to be
> modified accordingly.
...
> +errcode_t exclusive_option_check(char *para, int size)
> +{
> +	int start;
> +	int len = sizeof(opts);
> +	char *content = NULL;
> +
> +	if (resize)
> +		return 1;
> +
> +	/* We check from this field of opts. */
> +	start = (char *)&opts.num_slots - (char *)&opts;
> +	content = (char *)&opts.num_slots;

	Wow is this ugly.  Can't we do something like a bitfield
instead?  Or even just have a char* on the options list that takes the
name of the first exclusive option set.  So that you can do

if (opts.exclusive) 
	error("Cannot combine operations %s and %s", opts.exclusive,
	      this_opt_name);
else
	opts.exclusive = this_opt_name;

right when you are parsing the options.

Joel


-- 

"Conservative, n.  A statesman who is enamoured of existing evils,
 as distinguished from the Liberal, who wishes to replace them
 with others."
	- Ambrose Bierce, The Devil's Dictionary

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