CernVM-FS  2.13.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sync_item_dummy.h
Go to the documentation of this file.
1 
5 #ifndef CVMFS_SYNC_ITEM_DUMMY_H_
6 #define CVMFS_SYNC_ITEM_DUMMY_H_
7 
8 #include <ctime>
9 #include <string>
10 
12 #include "sync_item.h"
13 #include "sync_union_tarball.h"
14 
15 namespace publish {
16 
18  friend class SyncUnionTarball;
19 
20  protected:
22  const SyncUnion *union_engine)
23  : SyncItem(relative_parent_path, ".cvmfscatalog", union_engine,
24  kItemFile) { }
25 
26  public:
27  bool IsType(const SyncItemType expected_type) const {
28  return expected_type == kItemFile;
29  }
30 
32  bool /* enable_mtime_ns */) const {
34  std::string name(".cvmfscatalog");
36  dirent.linkcount_ = 1;
37  dirent.mode_ = S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH;
38  dirent.uid_ = getuid();
39  dirent.gid_ = getgid();
40  dirent.size_ = 0;
41  dirent.mtime_ = time(NULL);
42  dirent.checksum_ = this->GetContentHash();
43  dirent.is_external_file_ = false;
45 
46  dirent.name_.Assign(name.data(), name.length());
47 
48  return dirent;
49  }
50 
52  return new StringIngestionSource("", GetUnionPath());
53  }
54 
55  void StatScratch(const bool /* refresh */) const { return; }
56 
58 
59  void MakePlaceholderDirectory() const { }
60 };
61 
62 /*
63  * This class represents dummy directories that we know are going to be there
64  * but we still haven't found yet. This is possible in the extraction of
65  * tarball, where the files are not extracted in order (root to leaves) but in a
66  * random fashion.
67  */
69  friend class SyncUnionTarball;
70 
71  public:
73  bool enable_mtime_ns) const;
75  virtual void MakePlaceholderDirectory() const { rdonly_type_ = kItemDir; }
76 
77  protected:
79  const std::string &filename, const SyncUnion *union_engine,
80  const SyncItemType entry_type)
81  : SyncItemNative(relative_parent_path, filename, union_engine,
82  entry_type) {
83  assert(kItemDir == entry_type);
84 
85  scratch_stat_.obtained = true;
86  scratch_stat_.stat.st_mode = kPermision;
87  scratch_stat_.stat.st_nlink = 1;
88  scratch_stat_.stat.st_uid = getuid();
89  scratch_stat_.stat.st_gid = getgid();
90  }
92  const std::string &filename, const SyncUnion *union_engine,
93  const SyncItemType entry_type, uid_t uid, gid_t gid)
94  : SyncItemNative(relative_parent_path, filename, union_engine,
95  entry_type) {
96  assert(kItemDir == entry_type);
97 
98  scratch_stat_.obtained = true;
99  scratch_stat_.stat.st_mode = kPermision;
100  scratch_stat_.stat.st_nlink = 1;
101  scratch_stat_.stat.st_uid = uid;
102  scratch_stat_.stat.st_gid = gid;
103  }
104 
105  private:
106  static const mode_t kPermision = S_IFDIR | S_IRUSR | S_IWUSR | S_IXUSR
107  | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
108 };
109 
110 } // namespace publish
111 
112 #endif // CVMFS_SYNC_ITEM_DUMMY_H_
SyncItemType GetScratchFiletype() const
catalog::DirectoryEntryBase CreateBasicCatalogDirent(bool) const
shash::Any GetContentHash() const
Definition: sync_item.h:119
SyncItemType rdonly_type_
Definition: sync_item.h:280
inode_t inode_
IngestionSource * CreateIngestionSource() const
SyncItemDummyDir(const std::string &relative_parent_path, const std::string &filename, const SyncUnion *union_engine, const SyncItemType entry_type)
void Assign(const char *chars, const unsigned length)
Definition: shortstring.h:61
gid_t gid_
SyncItemType GetScratchFiletype() const
assert((mem||(size==0))&&"Out Of Memory")
virtual catalog::DirectoryEntryBase CreateBasicCatalogDirent(bool enable_mtime_ns) const
static const mode_t kPermision
void StatScratch(const bool) const
void MakePlaceholderDirectory() const
uint64_t size_
NameString name_
platform_stat64 stat
Definition: sync_item.h:271
zlib::Algorithms compression_algorithm_
std::string GetUnionPath() const
Definition: sync_item.cc:259
SyncItemDummyCatalog(const std::string &relative_parent_path, const SyncUnion *union_engine)
uint32_t linkcount_
bool is_external_file_
SyncItemDummyDir(const std::string &relative_parent_path, const std::string &filename, const SyncUnion *union_engine, const SyncItemType entry_type, uid_t uid, gid_t gid)
zlib::Algorithms GetCompressionAlgorithm() const
Definition: sync_item.h:125
std::string relative_parent_path() const
Definition: sync_item.h:180
time_t mtime_
static const inode_t kInvalidInode
bool IsType(const SyncItemType expected_type) const
EntryStat scratch_stat_
Definition: sync_item.h:281
unsigned int mode_
virtual void MakePlaceholderDirectory() const
SyncItemType
Definition: sync_item.h:29
shash::Any checksum_
std::string filename() const
Definition: sync_item.h:179
bool obtained
Definition: sync_item.h:269
uid_t uid_