X-Git-Url: http://git.ozlabs.org/?p=yaboot.git;a=blobdiff_plain;f=second%2Fyaboot.c;h=0232d33153b58da3c9c0fafecde8016437324f17;hp=30abbd6b181ab6a79c9d317e9d6159ae2bb7767a;hb=1bea6140c2894b1259fd07f323b25fd846bd5acf;hpb=cf0768af118d79ba4888a7fb0fcd800fdf76dc98 diff --git a/second/yaboot.c b/second/yaboot.c index 30abbd6..0232d33 100644 --- a/second/yaboot.c +++ b/second/yaboot.c @@ -368,6 +368,22 @@ load_config_file(struct boot_fspec_t *fspec) goto bail; } + /* + * set the default cf_option to label that has the same MAC addr + * it only works if there is a label with the MAC addr on yaboot.conf + */ + if (prom_get_devtype(fspec->dev) == FILE_DEVICE_NET) { + /* change the variable bellow to get the MAC dinamicaly */ + char * macaddr = NULL; + int default_mac = 0; + + macaddr = prom_get_mac(prom_get_netinfo()); + default_mac = cfg_set_default_by_mac(macaddr); + if (default_mac >= 1) { + prom_printf("Default label was changed to macaddr label.\n"); + } + } + DEBUG_F("Config file successfully parsed, %d bytes\n", sz); /* Now, we do the initialisations stored in the config file */ @@ -439,7 +455,9 @@ static int load_my_config_file(struct boot_fspec_t *orig_fspec) struct bootp_packet *packet; int rc = 0; struct boot_fspec_t fspec = *orig_fspec; -#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) + char *cfgpath = (_machine == _MACH_chrp) ? "/etc/" : ""; + int flen; + int minlen; packet = prom_get_netinfo(); @@ -453,34 +471,26 @@ static int load_my_config_file(struct boot_fspec_t *orig_fspec) if (!fspec.file) goto out; - if (_machine == _MACH_chrp) - sprintf(fspec.file, "/etc/%02x-", packet->htype); - else - sprintf(fspec.file, "%02x-", packet->htype); + sprintf(fspec.file, "%s%02x-", cfgpath, packet->htype); strcat(fspec.file, prom_get_mac(packet)); rc = load_config_file(&fspec); if (rc) goto out; - /* * Now try to match on IP. */ - free(fspec.file); - /* 8 chars in yiaddr + \0 */ - fspec.file = malloc(9); - if (!fspec.file) - goto out; - - strcat(fspec.file, prom_get_ip(packet)); + /* no need to realloc for /etc/ + 8 chars in yiaddr + \0 */ + sprintf(fspec.file, "%s%s", cfgpath, prom_get_ip(packet)); - while (strlen(fspec.file)) { + for (flen = strlen(fspec.file), + minlen = strlen(cfgpath); flen > minlen; flen--) { rc = load_config_file(&fspec); if (rc) goto out; /* Chop one digit off the end, try again */ - fspec.file[strlen(fspec.file) - 1] = '\0'; + fspec.file[flen - 1] = '\0'; } out: @@ -1580,7 +1590,7 @@ setup_display(void) } if (scrn == PROM_INVALID_HANDLE) { - prom_printf("No screen device found !/n"); + prom_printf("No screen device found !\n"); return; } for(i=0;i<16;i++) {