# compat_ftruncate64 ________________________________________
#
# asmlinkage int compat_sys_ftruncate64(unsigned int fd, u32 reg4,
#					unsigned long high, unsigned long low)
#

@define _SYSCALL_COMPAT_FTRUNCATE64_NAME
%(
	name = "ftruncate"
%)

@define _SYSCALL_COMPAT_FTRUNCATE64_ARGSTR
%(
	argstr = sprintf("%d, %d", fd, length)
%)

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

# dw_compat_ftruncate64 _____________________________________________________

probe dw_syscall.compat_ftruncate64 =
	kernel.function("compat_sys_ftruncate64").call ?
{
	@_SYSCALL_COMPAT_FTRUNCATE64_NAME
	fd = __int32($fd)
	length = ($high << 32 | $low)
	@_SYSCALL_COMPAT_FTRUNCATE64_ARGSTR
}
probe dw_syscall.compat_ftruncate64.return =
	kernel.function("compat_sys_ftruncate64").return ?
{
	@_SYSCALL_COMPAT_FTRUNCATE64_NAME
	retstr = return_str(1, $return)
}

# nd_compat_ftruncate64 _____________________________________________________

probe nd_syscall.compat_ftruncate64 =
	kprobe.function("compat_sys_ftruncate64") ?
{
	asmlinkage()
	@_SYSCALL_COMPAT_FTRUNCATE64_NAME
	fd = int_arg(1)
	length = (ulong_arg(3) << 32 | ulong_arg(4))
	@_SYSCALL_COMPAT_FTRUNCATE64_ARGSTR
}
probe nd_syscall.compat_ftruncate64.return =
	kprobe.function("compat_sys_ftruncate64").return ?
{
	@_SYSCALL_COMPAT_FTRUNCATE64_NAME
	retstr = returnstr(1)
}
