(root)/
strace-6.5/
src/
fanotify.c
       1  /*
       2   * Copyright (c) 2014-2015 Dmitry V. Levin <ldv@strace.io>
       3   * Copyright (c) 2014-2023 The strace developers.
       4   * All rights reserved.
       5   *
       6   * SPDX-License-Identifier: LGPL-2.1-or-later
       7   */
       8  
       9  #include "defs.h"
      10  
      11  #include "xlat/fan_classes.h"
      12  #include "xlat/fan_init_flags.h"
      13  
      14  #ifndef FAN_ALL_CLASS_BITS
      15  # define FAN_ALL_CLASS_BITS (FAN_CLASS_NOTIF | FAN_CLASS_CONTENT | FAN_CLASS_PRE_CONTENT)
      16  #endif
      17  #ifndef FAN_NOFD
      18  # define FAN_NOFD -1
      19  #endif
      20  
      21  SYS_FUNC(fanotify_init)
      22  {
      23  	/* flags */
      24  	unsigned int flags = tcp->u_arg[0];
      25  
      26  	tprint_flags_begin();
      27  	printxval(fan_classes, flags & FAN_ALL_CLASS_BITS, "FAN_CLASS_???");
      28  	flags &= ~FAN_ALL_CLASS_BITS;
      29  	if (flags) {
      30  		tprint_flags_or();
      31  		printflags_in(fan_init_flags, flags, "FAN_???");
      32  	}
      33  	tprint_flags_end();
      34  	tprint_arg_next();
      35  
      36  	/* event_f_flags */
      37  	tprint_open_modes((unsigned) tcp->u_arg[1]);
      38  
      39  	return RVAL_DECODED | RVAL_FD;
      40  }
      41  
      42  #include "xlat/fan_mark_flags.h"
      43  #include "xlat/fan_event_flags.h"
      44  
      45  SYS_FUNC(fanotify_mark)
      46  {
      47  	/* fanotify_fd */
      48  	printfd(tcp, tcp->u_arg[0]);
      49  	tprint_arg_next();
      50  
      51  	/* flags */
      52  	printflags(fan_mark_flags, tcp->u_arg[1], "FAN_MARK_???");
      53  	tprint_arg_next();
      54  
      55  	/*
      56  	 * the mask argument is defined as 64-bit,
      57  	 * but kernel uses the lower 32 bits only.
      58  	 */
      59  	unsigned long long mask = 0;
      60  	unsigned int argn = getllval(tcp, &mask, 2);
      61  	printflags64(fan_event_flags, mask, "FAN_???");
      62  	tprint_arg_next();
      63  
      64  	/* dirfd */
      65  	if ((int) tcp->u_arg[argn] == FAN_NOFD)
      66  		print_xlat_d(FAN_NOFD);
      67  	else
      68  		print_dirfd(tcp, tcp->u_arg[argn]);
      69  	tprint_arg_next();
      70  
      71  	/* pathname */
      72  	printpath(tcp, tcp->u_arg[argn + 1]);
      73  
      74  	return RVAL_DECODED;
      75  }