[v2,02/36] files: Do not lost original errno value

Submitted by Kirill Tkhai on Feb. 3, 2017, 4:11 p.m.

Details

Message ID 148613831401.3612.7683371870287739082.stgit@localhost.localdomain
State New
Series "Nested user namespaces support"
Headers show

Commit Message

Kirill Tkhai Feb. 3, 2017, 4:11 p.m.
The callers of rfi_remap() are interested in a errno,
linkat_hard() returns. So, preserve errno before we
call rm_parent_dirs().

Reported-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 criu/files-reg.c |    2 ++
 1 file changed, 2 insertions(+)

Patch hide | download patch | download mbox

diff --git a/criu/files-reg.c b/criu/files-reg.c
index e8d74a691..df270a646 100644
--- a/criu/files-reg.c
+++ b/criu/files-reg.c
@@ -1419,7 +1419,9 @@  static int rfi_remap(struct reg_file_info *rfi, int *level)
 
 	if (linkat_hard(mntns_root, rpath, mntns_root, path,
 			rfi->remap->uid, rfi->remap->gid, 0) < 0) {
+		int errno_saved = errno;
 		rm_parent_dirs(mntns_root, path, *level);
+		errno = errno_saved;
 		return -1;
 	}