Changeset 1638 in MondoRescue for branches/stable/mondo/src/common/libmondo-stream.c
- Timestamp:
- Sep 19, 2007, 9:32:00 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mondo/src/common/libmondo-stream.c
r1594 r1638 17 17 #include "mr_list.h" 18 18 #include "mr_gettext.h" 19 #include "mr_conf.h" 19 20 20 21 #include "mondostructures.h" … … 38 39 extern char *g_getfattr; 39 40 extern char *MONDO_LOGFILE; 41 42 extern struct mr_conf *mr_conf; 40 43 41 44 /** … … 864 867 malloc_string(temp_fname); 865 868 malloc_string(temp_cksum); 866 datablock = mr_malloc( TAPE_BLOCK_SIZE);869 datablock = mr_malloc(mr_conf->external_tape_blocksize); 867 870 crc16 = 0; 868 871 crctt = 0; … … 904 907 bytes_read) { 905 908 bytes_to_write = 906 (size < TAPE_BLOCK_SIZE) ? (long) size : TAPE_BLOCK_SIZE;907 bytes_to_read = TAPE_BLOCK_SIZE;909 (size < mr_conf->external_tape_blocksize) ? (long) size : mr_conf->external_tape_blocksize; 910 bytes_to_read = mr_conf->external_tape_blocksize; 908 911 bytes_read = fread(datablock, 1, bytes_to_read, g_tape_stream); 909 912 while (bytes_read < bytes_to_read) { // next tape! … … 995 998 /*@ end vars *************************************************** */ 996 999 997 tempblock = (char *) mr_malloc((size_t) TAPE_BLOCK_SIZE);998 999 for (i = 0; i < (int) TAPE_BLOCK_SIZE; i++) {1000 tempblock = (char *) mr_malloc((size_t) mr_conf->external_tape_blocksize); 1001 1002 for (i = 0; i < (int) mr_conf->external_tape_blocksize; i++) { 1000 1003 tempblock[i] = 0; 1001 1004 } 1002 1005 while (!(*pcontrol_char = tempblock[7000])) { 1003 1006 g_tape_posK += 1004 fread(tempblock, 1, (size_t) TAPE_BLOCK_SIZE,1007 fread(tempblock, 1, (size_t) mr_conf->external_tape_blocksize, 1005 1008 g_tape_stream) / 1024; 1006 1009 } … … 1131 1134 long bytes_to_write; 1132 1135 1133 datablock = mr_malloc( TAPE_BLOCK_SIZE);1136 datablock = mr_malloc(mr_conf->external_tape_blocksize); 1134 1137 malloc_string(temp_fname); 1135 1138 pB = strrchr(the_file_I_was_reading, '/'); … … 1181 1184 for (size = temp_size; size > 0; size -= bytes_to_write) { 1182 1185 bytes_to_write = 1183 (size < TAPE_BLOCK_SIZE) ? (long) size : TAPE_BLOCK_SIZE;1186 (size < mr_conf->external_tape_blocksize) ? (long) size : mr_conf->external_tape_blocksize; 1184 1187 // FIXME - needs error-checking and -catching 1185 fread(datablock, 1, (size_t) TAPE_BLOCK_SIZE, g_tape_stream);1188 fread(datablock, 1, (size_t) mr_conf->external_tape_blocksize, g_tape_stream); 1186 1189 } 1187 1190 res = … … 1444 1447 /*@ buffers **************************************************** */ 1445 1448 char *tmp = NULL; 1446 char datablock[TAPE_BLOCK_SIZE];1449 char *datablock = NULL; 1447 1450 char *checksum = NULL; 1448 1451 char *infile_basename = NULL; … … 1473 1476 crc16 = 0; 1474 1477 crctt = 0; 1478 datablock = mr_malloc(mr_conf->external_tape_blocksize); 1475 1479 1476 1480 /*@ end vars *************************************************** */ … … 1508 1512 for (noof_blocks = 0; filesize > 0; 1509 1513 noof_blocks++, filesize -= bytes_to_read) { 1510 if (filesize < TAPE_BLOCK_SIZE) {1514 if (filesize < mr_conf->external_tape_blocksize) { 1511 1515 bytes_to_read = (long) filesize; 1512 for (i = 0; i < TAPE_BLOCK_SIZE; i++) {1516 for (i = 0; i < mr_conf->external_tape_blocksize; i++) { 1513 1517 datablock[i] = '\0'; 1514 1518 } 1515 1519 } else { 1516 bytes_to_read = TAPE_BLOCK_SIZE;1520 bytes_to_read = mr_conf->external_tape_blocksize; 1517 1521 } 1518 1522 (void) fread(datablock, 1, (size_t) bytes_to_read, fin); 1519 1523 g_tape_posK += fwrite(datablock, 1, /*bytes_to_read */ 1520 (size_t) TAPE_BLOCK_SIZE,1524 (size_t) mr_conf->external_tape_blocksize, 1521 1525 g_tape_stream) / 1024; 1522 1526 if (g_sigpipe) { … … 1536 1540 #endif 1537 1541 } 1542 paranoid_free(datablock); 1538 1543 paranoid_fclose(fin); 1539 1544 mr_asprintf(&checksum, "%04x%04x", crc16, crctt); … … 1563 1568 { 1564 1569 /*@ buffers **************************************************** */ 1565 char tempblock[TAPE_BLOCK_SIZE];1570 char *tempblock; 1566 1571 char *p; 1567 1572 … … 1573 1578 /*@ end vars *************************************************** */ 1574 1579 1580 tempblock = mr_malloc(mr_conf->external_tape_blocksize); 1575 1581 1576 1582 olen = length_of_incoming_file; … … 1586 1592 return (1); 1587 1593 } 1588 for (i = 0; i < (int) TAPE_BLOCK_SIZE; i++) {1594 for (i = 0; i < (int) mr_conf->external_tape_blocksize; i++) { 1589 1595 tempblock[i] = 0; 1590 1596 } … … 1594 1600 strcpy(tempblock + 1000, filename); 1595 1601 g_tape_posK += 1596 fwrite(tempblock, 1, (size_t) TAPE_BLOCK_SIZE,1602 fwrite(tempblock, 1, (size_t) mr_conf->external_tape_blocksize, 1597 1603 g_tape_stream) / 1024; 1604 paranoid_free(tempblock); 1598 1605 mr_msg(6, "%s (fname=%s, size=%ld K)", 1599 1606 marker_to_string(control_char), p,
Note:
See TracChangeset
for help on using the changeset viewer.