diff options
-rw-r--r-- | fs/nfsd/nfsctl.c | 2 | ||||
-rw-r--r-- | include/linux/sunrpc/svc_xprt.h | 1 | ||||
-rw-r--r-- | net/sunrpc/svc_xprt.c | 35 |
3 files changed, 37 insertions, 1 deletions
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index eff6a6b4c2f6..bc22e0b0343a 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c | |||
@@ -503,7 +503,7 @@ static ssize_t write_ports(struct file *file, char *buf, size_t size) | |||
503 | int len = 0; | 503 | int len = 0; |
504 | lock_kernel(); | 504 | lock_kernel(); |
505 | if (nfsd_serv) | 505 | if (nfsd_serv) |
506 | len = svc_sock_names(buf, nfsd_serv, NULL); | 506 | len = svc_xprt_names(nfsd_serv, buf, 0); |
507 | unlock_kernel(); | 507 | unlock_kernel(); |
508 | return len; | 508 | return len; |
509 | } | 509 | } |
diff --git a/include/linux/sunrpc/svc_xprt.h b/include/linux/sunrpc/svc_xprt.h index 68862d51bb36..6fd7b016517f 100644 --- a/include/linux/sunrpc/svc_xprt.h +++ b/include/linux/sunrpc/svc_xprt.h | |||
@@ -81,6 +81,7 @@ void svc_delete_xprt(struct svc_xprt *xprt); | |||
81 | int svc_port_is_privileged(struct sockaddr *sin); | 81 | int svc_port_is_privileged(struct sockaddr *sin); |
82 | int svc_print_xprts(char *buf, int maxlen); | 82 | int svc_print_xprts(char *buf, int maxlen); |
83 | struct svc_xprt *svc_find_xprt(struct svc_serv *, char *, int, int); | 83 | struct svc_xprt *svc_find_xprt(struct svc_serv *, char *, int, int); |
84 | int svc_xprt_names(struct svc_serv *serv, char *buf, int buflen); | ||
84 | 85 | ||
85 | static inline void svc_xprt_get(struct svc_xprt *xprt) | 86 | static inline void svc_xprt_get(struct svc_xprt *xprt) |
86 | { | 87 | { |
diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c index 783597343877..c3fb36784f3b 100644 --- a/net/sunrpc/svc_xprt.c +++ b/net/sunrpc/svc_xprt.c | |||
@@ -1014,3 +1014,38 @@ struct svc_xprt *svc_find_xprt(struct svc_serv *serv, char *xcl_name, | |||
1014 | return found; | 1014 | return found; |
1015 | } | 1015 | } |
1016 | EXPORT_SYMBOL_GPL(svc_find_xprt); | 1016 | EXPORT_SYMBOL_GPL(svc_find_xprt); |
1017 | |||
1018 | /* | ||
1019 | * Format a buffer with a list of the active transports. A zero for | ||
1020 | * the buflen parameter disables target buffer overflow checking. | ||
1021 | */ | ||
1022 | int svc_xprt_names(struct svc_serv *serv, char *buf, int buflen) | ||
1023 | { | ||
1024 | struct svc_xprt *xprt; | ||
1025 | char xprt_str[64]; | ||
1026 | int totlen = 0; | ||
1027 | int len; | ||
1028 | |||
1029 | /* Sanity check args */ | ||
1030 | if (!serv) | ||
1031 | return 0; | ||
1032 | |||
1033 | spin_lock_bh(&serv->sv_lock); | ||
1034 | list_for_each_entry(xprt, &serv->sv_permsocks, xpt_list) { | ||
1035 | len = snprintf(xprt_str, sizeof(xprt_str), | ||
1036 | "%s %d\n", xprt->xpt_class->xcl_name, | ||
1037 | svc_xprt_local_port(xprt)); | ||
1038 | /* If the string was truncated, replace with error string */ | ||
1039 | if (len >= sizeof(xprt_str)) | ||
1040 | strcpy(xprt_str, "name-too-long\n"); | ||
1041 | /* Don't overflow buffer */ | ||
1042 | len = strlen(xprt_str); | ||
1043 | if (buflen && (len + totlen >= buflen)) | ||
1044 | break; | ||
1045 | strcpy(buf+totlen, xprt_str); | ||
1046 | totlen += len; | ||
1047 | } | ||
1048 | spin_unlock_bh(&serv->sv_lock); | ||
1049 | return totlen; | ||
1050 | } | ||
1051 | EXPORT_SYMBOL_GPL(svc_xprt_names); | ||