Implement mlock2 syscall decoding

* 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.
This commit is contained in:
Дмитрий Левин 2015-11-15 02:35:57 +00:00
parent 2aec1e67df
commit 0d0a50aa25
8 changed files with 56 additions and 3 deletions

View 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

11
mem.c
View File

@ -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)) {

1
tests/.gitignore vendored
View File

@ -20,6 +20,7 @@ ipc_sem
ipc_shm
membarrier
memfd_create
mlock2
mmap
mmap64
mmsg

View 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 \

25
tests/mlock2.c Normal file
View File

@ -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
}

13
tests/mlock2.test Executable file
View File

@ -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

1
xlat/mlock_flags.in Normal file
View File

@ -0,0 +1 @@
MLOCK_ONFAULT 1

View File

@ -1,2 +1,3 @@
MCL_CURRENT
MCL_FUTURE
MCL_CURRENT 1
MCL_FUTURE 2
MCL_ONFAULT 4