---
name: "sd_bus_error_add_map"
section: "3"
platform: "linux"
package: "systemd-libs"
version: "262.1-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/sd_bus_error_add_map"
---

# sd\_bus\_error\_add\_map(3)

Additional sd-dbus error mappings

## NAME

sd\_bus\_error\_add\_map, sd\_bus\_error\_map, SD\_BUS\_ERROR\_MAP, SD\_BUS\_ERROR\_END - Additional sd-dbus error mappings

## SYNOPSIS

```
#include <systemd/sd-bus.h>
```

```
typedef struct {
        const char *name;
        int code;
        ...
} sd_bus_error_map;
```

```
SD_BUS_ERROR_MAP(name, code)
```

```
SD_BUS_ERROR_MAP_END
```

**int sd\_bus\_error\_add\_map(const sd\_bus\_error\_map \****map***);**

## DESCRIPTION

**The** **sd\_bus\_error\_add\_map()** call may be used to register additional mappings for converting D-Bus errors to Linux *errno*-style errors. The mappings defined with this call are consulted by calls such as [**sd\_bus\_error\_set**(3)](/sd_bus_error_set/3.md) or [**sd\_bus\_error\_get\_errno**(3)](/sd_bus_error_get_errno/3.md). By default, a number of generic, standardized mappings are known, as documented in [**sd-bus-errors**(3)](/sd-bus-errors/3.md). Use this call to add further, application-specific mappings.

The function takes a pointer to an array of sd\_bus\_error\_map structures. A reference to the specified array is added to the lookup tables for error mappings. Note that the structure is not copied, and that it is hence essential that the array stays available and constant during the entire remaining runtime of the process.

The mapping array should be put together with a series of **SD\_BUS\_ERROR\_MAP()** macro invocations that take a literal name string and a (positive) *errno*-style error number. The last entry of the array should be an invocation of the **SD\_BUS\_ERROR\_MAP\_END** macro. The array should not be put together without use of these two macros.

Note that the call is idempotent: it is safe to invoke it multiple times with the parameter, which will only add the passed mapping array once.

Note that the memory allocated by this call is not intended to be freed during the lifetime of the process. It should not be freed explicitly.

## RETURN VALUE

**sd\_bus\_error\_add\_map()** returns a positive value when the new array was added to the lookup tables. It returns zero when the same array was already added before. On error, a negative *errno*-style error code is returned. See below for known error codes.

### Errors

Returned errors may indicate the following problems:

**-EINVAL**

The specified mapping array is invalid.

**-ENOMEM**

Memory allocation failed.

## NOTES

Functions described here are available as a shared library, which can be compiled against and linked to with the **libsystemd** [**pkg-config**(1)](/pkg-config/1.md) file.

All functions listed here are thread-agnostic and only a single thread may operate on a given object at any given time. Different threads may access the same object at different times. Multiple independent objects may be used from different threads in parallel.

The code described here uses [**getenv**(3)](/getenv/3.md), which is declared to be not multi-thread-safe. This means that the code calling the functions described here must not call [**setenv**(3)](/setenv/3.md) from a parallel thread. It is recommended to only do calls to **setenv()** from an early phase of the program when no other threads have been started.

## HISTORY

**sd\_bus\_error\_add\_map()** was added in version 221.

## SEE ALSO

[**systemd**(1)](/systemd/1.md), [**sd-bus**(3)](/sd-bus/3.md), [**sd\_bus\_error**(3)](/sd_bus_error/3.md), [**sd-bus-errors**(3)](/sd-bus-errors/3.md), [**errno**(3)](/errno/3.md), [**strerror\_r**(3)](/strerror_r/3.md)
