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-files.c

    r3430 r3610  
    276276
    277277    if (!kernel[0]) {
    278         strcpy(kernel, call_program_and_get_last_line_of_output("mindi --findkernel 2> /dev/null"));
     278        tmp = call_program_and_get_last_line_of_output("mindi --findkernel 2> /dev/null");
     279        strcpy(kernel, tmp);
     280        mr_free(tmp);
    279281    }
    280282    // If we didn't get anything back, check whether mindi raised a fatal error
    281283    if (!kernel[0]) {
    282284        mr_asprintf(command, "grep 'Fatal error' %s", MINDI_LOGFILE);
    283         mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     285        tmp = call_program_and_get_last_line_of_output(command);
    284286        if (strlen(tmp) > 1) {
    285287            popup_and_OK(tmp);
     
    334336    assert_string_is_neither_NULL_nor_zerolength(fname);
    335337    mr_asprintf(command, "which %s 2> /dev/null", fname);
    336     mr_asprintf(incoming, "%s", call_program_and_get_last_line_of_output(command));
     338    incoming = call_program_and_get_last_line_of_output(command);
    337339    mr_free(command);
    338340
     
    346348        mr_free(incoming);
    347349
    348         mr_asprintf(incoming, "%s", call_program_and_get_last_line_of_output(command));
     350        incoming = call_program_and_get_last_line_of_output(command);
    349351        mr_free(command);
    350352    }
     
    353355        mr_free(incoming);
    354356
    355         mr_asprintf(incoming, "%s", call_program_and_get_last_line_of_output(command));
     357        mr_free(command);
     358        incoming = call_program_and_get_last_line_of_output(command);
    356359        mr_free(command);
    357360    }
     
    435438    if (i < 0) {
    436439        mr_asprintf(command, "tail -n3 %s | grep -Fi \"%c\" | tail -n1 | awk '{print $0;}'", filename, '%');
    437         mr_asprintf(lastline, "%s", call_program_and_get_last_line_of_output(command));
     440        lastline = call_program_and_get_last_line_of_output(command);
    438441        mr_free(command);
    439442        if (!lastline[0]) {
     
    730733
    731734    log_it(command);
    732     mr_asprintf(sz_res, "%s", call_program_and_get_last_line_of_output(command));
     735    sz_res = call_program_and_get_last_line_of_output(command);
    733736    file_len_K = atol(sz_res);
    734737    log_msg(4, "%s --> %s --> %ld", command, sz_res, file_len_K);
     
    786789                    mr_asprintf(command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", fname);
    787790                    log_it("command = %s", command);
    788                     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     791                    tmp = call_program_and_get_last_line_of_output(command);
    789792                    mr_free(command);
    790793
     
    10591062    mr_free(command);
    10601063
    1061     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("which mondorestore"));
     1064    tmp = call_program_and_get_last_line_of_output("which mondorestore");
    10621065    if (!tmp[0]) {
    10631066        mr_free(tmp);
     
    10891092
    10901093    mvaddstr_and_log_it(g_currentY++, 74, "Done.");
    1091 }
    1092 
    1093 
    1094 /**
    1095  * Store the client's NETFS configuration in files to be restored at restore-time.
    1096  * Assumes that @c bkpinfo->media_type = netfs, but does not check for this.
    1097  * @param bkpinfo The backup information structure. Fields used:
    1098  * - @c netfs_mount
    1099  * - @c tmpdir
    1100  */
    1101 void store_netfs_config()
    1102 {
    1103 
    1104     /*@ buffers ******** */
    1105     char *netfs_dev = NULL;
    1106     char *netfs_client_hwaddr = NULL;
    1107     char *command = NULL;
    1108 
    1109     /********
    1110     * If the Network device found above is a bonded device,
    1111     * we need to replace it with an ethN device or the
    1112     * networking will not start during an Network restore.
    1113     *
    1114     * If the Network device in netfs_dev begins with the word "bond", or alb or aft
    1115     * look for the corresponding slave ethN device and copy it to netfs_dev.
    1116     * Using the common MAC address
    1117     ********/
    1118     if (!strncmp(netfs_dev, "bond", 4) || !strncmp(netfs_dev, "alb", 3) || !strncmp(netfs_dev, "aft", 3)) {
    1119         log_to_screen("Found bonding device %s; looking for corresponding ethN slave device\n", netfs_dev);
    1120         mr_asprintf(command, "ifconfig | grep -E '%s' | grep -v '%s' | head -n1 | cut -d' ' -f1",netfs_client_hwaddr,netfs_dev);
    1121         mr_asprintf(netfs_dev, "%s", call_program_and_get_last_line_of_output(command));
    1122         mr_free(command);
    1123         log_to_screen("Replacing it with %s\n", netfs_dev);
    1124     }
    1125 
    1126     log_it("Finished storing Network configuration");
    11271094}
    11281095
Note: See TracChangeset for help on using the changeset viewer.