Changeset 2320 in MondoRescue
- Timestamp:
- Aug 18, 2009, 2:37:39 PM (16 years ago)
- Location:
- branches/2.2.10/mondo
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/common/libmondo-archive.c
r2318 r2320 337 337 mr_asprintf(&zipparams, ""); 338 338 } 339 340 // make_hole_for_file(fname);341 339 342 340 if (!does_file_exist(bkpinfo->tmpdir)) { … … 543 541 544 542 assert(bkpinfo != NULL); 545 mr_asprintf(&tmp, "echo '%s' | tr -s ' ' '\n' | grep -E '^/dev/.*$' | tr -s '\n' ' ' | awk '{print $0\"\\n\";}'", bkpinfo->exclude_paths); 546 mr_asprintf(&devs_to_exclude, "%s", call_program_and_get_last_line_of_output(tmp)); 547 mr_free(tmp); 548 549 mr_asprintf(&tmp, "devs_to_exclude = '%s'", devs_to_exclude); 550 log_msg(2, tmp); 551 mr_free(tmp); 543 if (bkpinfo->exclude_paths) { 544 mr_asprintf(&tmp, "echo '%s' | tr -s ' ' '\n' | grep -E '^/dev/.*$' | tr -s '\n' ' ' | awk '{print $0\"\\n\";}'", bkpinfo->exclude_paths); 545 mr_asprintf(&devs_to_exclude, "%s", call_program_and_get_last_line_of_output(tmp)); 546 mr_free(tmp); 547 548 mr_asprintf(&tmp, "devs_to_exclude = '%s'", devs_to_exclude); 549 log_msg(2, tmp); 550 mr_free(tmp); 551 } 552 552 553 553 mvaddstr_and_log_it(g_currentY, 0, … … 885 885 last_filelist_number, // parameter #12 (STRING) 886 886 estimated_total_noof_slices, // parameter #13 (INT) 887 devs_to_exclude, // parameter #14887 (devs_to_exclude == NULL) ? "\"\"" : devs_to_exclude, // parameter #14 888 888 use_comp_sz, // parameter #15 889 889 use_lilo_sz, // parameter #16 … … 920 920 if (!res) { 921 921 log_to_screen("Boot+data disks were created OK"); 922 mr_asprintf(&command, "cp -f %s/images/mindi.iso %s/mondorescue.iso", 923 bkpinfo->scratchdir, MINDI_CACHE); 922 mr_asprintf(&command, "cp -f %s/images/mindi.iso %s/mondorescue.iso", bkpinfo->scratchdir, MINDI_CACHE); 924 923 log_msg(2, command); 925 924 run_program_and_log_output(command, FALSE); … … 927 926 928 927 if (bkpinfo->nonbootable_backup) { 929 mr_asprintf(&command, "cp -f %s/all.tar.gz %s/images", 930 bkpinfo->tmpdir, bkpinfo->scratchdir); 928 mr_asprintf(&command, "cp -f %s/all.tar.gz %s/images", bkpinfo->tmpdir, bkpinfo->scratchdir); 931 929 if (system(command)) { 932 930 paranoid_free(command); … … 941 939 paranoid_free(command); 942 940 } else { 943 mr_asprintf(&tmp, "cp -f %s/images/all.tar.gz %s", bkpinfo->scratchdir, 944 bkpinfo->tmpdir); 941 mr_asprintf(&tmp, "cp -f %s/images/all.tar.gz %s", bkpinfo->scratchdir, bkpinfo->tmpdir); 945 942 if (system(tmp)) { 946 943 fatal_error("Cannot find all.tar.gz in tmpdir"); … … 1689 1686 } 1690 1687 1691 log_msg(2, "make_iso_fs --- scratchdir=%s --- destfile=%s", 1692 bkpinfo->scratchdir, destfile); 1688 log_msg(2, "make_iso_fs --- scratchdir=%s --- destfile=%s", bkpinfo->scratchdir, destfile); 1693 1689 (void) getcwd(old_pwd, MAX_STR_LEN - 1); 1694 1690 mr_asprintf(&tmp, "chmod 755 %s", bkpinfo->scratchdir); … … 1727 1723 } else { 1728 1724 res = 1729 eval_call_to_make_ISO(bkpinfo->call_make_iso, 1730 bkpinfo->scratchdir, 1731 g_current_media_number, 1732 MONDO_LOGFILE, message_to_screen); 1725 eval_call_to_make_ISO(bkpinfo->call_make_iso, bkpinfo->scratchdir, g_current_media_number, MONDO_LOGFILE, message_to_screen); 1733 1726 if (res) { 1734 1727 log_to_screen("%s...failed to write", message_to_screen); … … 1789 1782 pause_for_N_seconds(5, "Letting DVD drive settle"); 1790 1783 res = 1791 eval_call_to_make_ISO(bkpinfo->call_make_iso, 1792 bkpinfo->scratchdir, 1793 g_current_media_number, 1794 MONDO_LOGFILE, 1795 message_to_screen); 1784 eval_call_to_make_ISO(bkpinfo->call_make_iso, bkpinfo->scratchdir, g_current_media_number, MONDO_LOGFILE, message_to_screen); 1796 1785 retval += res; 1797 1786 if (!bkpinfo->please_dont_eject) { … … 2378 2367 if (g_getfattr) { 2379 2368 get_fattr_list(biggielist, xattr_fname); 2380 mr_asprintf(&command, "cp %s %s/archives/", xattr_fname, 2381 bkpinfo->scratchdir); 2369 mr_asprintf(&command, "cp %s %s/archives/", xattr_fname, bkpinfo->scratchdir); 2382 2370 paranoid_system(command); 2383 2371 mr_free(command); … … 3302 3290 paranoid_fclose(fout); 3303 3291 3304 mr_asprintf(&tmp1, "cp -f %s/autorun %s/", g_mondo_home, 3305 bkpinfo->scratchdir); 3292 mr_asprintf(&tmp1, "cp -f %s/autorun %s/", g_mondo_home, bkpinfo->scratchdir); 3306 3293 if (run_program_and_log_output(tmp1, FALSE)) { 3307 3294 log_msg(2, "Warning - unable to copy autorun to scratchdir"); -
branches/2.2.10/mondo/src/common/libmondo-cli.c
r2319 r2320 56 56 static int get_dsf_mount_list (const char *dsf, char **included_dsf_list, char **excluded_dsf_list); 57 57 static int create_list_of_non_NFS_mounted_file_systems (void); 58 static MOUNTED_FS_STRUCT *find_mount_point_in_list (c har *mount_point);59 static MOUNTED_FS_STRUCT *find_device_in_list (c har *device);58 static MOUNTED_FS_STRUCT *find_mount_point_in_list (const char *mount_point); 59 static MOUNTED_FS_STRUCT *find_device_in_list (const char *device); 60 60 61 61 /* Do we use extended attributes and acl ? … … 124 124 mr_free(tmp); 125 125 126 sprintf(bkpinfo->scratchdir + strlen(bkpinfo->scratchdir),127 "/mondo.scratch.%ld", random() % 32767); 126 mr_strcat(bkpinfo->scratchdir, "/mondo.scratch.%ld", random() % 32767); 127 128 128 mr_asprintf(&tmp, "mkdir -p %s/tmpfs", bkpinfo->tmpdir); 129 129 paranoid_system(tmp); … … 168 168 bkpinfo->media_size[j] = friendly_sizestr_to_sizelong(p); 169 169 } 170 // bkpinfo->media_size[0] = bkpinfo->media_size[MAX_NOOF_MEDIA];171 170 for (j = 1; j <= MAX_NOOF_MEDIA; j++) { 172 171 if (bkpinfo->media_size[j] <= 0) { … … 189 188 while (DSFptr != NULL) { 190 189 DSFnext = DSFptr->next; 191 paranoid_free(DSFptr);190 mr_free(DSFptr); 192 191 DSFptr = DSFnext; 193 192 } … … 221 220 * structure if it did. 222 221 */ 223 static MOUNTED_FS_STRUCT *find_device_in_list (c har *device)222 static MOUNTED_FS_STRUCT *find_device_in_list (const char *device) 224 223 { 225 224 MOUNTED_FS_STRUCT *DSFptr = NULL; … … 242 241 * structure if it did. 243 242 */ 244 static MOUNTED_FS_STRUCT *find_mount_point_in_list (c har *mount_point)243 static MOUNTED_FS_STRUCT *find_mount_point_in_list (const char *mount_point) 245 244 { 246 245 MOUNTED_FS_STRUCT *DSFptr = NULL; … … 283 282 log_msg(5, "Running: %s", command); 284 283 mr_asprintf(&mounted_file_system, "%s", call_program_and_get_last_line_of_output(command)); 285 paranoid_free(command);284 mr_free(command); 286 285 287 286 mount_cnt = atoi(mounted_file_system); 288 287 log_msg (5, "mount_cnt: %d", mount_cnt); 289 paranoid_free(mounted_file_system);288 mr_free(mounted_file_system); 290 289 291 290 for (i=mount_cnt; i > 0; i--) { … … 293 292 log_msg(5, "Running: %s", command); 294 293 mr_asprintf(&mounted_file_system, "%s", call_program_and_get_last_line_of_output(command)); 295 paranoid_free(command);294 mr_free(command); 296 295 297 296 log_msg (5, "mounted_file_system: %s", mounted_file_system); 298 297 if ((token = strtok(mounted_file_system, token_chars)) == NULL) { 299 298 log_msg (4, "Could not get the list of mounted file systems"); 300 paranoid_free(mounted_file_system);299 mr_free(mounted_file_system); 301 300 mr_free(token); 302 301 return (1); … … 315 314 if ((token = strtok(NULL, token_chars)) == NULL) { 316 315 log_msg (5, "Ran out of entries on the mounted file systems list"); 317 paranoid_free(mounted_file_system);316 mr_free(mounted_file_system); 318 317 mr_free(token); 319 318 return (1); … … 324 323 token = strtok(NULL, token_chars); 325 324 } 326 paranoid_free(mounted_file_system);325 mr_free(mounted_file_system); 327 326 } 328 327 /******** … … 377 376 log_msg(5, " Executing: %s", command); 378 377 mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command)); 379 paranoid_free(command);378 mr_free(command); 380 379 381 380 log_msg(5, " Return value: %s", tmp); 382 381 c = atoi(tmp); 383 paranoid_free(tmp);382 mr_free(tmp); 384 383 385 384 if (!c) { … … 403 402 log_msg(4, "Executing: %s", command); 404 403 mr_asprintf(&partition_list, "%s", call_program_and_get_last_line_of_output(command)); 405 paranoid_free(command);404 mr_free(command); 406 405 log_msg(4, "Partition list for %s: %s", dsf, partition_list); 407 406 if (!strlen(partition_list)) { … … 419 418 mr_free(token); 420 419 } 421 paranoid_free(partition_list);420 mr_free(partition_list); 422 421 423 422 /******** … … 457 456 log_msg(4, " Running: %s", command); 458 457 mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command)); 459 paranoid_free(command); 458 mr_free(command); 459 460 460 log_msg(4, " Return value: %s", tmp); 461 461 c = strlen(tmp); 462 paranoid_free(tmp); 462 mr_free(tmp); 463 463 464 if (c) { 464 465 log_msg(4, "It's swap. Ignoring partition %s", partitions[i]); … … 468 469 mr_asprintf(&command, "mount 2>/dev/null | awk '{if((NF>0)&&($1==\"%s\")){print $3}}'", partitions[i]); 469 470 mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command)); 470 paranoid_free(command); 471 mr_free(command); 472 471 473 if (strlen(tmp)) { 472 474 log_msg(4, " %s is mounted: %s", partitions[i], tmp); 473 475 if ((DSFptr = find_mount_point_in_list(tmp)) == NULL) { 474 476 log_msg (4, "Can't find mount point %s in mounted file systems list", tmp); 475 paranoid_free(tmp);477 mr_free(tmp); 476 478 return (1); 477 479 } 478 480 DSFptr->check = 1; 479 paranoid_free(tmp);481 mr_free(tmp); 480 482 continue; 481 483 } 482 paranoid_free(tmp);484 mr_free(tmp); 483 485 /* It's not swap and it's not mounted. See if it's LVM */ 484 486 log_msg(4, " It's not mounted. Checking to see if it's LVM..."); … … 487 489 log_msg(4, " Running: %s", command); 488 490 mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command)); 489 paranoid_free(command);491 mr_free(command); 490 492 if (strlen(tmp)) { 491 493 log_msg(4, " Partition ID: %s", tmp); … … 496 498 log_msg(4, " Running: %s", command); 497 499 strcpy(VG, call_program_and_get_last_line_of_output(command)); 498 paranoid_free(command);500 mr_free(command); 499 501 log_msg(4, " Volume Group: %s", VG); 500 502 if (strlen(VG)) { … … 504 506 log_msg(4, " Running: %s", command); 505 507 mr_asprintf(&mount_list, "%s", call_program_and_get_last_line_of_output(command)); 506 paranoid_free(command);508 mr_free(command); 507 509 log_msg(4, " VG %s mount_list: %s", VG, mount_list); 508 510 lastpos = 0; … … 511 513 if ((DSFptr = find_mount_point_in_list(token)) == NULL) { 512 514 log_msg (4, "Can't find mount point %s in mounted file systems list", token); 513 paranoid_free(tmp);515 mr_free(tmp); 514 516 mr_free(token); 515 517 return (1); … … 522 524 * any of the Logical Volumes on the Volume Group. 523 525 *******/ 524 paranoid_free(mount_list);526 mr_free(mount_list); 525 527 mr_asprintf(&command, "%s", "cat /proc/mdstat|grep -iv Personal|awk '{if($0~\"^.*[ ]+:\"){printf(\"/dev/%s \", $1)}}END{print \"\"}'"); 526 528 log_msg (5, "Running: %s", command); 527 529 mr_asprintf(&mount_list, "%s", call_program_and_get_last_line_of_output(command)); 528 paranoid_free(command);530 mr_free(command); 529 531 log_msg(4, " Software raid device list: %s", mount_list); 530 532 lastpos = 0; … … 532 534 mr_asprintf(&command, "mdadm --detail %s 2>/dev/null | grep -c %s", token, VG); 533 535 log_msg (5, "Running: %s", command); 534 paranoid_free(tmp);536 mr_free(tmp); 535 537 mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command)); 536 paranoid_free(command);538 mr_free(command); 537 539 log_msg(4, "Number of Software raid device: %s", tmp); 538 540 if (atoi(tmp)) { … … 540 542 if ((DSFptr = find_device_in_list(token)) == NULL) { 541 543 log_msg (4, "Can't find device %s in mounted file systems list", token); 542 paranoid_free(tmp);544 mr_free(tmp); 543 545 mr_free(token); 544 546 return (1); … … 548 550 } 549 551 mr_free(token); 550 paranoid_free(mount_list);552 mr_free(mount_list); 551 553 } else { 552 554 log_msg (4, "Error finding Volume Group for partition %s", partitions[i]); 553 paranoid_free(tmp);555 mr_free(tmp); 554 556 return (1); 555 557 } 556 paranoid_free(tmp);558 mr_free(tmp); 557 559 continue; 558 560 } … … 560 562 log_msg (4, "Error finding partition type for the partition %s", partitions[i]); 561 563 } 562 paranoid_free(tmp);564 mr_free(tmp); 563 565 /******** 564 566 * It's not swap, mounted, or LVM. See if it's used in a software raid device. … … 568 570 log_msg(4, " Running: %s", command); 569 571 mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command)); 570 paranoid_free(command);572 mr_free(command); 571 573 if (!strlen(tmp)) { 572 574 log_msg(4, " Partition %s is not used in a non-LVM software raid device", partitions[i]); 573 paranoid_free(tmp);575 mr_free(tmp); 574 576 continue; 575 577 } … … 579 581 log_msg (5, " Running: %s", command); 580 582 mr_asprintf(&mount_list, "%s", call_program_and_get_last_line_of_output(command)); 581 paranoid_free(command);583 mr_free(command); 582 584 log_msg(4, " Software raid device list: %s", mount_list); 583 585 /* Loop through the software raid device list to see if we can find the partition */ … … 586 588 mr_asprintf(&command, "mdadm --detail %s 2>/dev/null | grep -c %s", token, tmp); 587 589 log_msg(4, " Running: %s", command); 588 paranoid_free(tmp);590 mr_free(tmp); 589 591 mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command)); 590 paranoid_free(command);592 mr_free(command); 591 593 if (!atoi(tmp)) { 592 594 log_msg (4," Didn't find partition %s in software raid device %s", partitions[i], token); … … 594 596 if ((DSFptr = find_device_in_list(token)) == NULL) { 595 597 log_msg (4, "Can't find device %s in mounted file systems list", token); 596 paranoid_free(tmp);598 mr_free(tmp); 597 599 mr_free(token); 598 600 return (1); … … 603 605 mr_free(token); 604 606 } 605 paranoid_free(tmp);606 } 607 paranoid_free(partition_list);608 paranoid_free(mount_list);607 mr_free(tmp); 608 } 609 mr_free(partition_list); 610 mr_free(mount_list); 609 611 610 612 /* Determine how much memory to allocate for included_dsf_list and excluded_dsf_list */ … … 753 755 754 756 if (flag_set['I']) { 755 if (bkpinfo->include_paths [0] == '-') {757 if (bkpinfo->include_paths && bkpinfo->include_paths[0] == '-') { 756 758 retval++; 757 759 log_to_screen("Please supply a sensible value with '-I'\n"); 758 }759 if (!strcmp(bkpinfo->include_paths, "/")) {760 log_msg(2, "'/' is pleonastic.");761 760 } 762 761 … … 783 782 } 784 783 } 785 paranoid_free(tmp1);784 mr_free(tmp1); 786 785 while ((token = mr_strtok(flag_val['I'], token_chars, &lastpos)) != NULL) { 787 786 switch (get_dsf_mount_list(token, &mounted_on_dsf, ¬_mounted_on_dsf)) { … … 798 797 log_to_screen(" %s\n", mounted_on_dsf); 799 798 mr_asprintf(&p, "/"); 799 mr_free(bkpinfo->include_paths); 800 800 bkpinfo->include_paths = p; 801 801 if (strlen(not_mounted_on_dsf)) { … … 803 803 log_to_screen("Not archiving the following file systems:\n"); 804 804 log_to_screen(" %s\n", not_mounted_on_dsf); 805 mr_strcat(bkpinfo->exclude_paths, " %s ", not_mounted_on_dsf);805 mr_strcat(bkpinfo->exclude_paths, " %s ", not_mounted_on_dsf); 806 806 } 807 807 break; … … 837 837 bkpinfo->make_filelist = FALSE; 838 838 mr_asprintf(&p, "%s", flag_val['J']); 839 mr_free(bkpinfo->include_paths); 839 840 bkpinfo->include_paths = p; 840 841 } … … 1089 1090 1090 1091 if (flag_set['E']) { 1091 if (bkpinfo->exclude_paths [0] == '-') {1092 if (bkpinfo->exclude_paths && bkpinfo->exclude_paths[0] == '-') { 1092 1093 retval++; 1093 1094 log_to_screen("Please supply a sensible value with '-E'\n"); 1094 1095 } 1095 mr_strcat(bkpinfo->exclude_paths, " ");1096 1096 mr_asprintf(&tmp1, "%s", flag_val['E']); 1097 1097 … … 1136 1136 log_to_screen(" %s\n", mounted_on_dsf); 1137 1137 log_msg (5, "Adding to bkpinfo->exclude_paths due to -E option: %s", mounted_on_dsf); 1138 mr_strcat(bkpinfo->exclude_paths, "%s ", mounted_on_dsf); 1139 } 1138 mr_strcat(bkpinfo->exclude_paths, " %s ", mounted_on_dsf); 1140 1139 } 1141 1140 break; … … 1146 1145 /* A device special file was not passed in. Process it as a path. */ 1147 1146 case -1: 1148 mr_strcat(bkpinfo->exclude_paths, " %s ", token);1147 mr_strcat(bkpinfo->exclude_paths, " %s ", token); 1149 1148 break; 1150 1149 } … … 1164 1163 { 1165 1164 mr_asprintf(&psz, "%s", list_of_NFS_mounts_only()); 1166 mr_strcat(bkpinfo->exclude_paths, " %s ", psz);1165 mr_strcat(bkpinfo->exclude_paths, " %s ", psz); 1167 1166 mr_free(psz); 1168 1167 … … 1300 1299 1301 1300 if (flag_set['S']) { 1302 sprintf(bkpinfo->scratchdir, "%s/mondo.scratch.%ld", flag_val['S'], 1303 random() % 32768); 1301 mr_asprintf(&tmp1, "%s/mondo.scratch.%ld", flag_val['S'], random() % 32768); 1302 mr_free(bkpinfo->scratchdir); 1303 bkpinfo->scratchdir = tmp1; 1304 1304 } 1305 1305 … … 1376 1376 finish(0); 1377 1377 } 1378 mr_free(tmp); 1378 1379 1379 1380 if ((flag_set['L']) && (! bkpinfo->restore_data)) { … … 1466 1467 /* and finally... */ 1467 1468 1468 paranoid_free(tmp);1469 1469 return (retval); 1470 1470 } … … 1515 1515 mr_asprintf(&tmp, "Switch -%c previously defined as %s\n", opt, flag_val[opt]); 1516 1516 log_to_screen(tmp); 1517 paranoid_free(tmp);1517 mr_free(tmp); 1518 1518 } else { 1519 1519 flag_set[opt] = TRUE; … … 1531 1531 mr_asprintf(&tmp, "-%c flag --- must be absolute path --- '%s' isn't absolute", opt, flag_val[opt]); 1532 1532 log_to_screen(tmp); 1533 paranoid_free(tmp);1533 mr_free(tmp); 1534 1534 bad_switches = TRUE; 1535 1535 } … … 1544 1544 mr_asprintf(&tmp, "Invalid arg -- %s\n", argv[i]); 1545 1545 log_to_screen(tmp); 1546 paranoid_free(tmp);1546 mr_free(tmp); 1547 1547 } 1548 1548 return (bad_switches); … … 1607 1607 mr_strcat(tmp, " signal received from OS"); 1608 1608 log_to_screen(tmp); 1609 paranoid_free(tmp);1609 mr_free(tmp); 1610 1610 1611 1611 log_to_screen(tmp2); 1612 paranoid_free(tmp2);1612 mr_free(tmp2); 1613 1613 if (sig == SIGABRT) { 1614 1614 sleep(10); -
branches/2.2.10/mondo/src/common/libmondo-devices.c
r2319 r2320 1979 1979 finish(1); 1980 1980 } 1981 strcpy(bkpinfo->scratchdir, p);1982 mr_free(p);1981 mr_free(bkpinfo->scratchdir); 1982 bkpinfo->scratchdir = p; 1983 1983 1984 1984 // Interactive mode: … … 2156 2156 if (tmp[0] != '/') { 2157 2157 mr_asprintf(&sz, "%s", tmp); 2158 paranoid_free(tmp);2158 mr_free(tmp); 2159 2159 mr_asprintf(&tmp, "/%s", sz); 2160 2160 mr_free(sz); … … 2166 2166 log_it("bkpinfo->tmpdir is being set to %s", bkpinfo->tmpdir); 2167 2167 2168 sprintf(bkpinfo->scratchdir, "%s/mondo.scratch.%d", tmp, 2169 (int) (random() % 32768)); 2168 mr_asprintf(&sz, "%s/mondo.scratch.%d", tmp, (int) (random() % 32768)); 2169 mr_free(bkpinfo->scratchdir); 2170 bkpinfo->scratchdir = sz; 2170 2171 log_it("bkpinfo->scratchdir is being set to %s", bkpinfo->scratchdir); 2171 2172 2172 2173 mr_asprintf(&command, "rm -Rf %s/tmp.mondo.* %s/mondo.scratch.*", tmp, tmp); 2173 paranoid_free(tmp);2174 mr_free(tmp); 2174 2175 2175 2176 paranoid_system(command); -
branches/2.2.10/mondo/src/common/libmondo-filelist.c
r2296 r2320 1296 1296 1297 1297 assert(bkpinfo != NULL); 1298 log_it("tmpdir=%s; scratchdir=%s", bkpinfo->tmpdir, 1299 bkpinfo->scratchdir); 1298 log_it("tmpdir=%s; scratchdir=%s", bkpinfo->tmpdir, bkpinfo->scratchdir); 1300 1299 if (bkpinfo->make_filelist) { 1301 1300 mvaddstr_and_log_it(g_currentY, 0, … … 1308 1307 if (bkpinfo->make_filelist) { 1309 1308 res = 1310 mondo_makefilelist(MONDO_LOGFILE, bkpinfo->tmpdir, 1311 bkpinfo->scratchdir, bkpinfo->include_paths, 1312 bkpinfo->exclude_paths, 1313 bkpinfo->differential, NULL); 1309 mondo_makefilelist(MONDO_LOGFILE, bkpinfo->tmpdir, bkpinfo->scratchdir, bkpinfo->include_paths, bkpinfo->exclude_paths, bkpinfo->differential, NULL); 1314 1310 } else { 1315 1311 res = 1316 mondo_makefilelist(MONDO_LOGFILE, bkpinfo->tmpdir, 1317 bkpinfo->scratchdir, NULL, 1318 bkpinfo->exclude_paths, 1319 bkpinfo->differential, 1320 bkpinfo->include_paths); 1312 mondo_makefilelist(MONDO_LOGFILE, bkpinfo->tmpdir, bkpinfo->scratchdir, NULL, bkpinfo->exclude_paths, bkpinfo->differential, bkpinfo->include_paths); 1321 1313 } 1322 1314 … … 1382 1374 malloc_string(find_skeleton_marker); 1383 1375 mr_asprintf(&find_excludes, " "); 1384 while((token = mr_strtok (sth, delims, &lastpos))) { 1385 mr_asprintf(&strtmp,"%s", find_excludes); 1386 paranoid_free(find_excludes); 1387 mr_asprintf(&find_excludes,"%s -path %s -prune -o", strtmp, token); 1388 paranoid_free(strtmp); 1389 mr_free(token); 1376 if (sth != NULL) { 1377 while((token = mr_strtok(sth, delims, &lastpos))) { 1378 mr_strcat(find_excludes," -path %s -prune -o", token); 1379 } 1390 1380 } 1391 1381 #if linux … … 1396 1386 mr_asprintf(&strtmp, "find '%s' -fstype mvfs -prune -o -path /proc -prune -o %s -type d -print > %s 2> /dev/null", dir, find_excludes, g_skeleton_filelist); 1397 1387 #endif 1398 paranoid_free(find_excludes); 1388 mr_free(find_excludes); 1389 1399 1390 log_msg(5, "find command = %s", strtmp); 1400 1391 (void)system(strtmp); 1401 paranoid_free(strtmp); 1392 mr_free(strtmp); 1393 1402 1394 mr_asprintf(&tmp, "wc -l %s | awk '{print $1;}'", g_skeleton_filelist); 1403 g_skeleton_entries = 1404 1 + atol(call_program_and_get_last_line_of_output(tmp));1405 paranoid_free(tmp); 1395 g_skeleton_entries = 1 + atol(call_program_and_get_last_line_of_output(tmp)); 1396 mr_free(tmp); 1397 1406 1398 sprintf(name_of_evalcall_form, "Making catalog of %s", dir); 1407 1399 open_evalcall_form(name_of_evalcall_form); … … 1415 1407 "grep -Fv '%s' %s > %s.new 2> /dev/null", dir, 1416 1408 g_skeleton_filelist, g_skeleton_filelist); 1417 // log_msg(0, "fsm = %s", find_skeleton_marker);1418 1409 if (!system(find_skeleton_marker)) { 1419 1410 percentage = (int) (skeleton_lino * 100 / g_skeleton_entries); 1420 1411 skeleton_lino++; 1421 // log_msg(5, "Found %s", dir);1422 // log_msg(2, "Incrementing skeleton_lino; now %ld/%ld (%d%%)", skeleton_lino, g_skeleton_entries, percentage);1423 1412 sprintf(find_skeleton_marker, "mv -f %s.new %s", 1424 1413 g_skeleton_filelist, g_skeleton_filelist); 1425 // log_msg(6, "fsm = %s", find_skeleton_marker);1426 1414 run_program_and_log_output(find_skeleton_marker, 8); 1427 1415 time(&this_time); … … 1570 1558 char *p, *q; 1571 1559 char *sz_datefile; 1572 char *sz_filelist, *exclude_paths, *tmp; 1560 char *sz_filelist; 1561 char *exclude_paths = NULL; 1562 char *tmp; 1573 1563 int i; 1574 1564 FILE *fout; … … 1581 1571 malloc_string(tmp); 1582 1572 malloc_string(g_skeleton_filelist); 1583 if (!(exclude_paths = malloc(8*MAX_STR_LEN))) {1584 fatal_error("Cannot malloc exclude_paths");1585 }1586 1573 mr_asprintf(&sz_datefile,MONDO_CACHE"/difflevel.%d" , 0); 1587 1574 if (!include_paths && !userdef_filelist) { … … 1637 1624 mr_free(command); 1638 1625 } else { 1639 log_msg(2, "include_paths = '%s'", include_paths); 1626 if (include_paths) { 1627 log_msg(2, "include_paths = '%s'", include_paths); 1628 } 1640 1629 log_msg(1, "Calculating filelist"); 1641 1630 mr_asprintf(&tmp2, "%s", call_program_and_get_last_line_of_output("mount | grep -Ew 'ntfs|ntfs-3g|fat|vfat|dos' | awk '{print $3}'")); … … 1649 1638 log_msg(2, "Found windows files: %s",tmp2); 1650 1639 } 1651 paranoid_free(tmp1); 1652 1653 snprintf(exclude_paths, (size_t)8*MAX_STR_LEN," %s %s %s %s %s . .. \ 1654 " MNT_CDROM " " MNT_FLOPPY " /media /tmp \ 1655 /proc /sys " MINDI_CACHE, MONDO_CACHE, excp, tmp2, (tmpdir[0] == '/' && tmpdir[1] == '/') ? (tmpdir + 1) : tmpdir, (scratchdir[0] == '/' && scratchdir[1] == '/') ? (scratchdir + 1) : scratchdir); 1656 paranoid_free(tmp2); 1640 mr_free(tmp1); 1641 1642 mr_asprintf(&exclude_paths, " %s %s %s %s %s . .. " MNT_CDROM " " MNT_FLOPPY " /media /tmp /proc /sys " MINDI_CACHE, MONDO_CACHE, (excp == NULL) ? "" : excp, tmp2, (tmpdir[0] == '/' && tmpdir[1] == '/') ? (tmpdir + 1) : tmpdir, (scratchdir[0] == '/' && scratchdir[1] == '/') ? (scratchdir + 1) : scratchdir); 1643 mr_free(tmp2); 1657 1644 1658 1645 log_msg(2, "Excluding paths = '%s'", exclude_paths); 1659 log_msg(2, 1660 "Generating skeleton filelist so that we can track our progress"); 1646 log_msg(2, "Generating skeleton filelist so that we can track our progress"); 1661 1647 sprintf(g_skeleton_filelist, "%s/tmpfs/skeleton.txt", tmpdir); 1662 1648 make_hole_for_file(g_skeleton_filelist); … … 1667 1653 } 1668 1654 i = 0; 1669 if ( strlen(include_paths) == 0) {1655 if ((!include_paths) || (strlen(include_paths) == 0)) { 1670 1656 log_msg(1, "Including only '/' in %s", sz_filelist); 1671 1657 open_and_list_dir("/", exclude_paths, fout, … … 1685 1671 } 1686 1672 } 1673 mr_free(exclude_paths); 1687 1674 paranoid_fclose(fout); 1688 1675 } … … 1702 1689 paranoid_free(sz_filelist); 1703 1690 log_msg(2, "Freeing variables"); 1704 paranoid_free(exclude_paths);1705 1691 paranoid_free(tmp); 1706 1692 paranoid_free(g_skeleton_filelist); -
branches/2.2.10/mondo/src/common/libmondo-tools.c
r2319 r2320 448 448 mr_free(tmp); 449 449 } 450 make_hole_for_dir(bkpinfo->scratchdir); 450 if (bkpinfo->scratchdir) { 451 make_hole_for_dir(bkpinfo->scratchdir); 452 chmod(bkpinfo->scratchdir, 0700); 453 } else { 454 fatal_error("Scratchdir set to NULL !"); 455 } 451 456 if (bkpinfo->backup_media_type == iso) 452 457 make_hole_for_dir(bkpinfo->isodir); … … 680 685 fprintf(stderr, "Type 'man mondoarchive' for help.\n"); 681 686 } 682 if (strlen(bkpinfo->tmpdir) < 2 || strlen(bkpinfo->scratchdir) < 2) {683 log_it("tmpdir or scratchdir areblank/missing");687 if (strlen(bkpinfo->tmpdir) < 2) { 688 log_it("tmpdir is blank/missing"); 684 689 retval++; 685 690 } … … 688 693 bkpinfo->include_paths = p; 689 694 } 690 chmod(bkpinfo->scratchdir, 0700);691 695 g_backup_media_type = bkpinfo->backup_media_type; 692 696 paranoid_free(mtpt); -
branches/2.2.10/mondo/src/common/mondostructures.h
r2226 r2320 480 480 * As such, it needs to be at least as large as the largest CD/DVD/ISO. 481 481 */ 482 char scratchdir[MAX_STR_LEN / 4];482 char *scratchdir; 483 483 484 484 /** … … 515 515 * If you do nothing, "/" will be used. 516 516 */ 517 char include_paths[MAX_STR_LEN*4];517 char *include_paths; 518 518 519 519 /** … … 522 522 * the scratchdir, and the tempdir are automatically excluded. 523 523 */ 524 char exclude_paths[MAX_STR_LEN*4];524 char *exclude_paths; 525 525 526 526 /** -
branches/2.2.10/mondo/src/common/newt-specific.c
r2319 r2320 294 294 fatal_error(char *error_string) { 295 295 /*@ buffers ***************************************************** */ 296 char fatalstr[MAX_NEWT_COMMENT_LEN] = 297 "-------FATAL ERROR---------"; 298 char *tmp; 299 char *command; 296 char *command = NULL; 300 297 static bool already_exiting = FALSE; 301 298 302 299 /*@ end vars **************************************************** */ 303 300 304 malloc_string(command);305 tmp = malloc(MAX_NEWT_COMMENT_LEN);306 301 set_signals(FALSE); // link to external func 307 302 g_exiting = TRUE; … … 311 306 log_msg(2, "mastermind %d is exiting", (int) getpid()); 312 307 kill(g_main_pid, SIGTERM); 313 paranoid_free(tmp);314 308 finish(1); 315 309 } … … 319 313 log_msg(2, "non-m/m %d is exiting", (int) getpid()); 320 314 kill(g_main_pid, SIGTERM); 321 paranoid_free(tmp);322 315 finish(1); 323 316 } … … 327 320 if (already_exiting) { 328 321 log_msg(3, "...I'm already exiting. Give me time, Julian!"); 329 paranoid_free(tmp);330 322 finish(1); 331 323 } … … 338 330 kill_anything_like_this("ntfsclone"); 339 331 sync(); 340 /*341 sprintf(tmp, "umount %s", g_tmpfs_mountpt);342 for (i = 0; i < 10 && run_program_and_log_output(tmp, 5); i++) {343 log_msg(2, "Waiting for child processes to terminate");344 sleep(1);345 run_program_and_log_output(tmp, 5);346 }347 */348 332 349 333 chdir("/"); 350 334 if (g_selfmounted_isodir) { 351 sprintf(command, "umount %s", g_selfmounted_isodir);335 mr_asprintf(&command, "umount %s", g_selfmounted_isodir); 352 336 run_program_and_log_output(command, 5); 353 sprintf(command, "rmdir %s", g_selfmounted_isodir); 337 mr_free(command); 338 mr_asprintf(&command, "rmdir %s", g_selfmounted_isodir); 354 339 run_program_and_log_output(command, 5); 340 mr_free(command); 355 341 } 356 342 357 343 if (!g_text_mode) { 358 log_msg(0, fatalstr);344 log_msg(0, "-------FATAL ERROR---------"); 359 345 log_msg(0, error_string); 360 346 newtFinished(); … … 362 348 363 349 printf("---FATALERROR--- %s\n", error_string); 364 printf 365 ("If you require technical support, please contact the mailing list.\n"); 350 printf("If you require technical support, please contact the mailing list.\n"); 366 351 printf("See http://www.mondorescue.org for details.\n"); 367 printf 368 ("The list's members can help you, if you attach that file to your e-mail.\n"); 352 printf("The list's members can help you, if you attach that file to your e-mail.\n"); 369 353 printf("Log file: %s\n", MONDO_LOGFILE); 370 354 printf("Mondo has aborted.\n"); … … 372 356 log_msg(3, "FYI - g_main_pid is blank"); 373 357 } 374 paranoid_free(tmp);375 paranoid_free(command);376 358 finish(254); 377 359 } … … 405 387 mr_asprintf(&command, "umount %s", g_selfmounted_isodir); 406 388 run_program_and_log_output(command, 1); 407 paranoid_free(command); 389 mr_free(command); 390 408 391 mr_asprintf(&command, "rmdir %s", g_selfmounted_isodir); 409 392 run_program_and_log_output(command, 1); 410 paranoid_free(command);393 mr_free(command); 411 394 } 412 395 if (!g_text_mode) { … … 443 426 mr_free(bkpinfo->exclude_paths); 444 427 mr_free(bkpinfo->include_paths); 428 mr_free(bkpinfo->scratchdir); 445 429 446 430 /* Then free the structure */ 447 paranoid_free(bkpinfo);431 mr_free(bkpinfo); 448 432 free_libmondo_global_strings(); 449 433 free_newt_stuff(); … … 947 931 } 948 932 949 err_log_lines = 950 (char **) malloc(sizeof(char *) * g_noof_log_lines); 951 if (!err_log_lines) { 952 fatal_error("Out of memory"); 953 } 933 err_log_lines = (char **) mr_malloc(sizeof(char *) * g_noof_log_lines); 954 934 955 935 for (i = 0; i < g_noof_log_lines; i++) { 956 err_log_lines[i] = (char *) malloc(MAX_NEWT_COMMENT_LEN); 957 if (!err_log_lines[i]) { 958 fatal_error("Out of memory"); 959 } 936 err_log_lines[i] = (char *) mr_malloc(MAX_NEWT_COMMENT_LEN); 960 937 } 961 938 … … 1055 1032 } 1056 1033 if (!g_text_mode) { 1057 // log_it("refreshing");1058 1034 newtRefresh(); 1059 1035 } … … 1080 1056 void 1081 1057 update_progress_form(char *blurb3) { 1082 /* log_it("update_progress_form --- called"); */1083 1058 if (g_current_progress == -999) { 1084 /* log_it("You're trying to update progress form when it ain't open. Aww, that's OK. I'll let it go. It's a bit naughty but it's a nonfatal error. No prob, Bob."); */1085 1059 return; 1086 1060 } … … 1194 1168 } 1195 1169 } 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1170 1209 1171 … … 1280 1242 } 1281 1243 newtPushHelpLine(title_sz); 1282 // newtOpenWindow (23, 3, 34, 17, minimsg_sz);1283 1244 newtCenteredWindow(34, 17, minimsg_sz); 1284 1245 b1 = newtButton(1, 1, "CD-R disks "); -
branches/2.2.10/mondo/src/include/mr_mem.h
r2316 r2320 20 20 #define mr_allocstr(x,y) mr_allocstr_int(x,y,__LINE__,__FILE__) 21 21 #define mr_asprintf(x,y,args...) mr_asprintf_int(x,__LINE__,__FILE__,y,## args) 22 #define mr_getline(x, z) mr_getline_int(x,z,__LINE__,__FILE__)22 #define mr_getline(x,y) mr_getline_int(x,y,__LINE__,__FILE__) 23 23 #define mr_malloc(x) mr_malloc_int((size_t)x,__LINE__,__FILE__) 24 24 #define mr_setenv(x,y) mr_setenv_int(x,y,__LINE__,__FILE__) -
branches/2.2.10/mondo/src/lib/mr_err.c
r1422 r2320 16 16 #include <stdio.h> 17 17 #include <stdlib.h> 18 #include "mr_msg.h" 18 19 19 20 /* Pointer to the right cleanup function provided by each main */ 20 extern void (*mr_cleanup)( void);21 extern void (*mr_cleanup)(int); 21 22 22 23 /* … … 26 27 27 28 if (mr_cleanup != NULL) { 28 mr_cleanup( );29 mr_cleanup(errorcode); 29 30 } 30 31 if (message != NULL) { 31 32 fprintf(stderr,"%s\n",message); 32 33 } 34 mr_msg_close(); 33 35 exit(errorcode); 34 36 } -
branches/2.2.10/mondo/src/lib/mr_mem.c
r2316 r2320 57 57 58 58 ssize_t ret; 59 ssize_t *n;59 ssize_t n = 0; 60 60 61 ret = getline(lineptr, n,fd);61 ret = getline(lineptr,&n,fd); 62 62 if ((ret == -1) && (! feof(fd))) { 63 63 mr_msg_int(1,line,file,"Unable to alloc memory in mr_getline\nExiting..."); -
branches/2.2.10/mondo/src/mondoarchive/mondoarchive.c
r2291 r2320 54 54 struct s_bkpinfo *bkpinfo; 55 55 56 /* No cleanup for the moment*/57 void (*mr_cleanup)( void) = NULL;56 /* Make cleanup the finish function */ 57 void (*mr_cleanup)(int) = finish; 58 58 59 59 /* To be coded */ -
branches/2.2.10/mondo/src/mondorestore/mondorestore.c
r2316 r2320 21 21 extern void twenty_seconds_til_yikes(void); 22 22 23 /* We don't have a cleanup function yet */24 void (*mr_cleanup)( void) = NULL;23 /* Let mr_cleanup pojnt to finish for the moment */ 24 void (*mr_cleanup)(int) = finish; 25 25 26 26 /* Reference to global bkpinfo */ -
branches/2.2.10/mondo/test/test-mountlist.c
r2235 r2320 44 44 extern int copy_from_src_to_dest(FILE * f_orig, FILE * f_archived, char direction); 45 45 /* We don't have a cleanup function yet */ 46 void (*mr_cleanup)( void) = NULL;46 void (*mr_cleanup)(int) = NULL; 47 47 48 48 void main() { -
branches/2.2.10/mondo/test/test-truncname.c
r2236 r2320 43 43 extern char *truncate_to_drive_name(char *); 44 44 /* We don't have a cleanup function yet */ 45 void (*mr_cleanup)( void) = NULL;45 void (*mr_cleanup)(int) = NULL; 46 46 void free_MR_global_filenames() { 47 47 }
Note:
See TracChangeset
for help on using the changeset viewer.