poky/meta/recipes-core/initrdscripts/initramfs-framework/nfsrootfs
Jimmy Ho 4333921896 nfsrootfs: disable warning message if bootargs root parameter have not been defined
we have case that don't define root in bootargs,
if [ ${bootparam_root} != "/dev/nfs" ] will output warning "/init.d/85-nfsrootfs: line 4: [: !=: unary operator expected"
let variable expension result become string to solve this problem

(From OE-Core rev: d50e12e5ae6a72535cacd0f767b1be1f89278f79)

Signed-off-by: Jimmy Ho <jimmy.ho@sifive.com>
Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2025-06-26 11:02:34 +01:00

1.1 KiB

#!/bin/sh

nfsrootfs_enabled() { if [ "${bootparam_root}" != "/dev/nfs" ] || [ -z ${bootparam_nfsroot} ]; then return 1 fi return 0 }

nfsrootfs_run() { local nfs_opts local location local flags local server_ip

nfs_opts=""
if [ "${bootparam_nfsroot#*,}" != "${bootparam_nfsroot}" ]; then
	nfs_opts="-o ${bootparam_nfsroot#*,}"
fi

location="${bootparam_nfsroot%%,*}"
if [ "${location#*:}" = "${location}" ]; then
	# server-ip not given. Get server ip from ip option
	server_ip=""
	if [ "${bootparam_ip#*:}" != "${bootparam_ip}" ]; then
		server_ip=$(echo "$bootparam_ip" | cut -d: -f2)
	fi

	if [ -z "$server_ip" ]; then
		fatal "Server IP is not set. Update ip or nfsroot options."
	fi
	location=${server_ip}:${location}
fi

flags="-o nolock"
if [ -n "$bootparam_ro" ] && ! echo "$bootparam_rootflags" | grep -w -q "ro"; then
	if [  -n "$bootparam_rootflags" ]; then
		bootparam_rootflags="$bootparam_rootflags,"
	fi
	bootparam_rootflags="${bootparam_rootflags}ro"
fi
if [ -n "$bootparam_rootflags" ]; then
	flags="$flags -o $bootparam_rootflags"
fi

mount -t nfs ${flags} ${nfs_opts} ${location} ${ROOTFS_DIR}

}