#include <snapper/Snapper.h>
#include <snapper/AppUtil.h>
#include <snapper/SnapperTmpl.h>
+#include <snapper/Files.h>
using namespace snapper;
using namespace std;
++s;
}
y2mil( "n1:" << n1 << " n2:" << n2 );
- Snapshot sn;
- bool ok = true;
- if( n1>0 && !getSnapshot( n1, sn ))
- {
- cerr << "No snapshot with number " << n1 << endl;
- ok = false;
- }
- if( n2>0 && !getSnapshot( n2, sn ))
- {
- cerr << "No snapshot with number " << n2 << endl;
- ok = false;
- }
- if( ok )
- {
- string p1 = (n1==0) ? "/" : "/snapshots/" + decString(n1);
- string p2 = (n2==0) ? "/" : "/snapshots/" + decString(n2);
- y2mil( "p1:" << p1 << " p2:" << p2 );
- }
+
+ setComparisonNums(n1, n2);
+ const list<string>& files = getFiles();
+ for (list<string>::const_iterator it = files.begin(); it != files.end(); ++it)
+ cout << statusToString(getStatus(*it, CMP_PRE_TO_POST)) << " " << *it << endl;
}
int
cmpDirs(const string& path1, const string& path2, void(*cb)(const string& name,
unsigned int status))
{
+ y2mil("path1:" << path1 << " path2:" << path2);
cmpDirsWorker(path1, path2, "", cb);
}
#include "snapper/SnapperTmpl.h"
#include "snapper/SystemCmd.h"
#include "snapper/SnapperDefines.h"
+#include "snapper/Files.h"
namespace snapper
list<Snapshot> snapshots;
- Snapshot& snapshot1;
- Snapshot& snapshot2;
+ Snapshot snapshot1;
+ Snapshot snapshot2;
+
+
+ bool files_loaded = false;
+
+ list<string> files;
+
+ map<string, unsigned int> pre_to_post_status;
+ map<string, unsigned int> pre_to_system_status;
+ map<string, unsigned int> post_to_system_status;
std::ostream& operator<<(std::ostream& s, const Snapshot& x)
}
-
bool
setComparisonNums(unsigned int num1, unsigned int num2)
{
if (snapshot1.num != snapshot2.pre_num)
return false;
- // load or generate file list
-
return true;
}
+
+ void
+ log(const string& file, unsigned int status)
+ {
+ files.push_back(file);
+ pre_to_post_status[file] = status;
+ }
+
+
+ void
+ compareBtrfsSnapshots()
+ {
+ string dir1 = SNAPSHOTSDIR "/" + decString(snapshot1.num) + "/snapshot";
+ string dir2 = SNAPSHOTSDIR "/" + decString(snapshot2.num) + "/snapshot";
+
+ files.clear();
+ pre_to_post_status.clear();
+
+ cmpDirs(dir1, dir2, log);
+ }
+
+
+ const list<string>&
+ getFiles()
+ {
+ if (!files_loaded)
+ {
+ compareBtrfsSnapshots();
+
+ files_loaded = true;
+ }
+
+ return files;
+ }
+
+
+ unsigned int
+ getStatus(const string& file, Cmp cmp)
+ {
+ return pre_to_post_status[file];
+ }
+
}
extern list<Snapshot> snapshots;
- extern Snapshot& snapshot1;
- extern Snapshot& snapshot2;
+ extern Snapshot snapshot1;
+ extern Snapshot snapshot2;
extern list<string> files;
-
- struct Statuses
- {
- unsigned int pre_to_post;
- unsigned int pre_to_system;
- unsigned int post_to_system;
- };
-
- extern map<string, Statuses> statuses;
+ extern map<string, unsigned int> pre_to_post_status;
+ extern map<string, unsigned int> pre_to_system_status;
+ extern map<string, unsigned int> post_to_system_status;
extern list<string> files_to_rollback;