summaryrefslogtreecommitdiffstats
path: root/recipes-devtools/pseudo/files/0001-Add-check-for-existence-of-old-file-to-renameat.patch
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-devtools/pseudo/files/0001-Add-check-for-existence-of-old-file-to-renameat.patch')
-rw-r--r--recipes-devtools/pseudo/files/0001-Add-check-for-existence-of-old-file-to-renameat.patch40
1 files changed, 40 insertions, 0 deletions
diff --git a/recipes-devtools/pseudo/files/0001-Add-check-for-existence-of-old-file-to-renameat.patch b/recipes-devtools/pseudo/files/0001-Add-check-for-existence-of-old-file-to-renameat.patch
new file mode 100644
index 0000000..3da2ad7
--- /dev/null
+++ b/recipes-devtools/pseudo/files/0001-Add-check-for-existence-of-old-file-to-renameat.patch
@@ -0,0 +1,40 @@
1From 41bb6c818a7ec9eeb33b60302c55c9c5ee393c5f Mon Sep 17 00:00:00 2001
2From: Anton Gerasimov <anton@advancedtelematic.com>
3Date: Fri, 30 Sep 2016 17:12:19 +0200
4Subject: [PATCH 1/1] Add check for existence of old file to renameat
5
6---
7 ports/unix/guts/renameat.c | 7 ++++++-
8 1 file changed, 6 insertions(+), 1 deletion(-)
9
10diff --git a/ports/unix/guts/renameat.c b/ports/unix/guts/renameat.c
11index ade0509..d5e36fa 100644
12--- a/ports/unix/guts/renameat.c
13+++ b/ports/unix/guts/renameat.c
14@@ -11,6 +11,7 @@
15 int oldrc, newrc;
16 int save_errno;
17 int old_db_entry = 0;
18+ int may_unlinked = 0;
19
20 pseudo_debug(PDBGF_FILE, "renameat: %d,%s->%d,%s\n",
21 olddirfd, oldpath ? oldpath : "<nil>",
22@@ -44,10 +45,14 @@
23 /* as with unlink, we have to mark that the file may get deleted */
24 msg = pseudo_client_op(OP_MAY_UNLINK, 0, -1, newdirfd, newpath, newrc ? NULL : &newbuf);
25 if (msg && msg->result == RESULT_SUCCEED)
26+ may_unlinked = 1;
27+ msg = pseudo_client_op(OP_STAT, 0, -1, olddirfd, oldpath, oldrc ? NULL : &oldbuf);
28+ if (msg && msg->result == RESULT_SUCCEED)
29 old_db_entry = 1;
30+
31 rc = real_renameat(olddirfd, oldpath, newdirfd, newpath);
32 save_errno = errno;
33- if (old_db_entry) {
34+ if (may_unlinked) {
35 if (rc == -1) {
36 /* since we failed, that wasn't really unlinked -- put
37 * it back.
38--
392.9.3
40