ADFlib icon indicating copy to clipboard operation
ADFlib copied to clipboard

Can't access empty native device

Open mankeli opened this issue 3 years ago • 9 comments

After writing my own native device handlers, it seems that the adfMountDev() returns nullptr if the disk (DD) doesn't already contain filesystem. (*adfEnv.wFct)("adfReadRootBlock : id not found");

Is there something I'm missing or why is this considered an error?

mankeli avatar May 21 '22 22:05 mankeli

Rootblock is mandatory, so it should be an error eFct and not a warning wFct. Did you try to dump your physical device as image, then mount it using adflib?

lclevy avatar May 22 '22 07:05 lclevy

But empty diskettes don't have a rootblock yet. I'm using adfCreateFlop() to initialize diskettes that may have whatever on them. I can work around this by writing a template filesystem on a disk before calling adfMountDev() but that's not really ideal.

Does adfMountDev() have to enforce that there's volumes on the disk? Would it be better suited that volumes are searched when adfMount() or adfDeviceInfo() is called?

mankeli avatar May 22 '22 07:05 mankeli

First, what is your goal? Then, we'll see if API is able to answer it, or could be improved

lclevy avatar May 22 '22 07:05 lclevy

It sounds like they would like to use ADFlib to format uninitialized media on a real device, i.e. not adfCreateDumpDevice() then adfCreateFlop(), but adfMountDev() then adfCreateFlop().

Imagine a DOpus program for some kind of CatWeasel device, using ADFlib. The user can format uninitialized floppy disks in their real floppy drive and can read/write files on them thereafter.

kyz avatar Jun 26 '22 12:06 kyz

Sorry, forgot to reply! I'm just creating adf images within another image file. Using my own low-level functions, like

nFct->adfInitDevice = ercInitDevice ;
nFct->adfNativeReadSector = ercReadSector ;
nFct->adfNativeWriteSector = ercWriteSector ;
nFct->adfReleaseDevice = ercReleaseDevice ;
nFct->adfIsDevNative = ercIsDevNative;

I worked around this by just using empty pre-formatted adf image that I copy to the memory area before. The ADFlib API kinda looks like you could just format your native disks with it, so imho it's a bit odd that the existing rootblock is required. :) The DOpus example @kyz came up with, is a good use case too. Same kind of template-writing would be necessary there too.

mankeli avatar Jun 26 '22 14:06 mankeli

I have precisely the same problem --- I can't create the Device to pass in to adfCreateFlop without first having a filesystem on the floppy disk.

I eventually managed to make it work by faking up a Device like this:

        struct Device dev = {};
        dev.readOnly = false;
        dev.isNativeDev = true;
        dev.devType = DEVTYPE_FLOPDD;
        dev.cylinders = 80;
        dev.heads = 2;
        dev.sectors = 11;
        adfInitDevice(&dev, nullptr, false);
        int res = adfCreateFlop(&dev,
            (char*)"FluxEngine FFS", 0);
        if (res != RC_OK)
            throw CannotWriteException();

davidgiven avatar Aug 30 '22 22:08 davidgiven

       throw CannotWriteException();

why would u use fukken C++ voluntarily

rofl0r avatar Aug 30 '22 23:08 rofl0r

First, what is your goal? Then, we'll see if API is able to answer it, or could be improved

MountDev has been designed to mount an existing filesystem. If I remember well, CreateFlop only create a valid filesystem on a floppy disk, and not HDD

lclevy avatar Nov 19 '22 13:11 lclevy

@mankeli, for the operation you wanted, try: adfOpenDev(), adfCreateFlop (), adfCloseDev() (as in examples/adf_floppy_format.c). As for now, it is tested only for std. floppies, not for hard disks. So let know if you test such case.

For the NATIVE/REAL SYSTEM DEVICES, I repeat again: THE CODE IS NOT TESTED. If you want to try it, do it in a safe way (read comments about it in #31).

t-w avatar Jan 19 '23 12:01 t-w

Possible to access empty devices since 0.8.0, improved in 0.9.0.

t-w avatar May 19 '24 12:05 t-w