Blob Blame History Raw
From 3aca580025b38aa043f6ef82f24ecab2d2d258e9 Mon Sep 17 00:00:00 2001
From: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Date: Thu, 13 Feb 2020 18:26:52 +0300
Subject: [PATCH 058/120] files-reg: temporary remount writable the mount we do
 unlink on

Previousely I din't mention this case because we had bad error handling
in ghost cleanup path.

Without these patch but with proper error handling for unlink we have an
error in mntns_ghost01 test:

Error (criu/files-reg.c:2269): Failed to unlink the remap file:
Read-only file system

Cherry-picked from Virtuozzo criu:
https://src.openvz.org/projects/OVZ/repos/criu/commits/151c859e1

Changes: check lookup_mnt_id return for NULL

Fixes: fd0a3cd9efb9 ("mount: remount ro mounts writable before
ghost-file restore")
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
---
 criu/files-reg.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/criu/files-reg.c b/criu/files-reg.c
index 0e126a32e..57403d2c6 100644
--- a/criu/files-reg.c
+++ b/criu/files-reg.c
@@ -2133,6 +2133,11 @@ ext:
 
 	if (rfi->remap) {
 		if (!rfi->remap->is_dir) {
+			struct mount_info *mi = lookup_mnt_id(rfi->rfe->mnt_id);
+
+			if (mi && try_remount_writable(mi, true))
+				goto err;
+
 			pr_debug("Unlink: %d:%s\n", rfi->rfe->mnt_id, rfi->path);
 			if (unlinkat(mntns_root, rfi->path, 0)) {
 				pr_perror("Failed to unlink the remap file");
-- 
2.34.1