UInt i;
struct vki_pollfd* ufds = (struct vki_pollfd *)ARG1;
*flags |= SfMayBlock;
- PRINT("sys_ppoll ( %p, %d, %p, %p, %llu )\n", ARG1,ARG2,ARG3,ARG4,ARG5);
+ PRINT("sys_ppoll ( %p, %d, %p, %p, %llu )\n", ARG1,ARG2,ARG3,ARG4,(ULong)ARG5);
PRE_REG_READ5(long, "ppoll",
struct vki_pollfd *, ufds, unsigned int, nfds,
struct vki_timespec *, tsp, vki_sigset_t *, sigmask,
POST_MEM_WRITE( ARG2, sizeof(struct vki_epoll_event)*RES ) ;
}
+PRE(sys_epoll_pwait)
+{
+ *flags |= SfMayBlock;
+ PRINT("sys_epoll_pwait ( %d, %p, %d, %d, %p, %llu )", ARG1,ARG2,ARG3,ARG4,ARG5,(ULong)ARG6);
+ PRE_REG_READ6(long, "epoll_pwait",
+ int, epfd, struct vki_epoll_event *, events,
+ int, maxevents, int, timeout, vki_sigset_t *, sigmask,
+ vki_size_t, sigsetsize);
+ PRE_MEM_WRITE( "epoll_pwait(events)", ARG2, sizeof(struct vki_epoll_event)*ARG3);
+ if (ARG4)
+ PRE_MEM_READ( "epoll_pwait(sigmask)", ARG5, sizeof(vki_sigset_t) );
+}
+POST(sys_epoll_pwait)
+{
+ vg_assert(SUCCESS);
+ if (RES > 0)
+ POST_MEM_WRITE( ARG2, sizeof(struct vki_epoll_event)*RES ) ;
+}
+
+PRE(sys_eventfd)
+{
+ PRINT("sys_eventfd ( %u )", ARG1);
+ PRE_REG_READ1(long, "sys_eventfd", unsigned int, count);
+}
+POST(sys_eventfd)
+{
+ if (!ML_(fd_allowed)(RES, "eventfd", tid, True)) {
+ VG_(close)(RES);
+ SET_STATUS_Failure( VKI_EMFILE );
+ } else {
+ if (VG_(clo_track_fds))
+ ML_(record_fd_open_nameless) (tid, RES);
+ }
+}
+
/* ---------------------------------------------------------------------
tid-related wrappers
------------------------------------------------------------------ */
PRE_REG_READ1(long, "timer_delete", vki_timer_t, timerid);
}
+/* ---------------------------------------------------------------------
+ timerfd* wrappers
+ See also http://lwn.net/Articles/260172/ for an overview.
+ See also /usr/src/linux/fs/timerfd.c for the implementation.
+ ------------------------------------------------------------------ */
+
+/* Returns True if running on 2.6.22, else False (or False if
+ cannot be determined). */
+static Bool linux_kernel_2_6_22(void)
+{
+ static Int result = -1;
+ Int fd, read;
+ HChar release[64];
+ SysRes res;
+
+ if (result == -1) {
+ res = VG_(open)("/proc/sys/kernel/osrelease", 0, 0);
+ if (res.isError)
+ return False;
+ fd = res.res;
+ read = VG_(read)(fd, release, sizeof(release) - 1);
+ vg_assert(read >= 0);
+ release[read] = 0;
+ VG_(close)(fd);
+ //VG_(printf)("kernel release = %s\n", release);
+ result = (VG_(strncmp)(release, "2.6.22", 6) == 0
+ && (release[6] < '0' || release[6] > '9'));
+ }
+ vg_assert(result == 0 || result == 1);
+ return result == 1;
+}
+
+PRE(sys_timerfd_create)
+{
+ if (linux_kernel_2_6_22()) {
+ /* 2.6.22 kernel: timerfd system call. */
+ PRINT("sys_timerfd ( %ld, %ld, %p )", ARG1, ARG2, ARG3);
+ PRE_REG_READ3(long, "sys_timerfd",
+ int, fd, int, clockid, const struct itimerspec *, tmr);
+ PRE_MEM_READ("timerfd(tmr)", ARG3,
+ sizeof(struct vki_itimerspec) );
+ if ((Word)ARG1 != -1L && !ML_(fd_allowed)(ARG1, "timerfd", tid, False))
+ SET_STATUS_Failure( VKI_EBADF );
+ } else {
+ /* 2.6.24 and later kernels: timerfd_create system call. */
+ PRINT("sys_timerfd_create (%ld, %ld )", ARG1, ARG2);
+ PRE_REG_READ2(long, "timerfd_create", int, clockid, int, flags);
+ }
+}
+POST(sys_timerfd_create)
+{
+ if (linux_kernel_2_6_22())
+ {
+ /* 2.6.22 kernel: timerfd system call. */
+ if (!ML_(fd_allowed)(RES, "timerfd", tid, True)) {
+ VG_(close)(RES);
+ SET_STATUS_Failure( VKI_EMFILE );
+ } else {
+ if (VG_(clo_track_fds))
+ ML_(record_fd_open_nameless) (tid, RES);
+ }
+ }
+ else
+ {
+ /* 2.6.24 and later kernels: timerfd_create system call. */
+ if (!ML_(fd_allowed)(RES, "timerfd_create", tid, True)) {
+ VG_(close)(RES);
+ SET_STATUS_Failure( VKI_EMFILE );
+ } else {
+ if (VG_(clo_track_fds))
+ ML_(record_fd_open_nameless) (tid, RES);
+ }
+ }
+}
+
+PRE(sys_timerfd_gettime)
+{
+ PRINT("sys_timerfd_gettime ( %d, %p )", ARG1, ARG2);
+ PRE_REG_READ2(long, "timerfd_gettime",
+ int, ufd,
+ struct vki_itimerspec*, otmr);
+ if (!ML_(fd_allowed)(ARG1, "timerfd_gettime", tid, False))
+ SET_STATUS_Failure(VKI_EBADF);
+ else
+ PRE_MEM_WRITE("timerfd_gettime(result)",
+ ARG2, sizeof(struct vki_itimerspec));
+}
+POST(sys_timerfd_gettime)
+{
+ if (RES == 0)
+ POST_MEM_WRITE(ARG2, sizeof(struct vki_itimerspec));
+}
+
+PRE(sys_timerfd_settime)
+{
+ PRINT("sys_timerfd_settime ( %d, %d, %p, %p )", ARG1, ARG2, ARG3, ARG4);
+ PRE_REG_READ4(long, "timerfd_settime",
+ int, ufd,
+ int, flags,
+ const struct vki_itimerspec*, utmr,
+ struct vki_itimerspec*, otmr);
+ if (!ML_(fd_allowed)(ARG1, "timerfd_settime", tid, False))
+ SET_STATUS_Failure(VKI_EBADF);
+ else
+ {
+ PRE_MEM_READ("timerfd_settime(result)",
+ ARG3, sizeof(struct vki_itimerspec));
+ if (ARG4)
+ {
+ PRE_MEM_WRITE("timerfd_settime(result)",
+ ARG4, sizeof(struct vki_itimerspec));
+ }
+ }
+}
+POST(sys_timerfd_settime)
+{
+ if (RES == 0 && ARG4 != 0)
+ POST_MEM_WRITE(ARG4, sizeof(struct vki_itimerspec));
+}
+
/* ---------------------------------------------------------------------
capabilities wrappers
------------------------------------------------------------------ */
}
#endif
+PRE(sys_signalfd)
+{
+ PRINT("sys_signalfd ( %d, %p, %llu )", (Int)ARG1, ARG2, (ULong) ARG3);
+ PRE_REG_READ3(long, "sys_signalfd",
+ int, fd, vki_sigset_t *, sigmask, vki_size_t, sigsetsize);
+ PRE_MEM_READ( "signalfd(sigmask)", ARG2, sizeof(vki_sigset_t) );
+ if ((int)ARG1 != -1 && !ML_(fd_allowed)(ARG1, "signalfd", tid, False))
+ SET_STATUS_Failure( VKI_EBADF );
+}
+POST(sys_signalfd)
+{
+ if (!ML_(fd_allowed)(RES, "signalfd", tid, True)) {
+ VG_(close)(RES);
+ SET_STATUS_Failure( VKI_EMFILE );
+ } else {
+ if (VG_(clo_track_fds))
+ ML_(record_fd_open_nameless) (tid, RES);
+ }
+}
+
+
/* ---------------------------------------------------------------------
rt_sig* wrappers
------------------------------------------------------------------ */
PRINT("sys_futimesat ( %d, %p(%s), %p )", ARG1,ARG2,ARG2,ARG3);
PRE_REG_READ3(long, "futimesat",
int, dfd, char *, filename, struct timeval *, tvp);
- PRE_MEM_RASCIIZ( "futimesat(filename)", ARG2 );
+ if (ARG2 != 0)
+ PRE_MEM_RASCIIZ( "futimesat(filename)", ARG2 );
+ if (ARG3 != 0)
+ PRE_MEM_READ( "futimesat(tvp)", ARG3, 2 * sizeof(struct vki_timeval) );
+}
+
+PRE(sys_utimensat)
+{
+ PRINT("sys_utimensat ( %d, %p(%s), %p, 0x%x )", ARG1,ARG2,ARG2,ARG3,ARG4);
+ PRE_REG_READ4(long, "utimensat",
+ int, dfd, char *, filename, struct timespec *, utimes, int, flags);
+ if (ARG2 != 0)
+ PRE_MEM_RASCIIZ( "utimensat(filename)", ARG2 );
if (ARG3 != 0)
- PRE_MEM_READ( "futimesat(tvp)", ARG3, sizeof(struct vki_timeval) );
+ PRE_MEM_READ( "utimensat(tvp)", ARG3, 2 * sizeof(struct vki_timespec) );
}
PRE(sys_newfstatat)
PRE_REG_READ3(int, "ioprio_set", int, which, int, who, int, ioprio);
}
-
-/* XXX I don't think this is really the right place for this.
- Move it elsewhere in this file? */
-PRE(sys_utimensat)
-{
- PRINT("sys_utimensat ( %d, %p(%s), %p )", ARG1,ARG2,ARG2,ARG3);
- PRE_REG_READ3(long, "utimensat",
- int, dfd, char *, filename, struct timespec *, tvp);
- PRE_MEM_RASCIIZ( "utimensat(filename)", ARG2 );
- if (ARG3 != 0)
- PRE_MEM_READ( "utimensat(tvp)", ARG3, sizeof(struct vki_timespec) );
-}
-
#undef PRE
#undef POST