Changeset 296 in MondoRescue for branches/2.06/mondo/mondo/mondorestore/mondo-restore.c
- Timestamp:
- Jan 11, 2006, 10:10:31 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.06/mondo/mondo/mondorestore/mondo-restore.c
r273 r296 1365 1365 /** malloc ***/ 1366 1366 char *checksum, *outfile_fname, *tmp, *bzip2_command, 1367 * partimagehack_command, *suffix, *sz_devfile;1367 *ntfsprog_command, *suffix, *sz_devfile; 1368 1368 char *bigblk; 1369 1369 char *p; … … 1372 1372 long sliceno; 1373 1373 long siz; 1374 char partimagehack_fifo[MAX_STR_LEN];1374 char ntfsprog_fifo[MAX_STR_LEN]; 1375 1375 char *file_to_openout = NULL; 1376 1376 struct s_filename_and_lstat_info biggiestruct; 1377 1377 struct utimbuf the_utime_buf, *ubuf; 1378 bool use_ partimage_hack = FALSE;1378 bool use_ntfsprog_hack = FALSE; 1379 1379 pid_t pid; 1380 1380 int res = 0; … … 1391 1391 malloc_string(tmp); 1392 1392 malloc_string(bzip2_command); 1393 malloc_string( partimagehack_command);1393 malloc_string(ntfsprog_command); 1394 1394 malloc_string(suffix); 1395 1395 malloc_string(sz_devfile); … … 1448 1448 1449 1449 log_msg(1, "DEFINITELY restoring %s", biggiestruct.filename); 1450 if (biggiestruct.use_ partimagehack) {1450 if (biggiestruct.use_ntfsprog) { 1451 1451 if (strncmp(biggiestruct.filename, "/dev/", 5)) { 1452 1452 log_msg(1, 1453 "I was in error when I set biggiestruct.use_ partimagehackto TRUE.");1453 "I was in error when I set biggiestruct.use_ntfsprog to TRUE."); 1454 1454 log_msg(1, "%s isn't even in /dev", biggiestruct.filename); 1455 biggiestruct.use_ partimagehack= FALSE;1456 } 1457 } 1458 1459 if (biggiestruct.use_ partimagehack) // if it's an NTFS device1455 biggiestruct.use_ntfsprog = FALSE; 1456 } 1457 } 1458 1459 if (biggiestruct.use_ntfsprog) // if it's an NTFS device 1460 1460 // if (!strncmp ( biggiestruct.filename, "/dev/", 5)) 1461 1461 { 1462 1462 g_loglevel = 4; 1463 use_ partimage_hack = TRUE;1463 use_ntfsprog_hack = TRUE; 1464 1464 log_msg(2, 1465 "Calling partimagehackin background because %s is an NTFS /dev entry",1465 "Calling ntfsclone in background because %s is an NTFS /dev entry", 1466 1466 outfile_fname); 1467 1467 sprintf(sz_devfile, "/tmp/%d.%d.000", (int) (random() % 32768), 1468 1468 (int) (random() % 32768)); 1469 1469 mkfifo(sz_devfile, 0x770); 1470 strcpy( partimagehack_fifo, sz_devfile);1471 file_to_openout = partimagehack_fifo;1470 strcpy(ntfsprog_fifo, sz_devfile); 1471 file_to_openout = ntfsprog_fifo; 1472 1472 switch (pid = fork()) { 1473 1473 case -1: … … 1475 1475 case 0: 1476 1476 log_msg(3, 1477 "CHILD - fip - calling feed_outfrom_ partimage(%s, %s)",1478 biggiestruct.filename, partimagehack_fifo);1477 "CHILD - fip - calling feed_outfrom_ntfsprog(%s, %s)", 1478 biggiestruct.filename, ntfsprog_fifo); 1479 1479 res = 1480 feed_outfrom_ partimage(biggiestruct.filename,1481 partimagehack_fifo);1480 feed_outfrom_ntfsprog(biggiestruct.filename, 1481 ntfsprog_fifo); 1482 1482 // log_msg(3, "CHILD - fip - exiting"); 1483 1483 exit(res); … … 1485 1485 default: 1486 1486 log_msg(3, 1487 "feed_into_ partimage() called in background --- pid=%ld",1487 "feed_into_ntfsprog() called in background --- pid=%ld", 1488 1488 (long int) (pid)); 1489 1489 } 1490 1490 } else { 1491 use_ partimage_hack = FALSE;1492 partimagehack_fifo[0] = '\0';1491 use_ntfsprog_hack = FALSE; 1492 ntfsprog_fifo[0] = '\0'; 1493 1493 file_to_openout = outfile_fname; 1494 1494 if (!does_file_exist(outfile_fname)) // yes, it looks weird with the '!' but it's correct that way … … 1517 1517 return (1); 1518 1518 } 1519 log_msg(3, "Opened out to %s", outfile_fname); // CD/DVD --> mondorestore --> partimagehack--> hard disk itself1519 log_msg(3, "Opened out to %s", outfile_fname); // CD/DVD --> mondorestore --> ntfsclone --> hard disk itself 1520 1520 1521 1521 for (sliceno = 1, finished = FALSE; !finished;) { … … 1626 1626 g_loglevel = old_loglevel; 1627 1627 1628 if (use_ partimage_hack) {1629 log_msg(3, "Waiting for partimage to finish");1628 if (use_ntfsprog_hack) { 1629 log_msg(3, "Waiting for ntfsclone to finish"); 1630 1630 sprintf(tmp, 1631 " ps ax | grep \" partimagehack\" | grep -v grep > /dev/null 2> /dev/null");1631 " ps ax | grep \" ntfsclone \" | grep -v grep > /dev/null 2> /dev/null"); 1632 1632 while (system(tmp) == 0) { 1633 1633 sleep(1); 1634 1634 } 1635 log_it("OK, partimage has really finished");1635 log_it("OK, ntfsclone has really finished"); 1636 1636 } 1637 1637 … … 1649 1649 paranoid_free(tmp); 1650 1650 paranoid_free(bzip2_command); 1651 paranoid_free( partimagehack_command);1651 paranoid_free(ntfsprog_command); 1652 1652 paranoid_free(suffix); 1653 1653 paranoid_free(sz_devfile); … … 1679 1679 long long biggiefile_size, //UNUSED 1680 1680 struct s_node *filelist, 1681 int use_ partimagehack,1681 int use_ntfsprog, 1682 1682 char *pathname_of_last_file_restored) 1683 1683 { … … 1689 1689 char *command; 1690 1690 char *outfile_fname; 1691 char * partimagehack_command;1691 char *ntfsprog_command; 1692 1692 char *sz_devfile; 1693 char * partimagehack_fifo;1693 char *ntfsprog_fifo; 1694 1694 char *file_to_openout = NULL; 1695 1695 … … 1703 1703 long long slice_siz; 1704 1704 bool dummy_restore = FALSE; 1705 bool use_ partimage_hack = FALSE;1705 bool use_ntfsprog_hack = FALSE; 1706 1706 pid_t pid; 1707 1707 struct s_filename_and_lstat_info biggiestruct; … … 1710 1710 1711 1711 malloc_string(tmp); 1712 malloc_string( partimagehack_fifo);1712 malloc_string(ntfsprog_fifo); 1713 1713 malloc_string(outfile_fname); 1714 1714 malloc_string(command); 1715 1715 malloc_string(sz_devfile); 1716 malloc_string( partimagehack_command);1716 malloc_string(ntfsprog_command); 1717 1717 old_loglevel = g_loglevel; 1718 1718 assert(bkpinfo != NULL); … … 1721 1721 1722 1722 pathname_of_last_file_restored[0] = '\0'; 1723 if (use_ partimagehack== BLK_START_A_PIHBIGGIE) {1724 use_ partimagehack= 1;1723 if (use_ntfsprog == BLK_START_A_PIHBIGGIE) { 1724 use_ntfsprog = 1; 1725 1725 log_msg(1, "%s --- pih=YES", orig_bf_fname); 1726 } else if (use_ partimagehack== BLK_START_A_NORMBIGGIE) {1727 use_ partimagehack= 0;1726 } else if (use_ntfsprog == BLK_START_A_NORMBIGGIE) { 1727 use_ntfsprog = 0; 1728 1728 log_msg(1, "%s --- pih=NO", orig_bf_fname); 1729 1729 } else { 1730 use_ partimagehack= 0;1730 use_ntfsprog = 0; 1731 1731 log_msg(1, "%s --- pih=NO (weird marker though)", orig_bf_fname); 1732 1732 } … … 1754 1754 } 1755 1755 1756 if (use_ partimagehack) {1756 if (use_ntfsprog) { 1757 1757 if (strncmp(orig_bf_fname, "/dev/", 5)) { 1758 1758 log_msg(1, 1759 "I was in error when I set use_ partimagehackto TRUE.");1759 "I was in error when I set use_ntfsprog to TRUE."); 1760 1760 log_msg(1, "%s isn't even in /dev", orig_bf_fname); 1761 use_ partimagehack= FALSE;1762 } 1763 } 1764 1765 if (use_ partimagehack) {1761 use_ntfsprog = FALSE; 1762 } 1763 } 1764 1765 if (use_ntfsprog) { 1766 1766 g_loglevel = 4; 1767 1767 strcpy(outfile_fname, orig_bf_fname); 1768 use_ partimage_hack = TRUE;1768 use_ntfsprog_hack = TRUE; 1769 1769 log_msg(2, 1770 "Calling partimagehackin background because %s is a /dev entry",1770 "Calling ntfsclone in background because %s is a /dev entry", 1771 1771 outfile_fname); 1772 1772 sprintf(sz_devfile, "/tmp/%d.%d.000", (int) (random() % 32768), 1773 1773 (int) (random() % 32768)); 1774 1774 mkfifo(sz_devfile, 0x770); 1775 strcpy( partimagehack_fifo, sz_devfile);1776 file_to_openout = partimagehack_fifo;1775 strcpy(ntfsprog_fifo, sz_devfile); 1776 file_to_openout = ntfsprog_fifo; 1777 1777 switch (pid = fork()) { 1778 1778 case -1: … … 1780 1780 case 0: 1781 1781 log_msg(3, 1782 "CHILD - fip - calling feed_outfrom_ partimage(%s, %s)",1783 outfile_fname, partimagehack_fifo);1782 "CHILD - fip - calling feed_outfrom_ntfsprog(%s, %s)", 1783 outfile_fname, ntfsprog_fifo); 1784 1784 res = 1785 feed_outfrom_ partimage(outfile_fname, partimagehack_fifo);1785 feed_outfrom_ntfsprog(outfile_fname, ntfsprog_fifo); 1786 1786 // log_msg(3, "CHILD - fip - exiting"); 1787 1787 exit(res); … … 1789 1789 default: 1790 1790 log_msg(3, 1791 "feed_into_ partimage() called in background --- pid=%ld",1791 "feed_into_ntfsprog() called in background --- pid=%ld", 1792 1792 (long int) (pid)); 1793 1793 } … … 1801 1801 orig_bf_fname); 1802 1802 } 1803 use_ partimage_hack = FALSE;1804 partimagehack_fifo[0] = '\0';1803 use_ntfsprog_hack = FALSE; 1804 ntfsprog_fifo[0] = '\0'; 1805 1805 file_to_openout = outfile_fname; 1806 1806 if (!does_file_exist(outfile_fname)) // yes, it looks weird with the '!' but it's correct that way … … 1879 1879 pathname_of_last_file_restored); 1880 1880 1881 if (use_ partimage_hack) {1882 log_msg(3, "Waiting for partimage to finish");1881 if (use_ntfsprog_hack) { 1882 log_msg(3, "Waiting for ntfsclone to finish"); 1883 1883 sprintf(tmp, 1884 " ps ax | grep \" partimagehack\" | grep -v grep > /dev/null 2> /dev/null");1884 " ps ax | grep \" ntfsclone \" | grep -v grep > /dev/null 2> /dev/null"); 1885 1885 while (system(tmp) == 0) { 1886 1886 sleep(1); 1887 1887 } 1888 log_msg(3, "OK, partimage has really finished");1888 log_msg(3, "OK, ntfsclone has really finished"); 1889 1889 } 1890 1890 … … 1903 1903 paranoid_free(outfile_fname); 1904 1904 paranoid_free(command); 1905 paranoid_free( partimagehack_command);1905 paranoid_free(ntfsprog_command); 1906 1906 paranoid_free(sz_devfile); 1907 paranoid_free( partimagehack_fifo);1907 paranoid_free(ntfsprog_fifo); 1908 1908 g_loglevel = old_loglevel; 1909 1909 return (retval);
Note:
See TracChangeset
for help on using the changeset viewer.