summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
8 hoursutil/nvmutil: use enum for command indexLeah Rowe
if the enum is messed up, this patch also prevents that. this is not to catch a runtime error, but to intentionally trip up a maintainer that screws up, prompting them to fix their future mistake. we previously used a pointer directly, without even checking index/NULL - that too is now covered, except that we now use an indice for command[] and execute the command from that, rather than directly declaring a pointer. Signed-off-by: Leah Rowe <leah@libreboot.org>
9 hoursutil/nvmutil: call it nvmutil in makefileLeah Rowe
a package manager by the name "nvm" exists, as i discovered. this is a courtesy to them. Signed-off-by: Leah Rowe <leah@libreboot.org>
9 hoursutil/nvmutil: print mac before settingLeah Rowe
this way, if a user does e.g. ./nvm gbe.bin bullshit It will say: bullshit Right now, it just says invalid length. This means if the user wanted to type e.g. ./nvm gbe.bin copy 0 but they typed: ./nvm gbe.bin coyp 0 Now it will tell them that it's trying to set the MAC address "coyp". This is because if an invalid command is given, it's treated as a MAC address instead. This is by design, to allow e.g. ./nvm gbe.bin xx:1x:1x:xx:xx:xx Signed-off-by: Leah Rowe <leah@libreboot.org>
10 hoursutil/nvmutil: store invert in command structLeah Rowe
handle inversion directly there Signed-off-by: Leah Rowe <leah@libreboot.org>
10 hoursutil/nvmutil: make cmd an integerLeah Rowe
point directly to the command table. run through an intermediary function to check bounds, for safety. this will allow me to then set things like the invert config directly in that struct. Signed-off-by: Leah Rowe <leah@libreboot.org>
20 hoursutil/clarity: name the gbe file half sizeLeah Rowe
we need only declare it in the centralised gbe_file_offset function, which determines whether a write to the gbe file falls specifically within the 4KB range that is the gbe part. it is always half of the gbe file size, and then the first 4KB of each half stores the gbe part. Signed-off-by: Leah Rowe <leah@libreboot.org>
21 hoursutil/nvmutil: only have newrandom on linux/oldunixLeah Rowe
these variables newrandom and oldrandom are unused on BSD systems, and their unused status may trigger warnings on some compilers. Signed-off-by: Leah Rowe <leah@libreboot.org>
24 hoursutil/nvmutil: tidy up open_dev_urandomLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
31 hoursutil/nvmutil: correct type on hextonum()Leah Rowe
use uint16_t instead Signed-off-by: Leah Rowe <leah@libreboot.org>
31 hoursutil/nvmutil: fix a commentLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
31 hoursutil/nvmutil: fix a commentLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
31 hoursutil/nvmutil: unambiguous sign conv_argv_part_numLeah Rowe
yeah, do the verification manually, don't convert to size_t. this avoids a bunch of theoretical bugs that i can't be bothered to explain at 3AM just trust me bro Signed-off-by: Leah Rowe <leah@libreboot.org>
31 hoursutil/nvmutil: clean up hextonum()Leah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
31 hoursutil/nvmutil: tidy up some commentsLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
31 hoursutil/nvmutil: make mac_updated a uint8_tLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
31 hoursutil/nvmutil: fix prototype indentationLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
31 hoursutil/nvmutil: reset mac_buf for mac parsingLeah Rowe
preventative fix for later, if the tool is ever expanded to have a better command syntax, for supporting more than one file at a time. Signed-off-by: Leah Rowe <leah@libreboot.org>
32 hoursutil/nvmutil: comment the unhandled errno exitLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
32 hoursutil/nvmutil: tidy up set_mac_byteLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
32 hoursutil/nvmutil: further mac address parsing cleanupLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
32 hoursutil/nvmutil: tidy up mac parsing codeLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
33 hoursutil/nvmutil: fix a bad commentLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
33 hoursutil/nvmutil: tidy up set_mac_byteLeah Rowe
send the mac address byte directly to check_mac_separator functionally identicaly, but cleaner, and uses multiplication instead of division (faster). Signed-off-by: Leah Rowe <leah@libreboot.org>
33 hoursutil/nvmutil: make do_read a uint8_tLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
33 hoursutil/nvmutil: clearer commenting about commandsLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
33 hoursutil/nvmutil: comment regarding bufLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
33 hoursutil/nvmutil: minor code cleanupLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
34 hoursutil/nvmutil: fix an err stringLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
34 hoursutil/nvmutil: tidy up conv_argv_part_numLeah Rowe
no need for strlen here (1-character string). Signed-off-by: Leah Rowe <leah@libreboot.org>
34 hoursutil/nvmutil: Shorten a commentLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
34 hoursutil/nvmutil: fix a bad commentLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
34 hoursutil/nvmutil: make gbe_st local, not static/globalLeah Rowe
forgot to remove static when making it local Signed-off-by: Leah Rowe <leah@libreboot.org>
34 hoursutil/nvmutil: rename rfd to urandom_fdLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
34 hoursutil/nvmutil: remove reset_global_stateLeah Rowe
it was put there for another change i haven't done yet, and probably won't. the program currently just runs once with one operation, on a given file. the current defaults are initialised just fine without this function, so let's remove this bloat for now. Signed-off-by: Leah Rowe <leah@libreboot.org>
34 hoursutil/nvmutil: rename arc4random defineLeah Rowe
specifically refer to the actual function i use. Signed-off-by: Leah Rowe <leah@libreboot.org>
34 hoursutil/nvmutil: reset errno on /dev/random fallbackLeah Rowe
i didn't catch this before. stale error state would have passed through, even on ultimate success. Signed-off-by: Leah Rowe <leah@libreboot.org>
34 hoursutil/nvmutil: remove rval from conv_argv_part_numLeah Rowe
relic from an earlier uncommitted version Signed-off-by: Leah Rowe <leah@libreboot.org>
35 hoursutil/nvmutil: set part_modified to a uint8_tLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
35 hoursutil/nvmutil: make invert a uint8_tLeah Rowe
cleaner intention, and shorter Signed-off-by: Leah Rowe <leah@libreboot.org>
35 hoursutil/nvmutil: safer argv part number parsingLeah Rowe
we now handle signedness properly, which is implementation defined, on char integers where signed/unsigned is not specified. Signed-off-by: Leah Rowe <leah@libreboot.org>
35 hoursutil/nvmutil: rename check_bound check_nvm_boundLeah Rowe
this makes the intent clearer, because we only want to access the 128-byte nvm area here. Signed-off-by: Leah Rowe <leah@libreboot.org>
35 hoursutil/nvmutil: be clearer about GbE file sizesLeah Rowe
the partsize variable is also misleading, because it refers to the full half of a file, which might be bigger than 4KB. this variable name is a hangover from when nvmutil only supported 8KB files. Signed-off-by: Leah Rowe <leah@libreboot.org>
36 hoursutil/nvmutil: rename fd to fd_ptr in xopen()Leah Rowe
clearer intent Signed-off-by: Leah Rowe <leah@libreboot.org>
36 hoursutil/nvmutil: cleaned up a few prototypesLeah Rowe
make them match how they're declared Signed-off-by: Leah Rowe <leah@libreboot.org>
36 hoursutil/nvmutil: more readable xopenLeah Rowe
match the argument names of openbsd open(2) Signed-off-by: Leah Rowe <leah@libreboot.org>
36 hoursutil/nvmutil: use unsigned char in hextonumLeah Rowe
char can be signed or unsigned, and this is often implementation-defined. this could result in bad comparisons, so we should specifically cast it. Signed-off-by: Leah Rowe <leah@libreboot.org>
36 hoursutil/nvmutil: remove redundant breakLeah Rowe
err takes care of it Signed-off-by: Leah Rowe <leah@libreboot.org>
36 hoursutil/nvmutil: rename write_gbe to write_gbe_fileLeah Rowe
for clarity Signed-off-by: Leah Rowe <leah@libreboot.org>
36 hoursutil/nvmutil: rename read_gbe to read_gbe_fileLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
36 hoursutil/nvmutil: unified partnum validationLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>