⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 loader.c~

📁 linux 安装程序
💻 C~
📖 第 1 页 / 共 5 页
字号:
                    if (strcmp((char *) &(netDev.dev.ip), "")) {                        ret = (char *) inet_ntop(AF_INET6,                                                 IP_ADDR(&(netDev.dev.ip)), ret,                                                 IP_STRLEN(&(netDev.dev.ip)));                    } else {                        ret = NULL;                        netDev.isDynamic = 1;                    }                    if (netDev.isDynamic || ret == NULL) {                        loaderData->ipv6 = strdup("dhcpv6");                    } else {                        loaderData->ipv6 = strdup(ret);                    }                }                loaderData->ipv6info_set = 1;            }            free(ret);            ret = NULL;            if ((rc == LOADER_BACK) || (rc == LOADER_ERROR) ||                ((dir == -1) && (rc == LOADER_NOOP))) {                step = STEP_IFACE;                dir = -1;                break;            }            writeNetInfo("/tmp/netinfo", &netDev);            step = STEP_URL;            dir = 1;            break;        case STEP_URL:            logMessage(INFO, "starting to STEP_URL");            /* if we found a CD already short circuit out */            /* we get this case when we're doing a VNC install from CD */            /* and we didnt short circuit earlier because we had to */            /* prompt for network info for vnc to work */            if (url && rhcdfnd)                return url;            url = installMethods[validMethods[methodNum]].mountImage(                                      installMethods + validMethods[methodNum],                                      location, loaderData, modInfo, modLoaded,                                       modDepsPtr);            if (!url) {                step = STEP_IP ;                dir = -1;            } else {                logMessage(INFO, "got url %s", url);                step = STEP_DONE;                dir = 1;            }            break;        default:            break;        }    }    return url;}static int manualDeviceCheck(moduleInfoSet modInfo, moduleList modLoaded,                             moduleDeps * modDepsPtr) {    char ** devices;    int i, j, rc, num = 0;    struct moduleInfo * mi;    unsigned int width = 40;    char * buf;    do {        devices = malloc((modLoaded->numModules + 1) * sizeof(*devices));        for (i = 0, j = 0; i < modLoaded->numModules; i++) {            if (!modLoaded->mods[i].weLoaded) continue;                        if (!(mi = findModuleInfo(modInfo, modLoaded->mods[i].name)) ||                (!mi->description))                continue;            devices[j] = sdupprintf("%s (%s)", mi->description,                                     modLoaded->mods[i].name);            if (strlen(devices[j]) > width)                width = strlen(devices[j]);            j++;        }        devices[j] = NULL;        if (width > 70)            width = 70;        if (j > 0) {            buf = _("The following devices have been found on your system.");        } else {            buf = _("No device drivers have been loaded for your system.  "                    "Would you like to load any now?");        }        rc = newtWinMenu(_("Devices"), buf, width, 10, 20,                          (j > 6) ? 6 : j, devices, &num, _("Done"),                          _("Add Device"), NULL);        /* no leaky */        for (i = 0; i < j; i++)             free(devices[j]);        free(devices);        if (rc != 2)            break;        chooseManualDriver(CLASS_UNSPEC, modLoaded, modDepsPtr, modInfo);    } while (1);    return 0;}/* JKFIXME: I don't really like this, but at least it isolates the ifdefs *//* Either move dirname to %s_old or unlink depending on arch (unlink on all * !s390{,x} arches).  symlink to /mnt/runtime/dirname.  dirname *MUST* start * with a '/' */static void migrate_runtime_directory(char * dirname) {    char * runtimedir;    int ret;    runtimedir = sdupprintf("/mnt/runtime%s", dirname);    if (!access(runtimedir, X_OK)) {#if !defined(__s390__) && !defined(__s390x__)        unlink(dirname);#else        char * olddir;        olddir = sdupprintf("%s_old", dirname);        rename(dirname, olddir);        free(olddir);#endif        ret = symlink(runtimedir, dirname);    }    free(runtimedir);}static int hasGraphicalOverride() {    int i;    if (getenv("DISPLAY"))        return 1;    for (i = 0; extraArgs[i] != NULL; i++) {        if (!strncasecmp(extraArgs[i], "--vnc", 5))            return 1;    }    return 0;}static void loaderSegvHandler(int signum) {    void *array[10];    size_t size;    char **strings;    size_t i, j;    const char const * const errmsg = "loader received SIGSEGV!  Backtrace:\n";    signal(signum, SIG_DFL); /* back to default */    newtFinished();    size = backtrace (array, 10);    strings = backtrace_symbols (array, size);    j = write(STDERR_FILENO, errmsg, strlen(errmsg));    for (i = 0; i < size; i++) {        j = write(STDERR_FILENO, strings[i], strlen(strings[i]));        j = write(STDERR_FILENO, "\n", 1);    }     free (strings);    exit(1);}static int anaconda_trace_init(void) {#if 0    int fd;#endif#ifdef USE_MTRACE    setenv("MALLOC_TRACE","/malloc",1);    mtrace();#endif    /* We have to do this before we init bogl(), which doLoaderMain will do     * when setting fonts for different languages.  It's also best if this     * is well before we might take a SEGV, so they'll go to tty8 */    initializeTtys();#if 0    fd = open("/dev/tty8", O_RDWR);    close(STDERR_FILENO);    dup2(fd, STDERR_FILENO);    close(fd);#endif    /* set up signal handler */    signal(SIGSEGV, loaderSegvHandler);    signal(SIGABRT, loaderSegvHandler);    return 0;}#ifdef NASH_FIRMWARE_LOADERint nashHotplugLogger(nashContext *nc, const nash_log_level level,        const char *fmt, va_list ap) {    int loglevel;    va_list apc;        switch (level) {        case NASH_DEBUG:            loglevel = DEBUGLVL;            break;        case NASH_WARNING:            loglevel = WARNING;            break;        case NASH_ERROR:            loglevel = ERROR;            break;        default:        case NASH_NOTICE:            loglevel = INFO;            break;    }    va_copy(ap, apc);    logMessageV(loglevel, fmt, apc);    va_end(apc);    return 0;}#endifint main(int argc, char ** argv) {    /* Very first thing, set up tracebacks and debug features. */    int rc;    struct stat sb;    struct serial_struct si;    int i;    char * arg;    FILE *f;    char twelve = 12;    moduleInfoSet modInfo;    moduleList modLoaded;    moduleDeps modDeps;    char *url = NULL;    char ** argptr, ** tmparg;    char * anacondaArgs[50];    int useRHupdates = 0;    struct loaderData_s loaderData;    char * cmdLine = NULL;    char * ksFile = NULL;    int testing = 0;    int mediacheck = 0;    char * virtpcon = NULL;    poptContext optCon;    struct poptOption optionTable[] = {        { "cmdline", '\0', POPT_ARG_STRING, &cmdLine, 0, NULL, NULL },        { "ksfile", '\0', POPT_ARG_STRING, &ksFile, 0, NULL, NULL },        { "test", '\0', POPT_ARG_NONE, &testing, 0, NULL, NULL },        { "mediacheck", '\0', POPT_ARG_NONE, &mediacheck, 0, NULL, NULL},        { "virtpconsole", '\0', POPT_ARG_STRING, &virtpcon, 0, NULL, NULL },        { 0, 0, 0, 0, 0, 0, 0 }    };#ifdef NASH_FIRMWARE_LOADER    nashContext *nc = nashNewContext();#endif    /* Make sure sort order is right. */    setenv ("LC_COLLATE", "C", 1);	    if (!strcmp(argv[0] + strlen(argv[0]) - 6, "insmod"))        return ourInsmodCommand(argc, argv);    if (!strcmp(argv[0] + strlen(argv[0]) - 8, "modprobe"))        return ourInsmodCommand(argc, argv);    if (!strcmp(argv[0] + strlen(argv[0]) - 5, "rmmod"))        return ourRmmodCommand(argc, argv);    rc = anaconda_trace_init();#ifdef NASH_FIRMWARE_LOADER    nashSetFirmwarePath(nc, "/firmware/:/lib/firmware/:/tmp/updates/firmware/:/tmp/product/firmware");    nashSetLogger(nc, nashHotplugLogger);#endif    /* now we parse command line options */    optCon = poptGetContext(NULL, argc, (const char **) argv, optionTable, 0);    if ((rc = poptGetNextOpt(optCon)) < -1) {        fprintf(stderr, "bad option %s: %s\n",                poptBadOption(optCon, POPT_BADOPTION_NOALIAS),                 poptStrerror(rc));        exit(1);    }    if ((arg = (char *) poptGetArg(optCon))) {        fprintf(stderr, "unexpected argument: %s\n", arg);        exit(1);    }    if (!testing && !access("/var/run/loader.run", R_OK)) {        printf(_("loader has already been run.  Starting shell.\n"));        execl("/bin/sh", "-/bin/sh", NULL);        exit(0);    }        f = fopen("/var/run/loader.run", "w+");    fprintf(f, "%d\n", getpid());    fclose(f);#ifdef NASH_FIRMWARE_LOADER    nashHotplugInit(nc);#endif    /* The fstat checks disallows serial console if we're running through       a pty. This is handy for Japanese. */    fstat(0, &sb);    if (major(sb.st_rdev) != 3 && major(sb.st_rdev) != 136 &&         (virtpcon == NULL)){        if ((ioctl (0, TIOCLINUX, &twelve) < 0) &&             (ioctl(0, TIOCGSERIAL, &si) != -1))            flags |= LOADER_FLAGS_SERIAL;    }    if (testing) flags |= LOADER_FLAGS_TESTING;    if (mediacheck) flags |= LOADER_FLAGS_MEDIACHECK;    if (ksFile) flags |= LOADER_FLAGS_KICKSTART;    if (virtpcon) flags |= LOADER_FLAGS_VIRTPCONSOLE;    /* uncomment to send mac address in ks=http:/ header by default*/    flags |= LOADER_FLAGS_KICKSTART_SEND_MAC;    /* JKFIXME: I do NOT like this... it also looks kind of bogus */#if defined(__s390__) && !defined(__s390x__)    flags |= LOADER_FLAGS_NOSHELL | LOADER_FLAGS_NOUSB;#endif    openLog(FL_TESTING(flags));    if (!FL_TESTING(flags))        openlog("loader", 0, LOG_LOCAL0);    memset(&loaderData, 0, sizeof(loaderData));    loaderData.method = -1;    extraArgs[0] = NULL;    parseCmdLineFlags(&loaderData, cmdLine);    if ((FL_SERIAL(flags) || FL_VIRTPCONSOLE(flags)) &&         !hasGraphicalOverride()) {        logMessage(INFO, "text mode forced due to serial/virtpconsole");        flags |= LOADER_FLAGS_TEXT;    }    if (FL_SERIAL(flags))        flags |= LOADER_FLAGS_NOFB;    setupRamfs();    arg = FL_TESTING(flags) ? "./module-info" : "/modules/module-info";    modInfo = newModuleInfoSet();    if (readModuleInfo(arg, modInfo, NULL, 0)) {        fprintf(stderr, "failed to read %s\n", arg);        sleep(5);#ifdef NASH_FIRMWARE_LOADER        nashHotplugKill(nc);#endif        exit(1);    }    mlReadLoadedList(&modLoaded);    modDeps = mlNewDeps();    mlLoadDeps(&modDeps, "/modules/modules.dep");    initializeConsole(modLoaded, modDeps, modInfo);    checkForRam();    /* iSeries vio console users will be telnetting in to the primary       partition, so use a terminal type that is appripriate */    if (isVioConsole())        setenv("TERM", "vt100", 1);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -