diff options
Diffstat (limited to 'meta/recipes-devtools/patchelf/patchelf/handle-read-only-files.patch')
-rw-r--r-- | meta/recipes-devtools/patchelf/patchelf/handle-read-only-files.patch | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/meta/recipes-devtools/patchelf/patchelf/handle-read-only-files.patch b/meta/recipes-devtools/patchelf/patchelf/handle-read-only-files.patch index 9fafec4b59..b755a263a4 100644 --- a/meta/recipes-devtools/patchelf/patchelf/handle-read-only-files.patch +++ b/meta/recipes-devtools/patchelf/patchelf/handle-read-only-files.patch @@ -1,53 +1,65 @@ -From 2a603acb65993698c21f1c6eb7664f93ad830d52 Mon Sep 17 00:00:00 2001 +From 682fb48c137b687477008b68863c2a0b73ed47d1 Mon Sep 17 00:00:00 2001 From: Fabio Berton <fabio.berton@ossystems.com.br> Date: Fri, 9 Sep 2016 16:00:42 -0300 Subject: [PATCH] handle read-only files -Organization: O.S. Systems Software LTDA. Patch from: https://github.com/darealshinji/patchelf/commit/40e66392bc4b96e9b4eda496827d26348a503509 -Upstream-Status: Pending +Upstream-Status: Denied [https://github.com/NixOS/patchelf/pull/89] Signed-off-by: Fabio Berton <fabio.berton@ossystems.com.br> + --- src/patchelf.cc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) -diff --git a/src/patchelf.cc b/src/patchelf.cc -index 136098f..aea360e 100644 ---- a/src/patchelf.cc -+++ b/src/patchelf.cc -@@ -388,7 +388,17 @@ void ElfFile<ElfFileParamNames>::sortShdrs() +Index: git/src/patchelf.cc +=================================================================== +--- git.orig/src/patchelf.cc ++++ git/src/patchelf.cc +@@ -534,9 +534,19 @@ void ElfFile<ElfFileParamNames>::sortShd - static void writeFile(string fileName) + static void writeFile(const std::string & fileName, const FileContents & contents) { -- int fd = open(fileName.c_str(), O_TRUNC | O_WRONLY); + struct stat st; + int fd; + + debug("writing %s\n", fileName.c_str()); + +- int fd = open(fileName.c_str(), O_CREAT | O_TRUNC | O_WRONLY, 0777); + if (stat(fileName.c_str(), &st) != 0) + error("stat"); + + if (chmod(fileName.c_str(), 0600) != 0) + error("chmod"); + -+ fd = open(fileName.c_str(), O_TRUNC | O_WRONLY); ++ fd = open(fileName.c_str(), O_CREAT | O_TRUNC | O_WRONLY, 0777); + if (fd == -1) error("open"); -@@ -397,6 +407,10 @@ static void writeFile(string fileName) +@@ -551,8 +561,6 @@ static void writeFile(const std::string + bytesWritten += portion; + } - if (close(fd) != 0) - error("close"); +- if (close(fd) >= 0) +- return; + /* + * Just ignore EINTR; a retry loop is the wrong thing to do. + * +@@ -561,9 +569,11 @@ static void writeFile(const std::string + * http://utcc.utoronto.ca/~cks/space/blog/unix/CloseEINTR + * https://sites.google.com/site/michaelsafyan/software-engineering/checkforeintrwheninvokingclosethinkagain + */ +- if (errno == EINTR) +- return; +- error("close"); ++ if ((close(fd) < 0) && errno != EINTR) ++ error("close"); + + if (chmod(fileName.c_str(), st.st_mode) != 0) + error("chmod"); -+ } --- -2.1.4 - |