Repository navigation
Conversation
dos64.library shares them with dos.library.
The linklib stubs of a function returning QUAD or UQUAD paste the return type into the call macro name. Map those names to the plain macros, which return d0/d1.
FileInfoBlock is a single structure; fib_Size64, fib_NumBlocks64 and fib_ActExtFlags overlay fib_Reserved at the MorphOS V51 offsets, 64 bit members are 2 byte aligned on 32 bit targets. FileInfoBlock32 and FileInfoBlock64 stay as names of it. ExAllData gets ed_Size64 and ED_SIZE64, RecordLock64 the MorphOS layout, InfoData64 is the standard InfoData followed by 64 bit block counts.
dos64.library has the 64 bit calls: Seek64(), SetFileSize64(), GetFilePosition64(), GetFileSize64(), ChangeFilePosition64(), ChangeFileSize64(), Read64() and Write64(), Examine64(), ExNext64(), ExamineFH64() and ExamineName64(), Info64(), the record locking calls and AllocDosObject64(). It is version 51.0 and takes the 64 bit arguments with AROS_LHAQUAD. The examine calls send ACTION_EXAMINE_OBJECT64, _NEXT64 and _FH64 on all systems. A handler that does not know them gets the 32 bit calls, and for a file of 2 GiB or more ACTION_GET_FILE_SIZE64 is asked for the size: with DupLock and OpenFromLock in Examine64(), by name in the directory in ExNext64(). A file that cannot be opened keeps the clamped size. ExamineName64() reads the entry from the parent directory when a file open for writing cannot be locked, so the size of a file being written is available.
* dos: MatchFirst()/MatchNext() with a zero current directory
A process whose current directory is the zero lock (the root of the
boot volume) is legal, but MatchNext() took DupLock() of it returning
zero as a failure and returned IoErr(), which is 0 when nothing has
failed: MatchFirst() on a wildcard in a missing directory then reported
success with no match, and every MatchNext() after it did the same.
Directory Opus 5 loops forever on that while scanning dopus5:groups/.
Only a non-zero current directory that cannot be duplicated is an
error. Checked with MatchFirst("RAM:x/nodir/#?.info") after
CurrentDir(NULL): ERROR_OBJECT_NOT_FOUND, as with a current directory.
* dos: ExNext() on a zero lock
A zero lock stands for the root of the boot volume. Examine() already
sends its packet to GetFileSysTask() for it, but ExNext() dereferenced
the lock unconditionally, so MatchFirst("#?") after CurrentDir(NULL),
whose base AChain keeps an_Lock 0, page-faulted on fl->fl_Task.
ExNext() now falls back to GetFileSysTask() the same way. Checked with
MatchFirst("#?") after CurrentDir(NULL): it returns 0, MatchNext()
walks the boot volume root and ends with ERROR_NO_MORE_ENTRIES.
FRead() always went through the handle buffer, so a large read cost one ACTION_READ packet per buffer: 100 packets for 100 KiB with the 1 KiB m68k-amiga buffer. FWrite() copied every byte into the buffer and flushed it in pieces the same way. Once the buffer is empty, a read at least one buffer long now goes straight into the caller's memory with a single Read(). A fully buffered write of at least one buffer flushes what is pending and is sent with a single Write(); line-buffered handles keep flushing at each newline, and append-mode handles still seek to the end first.
Seed the read buffer with the last successful direct-read byte so both UnGetC forms continue to work, and allocate it before consuming input. Clamp individual Read requests to the signed LONG limit. Retry short direct writes, stop on zero progress, and batch FWrite blocks with overflow-safe signed-length chunks so byte-block calls use the fast path. Keep append, pending-output and line-buffer behavior. Expand DOS regression tests for direct-read pushback, mixed-read seek positions and pending buffered append writes. Add sanitized host tests for oversized requests, partial/error writes, replaced buffers and packet batching. Update copyright years and dos.library revision to 50.82.
Seek returns the old position, which is negative as a LONG above 2G. FWrite and Flush after a read took that for a failure.
It goes into the ext bank (E0) after dos.library.
fopen, fseek, ftell, fseeko, ftello, lseek, ftruncate, read, write, stat, statfs and getfsstat go through helpers that use dos64.library when it is installed and the 32 bit calls otherwise. A value that does not fit fails with EOVERFLOW. File systems that answer the 64 bit packets are probed once per file. stat64 and fstat64 return the whole st_size, stat and fstat fail with EOVERFLOW for a file above 2G.
A size that fills 32 bits is asked again with ExamineName64 when dos64.library is installed, also for a file that is open for writing, which cannot be locked. The size is no longer sign extended, and the total of blocks is printed as 32 bits.
ASL, reqtools, MUI Dirlist, find, the Wanderer icon list, status bar, copy and the Info tool read the 32 bit size as unsigned and keep sizes and totals in 64 bits. A file whose 32 bit size is 4G-1 is asked again with ExamineName64 when dos64.library is installed, also when it is open for writing. Sorting by size is unsigned and the volume percentage of the reqtools requester no longer overflows.
…ge about the failure, and return 0. The compiler most likely optimized this away (0/0)
copyright sign unified to (C) $Id$ removed Lang: removed
copyright sign unfied to (C) $Id$ removed
Add bounds check to prevent writing past the end of the buffer when parsing path components. Without this, a long filename component can overflow the stack buffer.
record_bitmap fetched every bitmap block through the cache only to overwrite its entire content, then wrote each back individually - a read and a write per block across the whole bitmap area, the dominant cost of validating a large volume. The validator already holds the complete new bitmap in memory, so build the blocks with their checksums in a batch buffer and write runs of consecutive blocks directly. Bitmap data blocks are never cached during validation, so bypassing the cache is safe; the cache path remains as an allocation-failure fallback.
ULONG, LONG and uint32_t are all int-sized on every AROS architecture, so the %ld/%lu/%lx used throughout the debug output warned under -Wformat. Two format strings had a bare %l with no conversion character at all. Pointers were printed with 0x%08X, which truncated them to 32 bits on 64-bit targets - use 0x%p.
afs_security.[ch] (guarded by __AROS__): per-packet owner/umask resolution; R/W/X/D checks on FINDINPUT/OUTPUT/UPDATE, LOCATE_OBJECT, CREATE_DIR, DELETE, RENAME; property access (owner or root) on SET_PROTECT/COMMENT/DATE; ACTION_SET_OWNER (root only) and ACTION_IS_SECFS; new objects get the creator's owner and default protection. The root block has no owner words: system-owned, listable by all, writable by root. OpenLibrary() is retried per packet because boot-time mount packets precede the RTF_AFTERDOS init.
The kickstart mmakefiles each tested AROS_TARGET_CPU to force -Os, which applies to any m68k target rather than the amiga-m68k ROM that actually has the 512KB bank limit - and only exec, dos, Shell and shellcommands did it at all. configure now sets rom_optimization_level in the amiga m68k case only and substitutes it as ROM_OPTIMIZATION_CFLAGS, left empty everywhere else. Every mmakefile building a kickstart module uses it instead of testing the CPU; those under arch/m68k-amiga assign it directly, as they only ever build for that target. -D__DOS_NOLIBINLINE__ stays CPU-scoped, being a genuine per-CPU choice.
Every block went through the cache one 512-byte DoIO at a time, with a 20-block cache and no read-ahead, so booting from FFS on NVMe cost 34x the I/O round trips of FAT for the same data. Read consecutive data blocks of a file in one request, read ahead into free cache buffers on a miss, and size the cache from available memory (the DosEnvec value stays the floor, and the only value on m68k). Also stop a failed read leaving its block looking cached.
Every partition inherited the root DosEnvec's de_NumBuffers of 20, a floppy-era value that left afs, SFS and pfs3 with a few KB of cache on machines with gigabytes free. Default to one buffer per MiB of free memory, 20..1024, in an arch-overridable partition_platform.c; amiga-m68k keeps 20. Mount uses the same rule when a mountlist gives no BUFFERS. afs no longer scales the value itself.
Handles used to be created against a NULL volumenode whenever the DosList was contended at mount, and were then orphaned when the retry finally added a node - crashing remHandle on close. Follow the fat-handler pattern instead: make (or reconnect, by name and creation date via a handler-private offline list) the DosList node synchronously at medium init so every handle references its final node, and defer only the AddDosEntry publish, retried from the flush timer.
…; use partition.library's buffer default openfile() kept using the directory's cache entry after deleteObject() had recycled it, so createNewEntry() linked the new file into whatever block occupied the entry (typically the deleted file's own header). Re-fetch the directory by block number, as is already done for the file block. Only showed with a small, fully dirty cache. Partition now takes de_NumBuffers from the root partition handle, i.e. partition.library's platform default, instead of hardcoding 100.
Multi-block reads and writes were issued at whatever size the caller asked for, ignoring the device's limit. Read de_MaxTransfer at mount time and split each transfer into chunks no larger than it, keeping the Retry/Cancel requester per chunk.
initVolume() tests de_TableSize against DE_MAXTRANSFER, but off-target os.h substitutes os_unix_support.h, which declares its own copy of struct DosEnvec without the accompanying index constants, so libafs.a no longer compiled. The struct has the same fields in the same order as dos/filehandler.h, so mirror the whole index table next to it.
readAheadSlot() recycled any clean populated buffer for speculative sibling block read-ahead. Callers hold no BCF_USED across getBlock() calls, so a directory block a caller was walking could be silently repurposed as file data mid-walk; the corrupt hash pointer then raised an out-of-range getBlock() requester in the middle of a copy. Read-ahead now only uses genuinely free buffers (blocknum == 0). Verified: A full ~1 GB Copy of the Live CD to a hard disk partition: the requester appeared reproducibly before and the copy completes cleanly after. Tested on: x86_64-pc (64-bit little-endian), clang/LLVM 20 toolchain family, KVM guest. Not tested: 32-bit, big-endian and other targets (no access here).
getDirBlockBuffer() copied the last path component into the callers' 34-byte buffers and the directory part into a 256-byte buffer without a length check, so a name longer than 33 characters overwrote the handler's stack. The hash of a directory entry copied a length byte read from disk into a 34-byte buffer the same way. Names longer than MAX_NAME_LENGTH - 1 now fail with ERROR_INVALID_COMPONENT_NAME, and the on-disk length is bounded.
renameObject() marked the source header's cache block in use, then returned ERROR_OBJECT_EXISTS when the target name existed without clearing BCF_USED, as every other exit does. The source then read back empty.
FFS wrote its cache only one second after the last activity, from its flush timer, and answered ACTION_FLUSH with ERROR_ACTION_NOT_KNOWN, so a caller could not make its writes durable without inhibiting the volume. ACTION_FLUSH now writes the dirty blocks and the root, sends CMD_UPDATE to the device, and reports a failed device commit instead of DOSTRUE. It answers ERROR_NO_DISK while the volume is inhibited or absent.
Generate a shared registration loop for filesystem-only handler lists while preserving entry order, optional fields, named segments and allocation-failure behavior. Share AFS requester formatting wrappers instead of emitting copies per source file. Keep serial diagnostics and filesystem safety checks enabled, and add grouped host and native regression tests.
Keep inline wrappers as the generic default and select the shared implementation through the Amiga target make.opts. Reuse one implementation body for both forms and bump the handler revision to 41.13. Build and run both requester variants under the AFS normal and quick test groups. The inline-only test fails to link before the change; both implementations preserve formatted arguments, requester type and return values afterward. Shared m68k wrapper text remains byte-for-byte unchanged.
* afs: start invalidBitmap()'s bitmap window at relative block 0 On a volume with more than one bitmap block (more than 4066 blocks with 512-byte blocks and 2 reserved blocks), blocks 4066 and 4067 were looked up in bitmap block 0, as the bits of blocks 2 and 3. Marking or freeing them changed the wrong bits, and a free-block scan crossing from bitmap block 0 into bitmap block 1 judged blocks 4066 onwards by bitmap block 0's bits. Blocks already in use were handed out again, so the first write to such a volume could cross-link an existing file at block 4066; on larger volumes the same misreading ended in a false "disk full" with up to half the volume unused. gotoBitmapBlock() keeps bstartblock relative to the first bitmapped block: it subtracts bootblocks from the block before testing the window and sets bstartblock = bblock * maxinbitmap on a reload. invalidBitmap(), which runs at the start of every write, create and delete packet, set it to bootblocks instead, leaving bitmap block 0 cached with the window 2..4065 rather than 0..4063. Relative blocks 4064/4065 then fell inside the window and no reload happened (nor the "Wrong bitmapblockjump" check). Set it to 0. Verified on m68k by patching the compiled instruction in the AROS ROM builds of 2025-02-19 and 2026-08-20 (git 959b90997d and 3ffc074471), run under vAmiga: every one of 19 test cases that corrupted with the stock ROMs (4 MB and 2040 KB volumes, DOS\0 and DOS\1, delete-then- write, growth and fill-to-full) came out clean, and volumes fill to their last block. Volumes with a single bitmap block are unaffected either way. A full AROS build with this source change was not run. * afs: validator range checks use bootblocks, not bstartblock bstartblock is the bitmap-window start, kept relative to the first bitmapped block (block number minus bootblocks). check_block_range() and bm_mark_block() in the validator used it as the lowest valid absolute block number. That only held while invalidBitmap() set it to bootblocks. With bstartblock now 0 after invalidBitmap(), a corrupt header or extension block referencing block 0 or 1 would pass bm_mark_block()'s check, wrap to 0xFFFFFFFE/0xFFFFFFFF after "block -= bootblocks", and index ds->bitmap far outside its allocation. And if the window had moved to a later bitmap block before validation started (bstartblock == 4064 for bitmap block 1 with 512-byte blocks), every legitimate reference below it was reported as outside the volume. Compare against bootblocks in both, and add bootblocks back (not bstartblock) in bm_mark_block()'s duplicate-allocation debug output. State the relative meaning on the field definition in volumes.h.
…(#1775) countUsedBlocks() sweeps the bitmap area through a 64 KB read-ahead window. On a floppy the bitmap is a single block, so every mount read 128 blocks starting at the bitmap block: six extra cylinders, several seconds per disk insertion, with the old OFS game disks that boot from floppy. Cap the window at the number of bitmap (and extension) blocks the volume actually has. Floppies fall back to the single-block path; hard disks with many bitmap blocks keep the batched read. Measured on amiga-m68k (Amiberry 8.3, DD floppy, OFS): booting a disk with a tiny startup-sequence now reads the same blocks as Kickstart 1.3, and the time to finish loading a 300 KB executable drops by about 7 s, to within 1-2 s of Kickstart 1.3. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Block fields and date stamps are accessed through helpers. The packet dispatch is merged. The bitmap counting and file block freeing code is shared. Unreachable functions are removed.
The check walked the parents of the destination directory but never looked at that directory, so "Rename d0 d0/x" unlinked d0 and hashed it into itself.
pulchart
force-pushed
the
wip/jpu/dos64
branch
from
November 24, 2026 06:58
7c639ad to
1d57281
Compare
…#2390) * afs: clear dn_Task when ACTION_DIE is accepted and reply to it once The handler left dn_Task pointing at its port after it exited, so the DeviceNode looked served by a process that no longer existed. DOS starts a handler again only while dn_Task is NULL, so the next packet to the device went to a freed port and never came back, and a caller that removes the node once dn_Task clears never saw the handler go. ACTION_DIE was also replied twice, in the packet loop and again after it. The second PutMsg queued the same message on the handler's own port, breaking the sender's message list when it had not fetched the reply yet. Packets queued behind ACTION_DIE kept running on the freed volume. Clear dn_Task before replying, leave the loop right after the reply, and answer packets still queued with ERROR_DEVICE_NOT_MOUNTED under Forbid() before exiting. The process locks are unlocked before that, since DosEntry() would otherwise unlock them after the return and its packet round trip ends the Forbid(). Refuse ACTION_DIE while a volume taken offline still has locks: they are parked in its volume node, not in volume->locklist, and name this handler's port. * afs: release the process locks at startup UnLock() waits for its reply on pr_MsgPort, which is also where clients send their packets. Released after ACTION_DIE, a packet from a client that read dn_Task before it was cleared could be taken as that reply. The current and program directory locks are now released before the volume node makes the port known, and the exit path makes no DOS calls. afs also no longer keeps the directory of the process that mounted it locked while it runs. * afs: count parked volume nodes for ACTION_DIE remDosVolume() parks the locks of a removed volume also when the OfflineNode allocation fails, so an empty offlinevols list did not mean that no lock names this handler, and ACTION_DIE was accepted with live locks. A counter of parked nodes now decides. It drops when the last parked lock is freed or the node is reconnected. * afs: free the timer port AFS_free() never deleted timer_mp, so every handler that exits on ACTION_DIE left a message port behind. AFS_alloc() also leaked the port and the handler memory whenever it failed. * afs: take the flush timer reply off its port The timer request came back to timer_mp and stayed there, and startFlushTimer() sent it again while it was still linked in the port's message list. onFlushTimer() now removes the reply first and ignores a timer signal that has none.
The muFS support taken from AROS uses the newer security.library API: secIsConfigured(), secFS_API_VERSION, ACTION_IS_SECFS and ACTION_GET_SECFS_VERSION. The ApolloOS security.library and its headers predate it. AFS_SECURITY in the mmakefile selects the support and is 0 here, so afs uses the stubs afs_security.h already has for builds outside AROS, and the two actions are not known to the handler.
ApolloOS left countUsedBlocks() out of newMedium() in ApolloTeam-dev#132, so a mount does not read the whole bitmap. Keep it that way with the afs sources from AROS; the counted flag that only guarded the count goes too.
pulchart
force-pushed
the
wip/jpu/dos64
branch
from
November 26, 2026 07:28
f86a0db to
fbc38be
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Brings 4 GiB+ file support from AROS to ApolloOS, with fixes
dos64.libraryTested with a pfs3aio build with large file support. Without
dos64.librarythe 32-bit behaviour stays.the AROS afs history since 2020:
ACTION_FLUSH,DE_MAXTRANSFER,OpenFromLock()no longer returns NULL on success. Used blocks are still not counted at mount. muFS permissions stay off until ApolloOS has the newer security.library.dn_Taskwhen it acceptsACTION_DIEand replies to it once (afs: clear dn_Task when ACTION_DIE is accepted and reply to it once aros-development-team/AROS#2390).