mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
devices file: fail if --devicesfile filename doesn't exist
A typo of the filename after --devicesfile should result in a command error rather than the command falling back to using no devices file at all. Exception is vgcreate|pvcreate which create a new devices file if the file name doesn't exist.
This commit is contained in:
parent
9dfa6f3879
commit
bfe072e438
@ -1863,6 +1863,15 @@ int setup_devices(struct cmd_context *cmd)
|
||||
|
||||
file_exists = devices_file_exists(cmd);
|
||||
|
||||
/*
|
||||
* Fail if user specifies a file name that doesn't exist and
|
||||
* the command is not creating a new devices file.
|
||||
*/
|
||||
if (!file_exists && !cmd->create_edit_devices_file && cmd->devicesfile && strlen(cmd->devicesfile)) {
|
||||
log_error("Devices file not found: %s", cmd->devices_file_path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Removing the devices file is another way of disabling the use of
|
||||
* a devices file, unless the command creates the devices file.
|
||||
|
@ -104,6 +104,10 @@ not ls "$DFDIR/system.devices"
|
||||
vgs --devicesfile test.devices $vg1
|
||||
not vgs --devicesfile test.devices $vg2
|
||||
|
||||
# misspelled override name fails
|
||||
not vgs --devicesfile doesnotexist $vg1
|
||||
not vgs --devicesfile doesnotexist $vg2
|
||||
|
||||
# devicesfile and devices cannot be used together
|
||||
not vgs --devicesfile test.devices --devices "$dev1","$dev1" $vg1
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user