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

Check that vgname doesn't already exits in dev_dir

This commit is contained in:
Heinz Mauelshagen 2002-01-28 16:30:42 +00:00
parent 4b2ec1929a
commit 594cc87acf
2 changed files with 19 additions and 0 deletions

View File

@ -8,6 +8,21 @@
#include <sys/stat.h>
int check_dir(const char *dir)
{
struct stat info;
if (!*dir)
return 1;
if (stat(dir, &info) != -1 ) {
log_error("%s exists", dir);
return 0;
}
return 1;
}
int create_dir(const char *dir)
{
struct stat info;

View File

@ -31,6 +31,7 @@ int vgcreate(int argc, char **argv)
int max_lv, max_pv;
uint32_t extent_size;
char *vg_name;
char vg_path[PATH_MAX];
struct volume_group *vg;
if (!argc) {
@ -65,6 +66,9 @@ int vgcreate(int argc, char **argv)
if (!strncmp(vg_name, fid->cmd->dev_dir, strlen(fid->cmd->dev_dir)))
vg_name += strlen(fid->cmd->dev_dir);
snprintf(vg_path, PATH_MAX, "%s%s", fid->cmd->dev_dir, vg_name);
if (!check_dir(vg_path)) return ECMD_FAILED;
if (!is_valid_chars(vg_name)) {
log_error("New volume group name '%s' has invalid characters",
vg_name);