summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authorume <ume@FreeBSD.org>2010-02-27 18:27:32 +0000
committerume <ume@FreeBSD.org>2010-02-27 18:27:32 +0000
commitd3f654d9bd26a7b6191629fcdef59f0097eb769c (patch)
tree5532fc15a195479acd35defd696ddb3ba00fba6d /sbin
parente32ada9eaa2bbd6019da71f7bd36aa20a7fa3e9e (diff)
downloadFreeBSD-src-d3f654d9bd26a7b6191629fcdef59f0097eb769c.zip
FreeBSD-src-d3f654d9bd26a7b6191629fcdef59f0097eb769c.tar.gz
MFC r203490: 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.
Diffstat (limited to 'sbin')
-rw-r--r--sbin/mount_nfs/mount_nfs.c22
-rw-r--r--sbin/umount/umount.c13
2 files changed, 26 insertions, 9 deletions
diff --git a/sbin/mount_nfs/mount_nfs.c b/sbin/mount_nfs/mount_nfs.c
index 229da14..5f6d288 100644
--- a/sbin/mount_nfs/mount_nfs.c
+++ b/sbin/mount_nfs/mount_nfs.c
@@ -698,12 +698,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) {
@@ -731,10 +736,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';
}
/*
diff --git a/sbin/umount/umount.c b/sbin/umount/umount.c
index 32ffbb3..e5c5ba9 100644
--- a/sbin/umount/umount.c
+++ b/sbin/umount/umount.c
@@ -325,14 +325,21 @@ umountfs(struct statfs *sfs)
if ((nfsdirname = strdup(sfs->f_mntfromname)) == NULL)
err(1, "strdup");
orignfsdirname = nfsdirname;
- if ((delimp = strrchr(nfsdirname, ':')) != NULL) {
- *delimp = '\0';
+ if (*nfsdirname == '[' &&
+ (delimp = strchr(nfsdirname + 1, ']')) != NULL &&
+ *(delimp + 1) == ':') {
+ hostp = nfsdirname + 1;
+ nfsdirname = delimp + 2;
+ } else if ((delimp = strrchr(nfsdirname, ':')) != NULL) {
hostp = nfsdirname;
+ nfsdirname = delimp + 1;
+ }
+ if (hostp != NULL) {
+ *delimp = '\0';
getaddrinfo(hostp, NULL, &hints, &ai);
if (ai == NULL) {
warnx("can't get net id for host");
}
- nfsdirname = delimp + 1;
}
/*
OpenPOWER on IntegriCloud