dmi_file_write

Synopsis

#include <opendmi/utils/file.h>

ssize_t dmi_file_write(int fd, const dmi_data_t *data, size_t size);

Description

The dmi_file_write function performs a full write by looping until all requested bytes are written or a zero-length write is returned. It retries automatically if interrupted by a signal (EINTR). Fewer than size bytes are returned only if the underlying write(2) call returns zero before all bytes are written.

Parameters

fd

Open file descriptor to write to.

data

Buffer containing the data to write; must be at least size bytes.

size

Number of bytes to write.

Return value

Returns the total number of bytes written (may be less than size if a zero-length write occurs), or -1 on error with errno set accordingly.

A missing argument is not an error of the system: -1 is returned, and errno is left as it was.

Errors

DMI_ERROR_ARGUMENT_NULL

data is nullptr. The error reaches no error queue, since the function takes no context to hold it.