pacemaker  1.1.18-7fdfbbe
Scalable High-Availability cluster resource manager
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
utils.c File Reference
#include <crm_internal.h>
#include <dlfcn.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <sys/utsname.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <limits.h>
#include <pwd.h>
#include <time.h>
#include <libgen.h>
#include <signal.h>
#include <qb/qbdefs.h>
#include <crm/crm.h>
#include <crm/services.h>
#include <crm/msg_xml.h>
#include <crm/cib/internal.h>
#include <crm/common/xml.h>
#include <crm/common/util.h>
#include <crm/common/ipc.h>
#include <crm/common/iso8601.h>
#include <crm/common/mainloop.h>
#include <libxml2/libxml/relaxng.h>
#include <md5.h>
Include dependency graph for utils.c:

Go to the source code of this file.

Macros

#define _GNU_SOURCE
 
#define MAXLINE   512
 
#define PW_BUFFER_LEN   500
 
#define NUMCHARS   "0123456789."
 
#define WHITESPACE   " \t\n\r\f"
 
#define LOCKSTRLEN   11
 

Functions

 CRM_TRACE_INIT_DATA (common)
 
int crm_exit (int rc)
 
gboolean check_time (const char *value)
 
gboolean check_timer (const char *value)
 
gboolean check_boolean (const char *value)
 
gboolean check_number (const char *value)
 
gboolean check_positive_number (const char *value)
 
gboolean check_quorum (const char *value)
 
gboolean check_script (const char *value)
 
gboolean check_utilization (const char *value)
 
int char2score (const char *score)
 
char * score2char_stack (int score, char *buf, size_t len)
 
char * score2char (int score)
 
const char * cluster_option (GHashTable *options, gboolean(*validate)(const char *), const char *name, const char *old_name, const char *def_value)
 
const char * get_cluster_pref (GHashTable *options, pe_cluster_option *option_list, int len, const char *name)
 
void config_metadata (const char *name, const char *version, const char *desc_short, const char *desc_long, pe_cluster_option *option_list, int len)
 
void verify_all_options (GHashTable *options, pe_cluster_option *option_list, int len)
 
char * generate_hash_key (const char *crm_msg_reference, const char *sys)
 
int crm_user_lookup (const char *name, uid_t *uid, gid_t *gid)
 
int compare_version (const char *version1, const char *version2)
 
unsigned long long crm_get_interval (const char *input)
 
long long crm_get_msec (const char *input)
 
void crm_abort (const char *file, const char *function, int line, const char *assert_condition, gboolean do_core, gboolean do_fork)
 
int crm_pid_active (long pid, const char *daemon)
 
long crm_read_pidfile (const char *filename)
 
long crm_pidfile_inuse (const char *filename, long mypid, const char *daemon)
 
void crm_make_daemon (const char *name, gboolean daemonize, const char *pidfile)
 
char * crm_meta_name (const char *field)
 
const char * crm_meta_value (GHashTable *hash, const char *field)
 
void crm_set_options (const char *short_options, const char *app_usage, struct crm_option *long_options, const char *app_desc)
 
int crm_get_option (int argc, char **argv, int *index)
 
int crm_get_option_long (int argc, char **argv, int *index, const char **longname)
 
int crm_help (char cmd, int exit_code)
 
void cib_ipc_servers_init (qb_ipcs_service_t **ipcs_ro, qb_ipcs_service_t **ipcs_rw, qb_ipcs_service_t **ipcs_shm, struct qb_ipcs_service_handlers *ro_cb, struct qb_ipcs_service_handlers *rw_cb)
 
void cib_ipc_servers_destroy (qb_ipcs_service_t *ipcs_ro, qb_ipcs_service_t *ipcs_rw, qb_ipcs_service_t *ipcs_shm)
 
qb_ipcs_service_t * crmd_ipc_server_init (struct qb_ipcs_service_handlers *cb)
 
void attrd_ipc_server_init (qb_ipcs_service_t **ipcs, struct qb_ipcs_service_handlers *cb)
 
void stonith_ipc_server_init (qb_ipcs_service_t **ipcs, struct qb_ipcs_service_handlers *cb)
 
bool pcmk_acl_required (const char *user)
 
void * find_library_function (void **handle, const char *lib, const char *fn, gboolean fatal)
 
void * convert_const_pointer (const void *ptr)
 
char * crm_generate_uuid (void)
 
