summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
28 hoursutil/nvmutil: don't use /dev/urandomLeah Rowe
too over engineered and cumbersome. the new security in prw() makes it brittle, and i'd rather not move checks outside of it. the fallback rand is random enough. Signed-off-by: Leah Rowe <leah@libreboot.org>
28 hoursutil/nvmutil: fix file checkLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
28 hoursutil/nvmutil: fix cast checkLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
28 hoursutil/nvmutil: more aggressive file checkingLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
28 hoursutil/nvmutil: prevent overflow in rw_file_exactLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
28 hoursutil/nvmutil: verify final offset in pwrite/preadLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
28 hoursutil/nvmutil: check regular file in rw_file_exactLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
29 hoursutil/nvmutil: fix if (PWRITE)Leah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
30 hoursutil/nvmutil: don't check o_append in prwLeah Rowe
slow, per call. prw should be generic. do it just for gbe files, once Signed-off-by: Leah Rowe <leah@libreboot.org>
30 hoursutil/nvmutil: configurable eintr/eagainLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
30 hoursutil/nvmutil: configurable retries/preadLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
30 hoursutil/nvmutil: support real pwrite/preadLeah Rowe
build flag Signed-off-by: Leah Rowe <leah@libreboot.org>
30 hoursutil/nvmutil: better commented I/O functionsLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
31 hoursutil/nvmutil: make eintr/eagain setup clearerLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
38 hoursnvmutil: fix rval in close_filesLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
38 hoursutil/nvmutil: don't check write checksums on partialLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
38 hoursutil/nvmutil: don't recurse err/close_filesLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
39 hoursutil/nvmutil: restore pad before reading to itLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
39 hoursutil/nvmutil: don't show checksum on bad pwriteLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
39 hoursutil/nvmutil: always restore saved errnoLeah Rowe
the last lseek there is only there to reset state, so its errors are irrelevant. Signed-off-by: Leah Rowe <leah@libreboot.org>
40 hoursutil/nvmutil: post-write verification reportLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
41 hoursutil/nvmutil: optimise fsync / write checkLeah Rowe
write all at once, then sync all at once, then verify all at once. this increases the chancce that all data gets written first, in the case of power less, because fsync may take a while on some systems. Signed-off-by: Leah Rowe <leah@libreboot.org>
42 hoursutil/nvmutil: set EIO on bad memcmpLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
42 hoursutil/nvmutil: split up rw_gbe_file_partLeah Rowe
the post-verification stage deserves a function Signed-off-by: Leah Rowe <leah@libreboot.org>
42 hoursutil/nvmutil: detect partial gbe rwLeah Rowe
we already covered this in prw() which is what ultimately gets called, but still. it's logically correct not to check it here. Signed-off-by: Leah Rowe <leah@libreboot.org>
42 hoursutil/nvmutil: verify gbe contents after writingLeah Rowe
read it back and check. sync to disk first. Signed-off-by: Leah Rowe <leah@libreboot.org>
43 hoursutil/nvmutil: consistent typesLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
44 hoursutil/nvmutil: handle zero return in rw_file_exactLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
45 hoursutil/nvmutil: rename lseek_eintrLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
45 hoursutil/nvmutil: fix lseek eintr err checkLeah Rowe
it should be is equal, not not equal Signed-off-by: Leah Rowe <leah@libreboot.org>
45 hoursutil/nvmutil: rename err_eagain() to try_err()Leah Rowe
makes more sense in code Signed-off-by: Leah Rowe <leah@libreboot.org>
45 hoursutil/nvmutil: make EINTR configurable in prw()Leah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
45 hoursutil/nvmutil: tidy up prw()Leah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
45 hoursutil/nvmutil: extra overflow check in prwLeah Rowe
compliant posix systems should never meet this check, but i put it here. spec != implementation Signed-off-by: Leah Rowe <leah@libreboot.org>
45 hoursutil/nvmutil: extra overflow check in prwLeah Rowe
do it at the very end Signed-off-by: Leah Rowe <leah@libreboot.org>
45 hoursutil/nvmutil: handle EAGAIN in prw()Leah Rowe
the cat function can be greatly simplified handle it conditionally, because not all functions should use it Signed-off-by: Leah Rowe <leah@libreboot.org>
46 hoursutil/nvmutil: split up rw_file_exactLeah Rowe
move the gbe-specific parts out of it what remains is a relatively generic function; a very conservative implementation, wrapping around libc functions but with a few additional safety checks. Signed-off-by: Leah Rowe <leah@libreboot.org>
46 hoursutil/nvmutil: add negative off check to prwLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
46 hoursutil/nvmutil: also do libc check on normal ioLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
47 hoursutil/nvmutil: properly reset lseek on errorLeah Rowe
don't return. set r instead. this will fall through and return the same way, but with proper reset. Signed-off-by: Leah Rowe <leah@libreboot.org>
47 hoursutil/nvmutil: move libc check to prw()Leah Rowe
this still gets done from rw_once, but it's generic enough that we want it in our prw() wrapper function. Signed-off-by: Leah Rowe <leah@libreboot.org>
47 hoursutil/nvmutil: remove io_args()Leah Rowe
most of it can be done in rw_file_once truly general checks have been moved to prw(), so that the function is more general purpose. Signed-off-by: Leah Rowe <leah@libreboot.org>
47 hoursutil/nvmutil: move EINTR handle to prw()Leah Rowe
this way, we now have a universal function that is reusable elsewhere, with the same redundancy. the rw_once and rw_exact functions still get this redundancy, through prw Signed-off-by: Leah Rowe <leah@libreboot.org>
47 hoursutil/nvmutil: simplify i/oLeah Rowe
we can just fall through to nrw and decide what function ta call there - either read/write immediately and return, or fall back to the portable positional implementation. this also means we don't have to call io_args in every function, since everything now runs through prw() Signed-off-by: Leah Rowe <leah@libreboot.org>
2 daysutil/nvmutil: cast rnum pointer checkLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2 daysutil/nvmutil: allow ushort to be 32-bitLeah Rowe
no need to limit it here rename ux to uint. no number specified. Signed-off-by: Leah Rowe <leah@libreboot.org>
2 daysutil/nvmutil: fix int assertLeah Rowe
it can be higher than 32-bit, it's fine the current check breaks some newer systems accordingly, u32 becomes ux, x meaning x bits Signed-off-by: Leah Rowe <leah@libreboot.org>
2 daysutil/nvmutil: more assertsLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2 daysutil/nvmutil: nicer typedefsLeah Rowe
now that i'm not using stdint, i can use sane typedef names Signed-off-by: Leah Rowe <leah@libreboot.org>
2 daysutil/nvmutil: remove stdint feature macroLeah Rowe
and remove stdint i don't need it. i typedef these ints myself and i assert their size Signed-off-by: Leah Rowe <leah@libreboot.org>