cp will fail if /etc/lvm is an empty directory. Copy the entire directory and adjust environment variable. Signed-off-by: Olaf Hering <olaf at aepfle.de> --- daemon/lvm-filter.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/daemon/lvm-filter.c b/daemon/lvm-filter.c index 52d6b3d..204e238 100644 --- a/daemon/lvm-filter.c +++ b/daemon/lvm-filter.c @@ -47,7 +47,7 @@ void copy_lvm (void) { struct stat statbuf; - char cmd[64]; + char cmd[64], env[64]; int r; /* If /etc/lvm directory doesn't exist (or isn't a directory) assume @@ -68,8 +68,8 @@ copy_lvm (void) exit (EXIT_FAILURE); } - /* Hopefully no dotfiles in there ... XXX */ - snprintf (cmd, sizeof cmd, "%s -a /etc/lvm/* %s", str_cp, lvm_system_dir); + /* Copy the entire directory */ + snprintf (cmd, sizeof cmd, "%s -a /etc/lvm/ %s", str_cp, lvm_system_dir); r = system (cmd); if (r == -1) { perror (cmd); @@ -85,7 +85,8 @@ copy_lvm (void) } /* Set environment variable so we use the copy. */ - setenv ("LVM_SYSTEM_DIR", lvm_system_dir, 1); + snprintf(env, sizeof(env), "%s/lvm", lvm_system_dir); + setenv ("LVM_SYSTEM_DIR", env, 1); /* Set a handler to remove the temporary directory at exit. */ atexit (rm_lvm_system_dir); -- 1.8.0.1
Richard W.M. Jones
2013-Jan-17 14:14 UTC
[Libguestfs] [PATCH] daemon: copy entire lvm directory
On Wed, Jan 02, 2013 at 04:13:06PM +0100, Olaf Hering wrote:> cp will fail if /etc/lvm is an empty directory. Copy the entire > directory and adjust environment variable.Thanks - pushed. I changed the whitespace and removed some unnecessary parens in this line:> + snprintf(env, sizeof(env), "%s/lvm", lvm_system_dir);Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming blog: http://rwmj.wordpress.com Fedora now supports 80 OCaml packages (the OPEN alternative to F#)
Richard W.M. Jones
2013-Jan-18 07:17 UTC
Re: [Libguestfs] [PATCH] daemon: copy entire lvm directory
On Thu, Jan 17, 2013 at 02:14:00PM +0000, Richard W.M. Jones wrote:> On Wed, Jan 02, 2013 at 04:13:06PM +0100, Olaf Hering wrote: > > cp will fail if /etc/lvm is an empty directory. Copy the entire > > directory and adjust environment variable. > > Thanks - pushed. I changed the whitespace and removed some > unnecessary parens in this line: > > > + snprintf(env, sizeof(env), "%s/lvm", lvm_system_dir);Actually this breaks the lvm_set_filter test and clearing the LVM cache (since they expect to find lvm_system_dir/lvm.conf but the file has now moved to lvm_system_dir/lvm/lvm.conf). I added this patch to fix it: https://github.com/libguestfs/libguestfs/commit/d8f14591d10df847fad2e24f2f430b2543020912 Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://people.redhat.com/~rjones/virt-df/
Olaf Hering
2013-Jan-18 13:02 UTC
Re: [Libguestfs] [PATCH] daemon: copy entire lvm directory
On Fri, Jan 18, Richard W.M. Jones wrote:> On Thu, Jan 17, 2013 at 02:14:00PM +0000, Richard W.M. Jones wrote: > > On Wed, Jan 02, 2013 at 04:13:06PM +0100, Olaf Hering wrote: > > > cp will fail if /etc/lvm is an empty directory. Copy the entire > > > directory and adjust environment variable. > > > > Thanks - pushed. I changed the whitespace and removed some > > unnecessary parens in this line: > > > > > + snprintf(env, sizeof(env), "%s/lvm", lvm_system_dir); > > Actually this breaks the lvm_set_filter test and clearing the LVM > cache (since they expect to find lvm_system_dir/lvm.conf but the file > has now moved to lvm_system_dir/lvm/lvm.conf). I added this patch to > fix it:Sorry for that, and thanks for the followup fix. Olaf
Seemingly Similar Threads
- [PATCH 2/5] daemon: lvm-filter: start lvmetad better
- [PATCH v2] daemon: Move lvmetad to early in the appliance boot process.
- missing lvm.conf is fatal
- [PATCH 0/2] daemon: Reimplement handling of lvm.conf and filters.
- [PATCH 0/5] Improve LVM handling in the appliance