Commit 82d81b9e by Ondrej Kozina Committed by Milan Broz

extend use of lseek_blockwise functions

parent ed19ddf6
......@@ -183,9 +183,9 @@ int LUKS_encrypt_to_storage(char *src, size_t srcLength,
if (devfd < 0)
goto out;
if (lseek(devfd, sector * SECTOR_SIZE, SEEK_SET) == -1 ||
write_blockwise(devfd, device_block_size(device),
device_alignment(device), src, srcLength) == -1)
if (write_lseek_blockwise(devfd, device_block_size(device),
device_alignment(device), src, srcLength,
sector * SECTOR_SIZE) < 0)
goto out;
r = 0;
......@@ -239,9 +239,9 @@ int LUKS_decrypt_from_storage(char *dst, size_t dstLength,
if (devfd < 0)
goto bad;
if (lseek(devfd, sector * SECTOR_SIZE, SEEK_SET) == -1 ||
read_blockwise(devfd, device_block_size(device),
device_alignment(device), dst, dstLength) == -1)
if (read_lseek_blockwise(devfd, device_block_size(device),
device_alignment(device), dst, dstLength,
sector * SECTOR_SIZE) < 0)
goto bad;
close(devfd);
......
......@@ -73,10 +73,9 @@ static int luks2_encrypt_to_storage(char *src, size_t srcLength,
devfd = device_open_locked(device, O_RDWR);
if (devfd >= 0) {
if (lseek(devfd, sector * SECTOR_SIZE, SEEK_SET) == -1 ||
write_blockwise(devfd, device_block_size(device),
device_alignment(device), src,
srcLength) == -1)
if (write_lseek_blockwise(devfd, device_block_size(device),
device_alignment(device), src,
srcLength, sector * SECTOR_SIZE) < 0)
r = -EIO;
else
r = 0;
......@@ -132,9 +131,9 @@ static int luks2_decrypt_from_storage(char *dst, size_t dstLength,
devfd = device_open_locked(device, O_RDONLY);
if (devfd >= 0) {
if (lseek(devfd, sector * SECTOR_SIZE, SEEK_SET) == -1 ||
read_blockwise(devfd, device_block_size(device),
device_alignment(device), dst, dstLength) == -1)
if (read_lseek_blockwise(devfd, device_block_size(device),
device_alignment(device), dst,
dstLength, sector * SECTOR_SIZE) < 0)
r = -EIO;
else
r = 0;
......
......@@ -82,9 +82,9 @@ int VERITY_read_sb(struct crypt_device *cd,
return -EINVAL;
}
if (lseek(devfd, sb_offset, SEEK_SET) < 0 ||
read_blockwise(devfd, device_block_size(device), device_alignment(device),
&sb, hdr_size) < hdr_size) {
if (read_lseek_blockwise(devfd, device_block_size(device),
device_alignment(device), &sb, hdr_size,
sb_offset) < hdr_size) {
close(devfd);
return -EIO;
}
......
......@@ -94,6 +94,7 @@ static int FEC_read_interleaved(struct fec_context *ctx, uint64_t i,
continue;
}
/* FIXME: read_lseek_blockwise candidate */
if (lseek(ctx->inputs[n].fd, ctx->inputs[n].start + offset, SEEK_SET) < 0)
return -1;
return (read_buffer(ctx->inputs[n].fd, output, count) == (ssize_t)count) ? 0 : -1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment