summaryrefslogtreecommitdiff
path: root/util/nvramtool/cli
diff options
context:
space:
mode:
authorPatrick Georgi <patrick.georgi@secunet.com>2013-04-11 12:32:32 +0200
committerStefan Reinauer <stefan.reinauer@coreboot.org>2013-05-04 00:14:11 +0200
commita98d3061e9e85be2f924850860e76f07cfc5af37 (patch)
treeaae5432e1586fe6d04f97835318b7460569270f5 /util/nvramtool/cli
parent2fde9668b47e74d1bfad2f1688a4481e6b966d04 (diff)
nvramtool: Use CMOS_SIZE for cmos size
We write CMOS data to 128 byte files, which is a problem when using them later-on (eg. as part of a coreboot image) where nvramtool assumes them to be 256 byte, and so data corruption occurs. Change-Id: Ibc919c95f6d522866b21fd313ceb023e73d09fb9 Signed-off-by: Patrick Georgi <patrick.georgi@secunet.com> Reviewed-on: http://review.coreboot.org/3186 Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Diffstat (limited to 'util/nvramtool/cli')
-rw-r--r--util/nvramtool/cli/nvramtool.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/util/nvramtool/cli/nvramtool.c b/util/nvramtool/cli/nvramtool.c
index 76d5cbb678..d5acc5838e 100644
--- a/util/nvramtool/cli/nvramtool.c
+++ b/util/nvramtool/cli/nvramtool.c
@@ -162,8 +162,8 @@ int main(int argc, char *argv[])
exit(1);
}
- if (fd_stat.st_size < 128) {
- lseek(fd, 127, SEEK_SET);
+ if (fd_stat.st_size < CMOS_SIZE) {
+ lseek(fd, CMOS_SIZE - 1, SEEK_SET);
if (write(fd, "\0", 1) != 1) {
fprintf(stderr, "Unable to extended '%s' to its full size.\n",
nvramtool_op_modifiers[NVRAMTOOL_MOD_USE_CMOS_FILE].param);
@@ -176,7 +176,7 @@ int main(int argc, char *argv[])
#endif
}
- cmos_default = mmap(NULL, 128, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ cmos_default = mmap(NULL, CMOS_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (cmos_default == MAP_FAILED) {
fprintf(stderr, "Couldn't map '%s'\n", nvramtool_op_modifiers[NVRAMTOOL_MOD_USE_CMOS_FILE].param);
exit(1);