summaryrefslogtreecommitdiffstats
path: root/fuse_sdcard_provider.c
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2015-04-30 06:11:41 +0200
committerGerrit Code Review <noreply-gerritcodereview@google.com>2015-04-30 06:11:41 +0200
commit34c7731a0bb296a1289b85a83f53026117aa3677 (patch)
treee2c357667b0e76e6fa5a43c7a7951c872c373e9c /fuse_sdcard_provider.c
parentMerge "Stop using adb_strtok, and check argument validity." (diff)
parentCheck all lseek calls succeed. (diff)
downloadandroid_bootable_recovery-34c7731a0bb296a1289b85a83f53026117aa3677.tar
android_bootable_recovery-34c7731a0bb296a1289b85a83f53026117aa3677.tar.gz
android_bootable_recovery-34c7731a0bb296a1289b85a83f53026117aa3677.tar.bz2
android_bootable_recovery-34c7731a0bb296a1289b85a83f53026117aa3677.tar.lz
android_bootable_recovery-34c7731a0bb296a1289b85a83f53026117aa3677.tar.xz
android_bootable_recovery-34c7731a0bb296a1289b85a83f53026117aa3677.tar.zst
android_bootable_recovery-34c7731a0bb296a1289b85a83f53026117aa3677.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;