summaryrefslogtreecommitdiff
path: root/packages/busybox/busybox-1.13.2/udhcpc-fix-nfsroot.patch
blob: 39716ec14b7e82075b238a0e79f034c620fbaaab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
diff -uNr busybox-1.13.2-orig/examples/udhcp/simple.script busybox-1.13.2/examples/udhcp/simple.script
--- busybox-1.13.2-orig/examples/udhcp/simple.script	2009-02-04 11:08:13.000000000 -0500
+++ busybox-1.13.2/examples/udhcp/simple.script	2009-02-04 11:24:51.000000000 -0500
@@ -8,22 +8,31 @@
 [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
 [ -n "$subnet" ] && NETMASK="netmask $subnet"
 
+# return 0 if root is mounted on a network filesystem
+root_is_nfs() {
+	grep -qe '^/dev/root.*\(nfs\|smbfs\|ncp\|coda\) .*' /proc/mounts
+}
+
 case "$1" in
 	deconfig)
-		/sbin/ifconfig $interface 0.0.0.0
+		if ! root_is_nfs ; then
+			/sbin/ifconfig $interface 0.0.0.0
+		fi
 		;;
 
 	renew|bound)
 		/sbin/ifconfig $interface $ip $BROADCAST $NETMASK
 
 		if [ -n "$router" ] ; then
-			while route del default gw 0.0.0.0 dev $interface 2>/dev/null ; do
-				:
-			done
+			if ! root_is_nfs ; then
+				while route del default gw 0.0.0.0 dev $interface 2>/dev/null ; do
+					:
+				done
+			fi
 
 			metric=0
 			for i in $router ; do
-				route add default gw $i dev $interface metric $((metric++))
+				route add default gw $i dev $interface metric $((metric++)) 2>/dev/null
 			done
 		fi