From: Arvin Schnell Date: Wed, 12 Sep 2012 13:27:06 +0000 (+0200) Subject: - improved snapshot check functions X-Git-Tag: v0.1.3~95 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e7cec89858da814d8e5b6a223ab627d5e41e63fc;p=thirdparty%2Fsnapper.git - improved snapshot check functions --- diff --git a/snapper/AppUtil.cc b/snapper/AppUtil.cc index 232edd3c..f5d7a4d7 100644 --- a/snapper/AppUtil.cc +++ b/snapper/AppUtil.cc @@ -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 glob(const string& path, int flags) { diff --git a/snapper/AppUtil.h b/snapper/AppUtil.h index e9a88b44..056914ad 100644 --- a/snapper/AppUtil.h +++ b/snapper/AppUtil.h @@ -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 glob(const string& path, int flags); diff --git a/snapper/Filesystem.cc b/snapper/Filesystem.cc index 19d18ce0..1067b67b 100644 --- a/snapper/Filesystem.cc +++ b/snapper/Filesystem.cc @@ -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); }