Changeset 1081 in MondoRescue
- Timestamp:
- Jan 28, 2007, 11:20:07 PM (18 years ago)
- Location:
- trunk
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mindi/install.sh
r1079 r1081 12 12 local=${HEAD}$PREFIX 13 13 sublocal=$PREFIX 14 if [ -f /usr/local/sbin/mindi ]; then15 echo "WARNING: /usr/local/sbin/mindi exists. You should probably remove your manual installation !"16 fi17 14 if [ "_$CONFDIR" != "_" ]; then 18 15 conf=${HEAD}$CONFDIR/mindi … … 22 19 exit -1 23 20 fi 24 echo $PATH | grep /usr/sbin > /dev/null || echo "Warning - your PATH environmental variable is BROKEN. Please add /usr/sbin to your PATH."25 21 else 26 22 local=/usr/local … … 144 140 install -m 644 ChangeLog COPYING README README.busybox README.ia64 README.pxe TODO INSTALL svn.log $DOCDIR 145 141 146 if [ ! -f $locallib/mindi/rootfs/bin/busybox ]; then142 if [ "_$PREFIX" = "_" && ! -f $locallib/mindi/rootfs/bin/busybox ]; then 147 143 echo "WARNING: no busybox found, mindi will not work on this arch ($ARCH)" 148 144 fi -
trunk/mondo/src/common/libmondo-archive.c
r1079 r1081 820 820 821 821 if (g_getfattr) { 822 asprintf(&tmp1, "%s/XATTR", bkpinfo->tmpdir);822 mr_asprintf(&tmp1, "%s/XATTR", bkpinfo->tmpdir); 823 823 if (write_one_liner_data_file(tmp1, "TRUE")) { 824 824 log_msg(1, "%ld: Unable to write one-liner XATTR", … … 828 828 } 829 829 if (g_getfacl) { 830 asprintf(&tmp1, "%s/ACL", bkpinfo->tmpdir);830 mr_asprintf(&tmp1, "%s/ACL", bkpinfo->tmpdir); 831 831 if (write_one_liner_data_file(tmp1, "TRUE")) { 832 832 log_msg(1, "%ld: Unable to write one-liner ACL", … … 860 860 861 861 if (bkpinfo->backup_media_type == usb) { 862 asprintf(&tmp2, "--usb %s", bkpinfo->media_device);863 } else { 864 asprintf(&tmp2,"");862 mr_asprintf(&tmp2, "--usb %s", bkpinfo->media_device); 863 } else { 864 mr_asprintf(&tmp2,""); 865 865 } 866 866 … … 1486 1486 malloc_string(result_str); 1487 1487 transfer_block = 1488 m alloc(sizeof(struct s_bkpinfo) + BKPINFO_LOC_OFFSET + 64);1488 mr_malloc(sizeof(struct s_bkpinfo) + BKPINFO_LOC_OFFSET + 64); 1489 1489 memset((void *) transfer_block, 0, 1490 1490 sizeof(struct s_bkpinfo) + BKPINFO_LOC_OFFSET + 64); -
trunk/mondo/src/common/libmondo-filelist.c
r1046 r1081 455 455 mr_asprintf(&strtmp, syscall_sprintf, mr_stresc(file_to_analyze, "`$\\\"", '\\')); 456 456 mr_asprintf(&syscall, "%s 2>> /dev/null", strtmp); 457 paranoid_free(strtmp);457 mr_free(strtmp); 458 458 call_exe_and_pipe_output_to_fd(syscall, pout); 459 459 mr_free(syscall); … … 766 766 } 767 767 // add here 768 if (!(newnode = (struct s_node *) malloc(sizeof(struct s_node)))) { 769 log_to_screen(_("failed to malloc")); 770 depth--; 771 return (1); 772 } 768 newnode = (struct s_node *) mr_malloc(sizeof(struct s_node)); 773 769 if (char_to_add < node->ch) // add to the left of node 774 770 { … … 796 792 log_msg(6, "Adding remaining chars ('%s')", string_to_add + 1); 797 793 for (i = 1; i < noof_chars; i++) { 798 if (! 799 (node->down = 800 (struct s_node *) malloc(sizeof(struct s_node)))) { 801 log_to_screen(_("%s - failed to malloc"), string_to_add); 802 return (1); 794 node->down = (struct s_node *) mr_malloc(sizeof(struct s_node)); 803 795 } 804 796 node = node->down; … … 858 850 } 859 851 g_original_noof_lines_in_filelist = lines_in_filelist; 860 if (!(filelist = (struct s_node *) malloc(sizeof(struct s_node)))) { 861 return (NULL); 862 } 852 filelist = (struct s_node *) mr_malloc(sizeof(struct s_node)); 863 853 filelist->ch = '/'; 864 854 filelist->right = NULL; 865 filelist->down = m alloc(sizeof(struct s_node));855 filelist->down = mr_malloc(sizeof(struct s_node)); 866 856 filelist->expanded = filelist->selected = FALSE; 867 857 (filelist->down)->ch = '\0'; -
trunk/mondo/src/common/libmondo-fork.c
r1079 r1081 3 3 */ 4 4 #include "my-stuff.h" 5 #include "mr_mem.h" 5 6 #include "mondostructures.h" 6 7 #include "libmondo-fork.h" … … 79 80 assert_string_is_neither_NULL_nor_zerolength(isofile); 80 81 assert_string_is_neither_NULL_nor_zerolength(logstub); 81 if (!(midway_call = malloc(1200))) { 82 fatal_error("Cannot malloc midway_call"); 83 } 84 if (!(ultimate_call = malloc(1200))) { 85 fatal_error("Cannot malloc ultimate_call"); 86 } 87 if (!(tmp = malloc(1200))) { 88 fatal_error("Cannot malloc tmp"); 89 } 82 midway_call = mr_malloc(1200); 83 ultimate_call = mr_malloc(1200); 84 tmp = mr_malloc(1200); 90 85 91 86 mr_asprintf(&cd_number_str, "%d", cd_no); … … 350 345 log_msg(5, "Opening."); 351 346 bufcap = 256L * 1024L; 352 if (!(buf = malloc(bufcap))) { 353 fatal_error("Failed to malloc() buf"); 354 } 347 buf = mr_malloc(bufcap); 355 348 356 349 if (direction == 'w') { -
trunk/mondo/src/common/libmondo-mountlist.c
r900 r1081 1 /* $Id$2 subroutines for handling mountlist 1 /* subroutines for handling mountlist 2 $Id$ 3 3 */ 4 4 … … 16 16 #include "libmondo-string-EXT.h" 17 17 #include "newt-specific-EXT.h" 18 #include "mr_mem.h" 18 19 #include "mr_mem.h" 19 20 … … 753 754 /*@ initialize ******************************************************* */ 754 755 755 drivelist = m alloc(sizeof(struct list_of_disks));756 drivelist = mr_malloc(sizeof(struct list_of_disks)); 756 757 assert(mountlist != NULL); 757 758 -
trunk/mondo/src/common/libmondo-raid.c
r1079 r1081 18 18 #include "mr_mem.h" 19 19 #include "mr_str.h" 20 #include "mr_mem.h" 20 21 21 22 #ifdef __FreeBSD__ … … 817 818 int i, j; 818 819 static char **ret; 819 ret = (char **) m alloc(nval * sizeof(char *));820 ret = (char **) mr_malloc(nval * sizeof(char *)); 820 821 for (i = 0; i < (argc - nval); ++i) { 821 822 if (!strcmp(argv[i], option)) { 822 823 for (j = 0; j < nval; ++j) { 823 ret[j] = (char *) m alloc(strlen(argv[i + j + 1]) + 1);824 ret[j] = (char *) mr_malloc(strlen(argv[i + j + 1]) + 1); 824 825 strcpy(ret[j], argv[i + j + 1]); 825 826 } … … 1175 1176 int retval = 0; 1176 1177 1177 raidlist = m alloc(sizeof(struct raidlist_itself));1178 raidlist = mr_malloc(sizeof(struct raidlist_itself)); 1178 1179 1179 1180 // FIXME: Prefix '/dev/' should really be dynamic! -
trunk/mondo/src/common/libmondo-stream.c
r979 r1081 13 13 14 14 #include "my-stuff.h" 15 #include "mr_mem.h" 15 16 #include "mondostructures.h" 16 17 #include "libmondo-devices.h" … … 106 107 int i; 107 108 108 blk = (char *) m alloc(256 * 1024);109 blk = (char *) mr_malloc(256 * 1024); 109 110 110 111 log_it("closein_tape() -- entering"); … … 153 154 char *blk; 154 155 155 blk = (char *) m alloc(256 * 1024);156 blk = (char *) mr_malloc(256 * 1024); 156 157 157 158 sleep(1); … … 624 625 625 626 assert_string_is_neither_NULL_nor_zerolength(bkpinfo->media_device); 626 if (!(g_tapecatalog = malloc(sizeof(struct s_tapecatalog)))) { 627 fatal_error("Cannot alloc mem for tape catalog"); 628 } 627 g_tapecatalog = mr_malloc(sizeof(struct s_tapecatalog)); 629 628 g_tapecatalog->entries = 0; 630 629 g_tape_posK = 0; … … 658 657 return (-1); 659 658 } 660 if (!(datablock = (char *) malloc(256 * 1024))) { 661 log_to_screen(_("Unable to malloc 256*1024")); 662 exit(1); 663 } 659 datablock = (char *) mr_malloc(256 * 1024); 664 660 for (i = 0; i < 32; i++) { 665 661 for (j = 0; j < 4; j++) { … … 726 722 /* initialise the catalog */ 727 723 g_current_media_number = 1; 728 if (!(g_tapecatalog = malloc(sizeof(struct s_tapecatalog)))) { 729 fatal_error("Cannot alloc mem for tape catalog"); 730 } 724 g_tapecatalog = mr_malloc(sizeof(struct s_tapecatalog)); 731 725 g_tapecatalog->entries = 0; 732 726 /* log stuff */ … … 759 753 return (0); 760 754 } 761 if (!(g_tapecatalog = malloc(sizeof(struct s_tapecatalog)))) { 762 fatal_error("Cannot alloc mem for tape catalog"); 763 } 755 g_tapecatalog = mr_malloc(sizeof(struct s_tapecatalog)); 764 756 g_tapecatalog->entries = 0; 765 757 g_tape_posK = 0; … … 872 864 873 865 /*@ init ******************************************************* */ 874 datablock = m alloc(TAPE_BLOCK_SIZE);866 datablock = mr_malloc(TAPE_BLOCK_SIZE); 875 867 crc16 = 0; 876 868 crctt = 0; … … 1003 995 /*@ end vars *************************************************** */ 1004 996 1005 tempblock = (char *) m alloc((size_t) TAPE_BLOCK_SIZE);997 tempblock = (char *) mr_malloc((size_t) TAPE_BLOCK_SIZE); 1006 998 1007 999 for (i = 0; i < (int) TAPE_BLOCK_SIZE; i++) { … … 1142 1134 long bytes_to_write; 1143 1135 1144 datablock = m alloc(TAPE_BLOCK_SIZE);1136 datablock = mr_malloc(TAPE_BLOCK_SIZE); 1145 1137 pB = strrchr(the_file_I_was_reading, '/'); 1146 1138 if (pB) { -
trunk/mondo/src/common/libmondo-string.c
r900 r1081 9 9 10 10 #include "my-stuff.h" 11 #include "mr_mem.h" 11 12 #include "mondostructures.h" 12 13 #include "libmondo-string.h" -
trunk/mondo/src/common/libmondo-tools.c
r1079 r1081 9 9 10 10 #include "my-stuff.h" 11 #include "mr_mem.h" 11 12 #include "mondostructures.h" 12 13 #include "libmondo-tools.h" -
trunk/mondo/src/common/libmondo-verify.c
r1079 r1081 8 8 9 9 #include "my-stuff.h" 10 #include "mr_mem.h" 10 11 #include "mondostructures.h" 11 12 #include "libmondo-verify.h" … … 221 222 222 223 if (!bufblkA) { 223 if (!(bufblkA = malloc(maxbufsize))) { 224 fatal_error("Cannot malloc bufblkA"); 225 } 224 bufblkA = mr_malloc(maxbufsize); 226 225 } 227 226 if (!bufblkB) { 228 if (!(bufblkB = malloc(maxbufsize))) { 229 fatal_error("Cannot malloc bufblkB"); 230 } 227 bufblkB = mr_malloc(maxbufsize); 231 228 } 232 229 … … 685 682 } 686 683 mr_free(biggie_cksum); 687 688 684 return (retval); 689 685 } -
trunk/mondo/src/common/newt-specific.c
r1074 r1081 18 18 19 19 #include "my-stuff.h" 20 #include "mr_mem.h" 20 21 #include "mondostructures.h" 21 22 #include "newt-specific.h" … … 869 870 870 871 err_log_lines = 871 (char **) m alloc(sizeof(char *) * g_noof_log_lines);872 (char **) mr_malloc(sizeof(char *) * g_noof_log_lines); 872 873 if (!err_log_lines) { 873 874 fatal_error("Out of memory"); … … 1491 1492 } 1492 1493 1493 filelist = (struct s_filelist *) m alloc(sizeof(struct s_filelist));1494 filelist = (struct s_filelist *) mr_malloc(sizeof(struct s_filelist)); 1494 1495 fileListbox = 1495 1496 newtListbox(2, 2, 12, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT); -
trunk/mondo/src/include/my-stuff.h
r1079 r1081 14 14 #define NOOF_ERR_LINES 6 15 15 16 #define paranoid_free(exp) mr_free(exp)17 18 16 /** 19 17 * @file … … 22 20 23 21 #include <stdio.h> 22 #include "mr_mem.h" 24 23 25 24 #if !defined(bool) && !defined(__cplusplus) … … 286 285 * Malloc @p x to be MAX_STR_LEN bytes and call fatal_error() if we're out of memory. 287 286 */ 288 #define malloc_string(x) { x = (char *)m alloc(MAX_STR_LEN); if (!x) { fatal_error("Unable to malloc"); }x[0] = x[1] = '\0'; }287 #define malloc_string(x) { x = (char *)mr_malloc(MAX_STR_LEN); x[0] = x[1] = '\0'; } 289 288 290 289 /** -
trunk/mondo/src/mondoarchive/main.c
r932 r1081 1 /* 2 * $Id$ 3 * * 4 * This program is free software; you can redistribute it and/or modify * 5 * it under the terms of the GNU General Public License as published by * 6 * the Free Software Foundation; either version 2 of the License, or * 7 * (at your option) any later version. * 8 * * 9 *************************************************************************** 1 /*************************************************************************** 2 * $Id$ 3 */ 4 5 6 /** 7 * @file 10 8 * The main file for mondoarchive. 11 9 */ … … 176 174 diffs = 0; 177 175 printf(_("Initializing...\n")); 178 if (!(bkpinfo = malloc(sizeof(struct s_bkpinfo)))) { 179 fatal_error("Cannot malloc bkpinfo"); 180 } 176 bkpinfo = mr_malloc(sizeof(struct s_bkpinfo)); 181 177 182 178 /* Initialize Configuration Structure */ -
trunk/mondo/src/mondoarchive/mondo-cli.c
r1079 r1081 1 1 /*************************************************************************** 2 * $Id$ 3 * 2 $Id$ 3 *******************************************************************/ 4 5 /** 6 * @file 4 7 * Functions for handling command-line arguments passed to mondoarchive. 5 8 */ … … 522 525 if (flag_set['z']) { 523 526 if (find_home_of_exe("getfattr")) { 524 asprintf(&g_getfattr,"getfattr");527 mr_asprintf(&g_getfattr,"getfattr"); 525 528 } 526 529 if (find_home_of_exe("getfacl")) { 527 asprintf(&g_getfacl,"getfacl");530 mr_asprintf(&g_getfacl,"getfacl"); 528 531 } 529 532 } -
trunk/mondo/src/mondorestore/mondo-prep.c
r900 r1081 1 1 /*************************************************************************** 2 * $Id 3 * */2 * $Id$ 3 */ 4 4 5 5 /** … … 61 61 if (does_file_exist("/tmp/i-want-my-lvm")) // FIXME - cheating :) 62 62 { 63 drivelist = m alloc(sizeof(struct list_of_disks));63 drivelist = mr_malloc(sizeof(struct list_of_disks)); 64 64 make_list_of_drives_in_mountlist(mountlist, drivelist); 65 65 for (lino = 0; lino < drivelist->entries; lino++) { … … 522 522 } 523 523 } 524 525 524 return (0); 526 525 } … … 544 543 545 544 /** buffers ***********************************************************/ 546 char *devices = NULL; 547 char *strtmp = NULL; 548 char *level = NULL; 549 char *program = NULL; 550 551 // leave straight away if raidlist is initial or has no entries 552 if (!raidlist || raidlist->entries == 0) { 553 log_msg(1, "No RAID arrays found."); 554 return 1; 555 } else { 556 log_msg(1, "%d RAID arrays found.", raidlist->entries); 557 } 558 // find raidlist entry for requested device 559 for (i = 0; i < raidlist->entries; i++) { 560 if (!strcmp(raidlist->el[i].raid_device, device)) 561 break; 562 } 563 // check whether RAID device was found in raidlist 564 if (i == raidlist->entries) { 565 log_msg(1, "RAID device %s not found in list.", device); 566 return 1; 567 } 568 // create device list from normal disks followed by spare ones 569 mr_asprintf(&devices, raidlist->el[i].data_disks.el[0].device); 570 for (j = 1; j < raidlist->el[i].data_disks.entries; j++) { 571 mr_asprintf(&strtmp, "%s", devices); 572 mr_free(devices); 573 mr_asprintf(&devices, "%s %s", strtmp, 574 raidlist->el[i].data_disks.el[j].device); 575 mr_free(strtmp); 576 } 577 for (j = 0; j < raidlist->el[i].spare_disks.entries; j++) { 578 mr_asprintf(&strtmp, "%s", devices); 579 mr_free(devices); 580 mr_asprintf(&devices, "%s %s", strtmp, 581 raidlist->el[i].spare_disks.el[j].device); 582 mr_free(strtmp); 583 } 584 // translate RAID level 585 if (raidlist->el[i].raid_level == -2) { 586 mr_asprintf(&level, "multipath"); 587 } else if (raidlist->el[i].raid_level == -1) { 588 mr_asprintf(&level, "linear"); 589 } else { 590 mr_asprintf(&level, "raid%d", raidlist->el[i].raid_level); 591 } 592 // create RAID device: 593 // - RAID device, number of devices and devices mandatory 594 // - parity algorithm, chunk size and spare devices optional 595 // - faulty devices ignored 596 // - persistent superblock always used as this is recommended 597 mr_asprintf(&program, 598 "mdadm --create --force --run --auto=yes %s --level=%s --raid-devices=%d", 599 raidlist->el[i].raid_device, level, 600 raidlist->el[i].data_disks.entries); 601 if (raidlist->el[i].parity != -1) { 602 mr_asprintf(&strtmp, "%s", program); 603 mr_free(program); 604 switch (raidlist->el[i].parity) { 605 case 0: 606 mr_asprintf(&program, "%s --parity=%s", strtmp, "la"); 607 break; 608 case 1: 609 mr_asprintf(&program, "%s --parity=%s", strtmp, "ra"); 610 break; 611 case 2: 612 mr_asprintf(&program, "%s --parity=%s", strtmp, "ls"); 613 break; 614 case 3: 615 mr_asprintf(&program, "%s --parity=%s", strtmp, "rs"); 616 break; 617 default: 618 fatal_error("Unknown RAID parity algorithm."); 619 break; 620 } 621 mr_free(strtmp); 622 } 623 if (raidlist->el[i].chunk_size != -1) { 624 mr_asprintf(&strtmp, "%s", program); 625 mr_free(program); 626 mr_asprintf(&program, "%s --chunk=%d", strtmp, 627 raidlist->el[i].chunk_size); 628 mr_free(strtmp); 629 } 630 if (raidlist->el[i].spare_disks.entries > 0) { 631 mr_asprintf(&strtmp, "%s", program); 632 mr_free(program); 633 mr_asprintf(&program, "%s --spare-devices=%d", strtmp, 634 raidlist->el[i].spare_disks.entries); 635 mr_free(strtmp); 636 } 637 mr_asprintf(&strtmp, "%s", program); 638 mr_free(program); 639 mr_asprintf(&program, "%s %s", strtmp, devices); 640 mr_free(strtmp); 641 res = run_program_and_log_output(program, 1); 642 // free memory 643 mr_free(devices); 644 mr_free(level); 645 mr_free(program); 646 // return to calling instance 647 return res; 545 char *devices = NULL; 546 char *strtmp = NULL; 547 char *level = NULL; 548 char *program = NULL; 549 550 // leave straight away if raidlist is initial or has no entries 551 if (!raidlist || raidlist->entries == 0) { 552 log_msg(1, "No RAID arrays found."); 553 return 1; 554 } else { 555 log_msg(1, "%d RAID arrays found.", raidlist->entries); 556 } 557 // find raidlist entry for requested device 558 for (i = 0; i < raidlist->entries; i++) { 559 if (!strcmp(raidlist->el[i].raid_device, device)) break; 560 } 561 // check whether RAID device was found in raidlist 562 if (i == raidlist->entries) { 563 log_msg(1, "RAID device %s not found in list.", device); 564 return 1; 565 } 566 // create device list from normal disks followed by spare ones 567 mr_asprintf(&devices, raidlist->el[i].data_disks.el[0].device); 568 for (j = 1; j < raidlist->el[i].data_disks.entries; j++) { 569 mr_asprintf(&strtmp, "%s", devices); 570 mr_free(devices); 571 mr_asprintf(&devices, "%s %s", strtmp, 572 raidlist->el[i].data_disks.el[j].device); 573 mr_free(strtmp); 574 } 575 for (j = 0; j < raidlist->el[i].spare_disks.entries; j++) { 576 mr_asprintf(&strtmp, "%s", devices); 577 mr_free(devices); 578 mr_asprintf(&devices, "%s %s", strtmp, 579 raidlist->el[i].spare_disks.el[j].device); 580 mr_free(strtmp); 581 } 582 // translate RAID level 583 if (raidlist->el[i].raid_level == -2) { 584 mr_asprintf(&level, "multipath"); 585 } else if (raidlist->el[i].raid_level == -1) { 586 mr_asprintf(&level, "linear"); 587 } else { 588 mr_asprintf(&level, "raid%d", raidlist->el[i].raid_level); 589 } 590 // create RAID device: 591 // - RAID device, number of devices and devices mandatory 592 // - parity algorithm, chunk size and spare devices optional 593 // - faulty devices ignored 594 // - persistent superblock always used as this is recommended 595 mr_asprintf(&program, 596 "mdadm --create --force --run --auto=yes %s --level=%s --raid-devices=%d", 597 raidlist->el[i].raid_device, level, 598 raidlist->el[i].data_disks.entries); 599 if (raidlist->el[i].parity != -1) { 600 asprintf(&strtmp, "%s", program); 601 mr_free(program); 602 switch(raidlist->el[i].parity) { 603 case 0: 604 mr_asprintf(&program, "%s --parity=%s", strtmp, "la"); 605 break; 606 case 1: 607 mr_asprintf(&program, "%s --parity=%s", strtmp, "ra"); 608 break; 609 case 2: 610 mr_asprintf(&program, "%s --parity=%s", strtmp, "ls"); 611 break; 612 case 3: 613 mr_asprintf(&program, "%s --parity=%s", strtmp, "rs"); 614 break; 615 default: 616 fatal_error("Unknown RAID parity algorithm."); 617 break; 618 } 619 mr_free(strtmp); 620 } 621 if (raidlist->el[i].chunk_size != -1) { 622 mr_asprintf(&strtmp, "%s", program); 623 mr_free(program); 624 mr_asprintf(&program, "%s --chunk=%d", strtmp, raidlist->el[i].chunk_size); 625 mr_free(strtmp); 626 } 627 if (raidlist->el[i].spare_disks.entries > 0) { 628 mr_asprintf(&strtmp, "%s", program); 629 mr_free(program); 630 mr_asprintf(&program, "%s --spare-devices=%d", strtmp, 631 raidlist->el[i].spare_disks.entries); 632 mr_free(strtmp); 633 } 634 mr_asprintf(&strtmp, "%s", program); 635 mr_free(program); 636 mr_asprintf(&program, "%s %s", strtmp, devices); 637 mr_free(strtmp); 638 res = run_program_and_log_output(program, 1); 639 // free memory 640 mr_free(devices); 641 mr_free(level); 642 mr_free(program); 643 // return to calling instance 644 return res; 648 645 } 649 646 … … 1551 1548 mr_free(command); 1552 1549 mr_free(device_str); 1553 1554 1550 return r; 1555 1551 } … … 1643 1639 mr_free(device_str); 1644 1640 mr_free(format); 1645 1646 1641 return (1); 1647 1642 } … … 1955 1950 /** end ************************************************************/ 1956 1951 1957 drivelist = m alloc(sizeof(struct list_of_disks));1952 drivelist = mr_malloc(sizeof(struct list_of_disks)); 1958 1953 assert(mountlist != NULL); 1959 1954 … … 2168 2163 mr_free(partcode); 2169 2164 2170 2171 2165 return (res); 2172 2166 } … … 2518 2512 mr_free(tmp); 2519 2513 2520 drivemntlist = m alloc(sizeof(struct mountlist_reference));2514 drivemntlist = mr_malloc(sizeof(struct mountlist_reference)); 2521 2515 drivemntlist->el = 2522 malloc(sizeof(struct mountlist_line *) * MAX_TAPECATALOG_ENTRIES); 2523 2524 if (!drivemntlist) { 2525 fatal_error("Cannot malloc temporary mountlist\n"); 2526 } 2516 mr_malloc(sizeof(struct mountlist_line *) * MAX_TAPECATALOG_ENTRIES); 2517 2527 2518 create_mountlist_for_drive(mountlist, drive_name, drivemntlist); 2528 2519 … … 2595 2586 /** end *************************************************************/ 2596 2587 2597 drivelist = malloc(sizeof(struct list_of_disks)); 2598 assert(mountlist != NULL); 2588 drivelist = mr_malloc(sizeof(struct list_of_disks)); 2599 2589 2600 2590 if (g_mountlist_fname == NULL) { -
trunk/mondo/src/mondorestore/mondo-restore.c
r1079 r1081 1 1 /*************************************************************************** 2 $Id$ 3 restores mondoarchive data 2 * restores mondoarchive data 3 * $Id$ 4 4 ***************************************************************************/ 5 5 … … 910 910 assert(bkpinfo != NULL); 911 911 912 mountlist = malloc(sizeof(struct mountlist_itself)); 913 raidlist = malloc(sizeof(struct raidlist_itself)); 914 915 if (!mountlist || !raidlist) { 916 fatal_error("Cannot malloc() mountlist and/or raidlist"); 917 } 912 mountlist = mr_malloc(sizeof(struct mountlist_itself)); 913 raidlist = mr_malloc(sizeof(struct raidlist_itself)); 918 914 919 915 mr_allocstr(bkpinfo->restore_path, "/"); … … 964 960 eject_device(bkpinfo->media_device); 965 961 } 966 free(mountlist);967 free(raidlist);962 mr_free(mountlist); 963 mr_free(raidlist); 968 964 return (retval); 969 965 } … … 1029 1025 assert(bkpinfo != NULL); 1030 1026 1031 if (!(bigblk = malloc(TAPE_BLOCK_SIZE))) { 1032 fatal_error("Cannot malloc bigblk"); 1033 } 1027 bigblk = mr_malloc(TAPE_BLOCK_SIZE); 1034 1028 1035 1029 tmp = slice_fname(bigfileno, 0, ARCHIVES_PATH, ""); … … 1751 1745 mr_free(acl_fname); 1752 1746 mr_free(temp_log); 1753 1754 1747 log_msg(5, "Leaving"); 1755 1748 return (retval); … … 2876 2869 mr_free(tmp); 2877 2870 2878 if (! 2879 (bkpinfo = g_bkpinfo_DONTUSETHIS = 2880 malloc(sizeof(struct s_bkpinfo)))) { 2881 fatal_error("Cannot malloc bkpinfo"); 2882 } 2883 if (!(mountlist = malloc(sizeof(struct mountlist_itself)))) { 2884 fatal_error("Cannot malloc mountlist"); 2885 } 2886 if (!(raidlist = malloc(sizeof(struct raidlist_itself)))) { 2887 fatal_error("Cannot malloc raidlist"); 2888 } 2871 bkpinfo = g_bkpinfo_DONTUSETHIS = mr_malloc(sizeof(struct s_bkpinfo)); 2872 mountlist = mr_malloc(sizeof(struct mountlist_itself)); 2873 raidlist = mr_malloc(sizeof(struct raidlist_itself)); 2889 2874 2890 2875 malloc_libmondo_global_strings(); -
trunk/mondo/src/mondorestore/mondo-rstr-compare.c
r1043 r1081 1 1 /*************************************************************************** 2 * $Id$ -compares mondoarchive data3 * */4 2 * compares mondoarchive data 3 * $Id$ 4 */ 5 5 6 6 #include "my-stuff.h" -
trunk/mondo/src/mondorestore/mondo-rstr-newt.c
r900 r1081 1 1 /*************************************************************************** 2 2 * $Id$ 3 **/ 4 3 */ 5 4 6 5 /** … … 1652 1651 assert(raidrec != NULL); 1653 1652 1654 if (!(bkp_raidrec = malloc(sizeof(struct raid_device_record)))) { 1655 fatal_error("Cannot malloc space for raidrec"); 1656 } 1653 bkp_raidrec = mr_malloc(sizeof(struct raid_device_record)); 1657 1654 1658 1655 log_it("Started edit_raidlist_entry"); … … 1736 1733 calculate_raid_device_size(mountlist, raidlist, 1737 1734 raidrec->raid_device); 1735 <<<<<<< .courant 1738 1736 mr_free(bkp_raidrec); 1737 ======= 1738 mr_free(title_of_editraidForm_window); 1739 mr_free(sz_raid_level); 1740 mr_free(sz_data_disks); 1741 mr_free(sz_spare_disks); 1742 mr_free(sz_parity_disks); 1743 mr_free(sz_failed_disks); 1744 mr_free(bkp_raidrec); 1745 >>>>>>> .fusion-droit.r1080 1739 1746 #endif 1740 1747 } … … 1787 1794 struct mountlist_itself *unallocparts = NULL; 1788 1795 1796 <<<<<<< .courant 1789 1797 /* BERLIOS: Check return value */ 1790 1798 unallocparts = malloc(sizeof(struct mountlist_itself)); 1799 ======= 1800 unallocparts = mr_malloc(sizeof(struct mountlist_itself)); 1801 >>>>>>> .fusion-droit.r1080 1791 1802 1792 1803 log_it("Started edit_raidlist_entry"); … … 2811 2822 2812 2823 iamhere("malloc'ing"); 2813 if (!(bkp_raidrec = malloc(sizeof(struct raid_device_record)))) { 2814 fatal_error("Cannot malloc space for raidrec"); 2815 } 2816 if (!(bkp_disklist = malloc(sizeof(struct list_of_disks)))) { 2817 fatal_error("Cannot malloc space for disklist"); 2818 } 2819 if (!(bkp_raidlist = malloc(sizeof(struct raidlist_itself)))) { 2820 fatal_error("Cannot malloc space for raidlist"); 2821 } 2822 if (! 2823 (unallocated_raid_partitions = 2824 malloc(sizeof(struct mountlist_itself)))) { 2825 fatal_error("Cannot malloc space for unallocated_raid_partitions"); 2826 } 2824 bkp_raidrec = mr_malloc(sizeof(struct raid_device_record)); 2825 bkp_disklist = mr_malloc(sizeof(struct list_of_disks)); 2826 bkp_raidlist = mr_malloc(sizeof(struct raidlist_itself)); 2827 unallocated_raid_partitions = mr_malloc(sizeof(struct mountlist_itself)); 2827 2828 2828 2829 memcpy((void *) bkp_raidlist, (void *) raidlist, … … 2926 2927 sizeof(struct list_of_disks)); 2927 2928 } 2929 <<<<<<< .courant 2928 2930 mr_free(bkp_raidrec); 2929 2931 mr_free(bkp_disklist); 2930 2932 mr_free(bkp_raidlist); 2931 2933 mr_free(unallocated_raid_partitions); 2934 ======= 2935 mr_free(tmp); 2936 mr_free(help_text); 2937 mr_free(title_of_window); 2938 mr_free(sz_res); 2939 mr_free(header_text); 2940 mr_free(bkp_raidrec); 2941 mr_free(bkp_disklist); 2942 mr_free(bkp_raidlist); 2943 mr_free(unallocated_raid_partitions); 2944 >>>>>>> .fusion-droit.r1080 2932 2945 } 2933 2946 #endif -
trunk/mondo/src/mondorestore/mondo-rstr-tools.c
r1043 r1081 1 /* 1 /*************************************************************************** 2 2 * $Id$ 3 **/ 3 */ 4 4 5 5 6 #include <unistd.h> 6 7 7 #include "my-stuff.h" 8 8 #include "../common/mondostructures.h" … … 67 67 mr_free(g_isodir_device); 68 68 mr_free(g_isodir_format); 69 70 69 } 71 70 … … 201 200 retval = 0; 202 201 } 202 <<<<<<< .courant 203 203 mr_free(orig_fname); 204 ======= 205 mr_free(mountpt); 206 mr_free(command); 207 mr_free(orig_fname); 208 >>>>>>> .fusion-droit.r1080 204 209 return (retval); 205 210 } … … 265 270 266 271 res = run_program_and_log_output(command, FALSE); 267 mr_free(command); 272 <<<<<<< .courant 273 mr_free(command); 274 ======= 275 mr_free(command); 276 mr_free(file); 277 mr_free(tmp); 278 >>>>>>> .fusion-droit.r1080 268 279 if (res) { 269 280 return (FALSE); … … 363 374 log_msg(2, "%ld: bkpinfo->isodir is now %s", __LINE__, 364 375 bkpinfo->isodir); 376 <<<<<<< .courant 377 ======= 378 mr_free(mount_isodir_command); 379 mr_free(tmp); 380 mr_free(command); 381 >>>>>>> .fusion-droit.r1080 365 382 return (retval); 366 383 } … … 419 436 return (0); 420 437 } 438 <<<<<<< .courant 421 439 if (!strcmp(mountpoint, "image")) { 422 440 mr_free(mountpoint); 423 441 return (0); 442 ======= 443 if (!does_file_exist(rclocal_fname)) { 444 mr_free(rclocal_fname); 445 mr_free(newfile_fname); 446 mr_free(tmp); 447 return (1); 448 >>>>>>> .fusion-droit.r1080 424 449 } 425 450 mr_asprintf(&tmp, "Mounting device %s ", device); … … 431 456 mr_asprintf(&p1, "-o ro"); 432 457 } 458 <<<<<<< .courant 433 459 tmp = find_home_of_exe("setfattr"); 434 460 if (tmp) { … … 438 464 } 439 465 mr_free(tmp); 466 ======= 467 sprintf(tmp, "echo -en \"#!/bin/sh\ 468 \\n\ 469 \\n\ 470 grep -v mondorescue %s > %s\\n\ 471 rm -f /var/lock/subsys/*xfs*\\n\ 472 rm -f /var/run/xfs.*\\n\ 473 killall xfs\\n\ 474 service xfs start\\n\ 475 yes | rm -f %s\\n\ 476 \" > %s", rclocal_fname, rclocal_fname, newfile_fname, newfile_fname); 477 sprintf(tmp, "chmod +x \"%s\"", newfile_fname); 478 run_program_and_log_output(tmp, FALSE); 479 mr_free(rclocal_fname); 480 mr_free(newfile_fname); 481 mr_free(tmp); 482 return (0); 483 } 484 >>>>>>> .fusion-droit.r1080 440 485 441 486 tmp = find_home_of_exe("setfacl"); … … 538 583 539 584 assert(p_external_copy_of_mountlist != NULL); 540 mountlist = m alloc(sizeof(struct mountlist_itself));585 mountlist = mr_malloc(sizeof(struct mountlist_itself)); 541 586 memcpy((void *) mountlist, (void *) p_external_copy_of_mountlist, 542 587 sizeof(struct mountlist_itself)); … … 621 666 } 622 667 run_program_and_log_output("df -m", 3); 668 <<<<<<< .courant 623 669 mr_free(mountlist); 670 ======= 671 mr_free(mountlist); 672 mr_free(tmp); 673 mr_free(format); 674 mr_free(these_failed); 675 >>>>>>> .fusion-droit.r1080 624 676 return (retval); 625 677 } … … 651 703 || bkpinfo->backup_media_type == udev) { 652 704 log_msg(8, "Tape/udev. Therefore, no need to mount CDROM."); 705 <<<<<<< .courant 706 ======= 707 mr_free(mount_cmd); 708 >>>>>>> .fusion-droit.r1080 653 709 return 0; 654 710 } … … 656 712 if (!run_program_and_log_output("mount | grep -F " MNT_CDROM, FALSE)) { 657 713 log_msg(2, "mount_cdrom() - CD already mounted. Fair enough."); 714 <<<<<<< .courant 715 ======= 716 mr_free(mount_cmd); 717 >>>>>>> .fusion-droit.r1080 658 718 return (0); 659 719 } … … 747 807 log_msg(2, "Mounted CD-ROM drive OK"); 748 808 } 809 <<<<<<< .courant 810 ======= 811 mr_free(mount_cmd); 812 >>>>>>> .fusion-droit.r1080 749 813 return (res); 750 814 } … … 755 819 756 820 /** 821 <<<<<<< .courant 822 ======= 823 * Mount @p device at @p mpt as @p format. 824 * @param device The device (/dev entry) to mount. 825 * @param mpt The directory to mount it on. 826 * @param format The filesystem type of @p device. 827 * @param writeable If TRUE, mount read-write; if FALSE, mount read-only. 828 * @return 0 for success, nonzero for failure. 829 */ 830 int mount_device(char *device, char *mpt, char *format, bool writeable) 831 { 832 int res = 0; 833 834 /** malloc **/ 835 char *tmp, *command, *mountdir, *mountpoint, *additional_parameters; 836 837 assert_string_is_neither_NULL_nor_zerolength(device); 838 assert_string_is_neither_NULL_nor_zerolength(mpt); 839 assert(format != NULL); 840 malloc_string(tmp); 841 malloc_string(command); 842 malloc_string(mountdir); 843 malloc_string(mountpoint); 844 malloc_string(additional_parameters); 845 846 if (!strcmp(mpt, "/1")) { 847 strcpy(mountpoint, "/"); 848 log_msg(3, "Mommm! SME is being a dildo!"); 849 } else { 850 strcpy(mountpoint, mpt); 851 } 852 853 if (!strcmp(mountpoint, "lvm")) { 854 return (0); 855 } 856 if (!strcmp(mountpoint, "image")) { 857 return (0); 858 } 859 sprintf(tmp, "Mounting device %s ", device); 860 log_msg(1, tmp); 861 if (writeable) { 862 strcpy(additional_parameters, "-o rw"); 863 } else { 864 strcpy(additional_parameters, "-o ro"); 865 } 866 if (find_home_of_exe("setfattr")) { 867 strcat(additional_parameters, ",user_xattr"); 868 } 869 if (find_home_of_exe("setfacl")) { 870 strcat(additional_parameters, ",acl"); 871 } 872 873 if (!strcmp(mountpoint, "swap")) { 874 sprintf(command, "swapon %s", device); 875 } else { 876 if (!strcmp(mountpoint, "/")) { 877 strcpy(mountdir, MNT_RESTORING); 878 } else { 879 sprintf(mountdir, "%s%s", MNT_RESTORING, mountpoint); 880 } 881 sprintf(command, "mkdir -p %s", mountdir); 882 run_program_and_log_output(command, FALSE); 883 sprintf(command, "mount -t %s %s %s %s 2>> %s", format, device, 884 additional_parameters, mountdir, MONDO_LOGFILE); 885 log_msg(2, "command='%s'", command); 886 } 887 res = run_program_and_log_output(command, TRUE); 888 if (res && (strstr(command, "xattr") || strstr(command, "acl"))) { 889 log_msg(1, "Re-trying without the fancy extra parameters"); 890 sprintf(command, "mount -t %s %s %s 2>> %s", format, device, 891 mountdir, MONDO_LOGFILE); 892 res = run_program_and_log_output(command, TRUE); 893 } 894 if (res) { 895 log_msg(1, "Unable to mount device %s (type %s) at %s", device, 896 format, mountdir); 897 log_msg(1, "command was '%s'", command); 898 if (!strcmp(mountpoint, "swap")) { 899 log_to_screen(tmp); 900 } else { 901 log_msg(2, "Retrying w/o the '-t' switch"); 902 sprintf(command, "mount %s %s 2>> %s", device, mountdir, 903 MONDO_LOGFILE); 904 log_msg(2, "2nd command = '%s'", command); 905 res = run_program_and_log_output(command, TRUE); 906 if (res == 0) { 907 log_msg(1, 908 "That's OK. I called mount w/o a filesystem type and it worked fine in the end."); 909 } else { 910 log_to_screen(tmp); 911 } 912 } 913 } 914 if (res && !strcmp(mountpoint, "swap")) { 915 log_msg(2, "That's ok. It's just a swap partition."); 916 log_msg(2, "Non-fatal error. Returning 0."); 917 res = 0; 918 } 919 920 mr_free(tmp); 921 mr_free(command); 922 mr_free(mountdir); 923 mr_free(mountpoint); 924 mr_free(additional_parameters); 925 926 return (res); 927 } 928 929 /************************************************************************** 930 *END_MOUNT_DEVICE * 931 **************************************************************************/ 932 933 934 935 /** 936 >>>>>>> .fusion-droit.r1080 757 937 * Fix some miscellaneous things in the filesystem so the system will come 758 938 * up correctly on the first boot. … … 920 1100 read_cfg_var(cfg_file, "acl", value); 921 1101 if (strstr(value, "TRUE")) { 922 asprintf(&g_getfacl,"setfacl");1102 mr_asprintf(&g_getfacl,"setfacl"); 923 1103 log_msg(1, "We will restore ACLs"); 924 1104 if (! find_home_of_exe("setfacl")) { … … 928 1108 read_cfg_var(cfg_file, "xattr", value); 929 1109 if (strstr(value, "TRUE")) { 930 asprintf(&g_getfattr,"setfattr");1110 mr_asprintf(&g_getfattr,"setfattr"); 931 1111 log_msg(1, "We will restore XATTRs"); 932 1112 if (! find_home_of_exe("setfattr")) { … … 1129 1309 } 1130 1310 g_backup_media_type = bkpinfo->backup_media_type; 1311 <<<<<<< .courant 1131 1312 bkpinfo->backup_media_string = bkptype_to_string(bkpinfo->backup_media_type); 1132 1313 g_backup_media_string = bkpinfo->backup_media_string; 1314 ======= 1315 mr_free(value); 1316 mr_free(tmp); 1317 mr_free(command); 1318 mr_free(iso_mnt); 1319 mr_free(iso_path); 1320 mr_free(old_isodir); 1321 >>>>>>> .fusion-droit.r1080 1133 1322 return (0); 1134 1323 } … … 1320 1509 TRUE); 1321 1510 } 1511 <<<<<<< .courant 1512 ======= 1513 1514 mr_free(command); 1515 mr_free(tmp); 1516 >>>>>>> .fusion-droit.r1080 1322 1517 return (filelist); 1323 1518 } … … 1344 1539 mr_asprintf(&command, "cp -f %s/%s %s/%s.pristine", path_root, filename,path_root, filename); 1345 1540 res = run_program_and_log_output(command, 5); 1346 mr_free(command); 1541 <<<<<<< .courant 1542 mr_free(command); 1543 ======= 1544 mr_free(tmp); 1545 mr_free(command); 1546 >>>>>>> .fusion-droit.r1080 1347 1547 return (res); 1348 1548 } … … 1427 1627 log_to_screen(_("Your boot loader ran OK")); 1428 1628 } 1629 <<<<<<< .courant 1630 ======= 1631 mr_free(device); 1632 mr_free(tmp); 1633 mr_free(name); 1634 >>>>>>> .fusion-droit.r1080 1429 1635 return (retval); 1430 1636 } … … 1579 1785 mvaddstr_and_log_it(g_currentY++, 74, _("Done.")); 1580 1786 } 1787 <<<<<<< .courant 1788 ======= 1789 mr_free(rootdev); 1790 mr_free(rootdrive); 1791 mr_free(conffile); 1792 mr_free(command); 1793 mr_free(boot_device); 1794 mr_free(tmp); 1795 mr_free(editor); 1796 1797 >>>>>>> .fusion-droit.r1080 1581 1798 return (res); 1582 1799 } … … 1649 1866 res = TRUE; 1650 1867 } 1868 <<<<<<< .courant 1869 ======= 1870 mr_free(command); 1871 mr_free(tmp); 1872 mr_free(editor); 1873 >>>>>>> .fusion-droit.r1080 1651 1874 return (res); 1652 1875 } … … 1762 1985 " lilo -M /dev/sda", 3); 1763 1986 } 1987 <<<<<<< .courant 1988 ======= 1989 mr_free(command); 1990 mr_free(tmp); 1991 mr_free(editor); 1992 >>>>>>> .fusion-droit.r1080 1764 1993 return (res); 1765 1994 } … … 1842 2071 mvaddstr_and_log_it(g_currentY++, 74, _("Done.")); 1843 2072 } 2073 <<<<<<< .courant 2074 ======= 2075 mr_free(command); 2076 mr_free(boot_device); 2077 mr_free(tmp); 2078 mr_free(editor); 2079 >>>>>>> .fusion-droit.r1080 1844 2080 return (res); 1845 2081 } … … 1942 2178 paranoid_fclose(fout); 1943 2179 paranoid_fclose(fin); 2180 <<<<<<< .courant 2181 ======= 2182 mr_free(incoming); 2183 >>>>>>> .fusion-droit.r1080 1944 2184 } 1945 2185 /************************************************************************** … … 1988 2228 } 1989 2229 close_progress_form(); 2230 <<<<<<< .courant 2231 ======= 2232 mr_free(tmp); 2233 >>>>>>> .fusion-droit.r1080 1990 2234 } 1991 2235 /************************************************************************** … … 2028 2272 assert(p_external_copy_of_mountlist != NULL); 2029 2273 2030 mountlist = m alloc(sizeof(struct mountlist_itself));2274 mountlist = mr_malloc(sizeof(struct mountlist_itself)); 2031 2275 memcpy((void *) mountlist, (void *) p_external_copy_of_mountlist, 2032 2276 sizeof(struct mountlist_itself)); … … 2121 2365 log_to_screen(_("All partitions were unmounted OK.")); 2122 2366 } 2367 <<<<<<< .courant 2123 2368 free(mountlist); 2369 ======= 2370 mr_free(mountlist); 2371 mr_free(command); 2372 mr_free(tmp); 2373 >>>>>>> .fusion-droit.r1080 2124 2374 return (retval); 2125 2375 } … … 2157 2407 res = 0; 2158 2408 } 2409 <<<<<<< .courant 2410 ======= 2411 mr_free(command); 2412 >>>>>>> .fusion-droit.r1080 2159 2413 return (res); 2160 2414 } … … 2425 2679 2426 2680 g_backup_media_type = bkpinfo->backup_media_type; 2681 <<<<<<< .courant 2427 2682 bkpinfo->backup_media_string = bkptype_to_string(bkpinfo->backup_media_type); 2428 2683 g_backup_media_string = bkpinfo->backup_media_string; 2684 ======= 2685 mr_free(device); 2686 mr_free(command); 2687 mr_free(tmp); 2688 mr_free(cfg_file); 2689 mr_free(mounted_cfgf_path); 2690 mr_free(mountpt); 2691 mr_free(ramdisk_fname); 2692 mr_free(mountlist_file); 2693 >>>>>>> .fusion-droit.r1080 2429 2694 return (retval); 2430 2695 } … … 2442 2707 char *screen_message = NULL; 2443 2708 2444 raidlist = m alloc(sizeof(struct raidlist_itself));2709 raidlist = mr_malloc(sizeof(struct raidlist_itself)); 2445 2710 2446 2711 assert(wait_for_percentage <= 100); … … 2480 2745 } 2481 2746 } 2747 <<<<<<< .courant 2482 2748 mr_free(raidlist); 2483 } 2749 ======= 2750 mr_free(screen_message); 2751 mr_free(raidlist); 2752 >>>>>>> .fusion-droit.r1080 2753 } -
trunk/tools/quality
r1079 r1081 28 28 29 29 # How many sprintf/strcat/strcpy vs asprintf are they 30 for s in asprintf mr_asprintf sprintf strcat strcpy strncpy fgets malloc mr_malloc malloc_string getline mr_getline MAX_STR_LEN getcwd goto free mr_free ; do30 for s in asprintf mr_asprintf sprintf strcat strcpy strncpy fgets malloc mr_malloc malloc_string getline mr_getline MAX_STR_LEN getcwd goto free mr_free paranoid_free; do 31 31 echo "monodrescue $s usage : " 32 32 tot=0
Note:
See TracChangeset
for help on using the changeset viewer.