cnvogelg / amitools

Various tools for using AmigaOS programs on other platforms
250 stars 69 forks source link

Error listing contents of non-RDB (WinUAE) hdf file #189

Closed jimnarey closed 6 months ago

jimnarey commented 1 year ago

Hi,

I have been experimenting with xdftool and HDF files. I can run xdftool file.hdf list successfully using an RDB/full disk image created in WinUAE. If I attempt to do so using a non-RDB file I get the following output:

Traceback (most recent call last):
  File "/home/jimnarey/projects/amitools/bin/xdftool", line 45, in <module>
    res = main()
          ^^^^^^
  File "/home/jimnarey/projects/amitools/amitools/tools/xdftool.py", line 913, in main
    code = queue.run()
           ^^^^^^^^^^^
  File "/home/jimnarey/projects/amitools/amitools/tools/xdftool.py", line 87, in run
    exit_code = CommandQueue.run(self)
                ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jimnarey/projects/amitools/amitools/util/CommandQueue.py", line 39, in run
    exit_code = self.run_first(cmd_line, cmd)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jimnarey/projects/amitools/amitools/tools/xdftool.py", line 127, in run_first
    return self.run_next(cmd_line, cmd)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jimnarey/projects/amitools/amitools/tools/xdftool.py", line 160, in run_next
    self.volume = self.init_vol(self.blkdev)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jimnarey/projects/amitools/amitools/tools/xdftool.py", line 187, in init_vol
    vol.open()
  File "/home/jimnarey/projects/amitools/amitools/fs/ADFSVolume.py", line 54, in open
    self.root_dir.read()
  File "/home/jimnarey/projects/amitools/amitools/fs/ADFSDir.py", line 112, in read
    dcb.read()
  File "/home/jimnarey/projects/amitools/amitools/fs/block/DirCacheBlock.py", line 103, in read
    self._read()
  File "/home/jimnarey/projects/amitools/amitools/fs/block/DirCacheBlock.py", line 121, in _read
    off = r.get(self.data, off)
          ^^^^^^^^^^^^^^^^^^^^^
  File "/home/jimnarey/projects/amitools/amitools/fs/block/DirCacheBlock.py", line 39, in get
    self.type = ord(data[off + 22])
                ^^^^^^^^^^^^^^^^^^^
TypeError: ord() expected string of length 1, but int found

Using pdb I can see:

-> self.type = ord(data[off + 22])
(Pdb) dir()
['d', 'data', 'off', 'self']
(Pdb) data
bytearray(b'\x00\x00\x00!\x00\x08\x00\x01\x00\x08\x00\x00\x00\x00\x00\x0f\x00\x08\x01\x83\x11\x8b\xd9\xe4\x00\x08\x01\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00@\xf3\x00\x0e\t\xe9\x02\x08Trashcan\x00\x00\x00\x08\x01\n\x00\x00\x04\x94\x00\x00\x00\x00\x00\x00\x00\x00@\xf3\x00\x0e\t\xe9\xfd\rTrashcan.info\x00\x00\x08\x01\x0e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00@\xf3\x00!\x06\\\x02\x05Prefs\x00\x00\x08\x01\x1d\x00\x00\x02t\x00\x00\x00\x02\x00\x00\x00\x00@\xf3\x00!\x06\\\xfd\nPrefs.info\x00\x00\x00\x08\x01/\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00@\xf3\x00 \x01\x01\x02\x05Fonts\x00\x00\x08\x012\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00@\xf3\x00\x14\n\x98\x02\tExpansion\x00\x00\x08\x015\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00@\xf3\x00 \x06\xf3\x02\tWBStartup\x00\x00\x08\x018\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00@\xf3\x00\x14\n\x98\x02\x06Locale\x00\x00\x00\x08\x01G\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00@\xf3\x00\x1e\x02D\x02\x07Classes\x00\x00\x08\x01S\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00@\xf3\x00\x1c\x03W\x02\x04Devs\x00\x00\x00\x08\x01e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00@\xf3\x00!\x06a\x02\x07Storage\x00\x00\x08\x01h\x00\x00\x02t\x00\x00\x00\x02\x00\x00\x00\x00@\xf3\x00!\x06`\xfd\x0cStorage.info\x00\x00\x00\x08\x01z\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00@\xf3\x00 \x08\x16\x02\x04Libs\x00\x00\x00\x08\x01}\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00@\xf3\x00!\x06_\x02\x05Tools\x00\x00\x08\x04\xce\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00@\xf3\x00 \x05\xe3\x02\x01C\x00\x00\x00')
(Pdb) off
24

Is this expected behaviour with a non-RDB HDF file?

Thanks!

jimnarey commented 1 year ago

I did some more testing and narrowed the problem down to trying to use xdftool with HDFs formatted with the directory cache option enabled. All other combinations of formatting options available under 3.2 work fine. It's nothing to do with an image being (non-)RDB.

I'm assuming this isn't therefore a bug, as it's a relatively niche option.

cnvogelg commented 11 months ago

Hi @jimnarey, this looks like a bug in DirCache mode of the fs. Could you give me a short how-to so I can recreate such a faulty image for debugging? Preferably a sequence of xdftool commands. But real AmigaOS workflow is also fine... Thanks!

cnvogelg commented 11 months ago

I was able to reproduce the bug with an own image created in AmigaOS. See 6c74b02 for the fix. Please give it a try and verify that it works for you