When I try to add a special file from sys, e.g.:
/sys/class/scsi_host/host0/cmd_per_lun (which is reported of size 4096 but actually reading it will return only several bytes of a result), I get the following exception:
Traceback (most recent call last):
File "/opt/xpyv/lib/python26.zip/tarfile.py", line 1975, in add
self.addfile(tarinfo, f)
File "/opt/xpyv/lib/python26.zip/tarfile.py", line 2004, in addfile
copyfileobj(fileobj, self.fileobj, tarinfo.size)
File "/opt/xpyv/lib/python26.zip/tarfile.py", line 287, in copyfileobj
raise IOError("end of file reached")
IOError: end of file reached
Notice what happens if I try to add the file with regular tar:
root@buzaglo # tar cvzf /tmp/blat.tgz /sys/class/scsi_host/host0/cmd_per_lun
tar: Removing leading `/' from member names
/sys/class/scsi_host/host0/cmd_per_lun
tar: /sys/class/scsi_host/host0/cmd_per_lun: File shrank by 4094 bytes; padding with zeros
tar: Error exit delayed from previous errors
So it handles the issue by padding the rest of the file size with zeros.
I think this should be the behavior as well, instead of throwing an IOError.
|