diff options
| author | Dan Halbert <halbert@halwitz.org> | 2019-02-21 17:15:50 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-02-21 17:15:50 -0500 |
| commit | d218069f03451e74e049b337830cbd1be7a25d8e (patch) | |
| tree | 12ea8d89c81889671baba36cd3668c0ca2536023 /extmod | |
| parent | 3e877e0f6a05083980d5829e8fcc948a14642d58 (diff) | |
| parent | ed1ace09e971b24bc9ff88defe2e128064780824 (diff) | |
Merge pull request #1584 from tannewt/disable_concurrent_write_protection
Add option to disable the concurrent write protection
Diffstat (limited to 'extmod')
| -rw-r--r-- | extmod/vfs_fat.h | 2 | ||||
| -rw-r--r-- | extmod/vfs_fat_file.c | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/extmod/vfs_fat.h b/extmod/vfs_fat.h index dd5e5ffcb..08b03d0d1 100644 --- a/extmod/vfs_fat.h +++ b/extmod/vfs_fat.h @@ -38,6 +38,8 @@ #define FSUSER_NO_FILESYSTEM (0x0008) // the block device has no filesystem on it // Device is writable over USB and read-only to MicroPython. #define FSUSER_USB_WRITABLE (0x0010) +// Bit set when the above flag is checked before opening a file for write. +#define FSUSER_CONCURRENT_WRITE_PROTECTED (0x0020) typedef struct _fs_user_mount_t { mp_obj_base_t base; diff --git a/extmod/vfs_fat_file.c b/extmod/vfs_fat_file.c index 690073ce4..6aad1884c 100644 --- a/extmod/vfs_fat_file.c +++ b/extmod/vfs_fat_file.c @@ -34,6 +34,7 @@ #include "py/mperrno.h" #include "lib/oofatfs/ff.h" #include "extmod/vfs_fat.h" +#include "supervisor/filesystem.h" // this table converts from FRESULT to POSIX errno const byte fresult_to_errno_table[20] = { @@ -187,7 +188,7 @@ STATIC mp_obj_t file_open(fs_user_mount_t *vfs, const mp_obj_type_t *type, mp_ar } } assert(vfs != NULL); - if ((vfs->flags & FSUSER_USB_WRITABLE) != 0 && (mode & FA_WRITE) != 0) { + if ((mode & FA_WRITE) != 0 && !filesystem_is_writable_by_python(vfs)) { mp_raise_OSError(MP_EROFS); } |
