8 #if !defined(__APPLE__)
9 #include <sys/sysmacros.h>
25 SyncItem::SyncItem() :
32 masked_hardlink_(false),
33 has_catalog_marker_(false),
35 graft_marker_present_(false),
36 external_data_(false),
38 graft_chunklist_(NULL),
40 has_compression_algorithm_(false) {}
43 const std::string &filename,
48 scratch_type_(entry_type),
50 union_engine_(union_engine),
53 masked_hardlink_(false),
54 has_catalog_marker_(false),
56 graft_marker_present_(false),
57 external_data_(false),
59 relative_parent_path_(relative_parent_path),
60 graft_chunklist_(NULL),
62 has_compression_algorithm_(false) {
76 "[WARNING] '%s' has an unsupported file type (st_mode: %d errno: %d)",
101 PANIC(
kLogStderr,
"[WARNING] Failed to stat() '%s' in scratch. (errno: %s)",
116 if (
filename().substr(0, 12) ==
".cvmfsgraft-") {
146 "' should be deleted, but was not found in repository.");
196 const bool refresh) {
197 if (info->
obtained && !refresh)
return;
205 bool enable_mtime_ns)
const
230 char slnk[PATH_MAX+1];
231 const ssize_t length =
232 readlink((this->
GetUnionPath()).c_str(), slnk, PATH_MAX);
241 if (enable_mtime_ns) {
308 bool found_checksum =
false;
309 std::string checksum_type;
310 std::string checksum_value;
314 FILE *fp = fopen(graftfile.c_str(),
"r");
319 if ((errno != ENOENT) && (errno != ENOTDIR)) {
321 "(%s): %s (errno=%d)",
322 graftfile.c_str(), strerror(errno), errno);
329 std::vector<std::string> contents;
331 std::vector<off_t> chunk_offsets;
332 std::vector<shash::Any> chunk_checksums;
335 std::string trimmed_line =
Trim(line);
337 if (!trimmed_line.size()) {
continue;}
338 if (trimmed_line[0] ==
'#') {
continue;}
342 if (info.size() != 2) {
344 trimmed_line.c_str());
346 info[0] =
Trim(info[0]);
347 info[1] =
Trim(info[1]);
348 if (info[0] ==
"size") {
352 "to integer: %s (errno=%d)", trimmed_line.c_str(),
353 strerror(errno), errno);
357 }
else if (info[0] ==
"checksum") {
358 std::string hash_str = info[1];
362 found_checksum =
true;
368 }
else if (info[0] ==
"chunk_offsets") {
369 std::vector<std::string> offsets =
SplitString(info[1],
',');
370 for (std::vector<std::string>::const_iterator it = offsets.begin();
371 it != offsets.end(); it++)
380 chunk_offsets.push_back(val);
382 }
else if (info[0] ==
"chunk_checksums") {
383 std::vector<std::string> csums =
SplitString(info[1],
',');
384 for (std::vector<std::string>::const_iterator it = csums.begin();
385 it != csums.end(); it++)
392 "value: %s.", it->c_str());
397 }
else if (info[0] ==
"compression") {
403 "marker (%s): %s (errno=%d)",
404 graftfile.c_str(), strerror(errno), errno);
408 && (chunk_checksums.size() == chunk_offsets.size());
415 off_t last_offset = chunk_offsets[0];
416 if (last_offset != 0) {
418 " (in graft marker %s).", graftfile.c_str());
421 for (
unsigned idx = 1; idx < chunk_offsets.size(); idx++) {
422 off_t cur_offset = chunk_offsets[idx];
423 if (last_offset >= cur_offset) {
425 "in strictly increasing order (in graft marker %s).",
430 size_t cur_size = cur_offset - last_offset;
434 last_offset = cur_offset;
438 "less than total file size (in graft marker %s).",
SyncItemType GetGenericFiletype(const EntryStat &stat) const
Algorithms ParseCompressionAlgorithm(const std::string &algorithm_option)
unsigned int GetRdevMinor() const
shash::Any GetContentHash() const
SyncItemType rdonly_type_
string Trim(const string &raw, bool trim_newline)
unsigned int GetRdevMajor() const
void Assign(const char *chars, const unsigned length)
virtual catalog::DirectoryEntryBase CreateBasicCatalogDirent(bool enable_mtime_ns) const
const SyncUnion * union_engine_
std::string relative_parent_path_
std::string scratch_path() const
bool IsBlockDevice() const
bool IsCharacterDevice() const
assert((mem||(size==0))&&"Out Of Memory")
SyncItemType GetUnionFiletype() const
uint64_t GetUnionInode() const
void CheckCatalogMarker()
SyncItemType scratch_type_
bool String2Uint64Parse(const std::string &value, uint64_t *result)
uint64_t GetRdOnlyInode() const
virtual bool IsType(const SyncItemType expected_type) const
zlib::Algorithms compression_algorithm_
bool GetLineFile(FILE *f, std::string *line)
BigVector< FileChunk > FileChunkList
std::string union_path() const
vector< string > SplitString(const string &str, char delim)
uint64_t GetScratchSize() const
bool IsRegularFile() const
platform_stat64 GetUnionStat() const
std::string GetUnionPath() const
std::string GetRdOnlyPath() const
void StatRdOnly(const bool refresh=false) const
zlib::Algorithms GetCompressionAlgorithm() const
std::string GetScratchPath() const
vector< string > SplitStringBounded(unsigned max_chunks, const string &str, char delim)
static const inode_t kInvalidInode
void SetCompressionAlgorithm(const zlib::Algorithms &alg)
FileChunkList * graft_chunklist_
void PrintWarning(const string &message)
unsigned int GetRdOnlyLinkcount() const
virtual SyncItemType GetScratchFiletype() const
void PushBack(const Item &item)
void MarkAsOpaqueDirectory()
virtual void StatScratch(const bool refresh) const =0
static void StatGeneric(const std::string &path, EntryStat *info, const bool refresh)
Any MkFromHexPtr(const HexPtr hex, const char suffix)
std::string GetGraftMarkerPath() const
virtual void StatScratch(const bool refresh) const
virtual IngestionSource * CreateIngestionSource() const
void MarkAsWhiteout(const std::string &actual_filename)
unsigned int GetUnionLinkcount() const
bool graft_marker_present_
std::string filename() const
bool IsExternalData() const
SyncItemType GetSyncItemType() const
std::string rdonly_path() const
void StatUnion(const bool refresh=false) const
std::string GetRelativePath() const
uint64_t GetRdOnlySize() const
bool HasHardlinks() const
SyncItemType GetRdOnlyFiletype() const
CVMFS_EXPORT void LogCvmfs(const LogSource source, const int mask, const char *format,...)