[CRIU] [PATCH] zdtm: lock can belong to child or parent

Andrey Vagin avagin at openvz.org
Tue May 5 05:56:47 PDT 2015


Locks created by flock() are associated with an open file description
This means that duplicate file descriptors (created by, for  example,
fork or  dup)  refer  to  the  same  lock.

Reported-by: Mr Jenkins
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 test/zdtm/live/static/file_locks02.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/test/zdtm/live/static/file_locks02.c b/test/zdtm/live/static/file_locks02.c
index 242a861..ef4371c 100644
--- a/test/zdtm/live/static/file_locks02.c
+++ b/test/zdtm/live/static/file_locks02.c
@@ -16,7 +16,7 @@ const char *test_author	= "Pavel Emelyanov <xemul at parallels.com>";
 char *filename;
 TEST_OPTION(filename, string, "file name", 1);
 
-static int check_file_locks()
+static int check_file_locks(pid_t child)
 {
 	FILE		*fp_locks = NULL;
 	char		buf[100], fl_flag[16], fl_type[16], fl_option[16];
@@ -44,7 +44,7 @@ static int check_file_locks()
 			break;
 		}
 
-		if (fl_owner != pid)
+		if (fl_owner != pid && fl_owner != child)
 			continue;
 
 		if (!strcmp(fl_flag, "FLOCK") &&
@@ -90,7 +90,7 @@ int main(int argc, char **argv)
 	test_daemon();
 	test_waitsig();
 
-	if (check_file_locks())
+	if (check_file_locks(pid))
 		pass();
 	else
 		fail("Flock file locks check failed");
-- 
2.1.0



More information about the CRIU mailing list