summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMohammed Junaid Ahmed <junaid@gluster.com>2011-07-12 12:31:37 +0000
committerAnand Avati <avati@gluster.com>2011-07-12 22:09:27 -0700
commit446e71501b40a5a8f7b53e3086d32404111da37c (patch)
tree105942dc753d852b5eb0c8ec5be08f3065318198
parent9a12df6c6e47553005861de4ae97f571f270af83 (diff)
mgmt/glusterd: write complete string contained in value in to the volinfo file.
Currently, we are writing 4096 bytes of value variable to the volinfo file irrespective of its lenght, thus tampering with the volinfo file structure. Signed-off-by: Junaid <junaid@gluster.com> Signed-off-by: Anand Avati <avati@gluster.com> BUG: 3154 (glusterd fails to restart) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=3154
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
index ba59d790ed2..f3fa2c0aabe 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
@@ -908,16 +908,20 @@ int32_t
glusterd_store_save_value (int fd, char *key, char *value)
{
int32_t ret = -1;
- char buf[4096] = {0,};
GF_ASSERT (fd > 0);
GF_ASSERT (key);
GF_ASSERT (value);
- snprintf (buf, sizeof (buf), "%s=%s\n", key, value);
- ret = write (fd, buf, strlen (buf));
+ ret = write (fd, key, strlen (key));
+ if (ret > 0)
+ ret = write (fd, "=", strlen ("="));
+ if (ret > 0)
+ ret = write (fd, value, strlen (value));
+ if (ret > 0)
+ ret = write (fd, "\n", strlen ("\n"));
- if (ret < 0) {
+ if (ret <= 0) {
gf_log ("", GF_LOG_CRITICAL, "Unable to store key: %s,"
"value: %s, error: %s", key, value,
strerror (errno));