diff options
author | Joshua Oreman <oremanj@rwcr.net> | 2009-10-22 00:55:08 -0400 |
---|---|---|
committer | Marty Connor <mdc@etherboot.org> | 2010-01-20 17:52:02 -0500 |
commit | ef9d1a32c6dc83d1086141c18d2be19a05ab8e49 (patch) | |
tree | 92bc6ca29a4c89c023a644ae3516a5cb96fec5ad /src | |
parent | 06a8398422efb613b7ee4f9d8f1abcc813bb3f3b (diff) | |
download | ipxe-ef9d1a32c6dc83d1086141c18d2be19a05ab8e49.zip ipxe-ef9d1a32c6dc83d1086141c18d2be19a05ab8e49.tar.gz ipxe-ef9d1a32c6dc83d1086141c18d2be19a05ab8e49.tar.bz2 |
[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>
Diffstat (limited to 'src')
-rw-r--r-- | src/core/settings.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/core/settings.c b/src/core/settings.c index 87d84a0..fe67d6b 100644 --- a/src/core/settings.c +++ b/src/core/settings.c @@ -328,11 +328,20 @@ parse_settings_name ( const char *name, /* Parse each name component in turn */ while ( remainder ) { + struct net_device *netdev; + subname = remainder; remainder = strchr ( subname, '.' ); if ( remainder ) *(remainder++) = '\0'; - settings = get_child ( settings, subname ); + + /* Special case "netX" root settings block */ + if ( ( subname == name_copy ) && ! strcmp ( subname, "netX" ) && + ( ( netdev = last_opened_netdev() ) != NULL ) ) + settings = get_child ( settings, netdev->name ); + else + settings = get_child ( settings, subname ); + if ( ! settings ) break; } |