CernVM-FS  2.12.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
repository_util.h
Go to the documentation of this file.
1 
7 #ifndef CVMFS_PUBLISH_REPOSITORY_UTIL_H_
8 #define CVMFS_PUBLISH_REPOSITORY_UTIL_H_
9 
10 #include <string>
11 
12 #include "crypto/hash.h"
13 #include "util/single_copy.h"
14 
15 namespace publish {
16 
18  public:
20  const std::string &t,
21  const std::string &b,
22  const shash::Any &h,
23  const std::string &p)
24  : tag_(t), branch_(b), hash_(h), previous_branch_(p)
25  {}
26 
27  static CheckoutMarker *CreateFrom(const std::string &path);
28  void SaveAs(const std::string &path) const;
29 
30  std::string tag() const { return tag_; }
31  std::string branch() const { return branch_; }
32  shash::Any hash() const { return hash_; }
33  std::string previous_branch() const { return previous_branch_; }
34 
35  private:
36  std::string tag_;
37  std::string branch_;
39  std::string previous_branch_;
40 };
41 
42 
52  public:
53  explicit ServerLockFile(const std::string &path) : path_(path), fd_(-1) {}
54 
55  void Lock();
56  bool TryLock();
57  void Unlock();
58 
59  const std::string &path() const { return path_; }
60 
61  private:
62  std::string path_;
63  int fd_;
64 };
65 
73  public:
74  explicit ServerLockFileCheck(ServerLockFile &lock) : lock_(lock) {
76  }
78  if (owns_lock_)
79  lock_.Unlock();
80  }
81 
82  const bool owns_lock() const { return owns_lock_; }
83 
84  private:
86  bool owns_lock_;
87 };
88 
95  public:
96  explicit ServerLockFileGuard(ServerLockFile &lock) : lock_(lock) {
97  lock_.Lock();
98  }
100  lock_.Unlock();
101  }
102 
103  private:
105 };
106 
113  public:
114  explicit ServerFlagFile(const std::string &path) : path_(path) {}
115 
116  void Set();
117  void Clear();
118  bool IsSet() const;
119 
120  const std::string &path() const { return path_; }
121 
122  private:
123  std::string path_;
124 };
125 
129 void RunSuidHelper(const std::string &verb, const std::string &fqrn);
130 
131 
136 void SetInConfig(const std::string &path,
137  const std::string &key, const std::string &value);
138 
139 std::string SendTalkCommand(const std::string &socket, const std::string &cmd);
140 
141 } // namespace publish
142 
143 #endif // CVMFS_PUBLISH_REPOSITORY_UTIL_H_
std::string branch() const
const std::string & path() const
const bool owns_lock() const
ServerLockFile(const std::string &path)
std::string tag() const
ServerLockFileGuard(ServerLockFile &lock)
const std::string & path() const
shash::Any hash() const
std::string previous_branch() const
CheckoutMarker(const std::string &t, const std::string &b, const shash::Any &h, const std::string &p)
void SetInConfig(const std::string &path, const std::string &key, const std::string &value)
ServerFlagFile(const std::string &path)
void SaveAs(const std::string &path) const
std::string SendTalkCommand(const std::string &socket, const std::string &cmd)
void RunSuidHelper(const std::string &verb, const std::string &fqrn)
ServerLockFileCheck(ServerLockFile &lock)
static CheckoutMarker * CreateFrom(const std::string &path)