basic/efivars: do not return EIO if an efivar read is shorten than fstat size
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 6 Dec 2019 11:13:34 +0000 (12:13 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 15 Dec 2019 20:06:42 +0000 (21:06 +0100)
commit35b9eb0a72b6254568a294f0ebd011da20958a64
tree3016915686e94c719d64003cbba61970614174f2
parenta97abb30e7ebaf5cfa07e3815909d7c0c4416e6c
basic/efivars: do not return EIO if an efivar read is shorten than fstat size

On my machine stat returns size 22, but only 20 bytes are read:

openat(AT_FDCWD, "/sys/firmware/efi/efivars/LoaderTimeInitUSec-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f", O_RDONLY|O_NOCTTY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=22, ...}) = 0
read(3, "\6\0\0\0", 4)                  = 4
read(3, "7\0001\0001\0003\0005\0002\0007\0\0\0", 18) = 16
Failed to read LoaderTimeInitUSec: Input/output error

Let's just accept that the kernel is returning inconsistent results.
It seems to happen two only two variables on my machine:
/sys/firmware/efi/efivars/LoaderTimeInitUSec-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f
/sys/firmware/efi/efivars/LoaderTimeMenuUSec-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f
so it might be related to the way we write them.
src/basic/efivars.c