From 3ef01a98dba71323550af9515be202be5475c9d8 Mon Sep 17 00:00:00 2001 From: Thomas Schoebel-Theuer Date: Thu, 3 Nov 2011 12:31:47 +0100 Subject: [PATCH] allow override of power switches, fix __make_copy() --- mars_server.c | 1 + sy_old/mars_light.c | 12 +++++++++++- sy_old/strategy.h | 1 + sy_old/sy_generic.c | 9 +++++++++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/mars_server.c b/mars_server.c index 95446e1f..e72d4a8a 100644 --- a/mars_server.c +++ b/mars_server.c @@ -308,6 +308,7 @@ int handler_thread(void *data) (const struct generic_brick_type*)_bio_brick_type, (const struct generic_brick_type*[]){}, NULL, + 1, // start always path, (const char *[]){}, 0); diff --git a/sy_old/mars_light.c b/sy_old/mars_light.c index 3812dab2..53f4fd5c 100644 --- a/sy_old/mars_light.c +++ b/sy_old/mars_light.c @@ -528,6 +528,7 @@ int __make_copy( (const struct generic_brick_type*)&bio_brick_type, (const struct generic_brick_type*[]){}, NULL, + 1, // start always cc.fullpath[i], (const char *[]){}, 0); @@ -552,6 +553,7 @@ int __make_copy( (const struct generic_brick_type*)©_brick_type, (const struct generic_brick_type*[]){NULL,NULL,NULL,NULL}, "%s", + 0, // let switch decide "%s", (const char *[]){"%s", "%s", "%s", "%s"}, 4, @@ -1424,6 +1426,7 @@ int make_log_init(void *buf, struct mars_dent *dent) (const struct generic_brick_type*)&aio_brick_type, (const struct generic_brick_type*[]){}, NULL, + 1, // start always "%s/%s", (const char *[]){}, 0, @@ -1465,6 +1468,7 @@ int make_log_init(void *buf, struct mars_dent *dent) (const struct generic_brick_type*)&trans_logger_brick_type, (const struct generic_brick_type*[]){NULL}, switch_path, + 0, // let switch decide "%s/logger", (const char *[]){"%s/data-%s"}, 1, @@ -1803,6 +1807,7 @@ void _rotate_trans(struct mars_rotate *rot) (const struct generic_brick_type*)&aio_brick_type, (const struct generic_brick_type*[]){}, NULL, + 0, // let switch decide rot->next_relevant_log->d_path, (const char *[]){}, 0); @@ -1910,6 +1915,7 @@ int _start_trans(struct mars_rotate *rot) (const struct generic_brick_type*)&aio_brick_type, (const struct generic_brick_type*[]){}, NULL, + 1, // start always rot->relevant_log->d_path, (const char *[]){}, 0); @@ -2154,6 +2160,7 @@ int make_bio(void *buf, struct mars_dent *dent) (const struct generic_brick_type*)&bio_brick_type, (const struct generic_brick_type*[]){}, NULL, + 1, // start always dent->d_path, (const char *[]){}, 0); @@ -2246,7 +2253,8 @@ int make_dev(void *buf, struct mars_dent *dent) dent->d_argv[0], (const struct generic_brick_type*)&if_brick_type, (const struct generic_brick_type*[]){(const struct generic_brick_type*)&trans_logger_brick_type}, - switch_on ? NULL : "", // KLUDGE + NULL, + switch_on ? 1 : -1, "%s/device-%s", (const char *[]){"%s/logger"}, 1, @@ -2325,6 +2333,7 @@ static int _make_direct(void *buf, struct mars_dent *dent) (const struct generic_brick_type*)&bio_brick_type, (const struct generic_brick_type*[]){}, NULL, + 0, "%s", (const char *[]){}, 0, @@ -2346,6 +2355,7 @@ static int _make_direct(void *buf, struct mars_dent *dent) (const struct generic_brick_type*)&if_brick_type, (const struct generic_brick_type*[]){NULL}, NULL, + 0, "%s/directdevice-%s", (const char *[]){ "%s" }, 1, diff --git a/sy_old/strategy.h b/sy_old/strategy.h index d2a4878f..4ead887b 100644 --- a/sy_old/strategy.h +++ b/sy_old/strategy.h @@ -99,6 +99,7 @@ extern struct mars_brick *make_brick_all( const struct generic_brick_type *new_brick_type, const struct generic_brick_type *prev_brick_type[], const char *switch_fmt, + int switch_override, // -1 = off, +1 = on, 0 = let switch decide const char *new_fmt, const char *prev_fmt[], int prev_count, diff --git a/sy_old/sy_generic.c b/sy_old/sy_generic.c index 4a620342..2a5d0c56 100644 --- a/sy_old/sy_generic.c +++ b/sy_old/sy_generic.c @@ -1163,6 +1163,7 @@ struct mars_brick *make_brick_all( const struct generic_brick_type *new_brick_type, const struct generic_brick_type *prev_brick_type[], const char *switch_fmt, + int switch_override, // -1 = off, +1 = on, 0 = let switch decide const char *new_fmt, const char *prev_fmt[], int prev_count, @@ -1207,6 +1208,10 @@ struct mars_brick *make_brick_all( sscanf(test->new_link, "%d", &switch_state); } } + if (switch_override > 0) + switch_state = true; + else if (switch_override < 0) + switch_state = false; if (global && !global->global_power.button) { switch_state = false; } @@ -1244,6 +1249,10 @@ struct mars_brick *make_brick_all( goto err; } MARS_DBG("------> predecessor %d path = '%s'\n", i, path); + if (!prev[i]->power.led_on) { + switch_state = false; + MARS_DBG("predecessor power is not on\n"); + } } // some generic brick replacements (better performance / network functionality)