Commit 9361961f authored by Robert Sprowson's avatar Robert Sprowson

[415] Report dir full when hitting dir size limit

FileCore would allow objects to be added to BigDir extensible directories until eventually failing and leaving an unopenable broken directory behind.
In fact, the on disc directory was sound, but after updating the parent in GrowBigDir it would reload the child into the dir cache with FindDir, FindDir called SanityCheckBigDirHeader which was rejecting BigDir's of exactly 4MB that was created moments earlier.
Now, during the initial attempt grow, a check is made for exceeding BigDirMaxSize before trying to enlarge the dynamic area (while it would be possible to translate the error from maxing out the dynamic area, there could be situations where there genuinely isn't enough memory to enlarge the area) and a more polite "Dir full" error returned.
Tested with an initially empty drive (so the dynamic area must grow) and with one that previously created a maximal directory (dynamic area already large enough).

Also tightened up a couple of places loading byte wide variables using LDR, relying on the modulo 31 properties of LSR/LSL, when we can simply load the value as a byte for the same cost.

Version 3.72. Tagged as 'FileCore-3_72'
parent 8f7b5469
......@@ -11,13 +11,13 @@
GBLS Module_HelpVersion
GBLS Module_ComponentName
GBLS Module_ComponentPath
Module_MajorVersion SETS "3.71"
Module_Version SETA 371
Module_MajorVersion SETS "3.72"
Module_Version SETA 372
Module_MinorVersion SETS ""
Module_Date SETS "16 Dec 2016"
Module_ApplicationDate SETS "16-Dec-16"
Module_Date SETS "09 Apr 2017"
Module_ApplicationDate SETS "09-Apr-17"
Module_ComponentName SETS "FileCore"
Module_ComponentPath SETS "castle/RiscOS/Sources/FileSys/FileCore"
Module_FullVersion SETS "3.71"
Module_HelpVersion SETS "3.71 (16 Dec 2016)"
Module_FullVersion SETS "3.72"
Module_HelpVersion SETS "3.72 (09 Apr 2017)"
/* (3.71)
/* (3.72)
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
#define Module_MajorVersion_CMHG 3.71
#define Module_MajorVersion_CMHG 3.72
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 16 Dec 2016
#define Module_Date_CMHG 09 Apr 2017
#define Module_MajorVersion "3.71"
#define Module_Version 371
#define Module_MajorVersion "3.72"
#define Module_Version 372
#define Module_MinorVersion ""
#define Module_Date "16 Dec 2016"
#define Module_Date "09 Apr 2017"
#define Module_ApplicationDate "16-Dec-16"
#define Module_ApplicationDate "09-Apr-17"
#define Module_ComponentName "FileCore"
#define Module_ComponentPath "castle/RiscOS/Sources/FileSys/FileCore"
#define Module_FullVersion "3.71"
#define Module_HelpVersion "3.71 (16 Dec 2016)"
#define Module_LibraryVersionInfo "3:71"
#define Module_FullVersion "3.72"
#define Module_HelpVersion "3.72 (09 Apr 2017)"
#define Module_LibraryVersionInfo "3:72"
......@@ -116,11 +116,13 @@ SanityCheckBigDirHeader ROUT
MOVS r1, lr, LSR #22
ASSERT BigDirMaxSize = 1:SHL:22
SUB r1, lr, #1 ; can be equal to BigDirMaxSize though
MOVS r1, r1, LSR #22
[ DebugX
DLINE "Failed at BigDirSize too large"
DLINE "Failed at BigDirSize too large (or zero)"
......@@ -1439,7 +1441,10 @@ GrowBigDir ROUT
; first of all, ensure have enough memory for dir of required size
SUB R4, R6, R5 ; current dir size
ADD R4, R4, #BigDirMinSize ; add a bit to it
BL TryGrowDirBuf
CMP R4, #BigDirMaxSize ; clear V
MOVHI R0, #DirFullErr
BLVC TryGrowDirBuf
; loop back to here when need to move more files
......@@ -1450,8 +1455,8 @@ GrowBigDir ROUT
SUB R4, R6, R5
ADD R4, R4, #BigDirMinSize ; size required
BL DiscAddToRec ;(R3->LR) get disc record
LDR R7, [LR, #DiscRecord_Log2SectorSize] ; sector size
LDR LR, [LR, #DiscRecord_BigMap_ShareSize] ; share size
LDRB R7, [LR, #DiscRecord_Log2SectorSize] ; sector size
LDRB LR, [LR, #DiscRecord_BigMap_ShareSize] ; share size
ADD R7, R7, LR
MOV R11, #1
RSB R11, R11,R11,LSL R7
......@@ -3552,7 +3552,7 @@ Verify_Code ROUT
MOV r9,r0
BL MapPtrToDiscAdd
SUB r4,r0,r2
LDR lr,[r10,#ZoneHead+DiscRecord_Log2SectorSize]
LDRB lr,[r10,#ZoneHead+DiscRecord_Log2SectorSize]
MOV r4,r4,LSL lr
MOV r0,r9
CMP r4,#1024*1024*1024
......@@ -572,7 +572,7 @@ AllocWork2 # 0
LDR R0, FirstGap+(2*4) ;calc map ptr diff+zone diff*2^24
LDR R1, LastGap+(2*4)
SUB R9, R1, R0
LDR R3, [R10,#ZoneHead+DiscRecord_Log2SectorSize]
LDRB R3, [R10,#ZoneHead+DiscRecord_Log2SectorSize]
ADD R3, R3, #3 ;log2 bits in a zone
MOV R0, R0, LSR R3
MOV R1, R1, LSR R3
......@@ -486,7 +486,7 @@ DoOsFileCreateDir ROUT
BVS %FT99 ; don't yet know how to grow big dirs!
BL BeforeAlterFsMap ; (R3->R0,V)
MOV R10, #NewDirSize ; minimum size of a big dir is NewDirSize
MOV R10, #BigDirMinSize ; minimum size of a big dir
BL ClaimFreeSpace ; (R3,R10->R0,R2,V)
BVS %FT95 ; couldn't claim free space
BL TryCacheDirBuf ; (R3) we'll create dir in the dir buffer
......@@ -632,8 +632,7 @@ SaveCreate ROUT
BL TestBigDir ;test if it's a bigdir
BL IsBigDirFull ;(R1,R3,R5->R0,V)
BVC %FT02 ;dir has space
BL GrowBigDir ;try to grow the directory
BLVS GrowBigDir ;try to grow the directory if no space
B %FT02
BL IsDirFull ;(R3,R5,R6->R0,V)
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