[CRIU] [PATCH] spfs: do not tolerate file existence on creation

Stanislav Kinsburskiy skinsbursky at virtuozzo.com
Thu Jul 7 02:40:53 PDT 2016


There are no races in file creation anymore, because they are created
sequentially by main criu process.
So, let's treat -EEXIST as error now.

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

diff --git a/criu/spfs.c b/criu/spfs.c
index 949c333..476af09 100644
--- a/criu/spfs.c
+++ b/criu/spfs.c
@@ -129,10 +129,8 @@ static int create_reg_file(int ns_root_fd, const char *file_path, mode_t mode, s
 
 	fd = openat(ns_root_fd, file_path, O_CREAT | O_EXCL | O_WRONLY, 0777);
 	if (fd < 0) {
-		if (errno != EEXIST) {
-			pr_perror("failed to create regular file %s", file_path);
-			err = -errno;
-		}
+		pr_perror("failed to create regular file %s", file_path);
+		err = -errno;
 		goto free_path;
 	}
 
@@ -174,7 +172,7 @@ static int create_fifo(int ns_root_fd, const char *file_path, mode_t mode, size_
 	if (err)
 		goto free_path;
 
-	if (mkfifoat(ns_root_fd, file_path, 0777) && (errno != EEXIST)) {
+	if (mkfifoat(ns_root_fd, file_path, 0777)) {
 		pr_perror("failed to create fifo %s", file_path);
 		err = -errno;
 		goto free_path;



More information about the CRIU mailing list