barebox/fs/parseopt.c
Uwe Kleine-König 3ea30d9ce8 nfs: parse nfsport and mount port from file system options
This allows to use unfs3 on the server side which doesn't integrate into
portmap/rpcbind which results in the port not being impossible to lookup
via rpc calls to the portmap program.

Use it like:

	mount -t nfs -o port=2703,mountport=2703 192.168.77.157:/root /mnt/nfs

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-02-10 09:02:21 +01:00

35 lines
539 B
C

#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;
}