]> granicus.if.org Git - strace/commitdiff
Implement mlock2 syscall decoding
authorDmitry V. Levin <ldv@altlinux.org>
Sun, 15 Nov 2015 02:35:57 +0000 (02:35 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 17 Nov 2015 00:40:22 +0000 (00:40 +0000)
* mem.c: Include "xlat/mlock_flags.h".
(SYS_FUNC(mlock2)): New function.
* xlat/mlock_flags.in: New file.
* xlat/mlockall_flags.in: Add MCL_ONFAULT, add default values.
* linux/dummy.h (mlock2): Remove.
* tests/mlock2.c: New file.
* tests/mlock2.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add mlock2.
(TESTS): Add mlock2.test.
* tests/.gitignore Add mlock2.

linux/dummy.h
mem.c
tests/.gitignore
tests/Makefile.am
tests/mlock2.c [new file with mode: 0644]
tests/mlock2.test [new file with mode: 0755]
xlat/mlock_flags.in [new file with mode: 0644]
xlat/mlockall_flags.in

index e856bc99448af4f6e95106cd61135eeb07fb005b..ca76d0af03ead5b079f3db549645becb10111b26 100644 (file)
@@ -37,7 +37,6 @@
 #define        sys_kcmp                printargs
 #define        sys_kexec_file_load     printargs
 #define        sys_lookup_dcookie      printargs
-#define        sys_mlock2              printargs
 #define        sys_name_to_handle_at   printargs
 #define        sys_open_by_handle_at   printargs
 #define        sys_sysfs               printargs
diff --git a/mem.c b/mem.c
index 8867f1ee5dc46cf77f36f454f1f433f808dbe9de..c7c41cff0f3c87379e745ba6b11a14a727d915df 100644 (file)
--- a/mem.c
+++ b/mem.c
@@ -247,6 +247,17 @@ SYS_FUNC(msync)
        return RVAL_DECODED;
 }
 
+#include "xlat/mlock_flags.h"
+
+SYS_FUNC(mlock2)
+{
+       printaddr(tcp->u_arg[0]);
+       tprintf(", %lu, ", tcp->u_arg[1]);
+       printflags(mlock_flags, tcp->u_arg[2], "MLOCK_???");
+
+       return RVAL_DECODED;
+}
+
 SYS_FUNC(mincore)
 {
        if (entering(tcp)) {
index 79585e1a1e01ff6d54fb7f18540e7c7885431057..8e2919a9a72277083932167e80698eaaa0b08956 100644 (file)
@@ -20,6 +20,7 @@ ipc_sem
 ipc_shm
 membarrier
 memfd_create
+mlock2
 mmap
 mmap64
 mmsg
index 5aae4bd0af4481d3028d832cf50d242eb2f15a65..fe5f0bf5dd3b0cc7aadcffa5fff648191823fb51 100644 (file)
@@ -33,6 +33,7 @@ check_PROGRAMS = \
        ipc_shm \
        membarrier \
        memfd_create \
+       mlock2 \
        mmap \
        mmap64 \
        mmsg \
@@ -148,6 +149,7 @@ TESTS = \
        sysinfo.test \
        membarrier.test \
        memfd_create.test \
+       mlock2.test \
        mmap.test \
        mmap64.test \
        mmsg.test \
diff --git a/tests/mlock2.c b/tests/mlock2.c
new file mode 100644 (file)
index 0000000..fe662d2
--- /dev/null
@@ -0,0 +1,25 @@
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/syscall.h>
+
+int
+main(void)
+{
+#ifdef __NR_mlock2
+       if (syscall(__NR_mlock2, 0xdeadbeef, 0xdefaced, 0xffff) != -1)
+               return 77;
+       printf("mlock2(0xdeadbeef, 233811181, MLOCK_ONFAULT|0xfffe) = -1 %s\n",
+              errno == ENOSYS ?
+                       "ENOSYS (Function not implemented)" :
+                       "EINVAL (Invalid argument)");
+       puts("+++ exited with 0 +++");
+       return 0;
+#else
+        return 77;
+#endif
+}
diff --git a/tests/mlock2.test b/tests/mlock2.test
new file mode 100755 (executable)
index 0000000..fdbcfde
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+# Check mlock2 syscall decoding.
+
+. "${srcdir=.}/init.sh"
+
+run_prog > /dev/null
+OUT="$LOG.out"
+run_strace -e mlock2 $args > "$OUT"
+match_diff "$OUT" "$LOG"
+rm -f "$OUT"
+
+exit 0
diff --git a/xlat/mlock_flags.in b/xlat/mlock_flags.in
new file mode 100644 (file)
index 0000000..b285e67
--- /dev/null
@@ -0,0 +1 @@
+MLOCK_ONFAULT  1
index ba28847b211b4ec58dd7a0be2d7bab75a8c1f8e8..a39d7ba08345f107d3da45172fdd77e6f28e8e4a 100644 (file)
@@ -1,2 +1,3 @@
-MCL_CURRENT
-MCL_FUTURE
+MCL_CURRENT    1
+MCL_FUTURE     2
+MCL_ONFAULT    4