Changeset 3860 in MondoRescue for branches/3.3/mondo/src
- Timestamp:
- Mar 7, 2024, 11:00:54 AM (14 months ago)
- Location:
- branches/3.3/mondo/src/common
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3/mondo/src/common/libmondo-archive.c
r3858 r3860 2159 2159 res = make_afioballs_and_images_OLD(); 2160 2160 #endif 2161 write_header_block_to_stream((off_t)0, "stop-afioballs", 2162 BLK_STOP_AFIOBALLS); 2161 write_header_block_to_stream((off_t)0, "stop-afioballs", BLK_STOP_AFIOBALLS); 2163 2162 } else { 2164 2163 res = make_afioballs_and_images(); … … 2423 2422 /* ask for new tape if necessary */ 2424 2423 length_of_incoming_file = length_of_file(curr_file); 2425 write_header_block_to_stream(length_of_incoming_file, curr_file, 2426 start_chr); 2424 write_header_block_to_stream(length_of_incoming_file, curr_file, start_chr); 2427 2425 res = write_file_to_stream_from_file(curr_file); 2428 2426 retval += res; -
branches/3.3/mondo/src/common/libmondo-stream-EXT.h
r3857 r3860 36 36 extern int write_file_to_stream_from_file( 37 37 char *infile); 38 extern int write_header_block_to_stream(off_t length_of_incoming_file, 39 char *filename, int control_char); 38 extern int write_header_block_to_stream(off_t length_of_incoming_file, const char *filename, int control_char); 40 39 extern void wrong_marker(int should_be, int it_is); 41 40 extern int closein_cdstream(); -
branches/3.3/mondo/src/common/libmondo-stream.c
r3857 r3860 91 91 { 92 92 return (closein_tape()); 93 } 94 95 /** 96 * Write a header block to the opened stream (CD or tape). 97 * @param length_of_incoming_file The length to store in the header block. 98 * Usually matters only if this is a file-related header, in which case it should 99 * be the length of the file that will follow. 100 * @param filename The filename to store in the header block. Usually matters 101 * only if this is a file-related header, in which case this should be the name 102 * if the file that will follow. 103 * @param control_char The type of header block this is (start-file, end-file, start-tape, ...) 104 * @return 0 for success, nonzero for failure. 105 */ 106 int write_header_block_to_stream(off_t length_of_incoming_file, const char *filename, int control_char) 107 { 108 /*@ buffers **************************************************** */ 109 char tempblock[TAPE_BLOCK_SIZE]; 110 char *p; 111 char *tmp = NULL; 112 113 /*@ int ******************************************************** */ 114 int i; 115 116 off_t olen; 117 118 /*@ end vars *************************************************** */ 119 120 olen = length_of_incoming_file; 121 p = strrchr(filename, '/'); /* Make 'em go, "Unnnh!" Oh wait, that was _Master_ P... */ 122 if (!p) { 123 p = filename; 124 } else { 125 p++; 126 } 127 if (!g_tape_stream) { 128 log_to_screen("You're not backing up to tape. Why write a tape header?"); 129 return (1); 130 } 131 for (i = 0; i < (int) TAPE_BLOCK_SIZE; i++) { 132 tempblock[i] = 0; 133 } 134 sprintf(tempblock + 6000 + control_char, STR_HEADER); 135 tempblock[7000] = control_char; 136 if (length_of_incoming_file > 0) { 137 memcpy(tempblock + 7001, (char *) &olen, sizeof(off_t)); 138 } 139 strcpy(tempblock + 1000, filename); 140 g_tape_posK += fwrite(tempblock, 1, (size_t) TAPE_BLOCK_SIZE, g_tape_stream) / 1024; 141 tmp = marker_to_string(control_char); 142 log_msg(6, "%s (fname=%s, size=%ld K)", tmp, p, (long) length_of_incoming_file >> 10); 143 mr_free(tmp); 144 return (0); 93 145 } 94 146 … … 418 470 if (g_getfattr) { 419 471 // xattr 420 write_header_block_to_stream(length_of_file(xattr_fname), xattr_fname, 421 BLK_START_EXTENDED_ATTRIBUTES); 422 write_header_block_to_stream(length_of_file(xattr_fname), xattr_fname, 423 BLK_START_EXAT_FILE); 472 write_header_block_to_stream(length_of_file(xattr_fname), xattr_fname, BLK_START_EXTENDED_ATTRIBUTES); 473 write_header_block_to_stream(length_of_file(xattr_fname), xattr_fname, BLK_START_EXAT_FILE); 424 474 write_file_to_stream_from_file(xattr_fname); 425 475 write_header_block_to_stream((off_t)-1, xattr_fname, BLK_STOP_EXAT_FILE); 426 write_header_block_to_stream(length_of_file(xattr_fname), xattr_fname, 427 BLK_STOP_EXTENDED_ATTRIBUTES); 476 write_header_block_to_stream(length_of_file(xattr_fname), xattr_fname, BLK_STOP_EXTENDED_ATTRIBUTES); 428 477 } 429 478 if (g_getfacl) { 430 479 // acl 431 write_header_block_to_stream(length_of_file(acl_fname), acl_fname, 432 BLK_START_EXTENDED_ATTRIBUTES); 433 write_header_block_to_stream(length_of_file(acl_fname), acl_fname, 434 BLK_START_EXAT_FILE); 480 write_header_block_to_stream(length_of_file(acl_fname), acl_fname, BLK_START_EXTENDED_ATTRIBUTES); 481 write_header_block_to_stream(length_of_file(acl_fname), acl_fname, BLK_START_EXAT_FILE); 435 482 write_file_to_stream_from_file(acl_fname); 436 483 write_header_block_to_stream((off_t)-1, acl_fname, BLK_STOP_EXAT_FILE); 437 write_header_block_to_stream(length_of_file(acl_fname), acl_fname, 438 BLK_STOP_EXTENDED_ATTRIBUTES); 484 write_header_block_to_stream(length_of_file(acl_fname), acl_fname, BLK_STOP_EXTENDED_ATTRIBUTES); 439 485 } 440 486 return (res); … … 1519 1565 log_msg(6, "Can't write %s - it doesn't exist.", fname); 1520 1566 } else { 1521 write_header_block_to_stream(length_of_file(fname), 1522 "start-backcatalog-afio-or-slice", 1523 BLK_START_AN_AFIO_OR_SLICE); 1567 write_header_block_to_stream(length_of_file(fname), "start-backcatalog-afio-or-slice", BLK_START_AN_AFIO_OR_SLICE); 1524 1568 log_msg(2, "Writing %s", fname); 1525 1569 if (write_file_to_stream_from_file(fname)) { … … 1528 1572 } 1529 1573 if (i != last) { 1530 write_header_block_to_stream((off_t)0, 1531 "stop-backcatalog-afio-or-slice", 1532 BLK_STOP_AN_AFIO_OR_SLICE); 1574 write_header_block_to_stream((off_t)0, "stop-backcatalog-afio-or-slice", BLK_STOP_AN_AFIO_OR_SLICE); 1533 1575 } 1534 1576 } … … 1651 1693 } 1652 1694 filesize = length_of_file(infile); 1653 if (should_we_write_to_next_tape 1654 (bkpinfo->media_size, filesize)) { 1695 if (should_we_write_to_next_tape(bkpinfo->media_size, filesize)) { 1655 1696 start_to_write_to_next_tape(); 1656 1697 write_backcatalog_to_tape(); … … 1663 1704 } 1664 1705 log_it("Writing file '%s' to tape (%ld KB)", p, (long) filesize >> 10); 1665 write_header_block_to_stream(filesize, infile_basename, 1666 BLK_START_FILE); 1706 write_header_block_to_stream(filesize, infile_basename, BLK_START_FILE); 1667 1707 //go_here_to_restart_saving_of_file: 1668 1708 if (!(fin = fopen(infile, "r"))) { … … 1717 1757 1718 1758 1719 /**1720 * Write a header block to the opened stream (CD or tape).1721 * @param length_of_incoming_file The length to store in the header block.1722 * Usually matters only if this is a file-related header, in which case it should1723 * be the length of the file that will follow.1724 * @param filename The filename to store in the header block. Usually matters1725 * only if this is a file-related header, in which case this should be the name1726 * if the file that will follow.1727 * @param control_char The type of header block this is (start-file, end-file, start-tape, ...)1728 * @return 0 for success, nonzero for failure.1729 */1730 int1731 write_header_block_to_stream(off_t length_of_incoming_file,1732 char *filename, int control_char)1733 {1734 /*@ buffers **************************************************** */1735 char tempblock[TAPE_BLOCK_SIZE];1736 char *p;1737 char *tmp = NULL;1738 1739 /*@ int ******************************************************** */1740 int i;1741 1742 off_t olen;1743 1744 /*@ end vars *************************************************** */1745 1746 olen = length_of_incoming_file;1747 p = strrchr(filename, '/'); /* Make 'em go, "Unnnh!" Oh wait, that was _Master_ P... */1748 if (!p) {1749 p = filename;1750 } else {1751 p++;1752 }1753 if (!g_tape_stream) {1754 log_to_screen("You're not backing up to tape. Why write a tape header?");1755 return (1);1756 }1757 for (i = 0; i < (int) TAPE_BLOCK_SIZE; i++) {1758 tempblock[i] = 0;1759 }1760 sprintf(tempblock + 6000 + control_char, STR_HEADER);1761 tempblock[7000] = control_char;1762 if (length_of_incoming_file > 0) {1763 memcpy(tempblock + 7001, (char *) &olen, sizeof(off_t));1764 }1765 strcpy(tempblock + 1000, filename);1766 g_tape_posK += fwrite(tempblock, 1, (size_t) TAPE_BLOCK_SIZE, g_tape_stream) / 1024;1767 tmp = marker_to_string(control_char);1768 log_msg(6, "%s (fname=%s, size=%ld K)", tmp, p, (long) length_of_incoming_file >> 10);1769 mr_free(tmp);1770 return (0);1771 }1772 1773 1774 1775 1759 1776 1760 -
branches/3.3/mondo/src/common/libmondo-stream.h
r3857 r3860 35 35 int write_file_to_stream_from_file( 36 36 char *infile); 37 int write_header_block_to_stream(off_t length_of_incoming_file,38 char *filename, int control_char);39 37 void wrong_marker(int should_be, int it_is); 40 38 int closein_cdstream();
Note:
See TracChangeset
for help on using the changeset viewer.