[lxc-devel] [PATCH 2/2] templates: use hardlink detection in rsync

Dwight Engen dwight.engen at oracle.com
Mon Dec 3 19:10:50 UTC 2012


On Mon, 03 Dec 2012 13:55:41 -0500
"Michael H. Warfield" <mhw at WittsEnd.com> wrote:

> On Mon, 2012-12-03 at 12:18 -0600, Serge Hallyn wrote:
> > Quoting Dwight Engen (dwight.engen at oracle.com):
> > > On Mon, 3 Dec 2012 10:47:26 -0600
> > > Serge Hallyn <serge.hallyn at canonical.com> wrote:
> > > 
> > > > Quoting Dwight Engen (dwight.engen at oracle.com):
> > > > > On Mon, 3 Dec 2012 10:04:13 -0600
> > > > > Serge Hallyn <serge.hallyn at canonical.com> wrote:
> > > > > 
> > > > > > However one question is:  is -H ubiquitous?
> > > > > 
> > > > > I'm wondering why we don't just use the cp -a? It seems like
> > > > > cp is far more likely to be installed than rsync? rootfs_path
> > > > > probably doesn't already exist so it not like rsync is going
> > > > > to be faster?

One reason I commented on this was that I had noticed the use of rsync
to do this copy in other places as well, namely just about every
template that caches a rootfs, so we might want to consider replacing
those as well. Note that I'm not an rsync hater at all :) its a great
tool and I use it all the time for cross machine mirroring, backups
etc.. but if all we're doing is local file system directory copies, I
think there are benefits to reducing our external tool dependencies.

> > > > The one advantage to me was that 'rsync -va /x/ /y' does the
> > > > right thing whether or not /y already exists or not.  cp -a
> > > > does not.  This just left the code tidier.
> > > > 
> > > > Is there a nicer clean one-line idiom to do that with cp?
> > > 
> > > I think cp -aT does what we want. You might want to add -u also.
> > 
> > Boy, that does not do what I expected based on the documentation,
> > and having -t and -T invert args didn't help :)  But the little
> > test below seems to do the right thing.
> 
> Interesting.  I also would have not expected for the same reasons.
> I'm noting that for future reference myself.
> 
> > I'll send a new patch using cp -T, thanks!
> 
> Yeah, thanks!
> 
> > #!/bin/bash
> > rm -rf /tmp/d
> > mkdir -p /tmp/d/a/e/f
> > #mkdir -p /tmp/d/b
> > cp -aT /tmp/d/a /tmp/d/b
> > find /tmp/d
> > 
> > echo
> > 
> > rm -rf /tmp/d
> > mkdir -p /tmp/d/a/e/f
> > mkdir -p /tmp/d/b
> > cp -aT /tmp/d/a /tmp/d/b
> > find /tmp/d
> > 
> > echo
> > 
> > rm -rf /tmp/d
> > mkdir -p /tmp/d/a
> > touch /tmp/d/a/f
> > #mkdir -p /tmp/d/b
> > cp -aT /tmp/d/a /tmp/d/b
> > find /tmp/d
> > 
> > echo
> > 
> > rm -rf /tmp/d
> > mkdir -p /tmp/d/a
> > touch /tmp/d/a/f
> > ln -s /tmp/d/a/f /tmp/d/a/g
> > ln /tmp/d/a/f /tmp/d/a/h
> > mkdir -p /tmp/d/b
> > cp -aT /tmp/d/a /tmp/d/b
> > find /tmp/d
> > ls -li /tmp/d/b
> > 
> > -serge
> 
> Regards,
> Mike





More information about the lxc-devel mailing list