# getxattr ___________________________________________________
# ssize_t sys_getxattr(char __user *path, char __user *name,
#		void __user *value, size_t size)

@define _SYSCALL_GETXATTR_NAME
%(
	name = "getxattr"
%)

@define _SYSCALL_GETXATTR_ARGSTR
%(
	argstr = sprintf("%s, %s, %p, %u", path, name_str, value_uaddr, size)
%)

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

# dw_getxattr _____________________________________________________

probe dw_syscall.getxattr = kernel.function("sys_getxattr").call
{
	@_SYSCALL_GETXATTR_NAME
	path = user_string_quoted(@choose_defined($pathname, $path))
# 'name2' should have been 'name_str'.  Deprecate the old name.
%(systemtap_v <= "1.4" %?
	name2 = user_string_quoted($name)
%)
	name_str = user_string_quoted($name)
	value_uaddr = $value
	size = __ulong($size)
	@_SYSCALL_GETXATTR_ARGSTR
}
probe dw_syscall.getxattr.return = kernel.function("sys_getxattr").return
{
	@_SYSCALL_GETXATTR_NAME
	retstr = return_str(1, $return)
}

# nd_getxattr _____________________________________________________

probe nd_syscall.getxattr = kprobe.function("sys_getxattr") ?
{
	@_SYSCALL_GETXATTR_NAME
	asmlinkage()
	path = user_string_quoted(pointer_arg(1))
# 'name2' should have been 'name_str'.  Deprecate the old name.
%(systemtap_v <= "1.4" %?
	name2 = user_string_quoted(pointer_arg(2))
%)
	name_str = user_string_quoted(pointer_arg(2))
	value_uaddr = pointer_arg(3)
	size = ulong_arg(4)
	@_SYSCALL_GETXATTR_ARGSTR
}
probe nd_syscall.getxattr.return = kprobe.function("sys_getxattr").return ?
{
	@_SYSCALL_GETXATTR_NAME
	retstr = returnstr(1)
}
