CernVM-FS  2.13.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:
19  CheckoutMarker(const std::string &t,
20  const std::string &b,
21  const shash::Any &h,
22  const std::string &p)
23  : tag_(t), branch_(b), hash_(h), previous_branch_(p) { }
24 
25  static CheckoutMarker *CreateFrom(const std::string &path);
26  void SaveAs(const std::string &path) const;
27 
28  std::string tag() const { return tag_; }
29  std::string branch() const { return branch_; }
30  shash::Any hash() const { return hash_; }
31  std::string previous_branch() const { return previous_branch_; }
32 
33  private:
34  std::string tag_;
35  std::string branch_;
37  std::string previous_branch_;
38 };
39 
40 
50  public:
51  explicit ServerLockFile(const std::string &path) : path_(path), fd_(-1) { }
52 
53  void Lock();
54  bool TryLock();
55  void Unlock();
56 
57  const std::string &path() const { return path_; }
58 
59  private:
60  std::string path_;
61  int fd_;
62 };
63 
71  public:
72  explicit ServerLockFileCheck(ServerLockFile &lock) : lock_(lock) {
74  }
76  if (owns_lock_)
77  lock_.Unlock();
78  }
79 
80  const bool owns_lock() const { return owns_lock_; }
81 
82  private:
84  bool owns_lock_;
85 };
86 
93  public:
94  explicit ServerLockFileGuard(ServerLockFile &lock) : lock_(lock) {
95  lock_.Lock();
96  }
98 
99  private:
101 };
102 
109  public:
110  explicit ServerFlagFile(const std::string &path) : path_(path) { }
111 
112  void Set();
113  void Clear();
114  bool IsSet() const;
115 
116  const std::string &path() const { return path_; }
117 
118  private:
119  std::string path_;
120 };
121 
125 void RunSuidHelper(const std::string &verb, const std::string &fqrn);
126 
127 
132 void SetInConfig(const std::string &path, const std::string &key,
133  const std::string &value);
134 
135 std::string SendTalkCommand(const std::string &socket, const std::string &cmd);
136 
137 } // namespace publish
138 
139 #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)