mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-06 00:10:04 +01:00
extend use of lseek_blockwise functions
This commit is contained in:
committed by
Milan Broz
parent
ed19ddf620
commit
82d81b9e86
@@ -183,9 +183,9 @@ int LUKS_encrypt_to_storage(char *src, size_t srcLength,
|
|||||||
if (devfd < 0)
|
if (devfd < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (lseek(devfd, sector * SECTOR_SIZE, SEEK_SET) == -1 ||
|
if (write_lseek_blockwise(devfd, device_block_size(device),
|
||||||
write_blockwise(devfd, device_block_size(device),
|
device_alignment(device), src, srcLength,
|
||||||
device_alignment(device), src, srcLength) == -1)
|
sector * SECTOR_SIZE) < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
r = 0;
|
r = 0;
|
||||||
@@ -239,9 +239,9 @@ int LUKS_decrypt_from_storage(char *dst, size_t dstLength,
|
|||||||
if (devfd < 0)
|
if (devfd < 0)
|
||||||
goto bad;
|
goto bad;
|
||||||
|
|
||||||
if (lseek(devfd, sector * SECTOR_SIZE, SEEK_SET) == -1 ||
|
if (read_lseek_blockwise(devfd, device_block_size(device),
|
||||||
read_blockwise(devfd, device_block_size(device),
|
device_alignment(device), dst, dstLength,
|
||||||
device_alignment(device), dst, dstLength) == -1)
|
sector * SECTOR_SIZE) < 0)
|
||||||
goto bad;
|
goto bad;
|
||||||
|
|
||||||
close(devfd);
|
close(devfd);
|
||||||
|
|||||||
@@ -73,10 +73,9 @@ static int luks2_encrypt_to_storage(char *src, size_t srcLength,
|
|||||||
|
|
||||||
devfd = device_open_locked(device, O_RDWR);
|
devfd = device_open_locked(device, O_RDWR);
|
||||||
if (devfd >= 0) {
|
if (devfd >= 0) {
|
||||||
if (lseek(devfd, sector * SECTOR_SIZE, SEEK_SET) == -1 ||
|
if (write_lseek_blockwise(devfd, device_block_size(device),
|
||||||
write_blockwise(devfd, device_block_size(device),
|
|
||||||
device_alignment(device), src,
|
device_alignment(device), src,
|
||||||
srcLength) == -1)
|
srcLength, sector * SECTOR_SIZE) < 0)
|
||||||
r = -EIO;
|
r = -EIO;
|
||||||
else
|
else
|
||||||
r = 0;
|
r = 0;
|
||||||
@@ -132,9 +131,9 @@ static int luks2_decrypt_from_storage(char *dst, size_t dstLength,
|
|||||||
|
|
||||||
devfd = device_open_locked(device, O_RDONLY);
|
devfd = device_open_locked(device, O_RDONLY);
|
||||||
if (devfd >= 0) {
|
if (devfd >= 0) {
|
||||||
if (lseek(devfd, sector * SECTOR_SIZE, SEEK_SET) == -1 ||
|
if (read_lseek_blockwise(devfd, device_block_size(device),
|
||||||
read_blockwise(devfd, device_block_size(device),
|
device_alignment(device), dst,
|
||||||
device_alignment(device), dst, dstLength) == -1)
|
dstLength, sector * SECTOR_SIZE) < 0)
|
||||||
r = -EIO;
|
r = -EIO;
|
||||||
else
|
else
|
||||||
r = 0;
|
r = 0;
|
||||||
|
|||||||
@@ -82,9 +82,9 @@ int VERITY_read_sb(struct crypt_device *cd,
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lseek(devfd, sb_offset, SEEK_SET) < 0 ||
|
if (read_lseek_blockwise(devfd, device_block_size(device),
|
||||||
read_blockwise(devfd, device_block_size(device), device_alignment(device),
|
device_alignment(device), &sb, hdr_size,
|
||||||
&sb, hdr_size) < hdr_size) {
|
sb_offset) < hdr_size) {
|
||||||
close(devfd);
|
close(devfd);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ static int FEC_read_interleaved(struct fec_context *ctx, uint64_t i,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* FIXME: read_lseek_blockwise candidate */
|
||||||
if (lseek(ctx->inputs[n].fd, ctx->inputs[n].start + offset, SEEK_SET) < 0)
|
if (lseek(ctx->inputs[n].fd, ctx->inputs[n].start + offset, SEEK_SET) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
return (read_buffer(ctx->inputs[n].fd, output, count) == (ssize_t)count) ? 0 : -1;
|
return (read_buffer(ctx->inputs[n].fd, output, count) == (ssize_t)count) ? 0 : -1;
|
||||||
|
|||||||
Reference in New Issue
Block a user