Sfoglia il codice sorgente

[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 14 anni fa
parent
commit
ef9d1a32c6
1 ha cambiato i file con 10 aggiunte e 1 eliminazioni
  1. 10
    1
      src/core/settings.c

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

@@ -328,11 +328,20 @@ parse_settings_name ( const char *name,
328 328
 
329 329
 	/* Parse each name component in turn */
330 330
 	while ( remainder ) {
331
+		struct net_device *netdev;
332
+
331 333
 		subname = remainder;
332 334
 		remainder = strchr ( subname, '.' );
333 335
 		if ( remainder )
334 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 345
 		if ( ! settings )
337 346
 			break;
338 347
 	}

Loading…
Annulla
Salva