| Age | Commit message (Collapse) | Author |
|
set a constant maximum length. this seems reasonable,
and it's even quite generous.
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
we don't need it. what follows is a call to open(), which
would fail anyway if the path is a directory; further, this
removes a theoretical race condition in the program, and
makes open() happen sooner, making it more likely that we
get the file first, before another program can take it.
checking whether /dev/urandom is a directory is the height
of absurdity.
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
n + 1 is the same as saying sizeof(rnum) in this case.
we should be clear about that, in code. n is irrelevant
here, since it is only an index for the return value.
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
checking against -1 is incorrect, because we specifically want
to ensure that it always read the number of bytes defined by
the size of rnum.
this still covers the case where the return value is -1, and
therefore makes the error handling much stricter.
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
default to ECANCELED if zero
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
the way err works here now is very different than
the bsd one. here, we ALWAYS exit with EXIT_FAILURE,
and we call set_err with, as argument, the first
argument given to err.
this then sets errno, but the exit value is always
consistent.
that's what happens when i control err(). i make it
even better. the original bsd one is too conservative.
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
and use getnvmprogname
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
and getprogname, written as getnvmprogname
this removes a dependency on err.h, which is non-standard.
the remaining code is posix-compliant, or ifdef'd where
use of openbsd pledge is concerned - someone could theoretically
define __OpenBSD__ that isn't and OpenBSD base maintainer, and
then use nvmutil in it, but i so don't care about that evermore
hypothetical individual.
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
dirent.h is no longer needed, because i'm no longer
making use of opendir()
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
by handling close() in main, we can reduce the
indendation in write_gbe and generally make it
much easier to read.
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
these integers are already initialised to zero.
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
the swap function reverses the byte order in memory, of
a loaded GbE after after reading it, or before writing
it. this is required (as detected) on big-endian CPUs,
because GbE files store bytes in little-endian order.
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
set it after the argc check
i don't like initialising a const after
declaration, but it compiles, and it keeps
with the style used in the rest of the code.
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
it's not required
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
i declare it, using the 3rd argument, which might
not be available if only the file name is declared.
this fixes that.
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
these macros serve no purpose except to obfuscate the
code. it's actually cleaner just to refer directly to
argv, and it reduces the chance of contamination later
upon re-factoring.
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
and op to ops
typedefs not part of any base system e.g. openbsd
base system, or e.g. the libc, should not have _t
in them.
this is a stylistic change, and does not alter any
actual program behaviour.
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
reduced indentation
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
the second half of the function is mostly checking
arguments, and has the hack to set cmd to cmd_setmac
if cmd is unset (no command specified) but argc is
above two.
stylistically, this is more consistent.
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
we only need 12 bytes at a maximum
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
i don't intend for this to be used in a library
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
this is inconsistent with the style in the rest of
the code.
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
in the same order that functions are declared
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
each variable is declared on its own line.
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
don't hardcode it
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
this fixes the bug where if you specify an invalid command
such as:
./nvm gbe brick 9
part 9 doesn't exist, but fname isn't yet set, here.
same thing applys when running those pledge commands on
openbsd.
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
only 79 characters or less, per line.
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
this is separate from other function calls. err_if
is used as though it was an if, where we always add
a space. it's just a quirk of my coding style.
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
use the same naming scheme throughout
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
this way, the correct part number is printed when an invalid
part is being operated on, in cmd copy or swap.
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
i overlooked this in a previous modification
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
Signed-off-by: Leah Rowe <leah@libreboot.org>
|
|
instead, use a single integer, set to 1 if using
these commands (otherwise set to 0) used as an XOR
mask.
use this to invert where data gets read. one quirk
with this is that if a copy operation is performed
from a part with a bad checksum, it's already done
in advance, in memory, but then the check on the
checksum in cmd_copy is now checking the other part,
which will be all zeroes, so i invert that too; this
means now when running cmd_copy, it'll complain about
an invalid part, but the part number is inverted.
it's a small price to pay, because this restores the
previous performance optimisations but without being
as unsafe.
this is also true when doing the swap.
Signed-off-by: Leah Rowe <leah@libreboot.org>
|