dmi_file_read

Synopsis

#include <opendmi/utils/file.h>

ssize_t dmi_file_read(int fd, dmi_data_t *data, off_t offset, size_t size);

Description

The dmi_file_read function performs a full read by looping until all requested bytes are read or end-of-file is reached. It retries automatically if interrupted by a signal (EINTR). Fewer than size bytes are returned only if EOF is encountered before the read is complete.

Parameters

fd

Open file descriptor to read from.

data

Buffer that receives the data; must be at least size bytes.

offset

Starting offset, or -1 to read from the current position.

size

Number of bytes to read.

Return value

Returns the total number of bytes read (may be less than size at EOF), 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.