任务是在一个文件条目中创建两条不同大小的记录。我正在使用 python 3.4.5 进行测试:
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
是否有一个 ioctl opt 代码可以在磁带上启动一条具有可变记录长度的新记录。或者任何其他方法来解决这个错误?