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 - Version 2.01.11 -
============================== ==============================
Make VG name restrictions consistent.
Introduce lvconvert. So far only removes mirror images. Introduce lvconvert. So far only removes mirror images.
Allow mirror images to be resized. Allow mirror images to be resized.
Allow mirror images to have more than one segment. 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++) { for (i = 0; i < count; i++) {
/* ignore dot files */ if (!strcmp(dirent[i]->d_name, ".") ||
if (dirent[i]->d_name[0] == '.') !strcmp(dirent[i]->d_name, ".."))
continue; continue;
/* check the name is the correct format */ /* check the name is the correct format */

View File

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

View File

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

View File

@ -1042,3 +1042,18 @@ int apply_lvname_restrictions(const char *name)
return 1; 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 apply_lvname_restrictions(const char *name);
int validate_vg_name(struct cmd_context *cmd, const char *vg_name);
#endif #endif

View File

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

View File

@ -51,7 +51,7 @@ int vgrename(struct cmd_context *cmd, int argc, char **argv)
return ECMD_FAILED; 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", log_error("New volume group name \"%s\" is invalid",
vg_name_new); vg_name_new);
return ECMD_FAILED; return ECMD_FAILED;

View File

@ -222,6 +222,12 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
goto error; 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))) { if ((active = lvs_in_vg_activated(vg_from))) {
/* FIXME Remove this restriction */ /* FIXME Remove this restriction */
log_error("Logical volumes in \"%s\" must be inactive", log_error("Logical volumes in \"%s\" must be inactive",