Changeset 2211 in MondoRescue for branches/2.2.9/mondo/src/mondorestore/mondo-rstr-compare.c
- Timestamp:
- Jun 3, 2009, 7:10:19 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.9/mondo/src/mondorestore/mondo-rstr-compare.c
r1930 r2211 1 1 /*************************************************************************** 2 mondo-compare.c - compares mondoarchive data3 -------------------4 begin : Fri Apr 25 20035 copyright : (C) 2000 by Hugo Rabson6 email : Hugo Rabson <hugorabson@msn.com>7 2 cvsid : $Id$ 8 3 ***************************************************************************/ 9 4 10 /***************************************************************************11 * *12 * This program is free software; you can redistribute it and/or modify *13 * it under the terms of the GNU General Public License as published by *14 * the Free Software Foundation; either version 2 of the License, or *15 * (at your option) any later version. *16 * *17 ***************************************************************************/18 19 /***************************************************************************20 * Change Log *21 ***************************************************************************22 .23 24 25 26 10/21/200327 - changed "/mnt/cdrom" to MNT_CDROM28 29 10/1830 - don't say unknown compressor if no compressor at all31 32 09/1733 - cleaned up logging & conversion-to-changed.txt34 - cleaned up compare_mode()35 36 09/1637 - fixed bad malloc(),free() pairs in compare_a_biggiefile()38 39 09/1440 - compare_mode() --- a couple of strings were the wrong way round,41 e.g. changed.txt and changed.files42 43 05/0544 - exclude /dev/ * from list of changed files45 46 04/3047 - added textonly mode48 49 04/2750 - improved compare_mode() to allow for ISO/cd/crazy people51 52 04/2553 - first incarnation54 */55 56 57 5 #include <pthread.h> 58 6 #include "my-stuff.h" 7 #include "mr_mem.h" 59 8 #include "../common/mondostructures.h" 60 9 #include "../common/libmondo.h" … … 97 46 char *original_cksum_ptr; 98 47 char *bigfile_fname_ptr; 99 char *tmp_ptr ;48 char *tmp_ptr = NULL; 100 49 char *command_ptr; 101 50 … … 117 66 malloc_string(bigfile_fname_ptr); 118 67 malloc_string(command_ptr); 119 malloc_string(tmp_ptr);120 68 121 69 /********************************************************************* … … 126 74 memset(original_cksum_ptr, '\0', sizeof(original_cksum)); 127 75 memset(bigfile_fname_ptr, '\0', sizeof(bigfile_fname)); 128 memset(tmp_ptr, '\0', sizeof(tmp));129 76 memset(command_ptr, '\0', sizeof(command)); 130 77 /** end **/ … … 134 81 insist_on_this_cd_number((++g_current_media_number)); 135 82 } else { 136 sprintf(tmp_ptr,83 mr_asprintf(&tmp_ptr, 137 84 "No CD's left. No biggiefiles left. No prob, Bob."); 138 85 log_msg(2, tmp_ptr); 86 paranoid_free(tmp_ptr); 139 87 return (0); 140 88 } 141 89 } 142 90 if (!(fin = fopen(slice_fname(bigfileno, 0, ARCHIVES_PATH, ""), "r"))) { 143 sprintf(tmp_ptr,91 mr_asprintf(&tmp_ptr, 144 92 "Cannot open bigfile %ld (%s)'s info file", 145 93 bigfileno + 1, bigfile_fname_ptr); 146 94 log_to_screen(tmp_ptr); 95 paranoid_free(tmp_ptr); 147 96 return (1); 148 97 } … … 156 105 log_msg(2, "biggiestruct.checksum = %s", biggiestruct.checksum); 157 106 158 sprintf(tmp_ptr, "Comparing %s", bigfile_fname_ptr);159 160 107 if (!g_text_mode) { 108 mr_asprintf(&tmp_ptr, "Comparing %s", bigfile_fname_ptr); 161 109 newtDrawRootText(0, 22, tmp_ptr); 110 paranoid_free(tmp_ptr); 162 111 newtRefresh(); 163 112 } … … 173 122 } 174 123 log_msg(2, command_ptr); 175 sprintf(tmp_ptr, "cat /tmp/errors >> %s 2> /dev/null", MONDO_LOGFILE);124 mr_asprintf(&tmp_ptr, "cat /tmp/errors >> %s 2> /dev/null", MONDO_LOGFILE); 176 125 paranoid_system(tmp_ptr); 126 paranoid_free(tmp_ptr); 127 177 128 if (system(command_ptr)) { 178 129 log_OS_error("Warning - command failed"); … … 197 148 } 198 149 } 199 sprintf(tmp_ptr, "bigfile #%ld ('%s') ", bigfileno + 1,150 mr_asprintf(&tmp_ptr, "bigfile #%ld ('%s') ", bigfileno + 1, 200 151 bigfile_fname_ptr); 201 152 if (!strcmp(checksum_ptr, original_cksum_ptr) != 0) { 202 strcat(tmp_ptr, " ... OK");203 } else { 204 strcat(tmp_ptr, "... changed");153 mr_strcat(tmp_ptr, " ... OK"); 154 } else { 155 mr_strcat(tmp_ptr, "... changed"); 205 156 retval++; 206 157 } 207 158 log_msg(1, tmp_ptr); 159 paranoid_free(tmp_ptr); 160 208 161 if (retval) { 209 162 if (!(fout = fopen(MONDO_CACHE"/changed.txt", "a"))) { … … 222 175 paranoid_free(command_ptr); 223 176 paranoid_free(command); 224 paranoid_free(tmp_ptr);225 177 paranoid_free(tmp); 226 178 … … 302 254 303 255 /*** needs malloc *********/ 304 char *command, *tmp, *filelist_name, *logfile, *archiver_exe,256 char *command, *tmp, *filelist_name, *logfile, 305 257 *compressor_exe; 258 char *archiver_exe = NULL; 306 259 307 260 malloc_string(command); … … 309 262 malloc_string(filelist_name); 310 263 malloc_string(logfile); 311 malloc_string(archiver_exe);312 264 malloc_string(compressor_exe); 313 265 … … 331 283 332 284 if (use_star) { 333 strcpy(archiver_exe, "star");334 } else { 335 strcpy(archiver_exe, "afio");285 mr_asprintf(&archiver_exe, "star"); 286 } else { 287 mr_asprintf(&archiver_exe, "afio"); 336 288 } 337 289 … … 344 296 { 345 297 if (!strcmp(compressor_exe, "bzip2")) { 346 strcat(archiver_exe, " -bz");298 mr_strcat(archiver_exe, " -bz"); 347 299 } else { 348 300 fatal_error … … 373 325 BUFSIZE, compressor_exe, tarball_fname, logfile, logfile); 374 326 } 327 paranoid_free(archiver_exe); 328 375 329 #undef BUFSIZE 376 330 … … 405 359 paranoid_free(filelist_name); 406 360 paranoid_free(logfile); 407 paranoid_free(archiver_exe);408 361 paranoid_free(compressor_exe); 409 362 return (retval);
Note:
See TracChangeset
for help on using the changeset viewer.