From 19c75877f1b7ca99e37f107d2c6b6b3a7a0d69c5 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Sun, 5 May 2019 09:17:05 +0200 Subject: [PATCH] Allow the --force-device option to work with smart/up/down/devices --- cmdline/snapraid.c | 4 ++++ cmdline/state.c | 22 +++++++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/cmdline/snapraid.c b/cmdline/snapraid.c index 07103a60..ec4f839b 100644 --- a/cmdline/snapraid.c +++ b/cmdline/snapraid.c @@ -1001,6 +1001,10 @@ int main(int argc, char* argv[]) switch (operation) { case OPERATION_FIX : case OPERATION_CHECK : + case OPERATION_SMART : + case OPERATION_DEVICES : + case OPERATION_SPINUP : + case OPERATION_SPINDOWN : break; default : if (opt.force_device) { diff --git a/cmdline/state.c b/cmdline/state.c index b09fba23..37b4290d 100644 --- a/cmdline/state.c +++ b/cmdline/state.c @@ -310,15 +310,23 @@ static void state_config_check(struct snapraid_state* state, const char* path, t for (l = 0; l < state->level; ++l) { for (s = 0; s < state->parity[l].split_mac; ++s) { if (disk->device == state->parity[l].split_map[s].device) { - /* LCOV_EXCL_START */ - log_fatal("Disk '%s' and %s '%s' are on the same device.\n", disk->dir, lev_name(l), state->parity[l].split_map[s].path); + if (state->opt.force_device) { + /* note tha we just ignore the issue */ + /* and we DON'T mark the disk to be skipped */ + /* because we want to use these disks */ + if (!state->opt.no_warnings) + log_fatal("DANGER! Ignoring that disks '%s' and %s '%s' are on the same device\n", disk->dir, lev_name(l), state->parity[l].split_map[s].path); + } else { + /* LCOV_EXCL_START */ + log_fatal("Disk '%s' and %s '%s' are on the same device.\n", disk->dir, lev_name(l), state->parity[l].split_map[s].path); #ifdef _WIN32 - log_fatal("Both have the serial number '%" PRIx64 "'.\n", disk->device); - log_fatal("Try using the 'VolumeID' tool by 'Mark Russinovich'\n"); - log_fatal("to change one of the disk serial.\n"); + log_fatal("Both have the serial number '%" PRIx64 "'.\n", disk->device); + log_fatal("Try using the 'VolumeID' tool by 'Mark Russinovich'\n"); + log_fatal("to change one of the disk serial.\n"); #endif - exit(EXIT_FAILURE); - /* LCOV_EXCL_STOP */ + exit(EXIT_FAILURE); + /* LCOV_EXCL_STOP */ + } } } }