Jakub Jelinek 0332e1
commit 4b8a2fd25a4227f0b1411bee12add2d5c887c6a2
Jakub Jelinek 0332e1
Author: Dodji Seketeli <dodji@redhat.com>
Jakub Jelinek 0332e1
Date:   Mon Oct 5 13:45:38 2009 +0200
Jakub Jelinek 0332e1
Jakub Jelinek 0332e1
    Add a wrapper for inotify_init1 (vgbz #202315)
Jakub Jelinek 0332e1
    
Jakub Jelinek 0332e1
    	* coregrind/m_syswrap/priv_syswrap-linux.h: Declare the
Jakub Jelinek 0332e1
    	sys_inotify_init1 wrapper.
Jakub Jelinek 0332e1
    	* coregrind/m_syswrap/syswrap-linux.c: Add pre/post handlers for
Jakub Jelinek 0332e1
    	the sys_inotify_init1 syscall.
Jakub Jelinek 0332e1
    	* coregrind/m_syswrap/syswrap-amd64-linux.c: Insert the
Jakub Jelinek 0332e1
    	sys_inotify_init1 wrapper in the wrappers table for the amd64 arch.
Jakub Jelinek 0332e1
    	* coregrind/m_syswrap/syswrap-x86-linux.c: Likewise for the x86_32
Jakub Jelinek 0332e1
    	arch.
Jakub Jelinek 0332e1
Jakub Jelinek 0332e1
diff --git a/coregrind/m_syswrap/priv_syswrap-linux.h b/coregrind/m_syswrap/priv_syswrap-linux.h
Jakub Jelinek 0332e1
index fed3ba6..894678d 100644
Jakub Jelinek 0332e1
--- a/coregrind/m_syswrap/priv_syswrap-linux.h
Jakub Jelinek 0332e1
+++ b/coregrind/m_syswrap/priv_syswrap-linux.h
Jakub Jelinek 0332e1
@@ -116,6 +116,7 @@ DECL_TEMPLATE(linux, sys_set_mempolicy);
Jakub Jelinek 0332e1
 DECL_TEMPLATE(linux, sys_get_mempolicy);
Jakub Jelinek 0332e1
 
Jakub Jelinek 0332e1
 DECL_TEMPLATE(linux, sys_inotify_init);
Jakub Jelinek 0332e1
+DECL_TEMPLATE(linux, sys_inotify_init1);
Jakub Jelinek 0332e1
 DECL_TEMPLATE(linux, sys_inotify_add_watch);
Jakub Jelinek 0332e1
 DECL_TEMPLATE(linux, sys_inotify_rm_watch);
Jakub Jelinek 0332e1
 
Jakub Jelinek 0332e1
diff --git a/coregrind/m_syswrap/syswrap-amd64-linux.c b/coregrind/m_syswrap/syswrap-amd64-linux.c
Jakub Jelinek 0332e1
index 605d844..bb28073 100644
Jakub Jelinek 0332e1
--- a/coregrind/m_syswrap/syswrap-amd64-linux.c
Jakub Jelinek 0332e1
+++ b/coregrind/m_syswrap/syswrap-amd64-linux.c
Jakub Jelinek 0332e1
@@ -1374,8 +1374,8 @@ const SyscallTableEntry ML_(syscall_table)[] = {
Jakub Jelinek 0332e1
    LINX_(__NR_eventfd2,          sys_eventfd2),         // 290
Jakub Jelinek 0332e1
    LINXY(__NR_epoll_create1,     sys_epoll_create1),    // 291
Jakub Jelinek 0332e1
    //   (__NR_dup3,              sys_ni_syscall)        // 292
Jakub Jelinek 0332e1
-   LINXY(__NR_pipe2,             sys_pipe2)             // 293
Jakub Jelinek 0332e1
-   //   (__NR_inotify_init1,     sys_ni_syscall)        // 294
Jakub Jelinek 0332e1
+   LINXY(__NR_pipe2,             sys_pipe2),            // 293
Jakub Jelinek 0332e1
+   LINXY(__NR_inotify_init1,     sys_inotify_init1),     // 294
Jakub Jelinek 0332e1
 };
Jakub Jelinek 0332e1
 
Jakub Jelinek 0332e1
 const UInt ML_(syscall_table_size) = 
Jakub Jelinek 0332e1
diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c
Jakub Jelinek 0332e1
index 7f81262..895bc54 100644
Jakub Jelinek 0332e1
--- a/coregrind/m_syswrap/syswrap-linux.c
Jakub Jelinek 0332e1
+++ b/coregrind/m_syswrap/syswrap-linux.c
Jakub Jelinek 0332e1
@@ -1526,6 +1526,24 @@ POST(sys_inotify_init)
Jakub Jelinek 0332e1
    }
Jakub Jelinek 0332e1
 }
Jakub Jelinek 0332e1
 
