Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 153658
b: refs/heads/master
c: 335c54b
h: refs/heads/master
v: v3
  • Loading branch information
Chuck Lever authored and J. Bruce Fields committed Apr 28, 2009
1 parent 5ff8de4 commit a6b9a0f
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 20 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ea068bad27cefc71ab03230dbf01a8f8d98da5ba
refs/heads/master: 335c54bdc4d3bacdbd619ec95cd0b352435bd37f
2 changes: 1 addition & 1 deletion trunk/fs/nfsd/nfsctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ static ssize_t __write_ports_names(char *buf)
{
if (nfsd_serv == NULL)
return 0;
return svc_xprt_names(nfsd_serv, buf, 0);
return svc_xprt_names(nfsd_serv, buf, SIMPLE_TRANSACTION_LIMIT);
}

/*
Expand Down
2 changes: 1 addition & 1 deletion trunk/include/linux/sunrpc/svc_xprt.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ int svc_port_is_privileged(struct sockaddr *sin);
int svc_print_xprts(char *buf, int maxlen);
struct svc_xprt *svc_find_xprt(struct svc_serv *serv, const char *xcl_name,
const sa_family_t af, const unsigned short port);
int svc_xprt_names(struct svc_serv *serv, char *buf, int buflen);
int svc_xprt_names(struct svc_serv *serv, char *buf, const int buflen);

static inline void svc_xprt_get(struct svc_xprt *xprt)
{
Expand Down
56 changes: 39 additions & 17 deletions trunk/net/sunrpc/svc_xprt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1098,36 +1098,58 @@ struct svc_xprt *svc_find_xprt(struct svc_serv *serv, const char *xcl_name,
}
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.
static int svc_one_xprt_name(const struct svc_xprt *xprt,
char *pos, int remaining)
{
int len;

len = snprintf(pos, remaining, "%s %u\n",
xprt->xpt_class->xcl_name,
svc_xprt_local_port(xprt));
if (len >= remaining)
return -ENAMETOOLONG;
return len;
}

/**
* svc_xprt_names - format a buffer with a list of transport names
* @serv: pointer to an RPC service
* @buf: pointer to a buffer to be filled in
* @buflen: length of buffer to be filled in
*
* Fills in @buf with a string containing a list of transport names,
* each name terminated with '\n'.
*
* Returns positive length of the filled-in string on success; otherwise
* a negative errno value is returned if an error occurs.
*/
int svc_xprt_names(struct svc_serv *serv, char *buf, int buflen)
int svc_xprt_names(struct svc_serv *serv, char *buf, const int buflen)
{
struct svc_xprt *xprt;
char xprt_str[64];
int totlen = 0;
int len;
int len, totlen;
char *pos;

/* Sanity check args */
if (!serv)
return 0;

spin_lock_bh(&serv->sv_lock);

pos = buf;
totlen = 0;
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))
len = svc_one_xprt_name(xprt, pos, buflen - totlen);
if (len < 0) {
*buf = '\0';
totlen = len;
}
if (len <= 0)
break;
strcpy(buf+totlen, xprt_str);

pos += len;
totlen += len;
}

spin_unlock_bh(&serv->sv_lock);
return totlen;
}
Expand Down

0 comments on commit a6b9a0f

Please sign in to comment.