/* Returns positive length of the socket name string, or a negative errno value on error.  */
int svc_sock_names(struct svc_serv *serv, char *buf, const size_t buflen, const char *toclose)
/* Returns positive length of the socket name string, or a negative errno value on error.  */
int svc_sock_names(struct svc_serv *serv, char *buf, const size_t buflen, const char *toclose)
{
	struct svc_sock *svsk, *closesk = NULL;
	int len = 0;
	if (!serv)
		return 0;
	spin_lock_bh(&serv->sv_lock);
	list_for_each_entry(svsk, &serv->sv_permsocks, sk_xprt.xpt_list) {
		int onelen = svc_one_sock_name(svsk, buf + len, buflen - len);
		if (onelen < 0) {
			len = onelen;
			break;
		}
		if (toclose && strcmp(toclose, buf + len) == 0)
			closesk = svsk;
		else
			len += onelen;
	}
	spin_unlock_bh(&serv->sv_lock);
	if (closesk)
		svc_close_xprt(&closesk->sk_xprt);
	else if (toclose)
		return -ENOENT;
	return len;
}