5 ms·
If you think this is crazy, check out the VVFAT driver in qemu[1]. At first sight it seems simple enough - turn a host directory into a virtual FAT filesystem
by rwmj 7y ago
If you think this is crazy, check out the VVFAT driver in qemu[1]. At first sight it seems simple enough - turn a host directory into a virtual FAT filesystem which is presented to the guest.
The clever/insane thing is it supports writes. It is able to "reverse" those block level operations from the guest to modify the source filesystem on the host.
It was written by the ever exceptional Fabrice Bellard. EDIT: No it wasn't, it was written by Johannes Schindelin, thanks for the clarification in replies.
[1] https://github.com/qemu/qemu/blob/master/block/vvfat.c https://github.com/qemu/qemu/blob/master/block/vvfat.c
- beholder1 7y agoI see another name as author and no trace of Fabrice in history. Can you elaborate please?
- loeg 7y agoQEMU itself came from Bellard originally, but I believe you are correct that the RO and RW vvfat support came from Johannes Schindelin: https://github.com/qemu/qemu/commit/de167e416fa3d6e4bbdcac90973954c6bfae3070 https://github.com/qemu/qemu/commit/de167e416fa3d6e4bbdcac90... https://github.com/qemu/qemu/commit/a046433a161a1f554be55df8421d92cbdc52779f https://github.com/qemu/qemu/commit/a046433a161a1f554be55df8...
- lifthrasiir 7y ago> It was written by the ever exceptional Fabrice Bellard. I think it is rather by Johannes Schindelin [1]. [1] https://github.com/qemu/qemu/commit/de167e416fa3d6e4bbdcac90973954c6bfae3070#diff-90db5d22c672cc11fc524bf481313364 https://github.com/qemu/qemu/commit/de167e416fa3d6e4bbdcac90...
- yellowapple 7y agoOn the other hand, I don't think we've ever seen Fabrice Bellard and Johannes Schindelin in the same room together.
- lifthrasiir 7y agoThat is... compelling, I admit, as Bellard was known for his use of various pseudonyms (e.g. Gérard Lantau for FFmpeg). But I guess Schindelin now works for Microsoft while Bellard still works for Amarisoft [1], right? [1] https://www.amarisoft.com/about-us/ https://www.amarisoft.com/about-us/
- giantrobot 7y agoBut if you rearrange, remove, and then add some letters to Amerisoft it spells MicroSoft. The implication is clear.
- userbinator 7y agoThat seems like the perfect solution to the problem of newer Android devices losing USB mass storage support because the internal data filesystem is no longer FAT32 and they combined the partitions together into a Linux-format one. Unfortunately a quick Google suggests no one has tried to take that file/concept and implement it so the Android device could present a virtual USB drive using that with a directory on the "host", but I guess that just makes it an idea for anyone else who has some time and would like an interesting challenge...
- netsharc 7y agoI can imagine other interesting use cases. fat32 over the network, for example: so you can e.g. plug in a USB device into some legacy hardware, and when it does a directory read, the device lies to the host about what's inside, only retrieving the bytes over the air during a file read operation. I think the hard part is that if the "disk" is mounted, the FAT would be in memory on Windows, so it's very hard to put in a file from "outside", because Windows will probably never re-read the FAT from the disk and will never see that file.
- tomc1985 7y agoWhy can't they keep a fat32 driver around and mount it like they always have?
- userbinator 7y agoThe data partition used to be FAT32 and plugging the Android into USB with the mass storage option would unmount the partition and then the Android emulates a USB mass storage device to expose the block-level contents of the partition to the host computer. Note that this couldn't be done with the system partition, since the Android system itself is running on it; and even if it was unmountable, the filesystem would be a Linux one like ext3 or ext4, making it unreadable to a Windows host. In the newer versions, they combined the two partitions into one with a Linux filesystem, so there would no longer be a separate data partition to unmount from the Android and mount on the host. The idea I'm proposing is to turn VVFAT or an equivalent idea into a kernel module that treats the data directory --- or indeed any --- directory on the Android, including the system one, as the "host" since it has a filesystem-application interface on one side that just uses the normal filesystem calls, and expose the virtual FAT filesystem over USB mass storage on the other side.
- deleted 7y ago[deleted]
- kazinator 7y agoThe insane thing is supporting writes on the host side (are they?) which change the contents of the VFAT right under the guest OS. Writes in the other direction are a lot simpler because the guest is in control of the VFAT state. Come on, any sort of caching scheme will wreak havoc with underhanded updates to the image.
- LeoPanthera 7y agoI've used this feature quite a lot and it's important to understand that it is crazy unstable. The fact that it works at all is impressive, but it does explode quite a lot.
- rwmj 7y agoWe discussed VVFAT at the KVM Forum (2018 IIRC), and as a response I wrote: http://libguestfs.org/nbdkit-floppy-plugin.1.html http://libguestfs.org/nbdkit-floppy-plugin.1.html (It does not support all the crazy write/host filesystem interaction because I'm nowhere near as smart as Johannes Schindelin.)