CernVM-FS  2.10.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sync_union_aufs.cc
Go to the documentation of this file.
1 
5 #define __STDC_FORMAT_MACROS
6 
7 #include <string>
8 
9 #include "sync_union.h"
10 #include "sync_union_aufs.h"
11 
12 #include "fs_traversal.h"
13 #include "sync_mediator.h"
14 
15 namespace publish {
16 
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 preceeds for every whiteout file
30  whiteout_prefix_ = ".wh.";
31 }
32 
34  assert(this->IsInitialized());
35 
36  FileSystemTraversal<SyncUnionAufs> traversal(this, scratch_path(), true);
37 
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 
57  return entry->filename().substr(0, whiteout_prefix_.length()) ==
59 }
60 
62  return FileExists(directory->GetScratchPath() + "/.wh..wh..opq");
63 }
64 
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
virtual void LeaveDirectory(const std::string &parent_dir, const std::string &dir_name)
Definition: sync_union.cc:141
#define LogCvmfs(source, mask,...)
Definition: logging.h:20
bool IsWhiteoutEntry(SharedPtr< SyncItem > entry) const
VoidCallback fn_new_symlink
Definition: fs_traversal.h:48
VoidCallback fn_new_character_dev
Definition: fs_traversal.h:51
void Recurse(const std::string &dir_path) const
Definition: fs_traversal.h:112
std::string scratch_path() const
Definition: sync_union.h:98
A simple recursion engine to abstract the recursion of directories. It provides several callback hook...
Definition: fs_traversal.h:37
assert((mem||(size==0))&&"Out Of Memory")
VoidCallback fn_leave_dir
Definition: fs_traversal.h:46
virtual bool IsExternalData() const =0
virtual void ProcessSymlink(const std::string &parent_dir, const std::string &link_name)
Definition: sync_union.cc:107
std::string UnwindWhiteoutFilename(SharedPtr< SyncItem > entry) const
bool FileExists(const std::string &path)
Definition: posix.cc:816
SyncUnionAufs(SyncMediator *mediator, const std::string &rdonly_path, const std::string &union_path, const std::string &scratch_path)
BoolCallback fn_ignore_file
Definition: fs_traversal.h:62
VoidCallback fn_new_file
Definition: fs_traversal.h:47
bool IsOpaqueDirectory(SharedPtr< SyncItem > directory) const
AbstractSyncMediator * mediator_
Definition: sync_union.h:147
VoidCallback fn_enter_dir
Definition: fs_traversal.h:45
bool IsInitialized() const
Definition: sync_union.h:139
void ProcessBlockDevice(const std::string &parent_dir, const std::string &filename)
Definition: sync_union.cc:157
virtual bool IgnoreFilePredicate(const std::string &parent_dir, const std::string &filename)
Definition: sync_union.cc:57
bool IgnoreFilePredicate(const std::string &parent_dir, const std::string &filename)
void ProcessSocket(const std::string &parent_dir, const std::string &filename)
Definition: sync_union.cc:175
virtual void ProcessRegularFile(const std::string &parent_dir, const std::string &filename)
Definition: sync_union.cc:99
VoidCallback fn_new_block_dev
Definition: fs_traversal.h:50
std::string whiteout_prefix_
VoidCallback fn_new_socket
Definition: fs_traversal.h:49
std::set< std::string > ignore_filenames_
BoolCallback fn_new_dir_prefix
Definition: fs_traversal.h:69
VoidCallback fn_new_fifo
Definition: fs_traversal.h:52
virtual bool ProcessDirectory(const std::string &parent_dir, const std::string &dir_name)
const int kLogVerboseMsg
virtual void EnterDirectory(const std::string &parent_dir, const std::string &dir_name)
Definition: sync_union.cc:135
void ProcessFifo(const std::string &parent_dir, const std::string &filename)
Definition: sync_union.cc:167
void ProcessCharacterDevice(const std::string &parent_dir, const std::string &filename)
Definition: sync_union.cc:147