vpd_get_value: Allow sysfs reads when ro missing

For reference boards, there may be no VPD provisioned at manufacturing
time. This causes vpd_get_value requests to fall back to dump_vpd_log
unnecessarily, which can take over two seconds.

This commit also checks for the presence of an "rw" directory to
determine if vpd data is provided via sysfs on the target system. The OS
populates data in the "rw" section so it can be used even when nothing
was provisioned at manufacturing time.

BUG=b:110024486
TEST=chrome://system loads correctly on yorp with this change
BRANCH=None

Change-Id: Idf239e65bde844a8e9b130fc1ea3d40eaec95af5
Reviewed-on: https://chromium-review.googlesource.com/1106290
Commit-Ready: Justin TerAvest <teravest@chromium.org>
Tested-by: Justin TerAvest <teravest@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
diff --git a/util/vpd_get_value b/util/vpd_get_value
index a4e0683..26ccb48 100755
--- a/util/vpd_get_value
+++ b/util/vpd_get_value
@@ -29,7 +29,13 @@
 
   # Reading from /sys (works on ARM 3.18+, x86 4.4+) is most efficient;
   # otherwise we have to parse from VPD cache (maintained by dump_vpd_log).
-  if [ -z "${VPD_IGNORE_SYS_CACHE}" ] && [ -d "${SYS_VPD}/ro" ]; then
+  local sys_vpd_present=0
+  # VPD ro section may have no entries for reference boards; check for rw as
+  # well to prefer the fast path when possible.
+  if [ -d "${SYS_VPD}/ro" ] || [ -d "${SYS_VPD}/rw" ]; then
+    sys_vpd_present=1
+  fi
+  if [ -z "${VPD_IGNORE_SYS_CACHE}" ] && [ "${sys_vpd_present}" = "1" ]; then
     for file in "${SYS_VPD}/ro/${key}" "${SYS_VPD}/rw/${key}"; do
       if [ -f "${file}" ]; then
         cat "${file}"