MCPcopy Create free account
hub / github.com/corosync/corosync / get_state_dir

Function get_state_dir

exec/util.c:175–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

173}
174
175const char *get_state_dir(void)
176{
177 static char path[PATH_MAX] = {'\0'};
178 char *state_dir;
179 int res;
180
181 if (path[0] == '\0') {
182 if (icmap_get_string("system.state_dir", &state_dir) == CS_OK) {
183 res = snprintf(path, PATH_MAX, "%s", state_dir);
184 free(state_dir);
185 } else if ((state_dir = getenv("STATE_DIRECTORY")) != NULL) {
186 /*
187 * systemd allows multiple directory names that are
188 * passed to env variable separated by colon. Support for this feature
189 * is deliberately not implemented because corosync always
190 * uses just one state directory and it is unclear what behavior should
191 * be taken for multiple ones. If reasonable need for
192 * supporting multiple directories appear, it must be implemented also
193 * for cmap.
194 */
195 res = snprintf(path, PATH_MAX, "%s", state_dir);
196 } else {
197 res = snprintf(path, PATH_MAX, "%s/%s", LOCALSTATEDIR, "lib/corosync");
198 }
199
200 assert(res < PATH_MAX);
201 }
202
203 return (path);
204}
205
206static int safe_strcat(char *dst, size_t dst_len, const char *src)
207{

Callers 5

load_ev_tracking_barrierFunction · 0.85
corosync_ring_id_storeFunction · 0.85
mainFunction · 0.85

Calls 1

icmap_get_stringFunction · 0.85

Tested by

no test coverage detected