hdfmonkey - a Swiss Army Knife for HDF disk images

edited May 2012 in Announcements
This is a spin-off from my recent experiments on ESXDOS. If you want to play with the DivIDE (or other Speccy hard disk interfaces) under emulation, you'll be working with HDF files, which are images of hard disks in much the same way that TZXs and DSKs are for tapes and disks. The problem is, HDF files are a bit of a black box, with no good way to get at the individual files contained within them... there are utilities around for copying them to and from physical disks, but you really don't want to be doing that every time you want to get at an individual file. (And it's particularly annoying if you're trying to develop software for something like ESXDOS under emulation...)

Which is where hdfmonkey comes in. If you have an HDF image of a FAT-formatted disk (which is what all good firmwares for Speccy hard disk interfaces will be supporting for the forseeable future), and you want to get wibble.txt off it, you can do this:

hdfmonkey get myimage.hdf wibble.txt ./wibble.txt

And if you have a wonderful new game as a .tap file that you want to copy to the /games/ directory of your disk so that you can load it in via ESXDOS, FATware or ResiDOS, you can do this:

hdfmonkey put myimage.hdf wonderful_new_game.tap /games/wonderful_new_game.tap

Likewise, there are commands for getting directory listings, creating directories, and deleting files/directories. In theory you can even format the disk with a freshly minted FAT filesystem, but neither ESXDOS nor FATware recognise it at the moment and I'm not sure why. One to be fixed in a later version, hopefully...

Source code (should be portable with no weird dependencies): ftp://ftp.untergrund.net/users/gasman/zx/hdfmonkey/hdfmonkey-0.1.tar.gz
Mac OS X binary: ftp://ftp.untergrund.net/users/gasman/zx/hdfmonkey/hdfmonkey-0.1-osx.zip
Development site: http://github.com/gasman/hdfmonkey

Something that would be a really neat addition (and probably not a huge amount of work to add at this point) would be a FUSE / MacFUSE extension so that you can mount the disk and work with it directly using ordinary file commands. That's not something I'll be immediately rushing to do though, because for now it does everything I want :-)
Post edited by gasman on
«1

