]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- implement isDefault method for Btrfs class
authorAleksey Novikov <shader@yandex.ru>
Wed, 18 May 2016 12:12:12 +0000 (15:12 +0300)
committerAleksey Novikov <shader@yandex.ru>
Wed, 18 May 2016 12:12:12 +0000 (15:12 +0300)
snapper/Btrfs.cc
snapper/Btrfs.h

index 8414b723c9c108a95d1b28b83485b7ff0c62ab3d..dea0a2a3aae5fec234f169adb56ec59ac6ec60eb 100644 (file)
@@ -1398,6 +1398,33 @@ namespace snapper
 
 #ifdef ENABLE_ROLLBACK
 
+    bool
+    Btrfs::isDefault(unsigned int num) const
+    {
+       bool ret = false;
+
+       try
+       {
+           SDir subvolume_dir = openSubvolumeDir();
+           subvolid_t id = get_default_id(subvolume_dir.fd());
+           if (num == 0)
+           {
+               ret = get_id(subvolume_dir.fd()) == id;
+           }
+           else
+           {
+               ret = get_id(openSnapshotDir(num).fd()) == id;
+           }
+       }
+       catch (const runtime_error& e)
+       {
+           SN_THROW(IOErrorException(string("get default failed, ") + e.what()));
+       }
+
+       return ret;
+    }
+
+
     void
     Btrfs::setDefault(unsigned int num) const
     {
@@ -1426,6 +1453,13 @@ namespace snapper
 
 #else
 
+    bool
+    Btrfs::isDefault(unsigned int num) const
+    {
+       throw std::logic_error("not implemented");
+    }
+
+
     void
     Btrfs::setDefault(unsigned int num) const
     {
index 4a99a96a1a17c121b6c27e0930c1155519c1035b..9f0b90142c5683162d981e78c378a532a7e3b343 100644 (file)
@@ -75,6 +75,7 @@ namespace snapper
 
        virtual void cmpDirs(const SDir& dir1, const SDir& dir2, cmpdirs_cb_t cb) const;
 
+       virtual bool isDefault(unsigned int num) const;
        virtual void setDefault(unsigned int num) const;
 
        virtual void sync() const;