lib/deltas: Use pread() instead of lseek()+read()

That's why the syscall was invented, so let's use it. Just noticed while reading
the code while working on another patch.

Closes: #1270
Approved by: jlebon
This commit is contained in:
Colin Walters 2017-10-13 20:51:39 -04:00 committed by Atomic Bot
parent bb05b187b6
commit 93457071cb
1 changed files with 1 additions and 3 deletions

View File

@ -719,15 +719,13 @@ dispatch_write (OstreeRepo *repo,
{ {
if (state->read_source_fd != -1) if (state->read_source_fd != -1)
{ {
if (lseek (state->read_source_fd, content_offset, SEEK_SET) == -1)
return glnx_throw_errno_prefix (error, "lseek");
while (content_size > 0) while (content_size > 0)
{ {
char buf[4096]; char buf[4096];
gssize bytes_read; gssize bytes_read;
do do
bytes_read = read (state->read_source_fd, buf, MIN(sizeof(buf), content_size)); bytes_read = pread (state->read_source_fd, buf, MIN(sizeof(buf), content_size), content_offset);
while (G_UNLIKELY (bytes_read == -1 && errno == EINTR)); while (G_UNLIKELY (bytes_read == -1 && errno == EINTR));
if (bytes_read == -1) if (bytes_read == -1)
return glnx_throw_errno_prefix (error, "read"); return glnx_throw_errno_prefix (error, "read");