/* Return value should be free()'d */ char *get_machine_kernelpath() { FILE *f; char *tmp, *hw = NULL, c; char line[80]; f = fopen("/proc/cpuinfo", "r"); if (!f) { perror("/proc/cpuinfo"); exit(-1); } /* Search string 'Hardware' */ while (fgets(line, sizeof(line), f)) { line[strlen(line) - 1] = '\0'; hw = strstr(line, "Hardware"); if (NULL != hw) break; } fclose(f); if ( NULL != hw) { /* Search colon then skip it and space after */ hw = strchr(hw, ':'); if (NULL == hw) { /* Should not happens but anyway */ log_msg(lg, "Can't find ':' in 'Hardware' line"); return NULL; } hw += 2; /* May be ltrim()? */ /* Lowercase name and replace spaces with '_' */ tmp = hw; while('\0' != *tmp) { c = *tmp; if (isspace(c)) { *tmp = '_'; } else { *tmp = tolower(c); } ++tmp; } /* Prepend MOUNTPOINT"/boot/zImage-" to hw */ tmp = malloc(strlen(PREPEND_MOUNTPATH("/boot/zImage-")) + strlen(hw) + 1); if (NULL == tmp) { DPRINTF("Can't allocate memory for machine-specific kernel path"); return NULL; } strcpy(tmp, PREPEND_MOUNTPATH("/boot/zImage-")); strcat(tmp, hw); return tmp; } log_msg(lg, "Can't find 'Hardware' line in cpuinfo"); return NULL; }
/* Don't re-create devices when executing on host */ #ifdef USE_HOST_DEBUG #undef USE_DEVICES_RECREATING #endif #define PREPEND_MOUNTPATH(string) MOUNTPOINT""string #define MAX_LOAD_ARGV_NR (12 + 1) #define MAX_EXEC_ARGV_NR (3 + 1) #define MAX_ARG_LEN 256 /* NULL-terminated array of kernel search paths * First item should be filled with machine-dependent path */ char *default_kernels[] = { #ifdef USE_ZIMAGE PREPEND_MOUNTPATH("/boot/zImage"), PREPEND_MOUNTPATH("/zImage"), #endif #ifdef USE_UIMAGE PREPEND_MOUNTPATH("/boot/uImage"), PREPEND_MOUNTPATH("/uImage"), #endif NULL }; /* Init mode flag */ int initmode = 0; /* Contexts available - menu and textview */ typedef enum { KX_CTX_MENU,