}
+list<pair<string, string> >
+enum_configs(DBus::Connection* conn)
+{
+ list<pair<string, string> > configs;
+
+ if (no_dbus)
+ {
+ list<ConfigInfo> config_infos = Snapper::getConfigs();
+ for (list<ConfigInfo>::const_iterator it = config_infos.begin(); it != config_infos.end(); ++it)
+ {
+ configs.push_back(make_pair(it->getConfigName(), it->getSubvolume()));
+ }
+ }
+ else
+ {
+ list<XConfigInfo> config_infos = command_list_xconfigs(*conn);
+ for (list<XConfigInfo>::const_iterator it = config_infos.begin(); it != config_infos.end(); ++it)
+ {
+ configs.push_back(make_pair(it->config_name, it->subvolume));
+ }
+ }
+
+ return configs;
+}
+
+
void
command_list_configs(DBus::Connection* conn, Snapper* snapper)
{
<< endl
<< _(" Options for 'list' command:") << endl
<< _("\t--type, -t <type>\t\tType of snapshots to list.") << endl
+ << _("\t--all-configs, -a\t\tList snapshots from all accessible configs.") << endl
<< endl;
}
+enum ListMode { LM_ALL, LM_SINGLE, LM_PRE_POST };
+
+void list_from_one_config(DBus::Connection* conn, Snapper* snapper, string config_name, ListMode list_mode);
void
command_list(DBus::Connection* conn, Snapper* snapper)
{
const struct option options[] = {
{ "type", required_argument, 0, 't' },
+ { "all-configs", no_argument, 0, 'a' },
{ 0, 0, 0, 0 }
};
exit(EXIT_FAILURE);
}
- enum ListMode { LM_ALL, LM_SINGLE, LM_PRE_POST };
ListMode list_mode = LM_ALL;
GetOpts::parsed_opts::const_iterator opt;
}
}
+ list<pair<string, string> > configs;
+ if ((opt = opts.find("all-configs")) != opts.end())
+ {
+ configs = enum_configs(conn);
+ }
+ else
+ {
+ configs.push_back(make_pair(config_name, ""));
+ }
+
+ for (list<pair<string,string> >::iterator it = configs.begin(); it != configs.end(); ++it)
+ {
+ if (it != configs.begin())
+ cout << endl;
+
+ if (configs.size() > 1)
+ cout << "Config: " << it->first << ", subvolume: " << it->second << endl;
+ list_from_one_config(conn, snapper, it->first, list_mode);
+ }
+}
+
+void list_from_one_config(DBus::Connection* conn, Snapper* snapper, string config_name, ListMode list_mode)
+{
Table table;
switch (list_mode)