bool crm_is_daemon_name (const char *name)
 Check whether a string represents a cluster daemon name. More...
 
char * crm_md5sum (const char *buffer)
 
char * crm_generate_ra_key (const char *class, const char *provider, const char *type)
 
bool crm_provider_required (const char *standard)
 Check whether a resource standard requires a provider to be specified. More...
 
int crm_parse_agent_spec (const char *spec, char **standard, char **provider, char **type)
 Parse a "standard[:provider]:type" agent specification. More...
 

Variables

gboolean crm_config_error = FALSE
 
gboolean crm_config_warning = FALSE
 
char * crm_system_name = NULL
 
int node_score_red = 0
 
int node_score_green = 0
 
int node_score_yellow = 0
 
int node_score_infinity = INFINITY
 
gboolean do_stderr = FALSE
 
bool crm_is_daemon
 

Macro Definition Documentation

#define _GNU_SOURCE

Definition at line 23 of file utils.c.

#define LOCKSTRLEN   11

Definition at line 778 of file utils.c.

#define MAXLINE   512

Definition at line 55 of file utils.c.

#define NUMCHARS   "0123456789."

Definition at line 565 of file utils.c.

#define PW_BUFFER_LEN   500

Definition at line 63 of file utils.c.

#define WHITESPACE   " \t\n\r\f"

Definition at line 569 of file utils.c.

Function Documentation

void attrd_ipc_server_init ( qb_ipcs_service_t **  ipcs,
struct qb_ipcs_service_handlers *  cb 
)

Definition at line 1212 of file utils.c.

int char2score ( const char *  score)

Definition at line 230 of file utils.c.

gboolean check_boolean ( const char *  value)

Definition at line 129 of file utils.c.

gboolean check_number ( const char *  value)

Definition at line 140 of file utils.c.

gboolean check_positive_number ( const char *  value)

Definition at line 161 of file utils.c.

gboolean check_quorum ( const char *  value)

Definition at line 170 of file utils.c.

gboolean check_script ( const char *  value)

Definition at line 188 of file utils.c.

gboolean check_time ( const char *  value)

Definition at line 111 of file utils.c.

gboolean check_timer ( const char *  value)

Definition at line 120 of file utils.c.

gboolean check_utilization ( const char *  value)

Definition at line 215 of file utils.c.

void cib_ipc_servers_destroy ( qb_ipcs_service_t *  ipcs_ro,
qb_ipcs_service_t *  ipcs_rw,
qb_ipcs_service_t *  ipcs_shm 
)

Definition at line 1196 of file utils.c.

void cib_ipc_servers_init ( qb_ipcs_service_t **  ipcs_ro,
qb_ipcs_service_t **  ipcs_rw,
qb_ipcs_service_t **  ipcs_shm,
struct qb_ipcs_service_handlers *  ro_cb,
struct qb_ipcs_service_handlers *  rw_cb 
)

Definition at line 1179 of file utils.c.

const char* cluster_option ( GHashTable *  options,
gboolean(*)(const char *)  validate,
const char *  name,
const char *  old_name,
const char *  def_value 
)

Definition at line 294 of file utils.c.

int compare_version ( const char *  version1,
const char *  version2 
)

Definition at line 486 of file utils.c.

void config_metadata ( const char *  name,
const char *  version,
const char *  desc_short,
const char *  desc_long,
pe_cluster_option option_list,
int  len 
)

Definition at line 375 of file utils.c.

void* convert_const_pointer ( const void *  ptr)

Definition at line 1379 of file utils.c.

void crm_abort ( const char *  file,
const char *  function,
int  line,
const char *  assert_condition,
gboolean  do_core,
gboolean  do_fork 
)

Definition at line 656 of file utils.c.

int crm_exit ( int  rc)

Definition at line 83 of file utils.c.

char* crm_generate_ra_key ( const char *  class,
const char *  provider,
const char *  type 
)

Definition at line 1461 of file utils.c.

char* crm_generate_uuid ( void  )

Definition at line 1390 of file utils.c.

unsigned long long crm_get_interval ( const char *  input)

Definition at line 573 of file utils.c.

long long crm_get_msec ( const char *  input)

Definition at line 598 of file utils.c.

int crm_get_option ( int  argc,
char **  argv,
int *  index 
)

Definition at line 1053 of file utils.c.

int crm_get_option_long ( int  argc,
char **  argv,
int *  index,
const char **  longname 
)

