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

📄 loader.c~

📁 linux 安装程序
💻 C~
📖 第 1 页 / 共 5 页
字号:
                     !strncasecmp(argv[i], "nomount", 7) ||                     !strncasecmp(argv[i], "vnc", 3) ||                     !strncasecmp(argv[i], "vncconnect=", 11) ||                     !strncasecmp(argv[i], "headless", 8) ||                     !strncasecmp(argv[i], "usefbx", 6) ||                     !strncasecmp(argv[i], "mpath", 6) ||                     !strncasecmp(argv[i], "nompath", 8) ||                     !strncasecmp(argv[i], "dmraid", 6) ||                     !strncasecmp(argv[i], "nodmraid", 8) ||                     !strncasecmp(argv[i], "xdriver=", 8) ||                     !strncasecmp(argv[i], "vesa", 4) ||                     !strncasecmp(argv[i], "syslog=", 7)) {                 /* vnc implies graphical */                if (!strncasecmp(argv[i], "vnc", 3)) {                    logMessage(INFO, "vnc forced cmdline mode from cmdline");                    flags |= LOADER_FLAGS_GRAPHICAL;                }                if (!strncasecmp(argv[i], "vesa", 4)) {                    if (asprintf(&extraArgs[numExtraArgs],                                 "--xdriver=vesa") == -1)                        return;                    logMessage(WARNING, "\"vesa\" command line argument is deprecated.  Use \"xdriver=vesa\".");                } else {                    if (asprintf(&extraArgs[numExtraArgs],"--%s",argv[i]) == -1)                        return;                }                numExtraArgs += 1;                if (numExtraArgs > (MAX_EXTRA_ARGS - 2)) {                     logMessage(WARNING, "Too many command line arguments (max "                                "allowed is %d), rest will be dropped.",                                MAX_EXTRA_ARGS);                }            }        }    }    readNetInfo(&loaderData);    /* NULL terminates the array of extra args */    extraArgs[numExtraArgs] = NULL;    return;}#if 0/* determine if we are using a framebuffer console.  return 1 if so */static int checkFrameBuffer() {    int fd;    int rc = 0;    struct fb_fix_screeninfo fix;    if ((fd = open("/dev/fb0", O_RDONLY)) == -1) {        return 0;    }        if (ioctl(fd, FBIOGET_FSCREENINFO, &fix) >= 0) {        rc = 1;    }    close(fd);    return rc;}#endif/* make sure they have enough ram */static void checkForRam(void) {    if (totalMemory() < MIN_RAM) {        char *buf;        buf = sdupprintf(_("You do not have enough RAM to install %s "                           "on this machine."), getProductName());        startNewt();        newtWinMessage(_("Error"), _("OK"), buf);        free(buf);        stopNewt();        exit(0);    }}static int haveDeviceOfType(int type, moduleList modLoaded) {    struct device ** devices;    devices = probeDevices(type, BUS_UNSPEC, PROBE_LOADED);    if (devices) {        return 1;    }    return 0;}/* fsm for the basics of the loader. */static char *doLoaderMain(char * location,                          struct loaderData_s * loaderData,                          moduleInfoSet modInfo,                          moduleList modLoaded,                          moduleDeps * modDepsPtr) {    enum { STEP_LANG, STEP_KBD, STEP_METHOD, STEP_DRIVER,            STEP_DRIVERDISK, STEP_NETWORK, STEP_IFACE,           STEP_IP, STEP_URL, STEP_DONE } step;    char * url = NULL;    char * ret = NULL;    int dir = 1;    int rc, i;    char * installNames[10]; /* 10 install methods will be enough for anyone */    int numValidMethods = 0;    int validMethods[10];    int methodNum = -1;    int needed = -1;    int needsNetwork = 0;    int rhcdfnd = 0;    char * devName = NULL;    static struct networkDeviceConfig netDev;    char * kbdtype = NULL;    for (i = 0; i < numMethods; i++, numValidMethods++) {        installNames[numValidMethods] = installMethods[i].name;        validMethods[numValidMethods] = i;    }    installNames[numValidMethods] = NULL;    /* have we preselected this to be our install method? */    if (loaderData->method >= 0) {        methodNum = loaderData->method;        /* disable the fast path (#102652) */        flags |= LOADER_FLAGS_ASKMETHOD;    }    /* check to see if we have a CD.  If we have one, then     * we can fast-path the CD and not make people answer questions in      * text mode.  */    if (!FL_ASKMETHOD(flags) && !FL_KICKSTART(flags)) {        url = findAnacondaCD(location, modInfo, modLoaded, * modDepsPtr, !FL_RESCUE(flags));        /* if we found a CD and we're not in rescue or vnc mode return */        /* so we can short circuit straight to stage 2 from CD         */        if (url && (!FL_RESCUE(flags) && !hasGraphicalOverride()))            return url;        else {            rhcdfnd = 1;            methodNum = 0;        }    }    if (!FL_CMDLINE(flags))        startNewt();    step = STEP_LANG;    while (step != STEP_DONE) {        switch(step) {        case STEP_LANG:            if (loaderData->lang && (loaderData->lang_set == 1)) {                setLanguage(loaderData->lang);            } else {                chooseLanguage(&loaderData->lang);            }            step = STEP_KBD;            dir = 1;            break;        case STEP_KBD:            if (loaderData->kbd && (loaderData->kbd_set == 1)) {                /* JKFIXME: this is broken -- we should tell of the                  * failure; best by pulling code out in kbd.c to use */                if (isysLoadKeymap(loaderData->kbd)) {                    logMessage(WARNING, "requested keymap %s is not valid, asking", loaderData->kbd);                    loaderData->kbd = NULL;                    loaderData->kbd_set = 0;                    break;                }                rc = LOADER_NOOP;            } else {                /* JKFIXME: should handle kbdtype, too probably... but it                  * just matters for sparc */                if (!FL_CMDLINE(flags))                    rc = chooseKeyboard(loaderData, &kbdtype);                else                   rc = LOADER_NOOP;            }            if (rc == LOADER_NOOP) {                if (dir == -1)                    step = STEP_LANG;                else                    step = STEP_METHOD;                break;            }            if (rc == LOADER_BACK) {                step = STEP_LANG;                dir = -1;            } else {                step = STEP_METHOD;                dir = 1;            }            break;        case STEP_METHOD:            /* this is kind of crappy, but we want the first few questions             * to be asked when using rescue mode even if we're going             * to short-circuit to the CD.             *             * Alternately, if we're in a VNC install based from CD we             * can skip this step because we already found the CD */            if (url) {                if (FL_RESCUE(flags)) {                    return url;                } else if (rhcdfnd) {                    step = STEP_NETWORK;                    dir = 1;                    break;                }            }	                needed = -1;            if (loaderData->method != -1 && methodNum != -1) {                rc = 1;            } else {                /* we need to set these each time through so that we get                 * updated for language changes (#83672) */                for (i = 0; i < numMethods; i++) {                    installNames[i] = _(installMethods[i].name);                }                installNames[i] = NULL;                rc = newtWinMenu(FL_RESCUE(flags) ? _("Rescue Method") :                                 _("Installation Method"),                                 FL_RESCUE(flags) ?                                 _("What type of media contains the rescue "                                   "image?") :                                 _("What type of media contains the packages to "                                   "be installed?"),                                 30, 10, 20, 6, installNames, &methodNum,                                  _("OK"), _("Back"), NULL);            }             if (rc && rc != 1) {                step = STEP_KBD;                dir = -1;            } else {                needed = installMethods[validMethods[methodNum]].deviceType;                step = STEP_DRIVER;                dir = 1;            }            break;        case STEP_DRIVER: {            if (needed == -1 || haveDeviceOfType(needed, modLoaded)) {                step = STEP_NETWORK;                dir = 1;                needed = -1;                break;            }            rc = newtWinTernary(_("No driver found"), _("Select driver"),                                _("Use a driver disk"), _("Back"),                                _("Unable to find any devices of the type "                                  "needed for this installation type.  "                                  "Would you like to manually select your "                                  "driver or use a driver disk?"));            if (rc == 2) {                step = STEP_DRIVERDISK;                dir = 1;                break;            } else if (rc == 3) {                step = STEP_METHOD;                dir = -1;                break;            }                        chooseManualDriver(installMethods[validMethods[methodNum]].deviceType,                               modLoaded, modDepsPtr, modInfo);            /* it doesn't really matter what we return here; we just want             * to reprobe and make sure we have the driver */            step = STEP_DRIVER;            break;        }        case STEP_DRIVERDISK:            rc = loadDriverFromMedia(needed,                                     modLoaded, modDepsPtr, modInfo, 0, 0);            if (rc == LOADER_BACK) {                step = STEP_DRIVER;                dir = -1;                break;            }            /* need to come back to driver so that we can ensure that we found             * the right kind of driver after loading the driver disk */            step = STEP_DRIVER;            break;        case STEP_NETWORK:            if ( (installMethods[validMethods[methodNum]].deviceType !=                   CLASS_NETWORK) && (!hasGraphicalOverride()) &&                 !FL_ASKNETWORK(flags)) {                needsNetwork = 0;                if (dir == 1)                     step = STEP_URL;                else if (dir == -1)                    step = STEP_METHOD;                break;            }            needsNetwork = 1;            if (!haveDeviceOfType(CLASS_NETWORK, modLoaded)) {                needed = CLASS_NETWORK;                step = STEP_DRIVER;                break;            }            logMessage(INFO, "need to set up networking");            initLoopback();            memset(&netDev, 0, sizeof(netDev));            netDev.isDynamic = 1;            /* fall through to interface selection */        case STEP_IFACE:            logMessage(INFO, "going to pick interface");            rc = chooseNetworkInterface(loaderData);            if ((rc == LOADER_BACK) || (rc == LOADER_ERROR) ||                ((dir == -1) && (rc == LOADER_NOOP))) {                step = STEP_METHOD;                dir = -1;                break;            }            devName = loaderData->netDev;            strcpy(netDev.dev.device, devName);            /* continue to ip config */            step = STEP_IP;            dir = 1;            break;        case STEP_IP:            if (!needsNetwork) {                step = STEP_METHOD; /* only hit going back */                break;            }            if ((ret = malloc(48)) == NULL) {                logMessage(ERROR, "malloc failure for ret in STEP_IP");                exit(EXIT_FAILURE);            }            logMessage(INFO, "going to do getNetConfig");            /* populate netDev based on any kickstart data */            if (loaderData->ipinfo_set) {                netDev.preset = 1;            }            setupNetworkDeviceConfig(&netDev, loaderData);            rc = readNetConfig(devName, &netDev, loaderData->netCls, methodNum);            if ((loaderData->noipv4 = netDev.noipv4) == 1) {                loaderData->ipinfo_set = 0;            } else {                if (loaderData->ipv4 == NULL) {                    if (strcmp((char *) &(netDev.dev.ip), "")) {                        ret = (char *) inet_ntop(AF_INET,                                                 IP_ADDR(&(netDev.dev.ip)), ret,                                                 IP_STRLEN(&(netDev.dev.ip)));                    } else {                        ret = NULL;                        netDev.isDynamic = 1;                    }                    if (netDev.isDynamic || ret == NULL) {                        loaderData->ipv4 = strdup("dhcp");                    } else {                        loaderData->ipv4 = strdup(ret);                    }                }                loaderData->ipinfo_set = 1;            }            if ((loaderData->noipv6 = netDev.noipv6) == 1) {                loaderData->ipv6info_set = 0;            } else {                if (loaderData->ipv6 == NULL) {

⌨️ 快捷键说明

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