]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- simplify check for XAs support. remove unused code
authorOndrej Kozina <okozina@redhat.com>
Wed, 27 Feb 2013 15:48:17 +0000 (16:48 +0100)
committerOndrej Kozina <okozina@redhat.com>
Wed, 27 Feb 2013 16:30:11 +0000 (17:30 +0100)
snapper/Compare.cc
snapper/FileUtils.cc
snapper/FileUtils.h

index e82195d88ddf1faf63a4ff1b53b98fbafac98bf4..3f744c34b2166f16ead2c754a7c0eb0df1172500 100644 (file)
@@ -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
 }
index cc28925c387ac4857a4977c8070a94e9b9e6db3e..8b0759530287bfb47f036a62dc798f32f3fb423b 100644 (file)
@@ -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)
     {
index 803b6ae285ac210ab00b1edc2dab9e099e90c3ba..2e008467d79d8467271527ca784065725f0e42dd 100644 (file)
@@ -23,6 +23,7 @@
 #ifndef SNAPPER_FILE_UTILS_H
 #define SNAPPER_FILE_UTILS_H
 
+#include "config.h"
 
 #include <string>
 #include <vector>
@@ -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;