summaryrefslogtreecommitdiffstats
path: root/fuse_sdcard_provider.c
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2015-04-29 02:24:24 +0200
committerElliott Hughes <enh@google.com>2015-04-30 02:46:43 +0200
commit7bad7c4646ee8fd8d6e6ed0ffd3ddbb0c1b41a2f (patch)
treee2c357667b0e76e6fa5a43c7a7951c872c373e9c /fuse_sdcard_provider.c
parentMerge "Stop using adb_strtok, and check argument validity." (diff)
downloadandroid_bootable_recovery-7bad7c4646ee8fd8d6e6ed0ffd3ddbb0c1b41a2f.tar
android_bootable_recovery-7bad7c4646ee8fd8d6e6ed0ffd3ddbb0c1b41a2f.tar.gz
android_bootable_recovery-7bad7c4646ee8fd8d6e6ed0ffd3ddbb0c1b41a2f.tar.bz2
android_bootable_recovery-7bad7c4646ee8fd8d6e6ed0ffd3ddbb0c1b41a2f.tar.lz
android_bootable_recovery-7bad7c4646ee8fd8d6e6ed0ffd3ddbb0c1b41a2f.tar.xz
android_bootable_recovery-7bad7c4646ee8fd8d6e6ed0ffd3ddbb0c1b41a2f.tar.zst
android_bootable_recovery-7bad7c4646ee8fd8d6e6ed0ffd3ddbb0c1b41a2f.zip
Diffstat (limited to 'fuse_sdcard_provider.c')
-rw-r--r--fuse_sdcard_provider.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/fuse_sdcard_provider.c b/fuse_sdcard_provider.c
index ca8c914f9..4565c7b5b 100644
--- a/fuse_sdcard_provider.c
+++ b/fuse_sdcard_provider.c
@@ -36,19 +36,17 @@ struct file_data {
static int read_block_file(void* cookie, uint32_t block, uint8_t* buffer, uint32_t fetch_size) {
struct file_data* fd = (struct file_data*)cookie;
- if (lseek(fd->fd, block * fd->block_size, SEEK_SET) < 0) {
- printf("seek on sdcard failed: %s\n", strerror(errno));
+ off64_t offset = ((off64_t) block) * fd->block_size;
+ if (TEMP_FAILURE_RETRY(lseek64(fd->fd, offset, SEEK_SET)) == -1) {
+ fprintf(stderr, "seek on sdcard failed: %s\n", strerror(errno));
return -EIO;
}
while (fetch_size > 0) {
- ssize_t r = read(fd->fd, buffer, fetch_size);
- if (r < 0) {
- if (r != -EINTR) {
- printf("read on sdcard failed: %s\n", strerror(errno));
- return -EIO;
- }
- r = 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;