XAPBob wrote: ↑Fri Mar 06, 2020 8:57 pm
Recently found (here on the forum) that the RasPi4 USB-C port can be used in gadget mode, and is unrelated to the USB A ports.
That means, if I’m not mistaken that I’ll be able to have the pi act as a gadget AND have wired ethernet...
Last time I looked at the requirements on a PiZero for being a “smart usb stick” they all seemed to expose a virtual file system..
Nope. The USB host sees a block device. Software on the host then handles the filesystem level stuff.
If by "virtual file system" you mean the mass storage gadget's ability to use a flat file as its backing store, it isn't using it as a "virtual file system" it's using it as a virtual block device.
Is there an existing mechanism to expose an NFS share (even if only read only)...
Would have a few interesting applications I can think of...
Nope. At least not with NFS. While you can have a 4B running as a mass storage gadget and still have access to the USB A ports and ethernet what you want isn't possible due to the way the usb mass storage gadget works.
The g_mass_storage module (and mass storage via libcomposite) provides the host with block level access to its backing storage and requires the backing storeage be an entire block device, a partition, or a flat file. An NFS export (or smb/cifs share) share is none of those things.
If using the flat file storage option, the file can be located on a network share but you'd need to jump through a few hoops to get stuff on to it.
There is a different approach that gets close to what you want: use a SAN protocol to expose a partition or block device over your network. See my write up here:
https://www.instructables.com/id/NAS-Ac ... d-Devices/
The mass storage gadget works the same way on zero, zeroW A, A+, 3A+ and 4B. It's the same driver module and USB hardware.
Be aware that whichever option you choose for your backing store attempting to write to it from both Pi and USB host at the same time will corrupt your data. Writing to it from one side whist reading on the other will lead to the reading side missing changes.
Attempts to contact me outside of these forums will be ignored unless signed in triplicate, sent in, sent back, queried, lost, found, subjected to public enquiry, lost again, and finally buried in soft peat for three months and recycled as firelighters