CernVM-FS  2.10.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
loader.h
Go to the documentation of this file.
1 
5 #ifndef CVMFS_LOADER_H_
6 #define CVMFS_LOADER_H_
7 
8 #define _FILE_OFFSET_BITS 64
9 
10 #include <stdint.h>
11 #include <time.h>
12 
13 #include <cstring>
14 #include <string>
15 #include <vector>
16 
17 #include "duplex_fuse.h"
18 
19 namespace loader {
20 
21 extern std::string *usyslog_path_;
22 
27 enum Failures {
28  kFailOk = 0,
36  kFailIncompatibleVersions, // TODO(jblomer)
54 
56 };
57 
58 inline const char *Code2Ascii(const Failures error) {
59  const char *texts[kFailNumEntries + 1];
60  texts[0] = "OK";
61  texts[1] = "unknown error";
62  texts[2] = "illegal options";
63  texts[3] = "permission denied";
64  texts[4] = "failed to mount";
65  texts[5] = "unable to init loader talk socket";
66  texts[6] = "cannot run FUSE event loop";
67  texts[7] = "failed to load shared library";
68  texts[8] = "incompatible library version";
69  texts[9] = "cache directory/plugin problem";
70  texts[10] = "peering problem";
71  texts[11] = "NFS maps init failure";
72  texts[12] = "quota init failure";
73  texts[13] = "watchdog failure";
74  texts[14] = "talk socket failure";
75  texts[15] = "signature verification failure";
76  texts[16] = "file catalog failure";
77  texts[17] = "maintenance mode";
78  texts[18] = "state saving failure";
79  texts[19] = "state restore failure";
80  texts[20] = "already mounted";
81  texts[21] = "double mount";
82  texts[22] = "history init failure";
83  texts[23] = "proxy auto-discovery failed";
84  texts[24] = "workspace already locked";
85  texts[25] = "revision blacklisted";
86  texts[26] = "no text";
87  return texts[error];
88 }
89 
90 
91 enum StateId {
93  kStateOpenDirs, // >= 2.1.4
94  kStateOpenChunks, // >= 2.1.4, used as of 2.1.15
95  kStateGlueBuffer, // >= 2.1.9
96  kStateInodeGeneration, // >= 2.1.9
98  kStateGlueBufferV2, // >= 2.1.10
99  kStateGlueBufferV3, // >= 2.1.15
100  kStateGlueBufferV4, // >= 2.1.20
101  kStateOpenChunksV2, // >= 2.1.20
102  kStateOpenChunksV3, // >= 2.2.0
103  kStateOpenChunksV4, // >= 2.2.3
104  kStateOpenFiles, // >= 2.4
106 
107  // Note: kStateOpenFilesXXX was renamed to kStateOpenChunksXXX as of 2.4
108 };
109 
110 
111 struct SavedState {
113  version = 1;
114  size = sizeof(SavedState);
116  state = NULL;
117  }
118 
119  uint32_t version;
120  uint32_t size;
122  void *state;
123 };
124 typedef std::vector<SavedState *> StateList;
125 
126 
127 struct LoadEvent {
129  version = 1;
130  size = sizeof(LoadEvent);
131  timestamp = 0;
132  }
133 
134  uint32_t version;
135  uint32_t size;
136  time_t timestamp;
137  std::string so_version;
138 };
139 typedef std::vector<LoadEvent *> EventList;
140 
141 
157  version(5),
158  size(sizeof(LoaderExports)),
159  boot_time(0),
160  foreground(false),
161  disable_watchdog(false),
162  simple_options_parsing(false),
164  { }
165 
167  for (unsigned i = 0; i < history.size(); ++i)
168  delete history[i];
169  }
170 
171  uint32_t version;
172  uint32_t size;
173  time_t boot_time;
174  std::string loader_version;
176  std::string repository_name;
177  std::string mount_point;
178  std::string config_files;
179  std::string program_name;
182 
183  // added with CernVM-FS 2.1.8 (LoaderExports Version: 2)
185 
186  // added with CernVM-FS 2.2.0 (LoaderExports Version: 3)
188 
189  // added with CernVM-FS 2.4.0 (LoaderExports Version: 4)
190  // As of CernVM-FS 2.7, this has been rebranded from
191  // struct fuse_chan **fuse_channel to
192  // void **fuse_channel_or_session
193  // in order to work with both libfuse2 and libfuse3
195 
196  // Linux only, stores the major:minor internal mountpoint identifier
197  // The identifier is read just after mount from /proc/self/mountinfo
198  // If it cannot be determined (e.g. on macOS), device_id is "0:0".
199  std::string device_id;
200 };
201 
202 
211 struct CvmfsExports {
213  version = 1;
214  size = sizeof(CvmfsExports);
215  fnAltProcessFlavor = NULL;
216  fnInit = NULL;
217  fnSpawn = NULL;
218  fnFini = NULL;
219  fnGetErrorMsg = NULL;
220  fnMaintenanceMode = NULL;
221  fnSaveState = NULL;
222  fnRestoreState = NULL;
223  fnFreeSavedState = NULL;
224  memset(&cvmfs_operations, 0, sizeof(cvmfs_operations));
225  }
226 
227  uint32_t version;
228  uint32_t size;
229  std::string so_version;
230 
231  int (*fnAltProcessFlavor)(int argc, char **argv);
232  int (*fnInit)(const LoaderExports *loader_exports);
233  void (*fnSpawn)();
234  void (*fnFini)();
235  std::string (*fnGetErrorMsg)();
236  bool (*fnMaintenanceMode)(const int fd_progress);
237  bool (*fnSaveState)(const int fd_progress, StateList *saved_states);
238  bool (*fnRestoreState)(const int fd_progress, const StateList &saved_states);
239  void (*fnFreeSavedState)(const int fd_progress,
240  const StateList &saved_states);
241  struct fuse_lowlevel_ops cvmfs_operations;
242 };
243 
244 Failures Reload(const int fd_progress, const bool stop_and_go);
245 
246 } // namespace loader
247 
248 #endif // CVMFS_LOADER_H_
std::string repository_name
Definition: loader.h:176
Failures Reload(const int fd_progress, const bool stop_and_go)
Definition: loader.cc:548
uint32_t version
Definition: loader.h:171
std::string mount_point
Definition: loader.h:177
uint32_t size
Definition: loader.h:120
time_t timestamp
Definition: loader.h:136
EventList history
Definition: loader.h:180
int(* fnAltProcessFlavor)(int argc, char **argv)
Definition: loader.h:231
string * usyslog_path_
Definition: loader.cc:131
std::string so_version
Definition: loader.h:137
void(* fnFini)()
Definition: loader.h:234
StateId state_id
Definition: loader.h:121
const char * Code2Ascii(const Failures error)
Definition: loader.h:58
void ** fuse_channel_or_session
Definition: loader.h:194
std::string program_name
Definition: loader.h:179
std::string loader_version
Definition: loader.h:174
bool(* fnSaveState)(const int fd_progress, StateList *saved_states)
Definition: loader.h:237
std::string so_version
Definition: loader.h:229
bool(* fnRestoreState)(const int fd_progress, const StateList &saved_states)
Definition: loader.h:238
std::string config_files
Definition: loader.h:178
uint32_t version
Definition: loader.h:119
struct fuse_lowlevel_ops cvmfs_operations
Definition: loader.h:241
int(* fnInit)(const LoaderExports *loader_exports)
Definition: loader.h:232
bool simple_options_parsing
Definition: loader.h:187
bool(* fnMaintenanceMode)(const int fd_progress)
Definition: loader.h:236
void(* fnFreeSavedState)(const int fd_progress, const StateList &saved_states)
Definition: loader.h:239
Failures
Definition: loader.h:27
std::string device_id
Definition: loader.h:199
void(* fnSpawn)()
Definition: loader.h:233
std::string(* fnGetErrorMsg)()
Definition: loader.h:235
uint32_t version
Definition: loader.h:227
std::vector< SavedState * > StateList
Definition: loader.h:124
StateList saved_states
Definition: loader.h:181
uint32_t size
Definition: loader.h:135
std::vector< LoadEvent * > EventList
Definition: loader.h:139
uint32_t version
Definition: loader.h:134
StateId
Definition: loader.h:91