mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
toollib: validate_restricted_lvname_param
Lets make a separate new function to validate names that has to follow up restriction rules.
This commit is contained in:
parent
c87e5a308a
commit
b59335fb39
@ -126,16 +126,16 @@ static int _lvconvert_name_params(struct lvconvert_params *lp,
|
||||
(*pargv)++, (*pargc)--;
|
||||
}
|
||||
|
||||
if (!validate_lvname_param(cmd, &lp->vg_name, &lp->pool_metadata_name))
|
||||
if (!validate_restricted_lvname_param(cmd, &lp->vg_name, &lp->pool_metadata_name))
|
||||
return_0;
|
||||
|
||||
if (!validate_lvname_param(cmd, &lp->vg_name, &lp->pool_data_name))
|
||||
if (!validate_restricted_lvname_param(cmd, &lp->vg_name, &lp->pool_data_name))
|
||||
return_0;
|
||||
|
||||
if (!validate_lvname_param(cmd, &lp->vg_name, &lp->origin_name))
|
||||
if (!validate_restricted_lvname_param(cmd, &lp->vg_name, &lp->origin_name))
|
||||
return_0;
|
||||
|
||||
if (!validate_lvname_param(cmd, &lp->vg_name, &lp->lv_split_name))
|
||||
if (!validate_restricted_lvname_param(cmd, &lp->vg_name, &lp->lv_split_name))
|
||||
return_0;
|
||||
|
||||
if (strchr(lp->lv_name_full, '/') &&
|
||||
|
@ -51,10 +51,7 @@ static int _lvcreate_name_params(struct lvcreate_params *lp,
|
||||
const char *vg_name;
|
||||
|
||||
lp->lv_name = arg_str_value(cmd, name_ARG, NULL);
|
||||
if (!validate_lvname_param(cmd, &lp->vg_name, &lp->lv_name))
|
||||
return_0;
|
||||
|
||||
if (lp->lv_name && !apply_lvname_restrictions(lp->lv_name))
|
||||
if (!validate_restricted_lvname_param(cmd, &lp->vg_name, &lp->lv_name))
|
||||
return_0;
|
||||
|
||||
lp->pool_name = arg_str_value(cmd, thinpool_ARG, NULL)
|
||||
|
@ -1309,6 +1309,25 @@ int validate_lvname_param(struct cmd_context *cmd, const char **vg_name,
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate lvname parameter
|
||||
* This name must follow restriction rules on prefixes and suffixes.
|
||||
*
|
||||
* If it contains vgname, it is extracted from lvname.
|
||||
* If there is passed vgname, it is compared whether its the same name.
|
||||
*/
|
||||
int validate_restricted_lvname_param(struct cmd_context *cmd, const char **vg_name,
|
||||
const char **lv_name)
|
||||
{
|
||||
if (!validate_lvname_param(cmd, vg_name, lv_name))
|
||||
return_0;
|
||||
|
||||
if (lv_name && *lv_name && !apply_lvname_restrictions(*lv_name))
|
||||
return_0;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct vgnameid_list {
|
||||
struct dm_list list;
|
||||
const char *vg_name;
|
||||
|
@ -132,6 +132,8 @@ int get_and_validate_major_minor(const struct cmd_context *cmd,
|
||||
|
||||
int validate_lvname_param(struct cmd_context *cmd, const char **vg_name,
|
||||
const char **lv_name);
|
||||
int validate_restricted_lvname_param(struct cmd_context *cmd, const char **vg_name,
|
||||
const char **lv_name);
|
||||
|
||||
int lvremove_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
void *handle __attribute__((unused)));
|
||||
|
Loading…
Reference in New Issue
Block a user