Fix the bug when mixing usages with and without -f argument.

The SMBIOS requires the offset in type 241 table is absolute address.
We get in trouble if only VPD partition is read from BIOS (for speed)
because we have no overview scope to know the absolute address in BIOS.

Added a guess_offset() function to consider all combinations of how the
structure was made, and whether the whole file is read at parsing.
Please refer for the function comments for details.

Also fix the 64-bit integer issue for off_t.

BUS=chrome-os-partner:4010
TEST=tested on broken bios, and following commands (switch between w/ and w/o -f):
  vpd -O -s A=B
  vpd -l
  flashrom -r /tmp/bios
  vpd -f /tmp/bios -l
  vpd -f /tmp/bios -s C=D
  vpd -f /tmp/bios -l
  flashrom -w /tmp/bios
  vpd -l
  vpd -f /tmp/bios -O -s E=F
  flashrom -w /tmp/bios
  vpd -l
  vpd -s G=H
  vpd -l

Reviewed-on: http://gerrit.chromium.org/gerrit/1243
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Tested-by: Louis Yung-Chieh Lo <yjlou@chromium.org>

(cherry picked from commit 729bd30559906260d12a4ec7626bac7e9ae71e8c)

Change-Id: Iaf9a924f8a8982eceffc97483ec1d5bf5eaadab0
Reviewed-on: http://gerrit.chromium.org/gerrit/2976
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
Tested-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
1 file changed
tree: 6371f74ee46294f3a26e31faaf68421369821892
  1. LICENSE
  2. Makefile
  3. README
  4. include/
  5. lib/
  6. util/
  7. vpd.c