[syslinux] Using NIC-Specific Information to Choose a Config-File

Shao Miller sha0.miller at gmail.com
Thu Nov 22 19:08:18 PST 2012


On 11/22/2012 13:59, Torgeir.Wulfsberg at kongsberg.com wrote:
> Anyway I got exactly what I needed by adding this in core/fs/pxe/pxe.c
> _________________________________________________________
> static int pxe_load_config(void)
> {
> .
> .
> .
> /* Chop of, so we only get 01-00-aa-bb left */
> strncpy(stripped_mac_str, MAC_str, 11);
>
>     /* Try loading the stripped MAC address */
>     strcpy(config_file, stripped_mac_str);
>     if (try_load(ConfigName))
>         return 0;
> Actually I got an extra letter "E" on the end. So the file would have to look like this: 01-00-aa-bbE
> Does not bother me very much. But if some of you have an easier fix, I would really appreciate it.

This is because your 'strncpy' call will not copy more than 11 
characters, meaning the null terminator is not being copied. 
'config_file' thus contains your 11 characters immediately followed by 
whatever is still there from the last time 'config_file' was populated. 
  - Shao



More information about the Syslinux mailing list