RESOURCE_INT_VALUE(9)

πŸ’– RESOURCE_INT_VALUE β€” the kernel dev manual, bestie edition πŸ’–

okay so you're poking around section 9 of the Kernel Developer's Manual and you found resource_int_value, resource_long_value, and resource_string_value?? slay, you're literally in the kernel right now. let's get into it 🫢


✨ NAME ✨

resource_int_value, resource_long_value, resource_string_value β€” get a value from the hints mechanism

no cap, that's the whole job. they fetch. you receive. πŸ’…


🌸 SYNOPSIS 🌸

#include <sys/param.h>
#include <sys/bus.h>

int
resource_int_value(const char *name, int unit, const char *resname,
    int *result);

int
resource_long_value(const char *name, int unit, const char *resname,
    long *result);

int
resource_string_value(const char *name, int unit, const char *resname,
    const char **result);

three little functions, three little vibes: one does int, one does long, one does string. pick your fighter. ⭐


πŸŽ€ DESCRIPTION πŸŽ€

so the way that these functions work is they fetch a value from the "hints" mechanism. that's it, that's the plot. πŸ¦‹

and here's the cast of arguments, one by one:

  • name β€” the name of the device you're getting the resource value from. the main character, honestly. πŸ‘‘
  • unit β€” the unit number of the device. and listen, -1 is special: it's the wildcard entry. so -1 isn't a normal number here, it's a whole mood. 🌈
  • resname β€” the resource name. the thing you're asking about. πŸ“
  • result β€” a pointer to memory where the resource value gets stored. yes bestie, you have to hand it somewhere to live. 🏠

πŸ’« RETURN VALUES πŸ’«

if it worked? 0. iconic. ✨

if it did not work? a non-zero error code comes back at you. not iconic, but informative. 😭


πŸ’€ ERRORS πŸ’€

these functions will fail if:

  • [ENOENT] β€” the resource could not be found. it's giving lost in the sauce. πŸ™ˆ
  • [EFTYPE] β€” inappropriate resource type. wrong vibe, wrong type, hard no. πŸ’…

πŸ”₯ SEE ALSO πŸ”₯

go read those too, iykyk. 🧚


πŸ‘‘ AUTHORS πŸ‘‘

this manual page was written by Warner Losh <imp@FreeBSD.org>. legend behaviour, honestly. πŸ’œ


and that's the whole page, bestie!! it's from the Debian flavour of things, dated March 1, 2001 β€” so yes, this lore is vintage, and it still ate. periodt. πŸŽ€πŸ’–πŸŒΈ

πŸ“¦ where this page comes from