[Ocfs2-tools-devel] [PATCH 28/39] mkfs.ocfs2: Add the cluster stack options.
Joel Becker
Joel.Becker at oracle.com
Fri May 23 18:08:16 PDT 2008
On Fri, May 23, 2008 at 05:14:11PM -0700, Sunil Mushran wrote:
>> +static int pick_one(State *s, const char *what_is_it,
>> + const char *user_value, const char *o2cb_value,
>> + const char *disk_value, char **ret_value)
>> +{
>> + int rc = -1;
>> +
>> + /*
>> + * First, compare o2cb and disk values. If we get past this
>> + * block (via match or override), the o2cb value takes precedence.
>> + */
>> + if (disk_value) {
>> + if (o2cb_value) {
>> + if (strcmp(o2cb_value, disk_value)) {
>> + fprintf(stderr,
>> + "%s is configured to use %s \"%s\", but \"%s\" is currently running.\n"
>> + "%s will not be able to determine if the filesystem is in use.\n",
>> + s->device_name, what_is_it,
>> + disk_value, o2cb_value,
>> + s->progname);
>> + if (!s->force) {
>> + fprintf(stderr,
>> + "To skip this check, use --force or -F\n");
>> + goto out;
>> + }
>> + fprintf(stdout,
>> + "Overwrite of disk information forced\n");
>> + }
>> + }
>> + }
>> +
>> + if (user_value) {
>> + if (o2cb_value) {
>> + if (strcmp(o2cb_value, user_value)) {
>> + fprintf(stderr, "%s \"%s\" was requested, but \"%s\" is running.\n",
>> + what_is_it, user_value, o2cb_value);
>> + if (!s->force) {
>> + fprintf(stderr,
>> + "To skip this check, use --force or -F\n");
>> + goto out;
>> + }
>> + fprintf(stdout, "%s forced\n", what_is_it);
>> + }
>> + } else if (disk_value) {
>> + if (strcmp(disk_value, user_value)) {
>> + fprintf(stderr, "%s \"%s\" was requested, but %s is configured for \"%s\".\n",
>> + what_is_it, user_value,
>> + s->device_name, disk_value);
>> + if (!s->force) {
>> + fprintf(stderr,
>> + "To skip this check, use --force or -F\n");
>> + goto out;
>> + }
>> + fprintf(stderr, "%s forced\n", what_is_it);
>> + }
>> + }
>> + *ret_value = strdup(user_value);
>> + } else if (o2cb_value)
>> + *ret_value = strdup(o2cb_value);
>> + else if (disk_value)
>> + *ret_value = strdup(disk_value);
>> +
>> + rc = 0;
>> +
>> +out:
>> + return rc;;
>> +}
>>
>
> Wondering if we can simplify this.
Nope. It's dealing with the multitude of sources for these
values:
1. The command line
2. The physical disk
3. The running configuration
This code encodes an order of precedence for these sources.
Mark and I had a long discussion about it when I first wrote it.
Joel
--
"Baby, even the losers
Get luck sometimes.
Even the losers
Keep a little bit of pride."
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