1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-04 09:18:36 +03:00

Better support for LVs with hyphens in names.

This commit is contained in:
Alasdair Kergon 2002-03-19 16:41:44 +00:00
parent 902098d615
commit 9585e50fef
2 changed files with 24 additions and 13 deletions

View File

@ -1046,7 +1046,6 @@ int _create_rec(struct dev_manager *dm, struct dev_layer *dl)
struct list *sh; struct list *sh;
struct dev_layer *dep; struct dev_layer *dep;
char *dlid, *newname, *suffix; char *dlid, *newname, *suffix;
int len;
int suspended = 0; int suspended = 0;
list_iterate(sh, &dl->pre_create) { list_iterate(sh, &dl->pre_create) {
@ -1076,13 +1075,11 @@ int _create_rec(struct dev_manager *dm, struct dev_layer *dl)
/* Rename? */ /* Rename? */
if (dl->info.exists) { if (dl->info.exists) {
newname = _build_name(dm->mem, dm->vg_name, dl->lv->name, NULL);
len = strlen(newname);
if (strncmp(newname, dl->name, len)) {
if ((suffix = rindex(dl->dlid, '-'))) if ((suffix = rindex(dl->dlid, '-')))
suffix++; suffix++;
newname = _build_name(dm->mem, dm->vg_name, newname = _build_name(dm->mem, dm->vg_name, dl->lv->name,
dl->lv->name, suffix); suffix);
if (strcmp(newname, dl->name)) {
if (!_rename(dm, dl, newname)) { if (!_rename(dm, dl, newname)) {
stack; stack;
return 0; return 0;
@ -1259,12 +1256,21 @@ static int _execute(struct dev_manager *dm, struct volume_group *vg)
* looking at the beginning of the device * looking at the beginning of the device
* name. * name.
*/ */
static int _belong_to_vg(const char *vg, const char *name) static int _belong_to_vg(const char *vgname, const char *name)
{ {
/* const char *v = vgname, *n = name;
* FIXME: broken for vg's with '-'s in.
*/ while (*v) {
return !strncmp(vg, name, strlen(vg)); if ((*v != *n) ||
(*v == '-' && *(++n) != '-'))
return 0;
v++, n++;
}
if (*n == '-' && *(n+1) != '-')
return 1;
else
return 0;
} }
static int _add_existing_layer(struct dev_manager *dm, const char *name) static int _add_existing_layer(struct dev_manager *dm, const char *name)

View File

@ -221,6 +221,11 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
int is_valid_chars(char *n) int is_valid_chars(char *n)
{ {
register char c; register char c;
/* Hyphen used as VG-LV separator - ambiguity if LV starts with it */
if (*n == '-')
return 0;
while ((c = *n++)) while ((c = *n++))
if (!isalnum(c) && c != '.' && c != '_' && c != '-' && c != '+') if (!isalnum(c) && c != '.' && c != '_' && c != '-' && c != '+')
return 0; return 0;