mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2026-01-08 16:35:30 +01:00
Fix open flags in cryptsetup-reencrypt header access check.
We should not use O_DIRECT, it does not work tin in-memory fs. Also never use O_EXCL on regular files, it is undedfined according to open() documentation. Fixes: #529.
This commit is contained in:
@@ -194,8 +194,14 @@ static int device_check(struct reenc_ctx *rc, const char *device, header_magic s
|
||||
ssize_t s;
|
||||
uint16_t version;
|
||||
size_t buf_size = pagesize();
|
||||
struct stat st;
|
||||
|
||||
devfd = open(device, O_RDWR | O_EXCL | O_DIRECT);
|
||||
if (stat(device, &st)) {
|
||||
log_err(_("Cannot open device %s."), device);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
devfd = open(device, O_RDWR | (S_ISBLK(st.st_mode) ? O_EXCL : 0));
|
||||
if (devfd == -1) {
|
||||
if (errno == EBUSY) {
|
||||
log_err(_("Cannot exclusively open %s, device in use."),
|
||||
|
||||
Reference in New Issue
Block a user