Changeset 1080 in MondoRescue for branches/stable/mondo/src/mondorestore/mondo-rstr-tools.c
- Timestamp:
- Jan 28, 2007, 7:04:41 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mondo/src/mondorestore/mondo-rstr-tools.c
r1067 r1080 1 1 /*************************************************************************** 2 mondo-rstr-tools.c - description 3 ----------------- 4 5 begin: Sun Sep 21 16:40:35 EDT 2003 6 copyright : (C) 2002 Mondo Hugo Rabson 7 email : Hugo Rabson <hugorabson@msn.com> 8 edited by : by Stan Benoit ?/2003 9 email : troff@nakedsoul.org 10 cvsid : $Id: mondo-rstr-tools.c 11 ***************************************************************************/ 12 13 /*************************************************************************** 14 * * 15 * This program is free software; you can redistribute it and/or modify * 16 * it under the terms of the GNU General Public License as published by * 17 * the Free Software Foundation; either version 2 of the License, or * 18 * (at your option) any later version. * 19 * * 20 ***************************************************************************/ 21 /* mondo-rstr-tools.c Hugo Rabson 22 23 24 07/27 25 - if the user is foolish enough to use /dev/md0 as boot device, 26 call lilo -M /dev/hda to make sure lilo does its job properly 27 - better NFS+nuke support 28 29 07/20 30 - use backup's i-want-my-lvm file 31 - be sure to use archives' raidtab when restoring 32 33 07/18 34 - use /tmp/isodir for NFS if DR mode 35 - better support of users who boot from LVM CD and nuke-restore non-LVM backups 36 37 07/12 38 - bugfix to allow user to burn ISOs to CDs and restore from CDs (not original src) 39 40 06/29 41 - mount ext3 partitions as ext2, just in case :) 42 43 06/26 44 - delete make_relevant_partition_bootable() 45 46 06/19 47 - futzed with the call to mount floppy, to stop it from locking up on my AMD64 system 48 49 06/14 50 - shell out to /mnt/RESTORING chroot in order to let user install GRUB 51 manually if automatic GRUB installation fails 52 53 06/15 54 - Added check for different 'isodir' chosen by user than stored in the archive 55 Conor Daly <conor.daly@met.ie> 56 57 04/17 58 - replaced INTERNAL_TAPE_BLK_SIZE with bkpinfo->internal_tape_block_size 59 60 04/09 61 - don't try to mount CD if tape bkp 62 63 04/03 64 - trying to copy tmp/mondo-restore.cfg to itself - silly! - fixed 65 66 04/02 67 - when extracting cfg file and mountlist from all.tar.gz (tape copy), 68 use block size of INTERNAL_TAPE_BLK_SIZE, not TAPE_BLOCK_SIZE 69 70 02/21 71 - don't use 'mv -v' cos Busybox won't support it 72 73 02/09 74 - make hole for cfg file before moving it (line 2094 or so) 75 76 02/03 77 - changed a couple of refs to filelist.full, to filelist.full.gz 78 79 01/16/2004 80 - instead of copying filelist, use 'ln -sf' to link to original; 81 saves space 82 83 11/20/2003 84 - also retrieve /tmp/mountlist.txt if user wants 85 86 11/16 87 - fixed NFS path bug affecting the extractions of filelist/biggielist 88 during selective restore 89 90 11/02 91 - fixed mount_cdrom() to run properly w/ nfs restores 92 - mount_device() returns 0 if swap mount fails cos swap isn't crucial 93 94 10/17 95 - run_grub() uses MNT_RESTORING instead of "/mnt/RESTORING" 96 97 10/26 98 - cleaned up run_grub() 99 100 10/25 101 - fixed mount_cdrom() to run properly w/ nfs restores 102 103 10/21 104 - mount_device() returns 0 if swap mount fails cos swap isn't crucial 105 106 10/15 107 - run_grub() now uses its initiative instead 108 of calling grub-install 109 110 10/10 111 - don't leave copies of filelist.full lying around, clogging up 112 the ramdisk, there's a good fellow :-) 113 114 10/02 115 - added 'dvd' to the range of media types I'll understand 116 - fixed iso->cdr problem (thanks, Stan Benoit & Fred Beondo) 117 118 09/24 119 - try lots of tape devs if /dev/st0 fails 120 121 09/23/2003 122 - first incarnation 2 * $Id$ 123 3 */ 124 4 … … 132 12 //#include "mondo-rstr-compare-EXT.h" 133 13 #include "mondo-rstr-tools.h" 14 #include "mr_mem.h" 134 15 135 16 extern bool g_sigpipe_caught; … … 174 55 void free_MR_global_filenames() 175 56 { 176 paranoid_free(g_biggielist_txt);177 paranoid_free(g_filelist_full);178 paranoid_free(g_filelist_imagedevs);179 // paranoid_free (g_imagedevs_pot );180 paranoid_free(g_imagedevs_restthese);181 paranoid_free(g_mondo_cfg_file);182 paranoid_free(g_mountlist_fname);183 paranoid_free(g_mondo_home);184 paranoid_free(g_tmpfs_mountpt);185 paranoid_free(g_isodir_device);186 paranoid_free(g_isodir_format);57 mr_free(g_biggielist_txt); 58 mr_free(g_filelist_full); 59 mr_free(g_filelist_imagedevs); 60 // mr_free (g_imagedevs_pot ); 61 mr_free(g_imagedevs_restthese); 62 mr_free(g_mondo_cfg_file); 63 mr_free(g_mountlist_fname); 64 mr_free(g_mondo_home); 65 mr_free(g_tmpfs_mountpt); 66 mr_free(g_isodir_device); 67 mr_free(g_isodir_format); 187 68 188 69 } … … 213 94 assert_string_is_neither_NULL_nor_zerolength(outfname); 214 95 215 incoming_ptr = malloc(sizeof(incoming)); 216 if (incoming_ptr == NULL) { 217 fprintf(stderr, "Out of Memory\n"); 218 exit(EXIT_FAILURE); 219 } 220 221 question_ptr = malloc(sizeof(question)); 222 if (question_ptr == NULL) { 223 fprintf(stderr, "Out of Memory\n"); 224 exit(EXIT_FAILURE); 225 } 96 incoming_ptr = mr_malloc(sizeof(incoming)); 97 question_ptr = mr_malloc(sizeof(question)); 226 98 227 99 memset(incoming_ptr, '\0', sizeof(incoming)); … … 253 125 254 126 /*** free memory ***********/ 255 paranoid_free(incoming_ptr);127 mr_free(incoming_ptr); 256 128 incoming_ptr = NULL; 257 paranoid_free(question_ptr);129 mr_free(question_ptr); 258 130 question_ptr = NULL; 259 131 … … 341 213 retval = 0; 342 214 } 343 paranoid_free(mountpt);344 paranoid_free(command);345 paranoid_free(orig_fname);215 mr_free(mountpt); 216 mr_free(command); 217 mr_free(orig_fname); 346 218 return (retval); 347 219 … … 406 278 sprintf(command, "grep -E '^%s$' %s", file, list_fname); 407 279 res = run_program_and_log_output(command, FALSE); 408 paranoid_free(command);409 paranoid_free(file);410 paranoid_free(tmp);280 mr_free(command); 281 mr_free(file); 282 mr_free(tmp); 411 283 if (res) { 412 284 return (FALSE); … … 500 372 log_msg(2, "%ld: bkpinfo->isodir is now %s", __LINE__, 501 373 bkpinfo->isodir); 502 paranoid_free(mount_isodir_command);503 paranoid_free(tmp);504 paranoid_free(command);374 mr_free(mount_isodir_command); 375 mr_free(tmp); 376 mr_free(command); 505 377 return (retval); 506 378 } … … 519 391 "kill `ps 2> /dev/null | grep petris 2> /dev/null | grep -v grep | cut -d' ' -f2` 2> /dev/null"); 520 392 paranoid_system(command); 521 paranoid_free(command);393 mr_free(command); 522 394 } 523 395 … … 556 428 } 557 429 if (!does_file_exist(rclocal_fname)) { 558 paranoid_free(rclocal_fname);559 paranoid_free(newfile_fname);560 paranoid_free(tmp);430 mr_free(rclocal_fname); 431 mr_free(newfile_fname); 432 mr_free(tmp); 561 433 return (1); 562 434 } … … 582 454 sprintf(tmp, "chmod +x \"%s\"", newfile_fname); 583 455 run_program_and_log_output(tmp, FALSE); 584 paranoid_free(rclocal_fname);585 paranoid_free(newfile_fname);586 paranoid_free(tmp);456 mr_free(rclocal_fname); 457 mr_free(newfile_fname); 458 mr_free(tmp); 587 459 return (0); 588 460 } … … 613 485 malloc_string(these_failed); 614 486 assert(p_external_copy_of_mountlist != NULL); 615 mountlist = m alloc(sizeof(struct mountlist_itself));487 mountlist = mr_malloc(sizeof(struct mountlist_itself)); 616 488 memcpy((void *) mountlist, (void *) p_external_copy_of_mountlist, 617 489 sizeof(struct mountlist_itself)); … … 684 556 } 685 557 run_program_and_log_output("df -m", 3); 686 paranoid_free(mountlist);687 paranoid_free(tmp);688 paranoid_free(format);689 paranoid_free(these_failed);558 mr_free(mountlist); 559 mr_free(tmp); 560 mr_free(format); 561 mr_free(these_failed); 690 562 return (retval); 691 563 } … … 720 592 || bkpinfo->backup_media_type == udev) { 721 593 log_msg(8, "Tape/udev. Therefore, no need to mount CDROM."); 722 paranoid_free(mount_cmd);594 mr_free(mount_cmd); 723 595 return 0; 724 596 } … … 726 598 if (!run_program_and_log_output("mount | grep -F " MNT_CDROM, FALSE)) { 727 599 log_msg(2, "mount_cdrom() - CD already mounted. Fair enough."); 728 paranoid_free(mount_cmd);600 mr_free(mount_cmd); 729 601 return (0); 730 602 } … … 807 679 log_msg(2, "Mounted CD-ROM drive OK"); 808 680 } 809 paranoid_free(mount_cmd);681 mr_free(mount_cmd); 810 682 return (res); 811 683 } … … 918 790 } 919 791 920 paranoid_free(tmp);921 paranoid_free(command);922 paranoid_free(mountdir);923 paranoid_free(mountpoint);924 paranoid_free(additional_parameters);792 mr_free(tmp); 793 mr_free(command); 794 mr_free(mountdir); 795 mr_free(mountpoint); 796 mr_free(additional_parameters); 925 797 926 798 return (res); … … 1107 979 read_cfg_var(cfg_file, "acl", value); 1108 980 if (strstr(value, "TRUE")) { 1109 asprintf(&g_getfacl,"setfacl");981 mr_asprintf(&g_getfacl,"setfacl"); 1110 982 log_msg(1, "We will restore ACLs"); 1111 983 if (! find_home_of_exe("setfacl")) { … … 1115 987 read_cfg_var(cfg_file, "xattr", value); 1116 988 if (strstr(value, "TRUE")) { 1117 asprintf(&g_getfattr,"setfattr");989 mr_asprintf(&g_getfattr,"setfattr"); 1118 990 log_msg(1, "We will restore XATTRs"); 1119 991 if (! find_home_of_exe("setfattr")) { … … 1290 1162 } 1291 1163 g_backup_media_type = bkpinfo->backup_media_type; 1292 paranoid_free(value);1293 paranoid_free(tmp);1294 paranoid_free(command);1295 paranoid_free(iso_mnt);1296 paranoid_free(iso_path);1297 paranoid_free(old_isodir);1164 mr_free(value); 1165 mr_free(tmp); 1166 mr_free(command); 1167 mr_free(iso_mnt); 1168 mr_free(iso_path); 1169 mr_free(old_isodir); 1298 1170 return (0); 1299 1171 … … 1480 1352 } 1481 1353 1482 paranoid_free(command);1483 paranoid_free(tmp);1354 mr_free(command); 1355 mr_free(tmp); 1484 1356 return (filelist); 1485 1357 } … … 1514 1386 1515 1387 res = run_program_and_log_output(command, 5); 1516 paranoid_free(tmp);1517 paranoid_free(command);1388 mr_free(tmp); 1389 mr_free(command); 1518 1390 return (res); 1519 1391 } … … 1593 1465 log_to_screen("Your boot loader ran OK"); 1594 1466 } 1595 paranoid_free(device);1596 paranoid_free(tmp);1597 paranoid_free(name);1467 mr_free(device); 1468 mr_free(tmp); 1469 mr_free(name); 1598 1470 return (retval); 1599 1471 } … … 1739 1611 mvaddstr_and_log_it(g_currentY++, 74, "Done."); 1740 1612 } 1741 paranoid_free(rootdev);1742 paranoid_free(rootdrive);1743 paranoid_free(conffile);1744 paranoid_free(command);1745 paranoid_free(boot_device);1746 paranoid_free(tmp);1747 paranoid_free(editor);1613 mr_free(rootdev); 1614 mr_free(rootdrive); 1615 mr_free(conffile); 1616 mr_free(command); 1617 mr_free(boot_device); 1618 mr_free(tmp); 1619 mr_free(editor); 1748 1620 1749 1621 return (res); … … 1813 1685 res = TRUE; 1814 1686 } 1815 paranoid_free(command);1816 paranoid_free(tmp);1817 paranoid_free(editor);1687 mr_free(command); 1688 mr_free(tmp); 1689 mr_free(editor); 1818 1690 return (res); 1819 1691 } … … 1924 1796 " lilo -M /dev/sda", 3); 1925 1797 } 1926 paranoid_free(command);1927 paranoid_free(tmp);1928 paranoid_free(editor);1798 mr_free(command); 1799 mr_free(tmp); 1800 mr_free(editor); 1929 1801 return (res); 1930 1802 } … … 2006 1878 mvaddstr_and_log_it(g_currentY++, 74, "Done."); 2007 1879 } 2008 paranoid_free(command);2009 paranoid_free(boot_device);2010 paranoid_free(tmp);2011 paranoid_free(editor);1880 mr_free(command); 1881 mr_free(boot_device); 1882 mr_free(tmp); 1883 mr_free(editor); 2012 1884 return (res); 2013 1885 } … … 2129 2001 paranoid_fclose(fout); 2130 2002 paranoid_fclose(fin); 2131 paranoid_free(incoming);2003 mr_free(incoming); 2132 2004 } 2133 2005 … … 2177 2049 } 2178 2050 close_progress_form(); 2179 paranoid_free(tmp);2051 mr_free(tmp); 2180 2052 } 2181 2053 … … 2222 2094 assert(p_external_copy_of_mountlist != NULL); 2223 2095 2224 mountlist = m alloc(sizeof(struct mountlist_itself));2096 mountlist = mr_malloc(sizeof(struct mountlist_itself)); 2225 2097 memcpy((void *) mountlist, (void *) p_external_copy_of_mountlist, 2226 2098 sizeof(struct mountlist_itself)); … … 2306 2178 log_to_screen("All partitions were unmounted OK."); 2307 2179 } 2308 free(mountlist);2309 paranoid_free(command);2310 paranoid_free(tmp);2180 mr_free(mountlist); 2181 mr_free(command); 2182 mr_free(tmp); 2311 2183 return (retval); 2312 2184 } … … 2346 2218 res = 0; 2347 2219 } 2348 paranoid_free(command);2220 mr_free(command); 2349 2221 return (res); 2350 2222 } … … 2610 2482 run_program_and_log_output(command, FALSE); 2611 2483 g_backup_media_type = bkpinfo->backup_media_type; 2612 paranoid_free(device);2613 paranoid_free(command);2614 paranoid_free(tmp);2615 paranoid_free(cfg_file);2616 paranoid_free(mounted_cfgf_path);2617 paranoid_free(mountpt);2618 paranoid_free(ramdisk_fname);2619 paranoid_free(mountlist_file);2484 mr_free(device); 2485 mr_free(command); 2486 mr_free(tmp); 2487 mr_free(cfg_file); 2488 mr_free(mounted_cfgf_path); 2489 mr_free(mountpt); 2490 mr_free(ramdisk_fname); 2491 mr_free(mountlist_file); 2620 2492 return (retval); 2621 2493 } … … 2649 2521 2650 2522 malloc_string(screen_message); 2651 raidlist = m alloc(sizeof(struct raidlist_itself));2523 raidlist = mr_malloc(sizeof(struct raidlist_itself)); 2652 2524 2653 2525 assert(wait_for_percentage <= 100); … … 2684 2556 } 2685 2557 } 2686 paranoid_free(screen_message);2687 paranoid_free(raidlist);2688 } 2558 mr_free(screen_message); 2559 mr_free(raidlist); 2560 }
Note:
See TracChangeset
for help on using the changeset viewer.