
On Tue, Aug 12, 2008 at 07:29:20PM +0200, Jim Meyering wrote:
"Daniel P. Berrange" <berrange@redhat.com> wrote:
On Tue, Aug 12, 2008 at 07:18:00PM +0200, Jim Meyering wrote:
I've rewritten virFileLinkPointsTo to be a lot simpler, and more importantly, it has far fewer failure points. If anyone wants to preserve the original behavior that makes it fail when the first parameter does not specify a symlink, I can add that. The only difference in behavior would be when the two files are hard-linked.
Nah, that's not a difference we'd encounter with the way we use this API inside libvirt.
In any case, I'll remove the FIXME comment.
Remove the virLog() function too - the caller should be responsible for reporting errors / logging if it so desires. Aside from that, ACK - this is a very nice simplification.
Glad to. I would have done that initially, but was trying to retain more of the initial semantics.
That log message has been on my 'hit list' for a while :-)
Thanks for the quick review. Here's the new version:
/* Return nonzero if checkLink and checkDest refer to the same file. Otherwise, return 0. */ int virFileLinkPointsTo(const char *checkLink, const char *checkDest) { struct stat src_sb; struct stat dest_sb;
return (stat (checkLink, &src_sb) == 0 && stat (checkDest, &dest_sb) == 0 && SAME_INODE (src_sb, dest_sb)); }
ACK. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|