]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- added FSTYPE entry to configuration file
authorArvin Schnell <aschnell@suse.de>
Sun, 31 Jul 2011 11:56:59 +0000 (13:56 +0200)
committerArvin Schnell <aschnell@suse.de>
Sun, 31 Jul 2011 11:56:59 +0000 (13:56 +0200)
data/default-config
snapper/Filesystem.cc
snapper/Filesystem.h
snapper/Snapper.cc

index ee6c2f56d2e4a26837dfed5a6970f3f87b0a0976..bcb3bf9a829cc79aedddc50bdfb2893d90dc2eb7 100644 (file)
@@ -2,6 +2,9 @@
 # subvolume to snapshot
 SUBVOLUME="/"
 
+# filesystem type
+FSTYPE="btrfs"
+
 
 # run daily number cleanup
 NUMBER_CLEANUP="yes"
index 2d0825b37e9ad172352b76eb6aee09921585b9bd..c4982b1337d0f0f97a85c696c196eef1a8adc0e9 100644 (file)
 namespace snapper
 {
 
+    Filesystem*
+    Filesystem::create(const string& fstype, const string& subvolume)
+    {
+       if (fstype == "btrfs")
+           return new Btrfs(subvolume);
+
+       if (fstype == "ext4")
+           return new Ext4(subvolume);
+
+       throw InvalidConfigException();
+    }
+
+
     void
     Btrfs::addConfig() const
     {
index a04381920dbf5c00102fb0bc54c1967cdec1d020..3ed506f990805f0883e235f3a583c26623b6dc03 100644 (file)
@@ -42,6 +42,8 @@ namespace snapper
        Filesystem(const string& subvolume) : subvolume(subvolume) {}
        virtual ~Filesystem() {}
 
+       static Filesystem* create(const string& fstype, const string& subvolume);
+
        virtual string name() const = 0;
 
        virtual void addConfig() const = 0;
index ea0ac16a034ce1bca78201472678c627e7028691..5fbbe60a89ce2a22147e06b0173985fa7e2024dd 100644 (file)
@@ -62,12 +62,12 @@ namespace snapper
            throw ConfigNotFoundException();
        }
 
-       string val;
-       if (!config->getValue("SUBVOLUME", val))
+       if (!config->getValue("SUBVOLUME", subvolume))
            throw InvalidConfigException();
-       subvolume = val;
 
-       filesystem = new Btrfs(subvolume);
+       string fstype = "btrfs";
+       config->getValue("FSTYPE", fstype);
+       filesystem = Filesystem::create(fstype, subvolume);
 
        y2mil("subvolume:" << subvolume << " filesystem:" << filesystem->name());