]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
mips32: add sync_file_range syscall support
authorPetar Jovanovic <mips32r2@gmail.com>
Tue, 13 Aug 2019 14:30:30 +0000 (14:30 +0000)
committerPetar Jovanovic <mips32r2@gmail.com>
Tue, 13 Aug 2019 14:30:30 +0000 (14:30 +0000)
Hook up sync_file_range for mips32.

Along with the change for passing 7th argument in syscalls, this will fix
sync_file_range01 failure within LTP test suite.

Patch by Nikola Milutinovic.

coregrind/m_syswrap/syswrap-mips32-linux.c

index 7905547d32f34e9e6f5759df65609ba7de99c431..fe58d0925a02d31ed7c8fd38df10bf1d8b6e3b3e 100644 (file)
@@ -410,6 +410,7 @@ DECL_TEMPLATE (mips_linux, sys_set_thread_area);
 DECL_TEMPLATE (mips_linux, sys_pipe);
 DECL_TEMPLATE (mips_linux, sys_prctl);
 DECL_TEMPLATE (mips_linux, sys_ptrace);
+DECL_TEMPLATE (mips_linux, sys_sync_file_range);
 
 PRE(sys_mmap2) 
 {
@@ -724,6 +725,28 @@ POST(sys_prctl)
    WRAPPER_POST_NAME(linux, sys_prctl)(tid, arrghs, status);
 }
 
+PRE(sys_sync_file_range)
+{
+   *flags |= SfMayBlock;
+
+   PRINT("sys_sync_file_range ( %ld, %llu, %llu, %ld )",
+          SARG1, MERGE64(ARG3,ARG4), MERGE64(ARG5, ARG6), SARG7);
+
+   if (VG_(tdict).track_pre_reg_read) {
+      PRRSN;
+      PRA1("sync_file_range", int, fd);
+      PRA3("sync_file_range", vki_u32, MERGE64_FIRST(offset));
+      PRA4("sync_file_range", vki_u32, MERGE64_SECOND(offset));
+      PRA5("sync_file_range", vki_u32, MERGE64_FIRST(nbytes));
+      PRA6("sync_file_range", vki_u32, MERGE64_SECOND(nbytes));
+      PRA7("sync_file_range", int, flags);
+   }
+
+   if (!ML_(fd_allowed)(ARG1, "sync_file_range", tid, False)){
+      SET_STATUS_Failure( VKI_EBADF );
+   }
+}
+
 #undef PRE
 #undef POST
 
@@ -1038,6 +1061,7 @@ static SyscallTableEntry syscall_main_table[] = {
    LINXY (__NR_ppoll,                  sys_ppoll),                   // 302
    //..
    LINX_ (__NR_splice,                 sys_splice),                  // 304
+   PLAX_ (__NR_sync_file_range,        sys_sync_file_range),         // 305
    //..
    LINX_ (__NR_set_robust_list,        sys_set_robust_list),         // 309
    LINXY (__NR_get_robust_list,        sys_get_robust_list),         // 310