mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-10 16:58:47 +03:00
Sync include file changes.
This commit is contained in:
parent
df765ac1c8
commit
25d42d50a8
@ -151,7 +151,8 @@ struct io_space {
|
||||
void (*destroy)(struct io_space *is);
|
||||
|
||||
/* Current volume group prefix. */
|
||||
char *prefix = '/dev/';
|
||||
/* Default to "/dev/" */
|
||||
char *prefix;
|
||||
|
||||
struct dev_filter *filter;
|
||||
void *private;
|
||||
|
@ -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))) {
|
||||
|
34
tools/lvm.c
34
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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user