Changeset 2340 in MondoRescue for branches/2.2.10/mondo/src/common/libmondo-filelist.c
- Timestamp:
- Aug 21, 2009, 1:53:49 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/common/libmondo-filelist.c
r2331 r2340 211 211 char *outfname = NULL; 212 212 char *biggie_fname = NULL; 213 char *incoming ;213 char *incoming = NULL; 214 214 char *tmp = NULL; 215 215 … … 257 257 return (curr_set_no + 1); 258 258 } 259 incoming = malloc(MAX_STR_LEN * 2); 260 261 (void) fgets(incoming, MAX_STR_LEN * 2 - 1, fin); 259 260 mr_getline(incoming, fin); 262 261 while (!feof(fin)) { 263 262 lino++; … … 266 265 i = 0; 267 266 } 267 /* Now that we dyn. alloc is truncating needed ? 268 268 if (i > MAX_STR_LEN - 1) { 269 269 incoming[MAX_STR_LEN - 30] = '\0'; … … 271 271 err++; 272 272 } 273 */ 273 274 if (incoming[i] < 32) { 274 275 incoming[i] = '\0'; … … 299 300 mr_free(outfname); 300 301 mr_free(biggie_fname); 301 paranoid_free(incoming);302 mr_free(incoming); 302 303 return (curr_set_no + 1); 303 304 } … … 305 306 } 306 307 } 307 (void) fgets(incoming, MAX_STR_LEN * 2 - 1, fin); 308 } 309 paranoid_free(incoming); 308 mr_free(incoming); 309 mr_getline(incoming, fin); 310 } 311 mr_free(incoming); 312 310 313 paranoid_fclose(fin); 311 314 paranoid_fclose(fout); … … 1332 1335 * @bug Return value should be @c void. 1333 1336 */ 1334 int open_and_list_dir(char *dir1, char *sth, FILE * fout, 1335 time_t time_of_last_full_backup) 1336 { 1337 int open_and_list_dir(char *dir1, char *sth, FILE * fout, time_t time_of_last_full_backup) { 1338 1337 1339 const char delims[] = " "; 1338 1340 … … 1341 1343 struct stat statbuf; 1342 1344 char *new; 1343 char *tmp ;1345 char *tmp = NULL; 1344 1346 char *dir = NULL; 1345 1347 static int percentage = 0; 1346 char *skip_these ;1347 char *new_with_spaces ;1348 char *skip_these = NULL; 1349 char *new_with_spaces = NULL; 1348 1350 char *strtmp; 1349 1351 char *token; 1350 char *find_excludes; 1351 static char *name_of_evalcall_form; 1352 char *find_excludes = NULL; 1353 char *name_of_evalcall_form = NULL; 1354 char *find_skeleton_marker = NULL; 1352 1355 int i; 1353 1356 int lastpos = 0; … … 1356 1359 static int counter = 0; 1357 1360 static int uberctr = 0; 1358 static char *find_skeleton_marker; 1359 static long skeleton_lino = 0; 1360 static time_t last_time = 0; 1361 static long skeleton_lino = 0L; 1362 static time_t last_time = (time_t)0; 1361 1363 time_t this_time; 1362 1364 … … 1371 1373 1372 1374 if (!depth) { 1373 malloc_string(name_of_evalcall_form);1374 malloc_string(find_skeleton_marker);1375 1375 mr_asprintf(find_excludes, " "); 1376 1376 if (sth != NULL) { … … 1397 1397 mr_free(tmp); 1398 1398 1399 sprintf(name_of_evalcall_form, "Making catalog of %s", dir);1399 mr_asprintf(name_of_evalcall_form, "Making catalog of %s", dir); 1400 1400 open_evalcall_form(name_of_evalcall_form); 1401 find_skeleton_marker[0] = '\0'; 1401 mr_free(name_of_evalcall_form); 1402 1402 1403 skeleton_lino = 1; 1403 1404 log_msg(5, "entries = %ld", g_skeleton_entries); … … 1405 1406 } else // update evalcall form if appropriate 1406 1407 { 1407 sprintf(find_skeleton_marker, 1408 "grep -Fv '%s' %s > %s.new 2> /dev/null", dir, 1409 g_skeleton_filelist, g_skeleton_filelist); 1408 mr_asprintf(find_skeleton_marker, "grep -Fv '%s' %s > %s.new 2> /dev/null", dir, g_skeleton_filelist, g_skeleton_filelist); 1410 1409 if (!system(find_skeleton_marker)) { 1411 1410 percentage = (int) (skeleton_lino * 100 / g_skeleton_entries); 1412 1411 skeleton_lino++; 1413 sprintf(find_skeleton_marker, "mv -f %s.new %s", 1414 g_skeleton_filelist, g_skeleton_filelist); 1415 run_program_and_log_output(find_skeleton_marker, 8); 1412 mr_free(find_skeleton_marker); 1413 1414 mr_asprintf(find_skeleton_marker, "mv -f %s.new %s", g_skeleton_filelist, g_skeleton_filelist); 1415 (void)system(find_skeleton_marker); 1416 1416 time(&this_time); 1417 1417 if (this_time != last_time) { … … 1427 1427 } 1428 1428 } 1429 mr_free(find_skeleton_marker); 1429 1430 } 1430 1431 … … 1453 1454 mr_asprintf(new,"%s%s",dir,dit->d_name); 1454 1455 } 1455 paranoid_free(new_with_spaces);1456 mr_free(new_with_spaces); 1456 1457 mr_asprintf(new_with_spaces, " %s ", new); 1457 1458 if (strstr(skip_these, new_with_spaces)) { … … 1463 1464 if (!S_ISLNK(statbuf.st_mode) 1464 1465 && S_ISDIR(statbuf.st_mode)) { 1465 open_and_list_dir(new, skip_these, fout, 1466 time_of_last_full_backup); 1466 open_and_list_dir(new, skip_these, fout, time_of_last_full_backup); 1467 1467 } else { 1468 if (time_of_last_full_backup == 0 1469 || time_of_last_full_backup < 1470 statbuf.st_ctime) { 1468 if (time_of_last_full_backup == 0 || time_of_last_full_backup < statbuf.st_ctime) { 1471 1469 fprintf(fout, "%s\n", new); 1472 1470 if ((counter++) > 128) { 1473 1471 counter = 0; 1474 1472 uberctr++; 1473 #ifndef _XWIN 1475 1474 mr_asprintf(tmp, " %c ", special_dot_char(uberctr)); 1476 #ifndef _XWIN1477 1475 if (!g_text_mode) { 1478 1476 newtDrawRootText(77, g_noof_rows - 3, tmp); 1479 1477 newtRefresh(); 1480 1478 } 1479 mr_free(tmp); 1481 1480 #endif 1482 mr_free(tmp);1483 1481 } 1484 1482 } … … 1486 1484 } 1487 1485 } 1488 paranoid_free(new);1489 } 1490 } 1491 paranoid_free(new_with_spaces);1492 paranoid_free(skip_these);1486 mr_free(new); 1487 } 1488 } 1489 mr_free(new_with_spaces); 1490 mr_free(skip_these); 1493 1491 mr_free(dir); 1494 1492 … … 1501 1499 if (!depth) { 1502 1500 close_evalcall_form(); 1503 paranoid_free(name_of_evalcall_form);1504 paranoid_free(find_skeleton_marker);1505 1501 unlink(g_skeleton_filelist); 1506 1502 log_msg(5, "g_skeleton_entries = %ld", g_skeleton_entries); … … 1596 1592 ("date +%s")); 1597 1593 } else if (lstat(sz_datefile, &statbuf)) { 1598 log_msg(2, 1599 "Warning - unable to find date of previous backup. Full backup instead."); 1594 log_msg(2, "Warning - unable to find date of previous backup. Full backup instead."); 1600 1595 differential = 0; 1601 1596 time_of_last_full_backup = 0; … … 1608 1603 // use user-specified filelist (if specified) 1609 1604 if (userdef_filelist) { 1610 log_msg(1, 1611 "Using the user-specified filelist - %s - instead of calculating one", 1612 userdef_filelist); 1605 log_msg(1, "Using the user-specified filelist - %s - instead of calculating one", userdef_filelist); 1613 1606 mr_asprintf(command, "cp -f %s %s", userdef_filelist, sz_filelist); 1614 1607 if (run_program_and_log_output(command, 3)) {
Note:
See TracChangeset
for help on using the changeset viewer.