static int _epoll_ctl_mod(epoll_t* epoll, int fd, struct oe_epoll_event* event)
{
    int ret = -1;
    oe_fd_t* desc;
    oe_host_fd_t host_epfd;
    oe_host_fd_t host_fd;
    struct oe_epoll_event host_event;
    int retval;
    bool locked = false;

    oe_errno = 0;

    /* Check parameters. */
    if (!epoll || !event)
        OE_RAISE_ERRNO(OE_EINVAL);

    if (!(desc = oe_fdtable_get(fd, OE_FD_TYPE_ANY)))
        OE_RAISE_ERRNO(oe_errno);

    /* Get the host fd for the epoll device. */
    host_epfd = epoll->host_fd;

    /* Get the host fd for the device. */
    if ((host_fd = desc->ops.fd.get_host_fd(desc)) == -1)
        OE_RAISE_ERRNO(oe_errno);

    /* Initialize the host event. */
    {
        const size_t num_bytes = sizeof(host_event);

        if (oe_memset_s(&host_event, num_bytes, 0, num_bytes) != OE_OK)
            OE_RAISE_ERRNO(OE_EINVAL);

        host_event.events = event->events;
        host_event.data.fd = fd;
    }

    // The host call and the map update must be done in an atomic operation.
    locked = true;
    oe_mutex_lock(&epoll->lock);

    if (oe_syscall_epoll_ctl_ocall(
            &retval, host_epfd, OE_EPOLL_CTL_MOD, host_fd, &host_event) !=
        OE_OK)
    {
        OE_RAISE_ERRNO(oe_errno);
    }

    /* Modify the mapping. */
    if (retval == 0)
    {
        mapping_t* const mapping = _map_find(epoll, fd);
        if (!mapping)
            OE_RAISE_ERRNO(OE_ENOENT);

        mapping->event = *event;
    }

    ret = 0;

done:
    if (locked)
        oe_mutex_unlock(&epoll->lock);

    return ret;
}
static int _epoll_ctl_mod(epoll_t* epoll, int fd, struct oe_epoll_event* event)
{
    int ret = -1;
    oe_fd_t* desc;
    oe_host_fd_t host_epfd;
    oe_host_fd_t host_fd;
    struct oe_epoll_event host_event;
    int retval;
    bool locked = false;

    oe_errno = 0;

     
    if (!epoll || !event)
        OE_RAISE_ERRNO(OE_EINVAL);

    if (!(desc = oe_fdtable_get(fd, OE_FD_TYPE_ANY)))
        OE_RAISE_ERRNO(oe_errno);

     
    host_epfd = epoll->host_fd;

     
    if ((host_fd = desc->ops.fd.get_host_fd(desc)) == -1)
        OE_RAISE_ERRNO(oe_errno);

     
    {
        const size_t num_bytes = sizeof(host_event);

        if (oe_memset_s(&host_event, num_bytes, 0, num_bytes) != OE_OK)
            OE_RAISE_ERRNO(OE_EINVAL);

        host_event.events = event->events;
        host_event.data.fd = fd;
    }

     
    locked = true;
    oe_mutex_lock(&epoll->lock);

    if (oe_syscall_epoll_ctl_ocall(
            &retval, host_epfd, OE_EPOLL_CTL_MOD, host_fd, &host_event) !=
        OE_OK)
    {
        OE_RAISE_ERRNO(oe_errno);
    }

     
    if (retval == 0)
    {
        mapping_t* const mapping = _map_find(epoll, fd);
        if (!mapping)
            OE_RAISE_ERRNO(OE_ENOENT);

        mapping->event = *event;
    }

    ret = 0;

done:
    if (locked)
        oe_mutex_unlock(&epoll->lock);

    return ret;
}