CernVM-FS  2.12.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 "sync_item.h"
9 
10 #include <ctime>
11 #include <string>
12 
14 #include "sync_union_tarball.h"
15 
16 namespace publish {
17 
19  friend class SyncUnionTarball;
20 
21  protected:
23  const SyncUnion *union_engine)
24  : SyncItem(relative_parent_path, ".cvmfscatalog", union_engine,
25  kItemFile) {}
26 
27  public:
28  bool IsType(const SyncItemType expected_type) const {
29  return expected_type == kItemFile;
30  }
31 
33  bool /* enable_mtime_ns */) const
34  {
36  std::string name(".cvmfscatalog");
38  dirent.linkcount_ = 1;
39  dirent.mode_ =
40  S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH;
41  dirent.uid_ = getuid();
42  dirent.gid_ = getgid();
43  dirent.size_ = 0;
44  dirent.mtime_ = time(NULL);
45  dirent.checksum_ = this->GetContentHash();
46  dirent.is_external_file_ = false;
48 
49  dirent.name_.Assign(name.data(), name.length());
50 
51  return dirent;
52  }
53 
55  return new StringIngestionSource("", GetUnionPath());
56  }
57 
58  void StatScratch(const bool /* refresh */) const { return; }
59 
61 
62  void MakePlaceholderDirectory() const {}
63 };
64 
65 /*
66  * This class represents dummy directories that we know are going to be there
67  * but we still haven't found yet. This is possible in the extraction of
68  * tarball, where the files are not extracted in order (root to leaves) but in a
69  * random fashion.
70  */
72  friend class SyncUnionTarball;
73 
74  public:
76  bool enable_mtime_ns) const;
78  virtual void MakePlaceholderDirectory() const { rdonly_type_ = kItemDir; }
79 
80  protected:
82  const std::string &filename, const SyncUnion *union_engine,
83  const SyncItemType entry_type)
84  : SyncItemNative(relative_parent_path, filename, union_engine,
85  entry_type) {
86  assert(kItemDir == entry_type);
87 
88  scratch_stat_.obtained = true;
89  scratch_stat_.stat.st_mode = kPermision;
90  scratch_stat_.stat.st_nlink = 1;
91  scratch_stat_.stat.st_uid = getuid();
92  scratch_stat_.stat.st_gid = getgid();
93  }
95  const std::string &filename, const SyncUnion *union_engine,
96  const SyncItemType entry_type, uid_t uid, gid_t gid)
97  : SyncItemNative(relative_parent_path, filename, union_engine,
98  entry_type) {
99  assert(kItemDir == entry_type);
100 
101  scratch_stat_.obtained = true;
102  scratch_stat_.stat.st_mode = kPermision;
103  scratch_stat_.stat.st_nlink = 1;
104  scratch_stat_.stat.st_uid = uid;
105  scratch_stat_.stat.st_gid = gid;
106  }
107 
108  private:
109  static const mode_t kPermision = S_IFDIR | S_IRUSR | S_IWUSR | S_IXUSR |
110  S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
111 };
112 
113 } // namespace publish
114 
115 #endif // CVMFS_SYNC_ITEM_DUMMY_H_
SyncItemType GetScratchFiletype() const
catalog::DirectoryEntryBase CreateBasicCatalogDirent(bool) const
shash::Any GetContentHash() const
Definition: sync_item.h:121
SyncItemType rdonly_type_
Definition: sync_item.h:274
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:265
zlib::Algorithms compression_algorithm_
std::string GetUnionPath() const
Definition: sync_item.cc:261
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:127
std::string relative_parent_path() const
Definition: sync_item.h:181
time_t mtime_
static const inode_t kInvalidInode
bool IsType(const SyncItemType expected_type) const
EntryStat scratch_stat_
Definition: sync_item.h:275
unsigned int mode_
virtual void MakePlaceholderDirectory() const
SyncItemType
Definition: sync_item.h:29
shash::Any checksum_
std::string filename() const
Definition: sync_item.h:180
bool obtained
Definition: sync_item.h:263
uid_t uid_