Changeset 2241 in MondoRescue for branches/2.2.9/mondo/src/common
- Timestamp:
- Jun 29, 2009, 7:19:14 PM (16 years ago)
- Location:
- branches/2.2.9/mondo/src/common
- Files:
-
- 2 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.9/mondo/src/common/Makefile.am
r1930 r2241 25 25 libmondo-string-EXT.h libmondo-tools-EXT.h \ 26 26 libmondo-verify-EXT.h libmondo-stream-EXT.h libmondo-cli-EXT.h \ 27 newt-specific.h \ 28 mr_string.c mr_string.h 27 newt-specific.h -
branches/2.2.9/mondo/src/common/libmondo-archive.c
r2230 r2241 541 541 542 542 assert(bkpinfo != NULL); 543 malloc_string(last_filelist_number);544 545 543 mr_asprintf(&tmp, 546 544 "echo '%s' | tr -s ' ' '\n' | grep -E '^/dev/.*$' | tr -s '\n' ' ' | awk '{print $0\"\\n\";}'", … … 2035 2033 char *tmp = NULL; 2036 2034 char *bigfile_fname; 2037 char *sz_devfile ;2035 char *sz_devfile = NULL; 2038 2036 char *ntfsprog_fifo = NULL; 2039 2037 /*@ long *********************************************** */ … … 2055 2053 2056 2054 malloc_string(bigfile_fname); 2057 malloc_string(sz_devfile);2058 2055 estimated_total_noof_slices = 2059 2056 size_of_all_biggiefiles_K() / bkpinfo->optimal_set_size + 1; … … 2111 2108 "Calling ntfsclone in background because %s is an NTFS partition", 2112 2109 bigfile_fname); 2113 sprintf(sz_devfile, "%s/%d.%d.000",2110 mr_asprintf(&sz_devfile, "%s/%d.%d.000", 2114 2111 bkpinfo->tmpdir, 2115 2112 (int) (random() % 32768), … … 2119 2116 switch (pid = fork()) { 2120 2117 case -1: 2118 mr_free(sz_devfile); 2121 2119 fatal_error("Fork failure"); 2122 2120 case 0: … … 2125 2123 bigfile_fname, sz_devfile); 2126 2124 res = feed_into_ntfsprog(bigfile_fname, sz_devfile); 2125 /* BCO/BERLIOS Does the child need to unalocate memory as well ? 2126 paranoid_free(bigfile_fname); 2127 mr_free(sz_devfile); 2128 */ 2127 2129 exit(res); 2128 2130 break; … … 2131 2133 "feed_into_ntfsprog() called in background --- pid=%ld", 2132 2134 (long int) (pid)); 2135 mr_free(sz_devfile); 2133 2136 } 2134 2137 } 2135 2138 // Otherwise, use good old 'dd' and 'bzip2' 2136 2139 else { 2137 sz_devfile[0] = '\0';2138 2140 ntfsprog_fifo = NULL; 2139 2141 } … … 2188 2190 paranoid_fclose(fin); 2189 2191 paranoid_free(bigfile_fname); 2190 paranoid_free(sz_devfile);2191 2192 return (retval); 2192 2193 } -
branches/2.2.9/mondo/src/common/libmondo-cli.c
r2229 r2241 13 13 #include "my-stuff.h" 14 14 #include "mr_mem.h" 15 #include "mr_str ing.h"15 #include "mr_str.h" 16 16 #include "mondostructures.h" 17 17 #include "libmondo-cli-EXT.h" … … 297 297 log_msg (4, "Could not get the list of mounted file systems"); 298 298 paranoid_free(mounted_file_system); 299 mr_free(token); 299 300 return (1); 300 301 } 301 log_msg (5, "token: %s", token); 302 if (token) { 303 log_msg (5, "token: %s", token); 304 } 302 305 while (token != NULL) { 303 306 log_msg (5, "token: %s", token); … … 307 310 add_mounted_fs_struct(DSFptr); 308 311 strcpy(DSFptr->device, token); 312 mr_free(token); 309 313 if ((token = strtok(NULL, token_chars)) == NULL) { 310 314 log_msg (5, "Ran out of entries on the mounted file systems list"); 311 315 paranoid_free(mounted_file_system); 316 mr_free(token); 312 317 return (1); 313 318 } 314 319 log_msg (5, "token: %s", token); 315 320 strcpy(DSFptr->mount_point, token); 321 mr_free(token); 316 322 token = strtok(NULL, token_chars); 317 323 } … … 410 416 log_msg (5, "Found partition: %s", token); 411 417 strcpy(partitions[i++], token); 418 mr_free(token); 412 419 } 413 420 paranoid_free(partition_list); … … 507 514 log_msg (4, "Can't find mount point %s in mounted file systems list", token); 508 515 paranoid_free(tmp); 516 mr_free(token); 509 517 return (1); 510 518 } 511 519 DSFptr->check = 1; 520 mr_free(token); 512 521 } 513 522 /******** … … 535 544 log_msg (4, "Can't find device %s in mounted file systems list", token); 536 545 paranoid_free(tmp); 546 mr_free(token); 537 547 return (1); 538 548 } … … 540 550 } 541 551 } 552 mr_free(token); 542 553 paranoid_free(mount_list); 543 554 } else { … … 588 599 log_msg (4, "Can't find device %s in mounted file systems list", token); 589 600 paranoid_free(tmp); 601 mr_free(token); 590 602 return (1); 591 603 } … … 593 605 break; 594 606 } 607 mr_free(token); 595 608 } 596 609 paranoid_free(tmp); … … 806 819 break; 807 820 } 821 mr_free(token); 808 822 } 809 823 log_msg(1, "include_paths is now '%s'", bkpinfo->include_paths); … … 1137 1151 break; 1138 1152 } 1153 mr_free(token); 1139 1154 } 1140 1155 log_msg(1, "exclude_paths is now '%s'", bkpinfo->exclude_paths); -
branches/2.2.9/mondo/src/common/libmondo-devices.c
r2226 r2241 2406 2406 { 2407 2407 /*@ buffer ***************************************************** */ 2408 char *list_drives_cmd ;2408 char *list_drives_cmd = NULL; 2409 2409 char *current_drive; 2410 2410 … … 2418 2418 /*@ end vars *************************************************** */ 2419 2419 2420 malloc_string(list_drives_cmd);2421 2420 malloc_string(current_drive); 2422 2421 … … 2426 2425 #endif 2427 2426 assert(which_device != NULL); 2428 // sprintf (list_drives_cmd, 2429 // "fdisk -l | grep /dev | grep cyl | tr ':' ' ' | cut -d' ' -f2"); 2430 2431 sprintf(list_drives_cmd, 2427 2428 mr_asprintf(&list_drives_cmd, 2432 2429 "parted2fdisk -l 2>/dev/null | grep \"/dev/.*:\" | tr -s ':' ' ' | tr -s ' ' '\n' | grep /dev/; echo %s", 2433 2430 where_is_root_mounted()); … … 2436 2433 if (!(pdrives = popen(list_drives_cmd, "r"))) { 2437 2434 log_OS_error("Unable to open list of drives"); 2438 paranoid_free(list_drives_cmd);2435 mr_free(list_drives_cmd); 2439 2436 paranoid_free(current_drive); 2440 2437 return ('\0'); 2441 2438 } 2439 mr_free(list_drives_cmd); 2440 2442 2441 for ((void)fgets(current_drive, MAX_STR_LEN, pdrives); !feof(pdrives); 2443 2442 (void)fgets(current_drive, MAX_STR_LEN, pdrives)) { … … 2460 2459 log_it("%d grubs and %d lilos\n", count_grubs, count_lilos); 2461 2460 if (count_grubs && !count_lilos) { 2461 paranoid_free(current_drive); 2462 2462 return ('G'); 2463 2463 } else if (count_lilos && !count_grubs) { 2464 paranoid_free(current_drive); 2464 2465 return ('L'); 2465 2466 } else if (count_grubs == 1 && count_lilos == 1) { 2466 2467 log_it("I'll bet you used to use LILO but switched to GRUB..."); 2468 paranoid_free(current_drive); 2467 2469 return ('G'); 2468 2470 } else { 2469 2471 // We need to look on each partition then 2470 sprintf(list_drives_cmd,2472 mr_asprintf(&list_drives_cmd, 2471 2473 "parted2fdisk -l 2>/dev/null | grep -E \"^/dev/\" | tr -s ':' ' ' | tr -s ' ' '\n' | grep /dev/"); 2472 2474 log_it("list_drives_cmd = %s", list_drives_cmd); … … 2474 2476 if (!(pdrives = popen(list_drives_cmd, "r"))) { 2475 2477 log_OS_error("Unable to open list of drives"); 2476 paranoid_free(list_drives_cmd);2478 mr_free(list_drives_cmd); 2477 2479 paranoid_free(current_drive); 2478 2480 return ('\0'); 2479 2481 } 2482 mr_free(list_drives_cmd); 2483 2480 2484 for ((void)fgets(current_drive, MAX_STR_LEN, pdrives); !feof(pdrives); 2481 2485 (void)fgets(current_drive, MAX_STR_LEN, pdrives)) { … … 2497 2501 } 2498 2502 log_it("%d grubs and %d lilos\n", count_grubs, count_lilos); 2499 paranoid_free(list_drives_cmd);2500 2503 paranoid_free(current_drive); 2501 2504 if (count_grubs && !count_lilos) { -
branches/2.2.9/mondo/src/common/libmondo-filelist.c
r2230 r2241 17 17 #include "libmondo-gui-EXT.h" 18 18 #include "libmondo-tools-EXT.h" 19 #include "mr_string.h"20 19 #include "mr_mem.h" 20 #include "mr_str.h" 21 21 22 22 #include <time.h> … … 1383 1383 if (p) { 1384 1384 if (!strcmp(p, "/.") || !strcmp(p, "/..")) { 1385 mr_free(dir); 1385 1386 return (0); 1386 1387 } … … 1396 1397 mr_asprintf(&find_excludes,"%s -path %s -prune -o", strtmp, token); 1397 1398 paranoid_free(strtmp); 1398 paranoid_free(token);1399 mr_free(token); 1399 1400 } 1400 1401 #if linux … … 1517 1518 paranoid_free(new_with_spaces); 1518 1519 paranoid_free(skip_these); 1519 paranoid_free(dir);1520 mr_free(dir); 1520 1521 1521 1522 if (dip) { -
branches/2.2.9/mondo/src/common/libmondo-raid.c
r2211 r2241 17 17 #include "lib-common-externs.h" 18 18 #include "libmondo-raid.h" 19 #include "mr_string.h"20 19 #include "mr_mem.h" 20 #include "mr_str.h" 21 21 22 22 #ifdef __FreeBSD__ … … 1037 1037 strcpy(raidlist->el[raidlist->entries].raid_device, strtmp); 1038 1038 paranoid_free(strtmp); 1039 paranoid_free(token);1039 mr_free(token); 1040 1040 // skip ':' and status 1041 1041 token = mr_strtok (string, delims, &lastpos); 1042 paranoid_free(token);1042 mr_free(token); 1043 1043 token = mr_strtok (string, delims, &lastpos); 1044 1044 if (!strcmp(token, "inactive")) { … … 1046 1046 raidlist->el[raidlist->entries].raid_device); 1047 1047 paranoid_free(string); 1048 paranoid_free(token);1048 mr_free(token); 1049 1049 return 1; 1050 1050 } 1051 paranoid_free(token);1051 mr_free(token); 1052 1052 1053 1053 // get RAID level … … 1075 1075 return 1; 1076 1076 } 1077 paranoid_free(token);1077 mr_free(token); 1078 1078 1079 1079 // get RAID devices (type, index, device) … … 1120 1120 break; 1121 1121 } 1122 paranoid_free(token);1122 mr_free(token); 1123 1123 } 1124 1124 -
branches/2.2.9/mondo/src/common/libmondo-string.c
r2237 r2241 1145 1145 * @note The returned string points to static storage that will be overwritten with each call. 1146 1146 */ 1147 /* BCO/BERLIOS change that function to allocate memory, return a pointer and modify caller to free the mem */ 1147 1148 char *media_descriptor_string(t_bkptype type_of_bkp) 1148 1149 { -
branches/2.2.9/mondo/src/common/libmondo-tools.c
r2230 r2241 83 83 84 84 extern bool am_I_in_disaster_recovery_mode(void); 85 86 /* Return a string containing the date */87 char *mr_date(void) {88 89 time_t tcurr;90 91 tcurr = time(NULL);92 return(ctime(&tcurr));93 }94 85 95 86 /*-----------------------------------------------------------*/ … … 1411 1402 paranoid_free(g_magicdev_command); 1412 1403 1413 mr_free(bkpinfo->nfs_user);1414 1404 } 1415 1405 -
branches/2.2.9/mondo/src/common/newt-specific.c
r2230 r2241 368 368 } 369 369 370 /* Free memory allocated for newt */ 371 void free_newt_stuff() { 372 373 int i; 374 375 for (i = 0; i < g_noof_log_lines; i++) { 376 mr_free(err_log_lines[i]); 377 } 378 mr_free(err_log_lines); 379 } 380 370 381 371 382 … … 405 416 printf("Execution run ended; result=%d\n", signal); 406 417 printf("Type 'less %s' to see the output log\n", MONDO_LOGFILE); 407 if (strstr(bkpinfo->tmpdir ,"mondo.tmp.") != NULL) { 408 mr_asprintf(&command, "rm -Rf %s %s", bkpinfo->tmpdir, bkpinfo->scratchdir); 409 system(command); 410 paranoid_free(command); 411 } 418 if (bkpinfo->tmpdir) { 419 log_msg(8,"tempdir is %s",bkpinfo->tmpdir); 420 if (strstr(bkpinfo->tmpdir ,"mondo.tmp.") != NULL) { 421 log_msg(8,"erasing tempdir"); 422 mr_asprintf(&command, "rm -Rf %s", bkpinfo->tmpdir); 423 system(command); 424 paranoid_free(command); 425 } 426 } 427 if (bkpinfo->scratchdir) { 428 log_msg(8,"scratchdir is %s", bkpinfo->scratchdir); 429 if (strstr(bkpinfo->scratchdir ,"mondo.scratch.") != NULL) { 430 log_msg(8,"erasing scratchdir"); 431 mr_asprintf(&command, "rm -Rf %s", bkpinfo->scratchdir); 432 system(command); 433 paranoid_free(command); 434 } 435 } 436 /* Free all allocated strings in bkpinfo */ 437 mr_free(bkpinfo->nfs_user); 438 439 /* Then free the structure */ 412 440 paranoid_free(bkpinfo); 413 441 free_libmondo_global_strings(); 442 free_newt_stuff(); 414 443 exit(signal); 415 444 }
Note:
See TracChangeset
for help on using the changeset viewer.