LLAPI_PARAM_GET_VALUE(3)

πŸ“¦ version 2.17.58, in ubuntu stonking

✨ LLAPI_PARAM_GET_VALUE ✨

okay bestie, welcome to the Lustre Library Functions corner of the manual, page 3, and today's main character is llapi_param_get_value πŸ’…


πŸŽ€ NAME πŸŽ€

llapi_param_get_value β€” read parameter files for Lustre into a buffer πŸ¦‹


🌸 SYNOPSIS 🌸

#include <lustre/lustreapi.h>

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

πŸ’– DESCRIPTION πŸ’–

So. The llapi_param_get_value() function reads the contents of files in procfs, sysfs, etc. into a buffer. That's the whole vibe, that's the gig 🫢

Now, if the buffer is preallocated, it's gonna have a fixed size β€” locked in, no growth spurts. But if the buffer is not preallocated, it'll be automatically sized to fit the contents of the file. Iconic behaviour fr fr. There's also an option to just query the size of a file, if that's all you're after πŸ‘‘

The behavior of llapi_param_get_value() lowkey depends entirely on what you pass as buf. Let's break it down, because the way this function triages your arguments is genuinely giving main character energy:

  • 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 includes the space needed for the NUL terminating byte. BUT ⚠️ β€” and this is the plot twist β€” the size of the file can change, because it's dynamically generated. Which means it's totally possible for the file size to increase, and that'll cause the value stored in buflen to still not be large enough when you use it in a subsequent call. No cap, that's real.
  • 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. She's independent, she allocates for herself πŸ’…
  • If both buf and *buf are not NULL, then buf is assumed to be a pre-allocated buffer of *buflen size. The file's contents will be put into *buf, and the number of bytes written goes into *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 β€” and that suggested size includes the NUL terminating byte, just like in the case where buf is NULL. She's helpful like that πŸ₯°

πŸ”₯ RETURN VALUES πŸ”₯

  • 0 β€” on success πŸŽ‰ slay
  • -ve β€” error code on failure, and sets errno appropriately πŸ’€

πŸ’€ ERRORS πŸ’€

  • -EINVAL β€” if either path or buflen are NULL. bestie. you gotta pass something.
  • -EOVERFLOW β€” if buf and *buf are not NULL, and the pre-allocated buffer is too small. she literally cannot fit 😭
  • -ENOMEM β€” if buf is not NULL, but the buffer allocation failed. the mallocs said no πŸ™ˆ

🌈 AVAILABILITY 🌈

llapi_param_get_value() is part of the lustre(7) user application interface library since release 2.14.0 ⭐ it's been around, she's established, she's a veteran πŸ‘‘


πŸ¦‹ SEE ALSO πŸ¦‹


okay that's the whole page bestie, go forth and read your parameter files responsibly πŸ’œ

Lustre User API β€” dated 2024-08-27 β€” and that's LLAPI_PARAM_GET_VALUE(3), periodt βœ¨πŸ’…πŸŽ€

πŸ“¦ where this page comes from