• A
    perf trace: Beautify 'fsmount' arguments · f6af0956
    Arnaldo Carvalho de Melo 提交于
    Use existing beautifiers for the first arg, fd, assigned using the
    heuristic that looks for syscall arg names and associates SCA_FD with
    'fd' named argumes, and wire up the recently introduced fsmount
    attr_flags table generator.
    
    Now it should be possible to just use:
    
       perf trace -e fsmount
    
    As root and see all fsmount syscalls with its args beautified.
    
      # cat sys_fsmount.c
      #define _GNU_SOURCE        /* See feature_test_macros(7) */
      #include <unistd.h>
      #include <sys/syscall.h>   /* For SYS_xxx definitions */
    
      #define __NR_fsmount 432
    
      #define MOUNT_ATTR_RDONLY	 0x00000001 /* Mount read-only */
      #define MOUNT_ATTR_NOSUID	 0x00000002 /* Ignore suid and sgid bits */
      #define MOUNT_ATTR_NODEV	 0x00000004 /* Disallow access to device special files */
      #define MOUNT_ATTR_NOEXEC	 0x00000008 /* Disallow program execution */
      #define MOUNT_ATTR__ATIME	 0x00000070 /* Setting on how atime should be updated */
      #define MOUNT_ATTR_RELATIME	 0x00000000 /* - Update atime relative to mtime/ctime. */
      #define MOUNT_ATTR_NOATIME	 0x00000010 /* - Do not update access times. */
      #define MOUNT_ATTR_STRICTATIME 0x00000020 /* - Always perform atime updates */
      #define MOUNT_ATTR_NODIRATIME	 0x00000080 /* Do not update directory access times */
    
      static inline int sys_fsmount(int fs_fd, int flags, int attr_flags)
      {
      	syscall(__NR_fsmount, fs_fd, flags, attr_flags);
      }
    
      int main(int argc, char *argv[])
      {
      	int attr_flags = 0, fs_fd = 0;
    
      	sys_fsmount(fs_fd++, 0, attr_flags);
      	attr_flags |= MOUNT_ATTR_RDONLY;
      	sys_fsmount(fs_fd++, 1, attr_flags);
      	attr_flags |= MOUNT_ATTR_NOSUID;
      	sys_fsmount(fs_fd++, 0, attr_flags);
      	attr_flags |= MOUNT_ATTR_NODEV;
      	sys_fsmount(fs_fd++, 1, attr_flags);
      	attr_flags |= MOUNT_ATTR_NOEXEC;
      	sys_fsmount(fs_fd++, 0, attr_flags);
      	attr_flags |= MOUNT_ATTR_NOATIME;
      	sys_fsmount(fs_fd++, 1, attr_flags);
      	attr_flags |= MOUNT_ATTR_STRICTATIME;
      	sys_fsmount(fs_fd++, 0, attr_flags);
      	attr_flags |= MOUNT_ATTR_NODIRATIME;
      	sys_fsmount(fs_fd++, 0, attr_flags);
      	return 0;
      }
      #
      # perf trace -e fsmount ./sys_fsmount
      fsmount(0, 0, MOUNT_ATTR_RELATIME)      = -1 EINVAL (Invalid argument)
      fsmount(1, FSMOUNT_CLOEXEC, MOUNT_ATTR_RDONLY|MOUNT_ATTR_RELATIME) = -1 EINVAL (Invalid argument)
      fsmount(2, 0, MOUNT_ATTR_RDONLY|MOUNT_ATTR_NOSUID|MOUNT_ATTR_RELATIME) = -1 EINVAL (Invalid argument)
      fsmount(3, FSMOUNT_CLOEXEC, MOUNT_ATTR_RDONLY|MOUNT_ATTR_NOSUID|MOUNT_ATTR_NODEV|MOUNT_ATTR_RELATIME) = -1 EBADF (Bad file descriptor)
      fsmount(4, 0, MOUNT_ATTR_RDONLY|MOUNT_ATTR_NOSUID|MOUNT_ATTR_NODEV|MOUNT_ATTR_NOEXEC|MOUNT_ATTR_RELATIME) = -1 EBADF (Bad file descriptor)
      fsmount(5, FSMOUNT_CLOEXEC, MOUNT_ATTR_RDONLY|MOUNT_ATTR_NOSUID|MOUNT_ATTR_NODEV|MOUNT_ATTR_NOEXEC|MOUNT_ATTR_NOATIME) = -1 EBADF (Bad file descriptor)
      fsmount(6, 0, MOUNT_ATTR_RDONLY|MOUNT_ATTR_NOSUID|MOUNT_ATTR_NODEV|MOUNT_ATTR_NOEXEC|MOUNT_ATTR_NOATIME|MOUNT_ATTR_STRICTATIME) = -1 EINVAL (Invalid argument)
      fsmount(7, 0, MOUNT_ATTR_RDONLY|MOUNT_ATTR_NOSUID|MOUNT_ATTR_NODEV|MOUNT_ATTR_NOEXEC|MOUNT_ATTR_NOATIME|MOUNT_ATTR_STRICTATIME|MOUNT_ATTR_NODIRATIME) = -1 EINVAL (Invalid argument)
      #
    
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: Al Viro <viro@zeniv.linux.org.uk>
    Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Link: https://lkml.kernel.org/n/tip-w71uge0sfo6ns9uclhwtthca@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
    f6af0956
beauty.h 8.2 KB