Be more explicit if smart/down is not supported

This commit is contained in:
Andrea Mazzoleni 2016-02-06 10:20:31 +01:00
parent 94bfe2e4ae
commit 104f8b065e
2 changed files with 14 additions and 3 deletions

View file

@ -944,15 +944,19 @@ void state_device(struct snapraid_state* state, int operation, tommy_list* filte
ret = devquery(&high, &low, operation, others);
}
/* if the list is empty, it's not supported in this platform */
if (ret == 0 && tommy_list_empty(&low))
ret = -1;
if (ret != 0) {
const char* ope = 0;
switch (operation) {
case DEVICE_UP : ope = "Spinup"; break;
case DEVICE_DOWN : ope = "Spindown"; break;
case DEVICE_LIST : ope = "List"; break;
case DEVICE_SMART : ope = "SMART"; break;
case DEVICE_LIST : ope = "Device listing"; break;
case DEVICE_SMART : ope = "Smart"; break;
}
log_fatal("%s unsupported in this platform.\n", ope);
log_fatal("%s is unsupported in this platform.\n", ope);
} else {
if (operation == DEVICE_LIST) {
for (i = tommy_list_head(&low); i != 0; i = i->next) {

View file

@ -759,6 +759,7 @@ static int devscan(tommy_list* list)
/**
* Get SMART attributes.
*/
#if HAVE_LINUX_DEVICE
static int devsmart(dev_t device, const char* name, const char* custom, uint64_t* smart, char* serial)
{
char cmd[128];
@ -816,6 +817,7 @@ static int devsmart(dev_t device, const char* name, const char* custom, uint64_t
return 0;
}
#endif
/**
* Spin down a specific device.
@ -993,6 +995,7 @@ static void* thread_spindown(void* arg)
*/
static void* thread_smart(void* arg)
{
#if HAVE_LINUX_DEVICE
devinfo_t* devinfo = arg;
if (devsmart(devinfo->device, devinfo->name, devinfo->smartctl, devinfo->smart, devinfo->smart_serial) != 0) {
@ -1002,6 +1005,10 @@ static void* thread_smart(void* arg)
}
return 0;
#else
(void)arg;
return (void*)-1;
#endif
}
static int device_thread(tommy_list* list, void* (*func)(void* arg))