[CRIU] [PATCH 2/2] files: linkat_hard() should return errno of linkat

Andrey Vagin avagin at openvz.org
Fri Nov 13 07:30:54 PST 2015


From: Andrew Vagin <avagin at virtuozzo.com>

errno is used in open_path()

Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
 files-reg.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/files-reg.c b/files-reg.c
index ae8da8e..849bdb0 100644
--- a/files-reg.c
+++ b/files-reg.c
@@ -1020,6 +1020,7 @@ static void convert_path_from_another_mp(char *src, char *dst, int dlen,
 static int linkat_hard(int odir, char *opath, int ndir, char *npath, uid_t owner)
 {
 	int ret, old_fsuid = -1;
+	int errno_save;
 
 	if (root_ns_mask & CLONE_NEWUSER)
 		/*
@@ -1041,6 +1042,7 @@ static int linkat_hard(int odir, char *opath, int ndir, char *npath, uid_t owner
 		old_fsuid = setfsuid(owner);
 
 	ret = linkat(odir, opath, ndir, npath, 0);
+	errno_save = errno;
 	if (ret < 0)
 		pr_perror("Can't link %s -> %s", opath, npath);
 
@@ -1054,6 +1056,7 @@ static int linkat_hard(int odir, char *opath, int ndir, char *npath, uid_t owner
 			 * the proper fsuid, then we'll abort the restore.
 			 */
 	}
+	errno = errno_save;
 
 	return ret;
 }
-- 
2.4.3



More information about the CRIU mailing list