Commit 9571af18 authored by Tom Tucker's avatar Tom Tucker Committed by J. Bruce Fields

svc: Add svc_xprt_names service to replace svc_sock_names

Create a transport independent version of the svc_sock_names function.

The toclose capability of the svc_sock_names service can be implemented
using the svc_xprt_find and svc_xprt_close services.
Signed-off-by: default avatarTom Tucker <tom@opengridcomputing.com>
Acked-by: default avatarNeil Brown <neilb@suse.de>
Reviewed-by: default avatarChuck Lever <chuck.lever@oracle.com>
Reviewed-by: default avatarGreg Banks <gnb@sgi.com>
Signed-off-by: default avatarJ. Bruce Fields <bfields@citi.umich.edu>
parent a217813f
...@@ -503,7 +503,7 @@ static ssize_t write_ports(struct file *file, char *buf, size_t size) ...@@ -503,7 +503,7 @@ static ssize_t write_ports(struct file *file, char *buf, size_t size)
int len = 0; int len = 0;
lock_kernel(); lock_kernel();
if (nfsd_serv) if (nfsd_serv)
len = svc_sock_names(buf, nfsd_serv, NULL); len = svc_xprt_names(nfsd_serv, buf, 0);
unlock_kernel(); unlock_kernel();
return len; return len;
} }
......
...@@ -81,6 +81,7 @@ void svc_delete_xprt(struct svc_xprt *xprt); ...@@ -81,6 +81,7 @@ void svc_delete_xprt(struct svc_xprt *xprt);
int svc_port_is_privileged(struct sockaddr *sin); int svc_port_is_privileged(struct sockaddr *sin);
int svc_print_xprts(char *buf, int maxlen); int svc_print_xprts(char *buf, int maxlen);
struct svc_xprt *svc_find_xprt(struct svc_serv *, char *, int, int); struct svc_xprt *svc_find_xprt(struct svc_serv *, char *, int, int);
int svc_xprt_names(struct svc_serv *serv, char *buf, int buflen);
static inline void svc_xprt_get(struct svc_xprt *xprt) static inline void svc_xprt_get(struct svc_xprt *xprt)
{ {
......
...@@ -1014,3 +1014,38 @@ struct svc_xprt *svc_find_xprt(struct svc_serv *serv, char *xcl_name, ...@@ -1014,3 +1014,38 @@ struct svc_xprt *svc_find_xprt(struct svc_serv *serv, char *xcl_name,
return found; return found;
} }
EXPORT_SYMBOL_GPL(svc_find_xprt); EXPORT_SYMBOL_GPL(svc_find_xprt);
/*
* Format a buffer with a list of the active transports. A zero for
* the buflen parameter disables target buffer overflow checking.
*/
int svc_xprt_names(struct svc_serv *serv, char *buf, int buflen)
{
struct svc_xprt *xprt;
char xprt_str[64];
int totlen = 0;
int len;
/* Sanity check args */
if (!serv)
return 0;
spin_lock_bh(&serv->sv_lock);
list_for_each_entry(xprt, &serv->sv_permsocks, xpt_list) {
len = snprintf(xprt_str, sizeof(xprt_str),
"%s %d\n", xprt->xpt_class->xcl_name,
svc_xprt_local_port(xprt));
/* If the string was truncated, replace with error string */
if (len >= sizeof(xprt_str))
strcpy(xprt_str, "name-too-long\n");
/* Don't overflow buffer */
len = strlen(xprt_str);
if (buflen && (len + totlen >= buflen))
break;
strcpy(buf+totlen, xprt_str);
totlen += len;
}
spin_unlock_bh(&serv->sv_lock);
return totlen;
}
EXPORT_SYMBOL_GPL(svc_xprt_names);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment