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
{
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;
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());