From: Liu Yuan <[email protected]> This can stop sheep from rebooting when disk store is a meta-store, such as in a disordered path parameter
$ sheep /disk1,/disk2,/meta-store # abort We can only reboot when first component is meta-store to avoid mess-up. Signed-off-by: Liu Yuan <[email protected]> --- sheep/store.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/sheep/store.c b/sheep/store.c index 174ee32..28e2ab7 100644 --- a/sheep/store.c +++ b/sheep/store.c @@ -253,6 +253,19 @@ static inline int check_path_len(const char *path) return 0; } +static int is_meta_store(const char *path) +{ + char conf[PATH_MAX]; + char epoch[PATH_MAX]; + + snprintf(conf, PATH_MAX, "%s/config", path); + snprintf(epoch, PATH_MAX, "%s/epoch", path); + if (!access(conf, R_OK) && !access(epoch, R_OK)) + return true; + + return false; +} + static int init_obj_path(const char *base_path, char *argp) { char *p; @@ -278,6 +291,10 @@ static int init_obj_path(const char *base_path, char *argp) md_add_disk(obj_path); } else { do { + if (is_meta_store(p)) { + sd_eprintf("%s is meta-store, abort", p); + return -1; + } md_add_disk(p); } while ((p = strtok(NULL, ","))); } -- 1.7.9.5 -- sheepdog mailing list [email protected] http://lists.wpkg.org/mailman/listinfo/sheepdog
