Browse Source

[settings] Add automagic "netX" settings block for last opened netdev

A script loaded via autoboot may want to get some of the settings (MAC
address, IP address, et cetera) for the interface via which it was
loaded, in order to pass them to the operating system. Previously such
a script had no way to determine what to put in the X of ${netX/foo}.

Solve this problem by transparently forwarding accesses to the real
settings associated with the most recently opened network device,
so scripts in this situation can say literally ${netX/foo} and get
the foo setting they want.

Signed-off-by: Marty Connor <mdc@etherboot.org>
tags/v1.0.0-rc1
Joshua Oreman 15 years ago
parent
commit
ef9d1a32c6
1 changed files with 10 additions and 1 deletions
  1. 10
    1
      src/core/settings.c

+ 10
- 1
src/core/settings.c View File

328
 
328
 
329
 	/* Parse each name component in turn */
329
 	/* Parse each name component in turn */
330
 	while ( remainder ) {
330
 	while ( remainder ) {
331
+		struct net_device *netdev;
332
+
331
 		subname = remainder;
333
 		subname = remainder;
332
 		remainder = strchr ( subname, '.' );
334
 		remainder = strchr ( subname, '.' );
333
 		if ( remainder )
335
 		if ( remainder )
334
 			*(remainder++) = '\0';
336
 			*(remainder++) = '\0';
335
-		settings = get_child ( settings, subname );
337
+
338
+		/* Special case "netX" root settings block */
339
+		if ( ( subname == name_copy ) && ! strcmp ( subname, "netX" ) &&
340
+		     ( ( netdev = last_opened_netdev() ) != NULL ) )
341
+			settings = get_child ( settings, netdev->name );
342
+		else
343
+			settings = get_child ( settings, subname );
344
+
336
 		if ( ! settings )
345
 		if ( ! settings )
337
 			break;
346
 			break;
338
 	}
347
 	}

Loading…
Cancel
Save