summaryrefslogtreecommitdiffstats
path: root/fuse_sdcard_provider.cpp
diff options
context:
space:
mode:
authorTianjie Xu <xunchang@google.com>2016-09-01 20:01:09 +0200
committerandroid-build-merger <android-build-merger@google.com>2016-09-01 20:01:09 +0200
commit28f6c43db54159c218dd2ca27dbb775305b4011c (patch)
treece38d93bffc34e9304165aa198b24573870c2074 /fuse_sdcard_provider.cpp
parentMerge "minadbd: rename adb_server_main to minadbd_main." am: 818394869d am: aad4cef0f3 (diff)
parentMerge "Check an edge case when read(2) returns 0" am: 3202b8faf4 (diff)
downloadandroid_bootable_recovery-28f6c43db54159c218dd2ca27dbb775305b4011c.tar
android_bootable_recovery-28f6c43db54159c218dd2ca27dbb775305b4011c.tar.gz
android_bootable_recovery-28f6c43db54159c218dd2ca27dbb775305b4011c.tar.bz2
android_bootable_recovery-28f6c43db54159c218dd2ca27dbb775305b4011c.tar.lz
android_bootable_recovery-28f6c43db54159c218dd2ca27dbb775305b4011c.tar.xz
android_bootable_recovery-28f6c43db54159c218dd2ca27dbb775305b4011c.tar.zst
android_bootable_recovery-28f6c43db54159c218dd2ca27dbb775305b4011c.zip
Diffstat (limited to 'fuse_sdcard_provider.cpp')
-rw-r--r--fuse_sdcard_provider.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/fuse_sdcard_provider.cpp b/fuse_sdcard_provider.cpp
index df9631272..b0ecf96be 100644
--- a/fuse_sdcard_provider.cpp
+++ b/fuse_sdcard_provider.cpp
@@ -23,6 +23,8 @@
#include <unistd.h>
#include <fcntl.h>
+#include <android-base/file.h>
+
#include "fuse_sideload.h"
struct file_data {
@@ -41,14 +43,9 @@ static int read_block_file(void* cookie, uint32_t block, uint8_t* buffer, uint32
return -EIO;
}
- while (fetch_size > 0) {
- ssize_t r = TEMP_FAILURE_RETRY(read(fd->fd, buffer, fetch_size));
- if (r == -1) {
- fprintf(stderr, "read on sdcard failed: %s\n", strerror(errno));
- return -EIO;
- }
- fetch_size -= r;
- buffer += r;
+ if (!android::base::ReadFully(fd->fd, buffer, fetch_size)) {
+ fprintf(stderr, "read on sdcard failed: %s\n", strerror(errno));
+ return -EIO;
}
return 0;