From ed57478acee281505a140c996b22bfaa3b061bc4 Mon Sep 17 00:00:00 2001 From: Thomas Schoebel-Theuer Date: Mon, 25 Aug 2014 09:43:06 +0200 Subject: [PATCH] light: fix versionlink in emergency mode --- kernel/sy_old/mars_light.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/kernel/sy_old/mars_light.c b/kernel/sy_old/mars_light.c index 1b2d3005..9437a0cf 100644 --- a/kernel/sy_old/mars_light.c +++ b/kernel/sy_old/mars_light.c @@ -3473,12 +3473,19 @@ int make_log_finalize(struct mars_global *global, struct mars_dent *dent) * The secondaries will later stumble over it. */ if (!rot->created_hole) { - char *new_path = path_make("%s/log-%09d-%s", rot->parent_path, rot->max_sequence + 10, my_id()); - if (likely(new_path && !mars_find_dent(global, new_path))) { + int new_sequence = rot->max_sequence + 10; + char *new_vers = path_make("%s/version-%09d-%s", rot->parent_path, new_sequence, my_id()); + char *new_vval = path_make("00000000000000000000000000000000,log-%09d-%s,0:", new_sequence, my_id()); + char *new_path = path_make("%s/log-%09d-%s", rot->parent_path, new_sequence + 1, my_id()); + if (likely(new_vers && new_vval && new_path && + !mars_find_dent(global, new_path))) { MARS_INF_TO(rot->log_say, "EMERGENCY: creating new logfile '%s'\n", new_path); + mars_symlink(new_vval, new_vers, NULL, 0); _create_new_logfile(new_path); rot->created_hole = true; } + brick_string_free(new_vers); + brick_string_free(new_vval); brick_string_free(new_path); } } else {