1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

Make VG name restrictions consistent.

This commit is contained in:
Alasdair Kergon 2005-06-06 18:16:33 +00:00
parent 1a1f3d3efe
commit 8b80d2a57c
9 changed files with 33 additions and 11 deletions

View File

@ -1,5 +1,6 @@
Version 2.01.11 -
==============================
Make VG name restrictions consistent.
Introduce lvconvert. So far only removes mirror images.
Allow mirror images to be resized.
Allow mirror images to have more than one segment.

View File

@ -150,8 +150,8 @@ static struct list *_scan_archive(struct pool *mem,
}
for (i = 0; i < count; i++) {
/* ignore dot files */
if (dirent[i]->d_name[0] == '.')
if (!strcmp(dirent[i]->d_name, ".") ||
!strcmp(dirent[i]->d_name, ".."))
continue;
/* check the name is the correct format */

View File

@ -584,6 +584,9 @@ static inline int validate_name(const char *n)
if (*n == '-')
return 0;
if (!strcmp(n, ".") || !strcmp(n, ".."))
return 0;
while ((len++, c = *n++))
if (!isalnum(c) && c != '.' && c != '_' && c != '-' && c != '+')
return 0;

View File

@ -84,12 +84,14 @@ int remove_all_mirror_images(struct logical_volume *lv)
/*
* Add mirror images to an existing mirror
*/
/* FIXME
int add_mirror_images(struct alloc_handle *ah,
uint32_t first_area,
uint32_t num_areas,
struct logical_volume *lv)
{
}
*/
int create_mirror_layers(struct alloc_handle *ah,
uint32_t first_area,

View File

@ -1042,3 +1042,18 @@ int apply_lvname_restrictions(const char *name)
return 1;
}
int validate_vg_name(struct cmd_context *cmd, const char *vg_name)
{
char vg_path[PATH_MAX];
if (!validate_name(vg_name))
return 0;
snprintf(vg_path, PATH_MAX, "%s%s", cmd->dev_dir, vg_name);
if (path_exists(vg_path)) {
log_error("%s: already exists in filesystem", vg_path);
return 0;
}
return 1;
}

View File

@ -92,4 +92,6 @@ int exec_cmd(const char *command, const char *fscmd, const char *lv_path,
int apply_lvname_restrictions(const char *name);
int validate_vg_name(struct cmd_context *cmd, const char *vg_name);
#endif

View File

@ -22,7 +22,6 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
size_t max_lv, max_pv;
uint32_t extent_size;
char *vg_name;
char vg_path[PATH_MAX];
struct volume_group *vg;
const char *tag;
alloc_policy_t alloc;
@ -89,13 +88,7 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
if (!strncmp(vg_name, cmd->dev_dir, strlen(cmd->dev_dir)))
vg_name += strlen(cmd->dev_dir);
snprintf(vg_path, PATH_MAX, "%s%s", cmd->dev_dir, vg_name);
if (path_exists(vg_path)) {
log_error("%s: already exists in filesystem", vg_path);
return ECMD_FAILED;
}
if (!validate_name(vg_name)) {
if (!validate_vg_name(cmd, vg_name)) {
log_error("New volume group name \"%s\" is invalid", vg_name);
return ECMD_FAILED;
}

View File

@ -51,7 +51,7 @@ int vgrename(struct cmd_context *cmd, int argc, char **argv)
return ECMD_FAILED;
}
if (!validate_name(vg_name_new)) {
if (!validate_vg_name(cmd, vg_name_new)) {
log_error("New volume group name \"%s\" is invalid",
vg_name_new);
return ECMD_FAILED;

View File

@ -222,6 +222,12 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
goto error;
}
if (!validate_vg_name(cmd, vg_name_to)) {
log_error("New volume group name \"%s\" is invalid",
vg_name_to);
goto error;
}
if ((active = lvs_in_vg_activated(vg_from))) {
/* FIXME Remove this restriction */
log_error("Logical volumes in \"%s\" must be inactive",