[CRIU] [PATCH] flock: Don't assume device maj/min numbers are byte long

Cyrill Gorcunov gorcunov at openvz.org
Fri Oct 11 07:32:44 PDT 2013


Igor reported the following file lock

 | (00.003139) lockinfo: 4:POSIX ADVISORY WRITE 46567 b6:5f0b1:524702 0 EOF
 | (00.003154) lockinfo: 5:POSIX ADVISORY WRITE 46559 b6:5f0b1:524661 0 EOF
 | (00.003172) lockinfo: 6:POSIX ADVISORY WRITE 46543 b6:5f0b1:524326 0 0
 | (00.003188) lockinfo: 7:POSIX ADVISORY WRITE 46543 b6:5f0b1:524367 0 EOF

where device maj number is pretty big and parsing failed.
Fix it removing field width.

Reported-by: Igor Sukhih <igor at parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 proc_parse.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/proc_parse.c b/proc_parse.c
index d7add4e..e581e58 100644
--- a/proc_parse.c
+++ b/proc_parse.c
@@ -1077,19 +1077,19 @@ static int parse_file_lock_buf(char *buf, struct file_lock *fl,
 	int  num;
 
 	if (is_blocked) {
-		num = sscanf(buf, "%lld: -> %s %s %s %d %02x:%02x:%ld %lld %s",
+		num = sscanf(buf, "%lld: -> %s %s %s %d %x:%x:%ld %lld %s",
 			&fl->fl_id, fl->fl_flag, fl->fl_type, fl->fl_option,
 			&fl->fl_owner, &fl->maj, &fl->min, &fl->i_no,
 			&fl->start, fl->end);
 	} else {
-		num = sscanf(buf, "%lld:%s %s %s %d %02x:%02x:%ld %lld %s",
+		num = sscanf(buf, "%lld:%s %s %s %d %x:%x:%ld %lld %s",
 			&fl->fl_id, fl->fl_flag, fl->fl_type, fl->fl_option,
 			&fl->fl_owner, &fl->maj, &fl->min, &fl->i_no,
 			&fl->start, fl->end);
 	}
 
 	if (num < 10) {
-		pr_perror("Invalid file lock info: %s", buf);
+		pr_err("Invalid file lock info (%d): %s", num, buf);
 		return -1;
 	}
 
-- 
1.8.3.1



More information about the CRIU mailing list