-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
@tannewt Here is a scenario where automount does not seem to do the read/write vs. read-only mounting/locking I would expect. Tested on a PyPortal with 10.0.0-beta.0.
Run this program (I imported it in the REPL)
import board
import os
import random
import sdcardio
import storage
import time
spi = board.SPI()
cs = board.SD_CS
sdcard = sdcardio.SDCard(spi, cs)
vfs = storage.VfsFat(sdcard)
storage.mount(vfs, "/sd")
while True:
filename = f"/sd/{random.randint(0,10000)}"
print("Trying to create", filename)
f = open(filename, "w")
f.close()
print("Created", filename)
print("sleep 10 seconds")
time.sleep(10)
After a few seconds, the SD card automunts in Linux and appears as as drive. I can then create files on the mounted drive in Linux, yet at the same time, the program is still running and also creating files. I didn't manage to corrupt the filesystem, but it could happen.
What is your model of what should happen in this scenario? Should the SD drive appear as read-only to the the host computer?
EDIT: I did a slightly more thorough test on Windows, creating a file while the above was running, and then editing the file and adding some text. The files that the program created during this time got lost -- I'm guess because the FAT directory info was overwritten by what Windows though it was (it probably cached it, since it's not expecting changes from underneath itself).