[CRIU] [PATCH] spfs: do not treat existent file as error in create_reg_file

Stanislav Kinsburskiy skinsbursky at virtuozzo.com
Fri May 27 02:42:36 PDT 2016


File can be created by another process already, which means there is nothing
to do.

Signed-off-by: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
---
 criu/spfs.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/criu/spfs.c b/criu/spfs.c
index 4b1bf1b..42d0d64 100644
--- a/criu/spfs.c
+++ b/criu/spfs.c
@@ -126,9 +126,11 @@ static int create_reg_file(int ns_root_fd, const char *file_path, mode_t mode, s
 		goto free_path;
 
 	fd = openat(ns_root_fd, file_path, O_CREAT | O_EXCL | O_WRONLY, 0777);
-	if ((fd < 0) && (errno != EEXIST)) {
-		pr_perror("failed to create regular file %s", file_path);
-		err = -errno;
+	if (fd < 0) {
+		if (errno != EEXIST) {
+			pr_perror("failed to create regular file %s", file_path);
+			err = -errno;
+		}
 		goto free_path;
 	}
 



More information about the CRIU mailing list