diff options
Diffstat (limited to 'daemons/clvmd/lvm-functions.c')
-rw-r--r-- | daemons/clvmd/lvm-functions.c | 19 |
1 files changed, 14 insertions, 5 deletions
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; } |