ADFlib
ADFlib copied to clipboard
Can't access empty native device
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?
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?
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?
First, what is your goal? Then, we'll see if API is able to answer it, or could be improved
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.
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.
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();
throw CannotWriteException();
why would u use fukken C++ voluntarily
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
@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).