Ignore:
Timestamp:
Nov 5, 2016, 6:12:23 PM (7 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
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/mondo/src/common/libmondo-archive.c

    r3581 r3610  
    550550
    551551#ifdef __FreeBSD__
    552         mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'"));
     552        bootdev = call_program_and_get_last_line_of_output("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'");
    553553        if (!bootdev[0]) {
    554554            mr_free(bootdev);
    555             mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'"));
     555            bootdev = call_program_and_get_last_line_of_output("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'");
    556556        }
    557557#else
    558558        /* Linux */
    559559#ifdef __IA64__
    560         mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output("mount | grep ' /boot/efi ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'"));
     560        bootdev = call_program_and_get_last_line_of_output("mount | grep ' /boot/efi ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'");
    561561#else
    562         mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'"));
     562        bootdev = call_program_and_get_last_line_of_output("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'");
    563563#endif
    564564        if (strstr(bootdev, "/dev/cciss/")) {
    565565            mr_free(bootdev);
    566566#ifdef __IA64__
    567             mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output("mount | grep ' /boot/efi ' | head -1 | cut -d' ' -f1 | cut -dp -f1"));
     567            bootdev = call_program_and_get_last_line_of_output("mount | grep ' /boot/efi ' | head -1 | cut -d' ' -f1 | cut -dp -f1");
    568568#else
    569             mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | cut -dp -f1"));
     569            bootdev = call_program_and_get_last_line_of_output("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | cut -dp -f1");
    570570#endif
    571571        }
    572572        if (!bootdev[0]) {
    573573            mr_free(bootdev);
    574             mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'"));
     574            bootdev = call_program_and_get_last_line_of_output("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'");
    575575            if (strstr(bootdev, "/dev/cciss/")) {
    576576                mr_free(bootdev);
    577                 mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output("mount | grep ' / ' | head -1 | cut -d' ' -f1 | cut -dp -f1"));
     577                bootdev = call_program_and_get_last_line_of_output("mount | grep ' / ' | head -1 | cut -d' ' -f1 | cut -dp -f1");
    578578            }
    579579        }
     
    620620        if ((!does_file_exist("/boot/grub/menu.lst")) && (!does_file_exist("/boot/grub/grub.cfg")) && (!does_file_exist("/boot/grub2/grub.cfg"))) {
    621621            /* if UEFI then search under /boot/efi */
    622             mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("find /boot/efi -name grub.c*"));
     622            tmp = call_program_and_get_last_line_of_output("find /boot/efi -name grub.c*");
    623623            if (strstr(tmp, "grub.c") == NULL) {
    624624                mr_free(bootldr_str);
    625625                fatal_error("The de facto standard location for your boot loader's config file is /boot/grub/menu.lst, /boot/grub/grub.cfg, or /boot/grub2/grub.cfg /boot/efi/.../grub.cfg but I cannot find it there. What is wrong with your Linux distribution?");
    626626            }
    627         }
    628         mr_asprintf(bootldr_ver, "%s", call_program_and_get_last_line_of_output("grub --version 2> /dev/null"));
     627                        mr_free(tmp);
     628        }
     629        bootldr_ver = call_program_and_get_last_line_of_output("grub --version 2> /dev/null");
    629630        if (strcmp(bootldr_ver,"") ==0) {
    630631            mr_free(bootldr_ver);
    631             mr_asprintf(bootldr_ver, "%s", call_program_and_get_last_line_of_output("grub2-install --version"));
     632            bootldr_ver = call_program_and_get_last_line_of_output("grub2-install --version");
    632633        }
    633634    } else if (bkpinfo->boot_loader == 'E') {
     
    881882        log_to_screen("Mindi failed to create your boot+data disks.");
    882883        mr_asprintf(command, "grep 'Fatal error' %s", MINDI_LOGFILE);
    883         mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     884        tmp = call_program_and_get_last_line_of_output(command);
    884885        mr_free(command);
    885886
     
    11321133    /*@ buffers *********************************** */
    11331134    char *command = NULL;
     1135    char *tmp = NULL;
    11341136    char *tmpfile = NULL;
    11351137    char *data_disks_file = NULL;
     
    11381140    mr_asprintf(data_disks_file, "%s/all.tar.gz", bkpinfo->tmpdir);
    11391141
    1140     snprintf(g_serial_string, MAX_STR_LEN - 8, "%s", call_program_and_get_last_line_of_output("dd if=/dev/urandom bs=16 count=1 2> /dev/null | hexdump | tr -s ' ' '0' | head -n1"));
     1142        tmp = call_program_and_get_last_line_of_output("dd if=/dev/urandom bs=16 count=1 2> /dev/null | hexdump | tr -s ' ' '0' | head -n1");
     1143    snprintf(g_serial_string, MAX_STR_LEN - 8, "%s", tmp);
     1144        mr_free(tmp);
    11411145    strip_spaces(g_serial_string);
    11421146    strcat(g_serial_string, "...word.");
     
    18391843    mr_asprintf(command, "dd if=%s bs=512 count=1 2> /dev/null | strings | head -n1", bigfile_fname);
    18401844    log_msg(1, "command = '%s'", command);
    1841     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     1845    tmp = call_program_and_get_last_line_of_output(command);
    18421846    mr_free(command);
    18431847
     
    25802584            mr_asprintf(tmp, "cat %s 2> /dev/null", szserfname);
    25812585            mr_free(our_serial_str);
    2582             mr_asprintf(our_serial_str, "%s", call_program_and_get_last_line_of_output(tmp));
     2586            our_serial_str = call_program_and_get_last_line_of_output(tmp);
    25832587            mr_free(tmp);
    25842588            // FIXME - should be able to use last_line_of_file(), surely?
     
    27642768        mr_asprintf(command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", biggie_filename);
    27652769        log_it("command = %s", command);
    2766         mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     2770        tmp = call_program_and_get_last_line_of_output(command);
    27672771        mr_free(command);
    27682772        log_it("res of it = %s", tmp);
Note: See TracChangeset for help on using the changeset viewer.