1#!/bin/sh
2
3nfsrootfs_enabled() {
4	if [ ${bootparam_root} != "/dev/nfs" ] || [ -z ${bootparam_nfsroot} ]; then
5		return 1
6	fi
7	return 0
8}
9
10nfsrootfs_run() {
11	local nfs_opts
12	local location
13	local flags
14	local server_ip
15
16	nfs_opts=""
17	if [ "${bootparam_nfsroot#*,}" != "${bootparam_nfsroot}" ]; then
18		nfs_opts="-o ${bootparam_nfsroot#*,}"
19	fi
20
21	location="${bootparam_nfsroot%%,*}"
22	if [ "${location#*:}" = "${location}" ]; then
23		# server-ip not given. Get server ip from ip option
24		server_ip=""
25		if [ "${bootparam_ip#*:}" != "${bootparam_ip}" ]; then
26			server_ip=$(echo "$bootparam_ip" | cut -d: -f2)
27		fi
28
29		if [ -z "$server_ip" ]; then
30			fatal "Server IP is not set. Update ip or nfsroot options."
31		fi
32		location=${server_ip}:${location}
33	fi
34
35	flags="-o nolock"
36	if [ -n "$bootparam_ro" ] && ! echo "$bootparam_rootflags" | grep -w -q "ro"; then
37		if [  -n "$bootparam_rootflags" ]; then
38			bootparam_rootflags="$bootparam_rootflags,"
39		fi
40		bootparam_rootflags="${bootparam_rootflags}ro"
41	fi
42	if [ -n "$bootparam_rootflags" ]; then
43		flags="$flags -o $bootparam_rootflags"
44	fi
45
46	mount -t nfs ${flags} ${nfs_opts} ${location} ${ROOTFS_DIR}
47}
48
49