aboutsummaryrefslogtreecommitdiff
path: root/util-linux/mount.c
diff options
context:
space:
mode:
Diffstat (limited to 'util-linux/mount.c')
-rw-r--r--util-linux/mount.c99
1 files changed, 71 insertions, 28 deletions
diff --git a/util-linux/mount.c b/util-linux/mount.c
index f94b6e643..807e89747 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -820,31 +820,31 @@ enum {
820 */ 820 */
821 821
822struct nfs2_fh { 822struct nfs2_fh {
823 char data[32]; 823 char data[32];
824}; 824};
825struct nfs3_fh { 825struct nfs3_fh {
826 unsigned short size; 826 unsigned short size;
827 unsigned char data[64]; 827 unsigned char data[64];
828}; 828};
829 829
830struct nfs_mount_data { 830struct nfs_mount_data {
831 int version; /* 1 */ 831 int version; /* 1 */
832 int fd; /* 1 */ 832 int fd; /* 1 */
833 struct nfs2_fh old_root; /* 1 */ 833 struct nfs2_fh old_root; /* 1 */
834 int flags; /* 1 */ 834 int flags; /* 1 */
835 int rsize; /* 1 */ 835 int rsize; /* 1 */
836 int wsize; /* 1 */ 836 int wsize; /* 1 */
837 int timeo; /* 1 */ 837 int timeo; /* 1 */
838 int retrans; /* 1 */ 838 int retrans; /* 1 */
839 int acregmin; /* 1 */ 839 int acregmin; /* 1 */
840 int acregmax; /* 1 */ 840 int acregmax; /* 1 */
841 int acdirmin; /* 1 */ 841 int acdirmin; /* 1 */
842 int acdirmax; /* 1 */ 842 int acdirmax; /* 1 */
843 struct sockaddr_in addr; /* 1 */ 843 struct sockaddr_in addr; /* 1 */
844 char hostname[256]; /* 1 */ 844 char hostname[256]; /* 1 */
845 int namlen; /* 2 */ 845 int namlen; /* 2 */
846 unsigned int bsize; /* 3 */ 846 unsigned int bsize; /* 3 */
847 struct nfs3_fh root; /* 4 */ 847 struct nfs3_fh root; /* 4 */
848}; 848};
849 849
850/* bits in the flags field */ 850/* bits in the flags field */
@@ -859,6 +859,7 @@ enum {
859 NFS_MOUNT_VER3 = 0x0080, /* 3 */ 859 NFS_MOUNT_VER3 = 0x0080, /* 3 */
860 NFS_MOUNT_KERBEROS = 0x0100, /* 3 */ 860 NFS_MOUNT_KERBEROS = 0x0100, /* 3 */
861 NFS_MOUNT_NONLM = 0x0200, /* 3 */ 861 NFS_MOUNT_NONLM = 0x0200, /* 3 */
862 NFS_MOUNT_NOACL = 0x0800, /* 4 */
862 NFS_MOUNT_NORDIRPLUS = 0x4000 863 NFS_MOUNT_NORDIRPLUS = 0x4000
863}; 864};
864 865
@@ -1123,6 +1124,7 @@ static NOINLINE int nfsmount(struct mntent *mp, long vfsflags, char *filteropts)
1123 int noac; 1124 int noac;
1124 int nordirplus; 1125 int nordirplus;
1125 int nolock; 1126 int nolock;
1127 int noacl;
1126 1128
1127 find_kernel_nfs_mount_version(); 1129 find_kernel_nfs_mount_version();
1128 1130
@@ -1142,7 +1144,7 @@ static NOINLINE int nfsmount(struct mntent *mp, long vfsflags, char *filteropts)
1142 pathname = s + 1; 1144 pathname = s + 1;
1143 *s = '\0'; 1145 *s = '\0';
1144 /* Ignore all but first hostname in replicated mounts 1146 /* Ignore all but first hostname in replicated mounts
1145 until they can be fully supported. (mack@sgi.com) */ 1147 * until they can be fully supported. (mack@sgi.com) */
1146 s = strchr(hostname, ','); 1148 s = strchr(hostname, ',');
1147 if (s) { 1149 if (s) {
1148 *s = '\0'; 1150 *s = '\0';
@@ -1195,6 +1197,7 @@ static NOINLINE int nfsmount(struct mntent *mp, long vfsflags, char *filteropts)
1195 nolock = 0; 1197 nolock = 0;
1196 noac = 0; 1198 noac = 0;
1197 nordirplus = 0; 1199 nordirplus = 0;
1200 noacl = 0;
1198 retry = 10000; /* 10000 minutes ~ 1 week */ 1201 retry = 10000; /* 10000 minutes ~ 1 week */
1199 tcp = 1; /* nfs-utils uses tcp per default */ 1202 tcp = 1; /* nfs-utils uses tcp per default */
1200 1203
@@ -1333,7 +1336,8 @@ static NOINLINE int nfsmount(struct mntent *mp, long vfsflags, char *filteropts)
1333 "tcp\0" 1336 "tcp\0"
1334 "udp\0" 1337 "udp\0"
1335 "lock\0" 1338 "lock\0"
1336 "rdirplus\0"; 1339 "rdirplus\0"
1340 "acl\0";
1337 int val = 1; 1341 int val = 1;
1338 if (!strncmp(opt, "no", 2)) { 1342 if (!strncmp(opt, "no", 2)) {
1339 val = 0; 1343 val = 0;
@@ -1383,6 +1387,9 @@ static NOINLINE int nfsmount(struct mntent *mp, long vfsflags, char *filteropts)
1383 case 11: //rdirplus 1387 case 11: //rdirplus
1384 nordirplus = !val; 1388 nordirplus = !val;
1385 break; 1389 break;
1390 case 12: // acl
1391 noacl = !val;
1392 break;
1386 default: 1393 default:
1387 bb_error_msg("unknown nfs mount option: %s%s", val ? "" : "no", opt); 1394 bb_error_msg("unknown nfs mount option: %s%s", val ? "" : "no", opt);
1388 goto fail; 1395 goto fail;
@@ -1396,7 +1403,8 @@ static NOINLINE int nfsmount(struct mntent *mp, long vfsflags, char *filteropts)
1396 | (posix ? NFS_MOUNT_POSIX : 0) 1403 | (posix ? NFS_MOUNT_POSIX : 0)
1397 | (nocto ? NFS_MOUNT_NOCTO : 0) 1404 | (nocto ? NFS_MOUNT_NOCTO : 0)
1398 | (noac ? NFS_MOUNT_NOAC : 0) 1405 | (noac ? NFS_MOUNT_NOAC : 0)
1399 | (nordirplus ? NFS_MOUNT_NORDIRPLUS : 0); 1406 | (nordirplus ? NFS_MOUNT_NORDIRPLUS : 0)
1407 | (noacl ? NFS_MOUNT_NOACL : 0);
1400 if (nfs_mount_version >= 2) 1408 if (nfs_mount_version >= 2)
1401 data.flags |= (tcp ? NFS_MOUNT_TCP : 0); 1409 data.flags |= (tcp ? NFS_MOUNT_TCP : 0);
1402 if (nfs_mount_version >= 3) 1410 if (nfs_mount_version >= 3)
@@ -1675,7 +1683,6 @@ static NOINLINE int nfsmount(struct mntent *mp, long vfsflags, char *filteropts)
1675 1683
1676 /* Perform actual mount */ 1684 /* Perform actual mount */
1677 do_mount: 1685 do_mount:
1678 mp->mnt_type = (char*)"nfs";
1679 retval = mount_it_now(mp, vfsflags, (char*)&data); 1686 retval = mount_it_now(mp, vfsflags, (char*)&data);
1680 goto ret; 1687 goto ret;
1681 1688
@@ -1700,8 +1707,43 @@ static NOINLINE int nfsmount(struct mntent *mp, long vfsflags, char *filteropts)
1700 1707
1701#else // !ENABLE_FEATURE_MOUNT_NFS 1708#else // !ENABLE_FEATURE_MOUNT_NFS
1702 1709
1703// Never called. Call should be optimized out. 1710/* Linux 2.6.23+ supports nfs mounts with options passed as a string.
1704int nfsmount(struct mntent *mp, long vfsflags, char *filteropts); 1711 * For older kernels, you must build busybox with ENABLE_FEATURE_MOUNT_NFS.
1712 * (However, note that then you lose any chances that NFS over IPv6 would work).
1713 */
1714static int nfsmount(struct mntent *mp, long vfsflags, char *filteropts)
1715{
1716 len_and_sockaddr *lsa;
1717 char *opts;
1718 char *end;
1719 char *dotted;
1720 int ret;
1721
1722# if ENABLE_FEATURE_IPV6
1723 end = strchr(mp->mnt_fsname, ']');
1724 if (end && end[1] == ':')
1725 end++;
1726 else
1727# endif
1728 /* mount_main() guarantees that ':' is there */
1729 end = strchr(mp->mnt_fsname, ':');
1730
1731 *end = '\0';
1732 lsa = xhost2sockaddr(mp->mnt_fsname, /*port:*/ 0);
1733 *end = ':';
1734 dotted = xmalloc_sockaddr2dotted_noport(&lsa->u.sa);
1735 if (ENABLE_FEATURE_CLEAN_UP) free(lsa);
1736 opts = xasprintf("%s%saddr=%s",
1737 filteropts ? filteropts : "",
1738 filteropts ? "," : "",
1739 dotted
1740 );
1741 if (ENABLE_FEATURE_CLEAN_UP) free(dotted);
1742 ret = mount_it_now(mp, vfsflags, opts);
1743 if (ENABLE_FEATURE_CLEAN_UP) free(opts);
1744
1745 return ret;
1746}
1705 1747
1706#endif // !ENABLE_FEATURE_MOUNT_NFS 1748#endif // !ENABLE_FEATURE_MOUNT_NFS
1707 1749
@@ -1792,10 +1834,11 @@ static int singlemount(struct mntent *mp, int ignore_busy)
1792 } 1834 }
1793 1835
1794 // Might this be an NFS filesystem? 1836 // Might this be an NFS filesystem?
1795 if (ENABLE_FEATURE_MOUNT_NFS 1837 if ((!mp->mnt_type || strncmp(mp->mnt_type, "nfs", 3) == 0)
1796 && (!mp->mnt_type || strcmp(mp->mnt_type, "nfs") == 0)
1797 && strchr(mp->mnt_fsname, ':') != NULL 1838 && strchr(mp->mnt_fsname, ':') != NULL
1798 ) { 1839 ) {
1840 if (!mp->mnt_type)
1841 mp->mnt_type = (char*)"nfs";
1799 rc = nfsmount(mp, vfsflags, filteropts); 1842 rc = nfsmount(mp, vfsflags, filteropts);
1800 goto report_error; 1843 goto report_error;
1801 } 1844 }