diff -Nuarp --exclude '*~' --exclude '*.[oda]' --exclude '*.so' --exclude '*.static' --exclude test --exclude '*.in' --exclude Makefile --exclude man --exclude '*.pc' --exclude autoconf --exclude '*.po' LVM2.2.02.49.orig/lib/locking/file_locking.c LVM2.2.02.49/lib/locking/file_locking.c --- LVM2.2.02.49.orig/lib/locking/file_locking.c 2008-11-12 01:30:52.000000000 -0800 +++ LVM2.2.02.49/lib/locking/file_locking.c 2009-07-23 17:39:10.021993262 -0700 @@ -271,17 +271,22 @@ static int _file_lock_resource(struct cm return 1; } -int init_file_locking(struct locking_type *locking, struct cmd_context *cmd) +int init_file_locking(struct locking_type *locking, struct cmd_context *cmd, const char *lock_dir) { locking->lock_resource = _file_lock_resource; locking->reset_locking = _reset_file_locking; locking->fin_locking = _fin_file_locking; locking->flags = 0; - /* Get lockfile directory from config file */ - strncpy(_lock_dir, find_config_tree_str(cmd, "global/locking_dir", - DEFAULT_LOCK_DIR), - sizeof(_lock_dir)); + if(lock_dir) { + /* Get lockfile directory from commandline */ + strncpy(_lock_dir, lock_dir, sizeof(_lock_dir)); + } else { + /* Get lockfile directory from config file */ + strncpy(_lock_dir, find_config_tree_str(cmd, "global/locking_dir", + DEFAULT_LOCK_DIR), + sizeof(_lock_dir)); + } if (!dm_create_dir(_lock_dir)) return 0; diff -Nuarp --exclude '*~' --exclude '*.[oda]' --exclude '*.so' --exclude '*.static' --exclude test --exclude '*.in' --exclude Makefile --exclude man --exclude '*.pc' --exclude autoconf --exclude '*.po' LVM2.2.02.49.orig/lib/locking/locking.c LVM2.2.02.49/lib/locking/locking.c --- LVM2.2.02.49.orig/lib/locking/locking.c 2009-07-14 22:49:47.000000000 -0700 +++ LVM2.2.02.49/lib/locking/locking.c 2009-07-23 17:32:53.558509986 -0700 @@ -213,7 +213,7 @@ static void _update_vg_lock_count(const * Select a locking type * type: locking type; if < 0, then read config tree value */ -int init_locking(int type, struct cmd_context *cmd) +int init_locking(int type, struct cmd_context *cmd, const char *lock_dir) { if (type < 0) type = find_config_tree_int(cmd, "global/locking_type", 1); @@ -228,7 +228,7 @@ int init_locking(int type, struct cmd_co case 1: log_very_verbose("File-based locking selected."); - if (!init_file_locking(&_locking, cmd)) + if (!init_file_locking(&_locking, cmd, lock_dir)) break; return 1; @@ -268,7 +268,7 @@ int init_locking(int type, struct cmd_co log_warn("WARNING: Falling back to local file-based locking."); log_warn("Volume Groups with the clustered attribute will " "be inaccessible."); - if (init_file_locking(&_locking, cmd)) + if (init_file_locking(&_locking, cmd, lock_dir)) return 1; } diff -Nuarp --exclude '*~' --exclude '*.[oda]' --exclude '*.so' --exclude '*.static' --exclude test --exclude '*.in' --exclude Makefile --exclude man --exclude '*.pc' --exclude autoconf --exclude '*.po' LVM2.2.02.49.orig/lib/locking/locking.h LVM2.2.02.49/lib/locking/locking.h --- LVM2.2.02.49.orig/lib/locking/locking.h 2009-06-12 01:30:19.000000000 -0700 +++ LVM2.2.02.49/lib/locking/locking.h 2009-07-23 17:31:49.638555398 -0700 @@ -19,7 +19,7 @@ #include "uuid.h" #include "config.h" -int init_locking(int type, struct cmd_context *cmd); +int init_locking(int type, struct cmd_context *cmd, const char *lock_dir); void fin_locking(void); void reset_locking(void); int vg_write_lock_held(void); diff -Nuarp --exclude '*~' --exclude '*.[oda]' --exclude '*.so' --exclude '*.static' --exclude test --exclude '*.in' --exclude Makefile --exclude man --exclude '*.pc' --exclude autoconf --exclude '*.po' LVM2.2.02.49.orig/lib/locking/locking_types.h LVM2.2.02.49/lib/locking/locking_types.h --- LVM2.2.02.49.orig/lib/locking/locking_types.h 2009-07-14 22:57:11.000000000 -0700 +++ LVM2.2.02.49/lib/locking/locking_types.h 2009-07-23 17:37:58.598009804 -0700 @@ -42,7 +42,7 @@ int init_no_locking(struct locking_type int init_readonly_locking(struct locking_type *locking, struct cmd_context *cmd); -int init_file_locking(struct locking_type *locking, struct cmd_context *cmd); +int init_file_locking(struct locking_type *locking, struct cmd_context *cmd, const char *lock_dir); int init_external_locking(struct locking_type *locking, struct cmd_context *cmd); diff -Nuarp --exclude '*~' --exclude '*.[oda]' --exclude '*.so' --exclude '*.static' --exclude test --exclude '*.in' --exclude Makefile --exclude man --exclude '*.pc' --exclude autoconf --exclude '*.po' LVM2.2.02.49.orig/liblvm/lvm_base.c LVM2.2.02.49/liblvm/lvm_base.c --- LVM2.2.02.49.orig/liblvm/lvm_base.c 2009-07-13 20:01:18.000000000 -0700 +++ LVM2.2.02.49/liblvm/lvm_base.c 2009-07-23 17:38:09.830509799 -0700 @@ -39,7 +39,7 @@ lvm_t lvm_create(const char *system_dir) /* FIXME: locking_type config option needed? */ /* initialize locking */ - if (!init_locking(-1, cmd)) { + if (!init_locking(-1, cmd, NULL)) { /* FIXME: use EAGAIN as error code here */ log_error("Locking initialisation failed."); lvm_destroy((lvm_t) cmd); diff -Nuarp --exclude '*~' --exclude '*.[oda]' --exclude '*.so' --exclude '*.static' --exclude test --exclude '*.in' --exclude Makefile --exclude man --exclude '*.pc' --exclude autoconf --exclude '*.po' LVM2.2.02.49.orig/tools/args.h LVM2.2.02.49/tools/args.h --- LVM2.2.02.49.orig/tools/args.h 2009-06-04 05:01:16.000000000 -0700 +++ LVM2.2.02.49/tools/args.h 2009-07-23 17:30:36.680664586 -0700 @@ -22,6 +22,7 @@ arg(version_ARG, '\0', "version", NULL, arg(quiet_ARG, '\0', "quiet", NULL, 0) arg(physicalvolumesize_ARG, '\0', "setphysicalvolumesize", size_mb_arg, 0) arg(ignorelockingfailure_ARG, '\0', "ignorelockingfailure", NULL, 0) +arg(lock_dir_ARG, '\0', "lock-dir", string_arg, 0) arg(nolocking_ARG, '\0', "nolocking", NULL, 0) arg(metadatacopies_ARG, '\0', "metadatacopies", int_arg, 0) arg(metadatasize_ARG, '\0', "metadatasize", size_mb_arg, 0) diff -Nuarp --exclude '*~' --exclude '*.[oda]' --exclude '*.so' --exclude '*.static' --exclude test --exclude '*.in' --exclude Makefile --exclude man --exclude '*.pc' --exclude autoconf --exclude '*.po' LVM2.2.02.49.orig/tools/commands.h LVM2.2.02.49/tools/commands.h --- LVM2.2.02.49.orig/tools/commands.h 2009-07-06 12:13:26.000000000 -0700 +++ LVM2.2.02.49/tools/commands.h 2009-07-23 17:30:36.680664586 -0700 @@ -70,6 +70,7 @@ xx(lvchange, "\t[-f|--force]\n" "\t[-h|--help]\n" "\t[--ignorelockingfailure]\n" + "\t[--lock-dir path]\n" "\t[--ignoremonitoring]\n" "\t[--monitor {y|n}]\n" "\t[-M|--persistent y|n] [--major major] [--minor minor]\n" @@ -85,7 +86,7 @@ xx(lvchange, "\tLogicalVolume[Path] [LogicalVolume[Path]...]\n", alloc_ARG, autobackup_ARG, available_ARG, contiguous_ARG, force_ARG, - ignorelockingfailure_ARG, ignoremonitoring_ARG, major_ARG, minor_ARG, + ignorelockingfailure_ARG, lock_dir_ARG, ignoremonitoring_ARG, major_ARG, minor_ARG, monitor_ARG, partial_ARG, permission_ARG, persistent_ARG, readahead_ARG, resync_ARG, refresh_ARG, addtag_ARG, deltag_ARG, test_ARG, yes_ARG) @@ -185,6 +186,7 @@ xx(lvdisplay, "\t[-d|--debug]\n" "\t[-h|--help]\n" "\t[--ignorelockingfailure]\n" + "\t[--lock-dir path]\n" "\t[-m|--maps]\n" "\t[--nosuffix]\n" "\t[-P|--partial] " "\n" @@ -199,6 +201,7 @@ xx(lvdisplay, "\t[-d|--debug]\n" "\t[-h|--help]\n" "\t[--ignorelockingfailure]\n" + "\t[--lock-dir path]\n" "\t[--noheadings]\n" "\t[--nosuffix]\n" "\t[-o|--options [+]Field[,Field]]\n" @@ -213,7 +216,7 @@ xx(lvdisplay, "\t[LogicalVolume[Path] [LogicalVolume[Path]...]]\n", aligned_ARG, all_ARG, colon_ARG, columns_ARG, disk_ARG, - ignorelockingfailure_ARG, maps_ARG, noheadings_ARG, nosuffix_ARG, + ignorelockingfailure_ARG, lock_dir_ARG, maps_ARG, noheadings_ARG, nosuffix_ARG, options_ARG, sort_ARG, partial_ARG, segments_ARG, separator_ARG, unbuffered_ARG, units_ARG) @@ -373,6 +376,7 @@ xx(lvs, "\t[-d|--debug]\n" "\t[-h|--help]\n" "\t[--ignorelockingfailure]\n" + "\t[--lock-dir path]\n" "\t[--nameprefixes]\n" "\t[--noheadings]\n" "\t[--nosuffix]\n" @@ -390,7 +394,7 @@ xx(lvs, "\t[--version]" "\n" "\t[LogicalVolume[Path] [LogicalVolume[Path]...]]\n", - aligned_ARG, all_ARG, ignorelockingfailure_ARG, nameprefixes_ARG, + aligned_ARG, all_ARG, ignorelockingfailure_ARG, lock_dir_ARG, nameprefixes_ARG, noheadings_ARG, nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG, rows_ARG, segments_ARG, separator_ARG, sort_ARG, trustcache_ARG, unbuffered_ARG, units_ARG, unquoted_ARG) @@ -404,11 +408,12 @@ xx(lvscan, "\t[-d|--debug] " "\n" "\t[-h|-?|--help] " "\n" "\t[--ignorelockingfailure]\n" + "\t[--lock-dir path]\n" "\t[-P|--partial] " "\n" "\t[-v|--verbose] " "\n" "\t[--version]\n", - all_ARG, blockdevice_ARG, disk_ARG, ignorelockingfailure_ARG, partial_ARG) + all_ARG, blockdevice_ARG, disk_ARG, ignorelockingfailure_ARG, lock_dir_ARG, partial_ARG) xx(pvchange, "Change attributes of physical volume(s)", @@ -510,6 +515,7 @@ xx(pvdisplay, "\t[-d|--debug]\n" "\t[-h|--help]\n" "\t[--ignorelockingfailure]\n" + "\t[--lock-dir path]\n" "\t[-m|--maps]\n" "\t[--nosuffix]\n" "\t[-s|--short]\n" @@ -524,6 +530,7 @@ xx(pvdisplay, "\t[-d|--debug]\n" "\t[-h|--help]\n" "\t[--ignorelockingfailure]\n" + "\t[--lock-dir path]\n" "\t[--noheadings]\n" "\t[--nosuffix]\n" "\t[-o|--options [+]Field[,Field]]\n" @@ -535,7 +542,7 @@ xx(pvdisplay, "\t[--version]" "\n" "\t[PhysicalVolumePath [PhysicalVolumePath...]]\n", - aligned_ARG, all_ARG, colon_ARG, columns_ARG, ignorelockingfailure_ARG, + aligned_ARG, all_ARG, colon_ARG, columns_ARG, ignorelockingfailure_ARG, lock_dir_ARG, maps_ARG, noheadings_ARG, nosuffix_ARG, options_ARG, separator_ARG, short_ARG, sort_ARG, unbuffered_ARG, units_ARG) @@ -585,6 +592,7 @@ xx(pvs, "\t[-d|--debug]" "\n" "\t[-h|-?|--help] " "\n" "\t[--ignorelockingfailure]\n" + "\t[--lock-dir path]\n" "\t[--nameprefixes]\n" "\t[--noheadings]\n" "\t[--nosuffix]\n" @@ -602,7 +610,7 @@ xx(pvs, "\t[--version]\n" "\t[PhysicalVolume [PhysicalVolume...]]\n", - aligned_ARG, all_ARG, ignorelockingfailure_ARG, nameprefixes_ARG, + aligned_ARG, all_ARG, ignorelockingfailure_ARG, lock_dir_ARG, nameprefixes_ARG, noheadings_ARG, nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG, rows_ARG, segments_ARG, separator_ARG, sort_ARG, trustcache_ARG, unbuffered_ARG, units_ARG, unquoted_ARG) @@ -615,13 +623,14 @@ xx(pvscan, "\t{-e|--exported | -n|--novolumegroup} " "\n" "\t[-h|-?|--help]" "\n" "\t[--ignorelockingfailure]\n" + "\t[--lock-dir path]\n" "\t[-P|--partial] " "\n" "\t[-s|--short] " "\n" "\t[-u|--uuid] " "\n" "\t[-v|--verbose] " "\n" "\t[--version]\n", - exported_ARG, ignorelockingfailure_ARG, novolumegroup_ARG, partial_ARG, + exported_ARG, ignorelockingfailure_ARG, lock_dir_ARG, novolumegroup_ARG, partial_ARG, short_ARG, uuid_ARG) xx(segtypes, @@ -637,12 +646,13 @@ xx(vgcfgbackup, "\t[-f|--file filename] " "\n" "\t[-h|-?|--help] " "\n" "\t[--ignorelockingfailure]\n" + "\t[--lock-dir path]\n" "\t[-P|--partial] " "\n" "\t[-v|--verbose]" "\n" "\t[--version] " "\n" "\t[VolumeGroupName...]\n", - file_ARG, ignorelockingfailure_ARG, partial_ARG) + file_ARG, ignorelockingfailure_ARG, lock_dir_ARG, partial_ARG) xx(vgcfgrestore, "Restore volume group configuration", @@ -671,6 +681,7 @@ xx(vgchange, "\t[-d|--debug] " "\n" "\t[-h|--help] " "\n" "\t[--ignorelockingfailure]\n" + "\t[--lock-dir path]\n" "\t[--ignoremonitoring]\n" "\t[--monitor {y|n}]\n" "\t[--refresh]\n" @@ -689,7 +700,7 @@ xx(vgchange, "\t[VolumeGroupName...]\n", addtag_ARG, alloc_ARG, allocation_ARG, autobackup_ARG, available_ARG, - clustered_ARG, deltag_ARG, ignorelockingfailure_ARG, ignoremonitoring_ARG, + clustered_ARG, deltag_ARG, ignorelockingfailure_ARG, lock_dir_ARG, ignoremonitoring_ARG, logicalvolume_ARG, maxphysicalvolumes_ARG, monitor_ARG, partial_ARG, physicalextentsize_ARG, refresh_ARG, resizeable_ARG, resizable_ARG, test_ARG, uuid_ARG) @@ -752,6 +763,7 @@ xx(vgdisplay, "\t[-d|--debug] " "\n" "\t[-h|--help] " "\n" "\t[--ignorelockingfailure]" "\n" + "\t[--lock-dir path]\n" "\t[--nosuffix]\n" "\t[-P|--partial] " "\n" "\t[--units hsbkmgtHKMGT]\n" @@ -764,6 +776,7 @@ xx(vgdisplay, "\t[-d|--debug] " "\n" "\t[-h|--help] " "\n" "\t[--ignorelockingfailure]" "\n" + "\t[--lock-dir path]\n" "\t[--noheadings]\n" "\t[--nosuffix]\n" "\t[-o|--options [+]Field[,Field]]\n" @@ -777,7 +790,7 @@ xx(vgdisplay, "\t[VolumeGroupName [VolumeGroupName...]]\n", activevolumegroups_ARG, aligned_ARG, colon_ARG, columns_ARG, disk_ARG, - ignorelockingfailure_ARG, noheadings_ARG, nosuffix_ARG, options_ARG, + ignorelockingfailure_ARG, lock_dir_ARG, noheadings_ARG, nosuffix_ARG, options_ARG, partial_ARG, short_ARG, separator_ARG, sort_ARG, unbuffered_ARG, units_ARG) xx(vgexport, @@ -844,12 +857,13 @@ xx(vgmknodes, "\t[-d|--debug]\n" "\t[-h|--help]\n" "\t[--ignorelockingfailure]\n" + "\t[--lock-dir path]\n" "\t[--refresh]\n" "\t[-v|--verbose]\n" "\t[--version]" "\n" "\t[VolumeGroupName...]\n", - ignorelockingfailure_ARG, refresh_ARG) + ignorelockingfailure_ARG, lock_dir_ARG, refresh_ARG) xx(vgreduce, "Remove physical volume(s) from a volume group", @@ -909,6 +923,7 @@ xx(vgs, "\t[-d|--debug]\n" "\t[-h|--help]\n" "\t[--ignorelockingfailure]\n" + "\t[--lock-dir path]\n" "\t[--nameprefixes]\n" "\t[--noheadings]\n" "\t[--nosuffix]\n" @@ -925,7 +940,7 @@ xx(vgs, "\t[--version]\n" "\t[VolumeGroupName [VolumeGroupName...]]\n", - aligned_ARG, all_ARG, ignorelockingfailure_ARG, nameprefixes_ARG, + aligned_ARG, all_ARG, ignorelockingfailure_ARG, lock_dir_ARG, nameprefixes_ARG, noheadings_ARG, nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG, rows_ARG, separator_ARG, sort_ARG, trustcache_ARG, unbuffered_ARG, units_ARG, unquoted_ARG) @@ -937,12 +952,13 @@ xx(vgscan, "\t[-d|--debug]\n" "\t[-h|--help]\n" "\t[--ignorelockingfailure]\n" + "\t[--lock-dir path]\n" "\t[--mknodes]\n" "\t[-P|--partial] " "\n" "\t[-v|--verbose]\n" "\t[--version]" "\n", - ignorelockingfailure_ARG, mknodes_ARG, partial_ARG) + ignorelockingfailure_ARG, lock_dir_ARG, mknodes_ARG, partial_ARG) xx(vgsplit, "Move physical volumes into a new or existing volume group", diff -Nuarp --exclude '*~' --exclude '*.[oda]' --exclude '*.so' --exclude '*.static' --exclude test --exclude '*.in' --exclude Makefile --exclude man --exclude '*.pc' --exclude autoconf --exclude '*.po' LVM2.2.02.49.orig/tools/lvmcmdline.c LVM2.2.02.49/tools/lvmcmdline.c --- LVM2.2.02.49.orig/tools/lvmcmdline.c 2009-07-13 12:49:49.000000000 -0700 +++ LVM2.2.02.49/tools/lvmcmdline.c 2009-07-23 17:37:30.774058849 -0700 @@ -964,6 +964,7 @@ int lvm_run_command(struct cmd_context * { int ret = 0; int locking_type; + const char *lock_dir; init_error_message_produced(0); @@ -1015,7 +1016,12 @@ int lvm_run_command(struct cmd_context * else locking_type = -1; - if (!init_locking(locking_type, cmd)) { + if(arg_count(cmd, lock_dir_ARG)) { + /* Get lockfile directory from commandline */ + lock_dir = arg_str_value(cmd, lock_dir_ARG, ""); + } + + if (!init_locking(locking_type, cmd, lock_dir)) { log_error("Locking type %d initialisation failed.", locking_type); ret = ECMD_FAILED;