/* returns zero on success, an error code otherwise  */
static int smack_socket_getpeersec_stream(struct socket *sock, char __user *optval, int __user *optlen, unsigned len)
/* returns zero on success, an error code otherwise  */
static int smack_socket_getpeersec_stream(struct socket *sock, char __user *optval, int __user *optlen, unsigned len)
{
	struct socket_smack *ssp;
	int slen;
	int rc = 0;
	ssp = sock->sk->sk_security;
	slen = strlen(ssp->smk_packet) + 1;
	if (slen > len)
		rc = -ERANGE;
	else if (copy_to_user(optval, ssp->smk_packet, slen) != 0)
		rc = -EFAULT;
	if (put_user(slen, optlen) != 0)
		rc = -EFAULT;
	return rc;
}