Ignore:
Timestamp:
Sep 25, 2013, 8:55:43 AM (11 years ago)
Author:
Bruno Cornec
Message:
  • Modification to 3.1 branch to make it extremely similar to 3.0. What remains are function rewrite with allocation in the function and desallocation outside of the function. Will be next step
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.1/mondo/src/common/libmondo-files.c

    r3161 r3190  
    145145    fin = popen(command, "r");
    146146    mr_free(command);
     147
    147148    if (fin) {
    148149        if (feof(fin)) {
     
    216217    assert_string_is_neither_NULL_nor_zerolength(inout);
    217218    mr_asprintf(infname, "%s.in", inout);
    218     mr_asprintf(outfname, "%s", inout);
    219219    mr_asprintf(tmp, "cp -f %s %s", inout, infname);
    220220    run_program_and_log_output(tmp, FALSE);
     
    226226        return;
    227227    }
     228
     229    mr_asprintf(outfname, "%s", inout);
    228230    if (!(fout = fopen(outfname, "w"))) {
    229231        log_OS_error("Unable to openout outfname");
     232        mr_free(infname);
    230233        mr_free(outfname);
    231234        return;
     
    252255    mr_free(infname);
    253256}
    254 
    255 
    256 
    257 
    258 
    259 
    260 
    261257
    262258
     
    271267
    272268    char *tmp = NULL;
    273     char *command = NULL;;
    274     char *kernel = NULL;;
     269    char *command = NULL;
     270    char *kernel = NULL;
    275271
    276272    kernel = call_program_and_get_last_line_of_output("mindi --findkernel 2> /dev/null",TRUE);
     
    308304
    309305
    310 
    311 
    312 
    313 
    314306/**
    315307 * Find location of specified executable in user's PATH.
     
    358350    return (output);
    359351}
    360 
    361 
    362 
    363 
    364 
    365 
    366352
    367353
     
    659645    return (0);
    660646}
    661 
    662 
    663647
    664648
     
    10281012        fatal_error("Failed to copy LAST-FILELIST-NUMBER to scratchdir");
    10291013    }
     1014    mr_free(command);
    10301015
    10311016    tmp = call_program_and_get_last_line_of_output("which mondorestore",TRUE);
     
    10991084
    11001085    /* BERLIOS : there is a bug #67 here as it only considers the first NIC */
    1101     mr_asprintf(command, "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\n' | head -n1 | cut -d' ' -f1");
     1086    mr_asprintf(command, "%s", "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\n' | head -n1 | cut -d' ' -f1");
    11021087    netfs_dev = call_program_and_get_last_line_of_output(command,TRUE);
    11031088    mr_free(command);
     
    11191104    mr_free(command);
    11201105
     1106    mr_asprintf(command, "ifconfig %s | head -1 | awk '{print $5}'", netfs_dev);
     1107    netfs_client_hwaddr = call_program_and_get_last_line_of_output(command);
     1108    mr_free(command);
     1109
     1110    log_it("netfs_client_hwaddr=%s; netfs_client_ipaddr=%s; netfs_server_ipaddr=%s; netfs_mount=%s", netfs_client_hwaddr, netfs_client_ipaddr, netfs_server_ipaddr, netfs_mount);
    11211111    if (strlen(netfs_dev) < 2) {
    11221112        fatal_error("Unable to find ethN (eth0, eth1, ...) adapter via Network mount you specified.");
     
    11241114
    11251115    /********
    1126     * If the Network device that found above is a bonded device,
     1116    * If the Network device found above is a bonded device,
    11271117    * we need to replace it with an ethN device or the
    11281118    * networking will not start during an Network restore.
     
    11531143    mr_free(tmp);
    11541144
    1155     mr_asprintf(tmp, "%s/NETFS-SERVER-MOUNT", bkpinfo->tmpdir);
    1156     write_one_liner_data_file(tmp, bkpinfo->netfs_mount);
    1157     mr_free(tmp);
    1158     mr_free(netfs_mount);
     1145    mr_asprintf(tmp, "%s/NETFS-CLIENT-HWADDR", bkpinfo->tmpdir);
     1146    write_one_liner_data_file(tmp, netfs_client_hwaddr);
     1147    mr_free(netfs_client_hwaddr);
     1148    mr_free(tmp);
    11591149
    11601150    mr_asprintf(tmp, "%s/NETFS-CLIENT-IPADDR", bkpinfo->tmpdir);
    11611151    write_one_liner_data_file(tmp, netfs_client_ipaddr);
    1162     mr_free(tmp);
    1163 
    1164     mr_asprintf(tmp, "%s/NETFS-CLIENT-HWADDR", bkpinfo->tmpdir);
    1165     write_one_liner_data_file(tmp, netfs_client_hwaddr);
     1152    mr_free(netfs_client_ipaddr);
    11661153    mr_free(tmp);
    11671154
    11681155    mr_asprintf(tmp, "%s/NETFS-CLIENT-NETMASK", bkpinfo->tmpdir);
    11691156    write_one_liner_data_file(tmp, netfs_client_netmask);
     1157    mr_free(netfs_client_netmask);
    11701158    mr_free(tmp);
    11711159
    11721160    mr_asprintf(tmp, "%s/NETFS-CLIENT-BROADCAST", bkpinfo->tmpdir);
    11731161    write_one_liner_data_file(tmp, netfs_client_broadcast);
     1162    mr_free(netfs_client_broadcast);
    11741163    mr_free(tmp);
    11751164
    11761165    mr_asprintf(tmp, "%s/NETFS-CLIENT-DEFGW", bkpinfo->tmpdir);
    11771166    write_one_liner_data_file(tmp, netfs_client_defgw);
     1167    mr_free(netfs_client_defgw);
    11781168    mr_free(tmp);
    11791169
    11801170    mr_asprintf(tmp, "%s/NETFS-SERVER-IPADDR", bkpinfo->tmpdir);
    11811171    write_one_liner_data_file(tmp, netfs_server_ipaddr);
     1172    mr_free(netfs_server_ipaddr);
    11821173    mr_free(tmp);
    11831174
     
    11981189    write_one_liner_data_file(tmp, bkpinfo->prefix);
    11991190    mr_free(tmp);
     1191
     1192    sprintf(tmp, "%s/NETFS-PROTO", bkpinfo->tmpdir);
     1193    write_one_liner_data_file(tmp, bkpinfo->netfs_proto);
     1194    mr_free(tmp);
     1195
    12001196
    12011197    log_it("Finished storing Network configuration");
     
    12281224    long long scratchLL;
    12291225
    1230     if (bkpinfo->media_size[1] <= 0) {
     1226    if (bkpinfo->media_size <= 0) {
    12311227        log_to_screen("Number of media required: UNKNOWN");
    12321228        return;
     
    12341230
    12351231    log_it("Estimating number of media required...");
    1236     scratchLL =
    1237         (long long) (noof_sets) * (long long) (bkpinfo->optimal_set_size)
    1238         + (long long) (size_of_all_biggiefiles_K());
    1239     scratchLL = (scratchLL / 1024) / bkpinfo->media_size[1];
     1232    scratchLL = (long long) (noof_sets) * (long long) (bkpinfo->optimal_set_size) + (long long) (size_of_all_biggiefiles_K());
     1233    scratchLL = (scratchLL / 1024) / bkpinfo->media_size;
    12401234    scratchLL++;
    12411235    if (bkpinfo->use_lzo) {
Note: See TracChangeset for help on using the changeset viewer.