[CRIU] [PATCH] dump: fix parsing of /proc/locks

Andrey Vagin avagin at openvz.org
Wed Feb 6 04:47:47 EST 2013


is_blocked should be determined for each line independently.

For example:
1: POSIX  ADVISORY  WRITE 1974 fd:01:392012 0 EOF
2: POSIX  ADVISORY  WRITE 1974 fd:01:392011 0 EOF
3: POSIX  ADVISORY  WRITE 1698 fd:01:1196619 0 EOF
4: POSIX  ADVISORY  WRITE 1698 fd:01:1196620 0 EOF
5: POSIX  ADVISORY  WRITE 1698 fd:01:1196621 0 EOF
6: POSIX  ADVISORY  WRITE 1689 fd:01:1429204 0 EOF
7: POSIX  ADVISORY  WRITE 1690 fd:01:1429202 0 EOF
8: POSIX  ADVISORY  WRITE 1690 fd:01:1429201 0 0
8: -> POSIX  ADVISORY  WRITE 1701 fd:01:1429201 0 0
9: POSIX  ADVISORY  WRITE 1688 fd:01:1429206 0 EOF
10: FLOCK  ADVISORY  WRITE 1694 fd:01:1196520 0 EOF
11: POSIX  ADVISORY  WRITE 862 00:0f:12421 0 EOF
12: POSIX  ADVISORY  WRITE 846 00:0f:12377 0 EOF
13: FLOCK  ADVISORY  WRITE 821 00:0f:11378 0 EOF
14: POSIX  ADVISORY  WRITE 459 00:0f:9826 0 EOF
15: POSIX  ADVISORY  WRITE 511 00:0f:10413 0 EOF

Without this patch crtools returns the error:
(00.000613) Error (proc_parse.c:1089): Invalid file lock info!

It's because is_blocked is set in "true" for the line 8 and
it becomes "true" for the line 9.

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 proc_parse.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/proc_parse.c b/proc_parse.c
index 6b6df03..d1ed024 100644
--- a/proc_parse.c
+++ b/proc_parse.c
@@ -1086,7 +1086,7 @@ static int parse_file_lock_buf(char *buf, struct file_lock *fl,
 	}
 
 	if (num < 10) {
-		pr_perror("Invalid file lock info!");
+		pr_perror("Invalid file lock info: %s", buf);
 		return -1;
 	}
 
@@ -1099,7 +1099,7 @@ int parse_file_locks(void)
 
 	FILE	*fl_locks;
 	int	ret = 0;
-	bool	is_blocked = false;
+	bool	is_blocked;
 
 	fl_locks = fopen("/proc/locks", "r");
 	if (!fl_locks) {
@@ -1108,8 +1108,7 @@ int parse_file_locks(void)
 	}
 
 	while (fgets(buf, BUF_SIZE, fl_locks)) {
-		if (strstr(buf, "->"))
-			is_blocked = true;
+		is_blocked = strstr(buf, "->") != NULL;
 
 		fl = alloc_file_lock();
 		if (!fl) {
-- 
1.7.11.7



More information about the CRIU mailing list