1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
/*
* Check decoding of epoll_pwait2 syscall.
*
* Copyright (c) 2015-2024 Dmitry V. Levin <ldv@strace.io>
* All rights reserved.
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "tests.h"
#include "scno.h"
#include "xmalloc.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <linux/eventpoll.h>
#include "kernel_timespec.h"
#ifndef FD9_PATH
# define FD9_PATH ""
#endif
#ifndef SKIP_IF_PROC_IS_UNAVAILABLE
# define SKIP_IF_PROC_IS_UNAVAILABLE
#endif
static const char *errstr;
static long
k_epoll_pwait2(const unsigned int epfd,
const void *const events,
const unsigned int maxevents,
const void *const timeout,
const void *const sigmask,
const kernel_ulong_t sigsetsize)
{
const kernel_ulong_t fill = (kernel_ulong_t) 0xdefaced00000000ULL;
const kernel_ulong_t arg1 = fill | epfd;
const kernel_ulong_t arg2 = (unsigned long) events;
const kernel_ulong_t arg3 = fill | maxevents;
const kernel_ulong_t arg4 = (unsigned long) timeout;
const kernel_ulong_t arg5 = (unsigned long) sigmask;
const kernel_ulong_t arg6 = sigsetsize;
const long rc = syscall(__NR_epoll_pwait2,
arg1, arg2, arg3, arg4, arg5, arg6);
errstr = sprintrc(rc);
return rc;
}
int
main(void)
{
SKIP_IF_PROC_IS_UNAVAILABLE;
int fd = 9;
char *fd_str = xasprintf("%d%s", fd, FD9_PATH);
TAIL_ALLOC_OBJECT_CONST_PTR(struct epoll_event, events);
TAIL_ALLOC_OBJECT_CONST_PTR(kernel_timespec64_t, timeout);
TAIL_ALLOC_OBJECT_CONST_PTR(kernel_ulong_t, sigmask);
const unsigned int sigsetsize = sizeof(*sigmask);
k_epoll_pwait2(-1, events, fd, timeout, sigmask, fd);
#ifndef PATH_TRACING
printf("epoll_pwait2(-1, %p, %d, %p, %p, %u) = %s\n",
events, fd, timeout, sigmask, fd, errstr);
#endif
k_epoll_pwait2(fd, events, -1, timeout, sigmask, sigsetsize);
printf("epoll_pwait2(%s, %p, -1, %p, %p, %u) = %s\n",
fd_str, events, timeout, sigmask, sigsetsize, errstr);
/*
* Some positive tests should be added here
* when epoll_pwait2 becomes widely available.
*/
puts("+++ exited with 0 +++");
return 0;
}
|