Commit Graph

13 Commits

Author SHA1 Message Date
Leah Rowe
e55f7ea081 util/nvmutil: re-add fallback timer rand
for 1989

enabled via ifdef. not enabled by default.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-19 19:11:08 +00:00
Leah Rowe
f8b07dba29 util/nvmutil: rand: use getrandom on newer linux
we still fall back to the old /dev/urandom read
on older linux, via runtime detection (ENOSYS).

getrandom is better, because it guarantees entropy
via blocking, and works even when /dev/urandom
is unavailable.

it has the same practical benefit as arc4random,
which i use on bsd. linux can have arc4random,
but not every linux libc has it, so it's better
to use getrandom on linux.

older linux will fall back to /dev/urandom

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-19 18:34:28 +00:00
Leah Rowe
7c66a788bd util/nvmutil: buffered urandom reads
also generally tidied the code and made
it more robust e.g. retries

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-19 18:04:33 +00:00
Leah Rowe
55f006318a tidy some comments
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-19 16:02:15 +00:00
Leah Rowe
50300f846f util/nvmutil: hardened mkstemp
200 retries, not 100.

and open with O_NOFOLLOW and O_CLOEXEC

check X on mkstemp

support more than 6 X in mkstemp

make PATH_LEN 4096

1024 is a bit low

make default mkstemp length 4096

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-19 08:42:58 +00:00
Leah Rowe
4b35d9ac29 nvmutil: rename lseek_loop to lseek_on_eintr
that's what it does!

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-19 07:48:53 +00:00
Leah Rowe
1fbe972fa7 nvmutil: rename x_i_close to close_on_eintr
that's what it does. waits for eintr to stop firing

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-19 07:45:34 +00:00
Leah Rowe
dcf698b9a0 nvmutil: don't have finite eintr wait
this is technically incorrect. we don't control
faults in the hardware.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-19 07:43:43 +00:00
Leah Rowe
2eee2b5cac nvmutil: rename x_i_fsync to fsync_on_eintr
that's what it does. waits on eintr.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-19 07:41:04 +00:00
Leah Rowe
846cb23585 nvmutil: remove memcmp/memcpy/strrchr/rename
i had this idea in my head of later porting this
to k&r c for fun. but screw it.

compiling on everything since 1989 is enough

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-19 07:37:53 +00:00
Leah Rowe
f1fda8b43e util/nvmutil: tidy up includes
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-19 07:22:03 +00:00
Leah Rowe
2ed8db3adc util/nvmutil: major cleanup
handle init in xstatus()

it's now a singleton design

also tidied up some other code

also removed todo.c. bloat.
will do all those anyway.

too much change. i just kept
touching the code until it
looked good

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-19 04:25:43 +00:00
Leah Rowe
27371af4bc nvmutil: split nvmutil.c into multiple files
this is a big program now. act like it.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-03-18 13:37:06 +00:00