LL2_WRITE_ENTRY(3)

LL2_WRITE_ENTRY(3) πŸ’–

okay bestie, so this one is from the Programmers Manual β€” it's a liblastlog2 function and honestly it's giving "tiny function, big responsibility" energy. Sit down, grab a strawberry πŸ“, and let's get into it.


✨ NAME ✨

ll2_write_entry β€” literally writes a brand new entry into the database. slay.


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <lastlog2.h>

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

🌸 DESCRIPTION 🌸

So what it does is, it writes a new entry into the database, and that database is the one defined in context. and like β€” important detail β€” if context is NULL, then the default database gets used instead, the one defined in LL2_DEFAULT_DATABASE. no cap, that's the whole vibe check. 🫢

here's a little example of it in the wild, look at her go:

time_t login_time = time(0); // Get the system time
char   *error = NULL;
const  char *user = "root";

int ret = ll2_write_entry (NULL, user, login_time, "pts/0",
                            "192.168.122.1", NULL, &error);

and pam_service? that's the service or instance name that generated the entry β€” she's optional, so no pressure bestie. πŸ’…


πŸ”₯ RETURN VALUE πŸ”₯

  • Returns 0 on success β€” we love a clean win ✨
  • Returns -ENOMEM or -1 on other failure 😭
  • error contains an error string if the return value is -1
  • but like, careful β€” error is not guaranteed to contain an error string, it could also be NULL. so don't come for her if she's empty. πŸ™ˆ
  • error should be freed by the caller. yes, that's you. that's your job now. πŸ’€

πŸ‘‘ AUTHORS πŸ‘‘

Thorsten Kukuk <kukuk@suse.de> β€” an icon, honestly.


🌈 SEE ALSO 🌈

the whole friend group, fr fr πŸŽ€


🧚 REPORTING BUGS 🧚

got a bug to report? use the issue tracker <https://github.com/util-linux/util-linux/issues>. we don't do drama in the DMs, we do it in the tracker. πŸ’–


⭐ AVAILABILITY ⭐

The liblastlog2 library is part of the util-linux package since version 2.40. and you can download it from the Linux Kernel Archive <https://www.kernel.org/pub/linux/utils/util-linux/>. it's giving open source royalty, periodt. πŸ‘‘


kay that's the whole page bestie, go write some entries. mwah πŸ’œ

this little number is from util-linux 2.41.6, dated 2026-08-31 β€” like and subscribe, see you in the next manpage πŸ¦‹

πŸ“¦ where this page comes from