From d2c116058e72d365802eb5641be60a615daacb96 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Sat, 24 Sep 2011 20:50:35 +0000 Subject: CLVMD support for LVM_CLVMD_BINARY and LVM_BINARY Read 2 environmental vars to learn about overide position for CLVMD and LVM binaries. We support LVM_BINARY in other script - and this way we could easily test restart in our test-suite. --- daemons/clvmd/lvm-functions.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'daemons/clvmd/lvm-functions.c') diff --git a/daemons/clvmd/lvm-functions.c b/daemons/clvmd/lvm-functions.c index ba786bb0..f16d006c 100644 --- a/daemons/clvmd/lvm-functions.c +++ b/daemons/clvmd/lvm-functions.c @@ -704,14 +704,21 @@ static int get_initial_state(struct dm_hash_table *excl_uuid) char lv[64], vg[64], flags[25], vg_flags[25]; char uuid[65]; char line[255]; - FILE *lvs = - popen - (LVM_PATH " lvs --config 'log{command_names=0 prefix=\"\"}' --nolocking --noheadings -o vg_uuid,lv_uuid,lv_attr,vg_attr", - "r"); + char *lvs_cmd; + const char *lvm_binary = getenv("LVM_BINARY") ? : LVM_PATH; + FILE *lvs; - if (!lvs) + if (dm_asprintf(&lvs_cmd, "%s lvs --config 'log{command_names=0 prefix=\"\"}' " + "--nolocking --noheadings -o vg_uuid,lv_uuid,lv_attr,vg_attr", + lvm_binary) < 0) return 0; + /* FIXME: Maybe link and use liblvm2cmd directly instead of fork */ + if (!(lvs = popen(lvs_cmd, "r"))) { + dm_free(lvs_cmd); + return 0; + } + while (fgets(line, sizeof(line), lvs)) { if (sscanf(line, "%s %s %s %s\n", vg, lv, flags, vg_flags) == 4) { @@ -749,6 +756,8 @@ static int get_initial_state(struct dm_hash_table *excl_uuid) if (fclose(lvs)) DEBUGLOG("lvs fclose failed: %s\n", strerror(errno)); + dm_free(lvs_cmd); + return 1; } -- cgit