CernVM-FS  2.12.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
swissknife_check.h
Go to the documentation of this file.
1 
5 #ifndef CVMFS_SWISSKNIFE_CHECK_H_
6 #define CVMFS_SWISSKNIFE_CHECK_H_
7 
8 #include <set>
9 #include <string>
10 
11 #include "catalog.h"
12 #include "crypto/hash.h"
13 #include "smallhash.h"
14 #include "swissknife.h"
15 
16 namespace download {
17 class DownloadManager;
18 }
19 namespace history {
20 class History;
21 }
22 namespace manifest {
23 class Manifest;
24 }
25 
26 
27 
28 
29 namespace swissknife {
30 
31 class CommandCheck : public Command {
32  public:
33  CommandCheck();
35  virtual std::string GetName() const { return "check"; }
36  virtual std::string GetDescription() const {
37  return "CernVM File System repository sanity checker\n"
38  "This command checks the consistency of the file catalogs of a "
39  "cvmfs repository.";
40  }
41  virtual ParameterList GetParams() const {
42  ParameterList r;
43  r.push_back(Parameter::Mandatory('r', "repository directory / url"));
44  r.push_back(Parameter::Optional('n', "check specific repository tag"));
45  r.push_back(Parameter::Optional('t', "temp directory (default: /tmp)"));
46  r.push_back(Parameter::Optional('l', "log level (0-4, default: 2)"));
47  r.push_back(Parameter::Optional('s', "check subtree (nested catalog)"));
48  r.push_back(Parameter::Optional('k', "public key of the repository / dir"));
49  r.push_back(Parameter::Optional('z', "trusted certificates"));
50  r.push_back(Parameter::Optional('N', "name of the repository"));
51  r.push_back(Parameter::Optional('R', "path to reflog.chksum file"));
52  r.push_back(Parameter::Optional('@', "proxy url"));
53  r.push_back(Parameter::Switch('c', "check availability of data chunks"));
54  r.push_back(Parameter::Switch('d', "don't use hashmap to avoid duplicated"
55  " lookups. Note that this is a fallback"
56  " option that may be removed."));
57  r.push_back(Parameter::Switch('L', "follow HTTP redirects"));
58  return r;
59  }
60  int Main(const ArgumentList &args);
61 
62  protected:
63  bool InspectTree(const std::string &path,
64  const shash::Any &catalog_hash,
65  const uint64_t catalog_size,
66  const bool is_nested_catalog,
67  const catalog::DirectoryEntry *transition_point,
68  catalog::DeltaCounters *computed_counters);
69  catalog::Catalog* FetchCatalog(const std::string &path,
70  const shash::Any &catalog_hash,
71  const uint64_t catalog_size = 0);
72  bool FindSubtreeRootCatalog(const std::string &subtree_path,
73  shash::Any *root_hash,
74  uint64_t *root_size);
75 
76  std::string DecompressPiece(const shash::Any catalog_hash);
77  std::string DownloadPiece(const shash::Any catalog_hash);
78  std::string FetchPath(const std::string &path);
79  bool InspectReflog(const shash::Any &reflog_hash,
82  bool Find(const catalog::Catalog *catalog,
83  const PathString &path,
84  catalog::DeltaCounters *computed_counters,
85  std::set<PathString> *bind_mountpoints);
86  bool Exists(const std::string &file);
87  bool CompareCounters(const catalog::Counters &a,
88  const catalog::Counters &b);
90  const catalog::DirectoryEntry &b,
91  const bool compare_names,
92  const bool is_transition_point = false);
93 
94  private:
95  std::string temp_directory_;
96  std::string repo_base_path_;
99  bool is_remote_;
101 };
102 
103 } // namespace swissknife
104 
105 #endif // CVMFS_SWISSKNIFE_CHECK_H_
static Parameter Optional(const char key, const std::string &desc)
Definition: swissknife.h:41
bool InspectHistory(history::History *history)
const manifest::Manifest * manifest() const
Definition: repository.h:125
static Parameter Switch(const char key, const std::string &desc)
Definition: swissknife.h:44
virtual ParameterList GetParams() const
std::vector< Parameter > ParameterList
Definition: swissknife.h:71
const history::History * history() const
bool CompareEntries(const catalog::DirectoryEntry &a, const catalog::DirectoryEntry &b, const bool compare_names, const bool is_transition_point=false)
catalog::Catalog * FetchCatalog(const std::string &path, const shash::Any &catalog_hash, const uint64_t catalog_size=0)
bool InspectReflog(const shash::Any &reflog_hash, manifest::Manifest *manifest)
bool Find(const catalog::Catalog *catalog, const PathString &path, catalog::DeltaCounters *computed_counters, std::set< PathString > *bind_mountpoints)
std::string DownloadPiece(const shash::Any catalog_hash)
int Main(const ArgumentList &args)
std::string DecompressPiece(const shash::Any catalog_hash)
bool Exists(const std::string &file)
static Parameter Mandatory(const char key, const std::string &desc)
Definition: swissknife.h:38
std::string FetchPath(const std::string &path)
virtual std::string GetDescription() const
SmallHashDynamic< shash::Any, char > duplicates_map_
bool FindSubtreeRootCatalog(const std::string &subtree_path, shash::Any *root_hash, uint64_t *root_size)
bool CompareCounters(const catalog::Counters &a, const catalog::Counters &b)
std::map< char, SharedPtr< std::string > > ArgumentList
Definition: swissknife.h:72
virtual std::string GetName() const
bool InspectTree(const std::string &path, const shash::Any &catalog_hash, const uint64_t catalog_size, const bool is_nested_catalog, const catalog::DirectoryEntry *transition_point, catalog::DeltaCounters *computed_counters)