| Line |
Branch |
Exec |
Source |
| 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 "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 |
|
|
namespace swissknife { |
| 28 |
|
|
|
| 29 |
|
|
class CommandCheck : public Command { |
| 30 |
|
|
public: |
| 31 |
|
|
CommandCheck(); |
| 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 consistency 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::Optional('@', "proxy url")); |
| 51 |
|
✗ |
r.push_back(Parameter::Switch('c', "check availability of data chunks")); |
| 52 |
|
✗ |
r.push_back(Parameter::Switch('d', "don't use hashmap to avoid duplicated" |
| 53 |
|
|
" lookups. Note that this is a fallback" |
| 54 |
|
|
" option that may be removed.")); |
| 55 |
|
✗ |
r.push_back(Parameter::Switch('L', "follow HTTP redirects")); |
| 56 |
|
✗ |
return r; |
| 57 |
|
|
} |
| 58 |
|
|
int Main(const ArgumentList &args); |
| 59 |
|
|
|
| 60 |
|
|
protected: |
| 61 |
|
|
bool InspectTree(const std::string &path, |
| 62 |
|
|
const shash::Any &catalog_hash, |
| 63 |
|
|
const uint64_t catalog_size, |
| 64 |
|
|
const bool is_nested_catalog, |
| 65 |
|
|
const catalog::DirectoryEntry *transition_point, |
| 66 |
|
|
catalog::DeltaCounters *computed_counters); |
| 67 |
|
|
catalog::Catalog *FetchCatalog(const std::string &path, |
| 68 |
|
|
const shash::Any &catalog_hash, |
| 69 |
|
|
const uint64_t catalog_size = 0); |
| 70 |
|
|
bool FindSubtreeRootCatalog(const std::string &subtree_path, |
| 71 |
|
|
shash::Any *root_hash, |
| 72 |
|
|
uint64_t *root_size); |
| 73 |
|
|
|
| 74 |
|
|
std::string DecompressPiece(const shash::Any catalog_hash); |
| 75 |
|
|
std::string DownloadPiece(const shash::Any catalog_hash); |
| 76 |
|
|
std::string FetchPath(const std::string &path); |
| 77 |
|
|
bool InspectReflog(const shash::Any &reflog_hash, |
| 78 |
|
|
manifest::Manifest *manifest); |
| 79 |
|
|
bool InspectHistory(history::History *history); |
| 80 |
|
|
bool Find(const catalog::Catalog *catalog, |
| 81 |
|
|
const PathString &path, |
| 82 |
|
|
catalog::DeltaCounters *computed_counters, |
| 83 |
|
|
std::set<PathString> *bind_mountpoints); |
| 84 |
|
|
bool Exists(const std::string &file); |
| 85 |
|
|
bool CompareCounters(const catalog::Counters &a, const catalog::Counters &b); |
| 86 |
|
|
bool CompareEntries(const catalog::DirectoryEntry &a, |
| 87 |
|
|
const catalog::DirectoryEntry &b, |
| 88 |
|
|
const bool compare_names, |
| 89 |
|
|
const bool is_transition_point = false); |
| 90 |
|
|
|
| 91 |
|
|
private: |
| 92 |
|
|
std::string temp_directory_; |
| 93 |
|
|
std::string repo_base_path_; |
| 94 |
|
|
bool check_chunks_; |
| 95 |
|
|
bool no_duplicates_map_; |
| 96 |
|
|
bool is_remote_; |
| 97 |
|
|
SmallHashDynamic<shash::Any, char> duplicates_map_; |
| 98 |
|
|
}; |
| 99 |
|
|
|
| 100 |
|
|
} // namespace swissknife |
| 101 |
|
|
|
| 102 |
|
|
#endif // CVMFS_SWISSKNIFE_CHECK_H_ |
| 103 |
|
|
|