diff options
author | ume <ume@FreeBSD.org> | 2010-02-04 15:17:49 +0000 |
---|---|---|
committer | ume <ume@FreeBSD.org> | 2010-02-04 15:17:49 +0000 |
commit | 4650055e248bb24fa28802c303a9d9af06e02256 (patch) | |
tree | 47de67c389eb6cb8f26bd61cf585c8bbb5343ed0 /sbin/mount_nfs | |
parent | c0230e45d38c056190d62f120a08601dac6aa360 (diff) | |
download | FreeBSD-src-4650055e248bb24fa28802c303a9d9af06e02256.zip FreeBSD-src-4650055e248bb24fa28802c303a9d9af06e02256.tar.gz |
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
Diffstat (limited to 'sbin/mount_nfs')
-rw-r--r-- | sbin/mount_nfs/mount_nfs.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/sbin/mount_nfs/mount_nfs.c b/sbin/mount_nfs/mount_nfs.c index beb8ff8..5e722a0 100644 --- a/sbin/mount_nfs/mount_nfs.c +++ b/sbin/mount_nfs/mount_nfs.c @@ -697,12 +697,17 @@ getnfsargs(char *spec, struct iovec **iov, int *iovlen) { struct addrinfo hints, *ai_nfs, *ai; enum tryret ret; - int ecode, speclen, remoteerr; + int ecode, speclen, remoteerr, offset, have_bracket = 0; char *hostp, *delimp, *errstr; size_t len; 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; spec = delimp + 1; } else if ((delimp = strrchr(spec, '@')) != NULL) { @@ -730,10 +735,15 @@ getnfsargs(char *spec, struct iovec **iov, int *iovlen) /* Make both '@' and ':' notations equal */ if (*hostp != '\0') { len = strlen(hostp); - memmove(nam, hostp, len); - nam[len] = ':'; - memmove(nam + len + 1, spec, speclen); - nam[len + speclen + 1] = '\0'; + offset = 0; + if (have_bracket) + nam[offset++] = '['; + 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'; } /* |