[CRIU] [PATCH] syscall: use a correct type for timer_t

Andrey Vagin avagin at openvz.org
Fri Dec 25 12:51:54 PST 2015


From: Andrew Vagin <avagin at virtuozzo.com>

timer_t is (void *) in glibc, but timer_t is (int) in kernel.
When we call system calls, we need to use timer_t from kernl.

https://github.com/xemul/criu/issues/98
Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
 arch/arm/syscall.def             | 6 +++---
 arch/ppc64/syscall-ppc64.def     | 6 +++---
 arch/x86/syscalls/syscall_32.tbl | 6 +++---
 arch/x86/syscalls/syscall_64.tbl | 6 +++---
 include/syscall-types.h          | 3 +++
 pie/restorer.c                   | 8 ++++----
 6 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/arch/arm/syscall.def b/arch/arm/syscall.def
index 422aea4..03b70d7 100644
--- a/arch/arm/syscall.def
+++ b/arch/arm/syscall.def
@@ -80,11 +80,11 @@ gettid				178	224	(void)
 futex				98	240	(u32 *uaddr, int op, u32 val, struct timespec *utime, u32 *uaddr2, u32 val3)
 set_tid_address			96	256	(int *tid_addr)
 restart_syscall			128	0	(void)
-timer_create			107	257	(clockid_t which_clock, struct sigevent *timer_event_spec, timer_t *created_timer_id)
-timer_settime			110	258	(timer_t timer_id, int flags, const struct itimerspec *new_setting, struct itimerspec *old_setting)
+timer_create			107	257	(clockid_t which_clock, struct sigevent *timer_event_spec, kernel_timer_t *created_timer_id)
+timer_settime			110	258	(kernel_timer_t timer_id, int flags, const struct itimerspec *new_setting, struct itimerspec *old_setting)
 timer_gettime			108	259	(int timer_id, const struct itimerspec *setting)
 timer_getoverrun		109	260	(int timer_id)
-timer_delete			111	261	(timer_t timer_id)
+timer_delete			111	261	(kernel_timer_t timer_id)
 clock_gettime			113	263	(const clockid_t which_clock, const struct timespec *tp)
 exit_group			94	248	(int error_code)
 set_robust_list			99	338	(struct robust_list_head *head, size_t len)
diff --git a/arch/ppc64/syscall-ppc64.def b/arch/ppc64/syscall-ppc64.def
index bce66f5..e48bd29 100644
--- a/arch/ppc64/syscall-ppc64.def
+++ b/arch/ppc64/syscall-ppc64.def
@@ -77,11 +77,11 @@ __NR_gettid		207		sys_gettid		(void)
 __NR_futex		221		sys_futex		(u32 *uaddr, int op, u32 val, struct timespec *utime, u32 *uaddr2, u32 val3)
 __NR_set_tid_address	232		sys_set_tid_address	(int *tid_addr)
 __NR_restart_syscall	0		sys_restart_syscall	(void)
-__NR_sys_timer_create	240		sys_timer_create	(clockid_t which_clock, struct sigevent *timer_event_spec, timer_t *created_timer_id)
-__NR_sys_timer_settime	241		sys_timer_settime	(timer_t timer_id, int flags, const struct itimerspec *new_setting, struct itimerspec *old_setting)
+__NR_sys_timer_create	240		sys_timer_create	(clockid_t which_clock, struct sigevent *timer_event_spec, kernel_timer_t *created_timer_id)
+__NR_sys_timer_settime	241		sys_timer_settime	(kernel_timer_t timer_id, int flags, const struct itimerspec *new_setting, struct itimerspec *old_setting)
 __NR_sys_timer_gettime	242		sys_timer_gettime	(int timer_id, const struct itimerspec *setting)
 __NR_sys_timer_getoverrun	243		sys_timer_getoverrun	(int timer_id)
-__NR_sys_timer_delete	244		sys_timer_delete	(timer_t timer_id)
+__NR_sys_timer_delete	244		sys_timer_delete	(kernel_timer_t timer_id)
 __NR_clock_gettime	246		sys_clock_gettime	(const clockid_t which_clock, const struct timespec *tp)
 __NR_exit_group		234		sys_exit_group		(int error_code)
 __NR_waitid		272		sys_waitid		(int which, pid_t pid, struct siginfo *infop, int options, struct rusage *ru)
diff --git a/arch/x86/syscalls/syscall_32.tbl b/arch/x86/syscalls/syscall_32.tbl
index 4aca249..0d004cc 100644
--- a/arch/x86/syscalls/syscall_32.tbl
+++ b/arch/x86/syscalls/syscall_32.tbl
@@ -69,11 +69,11 @@ __NR_io_setup		245		sys_io_setup		(unsigned nr_reqs, aio_context_t *ctx32p)
 __NR_io_getevents	247		sys_io_getevents	(aio_context_t ctx_id, long min_nr, long nr, struct io_event *events, struct timespec *timeout)
 __NR_exit_group		252		sys_exit_group		(int error_code)
 __NR_set_tid_address	258		sys_set_tid_address	(int *tid_addr)
