Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/patchelf
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1fa4d36fead4
Choose a base ref
...
head repository: NixOS/patchelf
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 27ffe8ae871e
Choose a head ref
  • 2 commits
  • 1 file changed
  • 2 contributors

Commits on May 8, 2018

  1. Copy the full SHA
    ba2695a View commit details

Commits on May 9, 2018

  1. Merge pull request #148 from stmarkevich/bigfile

    fix reading and writing big files (e.g. > 2Gb)
    edolstra authored May 9, 2018

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    27ffe8a View commit details
Showing with 12 additions and 2 deletions.
  1. +12 −2 src/patchelf.cc
14 changes: 12 additions & 2 deletions src/patchelf.cc
Original file line number Diff line number Diff line change
@@ -332,7 +332,12 @@ static FileContents readFile(std::string fileName,
int fd = open(fileName.c_str(), O_RDONLY);
if (fd == -1) throw SysError(fmt("opening '", fileName, "'"));

if ((size_t) read(fd, contents->data(), size) != size)
size_t bytesRead = 0;
ssize_t portion;
while ((portion = read(fd, contents->data() + bytesRead, size - bytesRead)) > 0)
bytesRead += portion;

if (bytesRead != size)
throw SysError(fmt("reading '", fileName, "'"));

close(fd);
@@ -496,7 +501,12 @@ static void writeFile(std::string fileName, FileContents contents)
if (fd == -1)
error("open");

if (write(fd, contents->data(), contents->size()) != (off_t) contents->size())
size_t bytesWritten = 0;
ssize_t portion;
while ((portion = write(fd, contents->data() + bytesWritten, contents->size() - bytesWritten)) > 0)
bytesWritten += portion;

if (bytesWritten != contents->size())
error("write");

if (close(fd) != 0)