From: Arvin Schnell Date: Sun, 31 Jul 2011 11:56:59 +0000 (+0200) Subject: - added FSTYPE entry to configuration file X-Git-Tag: v0.1.3~331 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=ba02fa1f31228f360d4d92732a2ef4172c5042e0;p=thirdparty%2Fsnapper.git - added FSTYPE entry to configuration file --- diff --git a/data/default-config b/data/default-config index ee6c2f56..bcb3bf9a 100644 --- a/data/default-config +++ b/data/default-config @@ -2,6 +2,9 @@ # subvolume to snapshot SUBVOLUME="/" +# filesystem type +FSTYPE="btrfs" + # run daily number cleanup NUMBER_CLEANUP="yes" diff --git a/snapper/Filesystem.cc b/snapper/Filesystem.cc index 2d0825b3..c4982b13 100644 --- a/snapper/Filesystem.cc +++ b/snapper/Filesystem.cc @@ -34,6 +34,19 @@ 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 { diff --git a/snapper/Filesystem.h b/snapper/Filesystem.h index a0438192..3ed506f9 100644 --- a/snapper/Filesystem.h +++ b/snapper/Filesystem.h @@ -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; diff --git a/snapper/Snapper.cc b/snapper/Snapper.cc index ea0ac16a..5fbbe60a 100644 --- a/snapper/Snapper.cc +++ b/snapper/Snapper.cc @@ -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());