log_dbg("Storing backup of header (%u bytes) and keyslot area (%u bytes).",
sizeof(*hdr), buffer_size - LUKS_ALIGN_KEYSLOTS);
- devfd = open(device_path(device), O_RDONLY | O_DIRECT | O_SYNC);
+ devfd = device_open(device, O_RDONLY);
if(devfd == -1) {
log_err(ctx, _("Device %s is not a valid LUKS device.\n"), device_path(device));
r = -EINVAL;
log_dbg("Storing backup of header (%u bytes) and keyslot area (%u bytes) to device %s.",
sizeof(*hdr), buffer_size - LUKS_ALIGN_KEYSLOTS, device_path(device));
- devfd = open(device_path(device), O_RDWR | O_DIRECT | O_SYNC);
+ devfd = device_open(device, O_RDWR);
if (devfd == -1) {
if (errno == EACCES)
log_err(ctx, _("Cannot write to device %s, permission denied.\n"),
log_dbg("Reading LUKS header of size %d from device %s",
hdr_size, device_path(device));
- devfd = open(device_path(device), O_RDONLY | O_DIRECT | O_SYNC);
+ devfd = device_open(device, O_RDONLY);
if (devfd == -1) {
log_err(ctx, _("Cannot open device %s.\n"), device_path(device));
return -EINVAL;
if (r)
return r;
- devfd = open(device_path(device), O_RDWR | O_DIRECT | O_SYNC);
+ devfd = device_open(device, O_RDWR);
if(-1 == devfd) {
if (errno == EACCES)
log_err(ctx, _("Cannot write to device %s, permission denied.\n"),