Changeset 3185 in MondoRescue for branches/3.0/mondo/src/common/libmondo-filelist.c
- Timestamp:
- Sep 20, 2013, 2:29:57 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.0/mondo/src/common/libmondo-filelist.c
r3171 r3185 96 96 log_to_screen("Dividing filelist into sets. Please wait."); 97 97 i = 0; 98 mr_asprintf( &filelist, "%s/archives/filelist.full", bkpinfo->scratchdir);98 mr_asprintf(filelist, "%s/archives/filelist.full", bkpinfo->scratchdir); 99 99 if (!does_file_exist(filelist)) { 100 100 log_it("filelist %s not found", filelist); … … 107 107 estimate_noof_media_required(noof_sets); // for cosmetic purposes 108 108 109 mr_asprintf( &tempfile, "%s/biggielist.txt", bkpinfo->tmpdir);109 mr_asprintf(tempfile, "%s/biggielist.txt", bkpinfo->tmpdir); 110 110 if (!(fout = fopen(tempfile, "a"))) { 111 111 log_OS_error("Cannot append to biggielist"); … … 157 157 } // no sense in trying to sort an empty file 158 158 159 mr_asprintf( &tmp_fname, "%s/sortfile", bkpinfo->tmpdir);160 161 mr_asprintf( &command, "sort %s > %s 2>> %s", orig_fname, tmp_fname, MONDO_LOGFILE);159 mr_asprintf(tmp_fname, "%s/sortfile", bkpinfo->tmpdir); 160 161 mr_asprintf(command, "sort %s > %s 2>> %s", orig_fname, tmp_fname, MONDO_LOGFILE); 162 162 retval = system(command); 163 163 mr_free(command); … … 167 167 } else { 168 168 log_msg(5, "Sorted %s --> %s OK. Copying it back to %s now", orig_fname, tmp_fname, orig_fname); 169 mr_asprintf( &command, "mv -f %s %s", tmp_fname, orig_fname);169 mr_asprintf(command, "mv -f %s %s", tmp_fname, orig_fname); 170 170 retval += run_program_and_log_output(command, 5); 171 171 mr_free(command); … … 237 237 curr_set_no = 0; 238 238 curr_set_size = 0; 239 mr_asprintf( &outfname, "%s/filelist.%ld", outdir, curr_set_no);240 mr_asprintf( &biggie_fname, "%s/biggielist.txt", outdir);239 mr_asprintf(outfname, "%s/filelist.%ld", outdir, curr_set_no); 240 mr_asprintf(biggie_fname, "%s/biggielist.txt", outdir); 241 241 log_it("outfname=%s; biggie_fname=%s", outfname, biggie_fname); 242 242 if (!(fbig = fopen(biggie_fname, "w"))) { … … 255 255 } 256 256 257 mr_getline( &incoming, fin);257 mr_getline(incoming, fin); 258 258 while (!feof(fin)) { 259 259 lino++; … … 288 288 curr_set_size = 0; 289 289 290 mr_asprintf( &outfname, "%s/filelist.%ld", outdir, curr_set_no);290 mr_asprintf(outfname, "%s/filelist.%ld", outdir, curr_set_no); 291 291 if (!(fout = fopen(outfname, "w"))) { 292 292 log_OS_error("Unable to openout outfname"); … … 301 301 } 302 302 mr_free(incoming); 303 mr_getline( &incoming, fin);303 mr_getline(incoming, fin); 304 304 } 305 305 mr_free(incoming); … … 320 320 mr_free(biggie_fname); 321 321 322 mr_asprintf( &outfname, "%s/LAST-FILELIST-NUMBER", outdir);323 mr_asprintf( &tmp, "%ld", curr_set_no);322 mr_asprintf(outfname, "%s/LAST-FILELIST-NUMBER", outdir); 323 mr_asprintf(tmp, "%ld", curr_set_no); 324 324 if (write_one_liner_data_file(outfname, tmp)) { 325 325 log_OS_error … … 331 331 332 332 if (curr_set_no == 0) { 333 mr_asprintf( &tmp, "Only one fileset. Fine.");333 mr_asprintf(tmp, "Only one fileset. Fine."); 334 334 } else { 335 mr_asprintf( &tmp, "Filelist divided into %ld sets", curr_set_no + 1);335 mr_asprintf(tmp, "Filelist divided into %ld sets", curr_set_no + 1); 336 336 } 337 337 log_msg(1, tmp); … … 453 453 return (1); 454 454 } 455 mr_asprintf( &pout_command, "gzip -c1 > %s", auxlist_fname);455 mr_asprintf(pout_command, "gzip -c1 > %s", auxlist_fname); 456 456 if (!(pout = popen(pout_command, "w"))) { 457 457 log_msg(1, "Cannot openout auxlist_fname %s", auxlist_fname); … … 471 471 log_msg(8, "Analyzing %s", file_to_analyze); 472 472 tmp = mr_stresc(file_to_analyze, "'", '\\', '\''); 473 mr_asprintf( &syscall, "%s '%s' 2>> /dev/null", syscall_sprintf, tmp); // " MONDO_LOGFILE);473 mr_asprintf(syscall, "%s '%s' 2>> /dev/null", syscall_sprintf, tmp); // " MONDO_LOGFILE); 474 474 paranoid_free(tmp); 475 475 log_msg(20,"calling %s\n",syscall); … … 490 490 491 491 if (g_getfacl != NULL) { 492 mr_asprintf( &command, "touch \"%s\"", facl_fname);492 mr_asprintf(command, "touch \"%s\"", facl_fname); 493 493 run_program_and_log_output(command, 8); 494 494 mr_free(command); … … 506 506 507 507 if (g_getfattr != NULL) { 508 mr_asprintf( &command, "touch \"%s\"", fattr_fname);508 mr_asprintf(command, "touch \"%s\"", fattr_fname); 509 509 run_program_and_log_output(command, 8); 510 510 mr_free(command); … … 538 538 if (strstr(executable,"acl")) { 539 539 /* setfacl needs no additional option for physical walk */ 540 mr_asprintf( &tmp,"");540 mr_asprintf(tmp,""); 541 541 } else { 542 542 /* setfattr needs option -h for physical walk */ 543 mr_asprintf( &tmp,"-h");544 } 545 mr_asprintf( &command, "gzip -dc %s | %s %s --restore - 2>> %s", original_exat_fname, executable, tmp, MONDO_LOGFILE);543 mr_asprintf(tmp,"-h"); 544 } 545 mr_asprintf(command, "gzip -dc %s | %s %s --restore - 2>> %s", original_exat_fname, executable, tmp, MONDO_LOGFILE); 546 546 mr_free(tmp); 547 547 log_msg(1, "command = %s", command); … … 560 560 malloc_string(current_subset_file); 561 561 malloc_string(current_master_file); 562 mr_asprintf( &masklist, "%s/masklist", bkpinfo->tmpdir);563 mr_asprintf( &command, "cp -f %s %s", orig_msklist, masklist);562 mr_asprintf(masklist, "%s/masklist", bkpinfo->tmpdir); 563 mr_asprintf(command, "cp -f %s %s", orig_msklist, masklist); 564 564 run_program_and_log_output(command, 1); 565 565 mr_free(command); … … 568 568 current_subset_file[0] = current_master_file[0] = '\0'; 569 569 570 mr_asprintf( &syscall_pout, "%s --restore - 2>> %s", executable, MONDO_LOGFILE);570 mr_asprintf(syscall_pout, "%s --restore - 2>> %s", executable, MONDO_LOGFILE); 571 571 log_msg(1, "syscall_pout = %s", syscall_pout); 572 572 pout = popen(syscall_pout, "w"); … … 579 579 } 580 580 581 mr_asprintf( &syscall_pin, "gzip -dc %s", original_exat_fname);581 mr_asprintf(syscall_pin, "gzip -dc %s", original_exat_fname); 582 582 log_msg(1, "syscall_pin = %s", syscall_pin); 583 583 pin = popen(syscall_pin, "r"); … … 720 720 721 721 strcpy(val_sz,""); 722 mr_asprintf( &cfg_fname, "%s/mondo-restore.cfg", bkpinfo->tmpdir);722 mr_asprintf(cfg_fname, "%s/mondo-restore.cfg", bkpinfo->tmpdir); 723 723 read_cfg_var(cfg_fname, "last-filelist-number", val_sz); 724 724 mr_free(cfg_fname); … … 882 882 } 883 883 log_to_screen("Loading filelist"); 884 mr_asprintf( &tmp1, "zcat %s | wc -l", filelist_fname);884 mr_asprintf(tmp1, "zcat %s | wc -l", filelist_fname); 885 885 log_msg(6, "tmp1 = %s", tmp1); 886 886 lines_in_filelist = atol(call_program_and_get_last_line_of_output(tmp1)); … … 902 902 (filelist->down)->expanded = (filelist->down)->selected = FALSE; 903 903 904 mr_asprintf( &command_to_open_fname, "gzip -dc %s", filelist_fname);904 mr_asprintf(command_to_open_fname, "gzip -dc %s", filelist_fname); 905 905 if (!(pin = popen(command_to_open_fname, "r"))) { 906 906 log_OS_error("Unable to openin filelist_fname"); … … 1284 1284 bool in_quotes = FALSE; 1285 1285 1286 mr_asprintf( &sz_res, "%s", incoming);1286 mr_asprintf(sz_res, "%s", incoming); 1287 1287 p = sz_res; 1288 1288 while ((*p != '|' || in_quotes) && *p != '\0') { … … 1352 1352 } 1353 1353 } 1354 mr_asprintf( &find_excludes, " ");1354 mr_asprintf(find_excludes, " "); 1355 1355 1356 1356 if (!depth) { … … 1370 1370 #if linux 1371 1371 // 2.6 has /sys as a proc-type thing -- must be excluded 1372 mr_asprintf( &strtmp, "find '%s' -maxdepth %d -fstype mvfs -prune -o -fstype devpts -prune -o -fstype tmpfs -prune -o -fstype devtmpfs -prune -o -fstype proc -prune -o -fstype selinuxfs -prune -o -fstype securityfs -prune -o -fstype hugetlbfs -o -fstype cgroup -prune -prune -o -fstype mqueue -prune -o -fstype debugfs -prune -o -fstype sysfs -prune -o -fstype rpc_pipefs -prune -o -fstype none -prune -o %s -type d -print > %s 2> /dev/null", dir, MAX_SKEL_DEPTH, find_excludes, g_skeleton_filelist);1372 mr_asprintf(strtmp, "find '%s' -maxdepth %d -fstype mvfs -prune -o -fstype devpts -prune -o -fstype tmpfs -prune -o -fstype devtmpfs -prune -o -fstype proc -prune -o -fstype selinuxfs -prune -o -fstype securityfs -prune -o -fstype hugetlbfs -o -fstype cgroup -prune -prune -o -fstype mqueue -prune -o -fstype debugfs -prune -o -fstype sysfs -prune -o -fstype rpc_pipefs -prune -o -fstype none -prune -o %s -type d -print > %s 2> /dev/null", dir, MAX_SKEL_DEPTH, find_excludes, g_skeleton_filelist); 1373 1373 #else 1374 1374 // On BSD, for example, /sys is the kernel sources -- don't exclude 1375 mr_asprintf( &strtmp, "find '%s' -maxdepth %d -fstype mvfs -prune -o -path /proc -prune -o %s -type d -print > %s 2> /dev/null", dir, MAX_SKEL_DEPTH, find_excludes, g_skeleton_filelist);1375 mr_asprintf(strtmp, "find '%s' -maxdepth %d -fstype mvfs -prune -o -path /proc -prune -o %s -type d -print > %s 2> /dev/null", dir, MAX_SKEL_DEPTH, find_excludes, g_skeleton_filelist); 1376 1376 #endif 1377 1377 paranoid_free(find_excludes); … … 1379 1379 paranoid_system(strtmp); 1380 1380 paranoid_free(strtmp); 1381 mr_asprintf( &tmp, "wc -l %s | awk '{print $1;}'", g_skeleton_filelist);1381 mr_asprintf(tmp, "wc -l %s | awk '{print $1;}'", g_skeleton_filelist); 1382 1382 g_skeleton_entries = 1383 1383 1 + atol(call_program_and_get_last_line_of_output(tmp)); … … 1411 1411 int cols, rows; 1412 1412 newtGetScreenSize(&cols, &rows); 1413 mr_asprintf( &tmp, "Reading %-*s", cols, dir1);1413 mr_asprintf(tmp, "Reading %-*s", cols, dir1); 1414 1414 newtDrawRootText(0, g_noof_rows - 3, tmp); 1415 1415 mr_free(tmp); … … 1424 1424 1425 1425 // log_msg(0, "Cataloguing %s", dir); 1426 mr_asprintf( &skip_these, "|%s|", sth);1426 mr_asprintf(skip_these, "|%s|", sth); 1427 1427 1428 mr_asprintf( &new_with_pipe, "|%s|", dir1);1428 mr_asprintf(new_with_pipe, "|%s|", dir1); 1429 1429 if ((dip = opendir(dir1)) == NULL) { 1430 mr_asprintf( &tmp,"opendir %s", dir1);1430 mr_asprintf(tmp,"opendir %s", dir1); 1431 1431 log_OS_error(tmp); 1432 1432 paranoid_free(tmp); … … 1440 1440 i++; 1441 1441 if (strcmp(dir1, "/")) { 1442 mr_asprintf( &new,"%s/%s",dir1,dit->d_name);1442 mr_asprintf(new,"%s/%s",dir1,dit->d_name); 1443 1443 } else { 1444 mr_asprintf( &new,"%s%s",dir1,dit->d_name);1444 mr_asprintf(new,"%s%s",dir1,dit->d_name); 1445 1445 } 1446 1446 paranoid_free(new_with_pipe); 1447 mr_asprintf( &new_with_pipe, "|%s|", new);1447 mr_asprintf(new_with_pipe, "|%s|", new); 1448 1448 if (strstr(skip_these, new_with_pipe)) { 1449 1449 fprintf(fout, "%s\n", new); … … 1467 1467 counter = 0; 1468 1468 uberctr++; 1469 mr_asprintf( &tmp, " %c ", special_dot_char(uberctr));1469 mr_asprintf(tmp, " %c ", special_dot_char(uberctr)); 1470 1470 #ifndef _XWIN 1471 1471 if (!g_text_mode) { … … 1536 1536 malloc_string(tmp); 1537 1537 malloc_string(g_skeleton_filelist); 1538 mr_asprintf( &sz_datefile,MONDO_CACHE"/difflevel.%d" , 0);1538 mr_asprintf(sz_datefile,MONDO_CACHE"/difflevel.%d" , 0); 1539 1539 if (!include_paths && !userdef_filelist) { 1540 1540 fatal_error … … 1542 1542 } 1543 1543 // make hole for filelist 1544 mr_asprintf( &command, "mkdir -p %s/archives", scratchdir);1544 mr_asprintf(command, "mkdir -p %s/archives", scratchdir); 1545 1545 paranoid_system(command); 1546 1546 mr_free(command); 1547 1547 1548 mr_asprintf( &sz_filelist, "%s/tmpfs/filelist.full", tmpdir);1548 mr_asprintf(sz_filelist, "%s/tmpfs/filelist.full", tmpdir); 1549 1549 make_hole_for_file(sz_filelist); 1550 1550 1551 1551 if (differential == 0) { 1552 1552 // restore last good datefile if it exists 1553 mr_asprintf( &command, "cp -f %s.aborted %s", sz_datefile, sz_datefile);1553 mr_asprintf(command, "cp -f %s.aborted %s", sz_datefile, sz_datefile); 1554 1554 run_program_and_log_output(command, 3); 1555 1555 mr_free(command); … … 1557 1557 // backup last known good datefile just in case :) 1558 1558 if (does_file_exist(sz_datefile)) { 1559 mr_asprintf( &command, "mv -f %s %s.aborted", sz_datefile,1559 mr_asprintf(command, "mv -f %s %s.aborted", sz_datefile, 1560 1560 sz_datefile); 1561 1561 paranoid_system(command); … … 1582 1582 "Using the user-specified filelist - %s - instead of calculating one", 1583 1583 userdef_filelist); 1584 mr_asprintf( &command, "cp -f %s %s", userdef_filelist, sz_filelist);1584 mr_asprintf(command, "cp -f %s %s", userdef_filelist, sz_filelist); 1585 1585 if (run_program_and_log_output(command, 3)) { 1586 1586 mr_free(command); … … 1591 1591 log_msg(2, "include_paths = '%s'", include_paths); 1592 1592 log_msg(1, "Calculating filelist"); 1593 mr_asprintf( &tmp2, "%s", call_program_and_get_last_line_of_output("mount | grep -Ew 'ntfs|ntfs-3g|fat|vfat|dos' | awk '{print $3}'"));1593 mr_asprintf(tmp2, "%s", call_program_and_get_last_line_of_output("mount | grep -Ew 'ntfs|ntfs-3g|fat|vfat|dos' | awk '{print $3}'")); 1594 1594 if (strlen(tmp2) < 1) { 1595 mr_asprintf( &tmp1," ");1595 mr_asprintf(tmp1," "); 1596 1596 } else { 1597 1597 log_msg(2, "Found windows FS: %s",tmp2); 1598 mr_asprintf( &tmp1, "find %s -name '/win386.swp' -o -name '/hiberfil.sys' -o -name '/pagefile.sys' 2> /dev/null\n",tmp2);1598 mr_asprintf(tmp1, "find %s -name '/win386.swp' -o -name '/hiberfil.sys' -o -name '/pagefile.sys' 2> /dev/null\n",tmp2); 1599 1599 paranoid_free(tmp2); 1600 mr_asprintf( &tmp2, "%s", call_program_and_get_last_line_of_output(tmp1));1600 mr_asprintf(tmp2, "%s", call_program_and_get_last_line_of_output(tmp1)); 1601 1601 log_msg(2, "Found windows files: %s",tmp2); 1602 1602 } 1603 1603 paranoid_free(tmp1); 1604 1604 1605 mr_asprintf( &exclude_paths, MONDO_CACHE"|%s|%s|%s|.|..|"MNT_CDROM"|"MNT_FLOPPY"|/media|/tmp|/proc|/sys|/run|/dev/shm|"MINDI_CACHE, tmp2, (tmpdir[0] == '/' && tmpdir[1] == '/') ? (tmpdir + 1) : tmpdir, (scratchdir[0] == '/' && scratchdir[1] == '/') ? (scratchdir + 1) : scratchdir);1605 mr_asprintf(exclude_paths, MONDO_CACHE"|%s|%s|%s|.|..|"MNT_CDROM"|"MNT_FLOPPY"|/media|/tmp|/proc|/sys|/run|/dev/shm|"MINDI_CACHE, tmp2, (tmpdir[0] == '/' && tmpdir[1] == '/') ? (tmpdir + 1) : tmpdir, (scratchdir[0] == '/' && scratchdir[1] == '/') ? (scratchdir + 1) : scratchdir); 1606 1606 if (excp != NULL) { 1607 1607 mr_strcat(exclude_paths,"|%s",excp); … … 1640 1640 } 1641 1641 log_msg(2, "Copying new filelist to scratchdir"); 1642 mr_asprintf( &command, "mkdir -p %s/archives", scratchdir);1642 mr_asprintf(command, "mkdir -p %s/archives", scratchdir); 1643 1643 paranoid_system(command); 1644 1644 mr_free(command); 1645 1645 1646 mr_asprintf( &command, "cp -f %s %s/archives/", sz_filelist, scratchdir);1646 mr_asprintf(command, "cp -f %s %s/archives/", sz_filelist, scratchdir); 1647 1647 paranoid_system(command); 1648 1648 mr_free(command); 1649 1649 1650 mr_asprintf( &command, "mv -f %s %s", sz_filelist, tmpdir);1650 mr_asprintf(command, "mv -f %s %s", sz_filelist, tmpdir); 1651 1651 paranoid_system(command); 1652 1652 mr_free(command);
Note:
See TracChangeset
for help on using the changeset viewer.