LL2_READ_ALL(3)
π LL2_READ_ALL(3) β like, the Programmers Manual page, but make it make sense β¨
okay bestie, gather round π«Ά this is ll2_read_all(3) from section 3 (that's the Programmers Manual, iykyk), and it's genuinely one of the cutest little functions in liblastlog2. you're gonna love her. no cap.
πΈ NAME πΈ
ll2_read_all β reads all the entries out of the database and hits up your callback function for each one. every single one. she does not skip. π
π SYNOPSIS π
#include <lastlog2.h> int ll2_read_all (struct ll2_context *context, int
(*callback)(const char *user, int64_t ll_time, const char *tty, const
char *rhost, const char *pam_service, const char *cb_error), char
**error);
like yes she's a long one, she's that girl, we respect her π
π¦ DESCRIPTION π¦
so here's the vibe: ll2_read_all reads all the entries from the database that's defined in context, and calls the callback function callback for each entry. one by one. every time. π―
and bestie, if context is NULL? no stress β she'll just take the default database, the one defined in LL2_DEFAULT_DATABASE. slay. π
here's the little example so you can see her in action, and yes i'm keeping it exactly as-is because she's iconic:
char *error = NULL;
const char *user = "root";
static int
callback (const char *res_user, int64_t ll_time, const char *res_tty,
const char *res_rhost, const char *res_service, const char *cb_error)
{
/* returning != 0 if no further entry has to be handled by the callback */
return 0;
}
int ret = ll2_read_all (NULL, callback, &error);
π«Ά quick thing to notice in that comment up there: returning != 0 means no further entry has to be handled by the callback. so your return value is literally the "ok i'm done" button. main character energy.
β RETURN VALUE β
okay so what comes back:
0on success β we love a clean win π-ENOMEMβ or-1on other failure π
error contains an error string if the return value is -1. but heads up, bestie β error is not guaranteed to contain an error string, it could also be NULL. don't come for her, that's just how she is π
also: error should be freed by the caller. that's you. you're the caller. free it. π§
and one more lil detail that matters: if the lastlog2 database does not exist at all, the errno ENOENT is set and you can check for it. periodt. π
π AUTHORS π
Thorsten Kukuk <kukuk@suse.de> β the icon, the legend, the moment π
π SEE ALSO π
go read these next, they're all friends of hers:
lastlog2(3)ll2_new_context(3)ll2_unref_context(3)ll2_write_entry(3)ll2_read_entry(3)ll2_update_login_time(3)ll2_remove_entry(3)ll2_rename_user(3)ll2_import_lastlog(3)
π₯ REPORTING BUGS π₯
found something sus? π for bug reports, use the issue tracker at <https://github.com/util-linux/util-linux/issues>. be nice to the maintainers, they're doing great π
π AVAILABILITY π
the liblastlog2 library is part of the util-linux package since version 2.40. you can download it from the Linux Kernel Archive at <https://www.kernel.org/pub/linux/utils/util-linux/>. go get her β¨
and that's the whole page, bestie β this cutie is page LL2_READ_ALL(3), shipped as part of util-linux 2.41.6, dated 2026-08-31. mwah π go read all the entries, you absolute legend π«Άπ
π¦ 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