On 18 Oct, Matthew Howkins <[email protected]> wrote:
> > In src/hostfs.c there are two occurrences of 'ftell' which is limited by
> > being prototyped as a long. On WinXP (and no doubt others) this returns 
> > -1 and sets errno to EOVERFLOW if the filesize can't be represented as a 
> > signed long. Therefore files > 2G always falsely report a length of 4G-1.
>
> When I first read this email I was unsure as to what the benefit was
> of supporting larger files, because my understanding was that all
> versions of RISC OS only supported files of up to 2G-1.

Ah, that's a frequently called out myth.
In PRM 5a (in the section 'FileCore') the overview section describes the
limitations present, at RISC OS 3.70 at least. To paraphrase:

 Filecore = max file size 2^31 -1 
 FileSwitch = max file size 2^32 -1

as HostFS is a FileSwitch client it should be able to support 4G files as
far back as RISC OS 3.70. My recent fixes to the RISC OS 5 sources were, I
think without exception (and without going back and looking!), due to the 32
bitting process meaning that functions that previously preserved the
overflow bit now accidentally set it when comparing big files. This issue is
quite distinct from FileCore being stuck at 2G.

Indeed, my testing with 4G files has mostly been with an unmodified RISC OS
4.02 via LanManFS. RPCEmu is exceptionally useful for trying out
modifications to RISC OS 5 because if it all explodes I don't lose any data,
I just clear out the 'hostfs' directory!

> * The patch can only benefit RISC OS 5, and will cause problems for
> other versions of RISC OS. 

A simple test on 3.70 or 4.02 is
 *HOSTFS
 *CREATE bigfile 90000000
looking outside the emulator you see the correct file size, but
 F=OPENIN"bigfile"
 PRINT EXT#F
gives -1.

> * The patch only supports files of up to 4G-1. Files of >=4G will have
> the returned length truncated, so will report incorrectly. I don't see
> a better option for this than to disallow such files from being opened
> with a 'large file' error.

If can't create files >= 4G to start with, I'm not sure that applies. I
suppose it would be possible to create one outside of the emulator in the
'hostfs' directory, and yes that would alias, but that's no different to
prior to my patch.

> * The patch does not apply to the current repository, [...] 0.8.6.

My day job as an engineer tells me to only change one thing at once, so I
was being cautious to not jump to 0.8.8 (where, as you say hostfs has had
other changes made). I inspected the 0.8.8 sources and saw that the lines I
did change are identical, so the patch should still apply just at different
line numbers.

> I am open to comments and suggestions from you and others on whether
> you agree with this, or have other ideas.

I guess I see my patch as an improvement on the current situation (of not
checking the return result of ftell() being -1) while not breaking anything,
but could deal more gracefully (maybe by clamping to 4G -1) with files
created outside the emulator that are >= 4G,
Sprow.


_______________________________________________
Rpcemu mailing list
[email protected]
http://www.riscos.info/cgi-bin/mailman/listinfo/rpcemu

Reply via email to