Fix listing caches with path outside /dev/disk/by-id

Signed-off-by: Slawomir Jankowski <slawomir.jankowski@intel.com>
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
This commit is contained in:
Slawomir Jankowski 2021-01-20 14:19:20 +01:00 committed by Adam Rutkowski
parent 3df6305254
commit 035ed3e7f9

View File

@ -819,11 +819,14 @@ struct cache_device *get_cache_device(const struct kcas_cache_info *info, bool b
cache->expected_core_count = info->info.core_count; cache->expected_core_count = info->info.core_count;
cache->id = cache_id; cache->id = cache_id;
cache->state = info->info.state; cache->state = info->info.state;
if (set_device_path(cache->device, sizeof(cache->device), info->cache_path_name,
sizeof(info->cache_path_name)) != SUCCESS) { if (strncpy_s(cache->device, sizeof(cache->device),
info->cache_path_name,
sizeof(info->cache_path_name))) {
free(cache); free(cache);
return NULL; return NULL;
} }
cache->mode = info->info.cache_mode; cache->mode = info->info.cache_mode;
cache->dirty = info->info.dirty; cache->dirty = info->info.dirty;
cache->flushed = info->info.flushed; cache->flushed = info->info.flushed;
@ -2752,8 +2755,11 @@ int list_caches(unsigned int list_format, bool by_id_path)
float core_flush_prog; float core_flush_prog;
if (!by_id_path) { if (!by_id_path) {
get_dev_path(curr_cache->device, curr_cache->device, if (get_dev_path(curr_cache->device, curr_cache->device,
sizeof(curr_cache->device)); sizeof(curr_cache->device))) {
cas_printf(LOG_WARNING, "WARNING: Cannot resolve path "
"to cache. By-id path will be shown for that cache.\n");
}
} }
cache_flush_prog = calculate_flush_progress(curr_cache->dirty, curr_cache->flushed); cache_flush_prog = calculate_flush_progress(curr_cache->dirty, curr_cache->flushed);