diff options
author | Alasdair Kergon <agk@redhat.com> | 2002-02-11 15:42:34 +0000 |
---|---|---|
committer | Alasdair Kergon <agk@redhat.com> | 2002-02-11 15:42:34 +0000 |
commit | 7d0e6e800e41fd13a5dc51ef05de8298b30b7432 (patch) | |
tree | 51be3b97d6a751fed2fc643ce52dac6ad91f50ec /tools/vgcreate.c | |
parent | 713599407cc26d5e60889e828b923ed06f156ca0 (diff) | |
download | lvm2-7d0e6e800e41fd13a5dc51ef05de8298b30b7432.tar.gz lvm2-7d0e6e800e41fd13a5dc51ef05de8298b30b7432.tar.xz lvm2-7d0e6e800e41fd13a5dc51ef05de8298b30b7432.zip |
o Support locking with local lock files
o Disable control-c during updates (except if blocked waiting for a lock)
Diffstat (limited to 'tools/vgcreate.c')
-rw-r--r-- | tools/vgcreate.c | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/tools/vgcreate.c b/tools/vgcreate.c index 622cfb2d..1fdc12be 100644 --- a/tools/vgcreate.c +++ b/tools/vgcreate.c @@ -67,7 +67,10 @@ int vgcreate(int argc, char **argv) vg_name += strlen(fid->cmd->dev_dir); snprintf(vg_path, PATH_MAX, "%s%s", fid->cmd->dev_dir, vg_name); - if (!dir_exists(vg_path)) return ECMD_FAILED; + if (path_exists(vg_path)) { + log_error("%s: already exists in filesystem", vg_path); + return ECMD_FAILED; + } if (!is_valid_chars(vg_name)) { log_error("New volume group name \"%s\" has invalid characters", @@ -88,12 +91,32 @@ int vgcreate(int argc, char **argv) log_error("Warning: Setting maxphysicalvolumes to %d", vg->max_pv); - if (!archive(vg)) + if (!lock_vol("", LCK_VG | LCK_WRITE)) { + log_error("Can't get lock for orphan PVs"); + return ECMD_FAILED; + } + + if (!lock_vol(vg_name, LCK_VG | LCK_WRITE | LCK_NONBLOCK)) { + log_error("Can't get lock for %s", vg_name); + lock_vol("", LCK_VG | LCK_NONE); + return ECMD_FAILED; + } + + if (!archive(vg)) { + lock_vol(vg_name, LCK_VG | LCK_NONE); + lock_vol("", LCK_VG | LCK_NONE); return ECMD_FAILED; + } /* Store VG on disk(s) */ - if (!fid->ops->vg_write(fid, vg)) + if (!fid->ops->vg_write(fid, vg)) { + lock_vol(vg_name, LCK_VG | LCK_NONE); + lock_vol("", LCK_VG | LCK_NONE); return ECMD_FAILED; + } + + lock_vol(vg_name, LCK_VG | LCK_NONE); + lock_vol("", LCK_VG | LCK_NONE); backup(vg); |