"Richard W.M. Jones" <rjones@xxxxxxxxxx> wrote: > Secondly there is an API of sorts for lvm2. I think Alasdair called it > "libcmd", but maybe I got that wrong because Google doesn't seem to turn > up anything. In any case, all it is is a wrapper around the command > line tools, so it seems doubtful that this is going to be any better > than just invoking the command line tools ourselves. lvm2cmd is what you're looking for. It is only slightly higher-level than "system". Here's an example of that interface, from the lvm2 repo, doc/example_cmdlib.c: #include "lvm2cmd.h" /* All output gets passed to this function line-by-line */ void test_log_fn(int level, const char *file, int line, const char *format) { /* Extract and process output here rather than printing it */ if (level != 4) return; printf("%s\n", format); return; } int main(int argc, char **argv) { void *handle; int r; lvm2_log_fn(test_log_fn); handle = lvm2_init(); lvm2_log_level(handle, 1); r = lvm2_run(handle, "vgs --noheadings vg1"); /* More commands here */ lvm2_exit(handle); return r; }