diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-02-04 02:39:55 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-02-04 02:39:55 +0000 |
commit | 5870ad9672ac09e366f1bfd4086e98cd019ed8f2 (patch) | |
tree | d7657a18e022900fdc6e0df24b59af9042e84109 /util-linux | |
parent | 42823d597a9029ac497edda9102f61283630635b (diff) | |
download | busybox-5870ad9672ac09e366f1bfd4086e98cd019ed8f2.tar.gz |
mount: (try to) support cifs with IPv6
Diffstat (limited to 'util-linux')
-rw-r--r-- | util-linux/mount.c | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/util-linux/mount.c b/util-linux/mount.c index 702c0338a..567514ccb 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c @@ -687,6 +687,8 @@ get_mountport(struct sockaddr_in *server_addr, static struct pmap p = {0, 0, 0, 0}; server_addr->sin_port = PMAPPORT; +/* glibc 2.4 (still) has pmap_getmaps(struct sockaddr_in *). + * I understand it like "IPv6 for this is not 100% ready" */ pmap = pmap_getmaps(server_addr); if (version > MAX_NFSPROT) @@ -1396,8 +1398,9 @@ static int singlemount(struct mntent *mp, int ignore_busy) && (mp->mnt_fsname[0]=='/' || mp->mnt_fsname[0]=='\\') && mp->mnt_fsname[0]==mp->mnt_fsname[1] ) { - struct hostent *he; - char ip[32], *s; + len_and_sockaddr *lsa; + char *ip, *dotted; + char *s; rc = 1; // Replace '/' with '\' and verify that unc points to "//server/share". @@ -1408,29 +1411,34 @@ static int singlemount(struct mntent *mp, int ignore_busy) // get server IP s = strrchr(mp->mnt_fsname, '\\'); - if (s == mp->mnt_fsname+1) goto report_error; + if (s <= mp->mnt_fsname+1) goto report_error; *s = '\0'; - he = gethostbyname(mp->mnt_fsname+2); + lsa = host2sockaddr(mp->mnt_fsname+2, 0); *s = '\\'; - if (!he) goto report_error; + if (!lsa) goto report_error; - // Insert ip=... option into string flags. (NOTE: Add IPv6 support.) + // insert ip=... option into string flags. - sprintf(ip, "ip=%d.%d.%d.%d", he->h_addr[0], he->h_addr[1], - he->h_addr[2], he->h_addr[3]); + dotted = xmalloc_sockaddr2dotted_noport(&lsa->sa, lsa->len); + ip = xasprintf("ip=%s", dotted); parse_mount_options(ip, &filteropts); // compose new unc '\\server-ip\share' + // (s => slash after hostname) - mp->mnt_fsname = xasprintf("\\\\%s%s", ip+3, - strchr(mp->mnt_fsname+2,'\\')); + mp->mnt_fsname = xasprintf("\\\\%s%s", dotted, s); // lock is required vfsflags |= MS_MANDLOCK; mp->mnt_type = (char*)"cifs"; rc = mount_it_now(mp, vfsflags, filteropts); - if (ENABLE_FEATURE_CLEAN_UP) free(mp->mnt_fsname); + if (ENABLE_FEATURE_CLEAN_UP) { + free(mp->mnt_fsname); + free(ip); + free(dotted); + free(lsa); + } goto report_error; } @@ -1508,8 +1516,9 @@ static int singlemount(struct mntent *mp, int ignore_busy) } } -report_error: - if (ENABLE_FEATURE_CLEAN_UP) free(filteropts); + report_error: + if (ENABLE_FEATURE_CLEAN_UP) + free(filteropts); if (rc && errno == EBUSY && ignore_busy) rc = 0; if (rc < 0) |