This patch is preparation for adding SD_STATUS_HALT support.

Signed-off-by: MORITA Kazutaka <[email protected]>
---
 sheep/sheep_priv.h |    2 ++
 sheep/store.c      |   37 +++++++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index cccb986..a7d5c25 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -210,6 +210,8 @@ int update_epoch_store(uint32_t epoch);
 
 int set_global_nr_copies(uint32_t copies);
 int get_global_nr_copies(uint32_t *copies);
+int set_cluster_flags(uint32_t flags);
+int get_cluster_flags(uint32_t *flags);
 
 #define NR_GW_WORKER_THREAD 4
 #define NR_IO_WORKER_THREAD 4
diff --git a/sheep/store.c b/sheep/store.c
index 3da5713..a100e79 100644
--- a/sheep/store.c
+++ b/sheep/store.c
@@ -2054,3 +2054,40 @@ int get_global_nr_copies(uint32_t *copies)
 
        return SD_RES_SUCCESS;
 }
+
+int set_cluster_flags(uint32_t flags)
+{
+       int fd, ret;
+
+       fd = open(config_path, O_SYNC | O_WRONLY);
+       if (fd < 0)
+               return SD_RES_EIO;
+
+       ret = jrnl_perform(fd, &flags, sizeof(flags),
+                          offsetof(struct sheepdog_config, flags),
+                          config_path, jrnl_path);
+       close(fd);
+
+       if (ret != 0)
+               return SD_RES_EIO;
+
+       return SD_RES_SUCCESS;
+}
+
+int get_cluster_flags(uint32_t *flags)
+{
+       int fd, ret;
+
+       fd = open(config_path, O_RDONLY);
+       if (fd < 0)
+               return SD_RES_EIO;
+
+       ret = pread64(fd, flags, sizeof(*flags),
+                     offsetof(struct sheepdog_config, flags));
+       close(fd);
+
+       if (ret != sizeof(*flags))
+               return SD_RES_EIO;
+
+       return SD_RES_SUCCESS;
+}
-- 
1.7.2.5

-- 
sheepdog mailing list
[email protected]
http://lists.wpkg.org/mailman/listinfo/sheepdog

Reply via email to