2008-04-06 04:37:13 +02:00
|
|
|
--- src/util.c
|
|
|
|
+++ src/util.c
|
2008-04-12 20:03:36 +02:00
|
|
|
@@ -188,8 +188,15 @@ tape_fill_input_buffer (int in_des, int
|
2008-04-06 04:37:13 +02:00
|
|
|
input_size = rmtread (in_des, input_buffer, num_bytes);
|
|
|
|
if (input_size == 0 && input_is_special)
|
|
|
|
{
|
|
|
|
- get_next_reel (in_des);
|
|
|
|
+ if (!tape_eof (in_des))
|
|
|
|
+ get_next_reel (in_des);
|
|
|
|
input_size = rmtread (in_des, input_buffer, num_bytes);
|
2008-04-12 20:03:36 +02:00
|
|
|
+ if (input_size == 0)
|
|
|
|
+ {
|
|
|
|
+ if (tape_eod (in_des))
|
|
|
|
+ get_next_reel (in_des);
|
|
|
|
+ input_size = rmtread (in_des, input_buffer, num_bytes);
|
|
|
|
+ }
|
2008-04-06 04:37:13 +02:00
|
|
|
}
|
|
|
|
if (input_size < 0)
|
2008-04-12 20:03:36 +02:00
|
|
|
error (1, errno, _("read error"));
|
|
|
|
@@ -354,8 +361,15 @@ tape_buffered_peek (char *peek_buf, int
|
2008-04-06 04:37:13 +02:00
|
|
|
{
|
|
|
|
if (input_is_special)
|
|
|
|
{
|
|
|
|
- get_next_reel (in_des);
|
|
|
|
+ if (!tape_eof (in_des))
|
|
|
|
+ get_next_reel (in_des);
|
|
|
|
tmp_input_size = rmtread (in_des, append_buf, io_block_size);
|
2008-04-12 20:03:36 +02:00
|
|
|
+ if (tmp_input_size == 0)
|
|
|
|
+ {
|
|
|
|
+ if (tape_eod (in_des))
|
|
|
|
+ get_next_reel (in_des);
|
|
|
|
+ tmp_input_size = rmtread (in_des, append_buf, io_block_size);
|
|
|
|
+ }
|
2008-04-06 04:37:13 +02:00
|
|
|
}
|
|
|
|
else
|
2008-04-12 20:03:36 +02:00
|
|
|
break;
|
|
|
|
@@ -828,6 +842,40 @@ tape_offline (int tape_des)
|
2008-04-06 04:37:13 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
+int
|
|
|
|
+tape_eof( int tape_des)
|
|
|
|
+{
|
|
|
|
+ struct mtget status;
|
|
|
|
+
|
|
|
|
+ if (rmtioctl (tape_des, MTIOCGET, (char*)&status) == -1) {
|
|
|
|
+ error (1, errno, "Cannot get tape status");
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+
|
2008-04-12 20:03:36 +02:00
|
|
|
+ if (GMT_EOF(status.mt_gstat)) {
|
|
|
|
+ return 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+int
|
|
|
|
+tape_eod( int tape_des)
|
|
|
|
+{
|
|
|
|
+ struct mtget status;
|
|
|
|
+
|
|
|
|
+ if (rmtioctl (tape_des, MTIOCGET, (char*)&status) == -1) {
|
|
|
|
+ error (1, errno, "Cannot get tape status");
|
2008-04-06 04:37:13 +02:00
|
|
|
+ return 1;
|
2008-04-12 20:03:36 +02:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (GMT_EOD(status.mt_gstat)) {
|
|
|
|
+ return 1;
|
|
|
|
+ }
|
2008-04-06 04:37:13 +02:00
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
/* The file on file descriptor TAPE_DES is assumed to be magnetic tape
|
|
|
|
(or floppy disk or other device) and the end of the medium
|
|
|
|
has been reached. Ask the user for to mount a new "tape" to continue
|