Gracefully handle unreadable /sys/class/net/dev/ nodes
Fixes https://bugs.gentoo.org/629228 Fixes #189 Fixes #185 Fixes #178
This commit is contained in:
		
				
					committed by
					
						
						William Hubbs
					
				
			
			
				
	
			
			
			
						parent
						
							fb96c9c127
						
					
				
				
					commit
					5c81661d47
				
			@@ -31,7 +31,7 @@ get_interfaces()
 | 
				
			|||||||
start ()
 | 
					start ()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	local carriers configured dev gateway ifcount infinite
 | 
						local carriers configured dev gateway ifcount infinite
 | 
				
			||||||
	local rc state x
 | 
						local carrier operstate rc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ebegin "Checking to see if the network is online"
 | 
						ebegin "Checking to see if the network is online"
 | 
				
			||||||
	rc=0
 | 
						rc=0
 | 
				
			||||||
@@ -44,10 +44,10 @@ start ()
 | 
				
			|||||||
	ifcount=0
 | 
						ifcount=0
 | 
				
			||||||
 	for dev in ${interfaces}; do
 | 
					 	for dev in ${interfaces}; do
 | 
				
			||||||
		: $((ifcount += 1))
 | 
							: $((ifcount += 1))
 | 
				
			||||||
		read x < /sys/class/net/$dev/carrier
 | 
							read carrier < /sys/class/net/$dev/carrier 2> /dev/null
 | 
				
			||||||
		[ $x -eq 1 ] && : $((carriers += 1))
 | 
							[ $carrier -eq 1 ] && : $((carriers += 1))
 | 
				
			||||||
		read x < /sys/class/net/$dev/operstate
 | 
							read operstate < /sys/class/net/$dev/operstate 2> /dev/null
 | 
				
			||||||
		[ "$x" = up ] && : $((configured += 1))
 | 
							[ "$operstate" = up ] && : $((configured += 1))
 | 
				
			||||||
	done
 | 
						done
 | 
				
			||||||
	[ $configured -eq $ifcount ] && [ $carriers -ge 1 ] && break
 | 
						[ $configured -eq $ifcount ] && [ $carriers -ge 1 ] && break
 | 
				
			||||||
	sleep 1
 | 
						sleep 1
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user