# faccessat __________________________________________________
# new function with 2.6.16
# long sys_faccessat(int dfd, const char __user *filename, int mode)

@define _SYSCALL_FACCESSAT_NAME
%(
	name = "faccessat"
%)

@define _SYSCALL_FACCESSAT_ARGSTR
%(
	argstr = sprintf("%s, %s, %s", dirfd_str, pathname, mode_str)
%)

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

# dw_faccessat _____________________________________________________

probe dw_syscall.faccessat = kernel.function("sys_faccessat").call ?
{
	@__syscall_compat_gate(@const("__NR_faccessat"),
			       @const("__NR_compat_faccessat"))
	@_SYSCALL_FACCESSAT_NAME
	dirfd = __int32($dfd)
	dirfd_str = _dfd_str(__int32($dfd))
	pathname = user_string_quoted($filename)
	mode = __int32($mode)
	mode_str = _access_mode_str(__int32($mode))
	@_SYSCALL_FACCESSAT_ARGSTR
}
probe dw_syscall.faccessat.return = kernel.function("sys_faccessat").return ?
{
	@__syscall_compat_gate(@const("__NR_faccessat"),
			       @const("__NR_compat_faccessat"))
	@_SYSCALL_FACCESSAT_NAME
	retstr = return_str(1, $return)
}

# nd_faccessat _____________________________________________________

probe nd_syscall.faccessat = kprobe.function("sys_faccessat") ?
{
	@__syscall_compat_gate(@const("__NR_faccessat"),
			       @const("__NR_compat_faccessat"))
	@_SYSCALL_FACCESSAT_NAME
	asmlinkage()
	dirfd = int_arg(1)
	dirfd_str = _dfd_str(dirfd)
	pathname = user_string_quoted(pointer_arg(2))
	mode = int_arg(3)
	mode_str = _access_mode_str(mode)
	@_SYSCALL_FACCESSAT_ARGSTR
}
probe nd_syscall.faccessat.return = kprobe.function("sys_faccessat").return ?
{
	@__syscall_compat_gate(@const("__NR_faccessat"),
			       @const("__NR_compat_faccessat"))
	@_SYSCALL_FACCESSAT_NAME
	retstr = returnstr(1)
}
