summaryrefslogtreecommitdiffstats
path: root/fuse_sdcard_provider.c
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2015-04-30 06:44:20 +0200
committerAndroid Git Automerger <android-git-automerger@android.com>2015-04-30 06:44:20 +0200
commitb2007b70cafac781565ab20c299353cfb0415f71 (patch)
treee2c357667b0e76e6fa5a43c7a7951c872c373e9c /fuse_sdcard_provider.c
parentam 15a2e46b: am f7466f9f: Stop using adb_strtok, and check argument validity. (diff)
parentam 34d3a3d0: am 34c7731a: Merge "Check all lseek calls succeed." (diff)
downloadandroid_bootable_recovery-b2007b70cafac781565ab20c299353cfb0415f71.tar
android_bootable_recovery-b2007b70cafac781565ab20c299353cfb0415f71.tar.gz
android_bootable_recovery-b2007b70cafac781565ab20c299353cfb0415f71.tar.bz2
android_bootable_recovery-b2007b70cafac781565ab20c299353cfb0415f71.tar.lz
android_bootable_recovery-b2007b70cafac781565ab20c299353cfb0415f71.tar.xz
android_bootable_recovery-b2007b70cafac781565ab20c299353cfb0415f71.tar.zst
android_bootable_recovery-b2007b70cafac781565ab20c299353cfb0415f71.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;