Finding all valid drives
Jon Abbott (1421) 2651 posts |
How can I create a list of all valid drives? For example, ADFS::0, IDEFS::4, RAM::0 etc My initial plan was to go through all the Filing System Numbers setting the temp FS then get the FileCore private word via OS_FSControl 20 and finally query the number of floppy/HD’s using FileCore_Drives This however doesn’t work as:
My next thought was to try reading the catalogue information for all filing systems, eg ADFS::0.$, HostFS::0.$ etc. This however also isn’t a good solution as:
|
Jeffrey Lee (213) 6048 posts |
I’m not sure of the general answer to this question, but:
That’ll be because not all filing systems are FileCore based. I’d guess that if the R1 value returned by OS_FSControl 20 is the base address of FileCore then it’ll be a FileCore FS. Otherwise it’s some other FS and (unless you recognise the module) there’s no way of knowing what SWI interface it has available (since IIRC FileSwitch doesn’t use SWIs to talk to FS’s) |
Jon Abbott (1421) 2651 posts |
I should have thought of that, the documentation even mentions the primary module being FileCore’s base. Why do some return no drives though? Is there another call to get the number of drives? I’m assuming that HostFS is FileCore based, I’m away so can’t check at the minute. Is it just HostFS that has this issue? If so, I could assume HostFS::0 exists…I don’t like special cases though, it shouts botch! |
Jeffrey Lee (213) 6048 posts |
HostFS isn’t FileCore based – it’ll be registering with FileSwitch directly. FileCore handles the “ADFS” disc format (and proxying the entire disc to ImageFS’s like DOSFS). It primarily deals with physical media, hence the use of drive numbers. FileSwitch is a lot more abstract. It doesn’t deal with drive numbers, and I don’t think there’s any API to enumerate drive names. Hardcoding support for different FS’s is probably the only way to go, since it makes sense for some FS’s to be offered to the user (e.g. HostFS, NFS, LanMan) while others would be a bit silly (ResourceFS, Devices, etc.). Or maybe have a config file that the user can list the different paths in, assuming this is for the Wonderland problems you’ve been talking about on stardot. |
Steve Pampling (1551) 8170 posts |
Following Jon’s first thoughts would the use of OS_FSControl 13 to check each file system number to see if it is present narrow his overall search for drives on different file systems?
If OS_FSControl 13 responds positively to the query about filesystem number 153 then HostFS is there. You’d need to check the old PRM’s to see the filesystem numbers that legacy OS revision have if you need that functionality. |
nemo (145) 2546 posts |
You can’t, in general. The problem is that “drive” might not mean the same thing to the FS as it does to you. I wrote a filing system where the “drive” was actually a customer account number. The HostFS in VirtualRPC hosts printers as well as mounts. Enumerable drives would be a nice extension to the low-level FS interface, but it doesn’t exist right now. |
Jon Abbott (1421) 2651 posts |
Its a bit long winded, but the process is OS_FSControl 33 (which returns a null string if the FS doesn’t exist), OS_FSControl 11 (to select it), OS_FSControl 20 (to get the FileCore private word), OS_FSControl 19 (to unselect it), FileCore_Drives (to get the drive count). I need to add some additional steps to check if OS_FSControl 20 returns the FileCore base in R1, if it doesn’t I’ll see if OS_File,17,“< FS >::0.$” reports a directory. That should get close to a full list of drives, provided removable media is FileCore based.
There’s something seriously wrong if you have to hardcode filesystems into applications! I suspect it’s not even been considered that you might want a list of drives due to the way you drag/drop to save in RISC OS. I refuse to hardcode as that’s why I’m rewriting Wonderland’s Save/Load dialogue in the first place – it’s hardcoded for ADFS, RAM and SCSIFS. I’d like to at least attempt to future proof it without user intervention. |
Jon Abbott (1421) 2651 posts |
Here’s the code I’ve ended up at. I’ve had to add a check to see if the root of the drive is a directory as SCSI and SDFS return more drives than there actually are and there are some caveats:
|