Damien George | 04b9147 | 2014-05-03 23:27:38 +0100 | [diff] [blame] | 1 | /* |
Alexander Steffen | 55f3324 | 2017-06-30 09:22:17 +0200 | [diff] [blame^] | 2 | * This file is part of the MicroPython project, http://micropython.org/ |
Damien George | 04b9147 | 2014-05-03 23:27:38 +0100 | [diff] [blame] | 3 | * |
| 4 | * The MIT License (MIT) |
| 5 | * |
| 6 | * Copyright (c) 2013, 2014 Damien P. George |
| 7 | * |
| 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 9 | * of this software and associated documentation files (the "Software"), to deal |
| 10 | * in the Software without restriction, including without limitation the rights |
| 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 12 | * copies of the Software, and to permit persons to whom the Software is |
| 13 | * furnished to do so, subject to the following conditions: |
| 14 | * |
| 15 | * The above copyright notice and this permission notice shall be included in |
| 16 | * all copies or substantial portions of the Software. |
| 17 | * |
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 24 | * THE SOFTWARE. |
| 25 | */ |
Alexander Steffen | 299bc62 | 2017-06-29 23:14:58 +0200 | [diff] [blame] | 26 | #ifndef MICROPY_INCLUDED_EXTMOD_VFS_FAT_H |
| 27 | #define MICROPY_INCLUDED_EXTMOD_VFS_FAT_H |
Damien George | 04b9147 | 2014-05-03 23:27:38 +0100 | [diff] [blame] | 28 | |
Damien George | 6c23c75 | 2017-01-27 17:17:54 +1100 | [diff] [blame] | 29 | #include "py/lexer.h" |
Damien George | b697c89 | 2017-01-29 19:20:27 +1100 | [diff] [blame] | 30 | #include "py/obj.h" |
| 31 | #include "lib/oofatfs/ff.h" |
| 32 | #include "extmod/vfs.h" |
Damien George | 6c23c75 | 2017-01-27 17:17:54 +1100 | [diff] [blame] | 33 | |
Damien George | b697c89 | 2017-01-29 19:20:27 +1100 | [diff] [blame] | 34 | // these are the values for fs_user_mount_t.flags |
| 35 | #define FSUSER_NATIVE (0x0001) // readblocks[2]/writeblocks[2] contain native func |
| 36 | #define FSUSER_FREE_OBJ (0x0002) // fs_user_mount_t obj should be freed on umount |
| 37 | #define FSUSER_HAVE_IOCTL (0x0004) // new protocol with ioctl |
| 38 | |
| 39 | typedef struct _fs_user_mount_t { |
| 40 | mp_obj_base_t base; |
Damien George | b697c89 | 2017-01-29 19:20:27 +1100 | [diff] [blame] | 41 | uint16_t flags; |
| 42 | mp_obj_t readblocks[4]; |
| 43 | mp_obj_t writeblocks[4]; |
| 44 | // new protocol uses just ioctl, old uses sync (optional) and count |
| 45 | union { |
| 46 | mp_obj_t ioctl[4]; |
| 47 | struct { |
| 48 | mp_obj_t sync[2]; |
| 49 | mp_obj_t count[2]; |
| 50 | } old; |
| 51 | } u; |
| 52 | FATFS fatfs; |
| 53 | } fs_user_mount_t; |
Damien George | f5f4cda | 2016-06-01 17:00:28 +0100 | [diff] [blame] | 54 | |
Sven Wegener | 0e0ae97 | 2014-11-05 21:02:40 +0100 | [diff] [blame] | 55 | extern const byte fresult_to_errno_table[20]; |
Damien George | 32a1138 | 2017-01-27 15:04:17 +1100 | [diff] [blame] | 56 | extern const mp_obj_type_t mp_fat_vfs_type; |
Damien George | 02bc882 | 2014-07-19 16:39:13 +0100 | [diff] [blame] | 57 | |
Damien George | 6c23c75 | 2017-01-27 17:17:54 +1100 | [diff] [blame] | 58 | mp_import_stat_t fat_vfs_import_stat(struct _fs_user_mount_t *vfs, const char *path); |
Damien George | fb3ae17 | 2017-01-27 15:13:32 +1100 | [diff] [blame] | 59 | mp_obj_t fatfs_builtin_open_self(mp_obj_t self_in, mp_obj_t path, mp_obj_t mode); |
Damien George | 4ebdb1f | 2016-10-18 11:06:20 +1100 | [diff] [blame] | 60 | MP_DECLARE_CONST_FUN_OBJ_KW(mp_builtin_open_obj); |
Paul Sokolovsky | cd6d189 | 2016-02-28 17:17:24 +0200 | [diff] [blame] | 61 | |
Damien George | d4cd483 | 2017-05-05 23:32:44 +1000 | [diff] [blame] | 62 | mp_obj_t fat_vfs_ilistdir2(struct _fs_user_mount_t *vfs, const char *path, bool is_str_type); |
Alexander Steffen | 299bc62 | 2017-06-29 23:14:58 +0200 | [diff] [blame] | 63 | |
| 64 | #endif // MICROPY_INCLUDED_EXTMOD_VFS_FAT_H |