* @brief Set or modify the expiration time for a timer. * * This function is used to arm or re-arm a timer associated with a file descriptor created * by `sys_timerfd_create`. It allows setting a new expiration time and can also return * the previous timer configuration. * * @param[in] fd The file descriptor referring to the timer, which was created using * `sys_timerf
| 10671 | * can retrieve the expiration event by reading from the file descriptor. |
| 10672 | */ |
| 10673 | sysret_t sys_timerfd_settime(int fd, int flags, const struct itimerspec *new, struct itimerspec *old) |
| 10674 | { |
| 10675 | int ret = -1; |
| 10676 | struct itimerspec *knew = RT_NULL; |
| 10677 | struct itimerspec *kold = RT_NULL; |
| 10678 | |
| 10679 | if (new == RT_NULL) |
| 10680 | return -EINVAL; |
| 10681 | |
| 10682 | if (!lwp_user_accessable((void *)new, sizeof(struct itimerspec))) |
| 10683 | { |
| 10684 | return -EFAULT; |
| 10685 | } |
| 10686 | |
| 10687 | knew = kmem_get(sizeof(struct itimerspec)); |
| 10688 | |
| 10689 | if (knew) |
| 10690 | { |
| 10691 | lwp_get_from_user(knew, (void*)new, sizeof(struct itimerspec)); |
| 10692 | |
| 10693 | if (old) |
| 10694 | { |
| 10695 | if (!lwp_user_accessable((void *)old, sizeof(struct itimerspec))) |
| 10696 | { |
| 10697 | kmem_put(knew); |
| 10698 | return -EFAULT; |
| 10699 | } |
| 10700 | |
| 10701 | kold = kmem_get(sizeof(struct itimerspec)); |
| 10702 | if (kold == RT_NULL) |
| 10703 | { |
| 10704 | kmem_put(knew); |
| 10705 | return -ENOMEM; |
| 10706 | } |
| 10707 | } |
| 10708 | |
| 10709 | ret = timerfd_settime(fd, flags, knew, kold); |
| 10710 | |
| 10711 | if (old) |
| 10712 | { |
| 10713 | lwp_put_to_user(old, kold, sizeof(*kold)); |
| 10714 | kmem_put(kold); |
| 10715 | } |
| 10716 | |
| 10717 | kmem_put(knew); |
| 10718 | } |
| 10719 | |
| 10720 | return (ret < 0 ? GET_ERRNO() : ret); |
| 10721 | } |
| 10722 | |
| 10723 | /** |
| 10724 | * @brief Retrieve the current configuration of a timer. |
nothing calls this directly
no test coverage detected