Commit 64f3df44 authored by Ondrej Kozina's avatar Ondrej Kozina Committed by Milan Broz

Use read/write buffer functions where appropriate.

parent 42ccddef
......@@ -201,7 +201,7 @@ int LUKS_hdr_backup(const char *backup_file, struct crypt_device *ctx)
r = -EINVAL;
goto out;
}
if (write(devfd, buffer, buffer_size) < buffer_size) {
if (write_buffer(devfd, buffer, buffer_size) < buffer_size) {
log_err(ctx, _("Cannot write header backup file %s.\n"), backup_file);
r = -EIO;
goto out;
......@@ -254,7 +254,7 @@ int LUKS_hdr_restore(
goto out;
}
if (read(devfd, buffer, buffer_size) < buffer_size) {
if (read_buffer(devfd, buffer, buffer_size) < buffer_size) {
log_err(ctx, _("Cannot read header backup file %s.\n"), backup_file);
r = -EIO;
goto out;
......@@ -497,7 +497,7 @@ int LUKS_read_phdr_backup(const char *backup_file,
return -ENOENT;
}
if (read(devfd, hdr, hdr_size) < hdr_size)
if (read_buffer(devfd, hdr, hdr_size) < hdr_size)
r = -EIO;
else {
LUKS_fix_header_compatible(hdr);
......
......@@ -468,8 +468,7 @@ static int TCRYPT_pool_keyfile(struct crypt_device *cd,
return -EIO;
}
/* FIXME: add while */
data_size = read(fd, data, TCRYPT_KEYFILE_LEN);
data_size = read_buffer(fd, data, TCRYPT_KEYFILE_LEN);
close(fd);
if (data_size < 0) {
log_err(cd, _("Error reading keyfile %s.\n"), keyfile);
......
......@@ -137,7 +137,7 @@ ssize_t write_blockwise(int fd, int bsize, void *orig_buf, size_t count)
buf = orig_buf;
if (solid) {
r = write(fd, buf, solid);
r = write_buffer(fd, buf, solid);
if (r < 0 || r != (ssize_t)solid)
goto out;
}
......@@ -147,7 +147,7 @@ ssize_t write_blockwise(int fd, int bsize, void *orig_buf, size_t count)
if (!hangover_buf)
goto out;
r = read(fd, hangover_buf, bsize);
r = read_buffer(fd, hangover_buf, bsize);
if (r < 0 || r < (ssize_t)hangover)
goto out;
......@@ -159,7 +159,7 @@ ssize_t write_blockwise(int fd, int bsize, void *orig_buf, size_t count)
goto out;
memcpy(hangover_buf, (char*)buf + solid, hangover);
r = write(fd, hangover_buf, bsize);
r = write_buffer(fd, hangover_buf, bsize);
if (r < 0 || r < (ssize_t)hangover)
goto out;
}
......@@ -192,7 +192,7 @@ ssize_t read_blockwise(int fd, int bsize, void *orig_buf, size_t count) {
} else
buf = orig_buf;
r = read(fd, buf, solid);
r = read_buffer(fd, buf, solid);
if(r < 0 || r != (ssize_t)solid)
goto out;
......@@ -200,7 +200,7 @@ ssize_t read_blockwise(int fd, int bsize, void *orig_buf, size_t count) {
hangover_buf = aligned_malloc(&hangover_buf_base, bsize, alignment);
if (!hangover_buf)
goto out;
r = read(fd, hangover_buf, bsize);
r = read_buffer(fd, hangover_buf, bsize);
if (r < 0 || r < (ssize_t)hangover)
goto out;
......@@ -243,7 +243,7 @@ ssize_t write_lseek_blockwise(int fd, int bsize, char *buf, size_t count, off_t
if (!frontPadBuf)
goto out;
r = read(fd, frontPadBuf, bsize);
r = read_buffer(fd, frontPadBuf, bsize);
if (r < 0 || r != bsize)
goto out;
......@@ -256,7 +256,7 @@ ssize_t write_lseek_blockwise(int fd, int bsize, char *buf, size_t count, off_t
if (lseek(fd, offset - frontHang, SEEK_SET) < 0)
goto out;
r = write(fd, frontPadBuf, bsize);
r = write_buffer(fd, frontPadBuf, bsize);
if (r < 0 || r != bsize)
goto out;
......
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