Write magnetic tape end of record linux
<p>Task is create two record with different sizes within one file entry.
I'm using python 3.4.5 for testing:</p>

<pre><code>import fcntl
import os
import struct

MTIOCTOP = 0x40086d01  # refer to mtio.h
MTSETBLK = 20

fh = os.open('/dev/st2', os.O_WRONLY )
fcntl.ioctl(fh, MTIOCTOP, struct.pack('hi', MTSETBLK, 1024))
os.write(fh, b'a'*1024)
fcntl.ioctl(fh, MTIOCTOP, struct.pack('hi', MTSETBLK, 2048))
os.write(fh, b'b'*2048)
os.close(fh)


[root@dev2 mhvtl]# tcopy /dev/st2
file 0: block size 4096: 1 records
file 0: eof after 1 records: 4096 bytes &lt;&lt;&lt; should be 2 records
eot
total length: 4096 bytes
[root@dev2 mhvtl]# ^C
</code></pre>

<p>Is there an ioctl opt code that will initiate a new record on the tape with variable record length.
Or any other way to work around this bug?</p>

<p>Issue was with tcopy, it uses block size on device instead of detecting it.</p>

<pre><code>fcntl.ioctl(fh, MTIOCTOP, struct.pack('hi', MTSETBLK, 0))
</code></pre>

<p>after last write allowed tcopy to display data as intended.</p>

python linux ioctl fcntl mt