75 char *buf,
size_t buf_size)
79 for (i = 0; servicenames[i].
c_name != NULL; i++) {
80 if (service_id == servicenames[i].
c_val) {
81 return (servicenames[i].
c_name);
84 snprintf(buf, buf_size,
"%d", service_id);
94 return ((strncmp ((
char *)name1->
value, (
char *)name2->
value,
108 if (gettimeofday(&tv, 0)) {
112 time_now = (
cs_time_t)(tv.tv_sec) * 1000000000ULL;
113 time_now += (
cs_time_t)(tv.tv_usec) * 1000ULL;
133 "Corosync Cluster Engine exiting normally");
136 "with status %d at %s:%u.", err, file, line);
148 memset (ret_name, 0,
sizeof (ret_name));
152 return ((
char *)name->
value);
156 strncpy ((
char *)name->
value, str, sizeof (name->
value) - 1);
157 ((
char *)name->
value)[
sizeof (name->
value) - 1] =
'\0';
161 name->
length = strlen (str);
166 if (str1->
length == strlen (str2)) {
167 return ((strncmp ((
char *)str1->
value, (
char *)str2,
176 static char path[PATH_MAX] = {
'\0'};
177 char *cmap_state_dir;
180 if (path[0] ==
'\0') {
182 res = snprintf(path, PATH_MAX,
"%s", cmap_state_dir);
183 free(cmap_state_dir);
185 res = snprintf(path, PATH_MAX,
"%s/%s",
LOCALSTATEDIR,
"lib/corosync");
188 assert(res < PATH_MAX);
194static int safe_strcat(
char *dst,
size_t dst_len,
const char *src)
197 if (strlen(dst) + strlen(src) >= dst_len - 1) {
214 const char **list_str,
int machine_parseable_str,
215 const char *error_string_prefix,
const char **error_string)
218 struct knet_crypto_info crypto_list[16];
220 static char local_error_str[512];
221 static char local_list_str[256];
224 if (list_str != NULL) {
225 *list_str = local_list_str;
228 memset(local_error_str, 0,
sizeof(local_error_str));
229 memset(local_list_str, 0,
sizeof(local_list_str));
231 safe_strcat(local_error_str,
sizeof(local_error_str), error_string_prefix);
233 if (knet_get_crypto_list(NULL, &entries) != 0) {
234 *error_string =
"internal error - cannot get knet crypto list";
238 if (entries >
sizeof(crypto_list) /
sizeof(crypto_list[0])) {
239 *error_string =
"internal error - too many knet crypto list entries";
243 if (knet_get_crypto_list(crypto_list, &entries) != 0) {
244 *error_string =
"internal error - cannot get knet crypto list";
248 for (zi = 0; zi < entries; zi++) {
250 }
else if (zi == entries - 1) {
251 if (machine_parseable_str) {
252 (void)safe_strcat(local_list_str,
sizeof(local_list_str),
" ");
254 (void)safe_strcat(local_list_str,
sizeof(local_list_str),
" or ");
257 if (machine_parseable_str) {
258 (void)safe_strcat(local_list_str,
sizeof(local_list_str),
" ");
260 (void)safe_strcat(local_list_str,
sizeof(local_list_str),
", ");
264 (void)safe_strcat(local_list_str,
sizeof(local_list_str), crypto_list[zi].name);
266 if (val != NULL && strcmp(val, crypto_list[zi].name) == 0) {
272 (void)safe_strcat(local_error_str,
sizeof(local_error_str), local_list_str);
273 *error_string = local_error_str;
276 return (model_found);
280 const char **list_str,
int machine_parseable_str,
281 const char *error_string_prefix,
const char **error_string)
284 struct knet_compress_info compress_list[16];
286 static char local_error_str[512];
287 static char local_list_str[256];
290 if (list_str != NULL) {
291 *list_str = local_list_str;
294 memset(local_error_str, 0,
sizeof(local_error_str));
295 memset(local_list_str, 0,
sizeof(local_list_str));
297 safe_strcat(local_error_str,
sizeof(local_error_str), error_string_prefix);
299 if (knet_get_compress_list(NULL, &entries) != 0) {
300 *error_string =
"internal error - cannot get knet compress list";
304 if (entries >
sizeof(compress_list) /
sizeof(compress_list[0])) {
305 *error_string =
"internal error - too many knet compress list entries";
309 if (knet_get_compress_list(compress_list, &entries) != 0) {
310 *error_string =
"internal error - cannot get knet compress list";
314 for (zi = 0; zi < entries; zi++) {
316 }
else if (zi == entries - 1) {
317 if (machine_parseable_str) {
318 (void)safe_strcat(local_list_str,
sizeof(local_list_str),
" ");
320 (void)safe_strcat(local_list_str,
sizeof(local_list_str),
" or ");
323 if (machine_parseable_str) {
324 (void)safe_strcat(local_list_str,
sizeof(local_list_str),
" ");
326 (void)safe_strcat(local_list_str,
sizeof(local_list_str),
", ");
330 (void)safe_strcat(local_list_str,
sizeof(local_list_str), compress_list[zi].name);
332 if (val != NULL && strcmp(val, compress_list[zi].name) == 0) {
338 (void)safe_strcat(local_error_str,
sizeof(local_error_str), local_list_str);
339 *error_string = local_error_str;
342 return (model_found);
int64_t cs_time_t
cs_time_t
#define CS_MAX_NAME_LENGTH
cs_error_t icmap_get_string(const char *key_name, char **str)
Shortcut for icmap_get for string type.
#define LOGSYS_LEVEL_ERROR
#define log_printf(level, format, args...)
void logsys_system_fini(void)
logsys_system_fini
#define LOGSYS_LEVEL_NOTICE
uint8_t value[CS_MAX_NAME_LENGTH]
int util_is_valid_knet_crypto_model(const char *val, const char **list_str, int machine_parseable_str, const char *error_string_prefix, const char **error_string)
char * getcs_name_t(cs_name_t *name)
const char * get_state_dir(void)
cs_time_t clust_time_now(void)
Get the time of day and convert to nanoseconds.
const char * short_service_name_get(uint32_t service_id, char *buf, size_t buf_size)
Get the short name of a service from the service_id.
int util_is_valid_knet_compress_model(const char *val, const char **list_str, int machine_parseable_str, const char *error_string_prefix, const char **error_string)
int name_match(cs_name_t *name1, cs_name_t *name2)
Compare two names.
void setcs_name_t(cs_name_t *name, char *str)
void _corosync_out_of_memory_error(void)
LOGSYS_DECLARE_SUBSYS("MAIN")
void _corosync_exit_error(enum e_corosync_done err, const char *file, unsigned int line) __attribute__((noreturn))
int cs_name_tisEqual(cs_name_t *str1, char *str2)