mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-02 01:18:26 +03:00
agk, I recall you saying you had a massive commit pending; if you need me
to back this out so you can do that commit, let me know. Also, if there's an issue with the error message that's displayed, just change it in tools.h. This causes a "device-mapper driver/module not loaded?" error message to be displayed for the commands that require dm-mod, if the tools can't get the driver version. It's not done for commands that don't require dm-mod. This should clear up some problems people have had attempting to use lvm2 without rtfm'ing.
This commit is contained in:
parent
4efe1861c3
commit
50762c2186
@ -58,6 +58,9 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!driver_is_loaded())
|
||||||
|
return ECMD_FAILED;
|
||||||
|
|
||||||
return process_each_lv(cmd, argc, argv, LCK_VG_WRITE, &lvchange_single);
|
return process_each_lv(cmd, argc, argv, LCK_VG_WRITE, &lvchange_single);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -480,6 +480,9 @@ int lvcreate(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
if (!_read_params(&lp, cmd, argc, argv))
|
if (!_read_params(&lp, cmd, argc, argv))
|
||||||
return -EINVALID_CMD_LINE;
|
return -EINVALID_CMD_LINE;
|
||||||
|
|
||||||
|
if (!driver_is_loaded())
|
||||||
|
return ECMD_FAILED;
|
||||||
|
|
||||||
if (!lock_vol(cmd, lp.vg_name, LCK_VG_WRITE)) {
|
if (!lock_vol(cmd, lp.vg_name, LCK_VG_WRITE)) {
|
||||||
log_error("Can't get lock for %s", lp.vg_name);
|
log_error("Can't get lock for %s", lp.vg_name);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -42,5 +42,8 @@ int lvdisplay(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!driver_is_loaded())
|
||||||
|
return ECMD_FAILED;
|
||||||
|
|
||||||
return process_each_lv(cmd, argc, argv, LCK_VG_READ, &lvdisplay_single);
|
return process_each_lv(cmd, argc, argv, LCK_VG_READ, &lvdisplay_single);
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,9 @@ int lvremove(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!driver_is_loaded())
|
||||||
|
return ECMD_FAILED;
|
||||||
|
|
||||||
return process_each_lv(cmd, argc, argv, LCK_VG_READ, &lvremove_single);
|
return process_each_lv(cmd, argc, argv, LCK_VG_READ, &lvremove_single);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,6 +98,9 @@ int lvrename(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!driver_is_loaded())
|
||||||
|
return ECMD_FAILED;
|
||||||
|
|
||||||
log_verbose("Checking for existing volume group \"%s\"", vg_name);
|
log_verbose("Checking for existing volume group \"%s\"", vg_name);
|
||||||
|
|
||||||
if (!lock_vol(cmd, vg_name, LCK_VG_WRITE)) {
|
if (!lock_vol(cmd, vg_name, LCK_VG_WRITE)) {
|
||||||
|
@ -94,6 +94,9 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
if ((st = strrchr(lv_name, '/')))
|
if ((st = strrchr(lv_name, '/')))
|
||||||
lv_name = st + 1;
|
lv_name = st + 1;
|
||||||
|
|
||||||
|
if (!driver_is_loaded())
|
||||||
|
return ECMD_FAILED;
|
||||||
|
|
||||||
/* does VG exist? */
|
/* does VG exist? */
|
||||||
log_verbose("Finding volume group %s", vg_name);
|
log_verbose("Finding volume group %s", vg_name);
|
||||||
if (!lock_vol(cmd, vg_name, LCK_VG_WRITE)) {
|
if (!lock_vol(cmd, vg_name, LCK_VG_WRITE)) {
|
||||||
|
@ -151,4 +151,13 @@ static inline const char *command_name(struct cmd_context *cmd)
|
|||||||
return cmd->command->name;
|
return cmd->command->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int driver_is_loaded(void)
|
||||||
|
{
|
||||||
|
int i = driver_version(NULL, 0);
|
||||||
|
|
||||||
|
if (!i)
|
||||||
|
log_error("device-mapper driver/module not loaded?");
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -58,5 +58,8 @@ static int vg_backup_single(struct cmd_context *cmd, const char *vg_name)
|
|||||||
|
|
||||||
int vgcfgbackup(struct cmd_context *cmd, int argc, char **argv)
|
int vgcfgbackup(struct cmd_context *cmd, int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
if (!driver_is_loaded())
|
||||||
|
return ECMD_FAILED;
|
||||||
|
|
||||||
return process_each_vg(cmd, argc, argv, LCK_VG_READ, &vg_backup_single);
|
return process_each_vg(cmd, argc, argv, LCK_VG_READ, &vg_backup_single);
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,9 @@ int vgcfgrestore(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!driver_is_loaded())
|
||||||
|
return ECMD_FAILED;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FIXME: overloading the -l arg for now to display a
|
* FIXME: overloading the -l arg for now to display a
|
||||||
* list of archive files for a particular vg
|
* list of archive files for a particular vg
|
||||||
|
@ -75,6 +75,9 @@ int vgchange(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!driver_is_loaded())
|
||||||
|
return ECMD_FAILED;
|
||||||
|
|
||||||
return process_each_vg(cmd, argc, argv,
|
return process_each_vg(cmd, argc, argv,
|
||||||
(arg_count(cmd, available_ARG)) ?
|
(arg_count(cmd, available_ARG)) ?
|
||||||
LCK_VG_READ : LCK_VG_WRITE, &vgchange_single);
|
LCK_VG_READ : LCK_VG_WRITE, &vgchange_single);
|
||||||
|
@ -79,6 +79,9 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!driver_is_loaded())
|
||||||
|
return ECMD_FAILED;
|
||||||
|
|
||||||
/* Create the new VG */
|
/* Create the new VG */
|
||||||
if (!(vg = vg_create(cmd, vg_name, extent_size, max_pv, max_lv,
|
if (!(vg = vg_create(cmd, vg_name, extent_size, max_pv, max_lv,
|
||||||
argc - 1, argv + 1)))
|
argc - 1, argv + 1)))
|
||||||
|
@ -34,6 +34,9 @@ int vgdisplay(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!driver_is_loaded())
|
||||||
|
return ECMD_FAILED;
|
||||||
|
|
||||||
/* FIXME -D disk_ARG is now redundant */
|
/* FIXME -D disk_ARG is now redundant */
|
||||||
|
|
||||||
/********* FIXME: Do without this - or else 2(+) passes!
|
/********* FIXME: Do without this - or else 2(+) passes!
|
||||||
|
@ -34,6 +34,9 @@ int vgexport(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!driver_is_loaded())
|
||||||
|
return ECMD_FAILED;
|
||||||
|
|
||||||
return process_each_vg(cmd, argc, argv, LCK_VG_READ, &vgexport_single);
|
return process_each_vg(cmd, argc, argv, LCK_VG_READ, &vgexport_single);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +36,9 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!driver_is_loaded())
|
||||||
|
return ECMD_FAILED;
|
||||||
|
|
||||||
vg_name = argv[0];
|
vg_name = argv[0];
|
||||||
argc--;
|
argc--;
|
||||||
argv++;
|
argv++;
|
||||||
|
@ -34,6 +34,9 @@ int vgimport(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!driver_is_loaded())
|
||||||
|
return ECMD_FAILED;
|
||||||
|
|
||||||
return process_each_vg(cmd, argc, argv, LCK_VG_WRITE, &vgimport_single);
|
return process_each_vg(cmd, argc, argv, LCK_VG_WRITE, &vgimport_single);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,9 @@ int vgmerge(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!driver_is_loaded())
|
||||||
|
return ECMD_FAILED;
|
||||||
|
|
||||||
vg_name_to = argv[0];
|
vg_name_to = argv[0];
|
||||||
argc--;
|
argc--;
|
||||||
argv++;
|
argv++;
|
||||||
|
@ -46,6 +46,9 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!driver_is_loaded())
|
||||||
|
return ECMD_FAILED;
|
||||||
|
|
||||||
vg_name = argv[0];
|
vg_name = argv[0];
|
||||||
argv++;
|
argv++;
|
||||||
argc--;
|
argc--;
|
||||||
|
@ -26,6 +26,9 @@ int vgremove(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
if (!driver_is_loaded())
|
||||||
|
return ECMD_FAILED;
|
||||||
|
|
||||||
if (!lock_vol(cmd, "", LCK_VG_WRITE)) {
|
if (!lock_vol(cmd, "", LCK_VG_WRITE)) {
|
||||||
log_error("Can't get lock for orphan PVs");
|
log_error("Can't get lock for orphan PVs");
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
|
@ -67,6 +67,9 @@ int vgrename(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!driver_is_loaded())
|
||||||
|
return ECMD_FAILED;
|
||||||
|
|
||||||
log_verbose("Checking for existing volume group \"%s\"", vg_name_old);
|
log_verbose("Checking for existing volume group \"%s\"", vg_name_old);
|
||||||
|
|
||||||
if (!lock_vol(cmd, vg_name_old, LCK_VG_WRITE)) {
|
if (!lock_vol(cmd, vg_name_old, LCK_VG_WRITE)) {
|
||||||
|
@ -180,6 +180,9 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!driver_is_loaded())
|
||||||
|
return ECMD_FAILED;
|
||||||
|
|
||||||
log_verbose("Checking for volume group \"%s\"", vg_name_from);
|
log_verbose("Checking for volume group \"%s\"", vg_name_from);
|
||||||
if (!lock_vol(cmd, vg_name_from, LCK_VG_WRITE)) {
|
if (!lock_vol(cmd, vg_name_from, LCK_VG_WRITE)) {
|
||||||
log_error("Can't get lock for %s", vg_name_from);
|
log_error("Can't get lock for %s", vg_name_from);
|
||||||
|
Loading…
Reference in New Issue
Block a user