mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
lvm-string: add function to detect component LV suffix
Add is_component_lvname() function to recognize component LV name.
This commit is contained in:
parent
17649d4ac8
commit
3a841515af
@ -150,22 +150,41 @@ static const char *_lvname_has_reserved_prefix(const char *lvname)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const char *_lvname_has_reserved_string(const char *lvname)
|
||||
static const char *_lvname_has_reserved_component_string(const char *lvname)
|
||||
{
|
||||
static const char _strings[][12] = {
|
||||
/* Suffixes for compoment LVs */
|
||||
"_cdata",
|
||||
"_cmeta",
|
||||
"_corig",
|
||||
"_mimage",
|
||||
"_mlog",
|
||||
"_pmspare",
|
||||
"_rimage",
|
||||
"_rmeta",
|
||||
"_tdata",
|
||||
"_tmeta",
|
||||
"_tmeta"
|
||||
};
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < DM_ARRAY_SIZE(_strings); ++i)
|
||||
if (strstr(lvname, _strings[i]))
|
||||
return _strings[i];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const char *_lvname_has_reserved_string(const char *lvname)
|
||||
{
|
||||
static const char _strings[][12] = {
|
||||
/* Additional suffixes for non-compoment LVs */
|
||||
"_pmspare",
|
||||
"_vorigin"
|
||||
};
|
||||
unsigned i;
|
||||
const char *cs;
|
||||
|
||||
if ((cs = _lvname_has_reserved_component_string(lvname)))
|
||||
return cs;
|
||||
|
||||
for (i = 0; i < DM_ARRAY_SIZE(_strings); ++i)
|
||||
if (strstr(lvname, _strings[i]))
|
||||
@ -208,6 +227,11 @@ int is_reserved_lvname(const char *name)
|
||||
_lvname_has_reserved_string(name)) ? 1 : 0;
|
||||
}
|
||||
|
||||
int is_component_lvname(const char *name)
|
||||
{
|
||||
return (_lvname_has_reserved_component_string(name)) ? 1 : 0;
|
||||
}
|
||||
|
||||
char *build_dm_uuid(struct dm_pool *mem, const struct logical_volume *lv,
|
||||
const char *layer)
|
||||
{
|
||||
|
@ -47,6 +47,7 @@ int validate_tag(const char *n);
|
||||
void copy_systemid_chars(const char *src, char *dst);
|
||||
|
||||
int apply_lvname_restrictions(const char *name);
|
||||
int is_component_lvname(const char *name);
|
||||
int is_reserved_lvname(const char *name);
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user