GCC Code Coverage Report


Directory: cvmfs/
File: cvmfs/swissknife_scrub.h
Date: 2026-04-26 02:35:59
Exec Total Coverage
Lines: 0 3 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_SCRUB_H_
6 #define CVMFS_SWISSKNIFE_SCRUB_H_
7
8 #include <cassert>
9 #include <string>
10
11 #include "ingestion/pipeline.h"
12 #include "swissknife.h"
13
14 namespace swissknife {
15
16 class CommandScrub : public Command {
17 public:
18 CommandScrub();
19 ~CommandScrub();
20 virtual std::string GetName() const { return "scrub"; }
21 virtual std::string GetDescription() const {
22 return "CernVM File System repository file storage checker. Finds silent "
23 "disk corruptions by recomputing all file content checksums in the "
24 "backend file storage.";
25 }
26 virtual ParameterList GetParams() const;
27 int Main(const ArgumentList &args);
28
29
30 protected:
31 struct Alerts {
32 enum Type {
33 kUnexpectedFile = 1,
34 kUnexpectedSymlink,
35 kUnexpectedSubdir,
36 kUnexpectedModifier,
37 kMalformedHash,
38 kMalformedCasSubdir,
39 kContentHashMismatch,
40 kNumberOfErrorTypes // This should _always_ stay the last entry!
41 };
42
43 static const char *ToString(const Type t);
44 };
45
46 void FileCallback(const std::string &relative_path,
47 const std::string &file_name);
48 void DirCallback(const std::string &relative_path,
49 const std::string &dir_name);
50 void SymlinkCallback(const std::string &relative_path,
51 const std::string &symlink_name);
52
53 void OnFileHashed(const ScrubbingResult &scrubbing_result);
54
55 void PrintAlert(const Alerts::Type type,
56 const std::string &path,
57 const std::string &affected_hash = "") const;
58 void ShowAlertsHelpMessage() const;
59
60 private:
61 std::string CheckPathAndExtractHash(const std::string &relative_path,
62 const std::string &file_name,
63 const std::string &full_path) const;
64 bool CheckHashString(const std::string &hash_string,
65 const std::string &full_path) const;
66
67 std::string MakeFullPath(const std::string &relative_path,
68 const std::string &file_name) const;
69 std::string MakeRelativePath(const std::string &full_path);
70
71 ScrubbingPipeline pipeline_scrubbing_;
72 std::string repo_path_;
73 bool machine_readable_output_;
74
75 mutable unsigned int alerts_;
76 mutable pthread_mutex_t alerts_mutex_;
77 };
78
79 } // namespace swissknife
80
81 #endif // CVMFS_SWISSKNIFE_SCRUB_H_
82