summaryrefslogtreecommitdiffstats
path: root/tools/vgremove.c
diff options
context:
space:
mode:
authorAlasdair Kergon <agk@redhat.com>2002-11-18 14:04:08 +0000
committerAlasdair Kergon <agk@redhat.com>2002-11-18 14:04:08 +0000
commit5a52dca9c26ade9f233abcf5213300560d7a13a9 (patch)
tree9afbc621c07148c96a1ba1878a262dbd8aec613a /tools/vgremove.c
parentd1d9800ef1c7ec38a5f72b8e2586f927ab68188c (diff)
downloadlvm2-5a52dca9c26ade9f233abcf5213300560d7a13a9.tar.gz
lvm2-5a52dca9c26ade9f233abcf5213300560d7a13a9.tar.xz
lvm2-5a52dca9c26ade9f233abcf5213300560d7a13a9.zip
Some new features.
Diffstat (limited to 'tools/vgremove.c')
-rw-r--r--tools/vgremove.c52
1 files changed, 24 insertions, 28 deletions
diff --git a/tools/vgremove.c b/tools/vgremove.c
index 018976f7..14a0fcf3 100644
--- a/tools/vgremove.c
+++ b/tools/vgremove.c
@@ -20,38 +20,15 @@
#include "tools.h"
-static int vgremove_single(struct cmd_context *cmd, const char *vg_name);
-
-int vgremove(struct cmd_context *cmd, int argc, char **argv)
-{
- int ret;
-
- if (!driver_is_loaded())
- return ECMD_FAILED;
-
- if (!lock_vol(cmd, "", LCK_VG_WRITE)) {
- log_error("Can't get lock for orphan PVs");
- return ECMD_FAILED;
- }
-
- ret = process_each_vg(cmd, argc, argv,
- LCK_VG | LCK_WRITE | LCK_NONBLOCK,
- &vgremove_single);
-
- unlock_vg(cmd, "");
-
- return ret;
-}
-
-static int vgremove_single(struct cmd_context *cmd, const char *vg_name)
+static int vgremove_single(struct cmd_context *cmd, const char *vg_name,
+ struct volume_group *vg, int consistent,
+ void *handle)
{
- struct volume_group *vg;
struct physical_volume *pv;
struct list *pvh;
int ret = 0;
- log_verbose("Checking for volume group \"%s\"", vg_name);
- if (!(vg = vg_read(cmd, vg_name))) {
+ if (!vg || !consistent) {
log_error("Volume group \"%s\" doesn't exist", vg_name);
return ECMD_FAILED;
}
@@ -87,7 +64,8 @@ static int vgremove_single(struct cmd_context *cmd, const char *vg_name)
log_verbose("Removing physical volume \"%s\" from "
"volume group \"%s\"", dev_name(pv->dev), vg_name);
*pv->vg_name = '\0';
- if (!pv_write(cmd, pv)) {
+ /* FIXME Write to same sector label was read from */
+ if (!pv_write(cmd, pv, NULL, -1)) {
log_error("Failed to remove physical volume \"%s\""
" from volume group \"%s\"",
dev_name(pv->dev), vg_name);
@@ -104,3 +82,21 @@ static int vgremove_single(struct cmd_context *cmd, const char *vg_name)
return ret;
}
+
+int vgremove(struct cmd_context *cmd, int argc, char **argv)
+{
+ int ret;
+
+ if (!lock_vol(cmd, "", LCK_VG_WRITE)) {
+ log_error("Can't get lock for orphan PVs");
+ return ECMD_FAILED;
+ }
+
+ ret = process_each_vg(cmd, argc, argv,
+ LCK_VG | LCK_WRITE | LCK_NONBLOCK, 1, NULL,
+ &vgremove_single);
+
+ unlock_vg(cmd, "");
+
+ return ret;
+}