Changeset 2334 in MondoRescue
- Timestamp:
- Aug 18, 2009, 5:28:18 PM (15 years ago)
- Location:
- branches/2.2.10
- Files:
-
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/common/libmondo-archive-EXT.h
r1885 r2334 10 10 extern int do_that_initial_phase(); 11 11 extern int do_that_final_phase(); 12 extern int figure_out_kernel_path_interactively_if_necessary(char *kernel);12 extern char *figure_out_kernel_path_interactively_if_necessary(void); 13 13 extern int make_those_slices_phase(); 14 14 extern int make_those_afios_phase(); -
branches/2.2.10/mondo/src/common/libmondo-archive.c
r2331 r2334 441 441 442 442 copy_mondo_and_mindi_stuff_to_scratchdir(); // payload, too, if it exists 443 mr_free(bkpinfo->kernel_path); 443 444 #if __FreeBSD__ == 5 444 445 mr_asprintf(bkpinfo->kernel_path, "/boot/kernel/kernel"); … … 446 447 mr_asprintf(bkpinfo->kernel_path, "/kernel"); 447 448 #elif linux 448 if ( figure_out_kernel_path_interactively_if_necessary(bkpinfo->kernel_path)) {449 if ((bkpinfo->kernel_path = figure_out_kernel_path_interactively_if_necessary()) == NULL) { 449 450 fatal_error("Kernel not found. Please specify manually with the '-k' switch."); 450 451 } … … 854 855 use_gzip_sz); // parameter #20 (STRING) 855 856 857 mr_free(tmp2); 856 858 mr_free(devs_to_exclude); 857 859 mr_free(last_filelist_number); -
branches/2.2.10/mondo/src/common/libmondo-archive.h
r1885 r2334 11 11 int do_that_initial_phase(); 12 12 int do_that_final_phase(); 13 int figure_out_kernel_path_interactively_if_necessary(char *kernel);13 char *figure_out_kernel_path_interactively_if_necessary(void); 14 14 bool get_bit_N_of_array(char *array, int N); 15 15 int make_those_slices_phase(); -
branches/2.2.10/mondo/src/common/libmondo-cli.c
r2332 r2334 886 886 if ((flag_set['t'] && !flag_set['d']) && (! bkpinfo->restore_data)) { 887 887 log_it("Hmm! No tape drive specified. Let's see what we can do."); 888 if ((tmp1 = find_tape_device_and_size(NULL)) == NULL) {888 if ((tmp1 = mr_find_tape_device()) == NULL) { 889 889 fatal_error("Tape device not specified. I couldn't find it either."); 890 890 } … … 1191 1191 1192 1192 if (flag_set['x']) { 1193 mr_asprintf(bkpinfo->image_devs, flag_val['x']);1193 mr_asprintf(bkpinfo->image_devs, "%s", flag_val['x']); 1194 1194 if ((run_program_and_log_output("which ntfsclone", 2)) && (! bkpinfo->restore_data)) { 1195 1195 fatal_error("Please install ntfsprogs package/tarball."); … … 1202 1202 1203 1203 if ((flag_set['k']) && (! bkpinfo->restore_data)) { 1204 mr_free(bkpinfo->kernel_path); 1204 1205 mr_asprintf(bkpinfo->kernel_path, "%s", flag_val['k']); 1205 1206 if (!strcmp(bkpinfo->kernel_path, "failsafe")) { … … 1552 1553 case SIGKILL: 1553 1554 mr_asprintf(tmp, "SIGKILL"); 1554 mr_asprintf(tmp2, 1555 "I seriously have no clue how this signal even got to me. Something's wrong with your system."); 1555 mr_asprintf(tmp2, "I seriously have no clue how this signal even got to me. Something's wrong with your system."); 1556 1556 break; 1557 1557 case SIGTERM: … … 1565 1565 case SIGSEGV: 1566 1566 mr_asprintf(tmp, "SIGSEGV"); 1567 mr_asprintf(tmp2, 1568 "Internal programming error. Please send a backtrace as well as your log."); 1567 mr_asprintf(tmp2, "Internal programming error. Please send a backtrace as well as your log."); 1569 1568 break; 1570 1569 case SIGPIPE: -
branches/2.2.10/mondo/src/common/libmondo-devices.c
r2332 r2334 131 131 mr_free(tmp); 132 132 133 if (is_this_a_ramdisk) {134 if (!does_file_exist("/THIS-IS-A-RAMDISK")) {135 log_to_screen("Using /dev/root is stupid of you but I'll forgive you.");136 is_this_a_ramdisk = FALSE;137 }138 }139 if (does_file_exist("/THIS-IS-A-RAMDISK")) {140 is_this_a_ramdisk = TRUE;141 }142 133 log_msg(1, "Is this a ramdisk? result = %s", (is_this_a_ramdisk) ? "TRUE" : "FALSE"); 143 134 return (is_this_a_ramdisk); … … 515 506 516 507 if (g_cdrw_drive_is_here[0]) { 517 mr_asprintf(cdrw_device, g_cdrw_drive_is_here);508 mr_asprintf(cdrw_device, "%s", g_cdrw_drive_is_here); 518 509 log_msg(3, "Been there, done that. Returning %s", cdrw_device); 519 510 return(cdrw_device); … … 840 831 841 832 if (g_dvd_drive_is_here[0]) { 842 mr_asprintf(output, g_dvd_drive_is_here);833 mr_asprintf(output, "%s", g_dvd_drive_is_here); 843 834 log_msg(3, "Been there, done that. Returning %s", output); 844 835 return (output); … … 1599 1590 1600 1591 mr_free(bkpinfo->media_device); 1601 if ((!bkpinfo->restore_mode) && ((bkpinfo->media_device = find_tape_device_and_size(NULL)) == NULL)) {1592 if ((!bkpinfo->restore_mode) && ((bkpinfo->media_device = mr_find_tape_device()) == NULL)) { 1602 1593 log_msg(3, "Ok, using vanilla scsi tape."); 1603 1594 mr_asprintf(bkpinfo->media_device, "%s", VANILLA_SCSI_TAPE); … … 1641 1632 mr_free(tmp); 1642 1633 1643 bkpinfo->use_obdr = ask_me_yes_or_no 1644 ("Do you want to activate OBDR support for your tapes ?"); 1634 bkpinfo->use_obdr = ask_me_yes_or_no("Do you want to activate OBDR support for your tapes ?"); 1645 1635 bkpinfo->media_size[0] = 0; 1646 1636 log_msg(4, "media_size[0] = %ld", bkpinfo->media_size[0]); -
branches/2.2.10/mondo/src/common/libmondo-files-EXT.h
r2325 r2334 11 11 extern bool does_file_exist(char *filename); 12 12 extern void exclude_nonexistent_files(char *inout); 13 extern int figure_out_kernel_path_interactively_if_necessary(char *kernel);13 extern char *figure_out_kernel_path_interactively_if_necessary(void); 14 14 extern char *find_home_of_exe(char *fname); 15 15 extern int get_trackno_from_logfile(char *logfile); -
branches/2.2.10/mondo/src/common/libmondo-files.c
r2332 r2334 269 269 * @return 0 for success, 1 for failure. 270 270 */ 271 int figure_out_kernel_path_interactively_if_necessary(char *kernel) 272 { 271 char *figure_out_kernel_path_interactively_if_necessary(void) { 272 273 273 char *tmp = NULL; 274 274 char *command = NULL;; 275 276 if (kernel == NULL) { 277 278 }275 char *kernel = NULL;; 276 277 mr_asprintf(kernel, "%s", call_program_and_get_last_line_of_output("mindi --findkernel 2> /dev/null")); 278 279 279 // If we didn't get anything back, check whether mindi raised a fatal error 280 280 if (!kernel[0]) { … … 285 285 mr_free(tmp); 286 286 mr_free(command); 287 mr_free(kernel); 287 288 fatal_error("Mindi gave a fatal error. Please check '/var/log/mindi.log'."); 288 289 } … … 293 294 while (!kernel[0]) { 294 295 if (!ask_me_yes_or_no("Kernel not found or invalid. Choose another?")) { 295 return ( 1);296 return (NULL); 296 297 } 297 298 tmp = popup_and_get_string("Kernel path", "What is the full path and filename of your kernel, please?", kernel); … … 304 305 log_it("User says kernel is at %s", kernel); 305 306 } 306 return ( 0);307 return (kernel); 307 308 } 308 309 … … 1103 1104 } 1104 1105 *(p++) = '\0'; 1105 mr_asprintf(nfs_server_ipaddr, tmp);1106 mr_asprintf(nfs_mount, p);1106 mr_asprintf(nfs_server_ipaddr, "%s", tmp); 1107 mr_asprintf(nfs_mount, "%s", p); 1107 1108 mr_free(tmp); 1108 1109 … … 1151 1152 mr_free(nfs_dev); 1152 1153 1153 mr_asprintf(nfs_dev, call_program_and_get_last_line_of_output(command));1154 mr_asprintf(nfs_dev, "%s", call_program_and_get_last_line_of_output(command)); 1154 1155 mr_free(command); 1155 1156 -
branches/2.2.10/mondo/src/common/libmondo-files.h
r2325 r2334 14 14 bool does_file_exist(char *filename); 15 15 void exclude_nonexistent_files(char *inout); 16 int figure_out_kernel_path_interactively_if_necessary(char *kernel);16 char *figure_out_kernel_path_interactively_if_necessary(void); 17 17 char *find_home_of_exe(char *fname); 18 18 int get_trackno_from_logfile(char *logfile); -
branches/2.2.10/mondo/src/common/libmondo-raid.c
r2324 r2334 334 334 #ifdef __FreeBSD__ 335 335 int i, j; 336 char *org = NULL; 336 337 337 338 fprintf(fout, "\nvolume %s\n", raidrec->volname); 338 339 for (i = 0; i < raidrec->plexes; ++i) { 339 char org[24];340 340 switch (raidrec->plex[i].raidlevel) { 341 341 case -1: 342 strcpy(org, "concat");342 mr_asprintf(org, "concat"); 343 343 break; 344 344 case 0: 345 strcpy(org, "striped");345 mr_asprintf(org, "striped"); 346 346 break; 347 347 case 5: 348 strcpy(org, "raid5");348 mr_asprintf(org, "raid5"); 349 349 break; 350 350 } 351 351 fprintf(fout, " plex org %s", org); 352 mr_free(org); 353 352 354 if (raidrec->plex[i].raidlevel != -1) { 353 355 fprintf(fout, " %ik", raidrec->plex[i].stripesize); … … 356 358 357 359 for (j = 0; j < raidrec->plex[i].subdisks; ++j) { 358 fprintf(fout, " sd drive %s size 0\n", 359 raidrec->plex[i].sd[j].which_device); 360 fprintf(fout, " sd drive %s size 0\n", raidrec->plex[i].sd[j].which_device); 360 361 } 361 362 } … … 501 502 502 503 if (get_option_state(argc, argv, "hotspare")) { 503 strcpy(raidlist->spares.el[raidlist->spares.entries].name, 504 drivename); 505 strcpy(raidlist->spares.el[raidlist->spares.entries]. 506 device, devname); 504 strcpy(raidlist->spares.el[raidlist->spares.entries].name, drivename); 505 strcpy(raidlist->spares.el[raidlist->spares.entries]. device, devname); 507 506 raidlist->spares.el[raidlist->spares.entries].index = 508 507 raidlist->disks.entries; 509 508 raidlist->spares.entries++; 510 509 } else { 511 strcpy(raidlist->disks.el[raidlist->disks.entries].name, 512 drivename); 513 strcpy(raidlist->disks.el[raidlist->disks.entries].device, 514 devname); 510 strcpy(raidlist->disks.el[raidlist->disks.entries].name, drivename); 511 strcpy(raidlist->disks.el[raidlist->disks.entries].device, devname); 515 512 raidlist->disks.el[raidlist->disks.entries].index = 516 513 raidlist->disks.entries; -
branches/2.2.10/mondo/src/common/libmondo-stream-EXT.h
r2332 r2334 5 5 extern int closein_tape(); 6 6 extern int closeout_tape(); 7 extern char * find_tape_device_and_size(char *siz);7 extern char *mr_find_tape_device(void); 8 8 extern void insist_on_this_tape_number(int tapeno); 9 9 extern void log_tape_pos(void); -
branches/2.2.10/mondo/src/common/libmondo-stream.c
r2332 r2334 253 253 char *dev = NULL; 254 254 int res; 255 char *dev = NULL;256 255 257 256 log_to_screen("I am looking for your tape streamer. Please wait."); … … 260 259 if (tmp) { 261 260 mr_asprintf(cdr_exe, "cdrecord"); 262 263 261 } else { 264 262 mr_asprintf(cdr_exe, "dvdrecord"); … … 273 271 log_it("Either too few or too many tape streamers for me to detect..."); 274 272 mr_asprintf(dev, "%s", VANILLA_SCSI_TAPE); 275 mr_free(tmp);276 273 mr_free(tmp); 277 274 return(dev); … … 350 347 } else { 351 348 log_it("At this new point, dev is NULL and res = %d", res); 352 mr_free(tmp);353 349 } 354 350 … … 531 527 char *tmpdir = NULL; 532 528 char *old_fname = NULL; 533 char *p;534 char suffix[16];535 529 536 530 bufsize_K = (long long) (1024LL * (1 + g_tape_buffer_size_MB)); 537 if ((p = strrchr(latest_fname, '.'))) {538 strcpy(suffix, ++p);539 } else {540 suffix[0] = '\0';541 }542 531 if (strstr(latest_fname, ".afio.") || strstr(latest_fname, ".star.")) { 543 532 type = fileset; … … 1186 1175 g_tape_stream) / 1024; 1187 1176 } 1188 /* memcpy((char*)plength_of_incoming_file,(char*)tempblock+7001,sizeof(long long)); */1189 /* for(*plen=0,i=7;i>=0;i--) {*plen<<=8; *plen |= tempblock[7001+i];} */1190 1177 memcpy((char *) plen, tempblock + 7001, sizeof(long long)); 1191 1178 if (strcmp(tempblock + 6000 + *pcontrol_char, STR_HEADER)) { … … 1193 1180 } 1194 1181 strcpy(filename, tempblock + 1000); 1195 /* strcpy(cksum,tempblock+5555);*/1196 /* log_it( "%s (reading) fname=%s, filesize=%ld K",1197 marker_to_string (*pcontrol_char), filename,1198 (long) ((*plen) >> 10));1199 */1200 1182 if (*pcontrol_char == BLK_ABORTED_BACKUP) { 1201 1183 log_to_screen("I can't verify an aborted backup."); -
branches/2.2.10/mondo/src/common/libmondo-stream.h
r2332 r2334 7 7 int closein_tape(); 8 8 int closeout_tape(); 9 char * find_tape_device_and_size(char *siz);9 char *mr_find_tape_device(void); 10 10 void insist_on_this_tape_number(int tapeno); 11 11 void log_tape_pos(void); -
branches/2.2.10/mondo/src/common/libmondo-string.c
r2323 r2334 45 45 assert(partno >= 0); 46 46 47 mr_asprintf(partition, drive);47 mr_asprintf(partition, "%s", drive); 48 48 /* is this a devfs device path? */ 49 49 c = strrchr(partition, '/'); -
branches/2.2.10/mondo/src/common/libmondo-tools.c
r2332 r2334 170 170 void clean_up_KDE_desktop_if_necessary(void) 171 171 { 172 char *tmp; 173 174 malloc_string(tmp); 175 strcpy(tmp, 176 "for i in `find /root /home -type d -name Desktop -maxdepth 2`; do \ 177 file=$i/.directory; if [ -f \"$file\" ] ; then mv -f $file $file.old ; \ 178 awk '{if (index($0, \"rootimagesmindi\")) { while (length($0)>2) { getline;} ; } \ 179 else { print $0;};}' $file.old > $file ; fi ; done"); 172 char *tmp = NULL; 173 174 mr_asprintf(tmp, "for i in `find /root /home -type d -name Desktop -maxdepth 2`; do file=$i/.directory; if [ -f \"$file\" ] ; then mv -f $file $file.old ; awk '{if (index($0, \"rootimagesmindi\")) { while (length($0)>2) { getline;} ; } else { print $0;};}' $file.old > $file ; fi ; done"); 180 175 run_program_and_log_output(tmp, 5); 181 paranoid_free(tmp);176 mr_free(tmp); 182 177 } 183 178 … … 227 222 double get_kernel_version(void) 228 223 { 229 char *p, tmp[200]; 224 char *p = NULL; 225 char *tmp = NULL; 230 226 double d; 231 227 #ifdef __FreeBSD__ … … 233 229 d = 5.2; // :-) 234 230 #else 235 strcpy(tmp, call_program_and_get_last_line_of_output("uname -r"));231 mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("uname -r")); 236 232 p = strchr(tmp, '.'); 237 233 if (p) { … … 244 240 } 245 241 } 246 // log_msg(1, "tmp = '%s'", tmp);247 242 d = atof(tmp); 243 mr_free(tmp); 248 244 #endif 249 245 log_msg(1, "g_kernel_version = %f", d); … … 252 248 253 249 254 255 256 257 250 /** 258 251 * Get the current time. … … 263 256 return (long) time((void *) 0); 264 257 } 265 266 267 268 269 270 258 271 259 … … 411 399 char *command = NULL; 412 400 char *mtpt; 413 char *hostname ;401 char *hostname = NULL; 414 402 char *ip_address = NULL; 415 403 int retval = 0; 416 404 char *colon; 417 char *cdr_exe ;405 char *cdr_exe = NULL; 418 406 char *tmp = NULL; 419 407 char *p = NULL; … … 431 419 432 420 malloc_string(mtpt); 433 malloc_string(hostname);434 malloc_string(cdr_exe);435 421 bkpinfo->optimal_set_size = 436 422 (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type) ? 16 : 16) * … … 496 482 tmp = find_home_of_exe("growisofs"); 497 483 if (tmp) { 498 strcpy(cdr_exe, "growisofs");484 mr_asprintf(cdr_exe, "growisofs"); 499 485 } // unlikely to be used 500 486 else { … … 560 546 tmp = find_home_of_exe("cdrecord"); 561 547 if (tmp) { 562 strcpy(cdr_exe, "cdrecord");548 mr_asprintf(cdr_exe, "cdrecord"); 563 549 } else { 564 550 mr_free(tmp); 565 551 tmp = find_home_of_exe("dvdrecord"); 566 552 if (tmp) { 567 strcpy(cdr_exe, "dvdrecord");553 mr_asprintf(cdr_exe, "dvdrecord"); 568 554 } else { 569 555 mr_free(tmp); … … 590 576 } 591 577 #endif 592 else 593 { 578 else { 594 579 mr_asprintf(mondo_mkisofs_sz, MONDO_MKISOFS_REGULAR_SYSLINUX); 595 580 } … … 613 598 mr_asprintf(bkpinfo->call_make_iso, "%s . 2>> _ERR_ | %s %s %s fs=4m dev=%s speed=%d -", mondo_mkisofs_sz, cdr_exe, (bkpinfo->please_dont_eject) ? " " : "-eject", extra_cdrom_params, bkpinfo->media_device, bkpinfo->cdrw_speed); 614 599 } 600 mr_free(cdr_exe); 615 601 paranoid_free(mondo_mkisofs_sz); 616 602 paranoid_free(extra_cdrom_params); … … 654 640 mr_asprintf(iso_path, "%s", iso_tmp + strlen(iso_mnt)); 655 641 } 642 mr_free(iso_mnt); 656 643 mr_free(iso_tmp); 657 644 … … 674 661 if (bkpinfo->backup_media_type == nfs) { 675 662 if (bkpinfo->nfs_mount) { 676 strcpy(hostname, bkpinfo->nfs_mount);663 mr_asprintf(hostname, "%s", bkpinfo->nfs_mount); 677 664 } else { 678 665 log_it("nfs_mount is NULL"); 679 666 retval++; 680 strcpy(hostname, "");667 mr_asprintf(hostname, ""); 681 668 } 682 669 colon = strchr(hostname, ':'); … … 699 686 } 700 687 } 688 mr_free(hostname); 701 689 store_nfs_config(); 702 690 } … … 712 700 g_backup_media_type = bkpinfo->backup_media_type; 713 701 paranoid_free(mtpt); 714 paranoid_free(hostname);715 paranoid_free(cdr_exe);716 702 return (retval); 717 703 } … … 1254 1240 mr_asprintf(command, "mount | grep -Ew '/boot'"); 1255 1241 mr_free(tmp); 1256 mr_asprintf(tmp, call_program_and_get_last_line_of_output(command));1242 mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command)); 1257 1243 mr_free(command); 1258 1244 -
branches/2.2.10/mondo/src/common/libmondo-verify.c
r2327 r2334 623 623 /*@ char ************************************************************ */ 624 624 char *test_file = NULL; 625 char *biggie_cksum ;626 char *orig_cksum ;625 char *biggie_cksum = NULL; 626 char *orig_cksum = NULL; 627 627 char *tmp = NULL; 628 628 char *slice_fnam; … … 634 634 long long slice_siz; 635 635 636 malloc_string(biggie_cksum);637 malloc_string(orig_cksum);638 636 malloc_string(slice_fnam); 639 637 assert(bkpinfo != NULL); … … 651 649 ctrl_chr != BLK_STOP_A_BIGGIE; 652 650 res = 653 read_header_block_from_stream(&slice_siz, slice_fnam, 654 &ctrl_chr)) { 651 read_header_block_from_stream(&slice_siz, slice_fnam, &ctrl_chr)) { 655 652 if (ctrl_chr != BLK_START_AN_AFIO_OR_SLICE) { 656 653 wrong_marker(BLK_START_AN_AFIO_OR_SLICE, ctrl_chr); … … 659 656 unlink(test_file); 660 657 res = 661 read_header_block_from_stream(&slice_siz, slice_fnam, 662 &ctrl_chr); 658 read_header_block_from_stream(&slice_siz, slice_fnam, &ctrl_chr); 663 659 if (ctrl_chr != BLK_STOP_AN_AFIO_OR_SLICE) { 664 660 log_msg(2, "test_file = %s", test_file); … … 668 664 retval += res; 669 665 } 670 strcpy(biggie_cksum, slice_fnam);666 mr_asprintf(biggie_cksum, "%s", slice_fnam); 671 667 if (biggie_cksum[0] != '\0') { 672 strcpy(orig_cksum, calc_checksum_of_file(biggie_fname));668 mr_asprintf(orig_cksum, "%s", calc_checksum_of_file(biggie_fname)); 673 669 if (strcmp(biggie_cksum, orig_cksum)) { 674 670 log_msg(2, "orig cksum=%s; curr cksum=%s", biggie_cksum, orig_cksum); … … 680 676 } 681 677 } 678 mr_free(biggie_cksum); 682 679 mr_free(test_file); 683 paranoid_free(biggie_cksum); 684 paranoid_free(orig_cksum); 680 mr_free(orig_cksum); 685 681 paranoid_free(slice_fnam); 686 682 return (retval); -
branches/2.2.10/mondo/src/common/newt-specific.c
r2331 r2334 345 345 log_msg(0, "-------FATAL ERROR---------"); 346 346 log_msg(0, error_string); 347 newtFinished();348 347 } 349 348 … … 395 394 } 396 395 if (!g_text_mode) { 397 if (does_file_exist("/THIS-IS-A-RAMDISK")) { 398 log_msg(1, "Calling newtFinished()"); 399 newtFinished(); 400 } else { 401 log_msg(1, "Calling newtSuspend()"); 402 newtSuspend(); 403 } 396 log_msg(1, "Calling newtFinished()"); 397 newtFinished(); 404 398 } 405 399 printf("Execution run ended; result=%d\n", signal); … … 444 438 445 439 /*@ buffers ********************************************************** */ 446 char *command ;447 char *tmp ;440 char *command = NULL; 441 char *tmp = NULL; 448 442 449 443 /*@ pointers ********************************************************* */ … … 453 447 int i = 0; 454 448 455 malloc_string(command);456 malloc_string(tmp);457 449 assert_string_is_neither_NULL_nor_zerolength(filename); 458 450 assert(grep_for_me != NULL); 459 451 460 452 if (!does_file_exist(filename)) { 461 paranoid_free(command);462 paranoid_free(tmp);463 453 return; 464 454 } 465 455 if (grep_for_me[0] != '\0') { 466 sprintf(command, "grep '%s' %s | tail -n%d", 467 grep_for_me, filename, g_noof_log_lines); 468 } else { 469 sprintf(command, "tail -n%d %s", g_noof_log_lines, 470 filename); 456 mr_asprintf(command, "grep '%s' %s | tail -n%d", grep_for_me, filename, g_noof_log_lines); 457 } else { 458 mr_asprintf(command, "tail -n%d %s", g_noof_log_lines, filename); 471 459 } 472 460 fin = popen(command, "r"); … … 483 471 */ 484 472 if (!strncmp(err_log_lines[i], "root:", 5)) { 485 strcpy(tmp, err_log_lines[i] + 6);473 mr_asprintf(tmp, "%s", err_log_lines[i] + 6); 486 474 strcpy(err_log_lines[i], tmp); 475 mr_free(tmp); 487 476 } 488 477 if (feof(fin)) { … … 493 482 paranoid_pclose(fin); 494 483 } 484 mr_free(command); 495 485 refresh_log_screen(); 496 paranoid_free(command);497 paranoid_free(tmp);498 486 } 499 487 … … 584 572 585 573 /*@ buffers ********************************************************* */ 586 char *title ;587 char *tmp ;574 char *title = NULL; 575 char *tmp = NULL; 588 576 589 577 /*@ initialize ****************************************************** */ 590 578 g_isoform_old_progress = -1; 591 579 g_mysterious_dot_counter = 0; 592 malloc_string(title); 580 581 assert(ttl != NULL); 593 582 malloc_string(tmp); 594 595 assert(ttl != NULL); 596 strcpy(title, ttl); 583 mr_asprintf(title, "%s", ttl); 597 584 strcpy(g_isoform_header_str, title); 598 585 if (g_text_mode) { … … 620 607 } 621 608 update_evalcall_form(0); 609 mr_free(title); 622 610 paranoid_free(tmp); 623 paranoid_free(title);624 611 } 625 612 … … 641 628 /*@ buffers ********************************************************* */ 642 629 char *b1c; 643 char *blurb1 ;644 char *blurb2 ;645 char *blurb3 ;630 char *blurb1 = NULL; 631 char *blurb2 = NULL; 632 char *blurb3 = NULL; 646 633 647 634 /*@ initialize ****************************************************** */ 648 635 g_mysterious_dot_counter = 0; 649 636 650 malloc_string(b1c);651 637 malloc_string(blurb1); 652 638 malloc_string(blurb2); 653 639 malloc_string(blurb3); 640 malloc_string(b1c); 654 641 655 642 assert(title != NULL); … … 658 645 assert(b3 != NULL); 659 646 660 strcpy(blurb1, b1);661 strcpy(blurb2, b2);662 strcpy(blurb3, b3);647 strcpy(blurb1, b1); 648 strcpy(blurb2, b2); 649 strcpy(blurb3, b3); 663 650 strcpy(b1c, b1); 664 651 center_string(b1c, 80); … … 695 682 update_progress_form_full(blurb1, blurb2, blurb3); 696 683 paranoid_free(b1c); 697 paranoid_free(blurb1);698 paranoid_free(blurb2);699 paranoid_free(blurb3);684 mr_free(blurb1); 685 mr_free(blurb2); 686 mr_free(blurb3); 700 687 } 701 688 … … 1176 1163 1177 1164 /*@ newt ************************************************************ */ 1178 char *title_sz ;1179 char *minimsg_sz ;1165 char *title_sz = NULL; 1166 char *minimsg_sz = NULL; 1180 1167 static t_bkptype possible_bkptypes[] = 1181 1168 { none, cdr, cdrw, dvd, tape, cdstream, udev, nfs, iso }; … … 1198 1185 newtComponent myForm; 1199 1186 1200 title_sz = malloc(MAX_NEWT_COMMENT_LEN);1201 minimsg_sz = malloc(MAX_NEWT_COMMENT_LEN);1202 1187 outstr = malloc(MAX_NEWT_COMMENT_LEN); 1203 1188 if (g_text_mode) { … … 1217 1202 } 1218 1203 } 1219 paranoid_free(title_sz);1220 paranoid_free(minimsg_sz);1221 1204 paranoid_free(outstr); 1222 1205 return (backup_type); … … 1224 1207 newtDrawRootText(18, 0, WELCOME_STRING); 1225 1208 if (restoring) { 1226 strcpy(title_sz, 1227 "Please choose the backup media from which you want to read data."); 1228 strcpy(minimsg_sz, "Read from:"); 1229 } else { 1230 strcpy(title_sz, 1231 "Please choose the backup media to which you want to archive data."); 1232 strcpy(minimsg_sz, "Backup to:"); 1209 mr_asprintf(title_sz, "Please choose the backup media from which you want to read data."); 1210 mr_asprintf(minimsg_sz, "Read from:"); 1211 } else { 1212 mr_asprintf(title_sz, "Please choose the backup media to which you want to archive data."); 1213 mr_asprintf(minimsg_sz, "Backup to:"); 1233 1214 } 1234 1215 newtPushHelpLine(title_sz); … … 1266 1247 } 1267 1248 newtPopHelpLine(); 1268 paranoid_free(title_sz);1269 paranoid_free(minimsg_sz);1249 mr_free(title_sz); 1250 mr_free(minimsg_sz); 1270 1251 paranoid_free(outstr); 1271 1252 return (output); -
branches/2.2.10/mondo/src/include/my-stuff.h
r2329 r2334 236 236 */ 237 237 #define MAX_TAPECAT_FNAME_LEN 32 238 239 //#define strcpy(y,x) strncpy(y, x, sizeof(y)-1)240 241 238 242 239 /** -
branches/2.2.10/mondo/src/mondorestore/mondo-prep.c
r2331 r2334 192 192 char *incoming; 193 193 char *command; 194 char *lvscan_sz; 195 char *lvremove_sz; 196 char *pvscan_sz; 197 char *vgscan_sz; 198 char *vgcreate_sz; 199 char *vgchange_sz; 200 char *vgremove_sz; 201 // char *do_this_last; 194 char *lvscan_sz = NULL; 195 char *lvremove_sz = NULL; 196 char *pvscan_sz = NULL; 197 char *vgscan_sz = NULL; 198 char *vgchange_sz = NULL; 199 char *vgremove_sz = NULL; 202 200 203 201 /** char **************************************************/ … … 229 227 malloc_string(tmp); 230 228 malloc_string(incoming); 231 malloc_string(lvscan_sz); 232 malloc_string(lvremove_sz); 233 malloc_string(vgscan_sz); 234 malloc_string(pvscan_sz); 235 malloc_string(vgcreate_sz); 236 malloc_string(vgchange_sz); 237 malloc_string(vgremove_sz); 238 command = malloc(512); 229 command = malloc(1024); 239 230 240 231 log_it("STARTING"); … … 243 234 if (tmp1) // found it :) cool 244 235 { 245 strcpy(lvscan_sz, "lvm lvscan"); 246 strcpy(lvremove_sz, "lvm lvremove"); 247 strcpy(vgscan_sz, "lvm vgscan"); 248 strcpy(pvscan_sz, "lvm pvscan"); 249 strcpy(vgcreate_sz, "lvm vgcreate"); 250 strcpy(vgchange_sz, "lvm vgchange"); 251 strcpy(vgremove_sz, "lvm vgremove -f"); 236 mr_asprintf(lvscan_sz, "lvm lvscan"); 237 mr_asprintf(lvremove_sz, "lvm lvremove"); 238 mr_asprintf(vgscan_sz, "lvm vgscan"); 239 mr_asprintf(pvscan_sz, "lvm pvscan"); 240 mr_asprintf(vgchange_sz, "lvm vgchange"); 241 mr_asprintf(vgremove_sz, "lvm vgremove -f"); 252 242 } else { 253 strcpy(lvscan_sz, "lvscan"); 254 strcpy(lvremove_sz, "lvremove"); 255 strcpy(vgscan_sz, "vgscan"); 256 strcpy(pvscan_sz, "pvscan"); 257 strcpy(vgcreate_sz, "vgcreate"); 258 strcpy(vgchange_sz, "vgchange"); 259 strcpy(vgremove_sz, "vgremove"); 243 mr_asprintf(lvscan_sz, "lvscan"); 244 mr_asprintf(lvremove_sz, "lvremove"); 245 mr_asprintf(vgscan_sz, "vgscan"); 246 mr_asprintf(pvscan_sz, "pvscan"); 247 mr_asprintf(vgchange_sz, "vgchange"); 248 mr_asprintf(vgremove_sz, "vgremove"); 260 249 } 261 250 mr_free(tmp1); 262 251 263 252 mr_asprintf(tmp1, "for i in `%s | cut -d\"'\" -f2 | sort -r` ; do echo \"Shutting down lv $i\" >> %s ; %s -f $i; done", lvscan_sz, MONDO_LOGFILE, lvremove_sz); 253 mr_free(lvscan_sz); 254 mr_free(lvremove_sz); 255 264 256 run_program_and_log_output(tmp1, 5); 265 257 mr_free(tmp1); 266 258 267 259 sleep(1); 268 sprintf(command, 269 "for i in `%s | grep -i lvm | cut -d'\"' -f2` ; do %s -a n $i ; %s $i; echo \"Shutting down vg $i\" >> %s ; done", vgscan_sz, vgchange_sz, vgremove_sz, MONDO_LOGFILE); 260 sprintf(command, "for i in `%s | grep -i lvm | cut -d'\"' -f2` ; do %s -a n $i ; %s $i; echo \"Shutting down vg $i\" >> %s ; done", vgscan_sz, vgchange_sz, vgremove_sz, MONDO_LOGFILE); 261 mr_free(vgchange_sz); 262 mr_free(vgremove_sz); 263 270 264 run_program_and_log_output(command, 5); 271 265 if (just_erase_existing_volumes) { … … 401 395 sleep(1); 402 396 } 397 mr_free(vgscan_sz); 398 mr_free(pvscan_sz); 399 403 400 paranoid_fclose(fin); 404 401 log_msg(1, "Closed i-want-my-lvm. Finished doing funky stuff."); … … 407 404 paranoid_free(incoming); 408 405 paranoid_free(command); 409 paranoid_free(lvscan_sz);410 paranoid_free(lvremove_sz);411 paranoid_free(vgscan_sz);412 paranoid_free(pvscan_sz);413 paranoid_free(vgcreate_sz);414 paranoid_free(vgchange_sz);415 paranoid_free(vgremove_sz);416 406 system("sync"); 417 407 system("sync"); … … 829 819 830 820 if (res && strstr(program, "kludge")) { 831 mr_asprintf( &tmp, "Kludge failed; using regular mkfs.%s to format %s", format, device);821 mr_asprintf(tmp, "Kludge failed; using regular mkfs.%s to format %s", format, device); 832 822 mr_free(program); 833 823 #ifdef __FreeBSD__ … … 895 885 896 886 assert(mountlist != NULL); 897 mr_asprintf(tmp, "format_everything (mountlist, interactively = %s", (interactively) ? "true" : "false"); 898 log_it(tmp); 899 mr_free(tmp); 887 log_it("format_everything (mountlist, interactively = %s", (interactively) ? "true" : "false"); 900 888 901 889 mvaddstr_and_log_it(g_currentY, 0, "Formatting partitions "); … … 1423 1411 /** buffers *********************************************************/ 1424 1412 char *device_str = NULL; 1425 char *format ;1413 char *format = NULL; 1426 1414 char *tmp = NULL; 1427 1415 … … 1430 1418 assert(mountlist != NULL); 1431 1419 assert_string_is_neither_NULL_nor_zerolength(drivename); 1432 1433 malloc_string(format);1434 1420 1435 1421 log_it("Partitioning drive %s", drivename); … … 1445 1431 if (!pout_to_fdisk) { 1446 1432 log_to_screen("Cannot call parted2fdisk to configure %s", drivename); 1447 paranoid_free(format);1448 1433 return (1); 1449 1434 } … … 1480 1465 mr_free(command); 1481 1466 mr_free(device_str); 1482 paranoid_free(format);1483 1467 return r; 1484 1468 } … … 1495 1479 int i, line; 1496 1480 1497 strcpy(format, "ufs");1481 mr_asprintf(format, "ufs"); 1498 1482 partsize = 0; 1499 1483 for (i = 'a'; i < 'z'; ++i) { … … 1552 1536 #ifdef __FreeBSD__ 1553 1537 if (!fbsd_part) { 1554 #endif 1555 1556 strcpy(format, mountlist->el[lino].format); 1538 mr_free(format); 1539 #endif 1540 1541 mr_asprintf(format, "%s", mountlist->el[lino].format); 1557 1542 partsize = mountlist->el[lino].size; 1558 1543 … … 1566 1551 ("You must leave at least one partition spare as the Extended partition."); 1567 1552 mr_free(device_str); 1568 paranoid_free(format);1553 mr_free(format); 1569 1554 return (1); 1570 1555 } 1571 1556 #endif 1572 1557 1573 retval += 1574 partition_device(pout_to_fdisk, drivename, current_devno, 1575 previous_devno, format, partsize); 1558 retval += partition_device(pout_to_fdisk, drivename, current_devno, previous_devno, format, partsize); 1559 mr_free(format); 1576 1560 1577 1561 #ifdef __FreeBSD__ … … 1626 1610 } 1627 1611 } 1628 paranoid_free(format);1629 1612 return (retval); 1630 1613 } … … 1978 1961 mr_asprintf(partcode, ""); 1979 1962 } else if (strlen(format) >= 1 && strlen(format) <= 2) { 1980 mr_asprintf(partcode, format);1963 mr_asprintf(partcode, "%s", format); 1981 1964 } else { 1982 1965 /* probably an image */ … … 1985 1968 mr_free(tmp); 1986 1969 #ifdef __FreeBSD__ 1987 mr_asprintf(partcode, format); // was a51970 mr_asprintf(partcode, "%s", format); // was a5 1988 1971 #else 1989 mr_asprintf(partcode, format); // was 831972 mr_asprintf(partcode, "%s", format); // was 83 1990 1973 #endif 1991 1974 } … … 2260 2243 2261 2244 /** buffers *********************************************************/ 2262 char *tmp = NULL;2263 2245 char *program = NULL; 2264 2246 … … 2311 2293 mr_asprintf(program, "mkfs -t %s -c", format); // -c checks for bad blocks 2312 2294 #endif 2313 mr_asprintf(tmp, "Unknown format (%s) - assuming '%s' will do", format, program); 2314 log_it(tmp); 2315 mr_free(tmp); 2295 log_it("Unknown format (%s) - assuming '%s' will do", format, program); 2316 2296 res = 0; 2317 2297 } -
branches/2.2.10/mondo/src/mondorestore/mondo-rstr-compare.c
r2332 r2334 43 43 44 44 /** needs malloc *******/ 45 char *checksum_ptr ;46 char *original_cksum_ptr ;47 char *bigfile_fname_ptr ;45 char *checksum_ptr = NULL; 46 char *original_cksum_ptr = NULL; 47 char *bigfile_fname_ptr = NULL; 48 48 char *tmp_ptr = NULL; 49 49 char *command_ptr = NULL; 50 50 51 char *checksum, * original_cksum, *bigfile_fname, *tmp, *command;51 char *checksum, *bigfile_fname, *tmp, *command; 52 52 53 53 char *p; … … 58 58 59 59 malloc_string(checksum); 60 malloc_string(original_cksum);61 60 malloc_string(bigfile_fname); 62 61 malloc_string(tmp); 63 62 malloc_string(command); 64 malloc_string(checksum_ptr);65 malloc_string(original_cksum_ptr);66 malloc_string(bigfile_fname_ptr);67 63 68 64 /********************************************************************* … … 70 66 *********************************************************************/ 71 67 assert(bkpinfo != NULL); 72 memset(checksum_ptr, '\0', sizeof(checksum));73 memset(original_cksum_ptr, '\0', sizeof(original_cksum));74 memset(bigfile_fname_ptr, '\0', sizeof(bigfile_fname));75 68 /** end **/ 76 69 … … 84 77 } 85 78 if (!(fin = fopen(slice_fname(bigfileno, 0, ARCHIVES_PATH, ""), "r"))) { 86 log_to_screen("Cannot open bigfile %ld ( %s)'s info file", bigfileno + 1, bigfile_fname_ptr);79 log_to_screen("Cannot open bigfile %ld (NULL)'s info file", bigfileno + 1); 87 80 return (1); 88 81 } … … 90 83 paranoid_fclose(fin); 91 84 92 strcpy(checksum_ptr, biggiestruct.checksum);93 strcpy(bigfile_fname_ptr, biggiestruct.filename);85 mr_asprintf(checksum_ptr, "%s", biggiestruct.checksum); 86 mr_asprintf(bigfile_fname_ptr, "%s", biggiestruct.filename); 94 87 95 88 log_msg(2, "biggiestruct.filename = %s", biggiestruct.filename); … … 106 99 } 107 100 if (!strncmp(bigfile_fname_ptr, "/dev/", 5)) { 108 strcpy(original_cksum_ptr, "IGNORE");109 101 log_msg(2, "IGNORING %s as begining with /dev", bigfile_fname_ptr); 102 mr_free(bigfile_fname_ptr); 110 103 return (1); 111 104 } … … 122 115 if (i) { 123 116 log_OS_error("Warning - command failed"); 124 original_cksum[0] = '\0';125 117 return (1); 126 118 } else { … … 128 120 log_msg(2, 129 121 "Unable to open /tmp/md5sum.txt; can't get live checksum"); 130 original_cksum[0] = '\0';122 mr_free(bigfile_fname_ptr); 131 123 return (1); 132 124 } else { 133 fgets(original_cksum_ptr, MAX_STR_LEN - 1, fin);125 mr_getline(original_cksum_ptr, fin); 134 126 paranoid_fclose(fin); 135 for (i = strlen(original_cksum_ptr); 136 i > 0 && original_cksum[i - 1] < 32; i--); 137 original_cksum[i] = '\0'; 138 p = (char *) strchr(original_cksum_ptr, ' '); 127 p = strchr(original_cksum_ptr, ' '); 139 128 if (p) { 140 129 *p = '\0'; … … 143 132 } 144 133 mr_asprintf(tmp_ptr, "bigfile #%ld ('%s') ", bigfileno + 1, bigfile_fname_ptr); 145 if ( !strcmp(checksum_ptr, original_cksum_ptr) != 0) {134 if ((original_cksum_ptr != NULL) && (strcmp(checksum_ptr, original_cksum_ptr) == 0)) { 146 135 mr_strcat(tmp_ptr, " ... OK"); 147 136 } else { … … 149 138 retval++; 150 139 } 140 mr_free(checksum_ptr); 141 mr_free(original_cksum_ptr); 142 151 143 log_msg(1, tmp_ptr); 152 144 paranoid_free(tmp_ptr); … … 159 151 paranoid_fclose(fout); 160 152 } 161 162 paranoid_free(original_cksum_ptr); 163 paranoid_free(original_cksum); 164 paranoid_free(bigfile_fname_ptr); 153 mr_free(bigfile_fname_ptr); 154 165 155 paranoid_free(bigfile_fname); 166 paranoid_free(checksum_ptr);167 156 paranoid_free(checksum); 168 157 paranoid_free(command); … … 365 354 /** needs malloc **********/ 366 355 367 char *tarball_fname, *progress_str; 356 char *tarball_fname = NULL; 357 char *progress_str = NULL; 368 358 char *tmp = NULL; 369 359 char *mds = NULL; … … 443 433 mvaddstr_and_log_it(g_currentY++, 74, "Done."); 444 434 } 445 paranoid_free(tarball_fname);446 paranoid_free(progress_str);447 435 return (retval); 448 436 } -
branches/2.2.10/mondo/src/mondorestore/mondo-rstr-newt.c
r2332 r2334 78 78 newtPushHelpLine 79 79 (" Add one of the following unallocated RAID partitions to this RAID device."); 80 mr_asprintf( &tmp, "%-26s %s", "Device", "Size");80 mr_asprintf(tmp, "%-26s %s", "Device", "Size"); 81 81 headerMsg = newtLabel(1, 1, tmp); 82 82 partitionsListbox = … … 104 104 105 105 items = disklist->entries; 106 strcpy(disklist->el[items].device, 107 unallocated_raid_partitions->el[currline].device); 106 strcpy(disklist->el[items].device, unallocated_raid_partitions->el[currline].device); 108 107 disklist->el[items].index = index; 109 108 disklist->entries = ++items; … … 154 153 155 154 /** buffers **********************************************************/ 156 char drive_to_add[MAX_STR_LEN];157 char mountpoint_str[MAX_STR_LEN];158 char size_str[MAX_STR_LEN];159 char device_str[MAX_STR_LEN];160 char format_str[MAX_STR_LEN];155 char *drive_to_add = NULL; 156 char *mountpoint_str = NULL; 157 char *size_str = NULL; 158 char *device_str = NULL; 159 char *format_str = NULL; 161 160 162 161 /** pointers *********************************************************/ … … 171 170 assert(keylist != NULL); 172 171 173 strcpy(device_str, "/dev/"); 174 strcpy(mountpoint_str, "/"); 172 mr_asprintf(device_str, "/dev/"); 173 mr_asprintf(mountpoint_str, "/"); 174 mr_asprintf(size_str, ""); 175 175 #ifdef __FreeBSD__ 176 strcpy(format_str, "ufs");176 mr_asprintf(format_str, "ufs"); 177 177 #else 178 strcpy(format_str, "ext3");178 mr_asprintf(format_str, "ext3"); 179 179 #endif 180 size_str[0] = '\0';181 180 newtOpenWindow(20, 5, 48, 10, "Add entry"); 182 181 label0 = newtLabel(2, 1, "Device: "); … … 184 183 label2 = newtLabel(2, 3, "Size (MB): "); 185 184 label3 = newtLabel(2, 4, "Format: "); 186 deviceComp = 187 newtEntry(14, 1, device_str, 30, (void *) &device_here, 0); 188 mountpointComp = 189 newtEntry(14, 2, mountpoint_str, 30, (void *) &mountpoint_here, 0); 190 formatComp = 191 newtEntry(14, 4, format_str, 15, (void *) &format_here, 0); 185 deviceComp = newtEntry(14, 1, device_str, 30, (void *) &device_here, 0); 186 mountpointComp = newtEntry(14, 2, mountpoint_str, 30, (void *) &mountpoint_here, 0); 187 formatComp = newtEntry(14, 4, format_str, 15, (void *) &format_here, 0); 192 188 sizeComp = newtEntry(14, 3, size_str, 10, (void *) &size_here, 0); 193 189 bOK = newtButton(5, 6, " OK "); … … 201 197 for (b_res = NULL; b_res != bOK && b_res != bCancel;) { 202 198 b_res = newtRunForm(myForm); 203 strcpy(device_str, device_here); 204 strcpy(mountpoint_str, mountpoint_here); 205 strcpy(format_str, format_here); 206 strcpy(size_str, size_here); 207 // log_it ("Originals = %s,%s,%s,%s", device_str, mountpoint_str, format_str, size_str); 199 mr_free(device_str); 200 mr_asprintf(device_str, "%s", device_here); 201 202 mr_free(mountpoint_str); 203 mr_asprintf(mountpoint_str, "%s", mountpoint_here); 204 mr_strip_spaces(mountpoint_str); 205 206 mr_free(format_str); 207 mr_asprintf(format_str, "%s", format_here); 208 mr_strip_spaces(format_str); 209 210 mr_free(size_str); 211 mr_asprintf(size_str, "%s", size_here); 212 mr_strip_spaces(size_str); 213 208 214 strip_spaces(device_str); 209 strip_spaces(mountpoint_str);210 strip_spaces(format_str);211 strip_spaces(size_str);212 // log_it ("Modified = %s,%s,%s,%s", device_str, mountpoint_str, format_str, size_str);213 215 if (b_res == bOK) { 214 216 if (device_str[strlen(device_str) - 1] == '/') { … … 216 218 b_res = NULL; 217 219 } 218 if (size_of_specific_device_in_mountlist(mountlist, device_str) 219 >= 0) { 220 if (size_of_specific_device_in_mountlist(mountlist, device_str) >= 0) { 220 221 popup_and_OK("Can't add this - you've got one already!"); 221 222 b_res = NULL; … … 229 230 return; 230 231 } 231 strcpy(drive_to_add, device_str);232 mr_asprintf(drive_to_add, "%s", device_str); 232 233 for (i = strlen(drive_to_add); isdigit(drive_to_add[i - 1]); i--); 233 234 num_to_add = atoi(drive_to_add + i); 234 drive_to_add[i] = '\0'; 235 mr_free(drive_to_add); 236 235 237 currline = mountlist->entries; 236 238 strcpy(mountlist->el[currline].device, device_str); 237 239 strcpy(mountlist->el[currline].mountpoint, mountpoint_str); 240 mr_free(mountpoint_str); 241 238 242 strcpy(mountlist->el[currline].format, format_str); 243 mr_free(format_str); 244 239 245 mountlist->el[currline].size = atol(size_str) * 1024L; 246 mr_free(size_str); 247 240 248 mountlist->entries++; 241 249 if (strstr(mountlist->el[currline].device, RAID_DEVICE_STUB)) { 242 initiate_new_raidlist_entry(raidlist, mountlist, currline, 243 device_str); 244 } 250 initiate_new_raidlist_entry(raidlist, mountlist, currline, device_str); 251 } 252 mr_free(device_str); 253 245 254 redraw_mountlist(mountlist, keylist, listbox); 246 255 } … … 316 325 /** buffers ***********************************************************/ 317 326 char tmp = NULL; 318 319 320 327 char *devname = NULL; 321 328 322 329 for (i = 0; … … 324 331 && strcmp(raidlist->el[i].volname, basename(raid_device)); i++); 325 332 if (i == raidlist->entries) { 326 mr_asprintf(&tmp, "Cannot calc size of raid device %s - cannot find it in raidlist", raid_device); 327 log_it(tmp); 328 mr_free(tmp); 333 log_it("Cannot calc size of raid device %s - cannot find it in raidlist", raid_device); 329 334 return (0); // Isn't this more sensible than 999999999? If the raid dev !exists, 330 335 // then it has no size, right? … … 338 343 int k = 0, l = 0; 339 344 for (k = 0; k < raidrec->plex[j].subdisks; ++k) { 340 char devname[64]; 341 strcpy(devname, raidrec->plex[j].sd[k].which_device); 345 mr_asprintf(devname, "%s", raidrec->plex[j].sd[k].which_device); 342 346 for (l = 0; l < raidlist->disks.entries; ++l) { 343 347 if (!strcmp(devname, raidlist->disks.el[l].name)) { … … 367 371 } 368 372 } 373 mr_free(devname); 369 374 } 370 375 … … 387 392 } 388 393 389 mr_asprintf(&tmp, "I have calculated %s's real size to be %ld", raid_device, (long) smallest_plex); 390 log_it(tmp); 391 mr_free(tmp); 394 log_it("I have calculated %s's real size to be %ld", raid_device, (long) smallest_plex); 392 395 return (smallest_plex); 393 396 #else … … 406 409 long sp = 0; 407 410 408 /** buffers ***********************************************************/409 char tmp = NULL;410 411 411 assert(mountlist != NULL); 412 412 assert(raidlist != NULL); … … 417 417 && strcmp(raidlist->el[i].raid_device, raid_device); i++); 418 418 if (i == raidlist->entries) { 419 mr_asprintf(&tmp, "Cannot calc size of raid device %s - cannot find it in raidlist", raid_device); 420 log_it(tmp); 421 mr_free(tmp); 419 log_it("Cannot calc size of raid device %s - cannot find it in raidlist", raid_device); 422 420 return (999999999); 423 421 } … … 442 440 total_size = smallest_partition * (noof_partitions - 1); 443 441 } 444 mr_asprintf(&tmp, "I have calculated %s's real size to be %ld", raid_device, (long) total_size); 445 log_it(tmp); 446 mr_free(tmp); 442 log_it("I have calculated %s's real size to be %ld", raid_device, (long) total_size); 447 443 return (total_size); 448 444 #endif … … 499 495 } 500 496 p[i] = '\0'; 501 mr_free(sz);502 497 } 503 498 if (!strcmp(p, "concat")) { … … 568 563 } 569 564 p[i] = '\0'; 570 mr_free(sz);571 565 } 572 566 if (!strcmp(p, "linear")) { … … 613 607 614 608 /** buffers ***********************************************************/ 615 char *tmp = NULL;616 617 609 assert(mountlist != NULL); 618 610 assert(raidlist != NULL); … … 625 617 pos++); 626 618 if (pos < mountlist->entries) { 627 mr_asprintf(&tmp, "Deleting partition %s cos it was part of a now-defunct RAID", mountlist->el[pos].device); 628 log_it(tmp); 629 mr_free(tmp); 619 log_it("Deleting partition %s cos it was part of a now-defunct RAID", mountlist->el[pos].device); 630 620 631 621 memcpy((void *) &mountlist->el[pos], … … 662 652 assert_string_is_neither_NULL_nor_zerolength(raid_device); 663 653 664 mr_asprintf( &tmp, "Delete %s from RAID device %s - are you sure?", disklist->el[currline].device, raid_device);654 mr_asprintf(tmp, "Delete %s from RAID device %s - are you sure?", disklist->el[currline].device, raid_device); 665 655 res = ask_me_yes_or_no(tmp); 666 656 mr_free(tmp); … … 699 689 /** buffers ***********************************************************/ 700 690 char *tmp = NULL; 701 char device[MAX_STR_LEN];691 char *device = NULL; 702 692 703 693 … … 707 697 assert(keylist != NULL); 708 698 709 /* BERLIOS: Why isn't device initialized here ? what is expected */ 710 pos = 711 which_raid_device_is_using_this_partition(raidlist, 712 mountlist->el[currline]. 713 device); 699 pos = which_raid_device_is_using_this_partition(raidlist, mountlist->el[currline].device); 714 700 if (pos >= 0) { 715 mr_asprintf( &tmp, "Cannot delete %s: it is in use by RAID device %s", mountlist->el[currline].device, raidlist->el[pos].OSSWAP(raid_device, volname));701 mr_asprintf(tmp, "Cannot delete %s: it is in use by RAID device %s", mountlist->el[currline].device, raidlist->el[pos].OSSWAP(raid_device, volname)); 716 702 popup_and_OK(tmp); 717 703 mr_free(tmp); 718 704 return; 719 705 } 720 mr_asprintf( &tmp, "Delete %s - are you sure?", mountlist->el[currline].device);706 mr_asprintf(tmp, "Delete %s - are you sure?", mountlist->el[currline].device); 721 707 res = ask_me_yes_or_no(tmp); 722 708 mr_free(tmp); … … 726 712 } 727 713 if (strstr(mountlist->el[currline].device, RAID_DEVICE_STUB)) { 728 strcpy(device, mountlist->el[currline].device);714 mr_asprintf(device, "%s", mountlist->el[currline].device); 729 715 delete_raidlist_entry(mountlist, raidlist, device); 730 716 for (currline = 0; … … 732 718 && strcmp(mountlist->el[currline].device, device); 733 719 currline++); 720 mr_free(device); 721 734 722 if (currline == mountlist->entries) { 735 723 log_it("Dev is gone. I can't delete it. Ho-hum"); … … 775 763 return; 776 764 } 777 mr_asprintf( &tmp, "Do you want me to delete %s's partitions, too?", device);765 mr_asprintf(tmp, "Do you want me to delete %s's partitions, too?", device); 778 766 delete_partitions_too = ask_me_yes_or_no(tmp); 779 767 if (delete_partitions_too) { … … 788 776 if (!strcmp(raidlist->el[i].plex[x].sd[y].which_device, 789 777 raidlist->disks.el[z].name)) { 790 strcpy(d.el[d.entries].name, 791 raidlist->disks.el[z].name); 792 strcpy(d.el[d.entries++].device, 793 raidlist->disks.el[z].device); 778 strcpy(d.el[d.entries].name, raidlist->disks.el[z].name); 779 strcpy(d.el[d.entries++].device, raidlist->disks.el[z].device); 794 780 } 795 781 } … … 844 830 845 831 av = &raidrec->additional_vars; 846 mr_asprintf( &tmp, "Delete %s - are you sure?", av->el[lino].label);832 mr_asprintf(tmp, "Delete %s - are you sure?", av->el[lino].label); 847 833 res = ask_me_yes_or_no(tmp); 848 834 mr_free(tmp); … … 851 837 if (!strcmp(av->el[lino].label, "persistent-superblock") 852 838 || !strcmp(av->el[lino].label, "chunk-size")) { 853 mr_asprintf( &tmp, "%s must not be deleted. It would be bad.", av->el[lino].label);839 mr_asprintf(tmp, "%s must not be deleted. It would be bad.", av->el[lino].label); 854 840 popup_and_OK(tmp); 855 841 mr_free(tmp); … … 920 906 if (!warned_already) { 921 907 warned_already = TRUE; 922 mr_asprintf( &tmp1, "Too many lines. Displaying first %d entries only. Close a directory to see more.", ARBITRARY_MAXIMUM);908 mr_asprintf(tmp1, "Too many lines. Displaying first %d entries only. Close a directory to see more.", ARBITRARY_MAXIMUM); 923 909 popup_and_OK(tmp1); 924 910 mr_free(tmp1); 925 911 } 926 912 } else { 927 strcpy(g_strings_of_flist_window[lines_in_flist_window], 928 current_filename); 913 strcpy(g_strings_of_flist_window[lines_in_flist_window], current_filename); 929 914 g_is_path_selected[lines_in_flist_window] = node->selected; 930 915 lines_in_flist_window++; … … 941 926 (g_strings_of_flist_window[i], 942 927 g_strings_of_flist_window[i - 1]) < 0) { 943 mr_asprintf(&tmp1, g_strings_of_flist_window[i]); 944 strcpy(g_strings_of_flist_window[i], 945 g_strings_of_flist_window[i - 1]); 928 mr_asprintf(tmp1, "%s", g_strings_of_flist_window[i]); 929 strcpy(g_strings_of_flist_window[i], g_strings_of_flist_window[i - 1]); 946 930 strcpy(g_strings_of_flist_window[i - 1], tmp1); 947 931 mr_free(tmp1); … … 1048 1032 void *curr_choice; 1049 1033 void *keylist[ARBITRARY_MAXIMUM]; 1050 1051 /** buffers ***********************************************************/1052 char *tmp = NULL;1053 1034 1054 1035 /** bool **************************************************************/ … … 1098 1079 indexno = 0; 1099 1080 } 1100 mr_asprintf(&tmp, "You selected '%s'", g_strings_of_flist_window[indexno]); 1101 log_it(tmp); 1102 mr_free(tmp); 1081 log_it("You selected '%s'", g_strings_of_flist_window[indexno]); 1103 1082 1104 1083 if (b_res == bMore) { … … 1193 1172 1194 1173 /** buffers ***********************************************************/ 1195 char device_str[MAX_STR_LEN];1196 char mountpoint_str[MAX_STR_LEN];1197 char size_str[MAX_STR_LEN];1198 char format_str[MAX_STR_LEN];1174 char *device_str = NULL; 1175 char *mountpoint_str = NULL; 1176 char *size_str = NULL; 1177 char *format_str = NULL; 1199 1178 char *tmp = NULL; 1200 char device_used_to_be[MAX_STR_LEN];1201 char mountpt_used_to_be[MAX_STR_LEN];1179 char *device_used_to_be = NULL; 1180 char *mountpt_used_to_be = NULL; 1202 1181 1203 1182 /** pointers **********************************************************/ … … 1217 1196 memcpy((void *) &bkp_raidlist, (void *) raidlist, 1218 1197 sizeof(struct raidlist_itself)); 1219 strcpy(device_str, mountlist->el[currline].device);1220 strcpy(device_used_to_be, mountlist->el[currline].device);1221 strcpy(mountpoint_str, mountlist->el[currline].mountpoint);1222 strcpy(mountpt_used_to_be, mountlist->el[currline].mountpoint);1223 strcpy(format_str, mountlist->el[currline].format);1224 sprintf(size_str, "%lld", mountlist->el[currline].size / 1024L);1198 mr_asprintf(device_str, "%s", mountlist->el[currline].device); 1199 mr_asprintf(device_used_to_be, "%s", mountlist->el[currline].device); 1200 mr_asprintf(mountpoint_str, "%s", mountlist->el[currline].mountpoint); 1201 mr_asprintf(mountpt_used_to_be, "%s", mountlist->el[currline].mountpoint); 1202 mr_asprintf(format_str, "%s", mountlist->el[currline].format); 1203 mr_asprintf(size_str, "%lld", mountlist->el[currline].size / 1024L); 1225 1204 newtOpenWindow(20, 5, 48, 10, "Edit entry"); 1226 1205 label0 = newtLabel(2, 1, "Device:"); … … 1228 1207 label2 = newtLabel(2, 3, "Size (MB): "); 1229 1208 label3 = newtLabel(2, 4, "Format: "); 1230 deviceComp = 1231 newtEntry(14, 1, device_str, 30, (void *) &device_here, 0); 1232 mountpointComp = 1233 newtEntry(14, 2, mountpoint_str, 30, (void *) &mountpoint_here, 0); 1234 formatComp = 1235 newtEntry(14, 4, format_str, 15, (void *) &format_here, 0); 1209 deviceComp = newtEntry(14, 1, device_str, 30, (void *) &device_here, 0); 1210 mountpointComp = newtEntry(14, 2, mountpoint_str, 30, (void *) &mountpoint_here, 0); 1211 formatComp = newtEntry(14, 4, format_str, 15, (void *) &format_here, 0); 1236 1212 if (strstr(mountlist->el[currline].device, RAID_DEVICE_STUB) 1237 1213 || !strcmp(mountlist->el[currline].mountpoint, "image")) { … … 1253 1229 for (b_res = NULL; b_res != bOK && b_res != bCancel;) { 1254 1230 b_res = newtRunForm(myForm); 1255 strcpy(device_str, device_here); 1256 strip_spaces(device_str); 1257 strcpy(mountpoint_str, mountpoint_here); 1258 strip_spaces(mountpoint_str); 1259 strcpy(format_str, format_here); 1260 strip_spaces(format_str); 1231 mr_free(device_str); 1232 mr_asprintf(device_str, "%s", device_here); 1233 mr_strip_spaces(device_str); 1234 1235 mr_free(mountpoint_str); 1236 mr_asprintf(mountpoint_str, "%s", mountpoint_here); 1237 mr_strip_spaces(mountpoint_str); 1238 1239 mr_free(format_str); 1240 mr_asprintf(format_str, "%s", format_here); 1241 mr_strip_spaces(format_str); 1242 1261 1243 if (b_res == bOK && strstr(device_str, RAID_DEVICE_STUB) 1262 1244 && strstr(device_used_to_be, RAID_DEVICE_STUB) … … 1273 1255 if (!strstr(mountlist->el[currline].device, RAID_DEVICE_STUB) 1274 1256 && strcmp(mountlist->el[currline].mountpoint, "image")) { 1275 strcpy(size_str, size_here); 1276 strip_spaces(size_str); 1257 mr_free(size_str); 1258 mr_asprintf(size_str, "%s", size_here); 1259 mr_strip_spaces(size_str); 1277 1260 } else { 1278 sprintf(size_str, "%ld", 1279 calculate_raid_device_size(mountlist, raidlist, 1280 mountlist->el[currline]. 1281 device) / 1024); 1261 mr_asprintf(size_str, "%ld", calculate_raid_device_size(mountlist, raidlist, mountlist->el[currline].device) / 1024); 1282 1262 newtLabelSetText(sizeComp, size_str); 1283 1263 } … … 1296 1276 device); 1297 1277 if (j < 0) { 1298 mr_asprintf( &tmp, "/etc/raidtab does not have an entry for %s; please delete it and add it again", mountlist->el[currline].device);1278 mr_asprintf(tmp, "/etc/raidtab does not have an entry for %s; please delete it and add it again", mountlist->el[currline].device); 1299 1279 popup_and_OK(tmp); 1300 1280 mr_free(tmp); … … 1310 1290 newtPopHelpLine(); 1311 1291 newtPopWindow(); 1292 mr_free(mountpt_used_to_be); 1293 1312 1294 if (b_res == bCancel) { 1313 1295 memcpy((void *) raidlist, (void *) &bkp_raidlist, 1314 1296 sizeof(struct raidlist_itself)); 1297 mr_free(device_str); 1298 mr_free(device_used_to_be); 1299 mr_free(format_str); 1300 mr_free(size_str); 1315 1301 return; 1316 1302 } 1317 1303 strcpy(mountlist->el[currline].device, device_str); 1318 1304 strcpy(mountlist->el[currline].mountpoint, mountpoint_str); 1305 mr_free(mountpoint_str); 1306 1319 1307 strcpy(mountlist->el[currline].format, format_str); 1308 mr_free(format_str); 1309 1320 1310 if (strcmp(mountlist->el[currline].mountpoint, "image")) { 1321 1311 if (strstr(mountlist->el[currline].device, RAID_DEVICE_STUB)) { … … 1327 1317 } 1328 1318 } 1319 mr_free(size_str); 1329 1320 newtListboxSetEntry(listbox, (long) keylist[currline], 1330 1321 mountlist_entry_to_string(mountlist, currline)); … … 1332 1323 if (strstr(mountlist->el[currline].device, RAID_DEVICE_STUB) 1333 1324 && !strstr(device_used_to_be, RAID_DEVICE_STUB)) { 1334 initiate_new_raidlist_entry(raidlist, mountlist, currline, 1335 device_str); 1325 initiate_new_raidlist_entry(raidlist, mountlist, currline, device_str); 1336 1326 } 1337 1327 /* if moving from RAID to non-RAID then do funky stuff */ … … 1350 1340 #ifndef __FreeBSD__ /* It works fine under FBSD. */ 1351 1341 else if (strcmp(device_used_to_be, device_str)) { 1352 popup_and_OK 1353 ("You are renaming a RAID device as another RAID device. I don't like it but I'll allow it."); 1342 popup_and_OK("You are renaming a RAID device as another RAID device. I don't like it but I'll allow it."); 1354 1343 } 1355 1344 #endif 1345 mr_free(device_str); 1346 mr_free(device_used_to_be); 1347 1356 1348 redraw_mountlist(mountlist, keylist, listbox); 1357 1349 } … … 1376 1368 for (i = 0; i < raidlist->disks.entries; ++i) { 1377 1369 if (!strcmp(raidlist->disks.el[i].device, temp)) { 1378 strcpy(raidrec->sd[raidrec->subdisks].which_device, 1379 raidlist->disks.el[i].name); 1370 strcpy(raidrec->sd[raidrec->subdisks].which_device, raidlist->disks.el[i].name); 1380 1371 found = TRUE; 1381 1372 } … … 1494 1485 switch (raidrec->plex[i].raidlevel) { 1495 1486 case -1: 1496 mr_asprintf( &raidlevel, "concat");1487 mr_asprintf(raidlevel, "concat"); 1497 1488 break; 1498 1489 case 0: 1499 mr_asprintf( &raidlevel, "striped");1490 mr_asprintf(raidlevel, "striped"); 1500 1491 break; 1501 1492 case 5: 1502 mr_asprintf( &raidlevel, "raid5");1493 mr_asprintf(raidlevel, "raid5"); 1503 1494 break; 1504 1495 default: 1505 mr_asprintf( &raidlevel, "raid%i", raidrec->plex[i].raidlevel);1496 mr_asprintf(raidlevel, "raid%i", raidrec->plex[i].raidlevel); 1506 1497 break; 1507 1498 } 1508 1499 1509 1500 if (raidrec->plex[i].raidlevel == -1) { 1510 mr_asprintf( &chunksize, "N/A");1501 mr_asprintf(chunksize, "N/A"); 1511 1502 } else { 1512 mr_asprintf( &chunksize, "%dk", raidrec->plex[i].stripesize);1503 mr_asprintf(chunksize, "%dk", raidrec->plex[i].stripesize); 1513 1504 } 1514 1505 snprintf(pname, 64, "%s.p%i", raidrec->volname, i); … … 1540 1531 1541 1532 if (b_res == bDelete) { 1542 mr_asprintf( &msg, "Are you sure you want to delete %s.p%i?", raidrec->volname, currline2);1533 mr_asprintf(msg, "Are you sure you want to delete %s.p%i?", raidrec->volname, currline2); 1543 1534 res = ask_me_yes_or_no(msg); 1544 1535 mr_free(msg); … … 1578 1569 /** buffers ***********************************************************/ 1579 1570 char *title_of_editraidForm_window; 1580 char *sz_raid_level ;1571 char *sz_raid_level = NULL; 1581 1572 char *sz_data_disks = NULL; 1582 1573 char *sz_spare_disks = NULL; … … 1600 1591 assert(raidrec != NULL); 1601 1592 1602 malloc_string(title_of_editraidForm_window);1603 malloc_string(sz_raid_level);1604 1605 1593 bkp_raidrec = mr_malloc(sizeof(struct raid_device_record)); 1606 1594 log_it("Started edit_raidlist_entry"); 1607 1595 1608 1596 memcpy((void *) bkp_raidrec, (void *) raidrec, sizeof(struct raid_device_record)); 1609 sprintf(title_of_editraidForm_window, "%s", raidrec->raid_device);1597 mr_asprintf(title_of_editraidForm_window, "%s", raidrec->raid_device); 1610 1598 log_msg(2, "Opening newt window"); 1611 1599 newtOpenWindow(20, 5, 40, 14, title_of_editraidForm_window); 1612 1600 for (;;) { 1613 1601 log_msg(2, "Main loop"); 1614 sprintf(title_of_editraidForm_window, "Edit %s", 1615 raidrec->raid_device); 1616 strcpy(sz_raid_level, 1617 turn_raid_level_number_to_string(raidrec->raid_level)); 1602 mr_free(title_of_editraidForm_window); 1603 mr_asprintf(title_of_editraidForm_window, "Edit %s", raidrec->raid_device); 1604 mr_asprintf(sz_raid_level, "%s", turn_raid_level_number_to_string(raidrec->raid_level)); 1618 1605 /* Those 4 strings are allocated by the function */ 1619 1606 sz_data_disks = number_of_disks_as_string(raidrec->data_disks.entries, "data"); … … 1666 1653 newtPopWindow(); 1667 1654 mountlist->el[currline].size = calculate_raid_device_size(mountlist, raidlist, raidrec->raid_device); 1668 paranoid_free(title_of_editraidForm_window);1669 paranoid_free(sz_raid_level);1655 mr_free(title_of_editraidForm_window); 1656 mr_free(sz_raid_level); 1670 1657 paranoid_free(bkp_raidrec); 1671 1658 #endif … … 1715 1702 1716 1703 char *p = NULL; 1704 char *tmp = NULL; 1705 char *entry = NULL; 1717 1706 1718 1707 struct mountlist_itself *unallocparts; … … 1730 1719 for (;;) { 1731 1720 int i; 1732 char headerstr[MAX_STR_LEN];1733 char tmp[64];1734 snprintf(headerstr, MAX_STR_LEN, "%-24s %s", "Subdisk", "Device");1735 1736 1721 1737 1722 switch (raidrec->raidlevel) { 1738 1723 case -1: 1739 strcpy(tmp, "concat");1724 mr_asprintf(tmp, "concat"); 1740 1725 break; 1741 1726 case 0: 1742 strcpy(tmp, "striped");1727 mr_asprintf(tmp, "striped"); 1743 1728 break; 1744 1729 case 5: 1745 strcpy(tmp, "raid5");1730 mr_asprintf(tmp, "raid5"); 1746 1731 break; 1747 1732 default: 1748 sprintf(tmp, "unknown (%i)", raidrec->raidlevel);1733 mr_asprintf(tmp, "unknown (%i)", raidrec->raidlevel); 1749 1734 break; 1750 1735 } 1751 1736 bLevel = newtCompactButton(2, 2, " RAID level "); 1752 1737 sLevel = newtLabel(19, 2, tmp); 1738 mr_free(tmp); 1753 1739 1754 1740 if (raidrec->raidlevel >= 0) { 1755 sprintf(tmp, "%ik", raidrec->stripesize);1741 mr_asprintf(tmp, "%ik", raidrec->stripesize); 1756 1742 bStripeSize = newtCompactButton(2, 4, " Stripe size "); 1757 1743 } else { 1758 strcpy(tmp, "N/A");1744 mr_asprintf(tmp, "N/A"); 1759 1745 bStripeSize = newtLabel(2, 4, "Stripe size:"); 1760 1746 } 1761 1747 sStripeSize = newtLabel(19, 4, tmp); 1748 mr_free(tmp); 1762 1749 1763 1750 bOK = newtCompactButton(2, 16, " OK "); … … 1768 1755 1769 1756 1770 // plexesListbox = newtListbox (2, 7, 9, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT);1771 // plexesHeader = newtLabel (2, 6, headerstr);1772 1757 unallocListbox = 1773 1758 newtListbox(2, 7, 7, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT); … … 1785 1770 raidlist); 1786 1771 for (i = 0; i < ARBITRARY_MAXIMUM; ++i) { 1787 char entry[MAX_STR_LEN];1788 1772 keylist[i] = (void *) i; 1789 1773 if (i < raidrec->subdisks) { 1790 snprintf(entry, MAX_STR_LEN, "%-17s", 1791 find_dev_entry_for_raid_device_name(raidlist, 1792 raidrec-> 1793 sd[i]. 1794 which_device)); 1774 mr_asprintf(entry, "%-17s", find_dev_entry_for_raid_device_name(raidlist, raidrec->sd[i].which_device)); 1795 1775 newtListboxAppendEntry(allocListbox, entry, keylist[i]); 1776 mr_free(entry); 1796 1777 } 1797 1778 if (i < unallocparts->entries) { 1798 snprintf(entry, MAX_STR_LEN, "%-17s", 1799 unallocparts->el[i].device); 1779 mr_asprintf(entry, "%-17s", unallocparts->el[i].device); 1800 1780 newtListboxAppendEntry(unallocListbox, entry, keylist[i]); 1781 mr_free(entry); 1801 1782 } 1802 1783 } … … 1848 1829 choose_raid_level(raidrec); 1849 1830 } else if (b_res == bStripeSize) { 1850 char *tmp = NULL;1851 1852 1831 mr_asprintf(tmp, "%i", raidrec->stripesize); 1853 1832 p = popup_and_get_string("Stripe size", "Please enter the stripe size in kilobytes.", tmp); … … 1973 1952 bCancel = newtCompactButton(i += 12, 17, "Cancel"); 1974 1953 bOK = newtCompactButton(i += 12, 17, " OK "); 1975 mr_asprintf( &tmp, "%-24s %-24s %-8s %s", "Device", "Mountpoint", "Format", "Size (MB)");1954 mr_asprintf(tmp, "%-24s %-24s %-8s %s", "Device", "Mountpoint", "Format", "Size (MB)"); 1976 1955 headerMsg = newtLabel(2, 1, tmp); 1977 1956 flawsLabelA = newtLabel(2, 13, flaws_str_A); … … 2238 2217 #ifdef __FreeBSD__ 2239 2218 for (i = 0; i < raidlist->entries; i++) { 2240 mr_asprintf( &vdev, "/dev/vinum/%s", raidlist->el[i].volname);2219 mr_asprintf(vdev, "/dev/vinum/%s", raidlist->el[i].volname); 2241 2220 res = strcmp(device, vdev); 2242 2221 mr_free(vdev); … … 2365 2344 raidrec = &raidlist->el[pos_in_raidlist]; 2366 2345 initialize_raidrec(raidrec); 2367 strcpy(raidrec->OSSWAP(raid_device, volname), 2368 OSSWAP(device, basename(device))); 2346 strcpy(raidrec->OSSWAP(raid_device, volname), OSSWAP(device, basename(device))); 2369 2347 #ifndef __FreeBSD__ 2370 2348 choose_raid_level(raidrec); … … 2618 2596 char *new_dev) 2619 2597 { 2620 /** buffers ********************************************************/2621 char *tmp = NULL;2622 2623 2598 /** int ************************************************************/ 2624 2599 int pos = 0; … … 2631 2606 pos = which_raid_device_is_using_this_partition(raidlist, old_dev); 2632 2607 if (pos < 0) { 2633 mr_asprintf(&tmp, "No need to rejig %s in raidlist: it's not listed.", old_dev); 2634 log_it(tmp); 2635 mr_free(tmp); 2608 log_it("No need to rejig %s in raidlist: it's not listed.", old_dev); 2636 2609 } else { 2637 2610 if ((j = … … 2639 2612 OSSWAP(el[pos].data_disks, disks), 2640 2613 old_dev)) >= 0) { 2641 strcpy(raidlist->OSSWAP(el[pos].data_disks, disks).el[j]. 2642 device, new_dev); 2614 strcpy(raidlist->OSSWAP(el[pos].data_disks, disks).el[j].device, new_dev); 2643 2615 } else 2644 2616 if ((j = … … 2647 2619 spares), 2648 2620 old_dev)) >= 0) { 2649 strcpy(raidlist->OSSWAP(el[pos].spare_disks, spares).el[j]. 2650 device, new_dev); 2621 strcpy(raidlist->OSSWAP(el[pos].spare_disks, spares).el[j].device, new_dev); 2651 2622 } 2652 2623 #ifndef __FreeBSD__ … … 2665 2636 #endif 2666 2637 else { 2667 mr_asprintf(&tmp, "%s is supposed to be listed in this raid dev but it's not...", old_dev); 2668 log_it(tmp); 2669 mr_free(tmp); 2638 log_it("%s is supposed to be listed in this raid dev but it's not...", old_dev); 2670 2639 } 2671 2640 } -
branches/2.2.10/mondo/src/mondorestore/mondo-rstr-tools.c
r2332 r2334 206 206 { 207 207 208 /** needs malloc **/209 208 char *command = NULL; 210 char *file ;211 char *tmp ;209 char *file = NULL; 210 char *tmp = NULL; 212 211 int res; 213 212 214 malloc_string(file);215 malloc_string(tmp);216 213 assert_string_is_neither_NULL_nor_zerolength(f); 217 214 assert_string_is_neither_NULL_nor_zerolength(list_fname); … … 219 216 220 217 if (strncmp(preamble, f, strlen(preamble)) == 0) { 221 strcpy(file, f + strlen(preamble));218 mr_asprintf(file, "%s", f + strlen(preamble)); 222 219 } else { 223 strcpy(file, f);220 mr_asprintf(file, "%s", f); 224 221 } 225 222 if (file[0] == '/' && file[1] == '/') { 226 strcpy(tmp, file); 227 strcpy(file, tmp + 1); 223 mr_asprintf(tmp, "%s", file); 224 mr_free(file); 225 226 mr_asprintf(file, "%s", tmp + 1); 227 mr_free(tmp); 228 228 } 229 229 log_msg(2, "Checking to see if f=%s, file=%s, is in the list of biggiefiles", f, file); 230 230 mr_asprintf(command, "grep -E '^%s$' %s", file, list_fname); 231 mr_free(file); 232 231 233 res = run_program_and_log_output(command, FALSE); 232 234 mr_free(command); 233 paranoid_free(file);234 mr_free(tmp);235 235 if (res) { 236 236 return (FALSE); … … 429 429 } 430 430 if (res) { 431 log_msg(1, "Unable to mount device %s (type %s) at %s", device, 432 format, mountdir); 431 log_msg(1, "Unable to mount device %s (type %s) at %s", device, format, mountdir); 433 432 log_msg(1, "command was '%s'", command); 434 433 if (!strcmp(mountpoint, "swap")) { … … 479 478 char *tmp = NULL; 480 479 char *these_failed = NULL; 481 char *format;482 480 struct mountlist_itself *mountlist = NULL; 483 484 malloc_string(format);485 481 486 482 assert(p_external_copy_of_mountlist != NULL); … … 511 507 update_progress_form(tmp); 512 508 mr_free(tmp); 513 strcpy(format, mountlist->el[lino].format); 514 res = mount_device(mountlist->el[lino].device, 515 mountlist->el[lino].mountpoint, 516 format, writeable); 509 res = mount_device(mountlist->el[lino].device, mountlist->el[lino].mountpoint, mountlist->el[lino].format, writeable); 510 517 511 retval += res; 518 512 if (res) { … … 556 550 run_program_and_log_output("df -m", 3); 557 551 paranoid_free(mountlist); 558 paranoid_free(format);559 552 return (retval); 560 553 } … … 728 721 char *iso_path = NULL; 729 722 char *old_isodir = NULL; 730 char cfg_file[100];723 char *cfg_file = NULL; 731 724 t_bkptype media_specified_by_user; 732 725 … … 736 729 737 730 if (!cfgf) { 738 strcpy(cfg_file, g_mondo_cfg_file);731 cfg_file = g_mondo_cfg_file; 739 732 } else { 740 strcpy(cfg_file, cfgf);733 cfg_file = cfgf; 741 734 } 742 735 … … 1495 1488 char *conffile; 1496 1489 char *tmp = NULL; 1497 char *editor ;1490 char *editor = NULL; 1498 1491 char *p = NULL; 1499 1492 … … 1501 1494 bool done; 1502 1495 1503 malloc_string(editor);1504 1496 malloc_string(rootdev); 1505 1497 malloc_string(rootdrive); 1506 1498 malloc_string(conffile); 1507 1499 assert_string_is_neither_NULL_nor_zerolength(bd); 1508 strcpy(editor, find_my_editor());1509 1500 mr_asprintf(boot_device, "%s", bd); 1510 1501 … … 1544 1535 newtSuspend(); 1545 1536 } 1537 mr_asprintf(editor, "%s", find_my_editor()); 1538 1546 1539 mr_asprintf(tmp, "chroot %s %s /etc/fstab", MNT_RESTORING, editor); 1547 1540 paranoid_system(tmp); … … 1559 1552 paranoid_system(tmp); 1560 1553 mr_free(tmp); 1554 mr_free(editor); 1561 1555 1562 1556 if (!g_text_mode) { … … 1611 1605 paranoid_free(rootdrive); 1612 1606 paranoid_free(conffile); 1613 paranoid_free(editor);1614 1607 1615 1608 return (res); … … 1631 1624 char *command = NULL; 1632 1625 char *tmp = NULL; 1633 char *editor ;1626 char *editor = NULL; 1634 1627 1635 1628 int res; 1636 1629 int done; 1637 1630 1638 malloc_string(editor);1639 strcpy(editor, find_my_editor());1640 1631 if (offer_to_run_stabelilo 1641 1632 && ask_me_yes_or_no("Did you change the mountlist or cloned the system ?")) … … 1657 1648 newtSuspend(); 1658 1649 } 1650 mr_asprintf(editor, "%s", find_my_editor()); 1651 1659 1652 mr_asprintf(tmp, "chroot %s %s /etc/fstab", MNT_RESTORING, editor); 1660 1653 paranoid_system(tmp); … … 1664 1657 paranoid_system(tmp); 1665 1658 mr_free(tmp); 1659 1660 mr_free(editor); 1666 1661 1667 1662 if (!g_text_mode) { … … 1682 1677 res = TRUE; 1683 1678 } 1684 paranoid_free(editor);1685 1679 return (res); 1686 1680 } … … 1701 1695 char *command = NULL; 1702 1696 char *tmp = NULL; 1703 char *editor ;1697 char *editor = NULL; 1704 1698 1705 1699 int res; 1706 1700 int done; 1707 1701 bool run_lilo_M = FALSE; 1708 malloc_string(editor);1709 1702 1710 1703 if (!run_program_and_log_output … … 1713 1706 } 1714 1707 1715 strcpy(editor, find_my_editor());1716 1708 if (offer_to_run_stablilo 1717 1709 && ask_me_yes_or_no("Did you change the mountlist or cloned the system ?")) … … 1733 1725 newtSuspend(); 1734 1726 } 1727 mr_asprintf(editor, "%s", find_my_editor()); 1728 1735 1729 mr_asprintf(tmp, "%s " MNT_RESTORING "/etc/fstab", editor); 1736 1730 paranoid_system(tmp); … … 1740 1734 paranoid_system(tmp); 1741 1735 mr_free(tmp); 1736 1737 mr_free(editor); 1742 1738 1743 1739 if (!g_text_mode) { … … 1795 1791 " lilo -M /dev/sda", 3); 1796 1792 } 1797 paranoid_free(editor);1798 1793 return (res); 1799 1794 } … … 1821 1816 int done; 1822 1817 1823 malloc_string(editor);1824 1818 assert_string_is_neither_NULL_nor_zerolength(bd); 1825 1819 1826 strcpy(editor, find_my_editor());1827 1820 mr_asprintf(boot_device, "%s", bd); 1828 1821 … … 1838 1831 newtSuspend(); 1839 1832 } 1833 mr_asprintf(editor, "%s", find_my_editor()); 1840 1834 mr_asprintf(tmp, "%s " MNT_RESTORING "/etc/fstab", editor); 1835 mr_free(editor); 1836 1841 1837 paranoid_system(tmp); 1842 1838 mr_free(tmp); … … 1884 1880 mvaddstr_and_log_it(g_currentY++, 74, "Done."); 1885 1881 } 1886 paranoid_free(editor);1887 1882 return (res); 1888 1883 } -
branches/2.2.10/mondo/src/mondorestore/mondorestore.c
r2331 r2334 443 443 char *p = NULL; 444 444 char *tmp1 = NULL; 445 char *fstab_fname ;445 char *fstab_fname = NULL; 446 446 char *old_restpath = NULL; 447 447 … … 453 453 454 454 malloc_string(tmp); 455 malloc_string(fstab_fname);456 455 assert(bkpinfo != NULL); 457 456 assert(mountlist != NULL); … … 640 639 "Using tune2fs to identify your ext2,3,4 partitions"); 641 640 if (does_file_exist("/tmp/fstab.new")) { 642 strcpy(fstab_fname, "/tmp/fstab.new");641 mr_asprintf(fstab_fname, "/tmp/fstab.new"); 643 642 } else { 644 strcpy(fstab_fname, "/tmp/fstab");643 mr_asprintf(fstab_fname, "/tmp/fstab"); 645 644 } 646 645 mr_asprintf(tmp1, "label-partitions-as-necessary %s < %s >> %s 2>> %s", g_mountlist_fname, fstab_fname, MONDO_LOGFILE, MONDO_LOGFILE); 646 mr_free(fstab_fname); 647 647 648 res = system(tmp1); 648 649 mr_free(tmp1); … … 665 666 end_of_func: 666 667 paranoid_free(tmp); 667 paranoid_free(fstab_fname);668 668 log_it("Leaving interactive_mode()"); 669 669 return (retval); … … 1018 1018 1019 1019 /** malloc ***/ 1020 char *checksum ;1020 char *checksum = NULL; 1021 1021 char *outfile_fname = NULL; 1022 1022 char *tmp = NULL; 1023 1023 char *bzip2_command = NULL; 1024 char *ntfsprog_command, *suffix; 1024 char *ntfsprog_command; 1025 char *suffix = NULL; 1025 1026 char *sz_devfile = NULL; 1026 1027 char *bigblk; 1027 char *p;1028 1028 char *mds = NULL; 1029 1029 int retval = 0; … … 1031 1031 long sliceno; 1032 1032 long siz; 1033 char ntfsprog_fifo[MAX_STR_LEN];1033 char *ntfsprog_fifo = NULL; 1034 1034 char *file_to_openout = NULL; 1035 1035 struct s_filename_and_lstat_info biggiestruct; … … 1045 1045 assert(bkpinfo != NULL); 1046 1046 1047 malloc_string(checksum);1048 1047 malloc_string(ntfsprog_command); 1049 malloc_string(suffix);1050 1048 1051 1049 pathname_of_last_file_restored[0] = '\0'; … … 1067 1065 paranoid_fclose(fin); 1068 1066 1069 strcpy(checksum, biggiestruct.checksum); 1070 1067 mr_asprintf(checksum, "%s", biggiestruct.checksum); 1071 1068 if (!checksum[0]) { 1072 1069 log_msg(3, "Warning - bigfile %ld does not have a checksum", bigfileno + 1); 1073 p = checksum;1074 }1070 } 1071 mr_free(checksum); 1075 1072 1076 1073 if (!strncmp(biggiestruct.filename, "/dev/", 5)) // Whether NTFS or not :) … … 1085 1082 node = find_string_at_node(filelist, biggiestruct.filename); 1086 1083 if (!node) { 1087 log_msg(0, "Skipping %s (name isn't in filelist)", 1088 biggiestruct.filename); 1084 log_msg(0, "Skipping %s (name isn't in filelist)", biggiestruct.filename); 1089 1085 pathname_of_last_file_restored[0] = '\0'; 1090 1086 return (0); 1091 1087 } else if (!(node->selected)) { 1092 log_msg(1, "Skipping %s (name isn't in biggielist subset)", 1093 biggiestruct.filename); 1088 log_msg(1, "Skipping %s (name isn't in biggielist subset)", biggiestruct.filename); 1094 1089 pathname_of_last_file_restored[0] = '\0'; 1095 1090 return (0); 1096 1091 } 1097 1092 } 1093 1098 1094 /* otherwise, continue */ 1099 1100 1095 log_msg(1, "DEFINITELY restoring %s", biggiestruct.filename); 1101 1096 if (biggiestruct.use_ntfsprog) { 1102 1097 if (strncmp(biggiestruct.filename, "/dev/", 5)) { 1103 log_msg(1, 1104 "I was in error when I set biggiestruct.use_ntfsprog to TRUE."); 1098 log_msg(1, "I was in error when I set biggiestruct.use_ntfsprog to TRUE."); 1105 1099 log_msg(1, "%s isn't even in /dev", biggiestruct.filename); 1106 1100 biggiestruct.use_ntfsprog = FALSE; … … 1109 1103 1110 1104 if (biggiestruct.use_ntfsprog) // if it's an NTFS device 1111 // if (!strncmp ( biggiestruct.filename, "/dev/", 5))1112 1105 { 1113 1106 g_loglevel = 4; … … 1116 1109 mr_asprintf(sz_devfile, "/tmp/%d.%d.000", (int) (random() % 32768), (int) (random() % 32768)); 1117 1110 mkfifo(sz_devfile, 0x770); 1118 strcpy(ntfsprog_fifo, sz_devfile);1111 mr_asprintf(ntfsprog_fifo, "%s", sz_devfile); 1119 1112 mr_free(sz_devfile); 1120 1113 file_to_openout = ntfsprog_fifo; … … 1123 1116 fatal_error("Fork failure"); 1124 1117 case 0: 1125 log_msg(3, 1126 "CHILD - fip - calling feed_outfrom_ntfsprog(%s, %s)", 1127 biggiestruct.filename, ntfsprog_fifo); 1128 res = 1129 feed_outfrom_ntfsprog(biggiestruct.filename, 1130 ntfsprog_fifo); 1131 // log_msg(3, "CHILD - fip - exiting"); 1118 log_msg(3, "CHILD - fip - calling feed_outfrom_ntfsprog(%s, %s)", biggiestruct.filename, ntfsprog_fifo); 1119 res = feed_outfrom_ntfsprog(biggiestruct.filename, ntfsprog_fifo); 1120 mr_free(ntfsprog_fifo); 1132 1121 exit(res); 1133 1122 break; 1134 1123 default: 1135 log_msg(3, 1136 "feed_into_ntfsprog() called in background --- pid=%ld", 1137 (long int) (pid)); 1138 } 1124 log_msg(3, "feed_into_ntfsprog() called in background --- pid=%ld", (long int) (pid)); 1125 } 1126 mr_free(ntfsprog_fifo); 1139 1127 } else { 1140 1128 use_ntfsprog_hack = FALSE; 1141 ntfsprog_fifo[0] = '\0';1142 1129 file_to_openout = outfile_fname; 1143 1130 if (!does_file_exist(outfile_fname)) // yes, it looks weird with the '!' but it's correct that way … … 1155 1142 */ 1156 1143 1157 strncpy(pathname_of_last_file_restored, biggiestruct.filename, 1158 MAX_STR_LEN - 1); 1144 strncpy(pathname_of_last_file_restored, biggiestruct.filename, MAX_STR_LEN - 1); 1159 1145 pathname_of_last_file_restored[MAX_STR_LEN - 1] = '\0'; 1160 1146 … … 1167 1153 1168 1154 for (sliceno = 1, finished = FALSE; !finished;) { 1169 if (!does_file_exist 1170 (slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "")) 1171 && 1172 !does_file_exist(slice_fname 1173 (bigfileno, sliceno, ARCHIVES_PATH, "lzo")) 1174 && 1175 !does_file_exist(slice_fname 1176 (bigfileno, sliceno, ARCHIVES_PATH, "gz")) 1177 && 1178 !does_file_exist(slice_fname 1179 (bigfileno, sliceno, ARCHIVES_PATH, "bz2"))) { 1180 log_msg(3, 1181 "Cannot find a data slice or terminator slice on CD %d", 1182 g_current_media_number); 1155 if (!does_file_exist(slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "")) && 1156 !does_file_exist(slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "lzo")) && 1157 !does_file_exist(slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "gz")) && 1158 !does_file_exist(slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "bz2"))) { 1159 log_msg(3, "Cannot find a data slice or terminator slice on CD %d", g_current_media_number); 1183 1160 g_current_media_number++; 1184 1161 mds = media_descriptor_string(bkpinfo->backup_media_type); … … 1193 1170 mr_asprintf(tmp, "%s", slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "")); 1194 1171 if (does_file_exist(tmp) && length_of_file(tmp) == 0) { 1195 log_msg(2, 1196 "End of bigfile # %ld (slice %ld is the terminator)", 1197 bigfileno + 1, sliceno); 1172 log_msg(2, "End of bigfile # %ld (slice %ld is the terminator)", bigfileno + 1, sliceno); 1198 1173 finished = TRUE; 1199 1174 mr_free(tmp); 1200 1175 continue; 1201 1176 } else { 1202 if (does_file_exist 1203 (slice_fname 1204 (bigfileno, sliceno, ARCHIVES_PATH, "lzo"))) { 1177 if (does_file_exist(slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "lzo"))) { 1205 1178 mr_asprintf(bzip2_command, "lzop"); 1206 strcpy(suffix, "lzo");1179 mr_asprintf(suffix, "lzo"); 1207 1180 } else 1208 if (does_file_exist 1209 (slice_fname 1210 (bigfileno, sliceno, ARCHIVES_PATH, "gz"))) { 1181 if (does_file_exist(slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "gz"))) { 1211 1182 mr_asprintf(bzip2_command, "gzip"); 1212 strcpy(suffix, "gz");1183 mr_asprintf(suffix, "gz"); 1213 1184 } else 1214 if (does_file_exist 1215 (slice_fname 1216 (bigfileno, sliceno, ARCHIVES_PATH, "bz2"))) { 1185 if (does_file_exist(slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "bz2"))) { 1217 1186 mr_asprintf(bzip2_command, "bzip2"); 1218 strcpy(suffix, "bz2");1187 mr_asprintf(suffix, "bz2"); 1219 1188 } else 1220 if (does_file_exist 1221 (slice_fname 1222 (bigfileno, sliceno, ARCHIVES_PATH, ""))) { 1189 if (does_file_exist(slice_fname(bigfileno, sliceno, ARCHIVES_PATH, ""))) { 1223 1190 mr_asprintf(bzip2_command, ""); 1224 strcpy(suffix, "");1191 mr_asprintf(suffix, ""); 1225 1192 } else { 1226 1193 log_to_screen("OK, that's pretty fsck0red..."); … … 1235 1202 mr_asprintf(bzip2_command, "cat %s 2>> %s", slice_fname(bigfileno, sliceno, ARCHIVES_PATH, suffix), MONDO_LOGFILE); 1236 1203 } 1204 mr_free(suffix); 1205 1237 1206 mds = media_descriptor_string(bkpinfo->backup_media_type); 1238 1207 mr_asprintf(tmp, "Working on %s #%d, file #%ld, slice #%ld ", mds, g_current_media_number, bigfileno + 1, sliceno); … … 1288 1257 mr_free(outfile_fname); 1289 1258 paranoid_free(bigblk); 1290 paranoid_free(checksum);1291 1259 paranoid_free(ntfsprog_command); 1292 paranoid_free(suffix);1293 1260 1294 1261 return (retval); … … 1331 1298 char *ntfsprog_command; 1332 1299 char *sz_devfile = NULL; 1333 char *ntfsprog_fifo ;1300 char *ntfsprog_fifo = NULL; 1334 1301 char *file_to_openout = NULL; 1335 1302 … … 1350 1317 1351 1318 malloc_string(tmp); 1352 malloc_string(ntfsprog_fifo);1353 1319 malloc_string(ntfsprog_command); 1354 1320 old_loglevel = g_loglevel; … … 1407 1373 mr_asprintf(sz_devfile, "%s/%d.%d.000", bkpinfo->tmpdir, (int) (random() % 32768), (int) (random() % 32768)); 1408 1374 mkfifo(sz_devfile, 0x770); 1409 strcpy(ntfsprog_fifo, sz_devfile);1375 mr_asprintf(ntfsprog_fifo, "%s", sz_devfile); 1410 1376 mr_free(sz_devfile); 1411 1377 … … 1417 1383 log_msg(3, "CHILD - fip - calling feed_outfrom_ntfsprog(%s, %s)", outfile_fname, ntfsprog_fifo); 1418 1384 res = feed_outfrom_ntfsprog(outfile_fname, ntfsprog_fifo); 1385 mr_free(ntfsprog_fifo); 1419 1386 exit(res); 1420 1387 break; … … 1422 1389 log_msg(3, "feed_into_ntfsprog() called in background --- pid=%ld", (long int) (pid)); 1423 1390 } 1391 mr_free(ntfsprog_fifo); 1424 1392 } else { 1425 1393 if (!strncmp(orig_bf_fname, "/dev/", 5)) { … … 1431 1399 } 1432 1400 use_ntfsprog_hack = FALSE; 1433 ntfsprog_fifo[0] = '\0';1434 1401 file_to_openout = outfile_fname; 1435 1402 if (!does_file_exist(outfile_fname)) // yes, it looks weird with the '!' but it's correct that way … … 1539 1506 paranoid_free(tmp); 1540 1507 paranoid_free(ntfsprog_command); 1541 paranoid_free(ntfsprog_fifo);1542 1508 g_loglevel = old_loglevel; 1543 1509 return (retval); … … 2099 2065 char *tarball_fname = NULL; 2100 2066 char *progress_str = NULL; 2101 char *comment;2102 2103 malloc_string(comment);2104 2067 2105 2068 assert(bkpinfo != NULL); … … 2182 2145 mr_strcat(tmp1, " (%d attempts) - review logs", attempts); 2183 2146 } 2184 strcpy(comment, tmp1); 2147 if (attempts > 1) { 2148 log_to_screen(tmp1); 2149 } 2185 2150 mr_free(tmp1); 2186 if (attempts > 1) {2187 log_to_screen(comment);2188 }2189 2151 2190 2152 retval += res; … … 2203 2165 mvaddstr_and_log_it(g_currentY++, 74, "Done."); 2204 2166 } 2205 paranoid_free(comment);2206 2167 2207 2168 return (retval); … … 2633 2594 struct raidlist_itself *raidlist; 2634 2595 struct s_node *filelist; 2635 char *a, *b; 2596 char *tmp1 = NULL; 2597 char *tmp2 = NULL; 2636 2598 bool run_postnuke = FALSE; 2637 2599 … … 2663 2625 run_program_and_log_output("mkdir -p " MNT_CDROM, FALSE); 2664 2626 2665 malloc_string(a);2666 malloc_string(b);2667 2627 setup_MR_global_filenames(); // malloc() and set globals, using bkpinfo->tmpdir etc. 2668 2628 bkpinfo->backup_media_type = none; // in case boot disk was made for one backup type but user wants to restore from another backup type … … 2753 2713 toggle_path_selection(filelist, "/usr/share", TRUE); 2754 2714 save_filelist(filelist, "/tmp/out.txt"); 2755 strcpy(a, argv[3]); 2756 strcpy(b, argv[4]); 2757 2758 res = save_filelist_entries_in_common(a, filelist, b, FALSE); 2715 mr_asprintf(tmp1, "%s", argv[3]); 2716 mr_asprintf(tmp2, "%s", argv[4]); 2717 2718 res = save_filelist_entries_in_common(tmp1, filelist, tmp2, FALSE); 2719 mr_free(tmp1); 2720 mr_free(tmp2); 2721 2759 2722 free_filelist(filelist); 2760 2723 printf("res = %d", res); … … 3029 2992 paranoid_MR_finish(retval); // frees global stuff plus bkpinfo 3030 2993 free_libmondo_global_strings(); // it's fine to have this here :) really :) 3031 paranoid_free(a);3032 paranoid_free(b);3033 2994 3034 2995 unlink("/tmp/filelist.full"); -
branches/2.2.10/mondo/test/test-mem.c
r2310 r2334 30 30 is_null(str); 31 31 32 mr_asprintf( &str, "%s is %d", "two", 2);32 mr_asprintf(str, "%s is %d", "two", 2); 33 33 printf("*** String is %s\n",str); 34 34 -
branches/2.2.10/mondo/test/test-string.c
r2310 r2334 22 22 char *string = NULL; 23 23 24 mr_asprintf( &string, "%s", "md0 : active raid10 hda1[0] hda12[3] hda6[2] hda5[1]\n");24 mr_asprintf(string, "%s", "md0 : active raid10 hda1[0] hda12[3] hda6[2] hda5[1]\n"); 25 25 fprintf(stdout, "string=|%s|\n", string); 26 26 token = mr_strtok(string, delims, &lastpos); -
branches/2.2.10/tools/quality
r2332 r2334 46 46 cat /tmp/mondo.quality 47 47 echo "mondorescue uses : `cat /tmp/mondo.quality | wc -l` getline without &" 48 pbg mr_asprintf | grep -vE '"|FNAME|ISOFS|syscall_sprintf|mr_mem|quality' > /tmp/mondo.quality48 pbg -w mr_asprintf | grep -vE '"|FNAME|ISOFS|syscall_sprintf|mr_mem|quality' > /tmp/mondo.quality 49 49 cat /tmp/mondo.quality 50 50 echo "mondorescue uses : `cat /tmp/mondo.quality | wc -l` mr_asprintf without \"" 51 find . -name '*.c' -o -name '*.h' | egrep -v '\.svn|/\*|monitas|/\*|mindi-busybox' | xargs grep -rw mr_getline | egrep -v '/\*' | egrep -v 'mr_getline\(&' > /tmp/mondo.quality51 pbg 'mr_asprintf\(\&' > /tmp/mondo.quality 52 52 cat /tmp/mondo.quality 53 echo "monodrescue uses : `cat /tmp/mondo.quality | wc -l` mr_getline without &" 53 echo "mondorescue uses : `cat /tmp/mondo.quality | wc -l` mr_asprintf with \&" 54 pbg 'mr_getline\(\&' > /tmp/mondo.quality 55 cat /tmp/mondo.quality 56 echo "mondorescue uses : `cat /tmp/mondo.quality | wc -l` mr_getline with \&" 54 57 55 58 echo " "
Note:
See TracChangeset
for help on using the changeset viewer.