diff options
-rw-r--r-- | util-linux/mount.c | 50 |
1 files changed, 20 insertions, 30 deletions
diff --git a/util-linux/mount.c b/util-linux/mount.c index e1372ead5..1ffed9dfd 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c | |||
@@ -1639,52 +1639,42 @@ static int singlemount(struct mntent *mp, int ignore_busy) | |||
1639 | && (mp->mnt_fsname[0] == '/' || mp->mnt_fsname[0] == '\\') | 1639 | && (mp->mnt_fsname[0] == '/' || mp->mnt_fsname[0] == '\\') |
1640 | && mp->mnt_fsname[0] == mp->mnt_fsname[1] | 1640 | && mp->mnt_fsname[0] == mp->mnt_fsname[1] |
1641 | ) { | 1641 | ) { |
1642 | #if 0 /* reported to break things */ | 1642 | int len; |
1643 | char c; | ||
1643 | len_and_sockaddr *lsa; | 1644 | len_and_sockaddr *lsa; |
1644 | char *ip, *dotted; | 1645 | char *ip, *dotted, *s; |
1645 | char *s; | ||
1646 | |||
1647 | // Replace '/' with '\' and verify that unc points to "//server/share". | ||
1648 | for (s = mp->mnt_fsname; *s; ++s) | ||
1649 | if (*s == '/') *s = '\\'; | ||
1650 | 1646 | ||
1651 | // Get server IP | 1647 | s = mp->mnt_fsname + 2; |
1652 | s = strrchr(mp->mnt_fsname, '\\'); | 1648 | len = strcspn(s, "/\\"); |
1653 | if (s <= mp->mnt_fsname+1) | 1649 | s += len; // points after hostname |
1650 | if (len == 0 || *s == '\0') | ||
1654 | goto report_error; | 1651 | goto report_error; |
1652 | c = *s; | ||
1655 | *s = '\0'; | 1653 | *s = '\0'; |
1656 | lsa = host2sockaddr(mp->mnt_fsname+2, 0); | 1654 | lsa = host2sockaddr(s, 0); |
1657 | *s = '\\'; | 1655 | *s = c; |
1658 | if (!lsa) | 1656 | if (!lsa) |
1659 | goto report_error; | 1657 | goto report_error; |
1660 | 1658 | ||
1661 | // Insert ip=... option into string flags. | 1659 | // Insert "ip=..." option into options |
1662 | dotted = xmalloc_sockaddr2dotted_noport(&lsa->u.sa); | 1660 | dotted = xmalloc_sockaddr2dotted_noport(&lsa->u.sa); |
1661 | if (ENABLE_FEATURE_CLEAN_UP) free(lsa); | ||
1663 | ip = xasprintf("ip=%s", dotted); | 1662 | ip = xasprintf("ip=%s", dotted); |
1663 | if (ENABLE_FEATURE_CLEAN_UP) free(dotted); | ||
1664 | parse_mount_options(ip, &filteropts); | 1664 | parse_mount_options(ip, &filteropts); |
1665 | if (ENABLE_FEATURE_CLEAN_UP) free(ip); | ||
1665 | 1666 | ||
1666 | // Compose new unc '\\server-ip\share' | 1667 | // "-o mand" is required [why?] |
1667 | // (s => slash after hostname) | ||
1668 | mp->mnt_fsname = xasprintf("\\\\%s%s", dotted, s); | ||
1669 | #endif | ||
1670 | // Lock is required [why?] | ||
1671 | vfsflags |= MS_MANDLOCK; | 1668 | vfsflags |= MS_MANDLOCK; |
1672 | mp->mnt_type = (char*)"cifs"; | 1669 | mp->mnt_type = (char*)"cifs"; |
1673 | rc = mount_it_now(mp, vfsflags, filteropts); | 1670 | rc = mount_it_now(mp, vfsflags, filteropts); |
1674 | #if 0 | 1671 | |
1675 | if (ENABLE_FEATURE_CLEAN_UP) { | ||
1676 | free(mp->mnt_fsname); | ||
1677 | free(ip); | ||
1678 | free(dotted); | ||
1679 | free(lsa); | ||
1680 | } | ||
1681 | #endif | ||
1682 | goto report_error; | 1672 | goto report_error; |
1683 | } | 1673 | } |
1684 | 1674 | ||
1685 | // Might this be an NFS filesystem? | 1675 | // Might this be an NFS filesystem? |
1686 | if (ENABLE_FEATURE_MOUNT_NFS | 1676 | if (ENABLE_FEATURE_MOUNT_NFS |
1687 | && (!mp->mnt_type || !strcmp(mp->mnt_type, "nfs")) | 1677 | && (!mp->mnt_type || strcmp(mp->mnt_type, "nfs") == 0) |
1688 | && strchr(mp->mnt_fsname, ':') != NULL | 1678 | && strchr(mp->mnt_fsname, ':') != NULL |
1689 | ) { | 1679 | ) { |
1690 | rc = nfsmount(mp, vfsflags, filteropts); | 1680 | rc = nfsmount(mp, vfsflags, filteropts); |
@@ -1702,7 +1692,7 @@ static int singlemount(struct mntent *mp, int ignore_busy) | |||
1702 | if (ENABLE_FEATURE_MOUNT_LOOP && S_ISREG(st.st_mode)) { | 1692 | if (ENABLE_FEATURE_MOUNT_LOOP && S_ISREG(st.st_mode)) { |
1703 | loopFile = bb_simplify_path(mp->mnt_fsname); | 1693 | loopFile = bb_simplify_path(mp->mnt_fsname); |
1704 | mp->mnt_fsname = NULL; // will receive malloced loop dev name | 1694 | mp->mnt_fsname = NULL; // will receive malloced loop dev name |
1705 | if (set_loop(&(mp->mnt_fsname), loopFile, 0) < 0) { | 1695 | if (set_loop(&mp->mnt_fsname, loopFile, 0) < 0) { |
1706 | if (errno == EPERM || errno == EACCES) | 1696 | if (errno == EPERM || errno == EACCES) |
1707 | bb_error_msg(bb_msg_perm_denied_are_you_root); | 1697 | bb_error_msg(bb_msg_perm_denied_are_you_root); |
1708 | else | 1698 | else |
@@ -1870,9 +1860,9 @@ int mount_main(int argc UNUSED_PARAM, char **argv) | |||
1870 | { | 1860 | { |
1871 | // Don't show rootfs. FIXME: why?? | 1861 | // Don't show rootfs. FIXME: why?? |
1872 | // util-linux 2.12a happily shows rootfs... | 1862 | // util-linux 2.12a happily shows rootfs... |
1873 | //if (!strcmp(mtpair->mnt_fsname, "rootfs")) continue; | 1863 | //if (strcmp(mtpair->mnt_fsname, "rootfs") == 0) continue; |
1874 | 1864 | ||
1875 | if (!fstype || !strcmp(mtpair->mnt_type, fstype)) | 1865 | if (!fstype || strcmp(mtpair->mnt_type, fstype) == 0) |
1876 | printf("%s on %s type %s (%s)\n", mtpair->mnt_fsname, | 1866 | printf("%s on %s type %s (%s)\n", mtpair->mnt_fsname, |
1877 | mtpair->mnt_dir, mtpair->mnt_type, | 1867 | mtpair->mnt_dir, mtpair->mnt_type, |
1878 | mtpair->mnt_opts); | 1868 | mtpair->mnt_opts); |