summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
11 hoursutil/nvmutil: further clean up decode_pulse()Leah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
11 hoursutil/spkmodem-recv: tidy up frame decodingLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
11 hoursutil/spkmodem-recv: handle fread errorsLeah Rowe
also handle EOF condition and exit cleanly. don't use dirty feof. Signed-off-by: Leah Rowe <leah@libreboot.org>
11 hoursutil/spkmodem-recv: fix getopt prototypeLeah Rowe
i use -pedantic and std=c90 also add the define Signed-off-by: Leah Rowe <leah@libreboot.org>
12 hoursremoved some unnecessary thingsLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
12 hoursanother fixLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
12 hourstiny fixLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
12 hoursutil/spkmodem-recv: portability and code cleanupLeah Rowe
borrowing recent improvements from nvmutil Signed-off-by: Leah Rowe <leah@libreboot.org>
40 hoursutil/nvmutil: re-use do_rw() from prw()Leah Rowe
using a special leah-only technique Signed-off-by: Leah Rowe <leah@libreboot.org>
41 hoursutil/nvmutil: add missing sanitization testsLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
42 hoursutil/nvmutil: properly use rc in rw_File_exactLeah Rowe
subtract and add iteratively Signed-off-by: Leah Rowe <leah@libreboot.org>
42 hoursutil/nvmutil: tidy up gbe_cat_buf()Leah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
42 hoursutil/nvmutil: split up rw_file_exact()Leah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
42 hoursutil/nvmutil: update some commentsLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
42 hoursutil/nvmutil: re-add EINTR loop check on rwLeah Rowe
accidentally removed it during re-factor Signed-off-by: Leah Rowe <leah@libreboot.org>
43 hoursutil/nvmutil: rename set_err for code clarityLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
43 hoursutil/nvmutil: skip errno check in mainLeah Rowe
skip it if there is a valid checksum, to mitigate erroneous errno state upon exit from run_cmd(), because we can assume by this point that we are in fact ready to write at this point. the check at the end still exists, which will catch any error set by write, and any error set before that. this fixes a weird warning on cmd_dump. Signed-off-by: Leah Rowe <leah@libreboot.org>
43 hoursutil/nvmutil: don't reset errno in rw_file_exactLeah Rowe
reset it in callers instead. this means that the main function is more generalised. we know by the time we exit that there is no error. Signed-off-by: Leah Rowe <leah@libreboot.org>
43 hoursutil/nvmutil: reset errno in gbe_catLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
43 hoursutil/nvmutil: reset errno in gbe_cat_bufLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
43 hoursutil/nvmutil: fix bad loop in command sanitizerLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
43 hoursutil/nvmutil: use set_err where appropriateLeah Rowe
in the new file i/o functions, my own setting of errno should be done with set_err. this avoids clobbering what the real libc set. Signed-off-by: Leah Rowe <leah@libreboot.org>
43 hoursutil/nvmutil: properly set errno everywhereLeah Rowe
i set it to ecanceled before. now i set it more appropriately, for each type of error. where a real syscall was called, or my file i/o functions are used, err() is called with errno itself as input, to avoid clobbering real errno. Signed-off-by: Leah Rowe <leah@libreboot.org>
43 hoursutil/nvmutil: fix /dev/random fallbackLeah Rowe
i forgot to set urandom_fd Signed-off-by: Leah Rowe <leah@libreboot.org>
43 hoursRevert "util/nvmutil: fix check in command sanitizer"Leah Rowe
This reverts commit b28076557b4c12965c15d6fad7c06e34c67f7921. nope. the check was already correct before.
43 hoursutil/nvmutil: don't use bad pointer cast in prwLeah Rowe
in practise it's ok, but some compilers might complain. all this change costs is a bit of branching inside a loop, but compilers will sort that out. Signed-off-by: Leah Rowe <leah@libreboot.org>
43 hoursutil/nvmutil: fix check in command sanitizerLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
43 hoursutil/nvmutil: use EINVAL in command sanitizenLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
43 hoursutil/nvmutil: don't use xopen() for urandomLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
43 hoursutil/nvmutil: conservative use of errnoLeah Rowe
only use errno itself as the value Signed-off-by: Leah Rowe <leah@libreboot.org>
44 hoursutil/nvmutil: re-try /dev/[u]random on EAGAINLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
44 hoursutil/nvmutil: Make rw_file_exact an ssize_tLeah Rowe
Use its return value. Don't exit from the function, but actually treat it like a real syscall. Signed-off-by: Leah Rowe <leah@libreboot.org>
44 hoursutil/nvmutil: use O_NONBLOCK on /dev/[u]randomLeah Rowe
on some systems, it is otherwise blocking, but blocking can be disabled, making access more reliable. Signed-off-by: Leah Rowe <leah@libreboot.org>
44 hoursutil/nvmutil: fix possible overflow: gbe_x_offsetLeah Rowe
preventative fix, since the values are currently quite tiny. this new check is the same, but goes the other way to eliminate overflow. Signed-off-by: Leah Rowe <leah@libreboot.org>
45 hoursutil/nvmutil: reset rw_file_exact errno on EINTRLeah Rowe
this is essentially what it already did, but it wasn't explicitly stated. now it's clearer. Signed-off-by: Leah Rowe <leah@libreboot.org>
45 hoursutil/nvmutil: comment prw()Leah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
45 hoursutil/nvmutil: better SSIZE_MAX defineLeah Rowe
the old one assumes that ssize_t is signed size_t, which let's face it, is always true in practise, but not actually guaranteed! so now i'm using one that's even more pedantic. Signed-off-by: Leah Rowe <leah@libreboot.org>
45 hoursutil/nvmutil: define EXIT_FAILURE/SUCCESSLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
45 hoursutil/nvmutil: more sensible errno initLeah Rowe
just use errno itself as input to err if unset, it's set to ECANCELED anyway i really should rewrite the error handling to not use errno at some point. it's a bit unreliable, on some unix systems. Signed-off-by: Leah Rowe <leah@libreboot.org>
45 hoursutil/nvmutil: proper errno status on prw()Leah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
46 hoursutil/nvmutil: reset errno if EINTR on lseekLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
47 hoursutil/nvmutil: stricter errno on prw()Leah Rowe
we want the first error to be the one shown, when returning negative Signed-off-by: Leah Rowe <leah@libreboot.org>
48 hoursutil/nvmutil: fix printf c89/c90 specifiersLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
48 hoursutil/nvmutil: reset part_validLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
48 hoursutil/nvmutil: restore errno if lseek resets itLeah Rowe
if it resets it on success, that is! theoretically possible. we must preserve errno. normally i'm a bit more casual about it, but this function is replicating libc, so i must be strict Signed-off-by: Leah Rowe <leah@libreboot.org>
48 hoursutil/nvmutil: fix another printf specifierLeah Rowe
ditto to last commit Signed-off-by: Leah Rowe <leah@libreboot.org>
48 hoursutil/nvmutil: fix bad print specifier (c90)Leah Rowe
size_t may be unsigned long long, but lu is for unsigned long. the integer is small enough that we don't need to worry, so let's just cast it accordingly (inside err) Signed-off-by: Leah Rowe <leah@libreboot.org>
48 hoursutil/nvmutil: only inc num_invalid on bad checksumLeah Rowe
this fixes a regression that i introduced Signed-off-by: Leah Rowe <leah@libreboot.org>
48 hoursutil/nvmutil: restore errno on failed offset restoreLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
48 hoursutil/nvmutil: don't leave part_valid untouchedLeah Rowe
always set it. the current logic only sets it if valid, but invalid doesn't, relying on global initialisation. this check sets it explicitly. Signed-off-by: Leah Rowe <leah@libreboot.org>