Changeset 3610 in MondoRescue for branches/3.2/mondo/src/mondorestore


Ignore:
Timestamp:
Nov 5, 2016, 6:12:23 PM (8 years ago)
Author:
Bruno Cornec
Message:
  • Change interfaces for the call_program_and_get_last_line_of_output and where_is_root_mounted(now return dynamically allocated string)
  • removes useless function store_netfs_config
Location:
branches/3.2/mondo/src/mondorestore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/mondo/src/mondorestore/mondo-prep.c

    r3570 r3610  
    154154char *tmp;
    155155char *tmp1 = NULL;
     156char *tmp2 = NULL;
    156157char *incoming;
    157158char *command;
     
    186187#endif
    187188
    188 if (strstr(call_program_and_get_last_line_of_output("cat /proc/cmdline"), "nolvm")) {
     189tmp = call_program_and_get_last_line_of_output("cat "CMDLINE);
     190if (strstr(tmp, "nolvm")) {
     191    mr_free(tmp);
    189192    return(0);
    190193}
     194mr_free(tmp);
     195
    191196if (!(fin = fopen("/tmp/i-want-my-lvm", "r"))) {
    192197    log_OS_error("/tmp/i-want-my-lvm");
     
    299304            if (lvmversion == 2) {
    300305                mr_asprintf(tmp1, "tail -n5 %s | grep Insufficient | tail -n1", MONDO_LOGFILE);
    301                 strcpy(tmp, call_program_and_get_last_line_of_output(tmp1));
    302                 free(tmp1);
    303306            } else {
    304307                mr_asprintf(tmp1, "tail -n5 %s | grep lvcreate | tail -n1", MONDO_LOGFILE);
    305                 strcpy(tmp, call_program_and_get_last_line_of_output(tmp1));
    306                 free(tmp1);
    307308            }
     309            tmp2 =  call_program_and_get_last_line_of_output(tmp1);
     310            strcpy(tmp, tmp2);
     311            mr_free(tmp2);
     312            mr_free(tmp1);
     313
    308314            for (p = tmp; *p != '\0' && !isdigit(*p); p++);
    309315            extents = atol(p);
     
    14821488    // mark relevant partition as bootable
    14831489    mr_asprintf(tmp1,"mr-make-me-bootable /tmp/mountlist.txt %s",drivename);
    1484     call_program_and_get_last_line_of_output(tmp1);
     1490    tmp = call_program_and_get_last_line_of_output(tmp1);
    14851491    mr_free(tmp1);
     1492    mr_free(tmp);
    14861493
    14871494    log_msg(0,"------------------- end of fdisk.log...       ------------------");
  • branches/3.2/mondo/src/mondorestore/mondo-rstr-tools.c

    r3601 r3610  
    695695                strcpy(bkpinfo->prefix,STD_PREFIX);
    696696        }
    697         if (strstr(call_program_and_get_last_line_of_output("cat /proc/cmdline"), "pxe")) {
     697        tmp1 = call_program_and_get_last_line_of_output("cat "CMDLINE);
     698        if (strstr(tmp1, "pxe")) {
    698699            /* We need to override prefix value in PXE mode as it's
    699700            * already done in start-netfs */
     
    704705            strcpy(bkpinfo->prefix,envtmp1);
    705706        }   
     707        mr_free(tmp1);
    706708    } else if (!strcmp(value, "tape")) {
    707709        bkpinfo->backup_media_type = tape;
     
    832834
    833835read_cfg_var(cfg_file, "please-dont-eject", value);
    834 if (value[0] || strstr(call_program_and_get_last_line_of_output("cat /proc/cmdline"), "donteject")) {
     836tmp1 = call_program_and_get_last_line_of_output("cat "CMDLINE);
     837if (value[0] || strstr(tmp1, "donteject")) {
    835838    bkpinfo->please_dont_eject = TRUE;
    836839    log_msg(2, "Ok, I shan't eject when restoring! Groovy.");
    837840}
     841mr_free(tmp1);
    838842
    839843/* TODO: Read here the boot_* variables */
     
    881885        }
    882886    }
    883     if (strstr(call_program_and_get_last_line_of_output("cat /proc/cmdline"), "pxe")) {
     887    tmp1 = call_program_and_get_last_line_of_output("cat "CMDLINE);
     888    if (strstr(tmp1, "pxe")) {
    884889        /* We need to override values in PXE mode as it's
    885890        * already done in start-netfs */
     
    898903        mr_asprintf(bkpinfo->netfs_remote_dir, "%s", envtmp2);
    899904    }
     905    mr_free(tmp1);
    900906} else if (bkpinfo->backup_media_type == iso) {
    901907    /* Patch by Conor Daly 23-june-2004
     
    932938            mr_asprintf(command, "mount | grep -E '^%s' | tail -n1 | cut -d' ' -f3", g_isodir_device);
    933939            log_it("command = %s", command);
    934             log_it("res of it = %s", call_program_and_get_last_line_of_output(command));
    935             sprintf(iso_mnt, "%s", call_program_and_get_last_line_of_output(command));
     940            tmp1 = call_program_and_get_last_line_of_output(command);
     941            log_it("res of it = %s", tmp1);
     942            sprintf(iso_mnt, "%s", tmp1);
    936943            mr_free(command);
     944            mr_free(tmp1);
    937945        } else {
    938946            sprintf(iso_mnt, "/tmp/isodir");
     
    20642072    char *cfg_file = NULL;
    20652073    char *tmp = NULL;
     2074    char *tmp1 = NULL;
    20662075    char *mountpt = NULL;
    20672076    char *mountlist_file = NULL;
     
    21772186    if (does_file_exist(MONDO_CFG_FILE_STUB)) {
    21782187        log_msg(1, "gcffa --- great! We've got the config file");
    2179         mr_asprintf(tmp, "%s/%s", call_program_and_get_last_line_of_output("pwd"), MONDO_CFG_FILE_STUB);
     2188        tmp1 = call_program_and_get_last_line_of_output("pwd");
     2189        mr_asprintf(tmp, "%s/%s", tmp1, MONDO_CFG_FILE_STUB);
    21802190        mr_asprintf(command, "cp -f %s %s", tmp, cfg_file);
    21812191        log_it("%s",command);
     
    21892199        mr_free(command);
    21902200
    2191         mr_asprintf(command, "cp -f %s/%s %s", call_program_and_get_last_line_of_output("pwd"), MOUNTLIST_FNAME_STUB, mountlist_file);
     2201        mr_asprintf(command, "cp -f %s/%s %s", tmp1, MOUNTLIST_FNAME_STUB, mountlist_file);
     2202        mr_free(tmp1);
    21922203        log_it("%s",command);
    21932204        if (extract_mountlist_stub) {
  • branches/3.2/mondo/src/mondorestore/mondorestore.c

    r3564 r3610  
    18761876    log_it("Done loading config file; resizing ML");
    18771877
    1878     mr_asprintf(tmp1, "%s", call_program_and_get_last_line_of_output("cat "CMDLINE));
     1878    tmp1 = call_program_and_get_last_line_of_output("cat "CMDLINE);
    18791879    if (strstr(tmp1, "noresize")) {
    18801880        log_msg(1, "Not resizing mountlist.");
     
    21022102    get_cfg_file_from_archive_or_bust();
    21032103    load_mountlist(mountlist, g_mountlist_fname);   // in case read_cfg_file_into_bkpinfo updated the mountlist
    2104 #ifdef __FreeBSD__
    2105     if (strstr(call_program_and_get_last_line_of_output("cat /tmp/cmdline"), "noresize"))
    2106 #else
    2107     if (strstr(call_program_and_get_last_line_of_output("cat /proc/cmdline"), "noresize"))
    2108 #endif
    2109     {
     2104    tmp = call_program_and_get_last_line_of_output("cat "CMDLINE);
     2105    if (strstr(tmp, "noresize")) {
    21102106        log_msg(2, "Not resizing mountlist.");
    21112107    } else {
    21122108        resize_mountlist_proportionately_to_suit_new_drives(mountlist);
    21132109    }
     2110    mr_free(tmp);
     2111
    21142112    flaws_str = evaluate_mountlist(mountlist);
    21152113    if (flaws_str != NULL) {
     
    21382136            twenty_seconds_til_yikes();
    21392137            g_fprep = fopen("/tmp/prep.sh", "w");
    2140             mr_asprintf(tmp1, "%s", call_program_and_get_last_line_of_output("cat "CMDLINE));
     2138            tmp1 = call_program_and_get_last_line_of_output("cat "CMDLINE);
    21412139            if (strstr(tmp1, "nopart")) {
    21422140                log_msg(2, "Not partitioning drives due to 'nopart' option.");
     
    22042202
    22052203  after_the_nuke:
    2206     mr_asprintf(tmp1, "%s", call_program_and_get_last_line_of_output("cat "CMDLINE));
     2204    tmp1 =call_program_and_get_last_line_of_output("cat "CMDLINE);
    22072205    if (retval) {
    22082206        log_to_screen("Errors occurred during the nuke phase.");
     
    25952593
    25962594/* Configure global variables */
    2597 #ifdef __FreeBSD__
    2598     if (strstr
    2599         (call_program_and_get_last_line_of_output("cat /tmp/cmdline"),
    2600          "textonly"))
    2601 #else
    2602     if (strstr
    2603         (call_program_and_get_last_line_of_output("cat /proc/cmdline"),
    2604          "textonly"))
    2605 #endif
    2606     {
     2595    tmp = call_program_and_get_last_line_of_output("cat "CMDLINE);
     2596    if (strstr(tmp, "textonly")) {
    26072597        g_text_mode = TRUE;
    26082598        log_msg(1, "TEXTONLY MODE");
     
    26102600        g_text_mode = FALSE;
    26112601    }                           // newt :-)
     2602    mr_free(tmp);
     2603
    26122604    if (!(mountlist = malloc(sizeof(struct mountlist_itself)))) {
    26132605        fatal_error("Cannot malloc mountlist");
     
    26222614    malloc_libmondo_global_strings();
    26232615
    2624     strcpy(g_mondo_home,
    2625            call_program_and_get_last_line_of_output("which mondorestore"));
     2616    tmp = call_program_and_get_last_line_of_output("which mondorestore");
     2617    strcpy(g_mondo_home, tmp);
     2618        mr_free(tmp);
     2619
    26262620    g_current_media_number = 1; // precaution
    2627 
    26282621    run_program_and_log_output("mkdir -p " MNT_CDROM, FALSE);
    26292622
Note: See TracChangeset for help on using the changeset viewer.