From: Arvin Schnell Date: Wed, 3 Aug 2011 09:07:06 +0000 (+0200) Subject: - work on ext4 code X-Git-Tag: v0.1.3~323 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=d7f9ee2a104e10ad29c07f17df9288616fcedb4e;p=thirdparty%2Fsnapper.git - work on ext4 code --- diff --git a/snapper/Filesystem.cc b/snapper/Filesystem.cc index 5efa1e28..6f96ce90 100644 --- a/snapper/Filesystem.cc +++ b/snapper/Filesystem.cc @@ -179,8 +179,6 @@ namespace snapper SystemCmd cmd(CHSNAPBIN " -S " + quote(snapshotFile(num))); if (cmd.retcode() != 0) throw DeleteSnapshotFailedException(); - - // TODO } @@ -212,6 +210,8 @@ namespace snapper SystemCmd cmd2(CHSNAPBIN " -n " + quote(snapshotFile(num))); if (cmd2.retcode() != 0) throw UmountSnapshotFailedException(); + + rmdir(snapshotDir(num).c_str()); } diff --git a/snapper/Snapshot.cc b/snapper/Snapshot.cc index b16e9a33..1ea20b78 100644 --- a/snapper/Snapshot.cc +++ b/snapper/Snapshot.cc @@ -274,15 +274,21 @@ namespace snapper unsigned int Snapshots::nextNumber() { - unsigned int num = entries.empty() ? 1 : entries.rbegin()->num + 1; + unsigned int num = entries.empty() ? 0 : entries.rbegin()->num; - int r; - while ((r = mkdir((snapper->infosDir() + "/" + decString(num)).c_str(), 0777)) == -1 && - errno == EEXIST) + while (true) + { ++num; - if (r != 0) - { + if (snapper->getFilesystem()->checkFilesystemSnapshot(num)) + continue; + + if (mkdir((snapper->infosDir() + "/" + decString(num)).c_str(), 0777) == 0) + break; + + if (errno == EEXIST) + continue; + y2err("mkdir failed errno:" << errno << " (" << strerror(errno) << ")"); throw IOErrorException(); } @@ -322,6 +328,9 @@ namespace snapper void Snapshot::mountFilesystemSnapshot() const { + if (isCurrent()) + return; // TODO? + snapper->getFilesystem()->mountFilesystemSnapshot(num); } @@ -329,6 +338,9 @@ namespace snapper void Snapshot::umountFilesystemSnapshot() const { + if (isCurrent()) + return; // TODO? + snapper->getFilesystem()->umountFilesystemSnapshot(num); }