LL2_READ_ENTRY(3)

πŸ’… LL2_READ_ENTRY(3) β€” the liblastlog2 read-one-entry girlies ✨

okay so real talk, this is a page from the Programmers Manual (section 3, the library-call section, iykyk) and it's about ll2_read_entry from lastlog2.h. she reads one entry. one. that's her whole thing and she's iconic for it πŸŽ€


✨ NAME ✨

ll2_read_entry β€” reads one entry from the database and hands it right back to you, no cap πŸ’–


🌸 SYNOPSIS 🌸

#include <lastlog2.h>

int ll2_read_entry (struct ll2_context *context, const char *user,
int64_t *ll_time, char tty, char rhost, char pam_service, char error);

like, literally that's the whole signature bestie, copy it exactly, don't get creative with it 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

so what she does: she reads the first entry from the database (the one defined in context, mwah) for the user user. that's it. one entry. the first one. periodt πŸ’…

and if context is NULL? no worries, she just goes with the default database, the one defined in LL2_DEFAULT_DATABASE. iconic default behaviour honestly 🌈

here's the lil example they give, and yes you're getting it verbatim because code is sacred:

char    *error = NULL;
const   char *user = "root";
int64_t res_time;
char    *res_tty = NULL;
char    *res_rhost = NULL;
char    *res_service = NULL;

int ret = ll2_read_entry (NULL, user, &res_time, &res_tty, &res_rhost, &res_service, &error);

see how she's passing the pointers so the values can come back out? main character energy ngl πŸ‘‘


⭐ RETURN VALUE ⭐

okay so the score-keeping, pay attention:

  • returns 0 on success πŸŽ‰
  • returns -ENOMEM β€” or -1 on other failure πŸ’€

and error? she contains an error string if the return value is -1. but β€” and this is the part you gotta hear β€” error is not guaranteed to contain an error string, it could also be NULL. so vibe check your error pointer before you go trusting it, fr fr πŸ™ˆ

error should be freed by the caller. that's you. you're the caller. free her πŸ’–

and one more: if the lastlog2 database does not exist at all, the errno ENOENT is set and you can check that. very "she's not there, bestie" of the database 😭

the evaluated values come back out through ll_time, tty, rhost and pam_service. those are your little presents 🎁


🌺 AUTHORS 🌺

Thorsten Kukuk <kukuk@suse.de> β€” thank you for your service king 🫢


πŸ’œ SEE ALSO πŸ’œ

go read these next, they're all in the same friend group:


πŸ’€ REPORTING BUGS πŸ’€

found a bug? don't suffer in silence bestie, use the issue tracker: <https://github.com/util-linux/util-linux/issues>. the devs wanna hear from you πŸ“


🧚 AVAILABILITY 🧚

the liblastlog2 library is part of the util-linux package since version 2.40. you can download it from the Linux Kernel Archive: <https://www.kernel.org/pub/linux/utils/util-linux/>. go get her ✨


lowkey reminder: this is LL2_READ_ENTRY(3) from the Programmers Manual, and it shipped with util-linux 2.41.6 dated 2026-08-31. that's the whole page, no notes, slay πŸ’…πŸ’–
πŸ“¦ where this page comes from