Chromium Code Reviews| Index: host/arch/x86/lib/crossystem_arch.c |
| diff --git a/host/arch/x86/lib/crossystem_arch.c b/host/arch/x86/lib/crossystem_arch.c |
| index b8e6add597e9be5d70bc9cd1357c45a21dbff8ec..c3bd4df21260d8bc1ce5fa685d26a95c74ba0997 100644 |
| --- a/host/arch/x86/lib/crossystem_arch.c |
| +++ b/host/arch/x86/lib/crossystem_arch.c |
| @@ -84,6 +84,9 @@ |
| /* Filename for NVRAM file */ |
| #define NVRAM_PATH "/dev/nvram" |
| +/* Filename for legace firmware update tries */ |
|
Stefan Reinauer
2011/04/11 20:32:55
typo: legacy
|
| +#define NEED_FWUPDATE_PATH "/mnt/stateful_partition/.need_firmware_update" |
| + |
| int VbReadNvStorage(VbNvContext* vnc) { |
| FILE* f; |
| @@ -522,6 +525,19 @@ int VbGetArchPropertyInt(const char* name) { |
| if (-1 == value) |
| value = VbGetCmosRebootField(CMOSRF_TRY_B); |
| } |
| + /* Firmwate update tries is now stored in the kernel field. On |
|
Stefan Reinauer
2011/04/11 20:32:55
Typo: Firmware
|
| + * older systems where it's not, it was stored in a file in the |
| + * stateful partition. */ |
| + else if (!strcasecmp(name,"fwupdate_tries")) { |
| + if (-1 != VbGetNvStorage(VBNV_KERNEL_FIELD)) |
| + return -1; /* NvStorage supported; fail through arch-specific |
| + * implementation to normal implementation. */ |
| + |
| + /* Read value from file; missing file means value=0. */ |
| + value = ReadFileInt(NEED_FWUPDATE_PATH); |
| + if (-1 == value) |
| + value = 0; |
| + } |
| return value; |
| } |
| @@ -581,6 +597,24 @@ int VbSetArchPropertyInt(const char* name, int value) { |
| return 0; |
| return VbSetCmosRebootField(CMOSRF_TRY_B, value); |
| } |
| + /* Firmwate update tries is now stored in the kernel field. On |
|
Stefan Reinauer
2011/04/11 20:32:55
ditto
|
| + * older systems where it's not, it was stored in a file in the |
| + * stateful partition. */ |
| + else if (!strcasecmp(name,"fwupdate_tries")) { |
| + if (-1 != VbGetNvStorage(VBNV_KERNEL_FIELD)) |
| + return -1; /* NvStorage supported; fail through arch-specific |
| + * implementation to normal implementation */ |
| + |
| + if (value) { |
| + char buf[32]; |
| + snprintf(buf, sizeof(buf), "%d", value); |
| + return WriteFile(NEED_FWUPDATE_PATH, buf, sizeof(buf)); |
|
Stefan Reinauer
2011/04/11 20:32:55
strlen()
|
| + } else { |
| + /* No update tries, so remove file if it exists. */ |
| + unlink(NEED_FWUPDATE_PATH); |
| + return 0; |
| + } |
| + } |
| return -1; |
| } |