10 #ifndef CRM_COMMON_INTERNAL__H
11 #define CRM_COMMON_INTERNAL__H
18 #include <sys/types.h>
21 #include <libxml/tree.h>
38 #define PCMK__NELEM(a) ((int) (sizeof(a)/sizeof(a[0])) )
44 const char *peer_user);
47 pcmk__is_privileged(
const char *user)
49 return user && (!strcmp(user,
CRM_DAEMON_USER) || !strcmp(user,
"root"));
52 #if SUPPORT_CIBSECRETS
69 int sequence,
bool bzip);
73 unsigned int sequence,
int max);
75 uid_t uid, gid_t gid);
98 pcmk__open_devnull(
int flags)
102 (void) open(
"/dev/null", flags);
161 const char *expected_name, pid_t *
pid);
168 #define PCMK__OP_FMT "%s_%s_%u"
170 char *
pcmk__op_key(
const char *rsc_id,
const char *op_type, guint interval_ms);
172 const char *op_type);
195 static inline uint64_t
196 pcmk__set_flags_as(
const char *
function,
int line, uint8_t log_level,
197 const char *flag_type,
const char *
target,
198 uint64_t flag_group, uint64_t flags,
const char *flags_str)
200 uint64_t result = flag_group |
flags;
202 if (result != flag_group) {
204 "%s flags 0x%.8llx (%s) for %s set by %s:%d",
205 ((flag_type == NULL)?
"Group of" : flag_type),
206 (
unsigned long long) flags,
207 ((flags_str == NULL)?
"flags" : flags_str),
208 ((target == NULL)?
"target" : target),
229 static inline uint64_t
230 pcmk__clear_flags_as(
const char *
function,
int line, uint8_t log_level,
231 const char *flag_type,
const char *target,
232 uint64_t flag_group, uint64_t flags,
const char *flags_str)
234 uint64_t result = flag_group & ~flags;
236 if (result != flag_group) {
238 "%s flags 0x%.8llx (%s) for %s cleared by %s:%d",
239 ((flag_type == NULL)?
"Group of" : flag_type),
240 (
unsigned long long) flags,
241 ((flags_str == NULL)?
"flags" : flags_str),
242 ((target == NULL)?
"target" : target),
272 pcmk__realloc(
void *ptr,
size_t size)
279 new_ptr = realloc(ptr, size);
280 if (new_ptr == NULL) {
293 #define PCMK__RC_ERROR pcmk__rc_error_quark()
294 #define PCMK__EXITC_ERROR pcmk__exitc_error_quark()
304 pcmk__list_of_1(GList *list)
306 return list && (list->next == NULL);
311 pcmk__list_of_multiple(GList *list)
313 return list && (list->next != NULL);
318 #define PCMK__FAIL_COUNT_PREFIX "fail-count"
319 #define PCMK__LAST_FAILURE_PREFIX "last-failure"
339 pcmk__fail_attr_name(
const char *prefix,
const char *rsc_id,
const char *op,
342 CRM_CHECK(prefix && rsc_id && op,
return NULL);
347 pcmk__failcount_name(
const char *rsc_id,
const char *op, guint interval_ms)
354 pcmk__lastfailure_name(
const char *rsc_id,
const char *op, guint interval_ms)
#define CRM_CHECK(expr, failure_action)
const char * pcmk__message_name(const char *name)
Get name to be used as identifier for cluster messages.
guint pcmk__mainloop_timer_get_period(mainloop_timer_t *timer)
Get period for mainloop timer.
void crm_schema_init(void)
int pcmk__read_pidfile(const char *filename, pid_t *pid)
int pcmk__read_series_sequence(const char *directory, const char *series, unsigned int *seq)
int pcmk__write_sync(int fd, const char *contents)
int pcmk__substitute_secrets(const char *rsc_id, GHashTable *params)
struct mainloop_timer_s mainloop_timer_t
bool pcmk__verify_digest(xmlNode *input, const char *expected)
struct mainloop_io_s mainloop_io_t
void pcmk__close_fds_in_child(bool)
void crm_schema_cleanup(void)
void pcmk__filter_op_for_digest(xmlNode *param_set)
char * pcmk__format_named_time(const char *name, time_t epoch_time)
GQuark pcmk__exitc_error_quark(void)
char * pcmk__series_filename(const char *directory, const char *series, int sequence, bool bzip)
Wrappers for and extensions to glib mainloop.
#define PCMK__LAST_FAILURE_PREFIX
Wrappers for and extensions to libqb logging.
int pcmk__effective_rc(int rc)
char * pcmk__format_nvpair(const char *name, const char *value, const char *units)
#define do_crm_log_unlikely(level, fmt, args...)
Log a message that is likely to be filtered out.
int daemon(int nochdir, int noclose)
char * pcmk__notify_key(const char *rsc_id, const char *notify_type, const char *op_type)
void pcmk__sleep_ms(unsigned int ms)
struct crm_ipc_s crm_ipc_t
int pcmk__real_path(const char *path, char **resolved_path)
unsigned int pcmk__procfs_num_cores(void)
const char * pcmk__update_acl_user(xmlNode *request, const char *field, const char *peer_user)
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1
int pcmk__scan_nvpair(const char *input, char **name, char **value)
bool pcmk__daemon_can_write(const char *dir, const char *file)
#define PCMK__FAIL_COUNT_PREFIX
int pcmk__pid_active(pid_t pid, const char *daemon)
int pcmk__file_contents(const char *filename, char **contents)
pid_t pcmk__locate_sbd(void)
char * pcmk__op_key(const char *rsc_id, const char *op_type, guint interval_ms)
Generate an operation key (RESOURCE_ACTION_INTERVAL)
void pcmk__write_series_sequence(const char *directory, const char *series, unsigned int sequence, int max)
pid_t pcmk__procfs_pid_of(const char *name)
void pcmk__daemonize(const char *name, const char *pidfile)
int pcmk__lock_pidfile(const char *filename, const char *name)
const char * pcmk__get_tmpdir(void)
int pcmk__pidfile_matches(const char *filename, pid_t expected_pid, const char *expected_name, pid_t *pid)
char * pcmk__transition_key(int transition_id, int action_id, int target_rc, const char *node)
int pcmk__chown_series_sequence(const char *directory, const char *series, uid_t uid, gid_t gid)
void pcmk__sync_directory(const char *name)
void pcmk__panic(const char *origin)
char * pcmk__uid2username(uid_t uid)
int pcmk__add_mainloop_ipc(crm_ipc_t *ipc, int priority, void *userdata, struct ipc_client_callbacks *callbacks, mainloop_io_t **source)
Connect to IPC and add it as a main loop source.
GQuark pcmk__rc_error_quark(void)
int pcmk__build_path(const char *path_c, mode_t mode)
int pcmk__set_nonblocking(int fd)