files: Tune up false perror message

Submitted by Pavel Emelianov on Aug. 23, 2016, 7:51 p.m.

Details

Message ID 57BCA92D.6080200@virtuozzo.com
State Accepted
Series "files: Tune up false perror message"
Commit c593e8fc28891c0f0f57b7402278ce50fc49ef9a
Headers show

Commit Message

Pavel Emelianov Aug. 23, 2016, 7:51 p.m.
When linkat fails in uns we print error (!) and then sometimes
try some other way to linkat anyway %). Fix this place not
to produce the error message all the time, but only when it's
needed.

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>

---

Patch hide | download patch | download mbox

diff --git a/criu/files-reg.c b/criu/files-reg.c
index 03ad363..b91a2c3 100644
--- a/criu/files-reg.c
+++ b/criu/files-reg.c
@@ -1195,10 +1195,15 @@  static int linkat_hard(int odir, char *opath, int ndir, char *npath, uid_t owner
 	int errno_save;
 
 	ret = linkat(odir, opath, ndir, npath, 0);
-	if (ret < 0)
+	if (ret == 0)
+		return 0;
+
+	if (!( (errno == EPERM) && (root_ns_mask & CLONE_NEWUSER) )) {
+		errno_save = errno;
 		pr_perror("Can't link %s -> %s", opath, npath);
-	if (ret == 0 || errno != EPERM || !(root_ns_mask & CLONE_NEWUSER))
+		errno = errno_save;
 		return ret;
+	}
 
 	/*
 	 * Kernel before 4.3 has strange secutiry restrictions about