Changeset 300 in MondoRescue for trunk/mondo/mondo/mondorestore/mondo-restore.c
- Timestamp:
- Jan 11, 2006, 2:20:38 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/mondo/mondorestore/mondo-restore.c
r274 r300 1368 1368 /** malloc ***/ 1369 1369 char *checksum, *outfile_fname, *tmp, *bzip2_command, 1370 * partimagehack_command, *suffix, *sz_devfile;1370 *ntfsprog_command, *suffix, *sz_devfile; 1371 1371 char *bigblk; 1372 1372 char *p; … … 1375 1375 long sliceno; 1376 1376 long siz; 1377 char partimagehack_fifo[MAX_STR_LEN];1377 char ntfsprog_fifo[MAX_STR_LEN]; 1378 1378 char *file_to_openout = NULL; 1379 1379 struct s_filename_and_lstat_info biggiestruct; 1380 1380 struct utimbuf the_utime_buf, *ubuf; 1381 bool use_ partimage_hack = FALSE;1381 bool use_ntfsprog_hack = FALSE; 1382 1382 pid_t pid; 1383 1383 int res = 0; … … 1394 1394 malloc_string(tmp); 1395 1395 malloc_string(bzip2_command); 1396 malloc_string( partimagehack_command);1396 malloc_string(ntfsprog_command); 1397 1397 malloc_string(suffix); 1398 1398 malloc_string(sz_devfile); … … 1451 1451 1452 1452 log_msg(1, "DEFINITELY restoring %s", biggiestruct.filename); 1453 if (biggiestruct.use_ partimagehack) {1453 if (biggiestruct.use_ntfsprog) { 1454 1454 if (strncmp(biggiestruct.filename, "/dev/", 5)) { 1455 1455 log_msg(1, 1456 "I was in error when I set biggiestruct.use_ partimagehackto TRUE.");1456 "I was in error when I set biggiestruct.use_ntfsprog to TRUE."); 1457 1457 log_msg(1, "%s isn't even in /dev", biggiestruct.filename); 1458 biggiestruct.use_ partimagehack= FALSE;1459 } 1460 } 1461 1462 if (biggiestruct.use_ partimagehack) // if it's an NTFS device1458 biggiestruct.use_ntfsprog = FALSE; 1459 } 1460 } 1461 1462 if (biggiestruct.use_ntfsprog) // if it's an NTFS device 1463 1463 // if (!strncmp ( biggiestruct.filename, "/dev/", 5)) 1464 1464 { 1465 1465 g_loglevel = 4; 1466 use_ partimage_hack = TRUE;1466 use_ntfsprog_hack = TRUE; 1467 1467 log_msg(2, 1468 "Calling partimagehackin background because %s is an NTFS /dev entry",1468 "Calling ntfsclone in background because %s is an NTFS /dev entry", 1469 1469 outfile_fname); 1470 1470 sprintf(sz_devfile, "/tmp/%d.%d.000", (int) (random() % 32768), 1471 1471 (int) (random() % 32768)); 1472 1472 mkfifo(sz_devfile, 0x770); 1473 strcpy( partimagehack_fifo, sz_devfile);1474 file_to_openout = partimagehack_fifo;1473 strcpy(ntfsprog_fifo, sz_devfile); 1474 file_to_openout = ntfsprog_fifo; 1475 1475 switch (pid = fork()) { 1476 1476 case -1: … … 1478 1478 case 0: 1479 1479 log_msg(3, 1480 "CHILD - fip - calling feed_outfrom_ partimage(%s, %s)",1481 biggiestruct.filename, partimagehack_fifo);1480 "CHILD - fip - calling feed_outfrom_ntfsprog(%s, %s)", 1481 biggiestruct.filename, ntfsprog_fifo); 1482 1482 res = 1483 feed_outfrom_ partimage(biggiestruct.filename,1484 partimagehack_fifo);1483 feed_outfrom_ntfsprog(biggiestruct.filename, 1484 ntfsprog_fifo); 1485 1485 // log_msg(3, "CHILD - fip - exiting"); 1486 1486 exit(res); … … 1488 1488 default: 1489 1489 log_msg(3, 1490 "feed_into_ partimage() called in background --- pid=%ld",1490 "feed_into_ntfsprog() called in background --- pid=%ld", 1491 1491 (long int) (pid)); 1492 1492 } 1493 1493 } else { 1494 use_ partimage_hack = FALSE;1495 partimagehack_fifo[0] = '\0';1494 use_ntfsprog_hack = FALSE; 1495 ntfsprog_fifo[0] = '\0'; 1496 1496 file_to_openout = outfile_fname; 1497 1497 if (!does_file_exist(outfile_fname)) // yes, it looks weird with the '!' but it's correct that way … … 1520 1520 return (1); 1521 1521 } 1522 log_msg(3, "Opened out to %s", outfile_fname); // CD/DVD --> mondorestore --> partimagehack--> hard disk itself1522 log_msg(3, "Opened out to %s", outfile_fname); // CD/DVD --> mondorestore --> ntfsclone --> hard disk itself 1523 1523 1524 1524 for (sliceno = 1, finished = FALSE; !finished;) { … … 1629 1629 g_loglevel = old_loglevel; 1630 1630 1631 if (use_ partimage_hack) {1632 log_msg(3, "Waiting for partimage to finish");1631 if (use_ntfsprog_hack) { 1632 log_msg(3, "Waiting for ntfsclone to finish"); 1633 1633 sprintf(tmp, 1634 " ps ax | grep \" partimagehack\" | grep -v grep > /dev/null 2> /dev/null");1634 " ps ax | grep \" ntfsclone \" | grep -v grep > /dev/null 2> /dev/null"); 1635 1635 while (system(tmp) == 0) { 1636 1636 sleep(1); 1637 1637 } 1638 log_it("OK, partimage has really finished");1638 log_it("OK, ntfsclone has really finished"); 1639 1639 } 1640 1640 … … 1652 1652 paranoid_free(tmp); 1653 1653 paranoid_free(bzip2_command); 1654 paranoid_free( partimagehack_command);1654 paranoid_free(ntfsprog_command); 1655 1655 paranoid_free(suffix); 1656 1656 paranoid_free(sz_devfile); … … 1682 1682 long long biggiefile_size, //UNUSED 1683 1683 struct s_node *filelist, 1684 int use_ partimagehack,1684 int use_ntfsprog, 1685 1685 char *pathname_of_last_file_restored) 1686 1686 { … … 1692 1692 char *command; 1693 1693 char *outfile_fname; 1694 char * partimagehack_command;1694 char *ntfsprog_command; 1695 1695 char *sz_devfile; 1696 char * partimagehack_fifo;1696 char *ntfsprog_fifo; 1697 1697 char *file_to_openout = NULL; 1698 1698 … … 1706 1706 long long slice_siz; 1707 1707 bool dummy_restore = FALSE; 1708 bool use_ partimage_hack = FALSE;1708 bool use_ntfsprog_hack = FALSE; 1709 1709 pid_t pid; 1710 1710 struct s_filename_and_lstat_info biggiestruct; … … 1713 1713 1714 1714 malloc_string(tmp); 1715 malloc_string( partimagehack_fifo);1715 malloc_string(ntfsprog_fifo); 1716 1716 malloc_string(outfile_fname); 1717 1717 malloc_string(command); 1718 1718 malloc_string(sz_devfile); 1719 malloc_string( partimagehack_command);1719 malloc_string(ntfsprog_command); 1720 1720 old_loglevel = g_loglevel; 1721 1721 assert(bkpinfo != NULL); … … 1724 1724 1725 1725 pathname_of_last_file_restored[0] = '\0'; 1726 if (use_ partimagehack== BLK_START_A_PIHBIGGIE) {1727 use_ partimagehack= 1;1726 if (use_ntfsprog == BLK_START_A_PIHBIGGIE) { 1727 use_ntfsprog = 1; 1728 1728 log_msg(1, "%s --- pih=YES", orig_bf_fname); 1729 } else if (use_ partimagehack== BLK_START_A_NORMBIGGIE) {1730 use_ partimagehack= 0;1729 } else if (use_ntfsprog == BLK_START_A_NORMBIGGIE) { 1730 use_ntfsprog = 0; 1731 1731 log_msg(1, "%s --- pih=NO", orig_bf_fname); 1732 1732 } else { 1733 use_ partimagehack= 0;1733 use_ntfsprog = 0; 1734 1734 log_msg(1, "%s --- pih=NO (weird marker though)", orig_bf_fname); 1735 1735 } … … 1757 1757 } 1758 1758 1759 if (use_ partimagehack) {1759 if (use_ntfsprog) { 1760 1760 if (strncmp(orig_bf_fname, "/dev/", 5)) { 1761 1761 log_msg(1, 1762 "I was in error when I set use_ partimagehackto TRUE.");1762 "I was in error when I set use_ntfsprog to TRUE."); 1763 1763 log_msg(1, "%s isn't even in /dev", orig_bf_fname); 1764 use_ partimagehack= FALSE;1765 } 1766 } 1767 1768 if (use_ partimagehack) {1764 use_ntfsprog = FALSE; 1765 } 1766 } 1767 1768 if (use_ntfsprog) { 1769 1769 g_loglevel = 4; 1770 1770 strcpy(outfile_fname, orig_bf_fname); 1771 use_ partimage_hack = TRUE;1771 use_ntfsprog_hack = TRUE; 1772 1772 log_msg(2, 1773 "Calling partimagehackin background because %s is a /dev entry",1773 "Calling ntfsclone in background because %s is a /dev entry", 1774 1774 outfile_fname); 1775 1775 sprintf(sz_devfile, "/tmp/%d.%d.000", (int) (random() % 32768), 1776 1776 (int) (random() % 32768)); 1777 1777 mkfifo(sz_devfile, 0x770); 1778 strcpy( partimagehack_fifo, sz_devfile);1779 file_to_openout = partimagehack_fifo;1778 strcpy(ntfsprog_fifo, sz_devfile); 1779 file_to_openout = ntfsprog_fifo; 1780 1780 switch (pid = fork()) { 1781 1781 case -1: … … 1783 1783 case 0: 1784 1784 log_msg(3, 1785 "CHILD - fip - calling feed_outfrom_ partimage(%s, %s)",1786 outfile_fname, partimagehack_fifo);1785 "CHILD - fip - calling feed_outfrom_ntfsprog(%s, %s)", 1786 outfile_fname, ntfsprog_fifo); 1787 1787 res = 1788 feed_outfrom_ partimage(outfile_fname, partimagehack_fifo);1788 feed_outfrom_ntfsprog(outfile_fname, ntfsprog_fifo); 1789 1789 // log_msg(3, "CHILD - fip - exiting"); 1790 1790 exit(res); … … 1792 1792 default: 1793 1793 log_msg(3, 1794 "feed_into_ partimage() called in background --- pid=%ld",1794 "feed_into_ntfsprog() called in background --- pid=%ld", 1795 1795 (long int) (pid)); 1796 1796 } … … 1804 1804 orig_bf_fname); 1805 1805 } 1806 use_ partimage_hack = FALSE;1807 partimagehack_fifo[0] = '\0';1806 use_ntfsprog_hack = FALSE; 1807 ntfsprog_fifo[0] = '\0'; 1808 1808 file_to_openout = outfile_fname; 1809 1809 if (!does_file_exist(outfile_fname)) // yes, it looks weird with the '!' but it's correct that way … … 1882 1882 pathname_of_last_file_restored); 1883 1883 1884 if (use_ partimage_hack) {1885 log_msg(3, "Waiting for partimage to finish");1884 if (use_ntfsprog_hack) { 1885 log_msg(3, "Waiting for ntfsclone to finish"); 1886 1886 sprintf(tmp, 1887 " ps ax | grep \" partimagehack\" | grep -v grep > /dev/null 2> /dev/null");1887 " ps ax | grep \" ntfsclone \" | grep -v grep > /dev/null 2> /dev/null"); 1888 1888 while (system(tmp) == 0) { 1889 1889 sleep(1); 1890 1890 } 1891 log_msg(3, "OK, partimage has really finished");1891 log_msg(3, "OK, ntfsclone has really finished"); 1892 1892 } 1893 1893 … … 1906 1906 paranoid_free(outfile_fname); 1907 1907 paranoid_free(command); 1908 paranoid_free( partimagehack_command);1908 paranoid_free(ntfsprog_command); 1909 1909 paranoid_free(sz_devfile); 1910 paranoid_free( partimagehack_fifo);1910 paranoid_free(ntfsprog_fifo); 1911 1911 g_loglevel = old_loglevel; 1912 1912 return (retval);
Note:
See TracChangeset
for help on using the changeset viewer.