# mq_getsetattr ______________________________________________
# long sys_mq_getsetattr(mqd_t mqdes,
#                  const struct mq_attr __user *u_mqstat,
#                  struct mq_attr __user *u_omqstat)
# long compat_sys_mq_getsetattr(mqd_t mqdes,
#			const struct compat_mq_attr __user *u_mqstat,
#			struct compat_mq_attr __user *u_omqstat)
#

@define _SYSCALL_MQ_GETSETATTR_NAME
%(
	name = "mq_getsetattr"
%)

@define _SYSCALL_MQ_GETSETATTR_ARGSTR
%(
	argstr = sprintf("%d, %p, %p", mqdes, u_mqstat_uaddr, u_omqstat_uaddr)
%)

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

# dw_mq_getsetattr _____________________________________________________

probe dw_syscall.mq_getsetattr =
        __syscall.mq_getsetattr,
        kernel.function("compat_sys_mq_getsetattr").call ?
{
	@_SYSCALL_MQ_GETSETATTR_NAME
	mqdes = __int32($mqdes)
	u_mqstat_uaddr = @__pointer($u_mqstat)
	u_omqstat_uaddr = @__pointer($u_omqstat)
	@_SYSCALL_MQ_GETSETATTR_ARGSTR
}
probe __syscall.mq_getsetattr = kernel.function("sys_mq_getsetattr").call
{
        @__syscall_gate(@const("__NR_mq_getsetattr"))
}
probe dw_syscall.mq_getsetattr.return =
        __syscall.mq_getsetattr.return,
        kernel.function("compat_sys_mq_getsetattr").return ?
{
	@_SYSCALL_MQ_GETSETATTR_NAME
	retstr = return_str(1, $return)
}
probe __syscall.mq_getsetattr.return = kernel.function("sys_mq_getsetattr").return
{
        @__syscall_gate(@const("__NR_mq_getsetattr"))
}

# nd_mq_getsetattr _____________________________________________________

probe nd_syscall.mq_getsetattr =
        __nd_syscall.mq_getsetattr ?,
        kprobe.function("compat_sys_mq_getsetattr") ?
{
	@_SYSCALL_MQ_GETSETATTR_NAME
	asmlinkage()
	mqdes = int_arg(1)
	u_mqstat_uaddr = pointer_arg(2)
	u_omqstat_uaddr = pointer_arg(3)
	@_SYSCALL_MQ_GETSETATTR_ARGSTR
}
probe __nd_syscall.mq_getsetattr = kprobe.function("sys_mq_getsetattr")
{
        @__syscall_gate(@const("__NR_mq_getsetattr"))
}
probe nd_syscall.mq_getsetattr.return =
        __nd_syscall.mq_getsetattr.return ?,
        kprobe.function("compat_sys_mq_getsetattr").return ?
{
	@_SYSCALL_MQ_GETSETATTR_NAME
	retstr = returnstr(1)
}
probe __nd_syscall.mq_getsetattr.return = kprobe.function("sys_mq_getsetattr").return
{
        @__syscall_gate(@const("__NR_mq_getsetattr"))
}