Comments

  • edited May 2010
    Ignore, wrong thread..
  • edited July 2011
    Version 0.2 released...

    Source code: ftp://ftp.untergrund.net/users/gasman/zx/hdfmonkey/hdfmonkey-0.2.tar.gz
    Mac OS X binary: ftp://ftp.untergrund.net/users/gasman/zx/hdfmonkey/hdfmonkey-0.2-osx.zip
    Development site: is still http://github.com/gasman/hdfmonkey

    Thanks to some sterling fault-finding work by Phoenix, this version fixes the problem with the 'format' command where ESXDOS and FATware wouldn't recognise the FAT partition. I've also added new commands 'create' (create a new FAT-formatted HDF or raw disk image of any size) and 'clone' (copy an existing real/virtual disk to HDF, like the raw2hdf program in fuse-utils - but this one goes in the other direction too), improved the 'put' command so that you can copy multiple files and directories at once, and added the ability to specify a volume label on format/create.

    As an example, the following steps will create a 32Mb HDF image with volume label 'SPECCY' initialised with the ESXDOS system files (assuming you have them in ~/Development/esxdos). No more faffing around with actual CF card readers just to get something you can use in an emulator! :-)
    hdfmonkey create speccy.hdf 32M speccy
    hdfmonkey put speccy.hdf ~/Development/esxdos/* /
    
  • edited July 2011
    This is very useful! Thank you Gasman!
  • edited July 2011
    gasman wrote: »
    hdfmonkey create speccy.hdf 32M speccy
    hdfmonkey put speccy.hdf ~/Development/esxdos/* /
    

    Did you forget to format the hdf file?
    hdfmonkey format speccy.hdf

    By the way, I compiled it with mingw, I had to comment out some permission constants like S_*. Also Gmtime_r is not supported with mingw, and I gave a fixed date, so all files will be written as 10.10.2010 10:10:10. :)

    Here is the windows version, warning, I didn't check it throughly:
    http://arda.kisafilm.org/fish/hdfmonkey02_quickcompile.zip
  • edited July 2011
    Arda wrote: »
    Did you forget to format the hdf file?
    hdfmonkey format speccy.hdf

    Nope - formatting as FAT is done as part of the 'create' action (or at least, it should be...)

    Thanks for the Windows port, much appreciated!
  • edited July 2011
    gasman wrote: »
    Nope - formatting as FAT is done as part of the 'create' action (or at least, it should be...)

    Thanks for the Windows port, much appreciated!

    oh ok, then there may be a problem with windows port :D it doesn't work without formatting first.
  • edited August 2011
    Hi,

    This looks to be exactly what I was looking for...except I can't get it to work.

    I'm using Windows 7 and the port provided by Arda.

    I've done the following which creates a blank hdf that is visible in Fuse and ZXSpin

    hdfmonkey create speccy.hdf 32M speccy

    But, when I try to use the "put" command I get an error:

    read() error. line: 23
    Error opening file: Low-level disk error

    Any help would be greatly appreciated...


    Gareth
  • edited August 2011
    As Arda said... it doesn't work without formatting first :smile:
  • edited August 2011
    But if I do the format command I get Fuse telling me it's not a valid hdf file
  • edited August 2011
    Oops! Maybe you could use a preformatted HDF

    [EDIT] Here it is hdfmonkey-0.2 for windows, compiled with cygwin instead of mingw32. Seems to have better compatibility because "create" command format the file and fuse recognize it.
  • edited August 2011
    Hi Serbaldi,

    Thanks - Fuse and ZXSpin both recognise and can read it now. Put even seems to put a file on there but if I try to load them using FATWare I get the loading screen then a tape loading error. Very realistic but not quite what I wanted!!

    Gareth
  • edited August 2011
    Try with 64M image instead of 32M. Not sure why this works.
  • edited August 2011
    Nope, me neither...but it does!! Fantastic - thanks so much!
  • edited April 2012
    hdfmonkey (for windows) is OK but has problem to create HDF image e.g. 1MB. After inserting HDF 1MB (with TAP file) into emulator EightyOne, pressing NMI, selecting game from Disk Browser and LOAD "" there is Tape loading error.
    After create image HDF with other size e.g 16MB (with this same TAP file) is no errors and loading OK.
    Maybe hdfmonkey working only with 16x multiple sizes e.g. 16, 32, 64 etc. ???
  • edited April 2012
    What's the use case for a 1 MB hard disk image?
  • edited April 2012
    What's the use case for a 1 MB hard disk image?

    Use in case your 3.5 floppy breaks!
  • edited April 2012
    I try use 1MB for some test of course not for make my all games backup for DivIDE :-)
    Last time I try make HDF image with Muppet.dvo + player.tap for use with Fuse emu. File size Muppet.dvo is 135MB so I need make HDF some more size to add file player.tap e.g 138MB and this not working :-(. After create HDF 140MB is OK and working.
  • edited April 2012
    MrCheese wrote: »
    Use in case your 3.5 floppy breaks!

    That may be a particularly relevant answer in fact... :-)

    Any image under 63Mb in size will be created as FAT12 (the type usually found on floppies) rather than FAT16. It seems that Fatware only officially supports FAT16 - apparently FAT12 does work to some extent, but that might just be a fluke. I'll have to do some experimenting to confirm whether this is indeed the problem - if so, it would probably make sense for hdfmonkey to have a command line switch to force the use of FAT16.
  • edited April 2012
    gasman wrote: »
    If you have an HDF image of a FAT-formatted disk (which is what all good firmwares for Speccy hard disk interfaces will be supporting for the forseeable future)

    *ahem*

    How very dare you!? ;)

    oh wait, for the forseeable future - you're probably right there. :)

    Incidentally my firmware will support FAT just not on an IBM format disk :)
  • edited May 2012
    hdfmonkey 0.3 is here (and here's an OS X build of it, probably Intel only although it's hard to tell these things). Changes this time:

    - It should be a *lot* faster when copying large files now. (Copying outline.dvo to an .hdf image now takes 1.3 seconds on my Macbook, rather than 7 and a half minutes :-) ) For some reason, when I opened the image files, I previously had the "make all file access excruciatingly slow" (otherwise known as O_SYNC) flag set, and I have no idea why. If any Unix gurus want to pipe up and say "actually, removing O_SYNC set is a really bad idea", now is the time...

    - There's a new command, as previously hinted here:
    hdfmonkey rebuild oldfile.hdf newfile.hdf
    
    which does a file-by-file copy of all the things on oldfile.hdf onto newfile.hdf, which should ensure that everything on newfile.hdf is unfragmented.

    - It now handles read-only media correctly.
  • edited May 2012
    Brilliant! Here is a build for Windows:
    http://www.mediafire.com/?a4gcnliw1uuiq7s
  • hdfmonkey 0.4 is here up at http://files.zxdemo.org/gasman/speccy/hdfmonkey/
    and https://github.com/gasman/hdfmonkey

    it's now possible to override the automatically-chosen format with a switch.

    - There's a new command:
    hdfmonkey create <--fat12> <--fat16> <--fat32> <imagefile> <size> [volumelabel]

    Could please a build be created for Windows?
    (with cygwin1.dll and cyggcc_s-1.dll)
  • IMO --fat-{12,16,32} options are experimental and should be avoided if possible. Out of spec images may suffer undesired issues.

    Windows build:
    http://www.mediafire.com/file/ah6emm5416n644n/hdfmonkey-win32-0.4.zip
    Thanked by 2Spezzi63 Luzie
  • The Windows builds 04 of hdfmonkey is extremely small ;)
    The 04 is experimental.
    Since so far the v03 also works very well, but still cygwin1.dll and cyggcc_s-1.dll needs, would it be nice if the time allowed it to compile the version 0.3 also once again to Cross, please?
  • edited August 2017
    I have problems with hdfmonkey 0.4 formatting a 32MB image. When using this, I get an error on ZEsarUX:
    Trying to read beyond mmc. Size: 33554432 Asked: 402759680. Disabling MMC
    (see Screenshot).

    No change when I use --fat16 switch when formatting the 32MB image.
    When I use a 64MB image, there´s no error.
    When I use ImDisk Virtual Disk Driver from ltr-data.se/opencode.html/#ImDisk to create and format the 32MB Image, there´s no error.
    So I think it must be an issue with format from hdfmonkey

    file.php?id=6571
    Post edited by Luzie on
  • Luzie wrote: »
    I have problems with hdfmonkey 0.4 formatting a 32MB image.
    It's been formatted as FAT12, unsupported by esxdos. Use card sizes >= 64 Mb for maximum compatibility.
    No change when I use --fat16 switch when formatting the 32MB image.
    This option is experimental and error prone.
  • edited August 2017
    serbalgi wrote: »
    This option is experimental and error prone.
    A pity as ImDisk tool needs to be installed under windows and is not portable. And yet I found no other commandline-tool for formatting an image-file under windows with FAT16.
    Post edited by Luzie on
  • edited December 2017
    Is there a way to rename a directory in a .HDF-Image with hdfmonkey?

    There seem to be a rename function in "FatFs - FAT file system module R0.07e" sourcecode at: https://github.com/gasman/hdfmonkey/blob/master/src/ff.c but neither HDFmonkey.EXE v0.3 nor v0.4 (Windows Version) use it? (Looking into v0.3 binary I see text "rename", but it don´t seem to be implemented?
    Post edited by Luzie on
  • edited December 2017
    Luzie wrote: »
    Is there a way to rename a directory in a .HDF-Image with hdfmonkey?
    This operation isn't implemented but it's an easy addition. Do you mind doing beta testing?
    hdfmonkey move <imagefile> <source> <dest>
    

    Binary:
    http://www.mediafire.com/file/t9272cx99c4bkxa/hdfmonkey-win32-0.4-wip20171230.zip

    Source:
    https://github.com/sbaldovi/hdfmonkey/commit/b7c83859aa6f83f067c535336d6d56af24d7a0fa
    Post edited by serbalgi on
  • edited December 2017
    serbalgi wrote: »
    This operation isn't implemented but it's an easy addition. Do you mind doing beta testing?
    hdfmonkey move <imagefile> <source> <dest>
    
    Wow! Thank you very much. I´m into testing and it seems to work flawless :-)

    One thing which might be bettered is to rename message "Move (rename) failed: File not found" to "Move (rename) failed: File or Directory not found"
    Post edited by Luzie on
Sign In or Register to comment.