Task is create two record with different sizes within one file entry. I’m using python 3.4.5 for testing:
JavaScript
x
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 <<< should be 2 records
eot
total length: 4096 bytes
[root@dev2 mhvtl]# ^C
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?
Advertisement
Answer
Issue was with tcopy, it uses block size on device instead of detecting it.
JavaScript
fcntl.ioctl(fh, MTIOCTOP, struct.pack('hi', MTSETBLK, 0))
after last write allowed tcopy to display data as intended.