Skip to content

Allow USB floppy drives to be used as floppy disks in a Virtual Machine#6968

Merged
OBattler merged 6 commits into
86Box:masterfrom
tjemg:fdd_media
Mar 26, 2026
Merged

Allow USB floppy drives to be used as floppy disks in a Virtual Machine#6968
OBattler merged 6 commits into
86Box:masterfrom
tjemg:fdd_media

Conversation

@tjemg

@tjemg tjemg commented Mar 23, 2026

Copy link
Copy Markdown
Contributor

Summary

This patch allows to use an USB floppy drive as a device for 86Box.
To enable this feature, manually add a configuration to the 86Box.cfg of the machine, under the section "Floppy and CD-ROM drives" named fdd_XX_host_device, where XX is e.g. 01 for the first floppy drive.
In FreeBSD i can do this
fdd_01_host_device = /dev/da0
and on MacOS I can do this
fdd_01_host_device = /dev/disk4
to enable this feature.

Note - unfortunately, on MacOS, the OS has the tendency to grab the device, therefore, need to first unmount it before attaching to the VM. Also, in case a floppy is physically ejected before being ejected in 86Box, a new device (e.g. /dev/disk5) will be created by MacOS - to overcome this, simply unmount in 86Box, and physically eject the disk, re-insert it, unmount and attach in 86Box.

Short summary of the major changes:
src/config.c: add the parsing for fdd_XX_host_device, and also for the option fdd_host_buffering (which can be set to zero to disable buffering of the floppy - all reads will read, all writes will write to the floppy).

src/floppy/fdd.c: adjustments to load an ioctl:// device (i.e. physical device); in fdd_close i was having a strange bug, which "went away" when the drives are first set to NULL and then the drive is closed

src/floppy/fdd_img.c: img_seek - do not dereference dev before testing for NULL; added functionality to load an image from a raw device

src/qt/qt_mediamenu.cpp: enable the new setting "Use Host Floppy Drive" - this will appear when the fdd_XX_host_drive is configured

src/unix/dummy_floppy_ioctl.c: dummy floppy IOCTL for unsupported host OSes

src/unix/unix_floppy_ioctl.c: implementation of the floppy IOCTLs for FreeBSD and MacOS

Sorry, I have only tested this in FreeBSD and MacOS - therefore, for other platforms (which I currently do not have access to), this feature is not working/implemented. I would guess that for Linux it should not be much work to port it there...

Checklist

References

none

Comment thread src/floppy/fdd.c Fixed
@Dizzy611

Copy link
Copy Markdown
Contributor

Neat PR! Question, and it's alright if the answer is no, but you seem to understand IOCTL on macOS pretty well. Would you be willing to work on raw CDROM IOCTL support for macOS? We currently have it on Windows and Linux but none of us on the team are that familiar with how to deal with IOCTL on macOS.

@tjemg

tjemg commented Mar 24, 2026

Copy link
Copy Markdown
Contributor Author

Neat PR! Question, and it's alright if the answer is no, but you seem to understand IOCTL on macOS pretty well. Would you be willing to work on raw CDROM IOCTL support for macOS? We currently have it on Windows and Linux but none of us on the team are that familiar with how to deal with IOCTL on macOS.

Hi. Sorry, but I am afraid I will not have the time to look into the MacOS IOCTL part for now... :-(

As for the current PR, please do not merge it yet, as it is not yet finished - I am still working on it - it kind of works, but contains dead code / experiments and code that can/should be refactored.

@jriwanek jriwanek marked this pull request as draft March 24, 2026 09:28
@jriwanek

Copy link
Copy Markdown
Member

Converted to draft as you've said it's not quite ready yet, just let us know when you're happy with it's state.

@tjemg

tjemg commented Mar 24, 2026

Copy link
Copy Markdown
Contributor Author

Hi; I just did some code refactoring and also did some optimizations in the code. I think that now I am happy with the current state.
I have tested in MacOS and FreeBSD (as written in the initial PR) - unfortunately, this feature that I implemented is disabled for Linux and Windows.
The CI/CD runners are still running, but I currently do not expect any major issue; the Windows runner(s) is somehow borked... :-( but does not seem to be an issue with the present PR.

(as an aside: I will see if I can find some time, as asked by Dizzy611, to look at IOCTL for CDROM in MacOS; unfortunately cannot promise due to workload at home, my kids at home, and maintenance of FreeBSD ports)

Again, this program is really awesome - I use it for my YT channel, but also to run my own stuff out of nostalgia - thank you for your efforts in putting this together. I am currently planing on getting a video out about installing 386BSD - yeah!

@OBattler OBattler marked this pull request as ready for review March 26, 2026 09:31
@OBattler OBattler merged commit ed92ddd into 86Box:master Mar 26, 2026
36 of 45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants