The missing cases also show that we weren't propagating the const attribute down to the journal layer, so fix that as well. Signed-off-by: Christoph Hellwig Index: sheepdog/sheep/store.c =================================================================== --- sheepdog.orig/sheep/store.c 2012-04-25 10:14:03.588177222 +0200 +++ sheepdog/sheep/store.c 2012-04-25 10:14:07.200177316 +0200 @@ -2146,7 +2146,7 @@ static int init_objlist_cache(void) int init_store(const char *d) { int ret; - uint8_t driver_name[STORE_LEN]; + char driver_name[STORE_LEN]; ret = init_obj_path(d); if (ret) @@ -2172,8 +2172,8 @@ int init_store(const char *d) if (ret != SD_RES_SUCCESS) return 1; - if (strlen((char *)driver_name)) - sd_store = find_store_driver((char *)driver_name); + if (strlen(driver_name)) + sd_store = find_store_driver(driver_name); if (sd_store) { ret = sd_store->init(obj_path); @@ -2306,7 +2306,7 @@ out: return ret; } -int set_cluster_store(const uint8_t *name) +int set_cluster_store(const char *name) { int fd, ret = SD_RES_EIO, len; void *jd; @@ -2315,8 +2315,10 @@ int set_cluster_store(const uint8_t *nam if (fd < 0) goto out; - len = strlen((char *)name) + 1; - jd = jrnl_begin((void *)name, len, + len = strlen(name) + 1; + if (len > STORE_LEN) + goto err; + jd = jrnl_begin(name, len, offsetof(struct sheepdog_config, store), config_path, jrnl_path); if (!jd) { @@ -2335,7 +2337,7 @@ out: return ret; } -int get_cluster_store(uint8_t *buf) +int get_cluster_store(char *buf) { int fd, ret = SD_RES_EIO; Index: sheepdog/sheep/farm/farm.c =================================================================== --- sheepdog.orig/sheep/farm/farm.c 2012-04-25 10:14:06.348177294 +0200 +++ sheepdog/sheep/farm/farm.c 2012-04-25 10:14:07.200177316 +0200 @@ -673,7 +673,7 @@ static int farm_format(struct siocb *ioc { char path[PATH_MAX]; unsigned ret; - const uint8_t name[] = "farm"; + const char name[] = "farm"; dprintf("try get a clean store\n"); snprintf(path, sizeof(path), "%s", obj_path); Index: sheepdog/sheep/group.c =================================================================== --- sheepdog.orig/sheep/group.c 2012-04-25 10:14:06.348177294 +0200 +++ sheepdog/sheep/group.c 2012-04-25 10:14:07.204177316 +0200 @@ -573,9 +573,8 @@ static void update_cluster_info(struct j if (!sd_store && strlen((char *)msg->store)) { sd_store = find_store_driver((char *)msg->store); if (sd_store) { - const uint8_t *name = (uint8_t *)sd_store->name; sd_store->init(obj_path); - if (set_cluster_store(name) != SD_RES_SUCCESS) + if (set_cluster_store(sd_store->name) != SD_RES_SUCCESS) panic("failed to store into config file\n"); } else panic("backend store %s not supported\n", msg->store); Index: sheepdog/sheep/journal.c =================================================================== --- sheepdog.orig/sheep/journal.c 2012-04-25 10:12:25.604174716 +0200 +++ sheepdog/sheep/journal.c 2012-04-25 10:14:07.204177316 +0200 @@ -30,7 +30,7 @@ struct jrnl_head { struct jrnl_descriptor { struct jrnl_head head; - void *data; + const void *data; int fd; /* Open file fd */ int target_fd; char path[256]; @@ -179,7 +179,7 @@ static int jrnl_apply_to_target_object(s /* * We cannot use this function for concurrent write operations */ -struct jrnl_descriptor *jrnl_begin(void *buf, size_t count, off_t offset, +struct jrnl_descriptor *jrnl_begin(const void *buf, size_t count, off_t offset, const char *path, const char *jrnl_dir) { int ret; Index: sheepdog/sheep/sheep_priv.h =================================================================== --- sheepdog.orig/sheep/sheep_priv.h 2012-04-25 10:14:06.348177294 +0200 +++ sheepdog/sheep/sheep_priv.h 2012-04-25 10:14:07.208177316 +0200 @@ -269,8 +269,8 @@ int set_cluster_copies(uint8_t copies); int get_cluster_copies(uint8_t *copies); int set_cluster_flags(uint16_t flags); int get_cluster_flags(uint16_t *flags); -int set_cluster_store(const uint8_t *name); -int get_cluster_store(uint8_t *buf); +int set_cluster_store(const char *name); +int get_cluster_store(char *buf); int store_create_and_write_obj(const struct sd_req *, struct sd_rsp *, void *); int store_write_obj(const struct sd_req *, struct sd_rsp *, void *); @@ -331,7 +331,7 @@ int do_process_main(struct sd_op_templat struct sd_rsp *rsp, void *data); /* Journal */ -struct jrnl_descriptor *jrnl_begin(void *buf, size_t count, off_t offset, +struct jrnl_descriptor *jrnl_begin(const void *buf, size_t count, off_t offset, const char *path, const char *jrnl_dir); int jrnl_end(struct jrnl_descriptor * jd); int jrnl_recover(const char *jrnl_dir); Index: sheepdog/sheep/simple_store.c =================================================================== --- sheepdog.orig/sheep/simple_store.c 2012-04-25 10:14:06.348177294 +0200 +++ sheepdog/sheep/simple_store.c 2012-04-25 10:14:07.208177316 +0200 @@ -319,7 +319,7 @@ static int simple_store_format(struct si { char path[PATH_MAX]; unsigned epoch = iocb->epoch, ret, i; - const uint8_t name[] = "simple"; + const char name[] = "simple"; dprintf("epoch %u\n", epoch); for (i = 1; i <= epoch; i++) {