UDEV_LIST_ENTRY(3)

πŸ’… UDEV_LIST_ENTRY(3) β€” like, the whole udev list situation πŸ¦‹

okay so this is the udev_list_entry(3) page bestie, and it's literally all about iterating and accessing udev lists ✨ no cap, that's the entire vibe. Get comfy, we're reading lists together 🫢


🌸 NAME 🌸

udev_list_entry, udev_list_entry_get_next, udev_list_entry_get_by_name, udev_list_entry_get_name, udev_list_entry_get_value β€” iterate and access udev lists πŸ’–

The way that this is a whole little friend group of functions whose entire job is walking through udev lists and grabbing the stuff inside. Iconic behavior honestly πŸ‘‘

✨ SYNOPSIS ✨

#include <libudev.h>

struct udev_list_entry *udev_list_entry_get_next(struct udev_list_entry *list_entry);

struct udev_list_entry *udev_list_entry_get_by_name(struct udev_list_entry *list_entry,
                                                    const char *name);

const char *udev_list_entry_get_name(struct udev_list_entry *list_entry);

const char *udev_list_entry_get_value(struct udev_list_entry *list_entry);

like, #include <libudev.h> first obviously, that's the entry fee to the party πŸŽ€

πŸ₯Ί RETURN VALUE πŸ₯Ί

okay listen up because this part actually matters:

  • On success, udev_list_entry_get_next() and udev_list_entry_get_by_name() return a pointer to the requested list entry πŸ”₯
  • If no such entry can be found, or on failure, NULL is returned πŸ’€ β€” so like, please check for NULL, bestie, don't just rawdog the dereference πŸ™ˆ

and for the other two:

  • On success, udev_list_entry_get_name() and udev_list_entry_get_value() return a pointer to a constant string representing the requested value ⭐
  • the string is bound to the lifetime of the list entry itself β€” so it's not yours to keep, it lives and dies with the entry, no cap 😭
  • On failure, NULL is returned
fr fr, that lifetime thing is the sneaky part. The string is bound to the lifetime of the list entry itself. Don't go stashing that pointer somewhere and expecting it to be valid forever, because it won't be 🫠

πŸ¦‹ HISTORY πŸ¦‹

udev_list_entry_get_next(), udev_list_entry_get_by_name(), udev_list_entry_get_name(), and udev_list_entry_get_value() were all added in version 221 ✨ that's their origin story, their main character moment, their debut πŸŽ€

πŸ’œ SEE ALSO πŸ’œ

go touch these other pages, they're all besties with this one:


and that's the whole page, you ate that πŸ’…βœ¨

this little gem is from systemd 261.3 and it's the UDEV_LIST_ENTRY(3) page β€” go forth and iterate responsibly, bestie πŸ“πŸ§šπŸ’œ

πŸ“¦ where this page comes from