summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src
diff options
context:
space:
mode:
authorSachin Pandit <spandit@redhat.com>2014-01-08 07:36:50 +0530
committerSachin Pandit <spandit@redhat.com>2014-01-13 10:44:53 +0530
commit33c45ff71cb43eec7cdcee054a6a55b7c3aaa8fb (patch)
treebbf509eecdb86177d20782f635fad253b2dd50b8 /libglusterfs/src
parent847e14ccbaddd5d1f06f9200cba063ee007199ad (diff)
glusterd/snapshot : Making CG Name persistent and handle Snap Description Issue.
1)Write the CG Name in the "snap_list.info" file, so that CG Name is not lost when we restart the glusterd. 2)Fixes the issue where Description given for CG, as a part of create command, was getting stored as snap description rather than CG Description. 3)Fixes the problem with glusterd restart when we have multiple words in Snap Descripition Change-Id: I3129c53d1ec54dd170ca1300583f278f58c4e0e2 BUG: 1044476 Signed-off-by: Sachin Pandit <spandit@redhat.com>
Diffstat (limited to 'libglusterfs/src')
-rw-r--r--libglusterfs/src/store.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/libglusterfs/src/store.c b/libglusterfs/src/store.c
index 55027fa9b..64497e9bb 100644
--- a/libglusterfs/src/store.c
+++ b/libglusterfs/src/store.c
@@ -168,10 +168,12 @@ int
gf_store_read_and_tokenize (FILE *file, char *str, char **iter_key,
char **iter_val, gf_store_op_errno_t *store_errno)
{
- int32_t ret = -1;
- char *savetok = NULL;
- char *key = NULL;
- char *value = NULL;
+ int32_t ret = -1;
+ char *savetok = NULL;
+ char *key = NULL;
+ char *value = NULL;
+ char *temp = NULL;
+ size_t str_len = 0;
GF_ASSERT (file);
GF_ASSERT (str);
@@ -179,8 +181,12 @@ gf_store_read_and_tokenize (FILE *file, char *str, char **iter_key,
GF_ASSERT (iter_val);
GF_ASSERT (store_errno);
- ret = fscanf (file, "%s", str);
- if (ret <= 0 || feof (file)) {
+ temp = fgets (str, PATH_MAX, file);
+ str_len = strlen(str);
+ str[str_len - 1] = '\0';
+ /* Truncate the "\n", as fgets stores "\n" in str */
+
+ if (temp == NULL || feof (file)) {
ret = -1;
*store_errno = GD_STORE_EOF;
goto out;
@@ -253,8 +259,13 @@ gf_store_retrieve_value (gf_store_handle_t *handle, char *key, char **value)
goto out;
}
- scan_str = GF_CALLOC (1, st.st_size,
+ /* "st.st_size + 1" is used as we are fetching each
+ * line of a file using fgets, fgets will append "\0"
+ * to the end of the string
+ */
+ scan_str = GF_CALLOC (1, st.st_size + 1,
gf_common_mt_char);
+
if (scan_str == NULL) {
ret = -1;
store_errno = GD_STORE_ENOMEM;
@@ -532,7 +543,11 @@ gf_store_iter_get_next (gf_store_iter_t *iter, char **key, char **value,
goto out;
}
- scan_str = GF_CALLOC (1, st.st_size,
+ /* "st.st_size + 1" is used as we are fetching each
+ * line of a file using fgets, fgets will append "\0"
+ * to the end of the string
+ */
+ scan_str = GF_CALLOC (1, st.st_size + 1,
gf_common_mt_char);
if (!scan_str) {
ret = -1;