aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrelan <relan@users.noreply.github.com>2014-06-01 19:48:03 +0000
committerrelan <relan@users.noreply.github.com>2015-08-24 08:26:16 +0300
commit174be33f21390c2b002921f3968772c054c2a543 (patch)
treecd6322a39409963a46b750e8c7832aad362e3dda
parenta7da4aa7fd048ef07d9cc2ee796c6eb0a8385c68 (diff)
downloadandroid_external_exfat-174be33f21390c2b002921f3968772c054c2a543.tar.gz
android_external_exfat-174be33f21390c2b002921f3968772c054c2a543.tar.bz2
android_external_exfat-174be33f21390c2b002921f3968772c054c2a543.zip
Fix opening of a regular file (broken in r403).
-rw-r--r--libexfat/io.c11
1 files changed, 2 insertions, 9 deletions
diff --git a/libexfat/io.c b/libexfat/io.c
index ad71036..5a84ec4 100644
--- a/libexfat/io.c
+++ b/libexfat/io.c
@@ -65,17 +65,10 @@ static int open_rw(const char* spec)
int ro = 0;
/*
- This code is needed because after "blockdev --setro" kernel still
+ This ioctl is needed because after "blockdev --setro" kernel still
allows to open the device in read-write mode but fails writes.
*/
- if (fd == -1)
- return -1;
- if (ioctl(fd, BLKROGET, &ro) != 0)
- {
- close(fd);
- return -1;
- }
- if (ro)
+ if (fd != -1 && ioctl(fd, BLKROGET, &ro) == 0 && ro)
{
close(fd);
errno = EROFS;