From: Ondrej Kozina Date: Wed, 27 Feb 2013 15:48:17 +0000 (+0100) Subject: - simplify check for XAs support. remove unused code X-Git-Tag: v0.1.3~18^2~20 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0f1167bbd8d47b7d6e8a4f927bf3e60be900d551;p=thirdparty%2Fsnapper.git - simplify check for XAs support. remove unused code --- diff --git a/snapper/Compare.cc b/snapper/Compare.cc index e82195d8..3f744c34 100644 --- a/snapper/Compare.cc +++ b/snapper/Compare.cc @@ -178,7 +178,7 @@ namespace snapper unsigned int cmpFiles(const SFile& file1, const struct stat& stat1, const SFile& file2, - const struct stat& stat2) + const struct stat& stat2, bool xa_supported) { unsigned int status = 0; @@ -206,11 +206,11 @@ namespace snapper status |= CONTENT; #ifdef ENABLE_XATTRS - /* TODO: think about this. Do you want to report + /* NOTE: think about this. Do you want to report * XA modification in case the compared files differ - * in their types file A: link, file B: directory + * in their types? */ - if (file1.xaSupported() && file2.xaSupported()) + if (xa_supported) { if (!cmpFilesXattrs(file1, stat1, file2, stat2)) { @@ -267,7 +267,7 @@ namespace snapper throw IOErrorException(); } - return cmpFiles(file1, stat1, file2, stat2); + return cmpFiles(file1, stat1, file2, stat2, dir1.xaSupported() && dir2.xaSupported()); } @@ -330,7 +330,7 @@ namespace snapper { unsigned int status = 0; if (stat1.st_dev == cmp_data.dev1 && stat2.st_dev == cmp_data.dev2) - status = cmpFiles(SFile(dir1, name), stat1, SFile(dir2, name), stat2); + status = cmpFiles(SFile(dir1, name), stat1, SFile(dir2, name), stat2, dir1.xaSupported() && dir2.xaSupported()); if (status != 0) { @@ -495,42 +495,5 @@ namespace snapper return retval; } - -/* - bool cmpFilesXattrsLnk(const SFile& file1, const SFile& file2) - { - int fd1 = file1.open(O_RDONLY | O_NOATIME | O_CLOEXEC); - if (fd1 < 0) - { - y2err("Can't open link: " << file1.fullname() << " w/ error: " << stringerror(errno)); - throw IOErrorException(); - } - - int fd2 = file2.open(O_RDONLY | O_NOATIME | O_CLOEXEC); - if (fd2 < 0) - { - y2err("Can't open link:" << file2.fullname() << " w/ error: " << stringerror(errno)); - close(fd1); - throw IOErrorException(); - } - - bool retval; - - try - { - XAttributes xa(fd1), xb(fd2); - retval = (xa == xb); - } - catch (XAttributesException xae) - { - y2err("extended attributes compare failed"); - retval = false; - } - close(fd1); - close(fd2); - - return retval; - } -*/ #endif } diff --git a/snapper/FileUtils.cc b/snapper/FileUtils.cc index cc28925c..8b075953 100644 --- a/snapper/FileUtils.cc +++ b/snapper/FileUtils.cc @@ -390,13 +390,19 @@ namespace snapper return -1; } -#ifdef ENABLE_XATTRS + bool SDir::xaSupported(void) const { +#ifdef ENABLE_XATTRS return (xastatus == XA_SUPPORTED); +#else + return false; +#endif } + +#ifdef ENABLE_XATTRS void SDir::setXaStatus(void) { @@ -420,14 +426,9 @@ namespace snapper xastatus = XA_SUPPORTED; } } - - bool - SFile::xaSupported(void) const - { - return dir.xaSupported(); - } #endif + SFile::SFile(const SDir& dir, const string& name) : dir(dir), name(name) { diff --git a/snapper/FileUtils.h b/snapper/FileUtils.h index 803b6ae2..2e008467 100644 --- a/snapper/FileUtils.h +++ b/snapper/FileUtils.h @@ -23,6 +23,7 @@ #ifndef SNAPPER_FILE_UTILS_H #define SNAPPER_FILE_UTILS_H +#include "config.h" #include #include @@ -82,10 +83,7 @@ namespace snapper int rename(const string& oldname, const string& newname) const; int mktemp(string& name) const; -#ifdef ENABLE_XATTRS bool xaSupported() const; -#endif - private: #ifdef ENABLE_XATTRS int xastatus; @@ -110,9 +108,6 @@ namespace snapper int stat(struct stat* buf, int flags) const; int open(int flags) const; int readlink(string& buf) const; -#ifdef ENABLE_XATTRS - bool xaSupported() const; -#endif private: const SDir& dir;