Definition at line 1059 of file utils.c.

int crm_help ( char  cmd,
int  exit_code 
)

Definition at line 1104 of file utils.c.

bool crm_is_daemon_name ( const char *  name)

Check whether a string represents a cluster daemon name.

Parameters
[in]nameString to check
Returns
TRUE if name is standard client name used by daemons, FALSE otherwise

Definition at line 1408 of file utils.c.

void crm_make_daemon ( const char *  name,
gboolean  daemonize,
const char *  pidfile 
)

Definition at line 880 of file utils.c.

char* crm_md5sum ( const char *  buffer)

Definition at line 1424 of file utils.c.

char* crm_meta_name ( const char *  field)

Definition at line 927 of file utils.c.

const char* crm_meta_value ( GHashTable *  hash,
const char *  field 
)

Definition at line 949 of file utils.c.

int crm_parse_agent_spec ( const char *  spec,
char **  standard,
char **  provider,
char **  type 
)

Parse a "standard[:provider]:type" agent specification.

Parameters
[in]specAgent specification
[out]standardNewly allocated memory containing agent standard (or NULL)
[out]providerNewly allocated memory containing agent provider (or NULL)
put]type Newly allocated memory containing agent type (or NULL)
Returns
pcmk_ok if the string could be parsed, -EINVAL otherwise
Note
It is acceptable for the type to contain a ':' if the standard supports that. For example, systemd supports the form "systemd:UNIT@A:B".
It is the caller's responsibility to free the returned values.

Definition at line 1512 of file utils.c.

int crm_pid_active ( long  pid,
const char *  daemon 
)

Definition at line 718 of file utils.c.

long crm_pidfile_inuse ( const char *  filename,
long  mypid,
const char *  daemon 
)

Definition at line 818 of file utils.c.

bool crm_provider_required ( const char *  standard)

Check whether a resource standard requires a provider to be specified.

Parameters
[in]standardStandard name
Returns
TRUE if standard requires a provider, FALSE otherwise

Definition at line 1481 of file utils.c.

long crm_read_pidfile ( const char *  filename)

Definition at line 781 of file utils.c.

void crm_set_options ( const char *  short_options,
const char *  app_usage,
struct crm_option long_options,
const char *  app_desc 
)

Definition at line 1012 of file utils.c.

CRM_TRACE_INIT_DATA ( common  )
int crm_user_lookup ( const char *  name,
uid_t *  uid,
gid_t *  gid 
)

Definition at line 433 of file utils.c.

qb_ipcs_service_t* crmd_ipc_server_init ( struct qb_ipcs_service_handlers *  cb)

Definition at line 1206 of file utils.c.

void* find_library_function ( void **  handle,
const char *  lib,
const char *  fn,
gboolean  fatal 
)

Definition at line 1349 of file utils.c.

char* generate_hash_key ( const char *  crm_msg_reference,
const char *  sys 
)

Definition at line 423 of file utils.c.

const char* get_cluster_pref ( GHashTable *  options,
pe_cluster_option option_list,
int  len,
const char *  name 
)

Definition at line 356 of file utils.c.

bool pcmk_acl_required ( const char *  user)

Definition at line 1236 of file utils.c.

char* score2char ( int  score)

Definition at line 282 of file utils.c.

char* score2char_stack ( int  score,
char *  buf,
size_t  len 
)

Definition at line 268 of file utils.c.

void stonith_ipc_server_init ( qb_ipcs_service_t **  ipcs,
struct qb_ipcs_service_handlers *  cb 
)

Definition at line 1224 of file utils.c.

void verify_all_options ( GHashTable *  options,
pe_cluster_option option_list,
int  len 
)

Definition at line 410 of file utils.c.

Variable Documentation

gboolean crm_config_error = FALSE

Definition at line 68 of file utils.c.

gboolean crm_config_warning = FALSE

Definition at line 69 of file utils.c.

bool crm_is_daemon

Definition at line 49 of file logging.c.

char* crm_system_name = NULL

Definition at line 70 of file utils.c.

gboolean do_stderr = FALSE

Definition at line 562 of file utils.c.

int node_score_green = 0

Definition at line 73 of file utils.c.

int node_score_infinity = INFINITY

Definition at line 75 of file utils.c.

int node_score_red = 0

Definition at line 72 of file utils.c.

int node_score_yellow = 0

Definition at line 74 of file utils.c.