]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add support for fanotify_init and fanotify_mark, based on patches
authorTom Hughes <tom@compton.nu>
Wed, 17 Jul 2013 13:58:59 +0000 (13:58 +0000)
committerTom Hughes <tom@compton.nu>
Wed, 17 Jul 2013 13:58:59 +0000 (13:58 +0000)
from Heinrich Schuchardt. BZ#320895.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13460

coregrind/m_syswrap/priv_syswrap-linux.h
coregrind/m_syswrap/syswrap-amd64-linux.c
coregrind/m_syswrap/syswrap-linux.c
coregrind/m_syswrap/syswrap-x86-linux.c

index 2bb4e9fcb68f0eb3d9a73183080d14024b91e328..2ae844201a0c034e25e68af392f4f65fec631e3f 100644 (file)
@@ -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
index b74fc87ab62835e3953caefdd38d7fa571fb73da..1ec24b5ce66a699944bcbe106662179966b079cc 100644 (file)
@@ -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
index 312f10d064f2c7447990a00f754c70f33a6d82f0..a4e4bb773e1677248175aed3c0389e491489037c 100644 (file)
@@ -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
    ------------------------------------------------------------------ */
index 38c5a91fbec9c5161739cef0d7cef44b179d7d8c..730ab41b9a67efe4340d354adbb4830e39f807e0 100644 (file)
@@ -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