NAME |SYNOPSIS |DESCRIPTION |RETURN VALUE |NOTES |HISTORY |SEE ALSO |COLOPHON | |
SD_HWDB_NEW(3) sd_hwdb_newSD_HWDB_NEW(3)sd_hwdb_new, sd_hwdb_new_from_path, sd_hwdb_ref, sd_hwdb_unref - Create a new hwdb object and create or destroy references to it
#include <systemd/sd-hwdb.h>int sd_hwdb_new(sd_hwdb **hwdb);int sd_hwdb_new_from_path(const char *path, sd_hwdb **hwdb);sd_hwdb* sd_hwdb_ref(sd_hwdb *hwdb);sd_hwdb* sd_hwdb_unref(sd_hwdb *hwdb);
sd_hwdb_new()creates a new hwdb object to access the binary hwdb database. Upon initialization, the file containing the binary representation of the hardware database is located and opened. The new object is returned inhwdb.sd_hwdb_new_from_path()may be used to specify the path from which the binary hardware database should be opened. Thehwdb object is reference counted.sd_hwdb_ref()andsd_hwdb_unref()may be used to get a new reference or destroy an existing reference to an object. The caller must dispose of the reference acquired withsd_hwdb_new()by callingsd_hwdb_unref() when done with the object. Usesd_hwdb_seek(3),sd_hwdb_get(3), andsd_hwdb_enumerate(3) to access entries.
On success,sd_hwdb_new()andsd_hwdb_new_from_path()return a non-negative integer. On failure, a negative errno-style error code is returned.sd_hwdb_ref()always returns the argument.sd_hwdb_unref()always returnsNULL.Errors Returned errors may indicate the following problems:-ENOENT The binary hardware database file could not be located. Seesystemd-hwdb(8) for more information. Added in version 246.-EINVAL The located binary hardware database file is in an incompatible format. Added in version 246.-ENOMEM Memory allocation failed. Added in version 246.
Functions described here are available as a shared library, which can be compiled against and linked to with thelibsystemd pkg-config(1) file. The code described here usesgetenv(3), which is declared to be not multi-thread-safe. This means that the code calling the functions described here must not callsetenv(3) from a parallel thread. It is recommended to only do calls tosetenv()from an early phase of the program when no other threads have been started.
sd_hwdb_new(),sd_hwdb_ref(), andsd_hwdb_unref()were added in version 246.sd_hwdb_new_from_path()was added in version 252.
systemd(1),systemd-udevd.service(8),sd-hwdb(3),systemd-hwdb(8)
This page is part of thesystemd (systemd system and service manager) project. Information about the project can be found at ⟨http://www.freedesktop.org/wiki/Software/systemd⟩. If you have a bug report for this manual page, see ⟨http://www.freedesktop.org/wiki/Software/systemd/#bugreports⟩. This page was obtained from the project's upstream Git repository ⟨https://github.com/systemd/systemd.git⟩ on 2025-08-11. (At that time, the date of the most recent commit that was found in the repository was 2025-08-11.) If you discover any rendering problems in this HTML version of the page, or you believe there is a better or more up-to-date source for the page, or you have corrections or improvements to the information in this COLOPHON (which isnot part of the original manual page), send a mail to man-pages@man7.orgsystemd 258~rc2SD_HWDB_NEW(3)Pages that refer to this page:sd-hwdb(3), sd_hwdb_get(3), systemd.directives(7), systemd.index(7)
HTML rendering created 2025-09-06 byMichael Kerrisk, author ofThe Linux Programming Interface. For details of in-depthLinux/UNIX system programming training courses that I teach, lookhere. Hosting byjambit GmbH. | ![]() |