1 |
|
|
/** |
2 |
|
|
* This file is part of the CernVM File System. |
3 |
|
|
*/ |
4 |
|
|
|
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 "hash.h" |
13 |
|
|
#include "swissknife.h" |
14 |
|
|
|
15 |
|
|
namespace download { |
16 |
|
|
class DownloadManager; |
17 |
|
|
} |
18 |
|
|
namespace history { |
19 |
|
|
class History; |
20 |
|
|
} |
21 |
|
|
namespace manifest { |
22 |
|
|
class Manifest; |
23 |
|
|
} |
24 |
|
|
|
25 |
|
|
namespace swissknife { |
26 |
|
|
|
27 |
|
|
class CommandCheck : public Command { |
28 |
|
|
public: |
29 |
|
|
CommandCheck() |
30 |
|
|
: check_chunks_(false) |
31 |
|
|
, is_remote_(false) {} |
32 |
|
|
~CommandCheck() { } |
33 |
|
|
virtual std::string GetName() const { return "check"; } |
34 |
|
|
virtual std::string GetDescription() const { |
35 |
|
|
return "CernVM File System repository sanity checker\n" |
36 |
|
|
"This command checks the consisteny of the file catalogs of a " |
37 |
|
|
"cvmfs repository."; |
38 |
|
|
} |
39 |
|
|
virtual ParameterList GetParams() const { |
40 |
|
|
ParameterList r; |
41 |
|
|
r.push_back(Parameter::Mandatory('r', "repository directory / url")); |
42 |
|
|
r.push_back(Parameter::Optional('n', "check specific repository tag")); |
43 |
|
|
r.push_back(Parameter::Optional('t', "temp directory (default: /tmp)")); |
44 |
|
|
r.push_back(Parameter::Optional('l', "log level (0-4, default: 2)")); |
45 |
|
|
r.push_back(Parameter::Optional('s', "check subtree (nested catalog)")); |
46 |
|
|
r.push_back(Parameter::Optional('k', "public key of the repository / dir")); |
47 |
|
|
r.push_back(Parameter::Optional('z', "trusted certificates")); |
48 |
|
|
r.push_back(Parameter::Optional('N', "name of the repository")); |
49 |
|
|
r.push_back(Parameter::Optional('R', "path to reflog.chksum file")); |
50 |
|
|
r.push_back(Parameter::Switch('c', "check availability of data chunks")); |
51 |
|
|
r.push_back(Parameter::Switch('L', "follow HTTP redirects")); |
52 |
|
|
return r; |
53 |
|
|
} |
54 |
|
|
int Main(const ArgumentList &args); |
55 |
|
|
|
56 |
|
|
protected: |
57 |
|
|
bool InspectTree(const std::string &path, |
58 |
|
|
const shash::Any &catalog_hash, |
59 |
|
|
const uint64_t catalog_size, |
60 |
|
|
const bool is_nested_catalog, |
61 |
|
|
const catalog::DirectoryEntry *transition_point, |
62 |
|
|
catalog::DeltaCounters *computed_counters); |
63 |
|
|
catalog::Catalog* FetchCatalog(const std::string &path, |
64 |
|
|
const shash::Any &catalog_hash, |
65 |
|
|
const uint64_t catalog_size = 0); |
66 |
|
|
bool FindSubtreeRootCatalog(const std::string &subtree_path, |
67 |
|
|
shash::Any *root_hash, |
68 |
|
|
uint64_t *root_size); |
69 |
|
|
|
70 |
|
|
std::string DecompressPiece(const shash::Any catalog_hash); |
71 |
|
|
std::string DownloadPiece(const shash::Any catalog_hash); |
72 |
|
|
std::string FetchPath(const std::string &path); |
73 |
|
|
bool InspectReflog(const shash::Any &reflog_hash, |
74 |
|
|
manifest::Manifest *manifest); |
75 |
|
|
bool InspectHistory(history::History *history); |
76 |
|
|
bool Find(const catalog::Catalog *catalog, |
77 |
|
|
const PathString &path, |
78 |
|
|
catalog::DeltaCounters *computed_counters, |
79 |
|
|
std::set<PathString> *bind_mountpoints); |
80 |
|
|
bool Exists(const std::string &file); |
81 |
|
|
bool CompareCounters(const catalog::Counters &a, |
82 |
|
|
const catalog::Counters &b); |
83 |
|
|
bool CompareEntries(const catalog::DirectoryEntry &a, |
84 |
|
|
const catalog::DirectoryEntry &b, |
85 |
|
|
const bool compare_names, |
86 |
|
|
const bool is_transition_point = false); |
87 |
|
|
|
88 |
|
|
private: |
89 |
|
|
std::string temp_directory_; |
90 |
|
|
std::string repo_base_path_; |
91 |
|
|
bool check_chunks_; |
92 |
|
|
bool is_remote_; |
93 |
|
|
}; |
94 |
|
|
|
95 |
|
|
} // namespace swissknife |
96 |
|
|
|
97 |
|
|
#endif // CVMFS_SWISSKNIFE_CHECK_H_ |