GCC Code Coverage Report


Directory: cvmfs/
File: cvmfs/swissknife_check.h
Date: 2026-06-28 02:36:10
Exec Total Coverage
Lines: 0 21 0.0%
Branches: 0 0 -%

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