-__NR_timer_create	259		sys_timer_create	(clockid_t which_clock, struct sigevent *timer_event_spec, timer_t *created_timer_id)
-__NR_timer_settime	260		sys_timer_settime	(timer_t timer_id, int flags, struct itimerspec *new, struct itimerspec *old)
+__NR_timer_create	259		sys_timer_create	(clockid_t which_clock, struct sigevent *timer_event_spec, kernel_timer_t *created_timer_id)
+__NR_timer_settime	260		sys_timer_settime	(kernel_timer_t timer_id, int flags, struct itimerspec *new, struct itimerspec *old)
 __NR_timer_gettime	261		sys_timer_gettime	(int timer_id, struct itimerspec *setting)
 __NR_timer_getoverrun	262		sys_timer_getoverrun	(int timer_id)
-__NR_timer_delete	263		sys_timer_delete	(timer_t timer_id)
+__NR_timer_delete	263		sys_timer_delete	(kernel_timer_t timer_id)
 __NR_clock_gettime	265		sys_clock_gettime	(int which_clock, struct timespec *tp)
 __NR_seccomp		354		sys_seccomp		(unsigned int op, unsigned int flags, const char *uargs)
 __NR_waitid		284		sys_waitid		(int which, pid_t pid, struct siginfo *infop, int options, struct rusage *ru)
diff --git a/arch/x86/syscalls/syscall_64.tbl b/arch/x86/syscalls/syscall_64.tbl
index 221b621..1b53aee 100644
--- a/arch/x86/syscalls/syscall_64.tbl
+++ b/arch/x86/syscalls/syscall_64.tbl
@@ -78,11 +78,11 @@ __NR_io_getevents		208		sys_io_getevents	(aio_context_t ctx, long min_nr, long n
 __NR_get_thread_area		211		sys_get_thread_area	(user_desc_t *info)
 __NR_set_tid_address		218		sys_set_tid_address	(int *tid_addr)
 __NR_restart_syscall		219		sys_restart_syscall	(void)
-__NR_sys_timer_create		222		sys_timer_create	(clockid_t which_clock, struct sigevent *timer_event_spec, timer_t *created_timer_id)
-__NR_sys_timer_settime		223		sys_timer_settime	(timer_t timer_id, int flags, const struct itimerspec *new_setting, struct itimerspec *old_setting)
+__NR_sys_timer_create		222		sys_timer_create	(clockid_t which_clock, struct sigevent *timer_event_spec, kernel_timer_t *created_timer_id)
+__NR_sys_timer_settime		223		sys_timer_settime	(kernel_timer_t timer_id, int flags, const struct itimerspec *new_setting, struct itimerspec *old_setting)
 __NR_sys_timer_gettime		224		sys_timer_gettime	(int timer_id, const struct itimerspec *setting)
 __NR_sys_timer_getoverrun	225		sys_timer_getoverrun	(int timer_id)
-__NR_sys_timer_delete		226		sys_timer_delete	(timer_t timer_id)
+__NR_sys_timer_delete		226		sys_timer_delete	(kernel_timer_t timer_id)
 __NR_clock_gettime		228		sys_clock_gettime	(const clockid_t which_clock, const struct timespec *tp)
 __NR_exit_group			231		sys_exit_group		(int error_code)
 __NR_openat			257		sys_openat		(int dfd, const char *filename, int flags, int mode)
diff --git a/include/syscall-types.h b/include/syscall-types.h
index d553a4b..5aff6df 100644
--- a/include/syscall-types.h
+++ b/include/syscall-types.h
@@ -82,4 +82,7 @@ struct krlimit {
 
 struct siginfo;
 
+/* Type of timers in the kernel.  */
+typedef int kernel_timer_t;
+
 #endif /* __CR_SYSCALL_TYPES_H__ */
diff --git a/pie/restorer.c b/pie/restorer.c
index 283481c..d99c92d 100644
--- a/pie/restorer.c
+++ b/pie/restorer.c
@@ -688,7 +688,7 @@ static int timerfd_arm(struct task_restore_args *args)
 static int create_posix_timers(struct task_restore_args *args)
 {
 	int ret, i;
-	timer_t next_id;
+	kernel_timer_t next_id;
 	struct sigevent sev;
 
 	for (i = 0; i < args->posix_timers_n; i++) {
@@ -703,12 +703,12 @@ static int create_posix_timers(struct task_restore_args *args)
 				return ret;
 			}
 
-			if ((long)next_id == args->posix_timers[i].spt.it_id)
+			if (next_id == args->posix_timers[i].spt.it_id)
 				break;
 
 			ret = sys_timer_delete(next_id);
 			if (ret < 0) {
-				pr_err("Can't remove temporaty posix timer %lx\n", (long) next_id);
+				pr_err("Can't remove temporaty posix timer 0x%x\n", next_id);
 				return ret;
 			}
 
@@ -729,7 +729,7 @@ static void restore_posix_timers(struct task_restore_args *args)
 
 	for (i = 0; i < args->posix_timers_n; i++) {
 		rt = &args->posix_timers[i];
-		sys_timer_settime((timer_t)rt->spt.it_id, 0, &rt->val, NULL);
+		sys_timer_settime((kernel_timer_t)rt->spt.it_id, 0, &rt->val, NULL);
 	}
 }
 static void *bootstrap_start;
-- 
2.4.3



More information about the CRIU mailing list