Merge "Switch to android::base::ReadFully"
diff --git a/fs_mgr/Android.mk b/fs_mgr/Android.mk
index 8b09f53..b47199f 100644
--- a/fs_mgr/Android.mk
+++ b/fs_mgr/Android.mk
@@ -12,7 +12,7 @@
     external/openssl/include
 
 LOCAL_MODULE:= libfs_mgr
-LOCAL_STATIC_LIBRARIES := liblogwrap libmincrypt libext4_utils_static libsquashfs_utils
+LOCAL_STATIC_LIBRARIES := liblogwrap libmincrypt libext4_utils_static libsquashfs_utils libbase
 LOCAL_C_INCLUDES += system/extras/ext4_utils system/extras/squashfs_utils \
 	bootable/recovery
 LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
@@ -39,7 +39,7 @@
 LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)/sbin
 LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_UNSTRIPPED)
 
-LOCAL_STATIC_LIBRARIES := libfs_mgr liblogwrap libcutils liblog libc libmincrypt libext4_utils_static libsquashfs_utils
+LOCAL_STATIC_LIBRARIES := libfs_mgr liblogwrap libcutils liblog libc libmincrypt libext4_utils_static libsquashfs_utils libbase
 LOCAL_STATIC_LIBRARIES += libsparse_static libz libselinux
 LOCAL_CXX_STL := libc++_static
 
diff --git a/fs_mgr/fs_mgr_verity.cpp b/fs_mgr/fs_mgr_verity.cpp
index 961f3c6..8f7c6a2 100644
--- a/fs_mgr/fs_mgr_verity.cpp
+++ b/fs_mgr/fs_mgr_verity.cpp
@@ -29,6 +29,7 @@
 #include <libgen.h>
 #include <time.h>
 
+#include <base/file.h>
 #include <private/android_filesystem_config.h>
 #include <cutils/properties.h>
 #include <logwrap/logwrap.h>
@@ -200,7 +201,7 @@
         return -1;
     }
 
-    if (TEMP_FAILURE_RETRY(read(data_device, &sb, sizeof(sb))) != sizeof(sb)) {
+    if (!android::base::ReadFully(data_device, &sb, sizeof(sb))) {
         ERROR("Error reading superblock");
         close(data_device);
         return -1;
@@ -256,10 +257,8 @@
         ERROR("Could not seek to start of verity metadata block.\n");
         goto out;
     }
-
     // check the magic number
-    if (TEMP_FAILURE_RETRY(read(device, &magic_number, sizeof(magic_number))) !=
-            sizeof(magic_number)) {
+    if (!android::base::ReadFully(device, &magic_number, sizeof(magic_number))) {
         ERROR("Couldn't read magic number!\n");
         goto out;
     }
@@ -278,8 +277,8 @@
     }
 
     // check the protocol version
-    if (TEMP_FAILURE_RETRY(read(device, &protocol_version,
-            sizeof(protocol_version))) != sizeof(protocol_version)) {
+    if (!android::base::ReadFully(device, &protocol_version,
+            sizeof(protocol_version))) {
         ERROR("Couldn't read verity metadata protocol version!\n");
         goto out;
     }
@@ -294,7 +293,7 @@
         ERROR("Couldn't allocate memory for signature!\n");
         goto out;
     }
-    if (TEMP_FAILURE_RETRY(read(device, *signature, RSANUMBYTES)) != RSANUMBYTES) {
+    if (!android::base::ReadFully(device, *signature, RSANUMBYTES)) {
         ERROR("Couldn't read signature from verity metadata!\n");
         goto out;
     }
@@ -305,8 +304,7 @@
     }
 
     // get the size of the table
-    if (TEMP_FAILURE_RETRY(read(device, &table_length, sizeof(table_length))) !=
-            sizeof(table_length)) {
+    if (!android::base::ReadFully(device, &table_length, sizeof(table_length))) {
         ERROR("Couldn't get the size of the verity table from metadata!\n");
         goto out;
     }
@@ -317,8 +315,7 @@
         ERROR("Couldn't allocate memory for verity table!\n");
         goto out;
     }
-    if (TEMP_FAILURE_RETRY(read(device, *table, table_length)) !=
-            (ssize_t)table_length) {
+    if (!android::base::ReadFully(device, *table, table_length)) {
         ERROR("Couldn't read the verity table from metadata!\n");
         goto out;
     }
@@ -483,7 +480,7 @@
         goto out;
     }
 
-    if (TEMP_FAILURE_RETRY(read(fd, buffer, size)) != size) {
+    if (!android::base::ReadFully(fd, buffer, size)) {
         ERROR("Failed to read %zd bytes from %s (%s)\n", size, fname,
             strerror(errno));
         goto out;