[CRIU] [PATCH 09/12] posix-timer: Restore and fix one timer
Pavel Tikhomirov
snorcht at gmail.com
Wed May 29 19:36:18 EDT 2013
Signed-off-by: Pavel Tikhomirov <snorcht at gmail.com>
---
cr-restore.c | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/cr-restore.c b/cr-restore.c
index 9dfaf1f..edd3f0d 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -63,6 +63,7 @@
#include "protobuf.h"
#include "protobuf/sa.pb-c.h"
#include "protobuf/itimer.pb-c.h"
+#include "protobuf/posix-timer.pb-c.h"
#include "protobuf/vma.pb-c.h"
#include "protobuf/rlimit.pb-c.h"
#include "protobuf/pagemap.pb-c.h"
@@ -1464,6 +1465,44 @@ out:
return ret;
}
+static inline int posix_timer_restore_and_fix(PosixTimerEntry *pte,
+ struct restore_posix_timer *pt)
+{
+ pt->val.it_interval.tv_sec = pte->isec;
+ pt->val.it_interval.tv_nsec = pte->insec;
+
+ if (!time_valid((unsigned long) pt->val.it_interval.tv_sec,
+ (unsigned long) pt->val.it_interval.tv_nsec, NSEC_PER_SEC)) {
+ pr_err("Invalid timer interval(posix)\n");
+ return -1;
+ }
+
+ if (pte->vsec == 0 && pte->vnsec == 0) {
+ // Remaining time was too short. Set it to
+ // interval to make the timer armed and work.
+ pt->val.it_value.tv_sec = pte->isec;
+ pt->val.it_value.tv_nsec = pte->insec;
+ } else {
+ pt->val.it_value.tv_sec = pte->vsec;
+ pt->val.it_value.tv_nsec = pte->vnsec;
+ }
+
+ if (!time_valid((unsigned long) pt->val.it_value.tv_sec,
+ (unsigned long) pt->val.it_value.tv_nsec, NSEC_PER_SEC)) {
+ pr_err("Invalid timer value(posix)\n");
+ return -1;
+ }
+
+ pt->it_id = pte->it_id;
+ pt->clock_id = pte->clock_id;
+ pt->si_signo = pte->si_signo;
+ pt->it_sigev_notify = pte->it_sigev_notify;
+ pt->sival_ptr.i = pte->sival_ptr;
+ pt->overrun = pte->overrun;
+
+ return 0;
+}
+
static inline int verify_cap_size(CredsEntry *ce)
{
return ((ce->n_cap_inh == CR_CAP_SIZE) && (ce->n_cap_eff == CR_CAP_SIZE) &&
--
1.7.9.5
More information about the CRIU
mailing list