--- loader/method.c | 71 ------------------- loader/method.h | 2 - loader/nfsinstall.c | 193 --------------------------------------------------- loader/nfsinstall.h | 7 -- 4 files changed, 0 insertions(+), 273 deletions(-) diff --git a/loader/method.c b/loader/method.c index 5e1b4da..273649b 100644 --- a/loader/method.c +++ b/loader/method.c @@ -59,15 +59,6 @@ /* boot flags */ extern uint64_t flags; -static void stripTrailingSlash(char *path) { - size_t len = strlen(path); - - if (len == 0) - return; - if (path[len-1] == '/') - path[len-1] = '\0'; -} - /* returns the *absolute* path (malloced) to the #1 iso image */ /* get timestamp and description of ISO image from stamp file */ /* returns 0 on success, -1 otherwise */ @@ -444,65 +435,3 @@ int getFileFromBlockDevice(char *device, char *path, char * dest) { unlink("/tmp/mnt"); return rc; } - -void setStage2LocFromCmdline(char * arg, struct loaderData_s * ld) { - logMessage(INFO, "Setting stage2 from %s", arg); - - if (!strncmp(arg, "nfs:", 4)) { - ld->method = METHOD_NFS; - ld->stage2Data = calloc(sizeof(struct nfsInstallData), 1); - - parseNfsHostPathOpts(arg + 4, - &(((struct nfsInstallData *)ld->stage2Data)->host), - &(((struct nfsInstallData *)ld->stage2Data)->directory), - &(((struct nfsInstallData *)ld->stage2Data)->mountOpts)); - stripTrailingSlash(((struct nfsInstallData *)ld->stage2Data)->directory); - - logMessage(INFO, "method nfs - %s | %s | %s", - (((struct nfsInstallData *)ld->stage2Data)->host), - (((struct nfsInstallData *)ld->stage2Data)->directory), - (((struct nfsInstallData *)ld->stage2Data)->mountOpts) - ); - } else if (!strncmp(arg, "nfsiso:", 7)) { - ld->method = METHOD_NFS; - ld->stage2Data = calloc(sizeof(struct nfsInstallData), 1); - - parseNfsHostPathOpts(arg + 7, - &(((struct nfsInstallData *)ld->stage2Data)->host), - &(((struct nfsInstallData *)ld->stage2Data)->directory), - &(((struct nfsInstallData *)ld->stage2Data)->mountOpts)); - - logMessage(INFO, "method nfsiso - %s | %s | %s", - (((struct nfsInstallData *)ld->stage2Data)->host), - (((struct nfsInstallData *)ld->stage2Data)->directory), - (((struct nfsInstallData *)ld->stage2Data)->mountOpts) - ); - } else if (!strncmp(arg, "cdrom:", 6)) { - ld->method = METHOD_CDROM; - - logMessage(INFO, "method cdrom"); - } else if (!strncmp(arg, "harddrive:", 10) || - !strncmp(arg, "hd:", 3)) { - size_t offset; - - arg += strcspn(arg, ":"); - if (!*arg || !*(arg+1)) - return; - arg += 1; - offset = strcspn(arg, ":"); - - ld->method = METHOD_HD; - ld->stage2Data = calloc(sizeof(struct hdInstallData), 1); - ((struct hdInstallData *)ld->stage2Data)->partition = strndup(arg, offset); - arg += offset; - if (*arg && *(arg+1)) - ((struct hdInstallData *)ld->stage2Data)->directory = strdup(arg+1); - else - ((struct hdInstallData *)ld->stage2Data)->directory = NULL; - - logMessage(INFO, "method hd - %s | %s", - ((struct hdInstallData *)ld->stage2Data)->partition, - ((struct hdInstallData *)ld->stage2Data)->directory - ); - } -} diff --git a/loader/method.h b/loader/method.h index 9d71ec3..7918fe1 100644 --- a/loader/method.h +++ b/loader/method.h @@ -50,6 +50,4 @@ int unpackCpioBall(char * ballPath, char * rootDir); void copyUpdatesImg(char * path); void copyProductImg(char * path); -void setStage2LocFromCmdline(char * arg, struct loaderData_s * ld); - #endif diff --git a/loader/nfsinstall.c b/loader/nfsinstall.c index dad5663..1d22909 100644 --- a/loader/nfsinstall.c +++ b/loader/nfsinstall.c @@ -58,30 +58,6 @@ /* boot flags */ extern uint64_t flags; -/** - * Test whether the mounted stage2 path is an uncompreseed image, not a squashfs. - * - * Asusme path is readable. - */ -static int isNfsMountDirect(const char * path) { - struct stat stat_info; - if (stat(path, &stat_info)) - return 0; - - if (!S_ISDIR(stat_info.st_mode)) - /* if it's not a directory, then it's not an uncompressed image */ - return 0; - - char * buildstamp; - checked_asprintf(&buildstamp, "%s/%s", path, ".buildstamp"); - if (access(buildstamp, F_OK)) - /* if it doesn't contain buildstamp, then it's not an uncompressed image */ - return 0; - free(buildstamp); - - return 1; -} - static int nfsGetSetup(char ** hostptr, char ** dirptr, char ** optsptr) { struct newtWinEntry entries[4]; char * buf; @@ -276,177 +252,8 @@ int loadNfsImages(struct loaderData_s *loaderData) { return 1; } -char * mountNfsImage(struct installMethod * method, - char * location, struct loaderData_s * loaderData) { - char * host = NULL; - char * directory = NULL; - char * mountOpts = NULL; - char * fullPath = NULL; - char * url = NULL; - - enum { NFS_STAGE_NFS, NFS_STAGE_MOUNT, NFS_STAGE_DONE } stage = NFS_STAGE_NFS; - - int rc; - - /* JKFIXME: ASSERT -- we have a network device setup when we get here */ - while (stage != NFS_STAGE_DONE) { - switch (stage) { - case NFS_STAGE_NFS: - if (loaderData->method == METHOD_NFS && loaderData->stage2Data) { - host = ((struct nfsInstallData *)loaderData->stage2Data)->host; - directory = ((struct nfsInstallData *)loaderData->stage2Data)->directory; - - if (((struct nfsInstallData *) - loaderData->stage2Data)->mountOpts == NULL) { - mountOpts = strdup("ro"); - } else { - checked_asprintf(&mountOpts, "ro,%s", - ((struct nfsInstallData *) - loaderData->stage2Data)->mountOpts); - } - - logMessage(INFO, "host is %s, dir is %s, opts are '%s'", host, directory, mountOpts); - - if (!host || !directory) { - logMessage(ERROR, "missing host or directory specification"); - - if (loaderData->inferredStage2) - loaderData->invalidRepoParam = 1; - - loaderData->method = -1; - break; - } else { - host = strdup(host); - directory = strdup(directory); - } - } else { - char *colonopts, *substr, *tmp; - - logMessage(INFO, "going to do nfsGetSetup"); - if (nfsGetSetup(&host, &directory, &mountOpts) == LOADER_BACK) { - loaderData->stage2Data = NULL; - return NULL; - } - - /* If the user-provided URL points at a repo instead of a - * stage2 image, fix that up now. - */ - substr = strstr(directory, ".img"); - if (!substr || (substr && *(substr+4) != '\0')) { - if (mountOpts && strlen(mountOpts)) { - checked_asprintf(&colonopts, ":%s", mountOpts); - } else { - colonopts = strdup(""); - } - - checked_asprintf(&(loaderData->instRepo), "nfs%s:%s:%s", - colonopts, host, directory); - checked_asprintf(&tmp, "nfs%s:%s:%s/images/install.img", - colonopts, host, directory); - - setStage2LocFromCmdline(tmp, loaderData); - free(host); - free(directory); - free(mountOpts); - free(colonopts); - free(tmp); - continue; - } - - loaderData->invalidRepoParam = 1; - } - - stage = NFS_STAGE_MOUNT; - break; - - case NFS_STAGE_MOUNT: { - char *buf; - - checked_asprintf(&fullPath, "%s:%.*s", host, - (int) (strrchr(directory, '/')-directory), - directory); - logMessage(INFO, "mounting nfs path %s", fullPath); - - stage = NFS_STAGE_NFS; - - if (!doPwMount(fullPath, "/mnt/stage2", "nfs", mountOpts, NULL)) { - checked_asprintf(&buf, "/mnt/stage2/%s", - strrchr(directory, '/') + 1); - - if (!access(buf, R_OK)) { - logMessage(INFO, "can access %s", buf); - if (isNfsMountDirect(buf)) { - logMessage(INFO, "using uncompressed stage2 image"); - rc = mountStage2Direct(buf); - } else { - rc = mountStage2(buf); - } - - if (rc == 0) { - stage = NFS_STAGE_DONE; - checked_asprintf(&url, "nfs:%s:%s", host, - directory); - free(buf); - break; - } else { - logMessage(WARNING, "unable to mount %s", buf); - free(buf); - break; - } - } else { - logMessage(WARNING, "unable to access %s", buf); - free(buf); - umount("/mnt/stage2"); - } - } else { - newtWinMessage(_("Error"), _("OK"), - _("That directory could not be mounted from " - "the server.")); - if (loaderData->method >= 0) - loaderData->method = -1; - - if (loaderData->inferredStage2) - loaderData->invalidRepoParam = 1; - - break; - } - - checked_asprintf(&buf, - _("That directory does not seem to " - "contain a %s installation image."), - getProductName()); - - newtWinMessage(_("Error"), _("OK"), buf); - free(buf); - - if (loaderData->method >= 0) - loaderData->method = -1; - - if (loaderData->inferredStage2) - loaderData->invalidRepoParam = 1; - - break; - } - - case NFS_STAGE_DONE: - break; - } - } - - free(host); - free(directory); - if (mountOpts) - free(mountOpts); - if (fullPath) - free(fullPath); - - return url; -} - - void setKickstartNfs(struct loaderData_s * loaderData, int argc, char ** argv) { - char *substr = NULL; gchar *host = NULL, *dir = NULL, *mountOpts = NULL; GOptionContext *optCon = g_option_context_new(NULL); GError *optErr = NULL; diff --git a/loader/nfsinstall.h b/loader/nfsinstall.h index ee3ca80..f2865ad 100644 --- a/loader/nfsinstall.h +++ b/loader/nfsinstall.h @@ -22,13 +22,6 @@ #include "method.h" -struct nfsInstallData { - char * host; - char * directory; - char * mountOpts; -}; - - void setKickstartNfs(struct loaderData_s * loaderData, int argc, char ** argv); int kickstartFromNfs(char * url, struct loaderData_s * loaderData); -- 1.7.1.1 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list