2

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

4

2 回答 2

0

问题在于 tcopy,它使用设备上的块大小而不是检测它。

fcntl.ioctl(fh, MTIOCTOP, struct.pack('hi', MTSETBLK, 0))

在最后一次写入后允许 tcopy 按预期显示数据。

于 2016-10-11T16:11:43.990 回答
0

喜欢的东西怎么样commands.getstatus('mt -f /dev/st2 fsf')

于 2018-03-07T13:13:51.510 回答