diff --git a/cmdline/device.c b/cmdline/device.c index 5088c1a0..a69f2855 100644 --- a/cmdline/device.c +++ b/cmdline/device.c @@ -1082,6 +1082,15 @@ int devtest(tommy_list* high, tommy_list* low, int operation) return 0; } +void state_devmap(struct snapraid_state* state) +{ + /* map device if not already done */ + if (!state->mapped_device) { + devmap(); + state->mapped_device = 1; + } +} + int state_device(struct snapraid_state* state, int operation, tommy_list* filterlist_disk) { tommy_node* i; @@ -1091,17 +1100,13 @@ int state_device(struct snapraid_state* state, int operation, tommy_list* filter int ret; time_t now = time(0); - /* map device if not already done */ - if (!state->mapped_device) { - devmap(); - state->mapped_device = 1; - } - switch (operation) { case DEVICE_UP : msg_progress("Spinup...\n"); break; case DEVICE_DOWN : msg_progress("Spindown...\n"); break; } + state_devmap(state); + tommy_list_init(&high); tommy_list_init(&low); diff --git a/cmdline/state.h b/cmdline/state.h index 04cab782..0545cd00 100644 --- a/cmdline/state.h +++ b/cmdline/state.h @@ -253,6 +253,11 @@ void state_scan(struct snapraid_state* state); */ void state_touch(struct snapraid_state* state); +/** + * Map devices if not already done. + */ +void state_devmap(struct snapraid_state* state); + /** * Devices operations. */ diff --git a/cmdline/thermal.c b/cmdline/thermal.c index 36ee1926..924b0260 100644 --- a/cmdline/thermal.c +++ b/cmdline/thermal.c @@ -128,6 +128,8 @@ void state_thermal(struct snapraid_state* state, time_t now) if (state->thermal_temperature_limit == 0) return; + state_devmap(state); + tommy_list_init(&high); tommy_list_init(&low);