blob: 443e4eda8228969f9360059db4eb2b8bc2fc252e [file] [log] [blame]
Damien George04b91472014-05-03 23:27:38 +01001/*
Alexander Steffen55f33242017-06-30 09:22:17 +02002 * This file is part of the MicroPython project, http://micropython.org/
Damien George04b91472014-05-03 23:27:38 +01003 *
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 Steffen299bc622017-06-29 23:14:58 +020026#ifndef MICROPY_INCLUDED_EXTMOD_VFS_FAT_H
27#define MICROPY_INCLUDED_EXTMOD_VFS_FAT_H
Damien George04b91472014-05-03 23:27:38 +010028
Damien George6c23c752017-01-27 17:17:54 +110029#include "py/lexer.h"
Damien Georgeb697c892017-01-29 19:20:27 +110030#include "py/obj.h"
31#include "lib/oofatfs/ff.h"
32#include "extmod/vfs.h"
Damien George6c23c752017-01-27 17:17:54 +110033
Damien Georgeb697c892017-01-29 19:20:27 +110034// 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
39typedef struct _fs_user_mount_t {
40 mp_obj_base_t base;
Damien Georgeb697c892017-01-29 19:20:27 +110041 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 Georgef5f4cda2016-06-01 17:00:28 +010054
Sven Wegener0e0ae972014-11-05 21:02:40 +010055extern const byte fresult_to_errno_table[20];
Damien George32a11382017-01-27 15:04:17 +110056extern const mp_obj_type_t mp_fat_vfs_type;
Damien George02bc8822014-07-19 16:39:13 +010057
Damien George6c23c752017-01-27 17:17:54 +110058mp_import_stat_t fat_vfs_import_stat(struct _fs_user_mount_t *vfs, const char *path);
Damien Georgefb3ae172017-01-27 15:13:32 +110059mp_obj_t fatfs_builtin_open_self(mp_obj_t self_in, mp_obj_t path, mp_obj_t mode);
Damien George4ebdb1f2016-10-18 11:06:20 +110060MP_DECLARE_CONST_FUN_OBJ_KW(mp_builtin_open_obj);
Paul Sokolovskycd6d1892016-02-28 17:17:24 +020061
Damien Georged4cd4832017-05-05 23:32:44 +100062mp_obj_t fat_vfs_ilistdir2(struct _fs_user_mount_t *vfs, const char *path, bool is_str_type);
Alexander Steffen299bc622017-06-29 23:14:58 +020063
64#endif // MICROPY_INCLUDED_EXTMOD_VFS_FAT_H