diff options
-rw-r--r-- | fs/Makefile | 2 | ||||
-rw-r--r-- | fs/nfs.c | 32 | ||||
-rw-r--r-- | fs/parseopt.c | 34 | ||||
-rw-r--r-- | fs/parseopt.h | 1 |
4 files changed, 57 insertions, 12 deletions
diff --git a/fs/Makefile b/fs/Makefile index e8347bd670..d3465edfa5 100644 --- a/fs/Makefile +++ b/fs/Makefile @@ -8,6 +8,6 @@ obj-y += fs.o obj-$(CONFIG_FS_UBIFS) += ubifs/ obj-$(CONFIG_FS_TFTP) += tftp.o obj-$(CONFIG_FS_OMAP4_USBBOOT) += omap4_usbbootfs.o -obj-$(CONFIG_FS_NFS) += nfs.o +obj-$(CONFIG_FS_NFS) += nfs.o parseopt.o obj-$(CONFIG_FS_BPKFS) += bpkfs.o obj-$(CONFIG_FS_UIMAGEFS) += uimagefs.o @@ -36,6 +36,8 @@ #include <sizes.h> #include <byteorder.h> +#include "parseopt.h" + #define SUNRPC_PORT 111 #define PROG_PORTMAP 100000 @@ -1339,19 +1341,27 @@ static int nfs_probe(struct device_d *dev) /* Need a priviliged source port */ net_udp_bind(npriv->con, 1000); - ret = rpc_lookup_req(npriv, PROG_MOUNT, 3); - if (ret < 0) { - printf("lookup mount port failed with %d\n", ret); - goto err2; + parseopt_hu(fsdev->options, "mountport", &npriv->mount_port); + if (!npriv->mount_port) { + ret = rpc_lookup_req(npriv, PROG_MOUNT, 3); + if (ret < 0) { + printf("lookup mount port failed with %d\n", ret); + goto err2; + } + npriv->mount_port = ret; } - npriv->mount_port = ret; - - ret = rpc_lookup_req(npriv, PROG_NFS, 3); - if (ret < 0) { - printf("lookup nfs port failed with %d\n", ret); - goto err2; + debug("mount port: %hu\n", npriv->mount_port); + + parseopt_hu(fsdev->options, "port", &npriv->nfs_port); + if (!npriv->nfs_port) { + ret = rpc_lookup_req(npriv, PROG_NFS, 3); + if (ret < 0) { + printf("lookup nfs port failed with %d\n", ret); + goto err2; + } + npriv->nfs_port = ret; } - npriv->nfs_port = ret; + debug("nfs port: %d\n", npriv->nfs_port); ret = nfs_mount_req(npriv); if (ret) { diff --git a/fs/parseopt.c b/fs/parseopt.c new file mode 100644 index 0000000000..fbe53cfb02 --- /dev/null +++ b/fs/parseopt.c @@ -0,0 +1,34 @@ +#include <common.h> + +#include "parseopt.h" + +void parseopt_hu(const char *options, const char *opt, unsigned short *val) +{ + const char *start; + size_t optlen = strlen(opt); + ulong v; + char *endp; + +again: + start = strstr(options, opt); + + if (!start) + return; + + if (start > options && start[-1] != ',') { + options = start; + goto again; + } + + if (start[optlen] != '=') { + options = start; + goto again; + } + + v = simple_strtoul(start + optlen + 1, &endp, 0); + if (v > USHORT_MAX) + return; + + if (*endp == ',' || *endp == '\0') + *val = v; +} diff --git a/fs/parseopt.h b/fs/parseopt.h new file mode 100644 index 0000000000..a8523b6a10 --- /dev/null +++ b/fs/parseopt.h @@ -0,0 +1 @@ +void parseopt_hu(const char *options, const char *opt, unsigned short *val); |