]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- improved snapshot check functions
authorArvin Schnell <aschnell@suse.de>
Wed, 12 Sep 2012 13:27:06 +0000 (15:27 +0200)
committerArvin Schnell <aschnell@suse.de>
Wed, 12 Sep 2012 13:27:06 +0000 (15:27 +0200)
snapper/AppUtil.cc
snapper/AppUtil.h
snapper/Filesystem.cc

index 232edd3cab2e28964276a40e1bd9a628e1527339..f5d7a4d7e044851422f7ca54b78d6fa55181db7a 100644 (file)
@@ -53,22 +53,6 @@ namespace snapper
     }
 
 
-    bool
-    checkNormalFile(const string& Path_Cv)
-    {
-       struct stat Stat_ri;
-       return stat(Path_Cv.c_str(), &Stat_ri) >= 0 && S_ISREG(Stat_ri.st_mode);
-    }
-
-
-    bool
-    checkAnything(const string& Path_Cv)
-    {
-       struct stat Stat_ri;
-       return stat(Path_Cv.c_str(), &Stat_ri) >= 0;
-    }
-
-
     list<string>
     glob(const string& path, int flags)
     {
index e9a88b44c59cad34de543c249ea232e3ffc0b136..056914adaa93f2a2ec897d090db65b75061d3bb9 100644 (file)
@@ -41,9 +41,7 @@ namespace snapper
     using std::vector;
 
 
-    bool checkNormalFile(const string& Path_Cv);
     bool checkDir(const string& Path_Cv);
-    bool checkAnything(const string& Path_Cv);
 
     list<string> glob(const string& path, int flags);
 
index 19d18ce06509aa8a6979cf0363bdaa15d25e9b19..1067b67b8aeeed8699e57909fdbb8042b5752638 100644 (file)
@@ -633,7 +633,9 @@ namespace snapper
     bool
     Ext4::checkSnapshot(unsigned int num) const
     {
-       return checkNormalFile(snapshotFile(num));
+       struct stat stat;
+       int r1 = ::stat(snapshotFile(num).c_str(), &stat);
+       return r1 == 0 && S_ISREG(stat.st_mode);
     }
     // ENABLE_EXT4
 #endif
@@ -846,7 +848,9 @@ namespace snapper
     bool
     Lvm::checkSnapshot(unsigned int num) const
     {
-       return checkAnything(getDevice(num));
+       struct stat stat;
+       int r1 = ::stat(getDevice(num).c_str(), &stat);
+       return r1 == 0 && S_ISBLK(stat.st_mode);
     }