summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorPrasanna Kumar Kalever <prasanna.kalever@redhat.com>2017-06-12 11:59:13 +0530
committerPrasanna Kumar Kalever <prasanna.kalever@redhat.com>2017-06-22 16:30:46 +0530
commit94c79620db4451bf804d6ab631c9ca59759dbc21 (patch)
treeee5c0e9430fb30812753ac1911bd8b5c163cb5fd /utils
parent8bb5dd787e84f719940230adb24642653fcaec77 (diff)
block: add support to prealloc = full | no option
currently we allocate sparse files for block backends in the gluster volume, with 'prealloc = full' option introduced by this patch we should be able to fully preallocate the backend block file. Change-Id: Ibf32df5f978f732a3fd248693170463da6d08268 Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Diffstat (limited to 'utils')
-rw-r--r--utils/common.c25
-rw-r--r--utils/common.h48
2 files changed, 73 insertions, 0 deletions
diff --git a/utils/common.c b/utils/common.c
index c6d1c34..8a8f303 100644
--- a/utils/common.c
+++ b/utils/common.c
@@ -121,3 +121,28 @@ glusterBlockFormatSize(const char *dom, size_t bytes)
return buf;
}
+
+
+/* Return value and meaning
+ * 1 - true/set
+ * 0 - false/unset
+ * -1 - unknown string
+ */
+int
+convertStringToTrillianParse(const char *opt)
+{
+ int i;
+
+
+ if (!opt) {
+ return -1;
+ }
+
+ for (i = 1; i < GB_BOOL_MAX; i++) {
+ if (!strcmp(opt, ConvertStringToTrillianLookup[i])) {
+ return i%2;
+ }
+ }
+
+ return -1;
+}
diff --git a/utils/common.h b/utils/common.h
index 118d3f0..6503218 100644
--- a/utils/common.h
+++ b/utils/common.h
@@ -50,10 +50,58 @@ static const char *const JsonResponseFormatLookup[] = {
};
+/* Always add new boolean data in a way that, word with jist
+ * 'yes/true' first to assign a odd number to it */
+typedef enum ConvertStringToTrillian {
+ GB_BOOL_YES = 1,
+ GB_BOOL_NO = 2,
+
+ GB_BOOL_TRUE = 3,
+ GB_BOOL_FALSE = 4,
+
+ GB_BOOL_ENABLE = 5,
+ GB_BOOL_DISABLE = 6,
+
+ GB_BOOL_ONE = 7,
+ GB_BOOL_ZERO = 8,
+
+ GB_BOOL_SET = 9,
+ GB_BOOL_UNSET = 10,
+
+ GB_BOOL_FULL = 11,
+
+ GB_BOOL_MAX
+} ConvertStringToBool;
+
+
+static const char *const ConvertStringToTrillianLookup[] = {
+ [GB_BOOL_YES] = "yes",
+ [GB_BOOL_NO] = "no",
+
+ [GB_BOOL_TRUE] = "true",
+ [GB_BOOL_FALSE] = "false",
+
+ [GB_BOOL_ENABLE] = "enable",
+ [GB_BOOL_DISABLE] = "disable",
+
+ [GB_BOOL_ONE] = "1", /* true */
+ [GB_BOOL_ZERO] = "0",
+
+ [GB_BOOL_SET] = "set",
+ [GB_BOOL_UNSET] = "unset",
+
+ [GB_BOOL_FULL] = "full",
+
+ [GB_BOOL_MAX] = NULL,
+};
+
+
enum JsonResponseFormat jsonResponseFormatParse(const char *opt);
ssize_t glusterBlockParseSize(const char *dom, char *value);
char* glusterBlockFormatSize(const char *dom, size_t bytes);
+int convertStringToTrillianParse(const char *opt);
+
# endif /* _COMMON_H */