CernVM-FS  2.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
magic_xattr.h
Go to the documentation of this file.
1 
5 #ifndef CVMFS_MAGIC_XATTR_H_
6 #define CVMFS_MAGIC_XATTR_H_
7 
8 #include <map>
9 #include <string>
10 
11 #include "catalog_counters.h"
12 #include "directory_entry.h"
13 #include "shortstring.h"
14 #include "util/exception.h"
15 #include "util/string.h"
16 
17 class MountPoint;
18 
25 };
26 
40  friend class MagicXattrManager;
41 
42  public:
44  int retval = pthread_mutex_init(&access_mutex_, NULL);
45  assert(retval == 0);
46  }
51  virtual bool PrepareValueFenced() { return true; }
59  virtual std::string GetValue() = 0;
61 
62  void Lock(PathString path, catalog::DirectoryEntry *dirent) {
63  int retval = pthread_mutex_lock(&access_mutex_);
64  assert(retval == 0);
65  path_ = path;
66  dirent_ = dirent;
67  }
68  void Release() {
69  int retval = pthread_mutex_unlock(&access_mutex_);
70  assert(retval == 0);
71  }
72 
73  virtual ~BaseMagicXattr() {}
74 
75  protected:
79 
80  pthread_mutex_t access_mutex_;
81 };
82 
88  public:
89  inline MagicXattrRAIIWrapper() : ptr_(NULL) { }
90 
91  inline explicit MagicXattrRAIIWrapper(
92  BaseMagicXattr *ptr,
93  PathString path,
95  : ptr_(ptr)
96  {
97  if (ptr_ != NULL) ptr_->Lock(path, d);
98  }
100  inline explicit MagicXattrRAIIWrapper(BaseMagicXattr *ptr) : ptr_(ptr) { }
101 
102  inline ~MagicXattrRAIIWrapper() { if (ptr_ != NULL) ptr_->Release(); }
103 
104  inline BaseMagicXattr* operator->() const { return ptr_; }
105  inline bool IsNull() const { return ptr_ == NULL; }
106  inline BaseMagicXattr* Move() { BaseMagicXattr* ret = ptr_; ptr_ = NULL; return ret; }
107 
108  protected:
110 };
111 
114 };
115 
118 };
119 
122 };
123 
138  public:
142  BaseMagicXattr* GetLocked(const std::string &name, PathString path,
144  std::string GetListString(catalog::DirectoryEntry *dirent);
145  void Register(const std::string &name, BaseMagicXattr *magic_xattr);
146 
148 
149  protected:
150  std::map<std::string, BaseMagicXattr *> xattr_list_;
153 };
154 
156  virtual bool PrepareValueFenced();
157  virtual std::string GetValue();
159 };
160 
162  std::string subcatalog_path_;
164 
165  virtual bool PrepareValueFenced();
166  virtual std::string GetValue();
167 };
168 
170  std::string chunk_list_;
171 
172  virtual bool PrepareValueFenced();
173  virtual std::string GetValue();
174 };
175 
177  uint64_t n_chunks_;
178 
179  virtual bool PrepareValueFenced();
180  virtual std::string GetValue();
181 };
182 
184  virtual bool PrepareValueFenced();
185  virtual std::string GetValue();
186 };
187 
189  virtual bool PrepareValueFenced();
190  virtual std::string GetValue();
191 };
192 
194  virtual bool PrepareValueFenced();
195  virtual std::string GetValue();
196 };
197 
199  virtual std::string GetValue();
200 };
201 
203  virtual std::string GetValue();
204 };
205 
207  virtual std::string GetValue();
208 };
209 
211  virtual bool PrepareValueFenced();
212  virtual std::string GetValue();
213 };
214 
216  virtual std::string GetValue();
217 };
218 
220  virtual std::string GetValue();
221 };
222 
224  virtual bool PrepareValueFenced();
225  virtual std::string GetValue();
226 };
227 
229  virtual std::string GetValue();
230 };
231 
234 
235  virtual bool PrepareValueFenced();
236  virtual std::string GetValue();
237 };
238 
240  virtual std::string GetValue();
241 };
242 
244  virtual std::string GetValue();
245 };
246 
248  virtual std::string GetValue();
249 };
250 
252  virtual std::string GetValue();
253 };
254 
256  virtual std::string GetValue();
257 };
258 
260  virtual std::string GetValue();
261 };
262 
264  std::string pubkeys_;
265 
266  virtual bool PrepareValueFenced();
267  virtual std::string GetValue();
268 };
269 
271  virtual bool PrepareValueFenced();
272  virtual std::string GetValue();
273 };
274 
277 
278  virtual bool PrepareValueFenced();
279  virtual std::string GetValue();
280 };
281 
283  static uint64_t kMaxMetainfoLength;
284 
286  std::string error_reason_;
287 
288  virtual bool PrepareValueFenced();
289  virtual std::string GetValue();
290 };
291 
293  uint64_t revision_;
294 
295  virtual bool PrepareValueFenced();
296  virtual std::string GetValue();
297 };
298 
301 
302  virtual bool PrepareValueFenced();
303  virtual std::string GetValue();
304 };
305 
306 class RxMagicXattr : public BaseMagicXattr {
307  virtual std::string GetValue();
308 };
309 
311  virtual std::string GetValue();
312 };
313 
315  std::string tag_;
316 
317  virtual bool PrepareValueFenced();
318  virtual std::string GetValue();
319 };
320 
322  virtual std::string GetValue();
323 };
324 
326  virtual std::string GetValue();
327 };
328 
330  virtual std::string GetValue();
331 };
332 
334  virtual std::string GetValue();
335 };
336 
338  virtual std::string GetValue();
339 };
340 
341 #endif // CVMFS_MAGIC_XATTR_H_
virtual std::string GetValue()
Definition: magic_xattr.cc:327
virtual std::string GetValue()=0
MagicXattrManager(MountPoint *mountpoint, bool hide_magic_xattrs)
Definition: magic_xattr.cc:19
MagicXattrFlavor
Definition: magic_xattr.h:19
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:155
void Release()
Definition: magic_xattr.h:68
bool IsNull() const
Definition: magic_xattr.h:105
virtual std::string GetValue()
Definition: magic_xattr.cc:476
std::string subcatalog_path_
Definition: magic_xattr.h:162
void Register(const std::string &name, BaseMagicXattr *magic_xattr)
Definition: magic_xattr.cc:118
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:467
pthread_mutex_t access_mutex_
Definition: magic_xattr.h:80
virtual std::string GetValue()
Definition: magic_xattr.cc:148
BaseMagicXattr * ptr_
Definition: magic_xattr.h:109
virtual std::string GetValue()
Definition: magic_xattr.cc:482
virtual MagicXattrFlavor GetXattrFlavor()
Definition: magic_xattr.h:113
virtual std::string GetValue()
Definition: magic_xattr.cc:239
catalog::Counters counters_
Definition: magic_xattr.h:163
BaseMagicXattr * GetLocked(const std::string &name, PathString path, catalog::DirectoryEntry *d)
Definition: magic_xattr.cc:102
virtual std::string GetValue()
Definition: magic_xattr.cc:501
std::string error_reason_
Definition: magic_xattr.h:286
virtual std::string GetValue()
Definition: magic_xattr.cc:411
shash::Any root_hash_
Definition: magic_xattr.h:300
virtual std::string GetValue()
Definition: magic_xattr.cc:252
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:492
assert((mem||(size==0))&&"Out Of Memory")
virtual std::string GetValue()
Definition: magic_xattr.cc:517
catalog::DirectoryEntry * dirent_
Definition: magic_xattr.h:78
BaseMagicXattr * operator->() const
Definition: magic_xattr.h:104
virtual std::string GetValue()
Definition: magic_xattr.cc:211
virtual std::string GetValue()
Definition: magic_xattr.cc:282
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:215
virtual std::string GetValue()
Definition: magic_xattr.cc:304
MountPoint * mount_point_
Definition: magic_xattr.h:76
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:142
std::string chunk_list_
Definition: magic_xattr.h:170
virtual std::string GetValue()
Definition: magic_xattr.cc:134
static uint64_t kMaxMetainfoLength
Definition: magic_xattr.h:283
MountPoint * mount_point_
Definition: magic_xattr.h:151
virtual std::string GetValue()
Definition: magic_xattr.cc:364
BaseMagicXattr * Move()
Definition: magic_xattr.h:106
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:339
std::string GetListString(catalog::DirectoryEntry *dirent)
Definition: magic_xattr.cc:67
virtual std::string GetValue()
Definition: magic_xattr.cc:235
MagicXattrRAIIWrapper(BaseMagicXattr *ptr, PathString path, catalog::DirectoryEntry *d)
Definition: magic_xattr.h:91
virtual std::string GetValue()
Definition: magic_xattr.cc:463
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:458
virtual std::string GetValue()
Definition: magic_xattr.cc:497
virtual std::string GetValue()
Definition: magic_xattr.cc:258
virtual std::string GetValue()
Definition: magic_xattr.cc:360
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:406
virtual std::string GetValue()
Definition: magic_xattr.cc:513
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:300
virtual std::string GetValue()
Definition: magic_xattr.cc:266
bool hide_magic_xattrs()
Definition: magic_xattr.h:147
virtual std::string GetValue()
Definition: magic_xattr.cc:521
virtual std::string GetValue()
Definition: magic_xattr.cc:472
virtual std::string GetValue()
Definition: magic_xattr.cc:348
virtual std::string GetValue()
Definition: magic_xattr.cc:352
virtual std::string GetValue()
Definition: magic_xattr.cc:377
virtual std::string GetValue()
Definition: magic_xattr.cc:356
std::string tag_
Definition: magic_xattr.h:315
MagicXattrRAIIWrapper(BaseMagicXattr *ptr)
Wraps around a BaseMagicXattr* tha is already locked (or NULL)
Definition: magic_xattr.h:100
shash::Any metainfo_hash_
Definition: magic_xattr.h:285
uint64_t n_chunks_
Definition: magic_xattr.h:177
virtual std::string GetValue()
Definition: magic_xattr.cc:184
virtual std::string GetValue()
Definition: magic_xattr.cc:431
virtual std::string GetValue()
Definition: magic_xattr.cc:344
virtual std::string GetValue()
Definition: magic_xattr.cc:270
PathString path_
Definition: magic_xattr.h:77
virtual std::string GetValue()
Definition: magic_xattr.cc:219
std::map< std::string, BaseMagicXattr * > xattr_list_
Definition: magic_xattr.h:150
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:262
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:417
virtual bool PrepareValueFenced()
Definition: magic_xattr.h:51
virtual ~BaseMagicXattr()
Definition: magic_xattr.h:73
virtual std::string GetValue()
Definition: magic_xattr.cc:227
catalog::Counters counters_
Definition: magic_xattr.h:276
virtual MagicXattrFlavor GetXattrFlavor()
Definition: magic_xattr.h:60
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:389
virtual MagicXattrFlavor GetXattrFlavor()
Definition: magic_xattr.cc:138
std::string pubkeys_
Definition: magic_xattr.h:264
virtual std::string GetValue()
Definition: magic_xattr.cc:507
void Lock(PathString path, catalog::DirectoryEntry *dirent)
Definition: magic_xattr.h:62
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:188
virtual MagicXattrFlavor GetXattrFlavor()
Definition: magic_xattr.h:117
virtual std::string GetValue()
Definition: magic_xattr.cc:394
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:223
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:231
virtual bool PrepareValueFenced()
Definition: magic_xattr.cc:130