- Timestamp:
- Jan 29, 2007, 11:51:36 PM (18 years ago)
- Location:
- trunk/mondo
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/ChangeLog
r1043 r1084 3 3 MONDO CHANGES 4 4 5 3.0.0 (200 6-10-30)5 3.0.0 (2007-10-30) 6 6 - indent on source files 7 7 - asprintf used instead of malloc_string + sprintf/strcpy/strcat without verifications. Optimisations on memory consumption (allocate only size needed + remove memory leaks) (Bruno Cornec) -
trunk/mondo/src/mondorestore/Makefile.am
r1079 r1084 5 5 ## Process with Automake to generate Makefile.in 6 6 ## 7 AM_CPPFLAGS = -DMONDO_CONF_DIR=\"$(sysconfdir)\" -I${top_builddir}/src/include8 9 7 AM_CPPFLAGS = -DMONDO_CONF_DIR=\"$(sysconfdir)\" -I${top_builddir}/src/include 10 8 -
trunk/mondo/src/mondorestore/mondo-rstr-newt.c
r1081 r1084 1733 1733 calculate_raid_device_size(mountlist, raidlist, 1734 1734 raidrec->raid_device); 1735 <<<<<<< .courant1736 1735 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.r10801746 1736 #endif 1747 1737 } … … 1794 1784 struct mountlist_itself *unallocparts = NULL; 1795 1785 1796 <<<<<<< .courant1797 /* BERLIOS: Check return value */1798 unallocparts = malloc(sizeof(struct mountlist_itself));1799 =======1800 1786 unallocparts = mr_malloc(sizeof(struct mountlist_itself)); 1801 >>>>>>> .fusion-droit.r10801802 1787 1803 1788 log_it("Started edit_raidlist_entry"); … … 2927 2912 sizeof(struct list_of_disks)); 2928 2913 } 2929 <<<<<<< .courant2930 2914 mr_free(bkp_raidrec); 2931 2915 mr_free(bkp_disklist); 2932 2916 mr_free(bkp_raidlist); 2933 2917 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.r10802945 2918 } 2946 2919 #endif -
trunk/mondo/src/mondorestore/mondo-rstr-tools.c
r1081 r1084 200 200 retval = 0; 201 201 } 202 <<<<<<< .courant203 202 mr_free(orig_fname); 204 =======205 mr_free(mountpt);206 mr_free(command);207 mr_free(orig_fname);208 >>>>>>> .fusion-droit.r1080209 203 return (retval); 210 204 } … … 270 264 271 265 res = run_program_and_log_output(command, FALSE); 272 <<<<<<< .courant273 266 mr_free(command); 274 =======275 mr_free(command);276 mr_free(file);277 mr_free(tmp);278 >>>>>>> .fusion-droit.r1080279 267 if (res) { 280 268 return (FALSE); … … 374 362 log_msg(2, "%ld: bkpinfo->isodir is now %s", __LINE__, 375 363 bkpinfo->isodir); 376 <<<<<<< .courant377 =======378 mr_free(mount_isodir_command);379 mr_free(tmp);380 mr_free(command);381 >>>>>>> .fusion-droit.r1080382 364 return (retval); 383 365 } … … 436 418 return (0); 437 419 } 438 <<<<<<< .courant439 420 if (!strcmp(mountpoint, "image")) { 440 421 mr_free(mountpoint); 441 422 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.r1080449 423 } 450 424 mr_asprintf(&tmp, "Mounting device %s ", device); … … 456 430 mr_asprintf(&p1, "-o ro"); 457 431 } 458 <<<<<<< .courant459 432 tmp = find_home_of_exe("setfattr"); 460 433 if (tmp) { … … 464 437 } 465 438 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.r1080485 439 486 440 tmp = find_home_of_exe("setfacl"); … … 666 620 } 667 621 run_program_and_log_output("df -m", 3); 668 <<<<<<< .courant669 622 mr_free(mountlist); 670 =======671 mr_free(mountlist);672 mr_free(tmp);673 mr_free(format);674 mr_free(these_failed);675 >>>>>>> .fusion-droit.r1080676 623 return (retval); 677 624 } … … 703 650 || bkpinfo->backup_media_type == udev) { 704 651 log_msg(8, "Tape/udev. Therefore, no need to mount CDROM."); 705 <<<<<<< .courant706 =======707 mr_free(mount_cmd);708 >>>>>>> .fusion-droit.r1080709 652 return 0; 710 653 } … … 712 655 if (!run_program_and_log_output("mount | grep -F " MNT_CDROM, FALSE)) { 713 656 log_msg(2, "mount_cdrom() - CD already mounted. Fair enough."); 714 <<<<<<< .courant715 =======716 mr_free(mount_cmd);717 >>>>>>> .fusion-droit.r1080718 657 return (0); 719 658 } … … 807 746 log_msg(2, "Mounted CD-ROM drive OK"); 808 747 } 809 <<<<<<< .courant810 =======811 mr_free(mount_cmd);812 >>>>>>> .fusion-droit.r1080813 748 return (res); 814 749 } … … 819 754 820 755 /** 821 <<<<<<< .courant822 =======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.r1080937 756 * Fix some miscellaneous things in the filesystem so the system will come 938 757 * up correctly on the first boot. … … 1309 1128 } 1310 1129 g_backup_media_type = bkpinfo->backup_media_type; 1311 <<<<<<< .courant1312 1130 bkpinfo->backup_media_string = bkptype_to_string(bkpinfo->backup_media_type); 1313 1131 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.r10801322 1132 return (0); 1323 1133 } … … 1509 1319 TRUE); 1510 1320 } 1511 <<<<<<< .courant1512 =======1513 1514 mr_free(command);1515 mr_free(tmp);1516 >>>>>>> .fusion-droit.r10801517 1321 return (filelist); 1518 1322 } … … 1539 1343 mr_asprintf(&command, "cp -f %s/%s %s/%s.pristine", path_root, filename,path_root, filename); 1540 1344 res = run_program_and_log_output(command, 5); 1541 <<<<<<< .courant1542 1345 mr_free(command); 1543 =======1544 mr_free(tmp);1545 mr_free(command);1546 >>>>>>> .fusion-droit.r10801547 1346 return (res); 1548 1347 } … … 1627 1426 log_to_screen(_("Your boot loader ran OK")); 1628 1427 } 1629 <<<<<<< .courant1630 =======1631 mr_free(device);1632 mr_free(tmp);1633 mr_free(name);1634 >>>>>>> .fusion-droit.r10801635 1428 return (retval); 1636 1429 } … … 1785 1578 mvaddstr_and_log_it(g_currentY++, 74, _("Done.")); 1786 1579 } 1787 <<<<<<< .courant1788 =======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.r10801798 1580 return (res); 1799 1581 } … … 1866 1648 res = TRUE; 1867 1649 } 1868 <<<<<<< .courant1869 =======1870 mr_free(command);1871 mr_free(tmp);1872 mr_free(editor);1873 >>>>>>> .fusion-droit.r10801874 1650 return (res); 1875 1651 } … … 1985 1761 " lilo -M /dev/sda", 3); 1986 1762 } 1987 <<<<<<< .courant1988 =======1989 mr_free(command);1990 mr_free(tmp);1991 mr_free(editor);1992 >>>>>>> .fusion-droit.r10801993 1763 return (res); 1994 1764 } … … 2071 1841 mvaddstr_and_log_it(g_currentY++, 74, _("Done.")); 2072 1842 } 2073 <<<<<<< .courant2074 =======2075 mr_free(command);2076 mr_free(boot_device);2077 mr_free(tmp);2078 mr_free(editor);2079 >>>>>>> .fusion-droit.r10802080 1843 return (res); 2081 1844 } … … 2178 1941 paranoid_fclose(fout); 2179 1942 paranoid_fclose(fin); 2180 <<<<<<< .courant2181 =======2182 mr_free(incoming);2183 >>>>>>> .fusion-droit.r10802184 1943 } 2185 1944 /************************************************************************** … … 2228 1987 } 2229 1988 close_progress_form(); 2230 <<<<<<< .courant2231 =======2232 mr_free(tmp);2233 >>>>>>> .fusion-droit.r10802234 1989 } 2235 1990 /************************************************************************** … … 2365 2120 log_to_screen(_("All partitions were unmounted OK.")); 2366 2121 } 2367 <<<<<<< .courant2368 free(mountlist);2369 =======2370 2122 mr_free(mountlist); 2371 mr_free(command);2372 mr_free(tmp);2373 >>>>>>> .fusion-droit.r10802374 2123 return (retval); 2375 2124 } … … 2407 2156 res = 0; 2408 2157 } 2409 <<<<<<< .courant2410 =======2411 mr_free(command);2412 >>>>>>> .fusion-droit.r10802413 2158 return (res); 2414 2159 } … … 2679 2424 2680 2425 g_backup_media_type = bkpinfo->backup_media_type; 2681 <<<<<<< .courant2682 2426 bkpinfo->backup_media_string = bkptype_to_string(bkpinfo->backup_media_type); 2683 2427 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.r10802694 2428 return (retval); 2695 2429 } … … 2745 2479 } 2746 2480 } 2747 <<<<<<< .courant2748 2481 mr_free(raidlist); 2749 ======= 2750 mr_free(screen_message); 2751 mr_free(raidlist); 2752 >>>>>>> .fusion-droit.r1080 2753 } 2482 }
Note:
See TracChangeset
for help on using the changeset viewer.