CernVM-FS  2.9.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 
34  std::string name(".cvmfscatalog");
36  dirent.linkcount_ = 1;
37  dirent.mode_ =
38  S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH;
39  dirent.uid_ = getuid();
40  dirent.gid_ = getgid();
41  dirent.size_ = 0;
42  dirent.mtime_ = time(NULL);
43  dirent.checksum_ = this->GetContentHash();
44  dirent.is_external_file_ = false;
46 
47  dirent.name_.Assign(name.data(), name.length());
48 
49  return dirent;
50  }
51 
53  return new StringIngestionSource("", GetUnionPath());
54  }
55 
56  void StatScratch(const bool refresh) const { return; }
57 
59 
60  void MakePlaceholderDirectory() const {}
61 };
62 
63 /*
64  * This class represents dummy directories that we know are going to be there
65  * but we still haven't found yet. This is possible in the extraction of
66  * tarball, where the files are not extracted in order (root to leaves) but in a
67  * random fashion.
68  */
70  friend class SyncUnionTarball;
71 
72  public:
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  }
91 
92  private:
93  static const mode_t kPermision = S_IFDIR | S_IRUSR | S_IWUSR | S_IXUSR |
94  S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
95 };
96 
99 
101 
102  dirent.linkcount_ = 1;
103 
104  dirent.mode_ = kPermision;
105 
106  dirent.uid_ = scratch_stat_.stat.st_uid;
107  dirent.gid_ = scratch_stat_.stat.st_gid;
108  dirent.size_ = 4096;
109  dirent.mtime_ = time(NULL);
110  dirent.checksum_ = this->GetContentHash();
111  dirent.is_external_file_ = this->IsExternalData();
113 
114  dirent.name_.Assign(this->filename().data(), this->filename().length());
115 
116  assert(dirent.IsDirectory());
117 
118  return dirent;
119 }
120 
121 
123  return kItemDir;
124 }
125 
126 } // namespace publish
127 
128 #endif // CVMFS_SYNC_ITEM_DUMMY_H_
SyncItemType GetScratchFiletype() const
void StatScratch(const bool refresh) const
bool IsDirectory() const
shash::Any GetContentHash() const
Definition: sync_item.h:115
SyncItemType rdonly_type_
Definition: sync_item.h:262
inode_t inode_
IngestionSource * CreateIngestionSource() const
catalog::DirectoryEntryBase CreateBasicCatalogDirent() 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:53
gid_t gid_
SyncItemType GetScratchFiletype() const
assert((mem||(size==0))&&"Out Of Memory")
static const mode_t kPermision
void MakePlaceholderDirectory() const
uint64_t size_
NameString name_
platform_stat64 stat
Definition: sync_item.h:253
zlib::Algorithms compression_algorithm_
std::string GetUnionPath() const
Definition: sync_item.cc:249
SyncItemDummyCatalog(const std::string &relative_parent_path, const SyncUnion *union_engine)
uint32_t linkcount_
bool is_external_file_
zlib::Algorithms GetCompressionAlgorithm() const
Definition: sync_item.h:121
std::string relative_parent_path() const
Definition: sync_item.h:169
time_t mtime_
static const inode_t kInvalidInode
bool IsType(const SyncItemType expected_type) const
EntryStat scratch_stat_
Definition: sync_item.h:263
unsigned int mode_
virtual void MakePlaceholderDirectory() const
SyncItemType
Definition: sync_item.h:29
catalog::DirectoryEntryBase CreateBasicCatalogDirent() const
shash::Any checksum_
std::string filename() const
Definition: sync_item.h:168
bool IsExternalData() const
Definition: sync_item.h:81
bool obtained
Definition: sync_item.h:251
uid_t uid_