diff options
author | Kaushal M <kaushal@redhat.com> | 2012-04-04 12:00:30 +0530 |
---|---|---|
committer | Anand Avati <avati@redhat.com> | 2012-06-07 11:42:10 -0700 |
commit | 81e7464a54165b5d8b40847355d3bb6fe7b6e9df (patch) | |
tree | 990c4864efad87fefa6f24fb7a876c28f26c4238 /libglusterfs/src/options.h | |
parent | 86ff555eaaefb616b3dde5924a40271d99314861 (diff) |
libglusterfs : Fix validation for integer volume options.
Integer volume options which specified only the min value as 0, would not be
validated during "volume set".
The range check for an option happened only if both min and max were not 0. In
the above case, even though a minium was specified, the range check did not
happen as both min and max were 0.
To allow forced validation in such cases, a new member, "validate", has been
added to volume_options_t. This member takes the values GF_OPT_VALIDATE_BOTH,
GF_OPT_VALIDATE_MIN and GF_OPT_VALIDATE_MAX (GF_OPT_VALIDATE_BOTH is the
default).
Change-Id: I351de0eedb6028120e5c0b073ee5d9c141dee717
BUG: 809847
Signed-off-by: Kaushal M <kaushal@redhat.com>
Reviewed-on: http://review.gluster.com/3084
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'libglusterfs/src/options.h')
-rw-r--r-- | libglusterfs/src/options.h | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/libglusterfs/src/options.h b/libglusterfs/src/options.h index 8c0ff2499c9..1775ad9ea71 100644 --- a/libglusterfs/src/options.h +++ b/libglusterfs/src/options.h @@ -41,22 +41,32 @@ typedef enum { GF_OPTION_TYPE_MAX, } volume_option_type_t; +typedef enum { + GF_OPT_VALIDATE_BOTH = 0, + GF_OPT_VALIDATE_MIN, + GF_OPT_VALIDATE_MAX, +} opt_validate_type_t; #define ZR_VOLUME_MAX_NUM_KEY 4 #define ZR_OPTION_MAX_ARRAY_SIZE 64 /* Each translator should define this structure */ typedef struct volume_options { - char *key[ZR_VOLUME_MAX_NUM_KEY]; + char *key[ZR_VOLUME_MAX_NUM_KEY]; /* different key, same meaning */ - volume_option_type_t type; - int64_t min; /* 0 means no range */ - int64_t max; /* 0 means no range */ - char *value[ZR_OPTION_MAX_ARRAY_SIZE]; + volume_option_type_t type; + int64_t min; /* 0 means no range */ + int64_t max; /* 0 means no range */ + char *value[ZR_OPTION_MAX_ARRAY_SIZE]; /* If specified, will check for one of the value from this array */ - char *default_value; - char *description; /* about the key */ + char *default_value; + char *description; /* about the key */ + /* Required for int options where only the min value + * is given and is 0. This will cause validation not to + * happen + */ + opt_validate_type_t validate; } volume_option_t; |