[CRIU] [PATCH] zdtm: create devices with proper major and minor numbers

Andrew Vagin avagin at openvz.org
Tue Nov 10 04:05:22 PST 2015


Currently numbers for /dev/net/tun and /dev/rtc are hardcoded and
they changed after the last kernel update.

Reported-by: Mr Jenkins
Signed-off-by: Andrew Vagin <avagin at openvz.org>
---
 test/zdtm/lib/ns.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/test/zdtm/lib/ns.c b/test/zdtm/lib/ns.c
index 420d9c2..989bcf1 100644
--- a/test/zdtm/lib/ns.c
+++ b/test/zdtm/lib/ns.c
@@ -342,6 +342,7 @@ int ns_init(int argc, char **argv)
 
 static int construct_root()
 {
+	struct stat st;
 	char *root;
 	int dfd;
 
@@ -366,9 +367,17 @@ static int construct_root()
 	mknod("dev/null", 0777 | S_IFCHR, makedev(1, 3));
 	chmod("dev/null", 0777);
 	mkdir("dev/net", 0777);
-	mknod("dev/net/tun", 0777 | S_IFCHR, makedev(10, 200));
+	if (stat("/dev/net/tun", &st)) {
+		fprintf(stderr, "Unable to stat /dev/net/tun: %m");
+		return -1;
+	}
+	mknod("dev/net/tun", 0777 | S_IFCHR, st.st_rdev);
 	chmod("dev/net/tun", 0777);
-	mknod("dev/rtc", 0777 | S_IFCHR, makedev(254, 0));
+	if (stat("/dev/rtc", &st)) {
+		fprintf(stderr, "Unable to stat /dev/rtc: %m");
+		return -1;
+	}
+	mknod("dev/rtc", 0777 | S_IFCHR, st.st_rdev);
 	chmod("dev/rtc", 0777);
 
 	if (fchdir(dfd)) {
-- 
2.4.3



More information about the CRIU mailing list