[CRIU] [PATCH] fix parse_mnt_flags() to dump/restore STRICTATIME correctly

Oleg Nesterov oleg at redhat.com
Fri Apr 24 11:32:22 PDT 2015


CRIU always retores the mounts as MNT_RELATIME. This is because the
kernel uses this mode by default, so we need to pass MS_STRICTATIME
explicitely if we didn't see "noatime" or "MS_RELATIME".

While at it, make mnt_opt2flag[] and sb_opt2flag "static", otherwise
gcc actually creates these arrays on stack even if there are "const".

Signed-off-by: Oleg Nesterov <oleg at redhat.com>
---
 proc_parse.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/proc_parse.c b/proc_parse.c
index 14ef589..bde6f59 100644
--- a/proc_parse.c
+++ b/proc_parse.c
@@ -878,7 +878,7 @@ static int do_opt2flag(char *opt, unsigned *flags,
 
 static int parse_mnt_flags(char *opt, unsigned *flags)
 {
-	const struct opt2flag mnt_opt2flag[] = {
+	static const struct opt2flag mnt_opt2flag[] = {
 		{ "rw", 0, },
 		{ "ro", MS_RDONLY, },
 		{ "nosuid", MS_NOSUID, },
@@ -890,12 +890,19 @@ static int parse_mnt_flags(char *opt, unsigned *flags)
 		{ },
 	};
 
-	return do_opt2flag(opt, flags, mnt_opt2flag, NULL);
+	if (do_opt2flag(opt, flags, mnt_opt2flag, NULL))
+		return -1;
+
+	/* Otherwise the kernel assumes RELATIME by default */
+	if ((*flags & (MS_RELATIME | MS_NOATIME)) == 0)
+		*flags = MS_STRICTATIME;
+
+	return 0;
 }
 
 static int parse_sb_opt(char *opt, unsigned *flags, char *uopt)
 {
-	const struct opt2flag sb_opt2flag[] = {
+	static const struct opt2flag sb_opt2flag[] = {
 		{ "rw", 0, },
 		{ "ro", MS_RDONLY, },
 		{ "sync", MS_SYNC, },
-- 
1.5.5.1




More information about the CRIU mailing list