Paul Sokolovsky | e9be6a3 | 2016-02-13 22:51:21 +0200 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the MicroPython project, http://micropython.org/ |
| 3 | * |
| 4 | * The MIT License (MIT) |
| 5 | * |
| 6 | * Copyright (c) 2014 Damien P. George |
| 7 | * Copyright (c) 2016 Paul Sokolovsky |
| 8 | * |
| 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 10 | * of this software and associated documentation files (the "Software"), to deal |
| 11 | * in the Software without restriction, including without limitation the rights |
| 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 13 | * copies of the Software, and to permit persons to whom the Software is |
| 14 | * furnished to do so, subject to the following conditions: |
| 15 | * |
| 16 | * The above copyright notice and this permission notice shall be included in |
| 17 | * all copies or substantial portions of the Software. |
| 18 | * |
| 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 25 | * THE SOFTWARE. |
| 26 | */ |
| 27 | |
| 28 | #include "py/mpconfig.h" |
| 29 | #if MICROPY_VFS_FAT |
| 30 | |
Andrew Leech | 4e0964b | 2022-09-09 09:48:01 +1000 | [diff] [blame] | 31 | #if !MICROPY_ENABLE_FINALISER |
| 32 | #error "MICROPY_VFS_FAT requires MICROPY_ENABLE_FINALISER" |
| 33 | #endif |
| 34 | |
Damien George | fb3ae17 | 2017-01-27 15:13:32 +1100 | [diff] [blame] | 35 | #if !MICROPY_VFS |
| 36 | #error "with MICROPY_VFS_FAT enabled, must also enable MICROPY_VFS" |
| 37 | #endif |
| 38 | |
Paul Sokolovsky | cac6c97 | 2016-05-29 18:23:59 +0300 | [diff] [blame] | 39 | #include <string.h> |
Paul Sokolovsky | e9be6a3 | 2016-02-13 22:51:21 +0200 | [diff] [blame] | 40 | #include "py/runtime.h" |
Alex March | d02f3a5 | 2016-09-28 14:51:35 +0100 | [diff] [blame] | 41 | #include "py/mperrno.h" |
Damien George | f5f4cda | 2016-06-01 17:00:28 +0100 | [diff] [blame] | 42 | #include "lib/oofatfs/ff.h" |
Damien George | 32a1138 | 2017-01-27 15:04:17 +1100 | [diff] [blame] | 43 | #include "extmod/vfs_fat.h" |
Damien George | 136369d | 2021-07-09 14:19:15 +1000 | [diff] [blame] | 44 | #include "shared/timeutils/timeutils.h" |
Paul Sokolovsky | e9be6a3 | 2016-02-13 22:51:21 +0200 | [diff] [blame] | 45 | |
Damien George | e959f21 | 2019-02-25 23:46:03 +1100 | [diff] [blame] | 46 | #if FF_MAX_SS == FF_MIN_SS |
| 47 | #define SECSIZE(fs) (FF_MIN_SS) |
Damien George | 8aa8a0a | 2017-01-27 22:42:06 +1100 | [diff] [blame] | 48 | #else |
| 49 | #define SECSIZE(fs) ((fs)->ssize) |
| 50 | #endif |
| 51 | |
Paul Sokolovsky | e9be6a3 | 2016-02-13 22:51:21 +0200 | [diff] [blame] | 52 | #define mp_obj_fat_vfs_t fs_user_mount_t |
| 53 | |
Angus Gratton | decf8e6 | 2024-02-27 15:32:29 +1100 | [diff] [blame] | 54 | static mp_import_stat_t fat_vfs_import_stat(void *vfs_in, const char *path) { |
Damien George | c117eff | 2018-06-06 14:24:23 +1000 | [diff] [blame] | 55 | fs_user_mount_t *vfs = vfs_in; |
Damien George | 638b860 | 2018-02-23 17:24:57 +1100 | [diff] [blame] | 56 | FILINFO fno; |
| 57 | assert(vfs != NULL); |
| 58 | FRESULT res = f_stat(&vfs->fatfs, path, &fno); |
| 59 | if (res == FR_OK) { |
| 60 | if ((fno.fattrib & AM_DIR) != 0) { |
| 61 | return MP_IMPORT_STAT_DIR; |
| 62 | } else { |
| 63 | return MP_IMPORT_STAT_FILE; |
| 64 | } |
| 65 | } |
| 66 | return MP_IMPORT_STAT_NO_EXIST; |
| 67 | } |
| 68 | |
Angus Gratton | decf8e6 | 2024-02-27 15:32:29 +1100 | [diff] [blame] | 69 | static mp_obj_t fat_vfs_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { |
Damien George | fb3ae17 | 2017-01-27 15:13:32 +1100 | [diff] [blame] | 70 | mp_arg_check_num(n_args, n_kw, 1, 1, false); |
| 71 | |
| 72 | // create new object |
Jim Mussared | 0e7bfc8 | 2022-04-22 17:09:15 +1000 | [diff] [blame] | 73 | fs_user_mount_t *vfs = mp_obj_malloc(fs_user_mount_t, type); |
Damien George | fb3ae17 | 2017-01-27 15:13:32 +1100 | [diff] [blame] | 74 | vfs->fatfs.drv = vfs; |
| 75 | |
Damien George | e1c7b1c | 2019-09-08 22:01:09 +1000 | [diff] [blame] | 76 | // Initialise underlying block device |
| 77 | vfs->blockdev.flags = MP_BLOCKDEV_FLAG_FREE_OBJ; |
Damien George | cfe1c5a | 2019-10-29 12:25:30 +1100 | [diff] [blame] | 78 | vfs->blockdev.block_size = FF_MIN_SS; // default, will be populated by call to MP_BLOCKDEV_IOCTL_BLOCK_SIZE |
Damien George | e1c7b1c | 2019-09-08 22:01:09 +1000 | [diff] [blame] | 79 | mp_vfs_blockdev_init(&vfs->blockdev, args[0]); |
Damien George | fb3ae17 | 2017-01-27 15:13:32 +1100 | [diff] [blame] | 80 | |
Damien George | 12ad64b | 2017-11-16 16:01:47 +1100 | [diff] [blame] | 81 | // mount the block device so the VFS methods can be used |
| 82 | FRESULT res = f_mount(&vfs->fatfs); |
| 83 | if (res == FR_NO_FILESYSTEM) { |
| 84 | // don't error out if no filesystem, to let mkfs()/mount() create one if wanted |
Damien George | 9aabb6c | 2019-09-07 14:03:41 +1000 | [diff] [blame] | 85 | vfs->blockdev.flags |= MP_BLOCKDEV_FLAG_NO_FILESYSTEM; |
Damien George | 12ad64b | 2017-11-16 16:01:47 +1100 | [diff] [blame] | 86 | } else if (res != FR_OK) { |
| 87 | mp_raise_OSError(fresult_to_errno_table[res]); |
| 88 | } |
| 89 | |
Paul Sokolovsky | 1bb15ca | 2016-02-14 16:21:27 +0200 | [diff] [blame] | 90 | return MP_OBJ_FROM_PTR(vfs); |
Paul Sokolovsky | e9be6a3 | 2016-02-13 22:51:21 +0200 | [diff] [blame] | 91 | } |
| 92 | |
Damien George | 12ad64b | 2017-11-16 16:01:47 +1100 | [diff] [blame] | 93 | #if _FS_REENTRANT |
Angus Gratton | decf8e6 | 2024-02-27 15:32:29 +1100 | [diff] [blame] | 94 | static mp_obj_t fat_vfs_del(mp_obj_t self_in) { |
Damien George | 12ad64b | 2017-11-16 16:01:47 +1100 | [diff] [blame] | 95 | mp_obj_fat_vfs_t *self = MP_OBJ_TO_PTR(self_in); |
| 96 | // f_umount only needs to be called to release the sync object |
| 97 | f_umount(&self->fatfs); |
| 98 | return mp_const_none; |
| 99 | } |
Angus Gratton | decf8e6 | 2024-02-27 15:32:29 +1100 | [diff] [blame] | 100 | static MP_DEFINE_CONST_FUN_OBJ_1(fat_vfs_del_obj, fat_vfs_del); |
Damien George | 12ad64b | 2017-11-16 16:01:47 +1100 | [diff] [blame] | 101 | #endif |
| 102 | |
Angus Gratton | decf8e6 | 2024-02-27 15:32:29 +1100 | [diff] [blame] | 103 | static mp_obj_t fat_vfs_mkfs(mp_obj_t bdev_in) { |
Damien George | fb3ae17 | 2017-01-27 15:13:32 +1100 | [diff] [blame] | 104 | // create new object |
| 105 | fs_user_mount_t *vfs = MP_OBJ_TO_PTR(fat_vfs_make_new(&mp_fat_vfs_type, 1, 0, &bdev_in)); |
| 106 | |
| 107 | // make the filesystem |
Damien George | e959f21 | 2019-02-25 23:46:03 +1100 | [diff] [blame] | 108 | uint8_t working_buf[FF_MAX_SS]; |
Damien George | fb3ae17 | 2017-01-27 15:13:32 +1100 | [diff] [blame] | 109 | FRESULT res = f_mkfs(&vfs->fatfs, FM_FAT | FM_SFD, 0, working_buf, sizeof(working_buf)); |
Andrew Leech | 74d0746 | 2019-03-25 11:20:54 +1100 | [diff] [blame] | 110 | if (res == FR_MKFS_ABORTED) { // Probably doesn't support FAT16 |
| 111 | res = f_mkfs(&vfs->fatfs, FM_FAT32, 0, working_buf, sizeof(working_buf)); |
| 112 | } |
Damien George | fb3ae17 | 2017-01-27 15:13:32 +1100 | [diff] [blame] | 113 | if (res != FR_OK) { |
| 114 | mp_raise_OSError(fresult_to_errno_table[res]); |
| 115 | } |
| 116 | |
Terence Stenvold | 390390e | 2024-07-19 12:38:44 +0200 | [diff] [blame] | 117 | // set the filesystem label if it's configured |
| 118 | #ifdef MICROPY_HW_FLASH_FS_LABEL |
| 119 | f_setlabel(&vfs->fatfs, MICROPY_HW_FLASH_FS_LABEL); |
| 120 | #endif |
| 121 | |
Paul Sokolovsky | e9be6a3 | 2016-02-13 22:51:21 +0200 | [diff] [blame] | 122 | return mp_const_none; |
| 123 | } |
Angus Gratton | decf8e6 | 2024-02-27 15:32:29 +1100 | [diff] [blame] | 124 | static MP_DEFINE_CONST_FUN_OBJ_1(fat_vfs_mkfs_fun_obj, fat_vfs_mkfs); |
| 125 | static MP_DEFINE_CONST_STATICMETHOD_OBJ(fat_vfs_mkfs_obj, MP_ROM_PTR(&fat_vfs_mkfs_fun_obj)); |
Paul Sokolovsky | e9be6a3 | 2016-02-13 22:51:21 +0200 | [diff] [blame] | 126 | |
Damien George | ae4a077 | 2018-02-23 17:17:32 +1100 | [diff] [blame] | 127 | typedef struct _mp_vfs_fat_ilistdir_it_t { |
| 128 | mp_obj_base_t base; |
| 129 | mp_fun_1_t iternext; |
Andrew Leech | 4e0964b | 2022-09-09 09:48:01 +1000 | [diff] [blame] | 130 | mp_fun_1_t finaliser; |
Damien George | ae4a077 | 2018-02-23 17:17:32 +1100 | [diff] [blame] | 131 | bool is_str; |
| 132 | FF_DIR dir; |
| 133 | } mp_vfs_fat_ilistdir_it_t; |
| 134 | |
Angus Gratton | decf8e6 | 2024-02-27 15:32:29 +1100 | [diff] [blame] | 135 | static mp_obj_t mp_vfs_fat_ilistdir_it_iternext(mp_obj_t self_in) { |
Damien George | ae4a077 | 2018-02-23 17:17:32 +1100 | [diff] [blame] | 136 | mp_vfs_fat_ilistdir_it_t *self = MP_OBJ_TO_PTR(self_in); |
| 137 | |
| 138 | for (;;) { |
| 139 | FILINFO fno; |
| 140 | FRESULT res = f_readdir(&self->dir, &fno); |
| 141 | char *fn = fno.fname; |
| 142 | if (res != FR_OK || fn[0] == 0) { |
| 143 | // stop on error or end of dir |
| 144 | break; |
| 145 | } |
| 146 | |
| 147 | // Note that FatFS already filters . and .., so we don't need to |
| 148 | |
Tom Collins | 4d3a92c | 2018-03-08 16:02:26 -0800 | [diff] [blame] | 149 | // make 4-tuple with info about this entry |
| 150 | mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(4, NULL)); |
Damien George | ae4a077 | 2018-02-23 17:17:32 +1100 | [diff] [blame] | 151 | if (self->is_str) { |
Jon Foster | 92484d8 | 2024-04-01 19:23:49 +0100 | [diff] [blame] | 152 | t->items[0] = mp_obj_new_str_from_cstr(fn); |
Damien George | ae4a077 | 2018-02-23 17:17:32 +1100 | [diff] [blame] | 153 | } else { |
Damien George | 69661f3 | 2020-02-27 15:36:53 +1100 | [diff] [blame] | 154 | t->items[0] = mp_obj_new_bytes((const byte *)fn, strlen(fn)); |
Damien George | ae4a077 | 2018-02-23 17:17:32 +1100 | [diff] [blame] | 155 | } |
| 156 | if (fno.fattrib & AM_DIR) { |
| 157 | // dir |
| 158 | t->items[1] = MP_OBJ_NEW_SMALL_INT(MP_S_IFDIR); |
| 159 | } else { |
| 160 | // file |
| 161 | t->items[1] = MP_OBJ_NEW_SMALL_INT(MP_S_IFREG); |
| 162 | } |
| 163 | t->items[2] = MP_OBJ_NEW_SMALL_INT(0); // no inode number |
Tom Collins | 4d3a92c | 2018-03-08 16:02:26 -0800 | [diff] [blame] | 164 | t->items[3] = mp_obj_new_int_from_uint(fno.fsize); |
Damien George | ae4a077 | 2018-02-23 17:17:32 +1100 | [diff] [blame] | 165 | |
| 166 | return MP_OBJ_FROM_PTR(t); |
| 167 | } |
| 168 | |
| 169 | // ignore error because we may be closing a second time |
| 170 | f_closedir(&self->dir); |
| 171 | |
| 172 | return MP_OBJ_STOP_ITERATION; |
| 173 | } |
| 174 | |
Angus Gratton | decf8e6 | 2024-02-27 15:32:29 +1100 | [diff] [blame] | 175 | static mp_obj_t mp_vfs_fat_ilistdir_it_del(mp_obj_t self_in) { |
Andrew Leech | 4e0964b | 2022-09-09 09:48:01 +1000 | [diff] [blame] | 176 | mp_vfs_fat_ilistdir_it_t *self = MP_OBJ_TO_PTR(self_in); |
| 177 | // ignore result / error because we may be closing a second time. |
| 178 | f_closedir(&self->dir); |
| 179 | return mp_const_none; |
| 180 | } |
| 181 | |
Angus Gratton | decf8e6 | 2024-02-27 15:32:29 +1100 | [diff] [blame] | 182 | static mp_obj_t fat_vfs_ilistdir_func(size_t n_args, const mp_obj_t *args) { |
Damien George | f5f4cda | 2016-06-01 17:00:28 +0100 | [diff] [blame] | 183 | mp_obj_fat_vfs_t *self = MP_OBJ_TO_PTR(args[0]); |
Paul Sokolovsky | cd6d189 | 2016-02-28 17:17:24 +0200 | [diff] [blame] | 184 | bool is_str_type = true; |
| 185 | const char *path; |
| 186 | if (n_args == 2) { |
| 187 | if (mp_obj_get_type(args[1]) == &mp_type_bytes) { |
| 188 | is_str_type = false; |
| 189 | } |
| 190 | path = mp_obj_str_get_str(args[1]); |
| 191 | } else { |
| 192 | path = ""; |
| 193 | } |
| 194 | |
Damien George | ae4a077 | 2018-02-23 17:17:32 +1100 | [diff] [blame] | 195 | // Create a new iterator object to list the dir |
Damien George | cae690d | 2024-02-16 11:02:58 +1100 | [diff] [blame] | 196 | mp_vfs_fat_ilistdir_it_t *iter = mp_obj_malloc_with_finaliser(mp_vfs_fat_ilistdir_it_t, &mp_type_polymorph_iter_with_finaliser); |
Damien George | ae4a077 | 2018-02-23 17:17:32 +1100 | [diff] [blame] | 197 | iter->iternext = mp_vfs_fat_ilistdir_it_iternext; |
Andrew Leech | 4e0964b | 2022-09-09 09:48:01 +1000 | [diff] [blame] | 198 | iter->finaliser = mp_vfs_fat_ilistdir_it_del; |
Damien George | ae4a077 | 2018-02-23 17:17:32 +1100 | [diff] [blame] | 199 | iter->is_str = is_str_type; |
| 200 | FRESULT res = f_opendir(&self->fatfs, &iter->dir, path); |
| 201 | if (res != FR_OK) { |
| 202 | mp_raise_OSError(fresult_to_errno_table[res]); |
| 203 | } |
| 204 | |
| 205 | return MP_OBJ_FROM_PTR(iter); |
Paul Sokolovsky | cd6d189 | 2016-02-28 17:17:24 +0200 | [diff] [blame] | 206 | } |
Angus Gratton | decf8e6 | 2024-02-27 15:32:29 +1100 | [diff] [blame] | 207 | static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(fat_vfs_ilistdir_obj, 1, 2, fat_vfs_ilistdir_func); |
Paul Sokolovsky | cd6d189 | 2016-02-28 17:17:24 +0200 | [diff] [blame] | 208 | |
Angus Gratton | decf8e6 | 2024-02-27 15:32:29 +1100 | [diff] [blame] | 209 | static mp_obj_t fat_vfs_remove_internal(mp_obj_t vfs_in, mp_obj_t path_in, mp_int_t attr) { |
Damien George | f5f4cda | 2016-06-01 17:00:28 +0100 | [diff] [blame] | 210 | mp_obj_fat_vfs_t *self = MP_OBJ_TO_PTR(vfs_in); |
Paul Sokolovsky | 19749db | 2016-02-28 20:30:07 +0200 | [diff] [blame] | 211 | const char *path = mp_obj_str_get_str(path_in); |
Alex March | d02f3a5 | 2016-09-28 14:51:35 +0100 | [diff] [blame] | 212 | |
| 213 | FILINFO fno; |
Damien George | f5f4cda | 2016-06-01 17:00:28 +0100 | [diff] [blame] | 214 | FRESULT res = f_stat(&self->fatfs, path, &fno); |
Alex March | d02f3a5 | 2016-09-28 14:51:35 +0100 | [diff] [blame] | 215 | |
| 216 | if (res != FR_OK) { |
Damien George | 620c4c3 | 2016-10-07 13:44:55 +1100 | [diff] [blame] | 217 | mp_raise_OSError(fresult_to_errno_table[res]); |
Paul Sokolovsky | 19749db | 2016-02-28 20:30:07 +0200 | [diff] [blame] | 218 | } |
Alex March | d02f3a5 | 2016-09-28 14:51:35 +0100 | [diff] [blame] | 219 | |
| 220 | // check if path is a file or directory |
| 221 | if ((fno.fattrib & AM_DIR) == attr) { |
Damien George | f5f4cda | 2016-06-01 17:00:28 +0100 | [diff] [blame] | 222 | res = f_unlink(&self->fatfs, path); |
Alex March | d02f3a5 | 2016-09-28 14:51:35 +0100 | [diff] [blame] | 223 | |
| 224 | if (res != FR_OK) { |
| 225 | mp_raise_OSError(fresult_to_errno_table[res]); |
| 226 | } |
| 227 | return mp_const_none; |
| 228 | } else { |
| 229 | mp_raise_OSError(attr ? MP_ENOTDIR : MP_EISDIR); |
| 230 | } |
| 231 | } |
| 232 | |
Angus Gratton | decf8e6 | 2024-02-27 15:32:29 +1100 | [diff] [blame] | 233 | static mp_obj_t fat_vfs_remove(mp_obj_t vfs_in, mp_obj_t path_in) { |
Damien George | f5f4cda | 2016-06-01 17:00:28 +0100 | [diff] [blame] | 234 | return fat_vfs_remove_internal(vfs_in, path_in, 0); // 0 == file attribute |
Paul Sokolovsky | 19749db | 2016-02-28 20:30:07 +0200 | [diff] [blame] | 235 | } |
Angus Gratton | decf8e6 | 2024-02-27 15:32:29 +1100 | [diff] [blame] | 236 | static MP_DEFINE_CONST_FUN_OBJ_2(fat_vfs_remove_obj, fat_vfs_remove); |
Paul Sokolovsky | 19749db | 2016-02-28 20:30:07 +0200 | [diff] [blame] | 237 | |
Angus Gratton | decf8e6 | 2024-02-27 15:32:29 +1100 | [diff] [blame] | 238 | static mp_obj_t fat_vfs_rmdir(mp_obj_t vfs_in, mp_obj_t path_in) { |
Damien George | f5f4cda | 2016-06-01 17:00:28 +0100 | [diff] [blame] | 239 | return fat_vfs_remove_internal(vfs_in, path_in, AM_DIR); |
Paul Sokolovsky | 0a6f599 | 2016-07-16 03:46:42 +0300 | [diff] [blame] | 240 | } |
Angus Gratton | decf8e6 | 2024-02-27 15:32:29 +1100 | [diff] [blame] | 241 | static MP_DEFINE_CONST_FUN_OBJ_2(fat_vfs_rmdir_obj, fat_vfs_rmdir); |
Paul Sokolovsky | 0a6f599 | 2016-07-16 03:46:42 +0300 | [diff] [blame] | 242 | |
Angus Gratton | decf8e6 | 2024-02-27 15:32:29 +1100 | [diff] [blame] | 243 | static mp_obj_t fat_vfs_rename(mp_obj_t vfs_in, mp_obj_t path_in, mp_obj_t path_out) { |
Damien George | f5f4cda | 2016-06-01 17:00:28 +0100 | [diff] [blame] | 244 | mp_obj_fat_vfs_t *self = MP_OBJ_TO_PTR(vfs_in); |
Paul Sokolovsky | e082183 | 2016-02-29 01:22:38 +0200 | [diff] [blame] | 245 | const char *old_path = mp_obj_str_get_str(path_in); |
| 246 | const char *new_path = mp_obj_str_get_str(path_out); |
Damien George | f5f4cda | 2016-06-01 17:00:28 +0100 | [diff] [blame] | 247 | FRESULT res = f_rename(&self->fatfs, old_path, new_path); |
Damien George | b7df3e5 | 2016-12-02 15:06:09 +1100 | [diff] [blame] | 248 | if (res == FR_EXIST) { |
| 249 | // if new_path exists then try removing it (but only if it's a file) |
Damien George | f5f4cda | 2016-06-01 17:00:28 +0100 | [diff] [blame] | 250 | fat_vfs_remove_internal(vfs_in, path_out, 0); // 0 == file attribute |
Damien George | b7df3e5 | 2016-12-02 15:06:09 +1100 | [diff] [blame] | 251 | // try to rename again |
Damien George | f5f4cda | 2016-06-01 17:00:28 +0100 | [diff] [blame] | 252 | res = f_rename(&self->fatfs, old_path, new_path); |
Damien George | b7df3e5 | 2016-12-02 15:06:09 +1100 | [diff] [blame] | 253 | } |
Robert HH | 7c004e7 | 2016-05-27 22:28:00 +0200 | [diff] [blame] | 254 | if (res == FR_OK) { |
| 255 | return mp_const_none; |
| 256 | } else { |
Damien George | 620c4c3 | 2016-10-07 13:44:55 +1100 | [diff] [blame] | 257 | mp_raise_OSError(fresult_to_errno_table[res]); |
Paul Sokolovsky | e082183 | 2016-02-29 01:22:38 +0200 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | } |
Angus Gratton | decf8e6 | 2024-02-27 15:32:29 +1100 | [diff] [blame] | 261 | static MP_DEFINE_CONST_FUN_OBJ_3(fat_vfs_rename_obj, fat_vfs_rename); |
Paul Sokolovsky | e082183 | 2016-02-29 01:22:38 +0200 | [diff] [blame] | 262 | |
Angus Gratton | decf8e6 | 2024-02-27 15:32:29 +1100 | [diff] [blame] | 263 | static mp_obj_t fat_vfs_mkdir(mp_obj_t vfs_in, mp_obj_t path_o) { |
Damien George | f5f4cda | 2016-06-01 17:00:28 +0100 | [diff] [blame] | 264 | mp_obj_fat_vfs_t *self = MP_OBJ_TO_PTR(vfs_in); |
Paul Sokolovsky | bbe832a | 2016-02-29 00:02:50 +0200 | [diff] [blame] | 265 | const char *path = mp_obj_str_get_str(path_o); |
Damien George | f5f4cda | 2016-06-01 17:00:28 +0100 | [diff] [blame] | 266 | FRESULT res = f_mkdir(&self->fatfs, path); |
Robert HH | 7c004e7 | 2016-05-27 22:28:00 +0200 | [diff] [blame] | 267 | if (res == FR_OK) { |
| 268 | return mp_const_none; |
| 269 | } else { |
Damien George | 620c4c3 | 2016-10-07 13:44:55 +1100 | [diff] [blame] | 270 | mp_raise_OSError(fresult_to_errno_table[res]); |
Paul Sokolovsky | bbe832a | 2016-02-29 00:02:50 +0200 | [diff] [blame] | 271 | } |
| 272 | } |
Angus Gratton | decf8e6 | 2024-02-27 15:32:29 +1100 | [diff] [blame] | 273 | static MP_DEFINE_CONST_FUN_OBJ_2(fat_vfs_mkdir_obj, fat_vfs_mkdir); |
Paul Sokolovsky | bbe832a | 2016-02-29 00:02:50 +0200 | [diff] [blame] | 274 | |
Damien George | 4791d29 | 2021-05-06 12:11:51 +1000 | [diff] [blame] | 275 | // Change current directory. |
Angus Gratton | decf8e6 | 2024-02-27 15:32:29 +1100 | [diff] [blame] | 276 | static mp_obj_t fat_vfs_chdir(mp_obj_t vfs_in, mp_obj_t path_in) { |
Damien George | f5f4cda | 2016-06-01 17:00:28 +0100 | [diff] [blame] | 277 | mp_obj_fat_vfs_t *self = MP_OBJ_TO_PTR(vfs_in); |
Paul Sokolovsky | f12146c | 2016-05-29 18:17:00 +0300 | [diff] [blame] | 278 | const char *path; |
| 279 | path = mp_obj_str_get_str(path_in); |
| 280 | |
Damien George | f5f4cda | 2016-06-01 17:00:28 +0100 | [diff] [blame] | 281 | FRESULT res = f_chdir(&self->fatfs, path); |
Paul Sokolovsky | f12146c | 2016-05-29 18:17:00 +0300 | [diff] [blame] | 282 | |
| 283 | if (res != FR_OK) { |
Damien George | 620c4c3 | 2016-10-07 13:44:55 +1100 | [diff] [blame] | 284 | mp_raise_OSError(fresult_to_errno_table[res]); |
Paul Sokolovsky | f12146c | 2016-05-29 18:17:00 +0300 | [diff] [blame] | 285 | } |
| 286 | |
| 287 | return mp_const_none; |
| 288 | } |
Angus Gratton | decf8e6 | 2024-02-27 15:32:29 +1100 | [diff] [blame] | 289 | static MP_DEFINE_CONST_FUN_OBJ_2(fat_vfs_chdir_obj, fat_vfs_chdir); |
Paul Sokolovsky | f12146c | 2016-05-29 18:17:00 +0300 | [diff] [blame] | 290 | |
Damien George | 4791d29 | 2021-05-06 12:11:51 +1000 | [diff] [blame] | 291 | // Get the current directory. |
Angus Gratton | decf8e6 | 2024-02-27 15:32:29 +1100 | [diff] [blame] | 292 | static mp_obj_t fat_vfs_getcwd(mp_obj_t vfs_in) { |
Damien George | f5f4cda | 2016-06-01 17:00:28 +0100 | [diff] [blame] | 293 | mp_obj_fat_vfs_t *self = MP_OBJ_TO_PTR(vfs_in); |
Paul Sokolovsky | cac6c97 | 2016-05-29 18:23:59 +0300 | [diff] [blame] | 294 | char buf[MICROPY_ALLOC_PATH_MAX + 1]; |
Damien George | fb3ae17 | 2017-01-27 15:13:32 +1100 | [diff] [blame] | 295 | FRESULT res = f_getcwd(&self->fatfs, buf, sizeof(buf)); |
Paul Sokolovsky | cac6c97 | 2016-05-29 18:23:59 +0300 | [diff] [blame] | 296 | if (res != FR_OK) { |
Damien George | 620c4c3 | 2016-10-07 13:44:55 +1100 | [diff] [blame] | 297 | mp_raise_OSError(fresult_to_errno_table[res]); |
Paul Sokolovsky | cac6c97 | 2016-05-29 18:23:59 +0300 | [diff] [blame] | 298 | } |
Jon Foster | 92484d8 | 2024-04-01 19:23:49 +0100 | [diff] [blame] | 299 | return mp_obj_new_str_from_cstr(buf); |
Paul Sokolovsky | cac6c97 | 2016-05-29 18:23:59 +0300 | [diff] [blame] | 300 | } |
Angus Gratton | decf8e6 | 2024-02-27 15:32:29 +1100 | [diff] [blame] | 301 | static MP_DEFINE_CONST_FUN_OBJ_1(fat_vfs_getcwd_obj, fat_vfs_getcwd); |
Paul Sokolovsky | cac6c97 | 2016-05-29 18:23:59 +0300 | [diff] [blame] | 302 | |
Damien George | 4791d29 | 2021-05-06 12:11:51 +1000 | [diff] [blame] | 303 | // Get the status of a file or directory. |
Angus Gratton | decf8e6 | 2024-02-27 15:32:29 +1100 | [diff] [blame] | 304 | static mp_obj_t fat_vfs_stat(mp_obj_t vfs_in, mp_obj_t path_in) { |
Damien George | f5f4cda | 2016-06-01 17:00:28 +0100 | [diff] [blame] | 305 | mp_obj_fat_vfs_t *self = MP_OBJ_TO_PTR(vfs_in); |
Robert HH | ee009d7 | 2016-05-30 21:09:20 +0200 | [diff] [blame] | 306 | const char *path = mp_obj_str_get_str(path_in); |
| 307 | |
| 308 | FILINFO fno; |
Damien George | fb3ae17 | 2017-01-27 15:13:32 +1100 | [diff] [blame] | 309 | if (path[0] == 0 || (path[0] == '/' && path[1] == 0)) { |
Robert HH | ee009d7 | 2016-05-30 21:09:20 +0200 | [diff] [blame] | 310 | // stat root directory |
| 311 | fno.fsize = 0; |
Robert HH | 23067a1 | 2016-06-16 18:17:59 +0200 | [diff] [blame] | 312 | fno.fdate = 0x2821; // Jan 1, 2000 |
Robert HH | ee009d7 | 2016-05-30 21:09:20 +0200 | [diff] [blame] | 313 | fno.ftime = 0; |
| 314 | fno.fattrib = AM_DIR; |
| 315 | } else { |
Damien George | fb3ae17 | 2017-01-27 15:13:32 +1100 | [diff] [blame] | 316 | FRESULT res = f_stat(&self->fatfs, path, &fno); |
Robert HH | ee009d7 | 2016-05-30 21:09:20 +0200 | [diff] [blame] | 317 | if (res != FR_OK) { |
Damien George | 620c4c3 | 2016-10-07 13:44:55 +1100 | [diff] [blame] | 318 | mp_raise_OSError(fresult_to_errno_table[res]); |
Robert HH | ee009d7 | 2016-05-30 21:09:20 +0200 | [diff] [blame] | 319 | } |
| 320 | } |
| 321 | |
| 322 | mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(10, NULL)); |
| 323 | mp_int_t mode = 0; |
| 324 | if (fno.fattrib & AM_DIR) { |
Damien George | d70f688 | 2017-05-10 12:30:34 +1000 | [diff] [blame] | 325 | mode |= MP_S_IFDIR; |
Robert HH | ee009d7 | 2016-05-30 21:09:20 +0200 | [diff] [blame] | 326 | } else { |
Damien George | d70f688 | 2017-05-10 12:30:34 +1000 | [diff] [blame] | 327 | mode |= MP_S_IFREG; |
Robert HH | ee009d7 | 2016-05-30 21:09:20 +0200 | [diff] [blame] | 328 | } |
Yoctopuce dev | df05cae | 2025-07-01 13:16:20 +0200 | [diff] [blame] | 329 | mp_timestamp_t seconds = timeutils_seconds_since_epoch( |
Robert HH | ee009d7 | 2016-05-30 21:09:20 +0200 | [diff] [blame] | 330 | 1980 + ((fno.fdate >> 9) & 0x7f), |
| 331 | (fno.fdate >> 5) & 0x0f, |
| 332 | fno.fdate & 0x1f, |
| 333 | (fno.ftime >> 11) & 0x1f, |
| 334 | (fno.ftime >> 5) & 0x3f, |
| 335 | 2 * (fno.ftime & 0x1f) |
Damien George | 69661f3 | 2020-02-27 15:36:53 +1100 | [diff] [blame] | 336 | ); |
Robert HH | ee009d7 | 2016-05-30 21:09:20 +0200 | [diff] [blame] | 337 | t->items[0] = MP_OBJ_NEW_SMALL_INT(mode); // st_mode |
| 338 | t->items[1] = MP_OBJ_NEW_SMALL_INT(0); // st_ino |
| 339 | t->items[2] = MP_OBJ_NEW_SMALL_INT(0); // st_dev |
| 340 | t->items[3] = MP_OBJ_NEW_SMALL_INT(0); // st_nlink |
| 341 | t->items[4] = MP_OBJ_NEW_SMALL_INT(0); // st_uid |
| 342 | t->items[5] = MP_OBJ_NEW_SMALL_INT(0); // st_gid |
Damien George | 4c736ea | 2017-08-21 20:47:22 +1000 | [diff] [blame] | 343 | t->items[6] = mp_obj_new_int_from_uint(fno.fsize); // st_size |
Yoctopuce dev | df05cae | 2025-07-01 13:16:20 +0200 | [diff] [blame] | 344 | t->items[7] = timeutils_obj_from_timestamp(seconds); // st_atime |
| 345 | t->items[8] = timeutils_obj_from_timestamp(seconds); // st_mtime |
| 346 | t->items[9] = timeutils_obj_from_timestamp(seconds); // st_ctime |
Robert HH | ee009d7 | 2016-05-30 21:09:20 +0200 | [diff] [blame] | 347 | |
| 348 | return MP_OBJ_FROM_PTR(t); |
| 349 | } |
Angus Gratton | decf8e6 | 2024-02-27 15:32:29 +1100 | [diff] [blame] | 350 | static MP_DEFINE_CONST_FUN_OBJ_2(fat_vfs_stat_obj, fat_vfs_stat); |
Robert HH | ee009d7 | 2016-05-30 21:09:20 +0200 | [diff] [blame] | 351 | |
Alex March | dcf14c1 | 2016-09-12 18:13:44 +0100 | [diff] [blame] | 352 | // Get the status of a VFS. |
Angus Gratton | decf8e6 | 2024-02-27 15:32:29 +1100 | [diff] [blame] | 353 | static mp_obj_t fat_vfs_statvfs(mp_obj_t vfs_in, mp_obj_t path_in) { |
Damien George | f5f4cda | 2016-06-01 17:00:28 +0100 | [diff] [blame] | 354 | mp_obj_fat_vfs_t *self = MP_OBJ_TO_PTR(vfs_in); |
| 355 | (void)path_in; |
Alex March | dcf14c1 | 2016-09-12 18:13:44 +0100 | [diff] [blame] | 356 | |
Alex March | dcf14c1 | 2016-09-12 18:13:44 +0100 | [diff] [blame] | 357 | DWORD nclst; |
Damien George | f5f4cda | 2016-06-01 17:00:28 +0100 | [diff] [blame] | 358 | FATFS *fatfs = &self->fatfs; |
| 359 | FRESULT res = f_getfree(fatfs, &nclst); |
Alex March | dcf14c1 | 2016-09-12 18:13:44 +0100 | [diff] [blame] | 360 | if (FR_OK != res) { |
Damien George | 620c4c3 | 2016-10-07 13:44:55 +1100 | [diff] [blame] | 361 | mp_raise_OSError(fresult_to_errno_table[res]); |
Alex March | dcf14c1 | 2016-09-12 18:13:44 +0100 | [diff] [blame] | 362 | } |
| 363 | |
| 364 | mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(10, NULL)); |
| 365 | |
Damien George | 8aa8a0a | 2017-01-27 22:42:06 +1100 | [diff] [blame] | 366 | t->items[0] = MP_OBJ_NEW_SMALL_INT(fatfs->csize * SECSIZE(fatfs)); // f_bsize |
Alex March | dcf14c1 | 2016-09-12 18:13:44 +0100 | [diff] [blame] | 367 | t->items[1] = t->items[0]; // f_frsize |
Damien George | f781618 | 2017-03-29 12:53:35 +1100 | [diff] [blame] | 368 | t->items[2] = MP_OBJ_NEW_SMALL_INT((fatfs->n_fatent - 2)); // f_blocks |
Alex March | dcf14c1 | 2016-09-12 18:13:44 +0100 | [diff] [blame] | 369 | t->items[3] = MP_OBJ_NEW_SMALL_INT(nclst); // f_bfree |
| 370 | t->items[4] = t->items[3]; // f_bavail |
| 371 | t->items[5] = MP_OBJ_NEW_SMALL_INT(0); // f_files |
| 372 | t->items[6] = MP_OBJ_NEW_SMALL_INT(0); // f_ffree |
| 373 | t->items[7] = MP_OBJ_NEW_SMALL_INT(0); // f_favail |
| 374 | t->items[8] = MP_OBJ_NEW_SMALL_INT(0); // f_flags |
Damien George | e959f21 | 2019-02-25 23:46:03 +1100 | [diff] [blame] | 375 | t->items[9] = MP_OBJ_NEW_SMALL_INT(FF_MAX_LFN); // f_namemax |
Alex March | dcf14c1 | 2016-09-12 18:13:44 +0100 | [diff] [blame] | 376 | |
| 377 | return MP_OBJ_FROM_PTR(t); |
| 378 | } |
Angus Gratton | decf8e6 | 2024-02-27 15:32:29 +1100 | [diff] [blame] | 379 | static MP_DEFINE_CONST_FUN_OBJ_2(fat_vfs_statvfs_obj, fat_vfs_statvfs); |
Alex March | dcf14c1 | 2016-09-12 18:13:44 +0100 | [diff] [blame] | 380 | |
Angus Gratton | decf8e6 | 2024-02-27 15:32:29 +1100 | [diff] [blame] | 381 | static mp_obj_t vfs_fat_mount(mp_obj_t self_in, mp_obj_t readonly, mp_obj_t mkfs) { |
Damien George | fb3ae17 | 2017-01-27 15:13:32 +1100 | [diff] [blame] | 382 | fs_user_mount_t *self = MP_OBJ_TO_PTR(self_in); |
| 383 | |
| 384 | // Read-only device indicated by writeblocks[0] == MP_OBJ_NULL. |
| 385 | // User can specify read-only device by: |
| 386 | // 1. readonly=True keyword argument |
| 387 | // 2. nonexistent writeblocks method (then writeblocks[0] == MP_OBJ_NULL already) |
| 388 | if (mp_obj_is_true(readonly)) { |
Damien George | 9aabb6c | 2019-09-07 14:03:41 +1000 | [diff] [blame] | 389 | self->blockdev.writeblocks[0] = MP_OBJ_NULL; |
Damien George | fb3ae17 | 2017-01-27 15:13:32 +1100 | [diff] [blame] | 390 | } |
| 391 | |
Damien George | fb3ae17 | 2017-01-27 15:13:32 +1100 | [diff] [blame] | 392 | // check if we need to make the filesystem |
Damien George | 9aabb6c | 2019-09-07 14:03:41 +1000 | [diff] [blame] | 393 | FRESULT res = (self->blockdev.flags & MP_BLOCKDEV_FLAG_NO_FILESYSTEM) ? FR_NO_FILESYSTEM : FR_OK; |
Damien George | fb3ae17 | 2017-01-27 15:13:32 +1100 | [diff] [blame] | 394 | if (res == FR_NO_FILESYSTEM && mp_obj_is_true(mkfs)) { |
Damien George | e959f21 | 2019-02-25 23:46:03 +1100 | [diff] [blame] | 395 | uint8_t working_buf[FF_MAX_SS]; |
Damien George | fb3ae17 | 2017-01-27 15:13:32 +1100 | [diff] [blame] | 396 | res = f_mkfs(&self->fatfs, FM_FAT | FM_SFD, 0, working_buf, sizeof(working_buf)); |
| 397 | } |
| 398 | if (res != FR_OK) { |
| 399 | mp_raise_OSError(fresult_to_errno_table[res]); |
| 400 | } |
Damien George | 9aabb6c | 2019-09-07 14:03:41 +1000 | [diff] [blame] | 401 | self->blockdev.flags &= ~MP_BLOCKDEV_FLAG_NO_FILESYSTEM; |
Damien George | fb3ae17 | 2017-01-27 15:13:32 +1100 | [diff] [blame] | 402 | |
Radomir Dopieralski | d29ca28 | 2016-08-22 16:10:34 +0200 | [diff] [blame] | 403 | return mp_const_none; |
| 404 | } |
Angus Gratton | decf8e6 | 2024-02-27 15:32:29 +1100 | [diff] [blame] | 405 | static MP_DEFINE_CONST_FUN_OBJ_3(vfs_fat_mount_obj, vfs_fat_mount); |
Damien George | fb3ae17 | 2017-01-27 15:13:32 +1100 | [diff] [blame] | 406 | |
Angus Gratton | decf8e6 | 2024-02-27 15:32:29 +1100 | [diff] [blame] | 407 | static mp_obj_t vfs_fat_umount(mp_obj_t self_in) { |
Damien George | 12ad64b | 2017-11-16 16:01:47 +1100 | [diff] [blame] | 408 | (void)self_in; |
| 409 | // keep the FAT filesystem mounted internally so the VFS methods can still be used |
Damien George | fb3ae17 | 2017-01-27 15:13:32 +1100 | [diff] [blame] | 410 | return mp_const_none; |
| 411 | } |
Angus Gratton | decf8e6 | 2024-02-27 15:32:29 +1100 | [diff] [blame] | 412 | static MP_DEFINE_CONST_FUN_OBJ_1(fat_vfs_umount_obj, vfs_fat_umount); |
Radomir Dopieralski | d29ca28 | 2016-08-22 16:10:34 +0200 | [diff] [blame] | 413 | |
Angus Gratton | decf8e6 | 2024-02-27 15:32:29 +1100 | [diff] [blame] | 414 | static const mp_rom_map_elem_t fat_vfs_locals_dict_table[] = { |
Damien George | 12ad64b | 2017-11-16 16:01:47 +1100 | [diff] [blame] | 415 | #if _FS_REENTRANT |
| 416 | { MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&fat_vfs_del_obj) }, |
| 417 | #endif |
Paul Sokolovsky | e9be6a3 | 2016-02-13 22:51:21 +0200 | [diff] [blame] | 418 | { MP_ROM_QSTR(MP_QSTR_mkfs), MP_ROM_PTR(&fat_vfs_mkfs_obj) }, |
| 419 | { MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&fat_vfs_open_obj) }, |
Damien George | d4cd483 | 2017-05-05 23:32:44 +1000 | [diff] [blame] | 420 | { MP_ROM_QSTR(MP_QSTR_ilistdir), MP_ROM_PTR(&fat_vfs_ilistdir_obj) }, |
Paul Sokolovsky | bbe832a | 2016-02-29 00:02:50 +0200 | [diff] [blame] | 421 | { MP_ROM_QSTR(MP_QSTR_mkdir), MP_ROM_PTR(&fat_vfs_mkdir_obj) }, |
Paul Sokolovsky | 0a6f599 | 2016-07-16 03:46:42 +0300 | [diff] [blame] | 422 | { MP_ROM_QSTR(MP_QSTR_rmdir), MP_ROM_PTR(&fat_vfs_rmdir_obj) }, |
Paul Sokolovsky | f12146c | 2016-05-29 18:17:00 +0300 | [diff] [blame] | 423 | { MP_ROM_QSTR(MP_QSTR_chdir), MP_ROM_PTR(&fat_vfs_chdir_obj) }, |
Paul Sokolovsky | cac6c97 | 2016-05-29 18:23:59 +0300 | [diff] [blame] | 424 | { MP_ROM_QSTR(MP_QSTR_getcwd), MP_ROM_PTR(&fat_vfs_getcwd_obj) }, |
Paul Sokolovsky | 19749db | 2016-02-28 20:30:07 +0200 | [diff] [blame] | 425 | { MP_ROM_QSTR(MP_QSTR_remove), MP_ROM_PTR(&fat_vfs_remove_obj) }, |
Paul Sokolovsky | e082183 | 2016-02-29 01:22:38 +0200 | [diff] [blame] | 426 | { MP_ROM_QSTR(MP_QSTR_rename), MP_ROM_PTR(&fat_vfs_rename_obj) }, |
Robert HH | ee009d7 | 2016-05-30 21:09:20 +0200 | [diff] [blame] | 427 | { MP_ROM_QSTR(MP_QSTR_stat), MP_ROM_PTR(&fat_vfs_stat_obj) }, |
Alex March | dcf14c1 | 2016-09-12 18:13:44 +0100 | [diff] [blame] | 428 | { MP_ROM_QSTR(MP_QSTR_statvfs), MP_ROM_PTR(&fat_vfs_statvfs_obj) }, |
Damien George | fb3ae17 | 2017-01-27 15:13:32 +1100 | [diff] [blame] | 429 | { MP_ROM_QSTR(MP_QSTR_mount), MP_ROM_PTR(&vfs_fat_mount_obj) }, |
Radomir Dopieralski | d29ca28 | 2016-08-22 16:10:34 +0200 | [diff] [blame] | 430 | { MP_ROM_QSTR(MP_QSTR_umount), MP_ROM_PTR(&fat_vfs_umount_obj) }, |
Paul Sokolovsky | e9be6a3 | 2016-02-13 22:51:21 +0200 | [diff] [blame] | 431 | }; |
Angus Gratton | decf8e6 | 2024-02-27 15:32:29 +1100 | [diff] [blame] | 432 | static MP_DEFINE_CONST_DICT(fat_vfs_locals_dict, fat_vfs_locals_dict_table); |
Paul Sokolovsky | e9be6a3 | 2016-02-13 22:51:21 +0200 | [diff] [blame] | 433 | |
Angus Gratton | decf8e6 | 2024-02-27 15:32:29 +1100 | [diff] [blame] | 434 | static const mp_vfs_proto_t fat_vfs_proto = { |
Damien George | c117eff | 2018-06-06 14:24:23 +1000 | [diff] [blame] | 435 | .import_stat = fat_vfs_import_stat, |
| 436 | }; |
| 437 | |
Jim Mussared | 662b976 | 2021-07-14 14:38:38 +1000 | [diff] [blame] | 438 | MP_DEFINE_CONST_OBJ_TYPE( |
| 439 | mp_fat_vfs_type, |
| 440 | MP_QSTR_VfsFat, |
| 441 | MP_TYPE_FLAG_NONE, |
Jim Mussared | 94beeab | 2022-09-17 00:31:23 +1000 | [diff] [blame] | 442 | make_new, fat_vfs_make_new, |
Jim Mussared | 662b976 | 2021-07-14 14:38:38 +1000 | [diff] [blame] | 443 | protocol, &fat_vfs_proto, |
Jim Mussared | 9dce827 | 2022-06-24 16:27:46 +1000 | [diff] [blame] | 444 | locals_dict, &fat_vfs_locals_dict |
Jim Mussared | 662b976 | 2021-07-14 14:38:38 +1000 | [diff] [blame] | 445 | ); |
Paul Sokolovsky | e9be6a3 | 2016-02-13 22:51:21 +0200 | [diff] [blame] | 446 | |
| 447 | #endif // MICROPY_VFS_FAT |