basic: update in_first_boot() to return an error

This commit tweaks the in_first_boot() code to make it
a proper shared helper. It tweaks the comments about the
caching policy. This is important because while this is
simialr to `in_initrd()` there is a suble difference:
we never cache the result of access() because other parts
of systemd will use this file to signal if anything about
firstboot changes.

This also tweaks it to return an int instead of a bool.
So any error is returned as -errno. This allows other
parts of systemd (like the random-seed) that need to make
decisions about "unknown" first-boot state.

This also means that the consumers need to get updated
and we can now also use the new helper in random-seed-tool.c
and have only a single helper to check for first-boot.
This commit is contained in:
Michael Vogt
2026-07-09 16:48:26 +02:00
parent eb8227c671
commit 9d947d0a2a
5 changed files with 26 additions and 22 deletions
+1 -1
View File
@@ -6,4 +6,4 @@
bool in_initrd(void);
void in_initrd_force(bool value);
bool in_first_boot(void);
int in_first_boot(void);