Fix loop mapping on readonly file.
authorMilan Broz <gmazyland@gmail.com>
Tue, 1 May 2012 22:41:05 +0000 (00:41 +0200)
committerMilan Broz <gmazyland@gmail.com>
Tue, 1 May 2012 22:52:37 +0000 (00:52 +0200)
ChangeLog
lib/utils_loop.c

index 7000963..3864982 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2012-05-02  Milan Broz  <gmazyland@gmail.com>
+       * Fix loop mapping on readonly file.
+
 2012-04-09  Milan Broz  <gmazyland@gmail.com>
        * Fix header check to support old (cryptsetup 1.0.0) header alignment. (1.4.0)
        * Version 1.4.2.
index d0f185b..6a4e11f 100644 (file)
@@ -99,7 +99,7 @@ int crypt_loop_attach(const char *loop, const char *file, int offset,
        int loop_fd = -1, file_fd = -1, r = 1;
 
        file_fd = open(file, (*readonly ? O_RDONLY : O_RDWR) | O_EXCL);
-       if (file_fd < 0 && errno == EROFS && !*readonly) {
+       if (file_fd < 0 && (errno == EROFS || errno == EACCES) && !*readonly) {
                *readonly = 1;
                file_fd = open(file, O_RDONLY | O_EXCL);
        }