mount: fix mishandling of proto=tcp/udp

function                                             old     new   delta
singlemount                                         4729    4695     -34
This commit is contained in:
Denis Vlasenko 2008-06-24 21:39:32 +00:00
parent d0cc3f4ade
commit f26e3d2e41

View File

@ -1059,6 +1059,7 @@ static int nfsmount(struct mntent *mp, long vfsflags, char *filteropts)
if (filteropts) for (opt = strtok(filteropts, ","); opt; opt = strtok(NULL, ",")) { if (filteropts) for (opt = strtok(filteropts, ","); opt; opt = strtok(NULL, ",")) {
char *opteq = strchr(opt, '='); char *opteq = strchr(opt, '=');
if (opteq) { if (opteq) {
int val, idx;
static const char options[] ALIGN1 = static const char options[] ALIGN1 =
/* 0 */ "rsize\0" /* 0 */ "rsize\0"
/* 1 */ "wsize\0" /* 1 */ "wsize\0"
@ -1081,87 +1082,92 @@ static int nfsmount(struct mntent *mp, long vfsflags, char *filteropts)
/* 18 */ "proto\0" /* 18 */ "proto\0"
/* 19 */ "namlen\0" /* 19 */ "namlen\0"
/* 20 */ "addr\0"; /* 20 */ "addr\0";
int val = xatoi_u(opteq + 1);
*opteq = '\0'; *opteq++ = '\0';
switch (index_in_strings(options, opt)) { idx = index_in_strings(options, opt);
switch (idx) {
case 12: // "mounthost"
mounthost = xstrndup(opteq,
strcspn(opteq, " \t\n\r,"));
continue;
case 18: // "proto"
if (!strncmp(opteq, "tcp", 3))
tcp = 1;
else if (!strncmp(opteq, "udp", 3))
tcp = 0;
else
bb_error_msg("warning: unrecognized proto= option");
continue;
case 20: // "addr" - ignore
continue;
}
val = xatoi_u(opteq);
switch (idx) {
case 0: // "rsize" case 0: // "rsize"
data.rsize = val; data.rsize = val;
break; continue;
case 1: // "wsize" case 1: // "wsize"
data.wsize = val; data.wsize = val;
break; continue;
case 2: // "timeo" case 2: // "timeo"
data.timeo = val; data.timeo = val;
break; continue;
case 3: // "retrans" case 3: // "retrans"
data.retrans = val; data.retrans = val;
break; continue;
case 4: // "acregmin" case 4: // "acregmin"
data.acregmin = val; data.acregmin = val;
break; continue;
case 5: // "acregmax" case 5: // "acregmax"
data.acregmax = val; data.acregmax = val;
break; continue;
case 6: // "acdirmin" case 6: // "acdirmin"
data.acdirmin = val; data.acdirmin = val;
break; continue;
case 7: // "acdirmax" case 7: // "acdirmax"
data.acdirmax = val; data.acdirmax = val;
break; continue;
case 8: // "actimeo" case 8: // "actimeo"
data.acregmin = val; data.acregmin = val;
data.acregmax = val; data.acregmax = val;
data.acdirmin = val; data.acdirmin = val;
data.acdirmax = val; data.acdirmax = val;
break; continue;
case 9: // "retry" case 9: // "retry"
retry = val; retry = val;
break; continue;
case 10: // "port" case 10: // "port"
port = val; port = val;
break; continue;
case 11: // "mountport" case 11: // "mountport"
mountport = val; mountport = val;
break; continue;
case 12: // "mounthost"
mounthost = xstrndup(opteq+1,
strcspn(opteq+1," \t\n\r,"));
break;
case 13: // "mountprog" case 13: // "mountprog"
mountprog = val; mountprog = val;
break; continue;
case 14: // "mountvers" case 14: // "mountvers"
mountvers = val; mountvers = val;
break; continue;
case 15: // "nfsprog" case 15: // "nfsprog"
nfsprog = val; nfsprog = val;
break; continue;
case 16: // "nfsvers" case 16: // "nfsvers"
case 17: // "vers" case 17: // "vers"
nfsvers = val; nfsvers = val;
break; continue;
case 18: // "proto"
if (!strncmp(opteq+1, "tcp", 3))
tcp = 1;
else if (!strncmp(opteq+1, "udp", 3))
tcp = 0;
else
bb_error_msg("warning: unrecognized proto= option");
break;
case 19: // "namlen" case 19: // "namlen"
if (nfs_mount_version >= 2) //if (nfs_mount_version >= 2)
data.namlen = val; data.namlen = val;
else //else
bb_error_msg("warning: option namlen is not supported\n"); // bb_error_msg("warning: option namlen is not supported\n");
break; continue;
case 20: // "addr" - ignore
break;
default: default:
bb_error_msg("unknown nfs mount parameter: %s=%d", opt, val); bb_error_msg("unknown nfs mount parameter: %s=%d", opt, val);
goto fail; goto fail;
} }
} }
else { else { /* not of the form opt=val */
static const char options[] ALIGN1 = static const char options[] ALIGN1 =
"bg\0" "bg\0"
"fg\0" "fg\0"