Commit da1be409 authored by Laurent Dufour's avatar Laurent Dufour Committed by Pavel Emelyanov

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: 's avatarLaurent Dufour <ldufour@linux.vnet.ibm.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 1ad78171
......@@ -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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment