dmi_load

Synopsis

#include <opendmi/context.h>

bool dmi_load(dmi_context_t *context, const char *path);

Description

The dmi_load function reads a dump of SMBIOS data into a closed context, and decodes it the way dmi_open decodes the data of the system, so that the data of another machine is read on any system and without privileges.

Dump files are the ones dmi_save and opendmi dump write, and are interchangeable with the ones dmidecode --dump-bin writes and dmidecode --from-dump reads: the entry point, padded with zeros, followed by the table.

A context which fails to load the dump is left closed, with the errors telling why in its error queue. A context which is open already is left as it is.

Parameters

context

Context to open, which is required to be closed.

path

Path to the dump file.

Return value

Returns true if the dump has been loaded, and false otherwise.

Errors

DMI_ERROR_ARGUMENT_NULL

Path is nullptr.

DMI_ERROR_STATE_INVALID

Context is open already.

DMI_ERROR_FILE_STAT_FAILED

Dump file does not exist, or cannot be examined.

DMI_ERROR_FILE_OPEN_FAILED

Dump file cannot be opened.

DMI_ERROR_DUMP_INVALID

File is not a dump of SMBIOS data: it is not a regular file, or it is larger than an entry point followed by a table of DMI_TABLE_MAX_SIZE bytes, or it does not start with an entry point.

DMI_ERROR_BACKEND_OPEN_FAILED

Dump file cannot be read.

DMI_ERROR_ENTITY_TRUNCATED

Table area is empty, or a structure runs past its end.

DMI_ERROR_FIRMWARE_INFO_NOT_FOUND

Table holds no platform firmware information structure, in the strict mode only.

DMI_ERROR_MODULE_CONFLICT

Specifications of the modules enabled with dmi_add_extension, which apply to the platform, have the same type.

DMI_ERROR_OUT_OF_MEMORY

Memory is exhausted.

DMI_ERROR_CONTEXT_OPEN_FAILED

Context cannot be opened. Raised last on every failure but the one of a context which is open already, after the errors telling why.

Examples

dmi_context_t *context = dmi_create(DMI_CONTEXT_FLAG_LINK);

if (dmi_load(context, "smbios.bin")) {
    ...
}

dmi_destroy(context);