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
0on success π - returns
-ENOMEMβ or-1on 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:
lastlog2(3)ll2_new_context(3)ll2_unref_context(3)ll2_read_all(3)ll2_write_entry(3)ll2_update_login_time(3)ll2_remove_entry(3)ll2_rename_user(3)ll2_import_lastlog(3)
π 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 isLL2_READ_ENTRY(3)from the Programmers Manual, and it shipped withutil-linux 2.41.6dated2026-08-31. that's the whole page, no notes, slay π π
π¦ where this page comes from
- alpine 3.22: util-linux-doc 2.41.6-r1 Β· GPL-3.0-or-later AND GPL-2.0-or-later AND GPL-2.0-only AND GPL-1.0-only AND LGPL-2.1-or-later AND BSD-1-Clause AND BSD-3-Clause AND BSD-4-Clause-UC AND MIT AND Public-Domain
- alpine 3.23: util-linux-doc 2.41.6-r1 Β· GPL-3.0-or-later AND GPL-2.0-or-later AND GPL-2.0-only AND GPL-1.0-only AND LGPL-2.1-or-later AND BSD-1-Clause AND BSD-3-Clause AND BSD-4-Clause-UC AND MIT AND Public-Domain
- fedora 43: liblastlog2-devel 2.41.6-1.fc43 Β· BSD-2-Clause
- fedora 43: liblastlog2-devel 2.41.6-1.fc43 Β· BSD-2-Clause
- fedora 44: liblastlog2-devel 2.41.6-1.fc44 Β· BSD-2-Clause
- fedora 44: liblastlog2-devel 2.41.6-1.fc44 Β· BSD-2-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms