inotify: decode file descriptor returned by inotify_init
* inotify.c (SYS_FUNC(inotify_init)): New function. * linux/dummy.h (sys_inotify_init): Remove macro definition. * tests/.gitignore: Add inotify_init, inotify_init-y, inotify_init1-y. * tests/pure_executables.list: Likewise. * tests/gen_tests.in (inotify_init, inotify_init-y, inotify_init1-y): New tests. * tests/inotify_init-y.c: New file. * tests/inotify_init.c: Likewise. * tests/inotify_init1-y.c: Likewise. * tests/inotify_init1.c [PRINT_PATHS]: Print inotify fd path.
This commit is contained in:
parent
6d4b688d38
commit
771a786157
@ -56,6 +56,11 @@ SYS_FUNC(inotify_rm_watch)
|
||||
return RVAL_DECODED;
|
||||
}
|
||||
|
||||
SYS_FUNC(inotify_init)
|
||||
{
|
||||
return RVAL_DECODED | RVAL_FD;
|
||||
}
|
||||
|
||||
SYS_FUNC(inotify_init1)
|
||||
{
|
||||
printflags(inotify_init_flags, tcp->u_arg[0], "IN_???");
|
||||
|
@ -110,7 +110,6 @@
|
||||
#define sys_getppid printargs
|
||||
#define sys_gettid printargs
|
||||
#define sys_idle printargs
|
||||
#define sys_inotify_init printargs
|
||||
#define sys_munlockall printargs
|
||||
#define sys_pause printargs
|
||||
#define sys_printargs printargs
|
||||
|
3
tests/.gitignore
vendored
3
tests/.gitignore
vendored
@ -135,7 +135,10 @@ inet-cmsg
|
||||
init_module
|
||||
inject-nf
|
||||
inotify
|
||||
inotify_init
|
||||
inotify_init-y
|
||||
inotify_init1
|
||||
inotify_init1-y
|
||||
int_0x80
|
||||
ioctl
|
||||
ioctl_block
|
||||
|
@ -131,7 +131,10 @@ group_req -e trace=setsockopt
|
||||
inet-cmsg -e trace=recvmsg
|
||||
init_module -a27
|
||||
inotify -a23 -e trace=inotify_add_watch,inotify_rm_watch
|
||||
inotify_init -a15
|
||||
inotify_init-y -a15 -y -e trace=inotify_init
|
||||
inotify_init1 -a27
|
||||
inotify_init1-y -a27 -y -e trace=inotify_init1
|
||||
int_0x80 -a11 -e trace=getgid32
|
||||
ioctl_block +ioctl.test
|
||||
ioctl_dm +ioctl.test -s9
|
||||
|
2
tests/inotify_init-y.c
Normal file
2
tests/inotify_init-y.c
Normal file
@ -0,0 +1,2 @@
|
||||
#define PRINT_PATHS
|
||||
#include "inotify_init.c"
|
68
tests/inotify_init.c
Normal file
68
tests/inotify_init.c
Normal file
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Check decoding of inotify_init syscall.
|
||||
*
|
||||
* Copyright (c) 2018 The strace developers.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "tests.h"
|
||||
|
||||
#include <asm/unistd.h>
|
||||
|
||||
#if defined(__NR_inotify_init)
|
||||
|
||||
# include <stdio.h>
|
||||
# include <unistd.h>
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
long rc;
|
||||
|
||||
rc = syscall(__NR_inotify_init, 42);
|
||||
|
||||
#ifdef PRINT_PATHS
|
||||
if (rc < 0)
|
||||
perror_msg_and_skip("inotify_init");
|
||||
#endif
|
||||
|
||||
printf("inotify_init() = "
|
||||
#ifdef PRINT_PATHS
|
||||
"%ld<anon_inode:inotify>\n", rc
|
||||
#else
|
||||
"%s\n", sprintrc(rc)
|
||||
#endif
|
||||
);
|
||||
|
||||
puts("+++ exited with 0 +++");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
SKIP_MAIN_UNDEFINED("__NR_inotify_init");
|
||||
|
||||
#endif
|
2
tests/inotify_init1-y.c
Normal file
2
tests/inotify_init1-y.c
Normal file
@ -0,0 +1,2 @@
|
||||
#define PRINT_PATHS
|
||||
#include "inotify_init1.c"
|
@ -44,6 +44,12 @@
|
||||
# endif
|
||||
# define all_flags (O_NONBLOCK | cloexec_flag)
|
||||
|
||||
#ifdef PRINT_PATHS
|
||||
# define RC_FMT "%ld<anon_inode:inotify>"
|
||||
#else
|
||||
# define RC_FMT "%s"
|
||||
#endif
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
@ -65,8 +71,18 @@ main(void)
|
||||
(unsigned int) bogus_flags2, sprintrc(rc));
|
||||
|
||||
rc = syscall(__NR_inotify_init1, all_flags);
|
||||
printf("inotify_init1(IN_NONBLOCK%s) = %s\n",
|
||||
all_flags & cloexec_flag ? "|IN_CLOEXEC" : "", sprintrc(rc));
|
||||
#ifdef PRINT_PATHS
|
||||
if (rc < 0)
|
||||
perror_msg_and_skip("inotify_init(%#x)", all_flags);
|
||||
#endif
|
||||
printf("inotify_init1(IN_NONBLOCK%s) = " RC_FMT "\n",
|
||||
all_flags & cloexec_flag ? "|IN_CLOEXEC" : "",
|
||||
#ifdef PRINT_PATHS
|
||||
rc
|
||||
#else
|
||||
sprintrc(rc)
|
||||
#endif
|
||||
);
|
||||
|
||||
puts("+++ exited with 0 +++");
|
||||
|
||||
|
@ -107,7 +107,10 @@ group_req
|
||||
inet-cmsg
|
||||
init_module
|
||||
inotify
|
||||
inotify_init
|
||||
inotify_init-y
|
||||
inotify_init1
|
||||
inotify_init1-y
|
||||
ioctl
|
||||
ioctl_block
|
||||
ioctl_dm
|
||||
|
Loading…
x
Reference in New Issue
Block a user