/usr/include/snapper/Snapper.h is in libsnapper-dev 0.5.4-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | /*
* Copyright (c) [2011-2015] Novell, Inc.
* Copyright (c) 2016 SUSE LLC
*
* All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, contact Novell, Inc.
*
* To contact Novell about this file by physical or electronic mail, you may
* find current contact information at www.novell.com.
*/
#ifndef SNAPPER_SNAPPER_H
#define SNAPPER_SNAPPER_H
#include <vector>
#include <boost/noncopyable.hpp>
#include "snapper/Snapshot.h"
#include "snapper/AsciiFile.h"
namespace snapper
{
using std::vector;
class Filesystem;
class SDir;
class SelinuxLabelHandle;
class ConfigInfo : public SysconfigFile
{
public:
explicit ConfigInfo(const string& config_name, const string& root_prefix);
const string& getConfigName() const { return config_name; }
const string& getSubvolume() const { return subvolume; }
virtual void checkKey(const string& key) const;
private:
const string config_name;
string subvolume;
};
struct ConfigNotFoundException : public Exception
{
explicit ConfigNotFoundException() : Exception("config not found") {}
};
struct InvalidConfigException : public Exception
{
explicit InvalidConfigException() : Exception("invalid config") {}
};
struct InvalidConfigdataException : public Exception
{
explicit InvalidConfigdataException() : Exception("invalid configdata") {}
};
struct InvalidUserdataException : public Exception
{
explicit InvalidUserdataException() : Exception("invalid userdata") {}
};
struct ListConfigsFailedException : public Exception
{
explicit ListConfigsFailedException(const char* msg) : Exception(msg) {}
};
struct CreateConfigFailedException : public Exception
{
explicit CreateConfigFailedException(const char* msg) : Exception(msg) {}
};
struct DeleteConfigFailedException : public Exception
{
explicit DeleteConfigFailedException(const char* msg) : Exception(msg) {}
};
struct QuotaException : public Exception
{
explicit QuotaException(const char* msg) : Exception(msg) {}
};
struct QuotaData
{
uint64_t size;
uint64_t used;
};
class Snapper : private boost::noncopyable
{
public:
Snapper(const string& config_name, const string& root_prefix, bool disable_filters = false);
~Snapper();
const string& configName() const { return config_info->getConfigName(); }
string subvolumeDir() const;
SDir openSubvolumeDir() const;
SDir openInfosDir() const;
Snapshots& getSnapshots() { return snapshots; }
const Snapshots& getSnapshots() const { return snapshots; }
Snapshots::const_iterator getSnapshotCurrent() const;
Snapshots::iterator createSingleSnapshot(const SCD& scd);
Snapshots::iterator createSingleSnapshot(Snapshots::const_iterator parent, const SCD& scd);
Snapshots::iterator createSingleSnapshotOfDefault(const SCD& scd);
Snapshots::iterator createPreSnapshot(const SCD& scd);
Snapshots::iterator createPostSnapshot(Snapshots::const_iterator pre, const SCD& scd);
void modifySnapshot(Snapshots::iterator snapshot, const SMD& smd);
void deleteSnapshot(Snapshots::iterator snapshot);
const vector<string>& getIgnorePatterns() const { return ignore_patterns; }
static ConfigInfo getConfig(const string& config_name, const string& root_prefix);
static list<ConfigInfo> getConfigs(const string& root_prefix);
static void createConfig(const string& config_name, const string& root_prefix,
const string& subvolume, const string& fstype,
const string& template_name);
static void deleteConfig(const string& config_name, const string& root_prefix);
static bool detectFstype(const string& subvolume, string& fstype);
const Filesystem* getFilesystem() const { return filesystem; }
const ConfigInfo& getConfigInfo() { return *config_info; }
void setConfigInfo(const map<string, string>& raw);
void syncAcl() const;
void syncFilesystem() const;
void setupQuota();
void prepareQuota() const;
QuotaData queryQuotaData() const;
static const char* compileVersion();
static const char* compileFlags();
static vector<string> debug();
private:
void filter1(list<Snapshots::iterator>& tmp, time_t min_age);
void filter2(list<Snapshots::iterator>& tmp);
void loadIgnorePatterns();
void syncAcl(const vector<uid_t>& uids, const vector<gid_t>& gids) const;
void syncSelinuxContexts(bool skip_snapshot_dir) const;
void syncSelinuxContextsInInfosDir(bool skip_snapshot_dir) const;
void syncInfoDir(SDir& dir) const;
ConfigInfo* config_info;
Filesystem* filesystem;
vector<string> ignore_patterns;
Snapshots snapshots;
SelinuxLabelHandle* selabel_handle;
};
}
#endif
|