diff options
author | Tianjie Xu <xunchang@google.com> | 2016-09-01 19:55:08 +0200 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-09-01 19:55:08 +0200 |
commit | 0ae9d800825e30670d0db8038d41af46103c8220 (patch) | |
tree | 7f25f42263857f91cb7cd00275a7e38f4c7ae8b1 /fuse_sdcard_provider.cpp | |
parent | Merge "minadbd: rename adb_server_main to minadbd_main." am: 818394869d (diff) | |
parent | Merge "Check an edge case when read(2) returns 0" (diff) | |
download | android_bootable_recovery-0ae9d800825e30670d0db8038d41af46103c8220.tar android_bootable_recovery-0ae9d800825e30670d0db8038d41af46103c8220.tar.gz android_bootable_recovery-0ae9d800825e30670d0db8038d41af46103c8220.tar.bz2 android_bootable_recovery-0ae9d800825e30670d0db8038d41af46103c8220.tar.lz android_bootable_recovery-0ae9d800825e30670d0db8038d41af46103c8220.tar.xz android_bootable_recovery-0ae9d800825e30670d0db8038d41af46103c8220.tar.zst android_bootable_recovery-0ae9d800825e30670d0db8038d41af46103c8220.zip |
Diffstat (limited to 'fuse_sdcard_provider.cpp')
-rw-r--r-- | fuse_sdcard_provider.cpp | 13 |
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; |