]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- work on ext4 code
authorArvin Schnell <aschnell@suse.de>
Wed, 3 Aug 2011 09:07:06 +0000 (11:07 +0200)
committerArvin Schnell <aschnell@suse.de>
Wed, 3 Aug 2011 09:07:06 +0000 (11:07 +0200)
snapper/Filesystem.cc
snapper/Snapshot.cc

index 5efa1e28bf32f324dd1e436e28ead756a5ebad08..6f96ce90fe508b6ef3fcc8af581fe4faaf3484bd 100644 (file)
@@ -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());
     }
 
 
index b16e9a338e575acc1192bbc38b5177710f0c983b..1ea20b786bf755204c5cdb38aff3f769403142e9 100644 (file)
@@ -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);
     }