Verify whether input device path is actually a block device

This applies to add/momove core, start/stop cache, zero superblock
commands.

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
This commit is contained in:
Adam Rutkowski
2021-01-20 16:53:30 +01:00
parent 5f5c150c30
commit 1fb5fd9662
2 changed files with 17 additions and 6 deletions

View File

@@ -92,16 +92,13 @@ static struct command_args command_args_values = {
};
int validate_device_name(const char *dev_name) {
if (validate_dev(dev_name)) {
cas_printf(LOG_ERR, "Cache creation aborted, %s entry exists in /etc/fstab. Please remove it!\n",
dev_name);
if (strnlen(dev_name, MAX_STR_LEN) >= MAX_STR_LEN) {
cas_printf(LOG_ERR, "Illegal device name\n");
return FAILURE;
}
if (strnlen(dev_name, MAX_STR_LEN) >= MAX_STR_LEN) {
cas_printf(LOG_ERR, "Illegal device %s\n", dev_name);
if (validate_dev(dev_name))
return FAILURE;
}
return SUCCESS;
}