1 |
|
|
/** |
2 |
|
|
* This file is part of the CernVM File System |
3 |
|
|
* |
4 |
|
|
* This file defines a class which derives `SyncUnion` to provide support for |
5 |
|
|
* overlayfs |
6 |
|
|
* |
7 |
|
|
*/ |
8 |
|
|
|
9 |
|
|
#ifndef CVMFS_SYNC_UNION_OVERLAYFS_H_ |
10 |
|
|
#define CVMFS_SYNC_UNION_OVERLAYFS_H_ |
11 |
|
|
|
12 |
|
|
#include "sync_union.h" |
13 |
|
|
|
14 |
|
|
#include <set> |
15 |
|
|
#include <string> |
16 |
|
|
|
17 |
|
|
#include "util/shared_ptr.h" |
18 |
|
|
|
19 |
|
|
namespace publish { |
20 |
|
|
|
21 |
|
|
/** |
22 |
|
|
* Syncing a cvmfs repository by the help of an overlayed overlayfs |
23 |
|
|
* read-write volume. |
24 |
|
|
*/ |
25 |
|
|
class SyncUnionOverlayfs : public SyncUnion { |
26 |
|
|
public: |
27 |
|
|
SyncUnionOverlayfs(SyncMediator *mediator, const std::string &rdonly_path, |
28 |
|
|
const std::string &union_path, |
29 |
|
|
const std::string &scratch_path); |
30 |
|
|
|
31 |
|
|
bool Initialize(); |
32 |
|
|
|
33 |
|
|
void Traverse(); |
34 |
|
|
static bool ReadlinkEquals(std::string const &path, |
35 |
|
|
std::string const &compare_value); |
36 |
|
|
static bool HasXattr(std::string const &path, std::string const &attr_name); |
37 |
|
|
|
38 |
|
|
protected: |
39 |
|
|
void PreprocessSyncItem(SharedPtr<SyncItem> entry) const; |
40 |
|
|
|
41 |
|
|
bool IsWhiteoutEntry(SharedPtr<SyncItem> entry) const; |
42 |
|
|
bool IsOpaqueDirectory(SharedPtr<SyncItem> directory) const; |
43 |
|
|
bool IsWhiteoutSymlinkPath(const std::string &path) const; |
44 |
|
|
|
45 |
|
|
std::string UnwindWhiteoutFilename(SharedPtr<SyncItem> entry) const; |
46 |
|
|
std::set<std::string> GetIgnoreFilenames() const; |
47 |
|
|
|
48 |
|
|
void CheckForBrokenHardlink(SharedPtr<SyncItem> entry) const; |
49 |
|
|
void MaskFileHardlinks(SharedPtr<SyncItem> entry) const; |
50 |
|
|
|
51 |
|
|
bool ObtainSysAdminCapability() const; |
52 |
|
|
|
53 |
|
|
private: |
54 |
|
|
bool IsOpaqueDirPath(const std::string &path) const; |
55 |
|
|
|
56 |
|
|
std::set<std::string> hardlink_lower_files_; |
57 |
|
|
uint64_t hardlink_lower_inode_; |
58 |
|
|
}; // class SyncUnionOverlayfs |
59 |
|
|
} // namespace publish |
60 |
|
|
|
61 |
|
|
#endif // CVMFS_SYNC_UNION_OVERLAYFS_H_ |