| Line |
Branch |
Exec |
Source |
| 1 |
|
|
/** |
| 2 |
|
|
* This file is part of the CernVM File System |
| 3 |
|
|
*/ |
| 4 |
|
|
|
| 5 |
|
|
#define __STDC_FORMAT_MACROS |
| 6 |
|
|
|
| 7 |
|
|
#include "sync_union_aufs.h" |
| 8 |
|
|
|
| 9 |
|
|
#include <string> |
| 10 |
|
|
|
| 11 |
|
|
#include "sync_mediator.h" |
| 12 |
|
|
#include "sync_union.h" |
| 13 |
|
|
#include "util/fs_traversal.h" |
| 14 |
|
|
|
| 15 |
|
|
namespace publish { |
| 16 |
|
|
|
| 17 |
|
✗ |
SyncUnionAufs::SyncUnionAufs(SyncMediator *mediator, |
| 18 |
|
|
const std::string &rdonly_path, |
| 19 |
|
|
const std::string &union_path, |
| 20 |
|
✗ |
const std::string &scratch_path) |
| 21 |
|
✗ |
: SyncUnion(mediator, rdonly_path, union_path, scratch_path) { |
| 22 |
|
|
// Ignored filenames |
| 23 |
|
✗ |
ignore_filenames_.insert(".wh..wh..tmp"); |
| 24 |
|
✗ |
ignore_filenames_.insert(".wh..wh.plnk"); |
| 25 |
|
✗ |
ignore_filenames_.insert(".wh..wh.aufs"); |
| 26 |
|
✗ |
ignore_filenames_.insert(".wh..wh.orph"); |
| 27 |
|
✗ |
ignore_filenames_.insert(".wh..wh..opq"); |
| 28 |
|
|
|
| 29 |
|
|
// set the whiteout prefix AUFS precedes for every whiteout file |
| 30 |
|
✗ |
whiteout_prefix_ = ".wh."; |
| 31 |
|
|
} |
| 32 |
|
|
|
| 33 |
|
✗ |
void SyncUnionAufs::Traverse() { |
| 34 |
|
✗ |
assert(this->IsInitialized()); |
| 35 |
|
|
|
| 36 |
|
✗ |
FileSystemTraversal<SyncUnionAufs> traversal(this, scratch_path(), true); |
| 37 |
|
|
|
| 38 |
|
✗ |
traversal.fn_enter_dir = &SyncUnionAufs::EnterDirectory; |
| 39 |
|
✗ |
traversal.fn_leave_dir = &SyncUnionAufs::LeaveDirectory; |
| 40 |
|
✗ |
traversal.fn_new_file = &SyncUnionAufs::ProcessRegularFile; |
| 41 |
|
✗ |
traversal.fn_ignore_file = &SyncUnionAufs::IgnoreFilePredicate; |
| 42 |
|
✗ |
traversal.fn_new_dir_prefix = &SyncUnionAufs::ProcessDirectory; |
| 43 |
|
✗ |
traversal.fn_new_symlink = &SyncUnionAufs::ProcessSymlink; |
| 44 |
|
✗ |
traversal.fn_new_character_dev = &SyncUnionAufs::ProcessCharacterDevice; |
| 45 |
|
✗ |
traversal.fn_new_block_dev = &SyncUnionAufs::ProcessBlockDevice; |
| 46 |
|
✗ |
traversal.fn_new_fifo = &SyncUnionAufs::ProcessFifo; |
| 47 |
|
✗ |
traversal.fn_new_socket = &SyncUnionAufs::ProcessSocket; |
| 48 |
|
✗ |
LogCvmfs(kLogUnionFs, kLogVerboseMsg, |
| 49 |
|
|
"Aufs starting traversal " |
| 50 |
|
|
"recursion for scratch_path=[%s] with external data set to %d", |
| 51 |
|
✗ |
scratch_path().c_str(), mediator_->IsExternalData()); |
| 52 |
|
|
|
| 53 |
|
✗ |
traversal.Recurse(scratch_path()); |
| 54 |
|
|
} |
| 55 |
|
|
|
| 56 |
|
✗ |
bool SyncUnionAufs::IsWhiteoutEntry(SharedPtr<SyncItem> entry) const { |
| 57 |
|
✗ |
return entry->filename().substr(0, whiteout_prefix_.length()) |
| 58 |
|
✗ |
== whiteout_prefix_; |
| 59 |
|
|
} |
| 60 |
|
|
|
| 61 |
|
✗ |
bool SyncUnionAufs::IsOpaqueDirectory(SharedPtr<SyncItem> directory) const { |
| 62 |
|
✗ |
return FileExists(directory->GetScratchPath() + "/.wh..wh..opq"); |
| 63 |
|
|
} |
| 64 |
|
|
|
| 65 |
|
✗ |
string SyncUnionAufs::UnwindWhiteoutFilename(SharedPtr<SyncItem> entry) const { |
| 66 |
|
✗ |
const std::string &filename = entry->filename(); |
| 67 |
|
✗ |
return filename.substr(whiteout_prefix_.length()); |
| 68 |
|
|
} |
| 69 |
|
|
|
| 70 |
|
✗ |
bool SyncUnionAufs::IgnoreFilePredicate(const string &parent_dir, |
| 71 |
|
|
const string &filename) { |
| 72 |
|
✗ |
return SyncUnion::IgnoreFilePredicate(parent_dir, filename) |
| 73 |
|
✗ |
|| (ignore_filenames_.find(filename) != ignore_filenames_.end()); |
| 74 |
|
|
} |
| 75 |
|
|
} // namespace publish |
| 76 |
|
|
|