# umount _____________________________________________________
# long sys_umount(char __user * name, int flags)
# SYSCALL_DEFINE1(oldumount, char __user *, name)
#

@define _SYSCALL_UMOUNT_NAME
%(
	name = "umount"
%)

@define _SYSCALL_UMOUNT_ARGSTR
%(
	argstr = sprintf("%s, %s", target, flags_str)
%)

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

# dw_umount _____________________________________________________

probe dw_syscall.umount = __syscall.umount, __syscall.oldumount ?
{
	@_SYSCALL_UMOUNT_NAME
}
probe __syscall.umount = kernel.function("sys_umount").call
{
	@__syscall_compat_gate(@const("__NR_umount2"), @const("__NR_compat_umount2"))
	target = user_string_quoted($name)
	flags = $flags
	flags_str = _umountflags_str($flags)
	@_SYSCALL_UMOUNT_ARGSTR
}
probe __syscall.oldumount = kernel.function("sys_oldumount").call ?
{
	target = user_string_quoted($name)
	flags = 0
	flags_str = _umountflags_str(0)
	@_SYSCALL_UMOUNT_ARGSTR
}
probe dw_syscall.umount.return = __syscall.umount.return,
			      kernel.function("sys_oldumount").return ?
{
	@_SYSCALL_UMOUNT_NAME
	retstr = return_str(1, $return)
}
probe __syscall.umount.return = kernel.function("sys_umount").return
{
	@__syscall_compat_gate(@const("__NR_umount2"), @const("__NR_compat_umount2"))
}

# nd_umount _____________________________________________________

probe nd_syscall.umount = __nd_syscall.umount, __nd_syscall.oldumount ?
{
	@_SYSCALL_UMOUNT_NAME
}
probe __nd_syscall.umount = kprobe.function("sys_umount")
{
	@__syscall_compat_gate(@const("__NR_umount2"), @const("__NR_compat_umount2"))
	asmlinkage()
	target = user_string_quoted(pointer_arg(1))
	flags = int_arg(2)
	flags_str = _umountflags_str(flags)
	@_SYSCALL_UMOUNT_ARGSTR
}
probe __nd_syscall.oldumount = kprobe.function("sys_oldumount") ?
{
	asmlinkage()
	target = user_string_quoted(pointer_arg(1))
	flags = 0
	flags_str = _umountflags_str(0)
	@_SYSCALL_UMOUNT_ARGSTR
}
probe nd_syscall.umount.return = __nd_syscall.umount.return,
				 kprobe.function("sys_oldumount").return ?
{
	@_SYSCALL_UMOUNT_NAME
	retstr = returnstr(1)
}
probe __nd_syscall.umount.return = kprobe.function("sys_umount").return
{
	@__syscall_compat_gate(@const("__NR_umount2"), @const("__NR_compat_umount2"))
}