Jakub Jelinek 0332e1
+PRE(sys_inotify_init1)
Jakub Jelinek 0332e1
+{
Jakub Jelinek 0332e1
+   PRINT("sys_inotify_init ( %ld )", ARG1);
Jakub Jelinek 0332e1
+   PRE_REG_READ1(long, "inotify_init", int, flag);
Jakub Jelinek 0332e1
+}
Jakub Jelinek 0332e1
+
Jakub Jelinek 0332e1
+POST(sys_inotify_init1)
Jakub Jelinek 0332e1
+{
Jakub Jelinek 0332e1
+   vg_assert(SUCCESS);
Jakub Jelinek 0332e1
+   if (!ML_(fd_allowed)(RES, "inotify_init", tid, True)) {
Jakub Jelinek 0332e1
+      VG_(close)(RES);
Jakub Jelinek 0332e1
+      SET_STATUS_Failure( VKI_EMFILE );
Jakub Jelinek 0332e1
+   } else {
Jakub Jelinek 0332e1
+      if (VG_(clo_track_fds))
Jakub Jelinek 0332e1
+         ML_(record_fd_open_nameless) (tid, RES);
Jakub Jelinek 0332e1
+   }
Jakub Jelinek 0332e1
+}
Jakub Jelinek 0332e1
+
Jakub Jelinek 0332e1
 PRE(sys_inotify_add_watch)
Jakub Jelinek 0332e1
 {
Jakub Jelinek 0332e1
    PRINT( "sys_inotify_add_watch ( %ld, %#lx, %lx )", ARG1,ARG2,ARG3);
Jakub Jelinek 0332e1
diff --git a/coregrind/m_syswrap/syswrap-x86-linux.c b/coregrind/m_syswrap/syswrap-x86-linux.c
Jakub Jelinek 0332e1
index 90eb512..180e36b 100644
Jakub Jelinek 0332e1
--- a/coregrind/m_syswrap/syswrap-x86-linux.c
Jakub Jelinek 0332e1
+++ b/coregrind/m_syswrap/syswrap-x86-linux.c
Jakub Jelinek 0332e1
@@ -2253,8 +2253,8 @@ const SyscallTableEntry ML_(syscall_table)[] = {
Jakub Jelinek 0332e1
    LINXY(__NR_epoll_create1,     sys_epoll_create1),     // 329
Jakub Jelinek 0332e1
 
Jakub Jelinek 0332e1
    //   (__NR_dup3,              sys_ni_syscall)        // 330
Jakub Jelinek 0332e1
-   LINXY(__NR_pipe2,             sys_pipe2)             // 331
Jakub Jelinek 0332e1
-   //   (__NR_inotify_init1,     sys_ni_syscall)        // 332
Jakub Jelinek 0332e1
+   LINXY(__NR_pipe2,             sys_pipe2),            // 331
Jakub Jelinek 0332e1
+   LINX_(__NR_inotify_init1,     sys_inotify_init1)     // 332
Jakub Jelinek 0332e1
 };
Jakub Jelinek 0332e1
 
Jakub Jelinek 0332e1
 const UInt ML_(syscall_table_size) = 
Jakub Jelinek 0332e1
--- valgrind-3.5.0/coregrind/m_syswrap/syswrap-ppc32-linux.c.jj	2009-10-09 12:52:04.000000000 +0200
Jakub Jelinek 0332e1
+++ valgrind-3.5.0/coregrind/m_syswrap/syswrap-ppc32-linux.c	2009-10-12 16:14:33.000000000 +0200
Jakub Jelinek 0332e1
@@ -1866,8 +1866,8 @@ const SyscallTableEntry ML_(syscall_tabl
Jakub Jelinek 0332e1
    LINX_(__NR_eventfd2,          sys_eventfd2),         // 314
Jakub Jelinek 0332e1
    LINXY(__NR_epoll_create1,     sys_epoll_create1),    // 315
Jakub Jelinek 0332e1
    //   (__NR_dup3,              sys_ni_syscall)        // 316
Jakub Jelinek 0332e1
-   LINXY(__NR_pipe2,             sys_pipe2)             // 317
Jakub Jelinek 0332e1
-   //   (__NR_inotify_init1,     sys_ni_syscall)        // 318
Jakub Jelinek 0332e1
+   LINXY(__NR_pipe2,             sys_pipe2),            // 317
Jakub Jelinek 0332e1
+   LINX_(__NR_inotify_init1,     sys_inotify_init1)     // 318
Jakub Jelinek 0332e1
 };
Jakub Jelinek 0332e1
 
Jakub Jelinek 0332e1
 const UInt ML_(syscall_table_size) = 
Jakub Jelinek 0332e1
--- valgrind-3.5.0/coregrind/m_syswrap/syswrap-ppc64-linux.c.jj	2009-10-09 12:52:04.000000000 +0200
Jakub Jelinek 0332e1
+++ valgrind-3.5.0/coregrind/m_syswrap/syswrap-ppc64-linux.c	2009-10-12 16:14:55.000000000 +0200
Jakub Jelinek 0332e1
@@ -1506,8 +1506,8 @@ const SyscallTableEntry ML_(syscall_tabl
Jakub Jelinek 0332e1
    LINX_(__NR_eventfd2,          sys_eventfd2),         // 314
Jakub Jelinek 0332e1
    LINXY(__NR_epoll_create1,     sys_epoll_create1),    // 315
Jakub Jelinek 0332e1
    //   (__NR_dup3,              sys_ni_syscall)        // 316
Jakub Jelinek 0332e1
-   LINXY(__NR_pipe2,             sys_pipe2)             // 317
Jakub Jelinek 0332e1
-   //   (__NR_inotify_init1,     sys_ni_syscall)        // 318
Jakub Jelinek 0332e1
+   LINXY(__NR_pipe2,             sys_pipe2),            // 317
Jakub Jelinek 0332e1
+   LINX_(__NR_inotify_init1,     sys_inotify_init1)     // 318
Jakub Jelinek 0332e1
 };
Jakub Jelinek 0332e1
 
Jakub Jelinek 0332e1
 const UInt ML_(syscall_table_size) =