LLAPI_PARAM_GET_VALUE(3)

NAME
llapi_param_get_value - read parameter files for Lustre to a buffer

SYNOPSIS
#include <lustre/lustreapi.h>

int llapi_param_get_value(const char *path, char **buf, size_t *buflen);

DESCRIPTION
The llapi_param_get_value() function reads the contents of files in procfs, sysfs, etc. into a buffer. If the buffer is preallocated, it will have a fixed size. If the buffer is not preallocated, it will be automatically sized to fit the contents of the file. There is also an option to query the size of a file.

The behavior of llapi_param_get_value() depends on the value of buf. If buf is NULL, then the contents of path will not be saved into *buf, but the number of bytes needed to hold the file will be stored in buflen. This size will include the space needed for the NUL terminating byte. However, the size of the file can change because it is dynamically generated. This means that it's possible for the file size to increase which will cause the value stored in buflen to still not be large enough when used in a subsequent call.

If buf is not NULL but *buf is NULL, then *buf will point to an automatically allocated buffer that will hold the contents of path, and buflen will hold the number of bytes written excluding the NUL terminating byte.

If both buf and *buf are not NULL, then buf is assumed to be a pre-allocated buffer of *buflen size. The files contents will be put into *buf and the number of bytes written to *buflen, excluding the NUL terminating byte. In the case that buflen is too small to hold the NUL-terminated contents of the file, buflen will contain a suggested size for *buf. This suggested size includes the NUL terminating byte, just as in the case where buf is NULL.

RETURN VALUES

0   on success

-ve error code on failure and sets errno appropriately.

ERRORS

-EINVAL
    if either path or buflen are NULL.

-EOVERFLOW
    if buf and *buf are not NULL, and the pre-allocated buffer is too small.

-ENOMEM
    if buf is not NULL, but the buffer allocation failed

AVAILABILITY
llapi_param_get_value() is part of the lustre(7) user application interface library since release 2.14.0

SEE ALSO
llapi_get_param_paths(3), lustreapi(7), lctl-get_param(8)