From da1be409ccff85c3c14915bb1b5ad0492b656a22 Mon Sep 17 00:00:00 2001 From: Laurent Dufour Date: Thu, 15 Oct 2015 18:23:00 +0300 Subject: [PATCH] test: rtc don't use hard coded major value 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 Signed-off-by: Pavel Emelyanov --- 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 d17da44a7..0d6ffeac0 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) {