# name_to_handle_at __________________________________________
#
# SYSCALL_DEFINE5(name_to_handle_at, int, dfd, const char __user *, name,
#		struct file_handle __user *, handle, int __user *, mnt_id,
#		int, flag)

@define _SYSCALL_NAME_TO_HANDLE_AT_NAME
%(
	name = "name_to_handle_at"
%)

@define _SYSCALL_NAME_TO_HANDLE_AT_ARGSTR
%(
	argstr = sprintf("%s, %s, %p, %p, %s", dfd_str, pathname,
	                 handle_uaddr, mnt_id_uaddr, flags_str)
%)

probe syscall.name_to_handle_at = dw_syscall.name_to_handle_at !,
                                  nd_syscall.name_to_handle_at ? {}
probe syscall.name_to_handle_at.return = dw_syscall.name_to_handle_at.return !,
                                         nd_syscall.name_to_handle_at.return ? {}

# dw_name_to_handle_at _____________________________________________________

probe dw_syscall.name_to_handle_at =
	kernel.function("sys_name_to_handle_at").call ?
{
	@_SYSCALL_NAME_TO_HANDLE_AT_NAME
	dfd = __int32($dfd)
	dfd_str = _dfd_str(dfd)
	pathname = user_string_quoted($name)
	handle_uaddr = $handle
	mnt_id_uaddr = $mnt_id
	flags = $flag
	flags_str = _at_flag_str(flags)
	@_SYSCALL_NAME_TO_HANDLE_AT_ARGSTR
}
probe dw_syscall.name_to_handle_at.return =
	kernel.function("sys_name_to_handle_at").return ?
{
	@_SYSCALL_NAME_TO_HANDLE_AT_NAME
	retstr = return_str(1, $return)
}

# nd_name_to_handle_at _____________________________________________________

probe nd_syscall.name_to_handle_at =
	kprobe.function("sys_name_to_handle_at").call ?
{
	@_SYSCALL_NAME_TO_HANDLE_AT_NAME
	asmlinkage()
	dfd = int_arg(1)
	dfd_str = _dfd_str(dfd)
	pathname = user_string_quoted(pointer_arg(2))
	handle_uaddr = pointer_arg(3)
	mnt_id_uaddr = pointer_arg(4)
	flags = int_arg(5)
	flags_str = _at_flag_str(flags)
	@_SYSCALL_NAME_TO_HANDLE_AT_ARGSTR
}
probe nd_syscall.name_to_handle_at.return =
	kprobe.function("sys_name_to_handle_at").return ?
{
	@_SYSCALL_NAME_TO_HANDLE_AT_NAME
	retstr = returnstr(1)
}
