list<Snapper*> sh;
for (list<ConfigInfo>::const_iterator it = c.begin(); it != c.end(); ++it)
- sh.push_back(new Snapper(it->config_name));
+ sh.push_back(new Snapper(it->getConfigName()));
for (list<Snapper*>::const_iterator it = sh.begin(); it != sh.end(); ++it)
cout << (*it)->configName() << " " << (*it)->subvolumeDir() << " "
list<ConfigInfo> c = Snapper::getConfigs();
cout << c.size() << endl;
for (list<ConfigInfo>::const_iterator it = c.begin(); it != c.end(); ++it)
- cout << it->config_name << " " << it->subvolume << endl;
+ cout << it->getConfigName() << " " << it->getSubvolume() << endl;
if( c.begin()!=c.end() )
- sh = new Snapper(c.front().config_name);
+ sh = new Snapper(c.front().getConfigName());
if( sh )
{
/*
- * Copyright (c) 2012 Novell, Inc.
+ * Copyright (c) [2012-2013] Novell, Inc.
*
* All Rights Reserved.
*
snap2->setUserdata(userdata);
snap2->flushInfo();
- map<string, string>::const_iterator pos = it->config_info.raw.find("BACKGROUND_COMPARISON");
- if (pos == it->config_info.raw.end() || pos->second == "yes")
+ bool tmp;
+ if (it->config_info.getValue("BACKGROUND_COMPARISON", tmp) && tmp)
backgrounds.add_task(it, snap1, snap2);
DBus::MessageMethodReturn reply(msg);
/*
- * Copyright (c) 2012 Novell, Inc.
+ * Copyright (c) [2012-2013] Novell, Inc.
*
* All Rights Reserved.
*
MetaSnapper::MetaSnapper(const ConfigInfo& config_info)
: config_info(config_info), snapper(NULL)
{
- map<string, string>::const_iterator pos1 = config_info.raw.find("ALLOW_USERS");
- if (pos1 != config_info.raw.end())
+ vector<string> users;
+ if (config_info.getValue("ALLOW_USERS", users))
{
- string tmp = pos1->second;
- boost::trim(tmp, locale::classic());
- if (!tmp.empty())
+ for (vector<string>::const_iterator it = users.begin(); it != users.end(); ++it)
{
- vector<string> users;
- boost::split(users, tmp, boost::is_any_of(" \t"), boost::token_compress_on);
- for (vector<string>::const_iterator it = users.begin(); it != users.end(); ++it)
- {
- uid_t tmp;
- if (get_user_uid(it->c_str(), tmp))
- uids.push_back(tmp);
- }
+ uid_t tmp;
+ if (get_user_uid(it->c_str(), tmp))
+ uids.push_back(tmp);
}
}
- map<string, string>::const_iterator pos2 = config_info.raw.find("ALLOW_GROUPS");
- if (pos2 != config_info.raw.end())
+ vector<string> groups;
+ if (config_info.getValue("ALLOW_GROUPS", groups))
{
- string tmp = pos2->second;
- boost::trim(tmp, locale::classic());
- if (!tmp.empty())
+ for (vector<string>::const_iterator it = groups.begin(); it != groups.end(); ++it)
{
- vector<string> groups;
- boost::split(groups, tmp, boost::is_any_of(" \t"), boost::token_compress_on);
- for (vector<string>::const_iterator it = groups.begin(); it != groups.end(); ++it)
- {
- vector<uid_t> tmp;
- if (get_group_uids(it->c_str(), tmp))
- uids.insert(uids.end(), tmp.begin(), tmp.end());
- }
+ vector<uid_t> tmp;
+ if (get_group_uids(it->c_str(), tmp))
+ uids.insert(uids.end(), tmp.begin(), tmp.end());
}
}
MetaSnapper::getSnapper()
{
if (!snapper)
- snapper = new Snapper(config_info.config_name);
+ snapper = new Snapper(config_info.getConfigName());
update_use_time();
/*
- * Copyright (c) 2012 Novell, Inc.
+ * Copyright (c) [2012-2013] Novell, Inc.
*
* All Rights Reserved.
*
MetaSnapper(const ConfigInfo& config_info);
~MetaSnapper();
- const string& configName() const { return config_info.config_name; }
+ const string& configName() const { return config_info.getConfigName(); }
const ConfigInfo config_info;
/*
- * Copyright (c) 2012 Novell, Inc.
+ * Copyright (c) [2012-2013] Novell, Inc.
*
* All Rights Reserved.
*
operator<<(Hoho& hoho, const ConfigInfo& data)
{
hoho.open_struct();
- hoho << data.config_name << data.subvolume << data.raw;
+ hoho << data.getConfigName() << data.getSubvolume() << data.getAllValues();
hoho.close_struct();
return hoho;
}
Snapshot.h \
File.h \
Comparison.h \
+ AsciiFile.h \
Exception.h \
Logger.h
/*
- * Copyright (c) [2011-2012] Novell, Inc.
+ * Copyright (c) [2011-2013] Novell, Inc.
*
* All Rights Reserved.
*
using namespace std;
+ ConfigInfo::ConfigInfo(const string& config_name)
+ : SysconfigFile(CONFIGSDIR "/" + config_name), config_name(config_name), subvolume("/")
+ {
+ getValue("SUBVOLUME", subvolume);
+ }
+
+
Snapper::Snapper(const string& config_name, bool disable_filters)
: config_name(config_name), config(NULL), subvolume("/"), filesystem(NULL),
snapshots(this)
ConfigInfo
Snapper::getConfig(const string& config_name)
{
- SysconfigFile config(CONFIGSDIR "/" + config_name);
-
- string subvolume = "/";
- config.getValue("SUBVOLUME", subvolume);
-
- map<string, string> raw = config.getAllValues();
-
- return ConfigInfo(config_name, subvolume, raw);
+ return ConfigInfo(config_name);
}
list<ConfigInfo> configs = getConfigs();
for (list<ConfigInfo>::const_iterator it = configs.begin(); it != configs.end(); ++it)
{
- if (it->subvolume == subvolume)
+ if (it->getSubvolume() == subvolume)
{
throw CreateConfigFailedException("subvolume already covered");
}
/*
- * Copyright (c) [2011-2012] Novell, Inc.
+ * Copyright (c) [2011-2013] Novell, Inc.
*
* All Rights Reserved.
*
#include <boost/noncopyable.hpp>
#include "snapper/Snapshot.h"
+#include "snapper/AsciiFile.h"
namespace snapper
using std::vector;
- class SysconfigFile;
class Filesystem;
class SDir;
- struct ConfigInfo
+ struct ConfigInfo : public SysconfigFile
{
- ConfigInfo(const string& config_name, const string& subvolume,
- const map<string, string>& raw)
- : config_name(config_name), subvolume(subvolume), raw(raw) {}
+ explicit ConfigInfo(const string& config_name);
+
+ const string& getConfigName() const { return config_name; }
+ const string& getSubvolume() const { return subvolume; }
+
+ private:
+
+ const string config_name;
- string config_name;
string subvolume;
- map<string, string> raw;
};