1. 23 Jan, 2023 2 commits
    • Jeffrey Lee's avatar
      [480] Make use of fsfile_ReadInfoNoLen · e2242870
      Jeffrey Lee authored
      Update EnsureCanonicalObject so that it can optionally skip reading the
      file/object length, based on the new argument R7. Then trace back
      through the callers to have them pass in an appropriate value based on
      whether they care about the length or not.
      TopPath_DoBusinessToPath has also gained a new flag bit to suppress
      reading the length, but so far I've only updated DoThePath to use it.
      Result: If you have a file in PipeFS which is open for writing, and then
      attempt to open it for reading using OS_Find, it'll now open immediately
      instead of PipeFS trying to block/sleep until it's no longer open for
      Why: Since at least as far back as RISC OS 3.6, PipeFS tries to sleep
      inside fsfile_ReadInfo if the file is open for writing. But a
      combination of buggy sleep logic and TaskWindow's lazy approach to
      UpCall 6 meant that (prior to TaskWindow 0.65) it wouldn't sleep for
      long and would instead allow the open to proceed while the file is still
      open for write. The ab...
    • Jeffrey Lee's avatar
      Use OS_TaskControl 0 to reset the SVC stack · d64fdb08
      Jeffrey Lee authored
      Instead of manually resetting the SVC stack pointer when starting a new
      task, prefer to use the stack reset routine that's exposed by
      OS_TaskControl 0 in RISC OS Select / 5. If that routine isn't available,
      fall back to the old method of doing it manually.
      Requires Kernel-6_61 to build.
  2. 24 Dec, 2022 1 commit
    • Robert Sprowson's avatar
      Fix for NULL pointer dereference with Count/Copy/Wipe ops on duff FS · 5944f979
      Robert Sprowson authored
      Each of the 3 wildcard accepting OS_FSControl options takes its own copies of
      the paths in Util_CommonStart then frees the PassedFilename (and co). This is
      generally OK because the src name is kept in a 'copy block' struct relative
      to R7 (and, for Copy, the dst in a second struct relative to R8).
      However, when needing to get info on objects or other low level operations,
      if the FS is marked in the 'DuffFS' table it would then do a safety check for
      multiple $'s in the PassedFilename and in doing so dereferences a NULL pointer.
      Ref https://www.riscosopen.org/forum/forums/4/topics/17259
      Since the filenames constructed by resolving wildcards for Count/Copy/Wipe are
      all sanitised by Process_WildPathname we can skip the safety check; there will
      only be 1 $ by then.
      FSUtils3.s: Correct misleading comment
      LowLevel.s: Avoid NULL pointer dereference, drop noisy debug on every FS lookup
      Version 2.89. Tagged as 'FileSwitch-2_89'
  3. 08 Sep, 2021 1 commit
    • Ben Avison's avatar
      Cross-compilable · 12fc8643
      Ben Avison authored
      * Makefile: get directory separator and header extension from shared makefiles.
      * Build variable ImageSize (inherited by amu/make from environment) needs
        passing to objasm on command line.
      * Consolidated .gitignore to root.
      * Enable GitLab CI.
      Version 2.88. Not tagged
  4. 30 Jan, 2021 1 commit
  5. 23 Jan, 2021 1 commit
    • Julie Stamp's avatar
      Remove quotes from @Run/LoadType_FFB/FD1 · ec553fef
      Julie Stamp authored
        Quotes in an alias mean
          If "<Alias$@RunType_FD1>" = "" Then ...
        doesn't work. The quotes aren't necessary, because filenames can't have spaces in anyway.
        Tested on Linux and RPCEmu. Boots and fixes above problem.
      Version 2.88. Not tagged
  6. 16 Jan, 2021 1 commit
    • Timothy E Baldwin's avatar
      Add BASICTxt filetype · ee39744a
      Timothy E Baldwin authored
      Programmer's Reference Manual Volume 4 Table C
      defines a filetype for non-tokenised BASIC programs.
      Add support for this to FileSwitch with a Filetype name,
      load and run action.
      Version 2.88. Tagged as 'FileSwitch-2_88'
  7. 12 Oct, 2019 1 commit
  8. 08 Jun, 2018 1 commit
    • Robert Sprowson's avatar
      Fix for missing monitor name after load · 5cf8ee42
      Robert Sprowson authored
      The code path that filing systems the register with dontuseload omitted the line printed when *OPT 1 is non-zero.
      In particular this meant FileCore (which has the fsinfo word flag set) didn't report any monitor name.
      For dontusesave, the initial call to do the equivalent of *Create covers the output even though it's a bit early. However, the flag check appeared to be inverted, so an FS with it set would call OS_File, and one clear would call OS_GBPB.
      FileSwHdr.s: Remove use_fsfile_Save and use_fsfile_Load switches, since clients declare at runtime what their preference is (since RISC OS 3).
      LowLevel.s: Extract monitor name reporting code, replace with function call to common code.
      FSShared.s: Common function ReportMonitor.
      OSFile.s: After doing a load via OS_GBPB call the monitor name reporting code. Tune up the StrongARM code flush code a little to not need R5 as a temporary. Fix inverted sense of dontusesave.
      Version 2.87. Tagged as 'FileSwitch-2_87'
  9. 03 Sep, 2017 1 commit
    • Jeffrey Lee's avatar
      Eliminate global OS_SynchroniseCodeAreas · a16d5301
      Jeffrey Lee authored
        s/FSControl - Change the post-Service_UKCompression call to OS_SynchroniseCodeAreas to be a ranged up rather than a global one.
        Tested on iMx6
        Improves performance with SMP ROMs, where global D-cache clean isn't really possible
      Version 2.86. Tagged as 'FileSwitch-2_86'
  10. 15 Apr, 2017 1 commit
    • ROOL's avatar
      Fix to OS_FSControl 13 when no territory is loaded · 40b6e210
      ROOL authored
        PRM2-97 describes filing system name matching as case insensitive. However, the Internat_LowerCase macro is a no-op when there's no case conversion table, such as prior to the territory loading.
        Change FindFSName to use an case insensitive ASCII match until the territory starts.
        Fixes a problem with EtherUSB failing to start because it was using Devices: (rather than devices:). A global search of the sources shows SerMouse and the Kernel would also be affected.
        Submission from Colin Granville.
      Version 2.85. Tagged as 'FileSwitch-2_85'
  11. 05 Jul, 2016 1 commit
    • Robert Sprowson's avatar
      A few extra fsfunc symbols · 1985952b
      Robert Sprowson authored
      Add fsfunc_Opt subreasons, fsfunc_DirIs subreasons.
      Expand tabs on fsargs_IOCtl.
      No code change, retagged as FileSwitch-2_84.
  12. 08 May, 2016 1 commit
    • Jeffrey Lee's avatar
      Avoid unnecessary remainder calculations · d183fb9c
      Jeffrey Lee authored
        s/CtrlUtils, s/OSGBPB - Avoid unnecessary remainder calculations in DivRem macro
        Tested on Cortex-A15
      Version 2.84. Tagged as 'FileSwitch-2_84'
  13. 16 Jan, 2015 1 commit
    • Jeffrey Lee's avatar
      Escape some dollars · 6c284d47
      Jeffrey Lee authored
        s/CtrlUtils, s/DirStore, s/FSCtrl2, s/FSPath, s/FileSwBody, s/SysVars - Escape some dollars contained in strings to avoid warnings from objasm
        Resulting binary unchanged
      Version 2.83. Retagged as 'FileSwitch-2_83'
  14. 11 Nov, 2014 1 commit
    • Jeffrey Lee's avatar
      Fix buffer overflow in *cat when dealing with long paths. Fix spurious errors... · ccea391b
      Jeffrey Lee authored
      Fix buffer overflow in *cat when dealing with long paths. Fix spurious errors when examining files with certain load addresses
        s/CtrlUtils - Increase MaxFilenameSpace (used to reserve stack space for *cat directory path) from 400 bytes to StaticName_length (i.e. 1K)
        s/FileTypes - Avoid IsFileTyped erroneously returning with V set if r2 is within a certain range (e.g. &7ff00000). Now all exits go via code that ensures V is clear.
        Tested on Raspberry Pi
      Version 2.83. Tagged as 'FileSwitch-2_83'
  15. 11 Mar, 2013 1 commit
    • Robert Sprowson's avatar
      Increase maximum supported buffer size to 4k · 93f3ac2b
      Robert Sprowson authored
      LowFSI: Max_BuffSize define changed.
      FileSwBody: Module workspace claim changed to claim Max_BuffSize in addition to the workspace required, so that all the variables in the workspace remain within ADR range.
      OSFind: Vetting of acceptable buffer sizes now produced with a WHILE/WEND loop.
      StreamBits: Changed to use 'free' flag rather then comparing with 'Nowt'.
      MkClean/MkRom: Throwback enabled.
      Tested in IOMD ROM, workspace manually inspected as OK.
      Version 2.82. Tagged as 'FileSwitch-2_82'
  16. 13 Jan, 2013 1 commit
    • Jeffrey Lee's avatar
      Automatically adjust wimpslot when running AIFs via FSControl 4 · 1c07c7cd
      Jeffrey Lee authored
        s/FSCommon - Adjust ValidateR2R5_WriteToCoreCodeLoad to try and increase the wimpslot if it isn't already big enough to contain the region being validated (i.e. the program being loaded)
        s/FSControl - FSControl 4 now checks AIF memory limts and tries to extend wimpslot as necessary both before and after decompression. An extra 8K is added to the calculated memory requirements to take into account memory which isn't declared in the header (root stack chunk?) which is required by SCL initialisation.
        Tested in Iyonix ROM softload
        This should eliminate most/all of the "No writeable memory at this address", abort on data transfer, and "Not enough memory for C library" errors users receive due to the wimpslot being too small when all they want to do is run a program
      Version 2.81. Tagged as 'FileSwitch-2_81'
  17. 05 Jan, 2013 1 commit
  18. 09 Dec, 2012 1 commit
  19. 02 Dec, 2012 1 commit
    • Robert Sprowson's avatar
      Fix dereference of duff FS control block when resolving badly formed paths · f9d6deff
      Robert Sprowson authored
      In OS_Find there is a call to TopPath_DoBusinessToPath in DoTheOpen, any V set exits from this are propagated to the user correctly.
      Non V set exits (ie. the object type is returned) are passed to DoTheOpen_Common which in turn calls TryToOpenFile. TryToOpenFile (if fscb is not Nowt) dereferences it to get at the info word.
      A problem exists where TopPath_DoBusinessToPath fails the policing check - when multipart paths are permitted (such as OS_Find) it swallows the error, steps the path, and eventually exits with an object type 0. However, this code path never sets up the fscb.
      So when TryToOpenFile dereferences it (in testing it seemed to have some address in the kernel lingering) depending on your luck the fsinfo_alwaysopen bit might be set. This in turn triggers a forced call to the low level FS entry point, and the entry point is some garbage address leading to an abort.
      The minimalist test cases were
      both of which fail the policing step because the incorrect use of the path type bits mean the attempted name becomes MyPath$MyName and you can't have '$' in the middle of a filename. Other more complex examples exist, including having a multipart path where one of the path elements in invalid.
      Solved here by setting fscb up to a default (valid) value.
      Fixes ticket #287.
      Version 2.80. Tagged as 'FileSwitch-2_80'
  20. 19 Nov, 2012 2 commits
    • Robert Sprowson's avatar
      Make internal calls to EnsureFileSize saturate at 0xFFFFFFFF rather than error · 2ebf3e19
      Robert Sprowson authored
      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'
    • Robert Sprowson's avatar
      Tabs expanded in IOCtl OS_Arg · 48bc2294
      Robert Sprowson authored
      Not tagged.
  21. 15 Jul, 2012 1 commit
    • Ben Avison's avatar
      Bugfix to *Copy · 9367a4d8
      Ben Avison authored
        With *Copy A, and the related SWI OS_FSControl 26 with R3 bit 9 clear, if
        a directory was copied over an image file, the contents of the directory
        would be copied (assuming recursive) but then when the attributes were
        copied over, the directory's filetype (usually FFD, Data) and user access
        bits (both 0) were copied to the destination image file, rendering it
        Tested on a Raspberry Pi with the DOS partition in the standard disc image.
      Version 2.78. Tagged as 'FileSwitch-2_78'
  22. 09 Jul, 2012 1 commit
    • Jeffrey Lee's avatar
      Fix a couple of null/bad pointer dereferences · d9c7abb7
      Jeffrey Lee authored
        s/FSControl - faff_boot_option_startup (OS_FSControl 47/48) was acting as if it was given a path variable in r3, but neither of those calls use path variables, leading to aborts in some situations due to random bits of memory being peeked at.
        s/FSUtils - When CopyWildObject performs a single object copy, it wasn't taking into account the fact that the src/dest leafname pointers could be null, potentially causing a crash if high processor vectors are in use.
      Since I'm not 100% sure what the correct course of action is (in the case I saw it crash, both src and dest leafnames were null), and there aren't any bugs I know of with file copies using the wrong names, the code now uses the dest leafname if the dest leafname is null.
      This sounds wrong, but matches the behaviour of the old code, since byte &00000000 is highly unlikely to contain a '*' character
        Tested on BB-xM with high processor vectors
      Version 2.77. Tagged as 'FileSwitch-2_77'
  23. 09 Apr, 2012 1 commit
    • Jeffrey Lee's avatar
      Fix TopPath_DoBusinessToPath leaking memory on error · 1f3b4bd6
      Jeffrey Lee authored
        s/TopPath - Code which attempted to free the cleaned up user's path incorrectly assumed that it could find the string via the stacked R0. However stacked regs R0-R6 get updated with the found objects details, so we need to store a copy of the users R0 elsewhere and free the string via that instead.
        Fixes OS_FSControl 37 (and other operations?) filling the system heap if given paths which will generate errors (e.g. if drive empty/missing)
      Version 2.76. Tagged as 'FileSwitch-2_76'
  24. 18 Mar, 2012 1 commit
  25. 20 Feb, 2012 2 commits
  26. 27 Nov, 2011 4 commits
  27. 22 Oct, 2011 1 commit
  28. 20 Oct, 2011 1 commit
    • Robert Sprowson's avatar
      Fix for *COPY finishing too early with files > 2G · bd64d61d
      Robert Sprowson authored
      Same drill, V was being set or not preserved when it shouldn't or should be. In light of this all locations that do CMP/SUBS/ADDS involving fileptr/extent/anything ending in size or length have been reviewed and ammended where needed.
      Trim some dead code.
      Discard 'Version' file.
      Version 2.70. Tagged as 'FileSwitch-2_70'
  29. 16 Oct, 2011 2 commits
    • Robert Sprowson's avatar
      Put back a debug line, deleted in error. · d815ac29
      Robert Sprowson authored
      Retagged as FileSwitch-2_69.
    • Robert Sprowson's avatar
      Fix OS_Args 1 and OS_GBPB 3/4 for files > 2G. · cce1584b
      Robert Sprowson authored
      In OS_Args 1 a compare was followed by a conditional store, but with files > 2G some circumstances end up with VS so the store wasn't taken.
      In OS_GBPB 3/4 the assessment of how much could be done was based on adding the current fileptr to the request but not respecting the carry out. Reordered the equation to get this calculation right.
      Changed a signed compare of a byte variable to use unsigned so auditing of signed condition codes is clearer.
      Corrected spelling of 'openning'.
      Fix copy_srchandle and copy_dsthandle to not assume handles fit in 1 byte.
      Tested on a variety of contrived file sizes at the boundaries of 2G and 4G.
      Version 2.69. Tagged as 'FileSwitch-2_69'
  30. 04 Aug, 2011 1 commit
    • Jeffrey Lee's avatar
      Update to work with zero page relocation · 0b0a3063
      Jeffrey Lee authored
        s/FileSwBody, s/FileSwHdr - Try getting DomainId pointer via OS_ReadSysInfo 6 before falling back on legacy address. Store result in workspace for speedy lookup.
        s/FSCommon - Use workspace DomainId pointer
        s/CtrlUtils - Update int_ConstructFullPathWithoutFSAndSpecial to not attempt to append the contents of null string pointers.
        s/FSControl - Update AppendStringIfNotNull to ignore null pointers
        s/LowLevel - Update CallFSFile_Given to not try copying from null special field strings
        Tested on rev A2 BB-xM.
        AFAIK the null pointer bugs are all FileSwitch bugs and not bugs in whatever called FileSwitch, although I may be wrong. Not entirely sure how some of the code managed to read strings from null pointers without creating garbage filenames as a result!
      Version 2.68. Tagged as 'FileSwitch-2_68'
  31. 15 Jun, 2009 1 commit
    • Ben Avison's avatar
      Bugfix to OS_File 5 · 389710f2
      Ben Avison authored
        s.LowLevel: STRNE should have been STRNEB. Looks like this meant that
        OS_File 5 was broken if the object name contained a filing system special
        Added ENTRY directive to permit building of GPA debug listing.
        Built but not tested (should be a safe change).
      Version 2.67. Tagged as 'FileSwitch-2_67'
  32. 11 Jun, 2009 1 commit
    • Ben Avison's avatar
      GET file pathnames changed · 5d90bec5
      Ben Avison authored
        Uses suffixed file extensions for compatiblity with both objasm and asasm.
        Supplied by Peter Naulls, tested at ROOL
      Version 2.66. Not tagged
  33. 01 Jul, 2004 1 commit