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/extent_writer_unittest.cc b/extent_writer_unittest.cc
index fef3343..a1b254d 100644
--- a/extent_writer_unittest.cc
+++ b/extent_writer_unittest.cc
@@ -70,9 +70,7 @@
   EXPECT_TRUE(direct_writer.Write(bytes.data(), bytes.size()));
   EXPECT_TRUE(direct_writer.End());
 
-  struct stat stbuf;
-  EXPECT_EQ(0, fstat(fd(), &stbuf));
-  EXPECT_EQ(kBlockSize + bytes.size(), stbuf.st_size);
+  EXPECT_EQ(kBlockSize + bytes.size(), utils::FileSize(fd()));
 
   vector<char> result_file;
   EXPECT_TRUE(utils::ReadFile(path(), &result_file));
@@ -139,9 +137,7 @@
   }
   EXPECT_TRUE(direct_writer.End());
 
-  struct stat stbuf;
-  EXPECT_EQ(0, fstat(fd(), &stbuf));
-  EXPECT_EQ(data.size(), stbuf.st_size);
+  EXPECT_EQ(data.size(), utils::FileSize(fd()));
 
   vector<char> result_file;
   EXPECT_TRUE(utils::ReadFile(path(), &result_file));
@@ -190,9 +186,7 @@
   ASSERT_TRUE(zero_pad_writer.Write(&data[0], bytes_to_write));
   EXPECT_TRUE(zero_pad_writer.End());
 
-  struct stat stbuf;
-  EXPECT_EQ(0, fstat(fd(), &stbuf));
-  EXPECT_EQ(data.size(), stbuf.st_size);
+  EXPECT_EQ(data.size(), utils::FileSize(fd()));
 
   vector<char> result_file;
   EXPECT_TRUE(utils::ReadFile(path(), &result_file));