reliable way to get free space
Sergey Lentsov (8268) 63 posts |
Hello, Simple question. How to get free space for any drive via SWI? I tried to use xfilecore_free_space64 (not sure that it helps) but it required “Pointer to FileCore instance private word” and I don’t know where to get it.. When I tried to use null as “private word” but it not work also. How to reliable get free space of any drive? |
André Timmermans (100) 655 posts |
Curious, I just looked at the sources, I see an implementation as FSEntry 35, so normally it should work. And would you look at OS_FSControl 55, it’s an extension to 64-bit of an older entry, but the idiot who created the API left the “size of the largest object that can be created” as 32-bit, meaning we have to define yest other call in order to support for 64-bit file sizes. |
Matthew Phillips (473) 721 posts |
OS_FSControl 55 is the correct call to use, falling back on OS_FSControl 49 if 55 is not implemented. The FileCore calls will not be of help because a FAT-formatted medium is not understood by FileCore. FileCore is the native RISC OS format that you will be using if you are accessing stuff via ADFS, SCSIFS etc. The ADFS and SCSI modules implement the hardware drivers, but the layout and file allocation is all provided by FileCore. Do you find that the free space on the drive is accurately shown via the iconbar menu or using *free at the command line? Because they will be using the same filing system entry points behind the scenes. |
Stuart Swales (8827) 1357 posts |
Update:
I think Fat32FS may need to set bit “23 – Filing system supports image filing system extensions” in its info word for FreeSpace64 to be passed down to it from FileSwitch. I tried plugging a spare FAT formatted card into my Pi but it stiffed it! So can’t easily test. Note that DOSFS doesn’t support asking for free space. Not all filing systems will.
That was always the intention… Fat32FS’s show free seems to directly call into the module’s Entry_Func rather than going via FileSwitch. |
nemo (145) 2546 posts |
IIRC &FFFFFFFF means “bigger than you could possibly imagine”, or perhaps “try it and see”. |
Jeff Doggett (257) 234 posts |
It does. However setting this bit also causes other unimplemented calls to be made. E.g. FSEntry_Func 23 It appears to work now, but I’d suggest treating with caution for a while. EDIT: Forget that, doesn’t work – still something not implemented. |
Stuart Swales (8827) 1357 posts |
It does seem rather odd in the FileSwitch source as modified for image file systems BITD (not me!). Why the FreeSpace entries were lumped in there? |
Jeff Doggett (257) 234 posts |
When I type *Ex or *Cat it now moans that Fat32fs doesn’t support Special Fields. Setting bit 31 appears to make this work, but I’m not sure how much else will now be broken. |
Jon Abbott (1421) 2651 posts |
Jeff, if you’re using Special Fields, be aware of this issue, which may or may not affect FAT32FS. It may have been fixed in FileSwitch 2.89 in Jan, but I’ve yet to test. Sergey, as noted above the correct method is OS_FSControl 55 followed by OS_FSControl 49 if the former errors. FATFS doesn’t support these and as noted above neither does FAT32FS (currently by the looks of it). For Partition Manager I read the FAT32 “Last known free clusters” value from the FS Information sector which although not guaranteed to be accurate was a quick compromise. If Jeff gets it working I’ll add a version check into Partition Manager and use OS_FSControl 55 for mounted FAT32 drives. |
Jeff Doggett (257) 234 posts |
I’ve changed the response to func 23 to state that special fields are not used, so Bit 31 of the file information word is no longer needed. At the moment it seems to be working, I’ll need to do some more testing to be sure. |
Jeff Doggett (257) 234 posts |
I’ve uploaded V1.60 for testing. |
Sergey Lentsov (8268) 63 posts |
Hello, Thanks to all for help. I will make fallback to OS_FSControl 49 but it is 32bit and in my case file system is much bigger than 4GB and I afraid this not help. |
Jon Abbott (1421) 2651 posts |
What are you running this on? OS_FSControl 55 will likely always work, it will only fall back to OS_FSControl 49 under RISC OS 3.19 or earlier.
Fantastic, I’ll test with Partition Manager for the next beta release EDIT: v1.60 Looks good to me, OS_FSControl 55 is returning what I expect |
Dave Higton (1515) 3526 posts |
I downloaded FAT32FS 1.60 last night, and I’ve just given OS_FSControl 55 a whirl on a 16GB USB thumb drive. The results look correct to me. Thanks, Jeff. |