update_engine: Use utils::FileSize when finding the size of a file.

The utils::FileSize funciton can find the size of a block device correctly.
Use it instead of the adhoc methods used around the codebase.

BUG=chromium:415867
TEST=Ran a butterfly-paladin tryjob with --hwtest.

Change-Id: Id6fd37f04b136b4265bde9b1f56c379a5d9c30f9
Reviewed-on: https://chromium-review.googlesource.com/217418
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Gabe Black <gabeblack@chromium.org>
Tested-by: Gabe Black <gabeblack@chromium.org>
diff --git a/payload_generator/extent_mapper.cc b/payload_generator/extent_mapper.cc
index ace463f..5e363c7 100644
--- a/payload_generator/extent_mapper.cc
+++ b/payload_generator/extent_mapper.cc
@@ -49,13 +49,12 @@
   ScopedFdCloser fd_closer(&fd);
 
   // Get file size in blocks
-  rc = fstat(fd, &stbuf);
-  if (rc < 0) {
-    perror("fstat");
+  off_t file_size = utils::FileSize(fd);
+  if (file_size < 0) {
     return false;
   }
-  CHECK_LE(chunk_offset, stbuf.st_size);
-  off_t size = stbuf.st_size - chunk_offset;
+  CHECK_LE(chunk_offset, file_size);
+  off_t size = file_size - chunk_offset;
   if (chunk_size != -1) {
     size = std::min(size, chunk_size);
   }