From: Tom Hughes Date: Wed, 17 Jul 2013 13:58:59 +0000 (+0000) Subject: Add support for fanotify_init and fanotify_mark, based on patches X-Git-Tag: svn/VALGRIND_3_9_0~231 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=479650d93867870d90c0b4bbce0ae1dc8ddde3eb;p=thirdparty%2Fvalgrind.git Add support for fanotify_init and fanotify_mark, based on patches from Heinrich Schuchardt. BZ#320895. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13460 --- diff --git a/coregrind/m_syswrap/priv_syswrap-linux.h b/coregrind/m_syswrap/priv_syswrap-linux.h index 2bb4e9fcb6..2ae844201a 100644 --- a/coregrind/m_syswrap/priv_syswrap-linux.h +++ b/coregrind/m_syswrap/priv_syswrap-linux.h @@ -274,6 +274,10 @@ DECL_TEMPLATE(linux, sys_lookup_dcookie); // (*/32/64) L DECL_TEMPLATE(linux, sys_process_vm_readv); DECL_TEMPLATE(linux, sys_process_vm_writev); +// Linux-specific (new in Linux 2.6.36) +DECL_TEMPLATE(linux, sys_fanotify_init); +DECL_TEMPLATE(linux, sys_fanotify_mark); + /* --------------------------------------------------------------------- Wrappers for sockets and ipc-ery. These are split into standalone procedures because x86-linux hides them inside multiplexors diff --git a/coregrind/m_syswrap/syswrap-amd64-linux.c b/coregrind/m_syswrap/syswrap-amd64-linux.c index b74fc87ab6..1ec24b5ce6 100644 --- a/coregrind/m_syswrap/syswrap-amd64-linux.c +++ b/coregrind/m_syswrap/syswrap-amd64-linux.c @@ -1068,8 +1068,8 @@ static SyscallTableEntry syscall_table[] = { LINXY(__NR_perf_event_open, sys_perf_event_open), // 298 LINXY(__NR_recvmmsg, sys_recvmmsg), // 299 -// LINX_(__NR_fanotify_init, sys_ni_syscall), // 300 -// LINX_(__NR_fanotify_mark, sys_ni_syscall), // 301 + LINXY(__NR_fanotify_init, sys_fanotify_init), // 300 + LINX_(__NR_fanotify_mark, sys_fanotify_mark), // 301 LINXY(__NR_prlimit64, sys_prlimit64), // 302 LINXY(__NR_name_to_handle_at, sys_name_to_handle_at),// 303 LINXY(__NR_open_by_handle_at, sys_open_by_handle_at),// 304 diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c index 312f10d064..a4e4bb773e 100644 --- a/coregrind/m_syswrap/syswrap-linux.c +++ b/coregrind/m_syswrap/syswrap-linux.c @@ -1788,6 +1788,54 @@ POST(sys_get_mempolicy) POST_MEM_WRITE( ARG2, VG_ROUNDUP( ARG3-1, sizeof(UWord) * 8 ) / 8 ); } +/* --------------------------------------------------------------------- + fanotify_* wrappers + ------------------------------------------------------------------ */ + +PRE(sys_fanotify_init) +{ + PRINT("sys_fanotify_init ( %lu, %lu )", ARG1,ARG2); + PRE_REG_READ2(long, "fanotify_init", + unsigned int, flags, unsigned int, event_f_flags); +} + +POST(sys_fanotify_init) +{ + vg_assert(SUCCESS); + if (!ML_(fd_allowed)(RES, "fanotify_init", 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_fanotify_mark) +{ +#if VG_WORDSIZE == 4 + PRINT( "sys_fanotify_mark ( %ld, %lu, %llu, %ld, %#lx(%s))", + ARG1,ARG2,MERGE64(ARG3,ARG4),ARG5,ARG6,(char *)ARG6); + PRE_REG_READ6(long, "sys_fanotify_mark", + int, fanotify_fd, unsigned int, flags, + __vki_u32, mask0, __vki_u32, mask1, + int, dfd, const char *, pathname); + if (ARG6) + PRE_MEM_RASCIIZ( "fanotify_mark(path)", ARG6); +#elif VG_WORDSIZE == 8 + PRINT( "sys_fanotify_mark ( %ld, %lu, %llu, %ld, %#lx(%s))", + ARG1,ARG2,(ULong)ARG3,ARG4,ARG5,(char *)ARG5); + PRE_REG_READ5(long, "sys_fanotify_mark", + int, fanotify_fd, unsigned int, flags, + __vki_u64, mask, + int, dfd, const char *, pathname); + if (ARG5) + PRE_MEM_RASCIIZ( "fanotify_mark(path)", ARG5); +#else +# error Unexpected word size +#endif +} + /* --------------------------------------------------------------------- inotify_* wrappers ------------------------------------------------------------------ */ diff --git a/coregrind/m_syswrap/syswrap-x86-linux.c b/coregrind/m_syswrap/syswrap-x86-linux.c index 38c5a91fbe..730ab41b9a 100644 --- a/coregrind/m_syswrap/syswrap-x86-linux.c +++ b/coregrind/m_syswrap/syswrap-x86-linux.c @@ -1821,8 +1821,8 @@ static SyscallTableEntry syscall_table[] = { LINXY(__NR_rt_tgsigqueueinfo, sys_rt_tgsigqueueinfo),// 335 LINXY(__NR_perf_event_open, sys_perf_event_open), // 336 LINXY(__NR_recvmmsg, sys_recvmmsg), // 337 -// LINX_(__NR_fanotify_init, sys_ni_syscall), // 338 -// LINX_(__NR_fanotify_mark, sys_ni_syscall), // 339 + LINXY(__NR_fanotify_init, sys_fanotify_init), // 338 + LINX_(__NR_fanotify_mark, sys_fanotify_mark), // 339 LINXY(__NR_prlimit64, sys_prlimit64), // 340 LINXY(__NR_name_to_handle_at, sys_name_to_handle_at),// 341