update_engine: Make reading the size of a block device file work as expected.
When stating a block device file, the size is always returned as zero since,
presumably, there isn't a universally applicable way to determine the size of
device data, if such a concept even makes sense. Instead, block devices have
an ioctl which returns their size.
If utils::FileSize is called on a block device, it will now fall back to the
new function utils::BlockDevSize which will return the right answer. The error
reporting in FileSize has also been beefed up slightly so that when a call to
a standard library function fails (for instance stat), some information about
the error is printed. Finally, those functions have been reorganized so that
they can be called on file descriptors as well as file paths.
BUG=chromium:415867
TEST=Ran the delta generator using device files as input and saw that their
size was detected properly. Ran a tryjob on butterfly-paladin with --hwtest.
Ran the update_engine unittests for lumpy and for the host (with a hack around
crbug.com/412630) with another change which makes the rest of the update engine
use these functions to get file sizes.
Change-Id: I2ec8c1a0d134be76dffae730ef2ee2d78e4e887e
Reviewed-on: https://chromium-review.googlesource.com/216884
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Commit-Queue: Gabe Black <gabeblack@chromium.org>
Tested-by: Gabe Black <gabeblack@chromium.org>
2 files changed