1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

lvpoll.c: harden the checks for proper LV name

lvpoll now process passed LV name properly. It respects
LVM_VG_NAME env. variable and is able to process LV name
passed in various formats:

- VG/LV
- LV name only (with LVM_VG_NAME set)
- /dev/mapper/VG-LV
- /dev/VG/LV
This commit is contained in:
Ondrej Kozina 2015-05-15 16:35:00 +02:00
parent ba120640b2
commit 67657f1ff9

View File

@ -83,11 +83,17 @@ static int poll_lv(struct cmd_context *cmd, const char *lv_name)
{
struct daemon_parms parms = { 0 };
struct poll_operation_id id = {
.vg_name = extract_vgname(cmd, lv_name),
.lv_name = strchr(lv_name, '/') + 1,
.display_name = lv_name
.display_name = skip_dev_dir(cmd, lv_name, NULL)
};
if (!id.display_name)
return_EINVALID_CMD_LINE;
id.lv_name = id.display_name;
if (!validate_lvname_param(cmd, &id.vg_name, &id.lv_name))
return_EINVALID_CMD_LINE;
if (!_set_daemon_parms(cmd, &parms))
return_EINVALID_CMD_LINE;
@ -106,8 +112,8 @@ int lvpoll(struct cmd_context *cmd, int argc, char **argv)
return EINVALID_CMD_LINE;
}
if (!argc || !strchr(argv[0], '/')) {
log_error("Provide full VG/LV name");
if (!argc) {
log_error("Provide LV name");
return EINVALID_CMD_LINE;
}