[CRIU] [PATCH 3/3] mount: Use mode from stat for deleted entries

Cyrill Gorcunov gorcunov at openvz.org
Wed Aug 26 07:15:25 PDT 2015


Even for deleted entries better to use permissions
from the target's stat call, this makes result close
to how would it look if program hadn't been checkpointed.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 mount.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mount.c b/mount.c
index 2a2dc7aafc97..3e2f27abc70e 100644
--- a/mount.c
+++ b/mount.c
@@ -2008,12 +2008,12 @@ do_bind:
 				}
 			}
 			if (S_ISDIR(st.st_mode)) {
-				if (mkdir(root, 0700)) {
+				if (mkdir(root, (st.st_mode & ~S_IFMT))) {
 					pr_perror("Can't re-create deleted directory %s\n", root);
 					return -1;
 				}
 			} else if (S_ISREG(st.st_mode)) {
-				if (open(root, O_WRONLY | O_CREAT | O_TRUNC, 0644) < 0) {
+				if (open(root, O_WRONLY | O_CREAT | O_TRUNC, (st.st_mode & ~S_IFMT)) < 0) {
 					pr_perror("Can't re-create deleted file %s\n", root);
 					return -1;
 				}
-- 
2.4.3



More information about the CRIU mailing list