OSDN Git Service

Fixed opening of a regular file (broken in r403).
authorresver@gmail.com <resver@gmail.com@60bc1c72-a15a-11de-b98f-4500b42dc123>
Sun, 1 Jun 2014 19:48:03 +0000 (19:48 +0000)
committerresver@gmail.com <resver@gmail.com@60bc1c72-a15a-11de-b98f-4500b42dc123>
Sun, 1 Jun 2014 19:48:03 +0000 (19:48 +0000)
git-svn-id: http://exfat.googlecode.com/svn/trunk@404 60bc1c72-a15a-11de-b98f-4500b42dc123

libexfat/io.c

index ad71036..5a84ec4 100644 (file)
@@ -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;