1036 |
return; |
return; |
1037 |
} |
} |
1038 |
|
|
1039 |
|
static void |
1040 |
|
short_read (ssize_t status) |
1041 |
|
{ |
1042 |
|
size_t left; /* bytes left */ |
1043 |
|
char *more; /* pointer to next byte to read */ |
1044 |
|
|
1045 |
|
more = record_start->buffer + status; |
1046 |
|
left = record_size - status; |
1047 |
|
|
1048 |
|
while (left % BLOCKSIZE != 0 |
1049 |
|
|| (left && status && read_full_records_option)) |
1050 |
|
{ |
1051 |
|
if (status) |
1052 |
|
while ((status = rmtread (archive, more, left)) < 0) |
1053 |
|
archive_read_error (); |
1054 |
|
|
1055 |
|
if (status == 0) |
1056 |
|
break; |
1057 |
|
|
1058 |
|
if (! read_full_records_option) |
1059 |
|
FATAL_ERROR ((0, 0, _("Unaligned block (%lu bytes) in archive"), |
1060 |
|
(unsigned long) (record_size - left))); |
1061 |
|
|
1062 |
|
/* User warned us about this. Fix up. */ |
1063 |
|
|
1064 |
|
left -= status; |
1065 |
|
more += status; |
1066 |
|
} |
1067 |
|
|
1068 |
|
/* FIXME: for size=0, multi-volume support. On the first record, warn |
1069 |
|
about the problem. */ |
1070 |
|
|
1071 |
|
if (!read_full_records_option && verbose_option |
1072 |
|
&& record_start_block == 0 && status > 0) |
1073 |
|
WARN ((0, 0, _("Record size = %lu blocks"), |
1074 |
|
(unsigned long) ((record_size - left) / BLOCKSIZE))); |
1075 |
|
|
1076 |
|
record_end = record_start + (record_size - left) / BLOCKSIZE; |
1077 |
|
records_read++; |
1078 |
|
} |
1079 |
|
|
1080 |
/* Perform a read to flush the buffer. */ |
/* Perform a read to flush the buffer. */ |
1081 |
void |
void |
1082 |
flush_read (void) |
flush_read (void) |
1083 |
{ |
{ |
1084 |
ssize_t status; /* result from system call */ |
ssize_t status; /* result from system call */ |
|
size_t left; /* bytes left */ |
|
|
char *more; /* pointer to next byte to read */ |
|
1085 |
|
|
1086 |
if (checkpoint_option && !(++checkpoint % 10)) |
if (checkpoint_option && !(++checkpoint % 10)) |
1087 |
WARN ((0, 0, _("Read checkpoint %d"), checkpoint)); |
WARN ((0, 0, _("Read checkpoint %d"), checkpoint)); |
1154 |
goto vol_error; |
goto vol_error; |
1155 |
} |
} |
1156 |
if (status != record_size) |
if (status != record_size) |
1157 |
goto short_read; |
short_read (status); |
1158 |
|
|
1159 |
cursor = record_start; |
cursor = record_start; |
1160 |
|
|
1228 |
goto error_loop; /* try again */ |
goto error_loop; /* try again */ |
1229 |
} |
} |
1230 |
|
|
1231 |
short_read: |
short_read (status); |
|
more = record_start->buffer + status; |
|
|
left = record_size - status; |
|
|
|
|
|
while (left % BLOCKSIZE != 0 |
|
|
|| (left && status && read_full_records_option)) |
|
|
{ |
|
|
if (status) |
|
|
while ((status = rmtread (archive, more, left)) < 0) |
|
|
archive_read_error (); |
|
|
|
|
|
if (status == 0) |
|
|
break; |
|
|
|
|
|
if (! read_full_records_option) |
|
|
FATAL_ERROR ((0, 0, _("Unaligned block (%lu bytes) in archive"), |
|
|
(unsigned long) (record_size - left))); |
|
|
|
|
|
/* User warned us about this. Fix up. */ |
|
|
|
|
|
left -= status; |
|
|
more += status; |
|
|
} |
|
|
|
|
|
/* FIXME: for size=0, multi-volume support. On the first record, warn |
|
|
about the problem. */ |
|
|
|
|
|
if (!read_full_records_option && verbose_option |
|
|
&& record_start_block == 0 && status > 0) |
|
|
WARN ((0, 0, _("Record size = %lu blocks"), |
|
|
(unsigned long) ((record_size - left) / BLOCKSIZE))); |
|
|
|
|
|
record_end = record_start + (record_size - left) / BLOCKSIZE; |
|
|
records_read++; |
|
1232 |
} |
} |
1233 |
|
|
1234 |
/* Flush the current buffer to/from the archive. */ |
/* Flush the current buffer to/from the archive. */ |
1557 |
} |
} |
1558 |
} |
} |
1559 |
|
|
1560 |
if (verify_option) |
if (strcmp (archive_name_cursor[0], "-") == 0) |
1561 |
|
{ |
1562 |
|
read_full_records_option = true; |
1563 |
|
archive = STDIN_FILENO; |
1564 |
|
} |
1565 |
|
else if (verify_option) |
1566 |
archive = rmtopen (*archive_name_cursor, O_RDWR | O_CREAT, MODE_RW, |
archive = rmtopen (*archive_name_cursor, O_RDWR | O_CREAT, MODE_RW, |
1567 |
rsh_command_option); |
rsh_command_option); |
1568 |
else |
else |
1600 |
|
|
1601 |
return 1; |
return 1; |
1602 |
} |
} |
1603 |
|
|