Commit 2ebf3e19 authored by Robert Sprowson's avatar Robert Sprowson
Browse files

Make internal calls to EnsureFileSize saturate at 0xFFFFFFFF rather than error

The corresponding external interface, OS_Args 6, takes a byte size in R2 which is passed on verbatim. However, when FileSwitch wants to do the same operation it rounds up to the nearest buffer size and complains the operation can't complete ("File too big") when the same operation through OS_Args would succeed.
Internally FileSwitch doesn't actually use the allocated size for anything (other than to avoid unnecesary ensures, and to cache the value for read back via OS_Args 4), so the full byte range of R2 is now allowed internally as well as externally.
FSEntry_Open may also pass back 0xFFFFFFFF as the allocated size on opening similarly.
FSEntry_Args 7 and FSEntry_Args 4 are the corresponding low level API, these are unchanged in meaning.

The FSEntry_Args 8, write 0s to file (usually triggered by extending with EXT#handle=number), is defined as always passing the file offset as a multiple of the buffer size, and the number of 0s to write as a multiple of the buffer size. To allow this to write up to 4G of 0s while not spilling over R3, FileSwitch now splits such a call into one buffer, followed by the remainder.

Tested with LanManFS 2.38, checking operations are split appropriately.

Version 2.79. Tagged as 'FileSwitch-2_79'
parent 48bc2294
......@@ -11,13 +11,13 @@
GBLS Module_HelpVersion
GBLS Module_ComponentName
GBLS Module_ComponentPath
Module_MajorVersion SETS "2.78"
Module_Version SETA 278
Module_MajorVersion SETS "2.79"
Module_Version SETA 279
Module_MinorVersion SETS ""
Module_Date SETS "15 Jul 2012"
Module_ApplicationDate SETS "15-Jul-12"
Module_Date SETS "19 Nov 2012"
Module_ApplicationDate SETS "19-Nov-12"
Module_ComponentName SETS "FileSwitch"
Module_ComponentPath SETS "castle/RiscOS/Sources/FileSys/FileSwitch"
Module_FullVersion SETS "2.78"
Module_HelpVersion SETS "2.78 (15 Jul 2012)"
Module_FullVersion SETS "2.79"
Module_HelpVersion SETS "2.79 (19 Nov 2012)"
END
/* (2.78)
/* (2.79)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 2.78
#define Module_MajorVersion_CMHG 2.79
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 15 Jul 2012
#define Module_Date_CMHG 19 Nov 2012
#define Module_MajorVersion "2.78"
#define Module_Version 278
#define Module_MajorVersion "2.79"
#define Module_Version 279
#define Module_MinorVersion ""
#define Module_Date "15 Jul 2012"
#define Module_Date "19 Nov 2012"
#define Module_ApplicationDate "15-Jul-12"
#define Module_ApplicationDate "19-Nov-12"
#define Module_ComponentName "FileSwitch"
#define Module_ComponentPath "castle/RiscOS/Sources/FileSys/FileSwitch"
#define Module_FullVersion "2.78"
#define Module_HelpVersion "2.78 (15 Jul 2012)"
#define Module_LibraryVersionInfo "2:78"
#define Module_FullVersion "2.79"
#define Module_HelpVersion "2.79 (19 Nov 2012)"
#define Module_LibraryVersionInfo "2:79"
......@@ -836,7 +836,7 @@ BufferedMultipleWrite EntryS "r1, bcb"
; In fileptr = length of file to extend and fill with zeroes to
; extent = old extent of file
; r1 = new extent of file (endptr)
; r1 = new extent of file (endptr), known nonzero
; WriteMultiple needs to extend the file
......@@ -850,7 +850,8 @@ GBPBExtendFile Entry "r0-r2, fileptr, extent"
DREG r1, "WriteMultiple causing file extension, new endptr "
]
ADD r2, r1, bufmask ; Round xx001 -> xx100, but not xx000
BIC r2, r2, bufmask
BICS r2, r2, bufmask
MOVEQ r2, #&FFFFFFFF ; Saturate at 4G-1
BL EnsureFileSize ; Uses scb_extent
EXIT VS
......
......@@ -35,7 +35,7 @@ scb_fshandle # 4 ; Real Filing System handle } Keep together
scb_fscb # 4 ; Ptr to associated fscb } in order
scb_devid # 4 ; Stream identifier, normally zero
scb_allocsize # 4 ; Size currently allocated on disc
scb_allocsize # 4 ; Size currently allocated on disc, buffer aligned (saturate at 4G-1)
scb_special # 4 ; Pointer to special field (SGetAreaed) or scb^ used to open this file
scb_path # 4 ; Pointer to path tail (SGetAreaed) used to open this file
......@@ -673,10 +673,7 @@ GetFileBuffer Entry
EnsureBufferValidForWrite Entry "r1-r2"
BL FindFileBuffer ; Got the right buffer here ?
EXIT NE ; [yes]
BL GetFileBuffer ; Better run and get it
BL EnsureBufferValid ; Get bcb^ valid for this fileptr
EXIT VS
BIC r14, fileptr, bufmask ; Going to be writing at EOF ?
......@@ -686,19 +683,14 @@ EnsureBufferValidForWrite Entry "r1-r2"
EXIT
90
ADD r2, extent, #1
ADD r2, r2, bufmask ; Round 0000 up to 0100
ADD r2, r2, bufmask ; Round up to nearest buffer multiple
BICS r2, r2, bufmask
BEQ %FA99 ; [wrapped 32 bits]
MOVEQ r2, #&FFFFFFFF ; Saturate at 4G-1
BL EnsureFileSize
BLVS DeallocateBuffer ; Discard invalid buffer
EXIT ; Accumulates V
99 addr r0, ErrorBlock_FSFileTooBig
BL CopyError
EXIT
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;
; EnsureBufferValid
......@@ -797,7 +789,7 @@ ExtendFileWithZeroes Entry "r0-r2, fileptr, bcb, fscb" ; Nasty temporary
CMP r2, extent ; File growing ?
[ No26bitCode
BHI %FT05
CLRV
CLRV ; Ensure VClear for extents > 2G
EXIT
05
|
......@@ -823,7 +815,7 @@ ExtendFileWithZeroes Entry "r0-r2, fileptr, bcb, fscb" ; Nasty temporary
SUB r14, r2, #1 ; Maps xx001..xx100 -> xx000..xx0FF
BIC r14, r14, bufmask ; Map to buffer base
CMP r14, fscb ; In the same one as before ?
TEQ r14, fscb ; In the same one as before ?
EXIT EQ ; All done then ! VClear
......@@ -831,7 +823,7 @@ ExtendFileWithZeroes Entry "r0-r2, fileptr, bcb, fscb" ; Nasty temporary
ADD r2, r2, bufmask ; Reserve space on media
BICS r2, r2, bufmask
BEQ %FA99 ; [wrapped 32 bits; 0 case handled ^]
MOVEQ r2, #&FFFFFFFF ; Saturate at 4G-1
BL EnsureFileSize
EXIT VS
......@@ -848,6 +840,18 @@ ExtendFileWithZeroes Entry "r0-r2, fileptr, bcb, fscb" ; Nasty temporary
BIC r2, r2, bufmask
SUBS r1, r14, r2 ; How much to do
BNE %FT30
; This is definitely a grow operation since "less than extent" was rejected earlier,
; so the only way to end up with zero here is if 4G is required. However, the
; interface for fsargs_WriteZeroes is defined to only take buffer multiples, so
; split the 4G across two FS calls.
ADD r1, bufmask, #1 ; One buffer
BL ZeroFileFromPosition
ADD r2, r2, r1 ; Adjust start point
RSB r1, r1, #0 ; Remainder to do
30
BL ZeroFileFromPosition
; In the interests of efficiency, we should really create a buffer full of
......@@ -857,11 +861,6 @@ ExtendFileWithZeroes Entry "r0-r2, fileptr, bcb, fscb" ; Nasty temporary
EXIT
99 addr r0, ErrorBlock_FSFileTooBig
BL CopyError
EXIT
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;
; ZeroBufferFromPosition
......@@ -905,8 +904,8 @@ ZeroBufferFromPosition Entry "r0-r1"
;
; Write zeroes to a file from a given point
; In r2 = offset in file
; r1 = number of bytes to zero (can be zero)
; In r2 = offset in file, a buffer multiple
; r1 = number of bytes to zero (can be zero), a buffer multiple
ZeroFileFromPosition Entry "r0-r3"
......@@ -946,7 +945,7 @@ EnsureFileSize Entry "r0, r3"
EXITS LS ; Assumes VClear in entry lr
]
MOV r0, #fsargs_EnsureSize ; r2 = new size, r3 = old extnt
MOV r0, #fsargs_EnsureSize ; r2 = new size, r3 = old extent
LDR r3, scb_extent
BL CallFSArgs
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment