Introduce '[ipaddr]:path' notation.

Since the existing implementation searches ':' backward, a path which
includes ':' could not be mounted.  You can now mount such path by
enclosing an IP address by '[]'.
Though we should change to search ':' forward, it will break
'ipv6addr:path' which is currently working.  So, it still searches ':'
backward, at least for now.

MFC after:	2 weeks
This commit is contained in:
Hajimu UMEMOTO 2010-02-04 15:17:49 +00:00
parent 0a65b79f42
commit a505d4352f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=203490
2 changed files with 26 additions and 9 deletions

View File

@ -697,12 +697,17 @@ getnfsargs(char *spec, struct iovec **iov, int *iovlen)
{ {
struct addrinfo hints, *ai_nfs, *ai; struct addrinfo hints, *ai_nfs, *ai;
enum tryret ret; enum tryret ret;
int ecode, speclen, remoteerr; int ecode, speclen, remoteerr, offset, have_bracket = 0;
char *hostp, *delimp, *errstr; char *hostp, *delimp, *errstr;
size_t len; size_t len;
static char nam[MNAMELEN + 1], pname[MAXHOSTNAMELEN + 5]; static char nam[MNAMELEN + 1], pname[MAXHOSTNAMELEN + 5];
if ((delimp = strrchr(spec, ':')) != NULL) { if (*spec == '[' && (delimp = strchr(spec + 1, ']')) != NULL &&
*(delimp + 1) == ':') {
hostp = spec + 1;
spec = delimp + 2;
have_bracket = 1;
} else if ((delimp = strrchr(spec, ':')) != NULL) {
hostp = spec; hostp = spec;
spec = delimp + 1; spec = delimp + 1;
} else if ((delimp = strrchr(spec, '@')) != NULL) { } else if ((delimp = strrchr(spec, '@')) != NULL) {
@ -730,10 +735,15 @@ getnfsargs(char *spec, struct iovec **iov, int *iovlen)
/* Make both '@' and ':' notations equal */ /* Make both '@' and ':' notations equal */
if (*hostp != '\0') { if (*hostp != '\0') {
len = strlen(hostp); len = strlen(hostp);
memmove(nam, hostp, len); offset = 0;
nam[len] = ':'; if (have_bracket)
memmove(nam + len + 1, spec, speclen); nam[offset++] = '[';
nam[len + speclen + 1] = '\0'; memmove(nam + offset, hostp, len);
if (have_bracket)
nam[len + offset++] = ']';
nam[len + offset++] = ':';
memmove(nam + len + offset, spec, speclen);
nam[len + speclen + offset] = '\0';
} }
/* /*

View File

@ -325,14 +325,21 @@ umountfs(struct statfs *sfs)
if ((nfsdirname = strdup(sfs->f_mntfromname)) == NULL) if ((nfsdirname = strdup(sfs->f_mntfromname)) == NULL)
err(1, "strdup"); err(1, "strdup");
orignfsdirname = nfsdirname; orignfsdirname = nfsdirname;
if ((delimp = strrchr(nfsdirname, ':')) != NULL) { if (*nfsdirname == '[' &&
*delimp = '\0'; (delimp = strchr(nfsdirname + 1, ']')) != NULL &&
*(delimp + 1) == ':') {
hostp = nfsdirname + 1;
nfsdirname = delimp + 2;
} else if ((delimp = strrchr(nfsdirname, ':')) != NULL) {
hostp = nfsdirname; hostp = nfsdirname;
nfsdirname = delimp + 1;
}
if (hostp != NULL) {
*delimp = '\0';
getaddrinfo(hostp, NULL, &hints, &ai); getaddrinfo(hostp, NULL, &hints, &ai);
if (ai == NULL) { if (ai == NULL) {
warnx("can't get net id for host"); warnx("can't get net id for host");
} }
nfsdirname = delimp + 1;
} }
/* /*