[CRIU] [PATCH] test: rtc don't use hard coded major value

Laurent Dufour ldufour at linux.vnet.ibm.com
Thu Oct 15 08:23:41 PDT 2015


The /dev/rtc device major value may change depending on the
architecture, and kernel release. To ensure the test rtc is working
all the time, we no longer belong on hard coded major value but peek
it from /dev/rtc itself.

Signed-off-by: Laurent Dufour <ldufour at linux.vnet.ibm.com>
---
 test/zdtm/live/static/criu-rtc.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/test/zdtm/live/static/criu-rtc.c b/test/zdtm/live/static/criu-rtc.c
index d17da44a7894..0d6ffeac0d5f 100644
--- a/test/zdtm/live/static/criu-rtc.c
+++ b/test/zdtm/live/static/criu-rtc.c
@@ -23,19 +23,21 @@ int cr_plugin_dump_file(int fd, int id)
 	unsigned char buf[4096];
 	int img_fd, ret, len;
 	unsigned long irqp;
-	struct stat st;
+	struct stat st, st_rtc;
 
 	if (fstat(fd, &st) == -1) {
 		pr_perror("fstat");
 		return -1;
 	}
 
-#if defined(__PPC64__)
-#define RTC_DEV_MAJOR	253
-#else
-#define RTC_DEV_MAJOR	254
-#endif
-	if (major(st.st_rdev) != RTC_DEV_MAJOR || minor(st.st_rdev) != 0)
+	ret = stat("/dev/rtc", &st_rtc);
+	if (ret == -1) {
+		pr_perror("fstat");
+		return -1;
+	}
+
+	if (major(st.st_rdev) != major(st_rtc.st_rdev) ||
+	    minor(st.st_rdev) != 0)
 		return -ENOTSUP;
 
 	if (ioctl(fd, RTC_IRQP_READ, &irqp) == -1) {
-- 
1.9.1



More information about the CRIU mailing list