[gamin] [Fwd: [Valgrind-developers] Inotify system call wrapper]



--- Begin Message ---
Yo,

I've attached a patch that wraps the inotify system calls on x86 linux.
Please consider this for the next version of valgrind.

Thanks,
John McCutchan
Index: coregrind/m_syswrap/syswrap-linux.c
===================================================================
--- coregrind/m_syswrap/syswrap-linux.c	(revision 4246)
+++ coregrind/m_syswrap/syswrap-linux.c	(working copy)
@@ -860,6 +860,36 @@
       POST_MEM_WRITE( ARG2, VG_ROUNDUP( ARG3, sizeof(UWord) * 8 ) / sizeof(UWord) );
 }
 
+PRE(sys_inotify_init)
+{
+   *flags |= SfMayBlock;
+}
+
+POST(sys_inotify_init)
+{
+    vg_assert (SUCCESS);
+    if (!ML_(fd_allowed)(RES, "inotify_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_inotify_add_watch)
+{
+	PRINT( "sys_inotify_add_watch (%p, %d)", ARG1, ARG2);
+	PRE_REG_READ3(long, "inotify_add_watch", int, fd, char *, path, int, mask);
+	PRE_MEM_RASCIIZ( "inotify_add_watch(path)", ARG2);
+}
+
+PRE(sys_inotify_rm_watch)
+{
+	PRINT( "sys_inotify_rm_watch(%d)", ARG1);
+	PRE_REG_READ2(long, "inotify_rm_watch", int, fd, int, wd);
+}
+
 #undef PRE
 #undef POST
 
Index: coregrind/m_syswrap/syswrap-x86-linux.c
===================================================================
--- coregrind/m_syswrap/syswrap-x86-linux.c	(revision 4246)
+++ coregrind/m_syswrap/syswrap-x86-linux.c	(working copy)
@@ -2277,6 +2277,9 @@
    GENX_(__NR_mq_notify,         sys_mq_notify),      // (mq_open+4)
    GENXY(__NR_mq_getsetattr,     sys_mq_getsetattr),  // (mq_open+5)
    GENX_(__NR_sys_kexec_load,    sys_ni_syscall),     // 283
+   LINX_(291,			 sys_inotify_init),   // 291
+   LINX_(292,			 sys_inotify_add_watch), // 292
+   LINX_(293,			 sys_inotify_rm_watch), // 293
 };
 
 const UInt ML_(syscall_table_size) = 
Index: coregrind/m_syswrap/priv_syswrap-linux.h
===================================================================
--- coregrind/m_syswrap/priv_syswrap-linux.h	(revision 4246)
+++ coregrind/m_syswrap/priv_syswrap-linux.h	(working copy)
@@ -92,6 +92,10 @@
 DECL_TEMPLATE(linux, sys_set_mempolicy);
 DECL_TEMPLATE(linux, sys_get_mempolicy);
 
+DECL_TEMPLATE(linux, sys_inotify_init);
+DECL_TEMPLATE(linux, sys_inotify_add_watch);
+DECL_TEMPLATE(linux, sys_inotify_rm_watch);
+
 #endif   // __PRIV_SYSWRAP_LINUX_H
 
 /*--------------------------------------------------------------------*/

--- End Message ---


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]