summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorAlasdair Kergon <agk@redhat.com>2001-10-05 21:39:30 +0000
committerAlasdair Kergon <agk@redhat.com>2001-10-05 21:39:30 +0000
commit25d42d50a84a960d71e506cc6eff5151f272abca (patch)
tree073e0b5a10bb7116f43937a8a1c3253819233029 /tools
parentdf765ac1c8934a674988d4f59b9e0e091c7be29f (diff)
downloadlvm2-25d42d50a84a960d71e506cc6eff5151f272abca.tar.gz
lvm2-25d42d50a84a960d71e506cc6eff5151f272abca.tar.xz
lvm2-25d42d50a84a960d71e506cc6eff5151f272abca.zip
Sync include file changes.
Diffstat (limited to 'tools')
-rw-r--r--tools/lvactivate.c2
-rw-r--r--tools/lvm.c34
-rw-r--r--tools/lvmchange.c4
-rw-r--r--tools/lvremove.c6
-rw-r--r--tools/pvchange.c10
-rw-r--r--tools/pvcreate.c2
-rw-r--r--tools/pvscan.c8
-rw-r--r--tools/toollib.c53
-rw-r--r--tools/toollib.h6
-rw-r--r--tools/tools.h2
-rw-r--r--tools/vgrename.c2
11 files changed, 84 insertions, 45 deletions
diff --git a/tools/lvactivate.c b/tools/lvactivate.c
index e35dc007..3558c8d0 100644
--- a/tools/lvactivate.c
+++ b/tools/lvactivate.c
@@ -55,7 +55,7 @@ int lvactivate(int argc, char **argv)
return -1;
}
- if (pv->status & STATUS_ALLOCATED) {
+ if (pv->status & ALLOCATED_PV) {
if (!(pv->pe = pv_read_pe(pv_name, pv)))
goto pvdisplay_device_out;
if (!(lvs = pv_read_lvs(pv))) {
diff --git a/tools/lvm.c b/tools/lvm.c
index cba83521..49f9ed88 100644
--- a/tools/lvm.c
+++ b/tools/lvm.c
@@ -120,7 +120,7 @@ int main(int argc, char **argv)
if (argc < 2) {
log_fatal("Please supply an LVM command.");
display_help();
- ret = LVM_EINVALID_CMD_LINE;
+ ret = EINVALID_CMD_LINE;
goto out;
}
@@ -129,9 +129,9 @@ int main(int argc, char **argv)
}
ret = run_command(argc, argv);
- if ((ret == LVM_ENO_SUCH_CMD) && (!alias))
+ if ((ret == ENO_SUCH_CMD) && (!alias))
ret = run_script(argc, argv);
- if (ret == LVM_ENO_SUCH_CMD)
+ if (ret == ENO_SUCH_CMD)
log_error("No such command");
out:
@@ -211,10 +211,10 @@ int string_arg(struct arg *a)
int permission_arg(struct arg *a)
{
if ((!strcmp(a->value, "rw")) || (!strcmp(a->value, "wr")))
- a->i_value = ACCESS_READ | ACCESS_WRITE;
+ a->i_value = LVM_READ | LVM_WRITE;
else if (!strcmp(a->value, "r"))
- a->i_value = ACCESS_READ;
+ a->i_value = LVM_READ;
else
return 0;
@@ -264,7 +264,7 @@ static void register_command(const char *name, command_fn fn,
/* allocate space for them */
if (!(args = dbg_malloc(sizeof (*args) * nargs))) {
log_fatal("Out of memory.");
- exit(LVM_ENOMEM);
+ exit(ECMD_FAILED);
}
/* fill them in */
@@ -320,7 +320,7 @@ static void __alloc(int size)
{
if (!(_commands = dbg_realloc(_commands, sizeof (*_commands) * size))) {
log_fatal("Couldn't allocate memory.");
- exit(LVM_ENOMEM);
+ exit(ECMD_FAILED);
}
_array_size = size;
@@ -443,20 +443,20 @@ static int process_common_commands(struct command *com)
if (arg_count(help_ARG)) {
usage(com->name);
- return LVM_ECMD_PROCESSED;
+ return ECMD_PROCESSED;
}
if (arg_count(version_ARG)) {
/* FIXME: Add driver and software version */
log_error("%s: ", com->name);
- return LVM_ECMD_PROCESSED;
+ return ECMD_PROCESSED;
}
/* Set autobackup if command takes this option */
for (l = 0; l < com->num_args; l++)
if (com->valid_args[l] == autobackup_ARG) {
if (init_autobackup())
- return LVM_EINVALID_CMD_LINE;
+ return EINVALID_CMD_LINE;
else
break;
}
@@ -498,11 +498,11 @@ static int run_command(int argc, char **argv)
struct command *com;
if (!(com = find_command(argv[0])))
- return LVM_ENO_SUCH_CMD;
+ return ENO_SUCH_CMD;
if (!process_command_line(com, &argc, &argv)) {
log_error("Error during parsing of command line.");
- return LVM_EINVALID_CMD_LINE;
+ return EINVALID_CMD_LINE;
}
if ((ret = process_common_commands(com)))
@@ -510,7 +510,7 @@ static int run_command(int argc, char **argv)
ret = com->fn(argc, argv);
- if (ret == LVM_EINVALID_CMD_LINE && !_interactive)
+ if (ret == EINVALID_CMD_LINE && !_interactive)
usage(com->name);
return ret;
@@ -655,27 +655,27 @@ static int run_script(int argc, char **argv)
int magic_number = 0;
if ((script = fopen(argv[0], "r")) == NULL)
- return LVM_ENO_SUCH_CMD;
+ return ENO_SUCH_CMD;
while (fgets(buffer, sizeof (buffer), script) != NULL) {
if (!magic_number) {
if (buffer[0] == '#' && buffer[1] == '!')
magic_number = 1;
else
- return LVM_ENO_SUCH_CMD;
+ return ENO_SUCH_CMD;
}
if ((strlen(buffer) == sizeof (buffer) - 1)
&& (buffer[sizeof (buffer) - 1] - 2 != '\n')) {
buffer[50] = '\0';
log_error("Line too long (max 255) beginning: %s",
buffer);
- ret = LVM_EINVALID_CMD_LINE;
+ ret = EINVALID_CMD_LINE;
break;
}
if (split(buffer, &argc, argv, MAX_ARGS) == MAX_ARGS) {
buffer[50] = '\0';
log_error("Too many arguments: %s", buffer);
- ret = LVM_EINVALID_CMD_LINE;
+ ret = EINVALID_CMD_LINE;
break;
}
if (!argc)
diff --git a/tools/lvmchange.c b/tools/lvmchange.c
index 3e49f971..42b186b5 100644
--- a/tools/lvmchange.c
+++ b/tools/lvmchange.c
@@ -20,8 +20,8 @@
#include "tools.h"
-int lvmchange(int argc, char **argv) {
+int lvmchange(int argc, char **argv)
+{
log_print("With the device mapper, this program is obsolete.");
return 0;
}
-
diff --git a/tools/lvremove.c b/tools/lvremove.c
index 77d75e3a..2e0ba237 100644
--- a/tools/lvremove.c
+++ b/tools/lvremove.c
@@ -66,7 +66,7 @@ int lvremove_single(char *lv_name)
return ECMD_FAILED;
}
- if (!(vg->status & STATUS_ACTIVE)) {
+ if (!(vg->status & ACTIVE)) {
log_error("volume group %s must be active before removing "
"logical volume", vg_name);
return ECMD_FAILED;
@@ -78,7 +78,7 @@ int lvremove_single(char *lv_name)
return ECMD_FAILED;
}
- if (lv->access & ACCESS_SNAPSHOT_ORG) {
+ if (lv->status & SNAPSHOT_ORG) {
log_error("can't remove logical volume %s under snapshot",
lv_name);
return ECMD_FAILED;
@@ -86,7 +86,7 @@ int lvremove_single(char *lv_name)
if (lv->open) {
log_error("can't remove open %s logical volume %s",
- lv->access & ACCESS_SNAPSHOT ? "snapshot" : "",
+ lv->status & SNAPSHOT ? "snapshot" : "",
lv_name);
return ECMD_FAILED;
}
diff --git a/tools/pvchange.c b/tools/pvchange.c
index e3228f01..36d561c9 100644
--- a/tools/pvchange.c
+++ b/tools/pvchange.c
@@ -130,14 +130,14 @@ void pvchange_single_volume(struct physical_volume *pv)
/* change allocatability for a PV */
if (arg_count(allocation_ARG) > 0) {
- if (allocation && (pv->status & STATUS_ALLOCATED)) {
+ if (allocation && (pv->status & ALLOCATED_PV)) {
log_error("physical volume %s is allocatable", pv_name);
not_done++;
return;
} else
change_msg = 1;
- if (!allocation && !(pv->status & STATUS_ALLOCATED)) {
+ if (!allocation && !(pv->status & ALLOCATED_PV)) {
log_error("physical volume %s is unallocatable",
pv_name);
not_done++;
@@ -148,12 +148,12 @@ void pvchange_single_volume(struct physical_volume *pv)
if (allocation) {
log_verbose
("setting physical volume %s allocatable", pv_name);
- pv->status |= STATUS_ALLOCATED;
+ pv->status |= ALLOCATED_PV;
} else {
log_verbose
("setting physical volume %s NOT allocatable",
pv_name);
- pv->status &= ~STATUS_ALLOCATED;
+ pv->status &= ~ALLOCATED_PV;
}
}
@@ -162,7 +162,7 @@ void pvchange_single_volume(struct physical_volume *pv)
if (doit == 1) {
log_verbose("checking physical volume %s is activite",
pv->dev->name);
- if (!(pv->status & STATUS_ACTIVE)) {
+ if (!(pv->status & ACTIVE)) {
log_verbose("Physical volume %s inactive", pv_name);
}
diff --git a/tools/pvcreate.c b/tools/pvcreate.c
index e538ab77..036fb8ea 100644
--- a/tools/pvcreate.c
+++ b/tools/pvcreate.c
@@ -94,7 +94,7 @@ void pvcreate_single(const char *pv_name)
}
- if (pv && (pv->status & STATUS_ACTIVE)) {
+ if (pv && (pv->status & ACTIVE)) {
log_error("Can't create on active physical volume %s", pv_name);
return;
}
diff --git a/tools/pvscan.c b/tools/pvscan.c
index ef4bea9e..bc688984 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -83,7 +83,7 @@ int pvscan(int argc, char **argv)
continue;
********/
pvs_found++;
-
+
size = dev_get_size(pv->dev);
size_total += size;
@@ -126,9 +126,7 @@ int pvscan(int argc, char **argv)
pvs_found - new_pvs_found,
(s2 =
display_size((size_total - size_new) / 2, SIZE_SHORT)),
- new_pvs_found, (s3 =
- display_size(size_new / 2,
- SIZE_SHORT)));
+ new_pvs_found, (s3 = display_size(size_new / 2, SIZE_SHORT)));
dbg_free(s1);
dbg_free(s2);
dbg_free(s3);
@@ -163,7 +161,7 @@ void pvscan_display_single(struct physical_volume *pv)
memset(pv_tmp_name, 0, sizeof (pv_tmp_name));
- active_str = (pv->status & STATUS_ACTIVE) ? "ACTIVE " : "inactive ";
+ active_str = (pv->status & ACTIVE) ? "ACTIVE " : "inactive ";
vg_name_len = strlen(pv->vg_name) - sizeof (EXPORTED) + 1;
diff --git a/tools/toollib.c b/tools/toollib.c
index 648ea980..c3ef0f3d 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -18,7 +18,7 @@
*
*/
-#include "lvm_user.h"
+#include "tools.h"
static int _autobackup = 1;
@@ -55,29 +55,68 @@ int init_autobackup()
return 0;
}
-int do_autobackup(char *vg_name, vg_t * vg)
+int do_autobackup(struct volume_group *vg)
{
- int ret;
+/***************
log_verbose("Changing lvmtab");
- if ((ret = vg_cfgbackup(vg_name, LVMTAB_DIR, vg))) {
+ if ((vg_cfgbackup(vg_name, LVMTAB_DIR, vg))) {
log_error("\"%s\" writing \"%s\"", lvm_error(ret), LVMTAB);
return LVM_E_VG_CFGBACKUP;
}
+**************/
if (!autobackup_set()) {
log_print
- ("WARNING: You don't have an automatic backup of \"%s\"",
- vg_name);
+ ("WARNING: You don't have an automatic backup of %s",
+ vg->name);
return 0;
}
+/***************
log_print("Creating automatic backup of volume group \"%s\"", vg_name);
- if ((ret = vg_cfgbackup(vg_name, VG_BACKUP_DIR, vg))) {
+ if ((vg_cfgbackup(vg_name, VG_BACKUP_DIR, vg))) {
log_error("\"%s\" writing VG backup of \"%s\"", lvm_error(ret),
vg_name);
return LVM_E_VG_CFGBACKUP;
}
+***************/
return 0;
}
+
+int process_each_vg(int argc, char **argv,
+ int (*process_single) (const char *vg_name))
+{
+ int opt = 0;
+ int ret_max = 0;
+ int ret = 0;
+
+ struct io_space *ios;
+ struct list_head *vgh;
+ struct name_list *vgs_list;
+
+ ios = active_ios();
+
+ if (argc) {
+ log_verbose("Using volume group(s) on command line");
+ for (; opt < argc; opt++)
+ if ((ret = process_single(argv[opt])) > ret_max)
+ ret_max = ret;
+ } else {
+ log_verbose("Finding all volume group(s)");
+ if (!(vgs_list = ios->get_vgs(ios))) {
+ log_error("No volume groups found");
+ return ECMD_FAILED;
+ }
+ list_for_each(vgh, &vgs_list->list) {
+ ret =
+ process_single(list_entry
+ (vgh, struct name_list, list)->name);
+ if (ret > ret_max)
+ ret_max = ret;
+ }
+ }
+
+ return ret_max;
+}
diff --git a/tools/toollib.h b/tools/toollib.h
index 42e18058..3cb417fe 100644
--- a/tools/toollib.h
+++ b/tools/toollib.h
@@ -21,8 +21,10 @@
#ifndef _LVM_TOOLLIB_H
#define _LVM_TOOLLIB_H
-int autobackup_set (void);
-int init_autobackup (void);
+int autobackup_set(void);
+int init_autobackup(void);
int do_autobackup(struct volume_group *vg);
+int process_each_vg(int argc, char **argv,
+ int (*process_single) (const char *vg_name));
#endif
diff --git a/tools/tools.h b/tools/tools.h
index 32cacf9d..cccc210a 100644
--- a/tools/tools.h
+++ b/tools/tools.h
@@ -103,7 +103,7 @@ static inline int arg_count_increment(int a)
return the_args[a].count++;
}
-#endif
struct config_file *active_config_file(void);
struct dev_filter *active_filter(void);
struct io_space *active_ios(void);
+#endif
diff --git a/tools/vgrename.c b/tools/vgrename.c
index 459a75fe..1e0a6eba 100644
--- a/tools/vgrename.c
+++ b/tools/vgrename.c
@@ -81,7 +81,7 @@ int vgrename(int argc, char **argv)
log_error("volume group %s doesn't exist", vg_name_old);
return ECMD_FAILED;
}
- if (vg_old->status & STATUS_ACTIVE) {
+ if (vg_old->status & ACTIVE) {
log_error("Volume group %s still active", vg_name_old);
}