mirror of
git://sourceware.org/git/lvm2.git
synced 2024-10-27 18:55:19 +03:00
Check that vgname doesn't already exits in dev_dir
This commit is contained in:
parent
4b2ec1929a
commit
594cc87acf
@ -8,6 +8,21 @@
|
|||||||
|
|
||||||
#include <sys/stat.h>
|
#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)
|
int create_dir(const char *dir)
|
||||||
{
|
{
|
||||||
struct stat info;
|
struct stat info;
|
||||||
|
@ -31,6 +31,7 @@ int vgcreate(int argc, char **argv)
|
|||||||
int max_lv, max_pv;
|
int 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;
|
||||||
|
|
||||||
if (!argc) {
|
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)))
|
if (!strncmp(vg_name, fid->cmd->dev_dir, strlen(fid->cmd->dev_dir)))
|
||||||
vg_name += 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)) {
|
if (!is_valid_chars(vg_name)) {
|
||||||
log_error("New volume group name '%s' has invalid characters",
|
log_error("New volume group name '%s' has invalid characters",
|
||||||
vg_name);
|
vg_name);
|
||||||
|
Loading…
Reference in New Issue
Block a user