Skip to content

write-locking problem with USB automount #10510

@dhalbert

Description

@dhalbert

@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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy