Home: https://codeberg.org/Asato/swap42
From README.md:
swap42
a tool for Linux* to map host directories to a raw hdd image file
meant for working with PC Emulators (like PCem, QEMU) to easily
copy files from host to guest or for cross platform development (MSDOS)
Copyright (C) 2021 Asato/Unchained (unchainedgroup.wordpress.com)
Developed on VOID Linux with GCC 10.2.1
GPL3 licensed
swap42
* creates an raw hdd image defined by CHS values (16 MB to 2GB)
* with one primary partition & FAT16 file system for MSDOS
* copies content of a host dir into it
* allows rescaning the host from inside the guest when contents of
host dir changed (special rescan.com for MSDOS 5.0)
* maps the image file to memory to monitor rescan cmd
Notes
* host files and directories are simply skipped when there is not
enough disk space left on image or they are not accessible
* the image file is created or overwritten
* for Windows 98 set disk in hw manager to "removable",
Windows then detects filesystem changes, invoke rescan by HOST with 'R'
* under MSDOS you MUST use rescan.com, don't invoke by HOST!
Tested with
* HOST OS: Linux (Void, Debian), (*) WSL (Windows Subsystem for Linux)
(WSL: the image file is locked, so refreshing from HOST/Guest is not possible)
* Guest OS: MSDOS 5.0, Windows 98
* Emulators: PCem v17, QEMU 5.2, MAME 0.229, Bochs 2.6.11
--------------------------------------------------------------------------------
swap42 was published by Asato/Unchained in 2021 and I already bookmarked it month ago, but it took until yesterday to try.
This is what I tried so far:
I built it on Linux Mint 22 MATE by simply executing gcc -o swap42 swap42.c and fasm rescan.asm. GCC showed some integer size warnings, which can be fixed by applying my naive patch.
For testing I ran ./swap42 dosdata.raw /home/robert/Projekte/DOSBox/drives/c to create and map the image.
Example output:
*** swap42 host to raw image mapper ***
Creating image ...
Mapping image file to memory ...
Writing host directory to image ...
/home/robert/Projekte/DOSBox/drives/c mapped to dosdata.raw
Image properties
Cylinders 820
Heads 6
Sectors 17
Disk size 42823680
Partition size 42814976
Free disk space 42620928
Sectors per FAT 164
Cluster size 1024
VBR offset 0x2200
FAT offset 0x2400
Dir table offset 0x2b400
Data area offset 0x2f400
Waiting for RESCAN command by GUEST (enter 'Q' to quit or 'R' to rescan)
I then mounted the dosdata image in DOSBox 0.74-3 with imgmount d: /home/robert/Projekte/swap42/dosdata.raw -size 512,820,6,17. I was able to read, write, create and delete files inside DOSBox, but timestamps of files and dirs are always 00-00-1980 0:00, even for newly created.
RESCAN.COM didn't work, it just quit with „swap42 drive not found!“ although I changed drive_number from 2 (C:) to 3 (D:) in rescan.asm. Bypassing the check hung DOSBox when executing RESCAN.COM.
Rescanning by pressing R on the swap42 host changed content on D: in DOSBox. (Yes, I know Ctrl+F4 for rescanning the host directory in DOSBox, but that's a different story.)
I successfully used the dosdata image in a VirtualBox machine running MS-DOS 5.0, but I had to convert it to VDI format first: VBoxManage convertfromraw /home/robert/Projekte/swap42/dosdata.raw dosdata.vdi – With this additional step you lose the idea of rescanning. 
Timestamps of files and dirs showed correctly in MS-DOS 5.0. 
Command-line options:
*** swap42 host to raw image mapper ***
Usage: swap42 IMAGEFILENAME HOSTDIRECTORY [Cylinders] [Heads] [Sectors]
(default 42MB ST252 820, 6, 17)
Examples (write to BIOS!)
Model ST1111A 538, 10, 36 (99 MB)
Model ST2274A 536, 16, 55 (241 MB)
Model ST3543A 525, 32, 63 (542 MB)
Model ST31010A 524, 64, 63 (1 GB)
Model ST32110A 1023, 64, 63 (2 GB)
I didn't test swap42 with PCem, QEMU, MAME, or Bochs, because I would have had to set those programs up first. --- Forum admin |