CMAP_SET(3)
πΎ CMAP_SET(3) β the Corosync Cluster Engine Programmer's Manual one
okay bestie, welcome to the <corosync/cmap.h> girlies' corner of the Corosync Cluster Engine Programmer's Manual π this is cmap_set, page 3 of the manual, and she's here to help you store a value in CMAP. iconic behavior, truly.
β¨ NAME β¨
cmap_set β Store value in CMAP π«Ά
π SYNOPSIS π
First up, the main character:
#include <corosync/cmap.h>
cs_error_t cmap_set (cmap_handle_t handle, const char *key_name, const
void *value, size_t value_len, cmap_value_types_t type);
Also shortcuts for different types are defined π β yes queen, one per type, because typing casts is not the vibe:
cs_error_t cmap_set_int8(cmap_handle_t handle, const char *key_name,
int8_t value);
cs_error_t cmap_set_uint8(cmap_handle_t handle, const char *key_name,
uint8_t value);
cs_error_t cmap_set_int16(cmap_handle_t handle, const char *key_name,
int16_t value);
cs_error_t cmap_set_uint16(cmap_handle_t handle, const char *key_name,
uint16_t value);
cs_error_t cmap_set_int32(cmap_handle_t handle, const char *key_name,
int32_t value);
cs_error_t cmap_set_uint32(cmap_handle_t handle, const char *key_name,
uint32_t value);
cs_error_t cmap_set_int64(cmap_handle_t handle, const char *key_name,
int64_t value);
cs_error_t cmap_set_uint64(cmap_handle_t handle, const char *key_name,
uint64_t value);
cs_error_t cmap_set_float(cmap_handle_t handle, const char *key_name,
float value);
cs_error_t cmap_set_double(cmap_handle_t handle, const char *key_name,
double value);
cs_error_t cmap_set_string(cmap_handle_t handle, const char *key_name,
const char *value);
π DESCRIPTION π
so the cmap_set function is the one that stores a key inside cmap. simple. elegant. she serves. β¨
let's break down her little ensemble:
handleβ this is your connection to the CMAP database, and you got it by callingcmap_initialize(3). no handle, no entry, periodt.key_nameβ the name of the key you're setting a value for. and bestie, she has rules: the key name is limited by a minimal length (CMAP_KEYNAME_MINLEN, currently3) and a maximal length (CMAP_KEYNAME_MAXLEN, currently255). also, the key can contain only a limited set of characters, expressed by this regexp:[a-zA-Z0-9._-/:]*. that's the whole guest list, nobody else gets in πvalueβ a pointer to the allocated data that will be stored inside CMAP. yes, allocated. we love a responsible memory moment.value_lenβ the length ofvalue, measured in number of bytes. byte count, not vibes count.typeβ the last parameter, and she tells CMAP what kind of value this is. it may be one of:CMAP_VALUETYPE_INT8β 8-bit signed integerCMAP_VALUETYPE_UINT8β 8-bit unsigned integerCMAP_VALUETYPE_INT16β 16-bit signed integerCMAP_VALUETYPE_UINT16β 16-bit unsigned integerCMAP_VALUETYPE_INT32β 32-bit signed integerCMAP_VALUETYPE_UINT32β 32-bit unsigned integerCMAP_VALUETYPE_INT64β 64-bit signed integerCMAP_VALUETYPE_UINT64β 64-bit unsigned integerCMAP_VALUETYPE_FLOATβ Float valueCMAP_VALUETYPE_DOUBLEβ Double valueCMAP_VALUETYPE_STRINGβ C-style stringCMAP_VALUETYPE_BINARYβ Binary data, byte with zero value has no special meaning
π¨ RETURN VALUE π¨
okay so this call returns the CS_OK value if it's successful β that's your green flag, your little win, your slay π
but sometimes she says no, and here's the whole tea:
- If
valueorkey_nameare unspecified,CS_ERR_INVALID_PARAMis returned. like, you have to actually give her something, bestie π - Too short or too long
key_namereturns theCS_ERR_NAME_TOO_LONGerror code. respect the length limits or get gently rejected. - Some of keys may be tagged read-only directly in corosync, and setting such a key will result in a
CS_ERR_ACCESSerror. no means no, that key is not accepting edits today π
π SEE ALSO π
go read these next, iykyk:
and here's the full error-code lineup, in case your call comes back looking a little different:
CS_ERR_TRY_AGAINβ Resource temporarily unavailableCS_ERR_INVALID_PARAMβ Invalid argumentCS_ERR_ACCESSβ Permission deniedCS_ERR_LIBRARYβ The connection failedCS_ERR_INTERRUPTβ System call interrupted by a signalCS_ERR_NOT_SUPPORTEDβ The requested protocol/functionality not supportedCS_ERR_MESSAGE_ERRORβ Incorrect auth message receivedCS_ERR_NO_MEMORYβ Not enough memory to complete the requested task
and that's the whole page, bestie π§ this was the corosync Man Page, dated 23/01/2012 β yes, she's an elder but she still eats π go set some keys, and remember: check your return codes. mwah. π
β¨
π¦ where this page comes from
- debian bookworm: libcmap-dev 3.1.7-1+deb12u2 Β· BSD-3-Clause
- debian trixie: libcmap-dev 3.1.9-2+deb13u1 Β· BSD-3-Clause
- epel 9: corosynclib-devel 3.1.10-0.2.el9.1 Β· BSD-3-Clause
- fedora 43: corosynclib-devel 3.1.10-3.fc43 Β· BSD-3-Clause
- fedora 43: corosynclib-devel 3.1.10-3.fc43 Β· BSD-3-Clause
- fedora 43: corosynclib-devel 3.1.9-5.fc43 Β· BSD-3-Clause
- fedora 43: corosynclib-devel 3.1.9-5.fc43 Β· BSD-3-Clause
- fedora 44: corosynclib-devel 3.1.10-4.fc44 Β· BSD-3-Clause
- fedora 44: corosynclib-devel 3.1.10-4.fc44 Β· BSD-3-Clause
- fedora 44: corosynclib-devel 3.1.10-6.fc44 Β· BSD-3-Clause
- fedora 44: corosynclib-devel 3.1.10-6.fc44 Β· BSD-3-Clause
- nixos 26.05: corosync 3.1.9
- nixpkgs unstable: corosync 3.1.9
- opensuse-leap 16.0: corosync-devel 3.1.9-160000.4.1 Β· BSD-3-Clause
- opensuse-leap 16.0: corosync-devel 3.1.9-160000.4.1 Β· BSD-3-Clause
- opensuse-leap 16.0: corosync-devel 3.1.9-160000.4.1 Β· BSD-3-Clause
- opensuse-leap 16.0: corosync-devel 3.1.9-160000.4.1 Β· BSD-3-Clause
- ubuntu jammy: libcmap-dev 3.1.6-1ubuntu1 Β· BSD-3-Clause
- ubuntu jammy: libcmap-dev 3.1.6-1ubuntu1.2 Β· BSD-3-Clause
- ubuntu noble: libcmap-dev 3.1.7-1ubuntu3 Β· BSD-3-Clause
- ubuntu noble: libcmap-dev 3.1.7-1ubuntu3.2 Β· BSD-3-Clause
- ubuntu questing: libcmap-dev 3.1.9-2ubuntu1
- ubuntu questing: libcmap-dev 3.1.9-2ubuntu1.1
- ubuntu resolute: libcmap-dev 3.1.9-2ubuntu3 Β· BSD-3-Clause
- ubuntu stonking: libcmap-dev 3.1.10-3ubuntu1 Β· BSD-3-Clause
- Copyright (c) 2012 Red Hat, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms