Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 153652
b: refs/heads/master
c: 4eb68c2
h: refs/heads/master
v: v3
  • Loading branch information
Chuck Lever authored and J. Bruce Fields committed Apr 28, 2009
1 parent 48d974a commit 87cd26a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 24 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: 4cd5dc751a5889b5b37aa88752e33a58d8f6b624
refs/heads/master: 4eb68c266cb1754ffa0040e882882680ece8cf34
56 changes: 33 additions & 23 deletions trunk/fs/nfsd/nfsctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,36 @@ static ssize_t write_versions(struct file *file, char *buf, size_t size)
return rv;
}

/*
* A transport listener is added by writing it's transport name and
* a port number.
*/
static ssize_t __write_ports_addxprt(char *buf)
{
char transport[16];
int port, err;

if (sscanf(buf, "%15s %4u", transport, &port) != 2)
return -EINVAL;

if (port < 1 || port > USHORT_MAX)
return -EINVAL;

err = nfsd_create_serv();
if (err != 0)
return err;

err = svc_create_xprt(nfsd_serv, transport,
PF_INET, port, SVC_SOCK_ANONYMOUS);
if (err < 0) {
/* Give a reasonable perror msg for bad transport string */
if (err == -ENOENT)
err = -EPROTONOSUPPORT;
return err;
}
return 0;
}

/*
* A transport listener is removed by writing a "-", it's transport
* name, and it's port number.
Expand Down Expand Up @@ -986,29 +1016,9 @@ static ssize_t __write_ports(struct file *file, char *buf, size_t size)
kfree(toclose);
return len;
}
/*
* Add a transport listener by writing it's transport name
*/
if (isalpha(buf[0])) {
int err;
char transport[16];
int port;
if (sscanf(buf, "%15s %4d", transport, &port) == 2) {
if (port < 1 || port > 65535)
return -EINVAL;
err = nfsd_create_serv();
if (!err) {
err = svc_create_xprt(nfsd_serv,
transport, PF_INET, port,
SVC_SOCK_ANONYMOUS);
if (err == -ENOENT)
/* Give a reasonable perror msg for
* bad transport string */
err = -EPROTONOSUPPORT;
}
return err < 0 ? err : 0;
}
}

if (isalpha(buf[0]))
return __write_ports_addxprt(buf);

if (buf[0] == '-' && isalpha(buf[1]))
return __write_ports_delxprt(buf);
Expand Down

0 comments on commit 87cd26a

Please sign in to comment.