Skip to content

Commit

Permalink
Do not use O_EXCL for allocated backing loop device.
Browse files Browse the repository at this point in the history
Exclusive flag is defined only when creating a file,
for opening existing file it is undefinded operation.

Remove it from crypt_loop_attach as it was wrong since
the initial commit.
  • Loading branch information
mbroz committed Jul 24, 2024
1 parent d88a97b commit 5873a65
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/utils_loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ int crypt_loop_attach(char **loop, const char *file, int offset,

*loop = NULL;

file_fd = open(file, (*readonly ? O_RDONLY : O_RDWR) | O_EXCL);
file_fd = open(file, *readonly ? O_RDONLY : O_RDWR);
if (file_fd < 0 && (errno == EROFS || errno == EACCES) && !*readonly) {
*readonly = 1;
file_fd = open(file, O_RDONLY | O_EXCL);
file_fd = open(file, O_RDONLY);
}
if (file_fd < 0)
goto out;
Expand Down

0 comments on commit 5873a65

Please sign in to comment.