---
name: "cmap_set"
section: "3"
platform: "linux"
package: "libcmap-dev"
version: "3.1.9-2+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/cmap_set"
---

# cmap\_set(3)

Store value in CMAP

## NAME

cmap\_set - Store value in CMAP

## SYNOPSIS

**#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

**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

The **cmap\_set** function is used to store key inside cmap. The *handle* argument is connection to CMAP database obtained by calling **[cmap\_initialize(3)](/cmap_initialize/3.md)** function. *key\_name* is name of key to set value. Key name is limited by minimal (CMAP\_KEYNAME\_MINLEN, currently 3) and maximal (CMAP\_KEYNAME\_MAXLEN, currently 255) length. Also key can contain only limited set of characters expressed by regexp \[a-zA-Z0-9.\_-/:\]\*. *value* is pointer to allocated data which will be stored inside CMAP. Length of value (number of bytes) is supplied as *value\_len* parameter. Last parameter is *type* which gives type of value. It may be one of:

**CMAP\_VALUETYPE\_INT8** - 8-bit signed integer

**CMAP\_VALUETYPE\_UINT8** - 8-bit unsigned integer

**CMAP\_VALUETYPE\_INT16** - 16-bit signed integer

**CMAP\_VALUETYPE\_UINT16** - 16-bit unsigned integer

**CMAP\_VALUETYPE\_INT32** - 32-bit signed integer

**CMAP\_VALUETYPE\_UINT32** - 32-bit unsigned integer

**CMAP\_VALUETYPE\_INT64** - 64-bit signed integer

**CMAP\_VALUETYPE\_UINT64** - 64-bit unsigned integer

**CMAP\_VALUETYPE\_FLOAT** - Float value

**CMAP\_VALUETYPE\_DOUBLE** - Double value

**CMAP\_VALUETYPE\_STRING** - C-style string

**CMAP\_VALUETYPE\_BINARY** - Binary data, byte with zero value has no special meaning

## RETURN VALUE

This call returns the CS\_OK value if successful. If value or key\_name are unspecified, CS\_ERR\_INVALID\_PARAM is returned. Too short or too long key\_name returns CS\_ERR\_NAME\_TOO\_LONG error code. Some of keys may be tagged read-only directly in corosync and setting such key will result in CS\_ERR\_ACCESS error.

## SEE ALSO

[**cmap\_get**(3)](/cmap_get/3.md), [**cmap\_initialize**(3)](/cmap_initialize/3.md), [**cmap\_overview**(3)](/cmap_overview/3.md)

**CS\_ERR\_TRY\_AGAIN** Resource temporarily unavailable

**CS\_ERR\_INVALID\_PARAM** Invalid argument

**CS\_ERR\_ACCESS** Permission denied

**CS\_ERR\_LIBRARY** The connection failed

**CS\_ERR\_INTERRUPT** System call interrupted by a signal

**CS\_ERR\_NOT\_SUPPORTED** The requested protocol/functionality not supported

**CS\_ERR\_MESSAGE\_ERROR** Incorrect auth message received

**CS\_ERR\_NO\_MEMORY** Not enough memory to complete the requested task
