From b697c890096805d9ccaf7553dbff5b82f5332609 Mon Sep 17 00:00:00 2001
From: Damien George <damien.p.george@gmail.com>
Date: Sun, 29 Jan 2017 19:20:27 +1100
Subject: [PATCH] extmod: Merge old fsusermount.h header into vfs.h and
 vfs_fat.h.

vfs.h is for generic VFS declarations, and vfs_fat.h is for VfsFat
specific things.
---
 cc3200/ftp/ftp.c        |  2 +-
 cc3200/mods/pybflash.c  |  1 -
 cc3200/mods/pybsd.c     |  2 +-
 cc3200/mptask.c         |  2 +-
 extmod/fsusermount.h    | 62 -----------------------------------------
 extmod/vfs.c            |  5 +++-
 extmod/vfs.h            |  7 +++++
 extmod/vfs_fat.c        |  1 -
 extmod/vfs_fat.h        | 26 ++++++++++++++++-
 extmod/vfs_fat_diskio.c |  2 +-
 extmod/vfs_fat_file.c   |  1 -
 extmod/vfs_fat_misc.c   |  1 -
 stmhal/main.c           |  2 +-
 stmhal/modmachine.c     |  2 +-
 stmhal/sdcard.c         |  1 -
 stmhal/storage.c        |  1 -
 16 files changed, 42 insertions(+), 76 deletions(-)
 delete mode 100644 extmod/fsusermount.h

diff --git a/cc3200/ftp/ftp.c b/cc3200/ftp/ftp.c
index c8a52149c..679c32561 100644
--- a/cc3200/ftp/ftp.c
+++ b/cc3200/ftp/ftp.c
@@ -32,7 +32,7 @@
 #include "py/obj.h"
 #include "lib/oofatfs/ff.h"
 #include "extmod/vfs.h"
-#include "extmod/fsusermount.h"
+#include "extmod/vfs_fat.h"
 #include "inc/hw_types.h"
 #include "inc/hw_ints.h"
 #include "inc/hw_memmap.h"
diff --git a/cc3200/mods/pybflash.c b/cc3200/mods/pybflash.c
index 0779f4a05..f5af79dbf 100644
--- a/cc3200/mods/pybflash.c
+++ b/cc3200/mods/pybflash.c
@@ -31,7 +31,6 @@
 #include "lib/oofatfs/ff.h"
 #include "lib/oofatfs/diskio.h"
 #include "extmod/vfs_fat.h"
-#include "extmod/fsusermount.h"
 
 #include "fatfs/src/drivers/sflash_diskio.h"
 #include "mods/pybflash.h"
diff --git a/cc3200/mods/pybsd.c b/cc3200/mods/pybsd.c
index bac5a270c..937b8599d 100644
--- a/cc3200/mods/pybsd.c
+++ b/cc3200/mods/pybsd.c
@@ -29,7 +29,7 @@
 #include "py/runtime.h"
 #include "lib/oofatfs/ff.h"
 #include "lib/oofatfs/diskio.h"
-#include "extmod/fsusermount.h"
+#include "extmod/vfs_fat.h"
 #include "inc/hw_types.h"
 #include "inc/hw_gpio.h"
 #include "inc/hw_ints.h"
diff --git a/cc3200/mptask.c b/cc3200/mptask.c
index 476561c6d..c7c1832ed 100644
--- a/cc3200/mptask.c
+++ b/cc3200/mptask.c
@@ -36,7 +36,7 @@
 #include "lib/oofatfs/ff.h"
 #include "lib/oofatfs/diskio.h"
 #include "extmod/vfs.h"
-#include "extmod/fsusermount.h"
+#include "extmod/vfs_fat.h"
 #include "inc/hw_memmap.h"
 #include "inc/hw_types.h"
 #include "inc/hw_ints.h"
diff --git a/extmod/fsusermount.h b/extmod/fsusermount.h
deleted file mode 100644
index af6867d23..000000000
--- a/extmod/fsusermount.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * This file is part of the Micro Python project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2014 Damien P. George
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-// these are the values for fs_user_mount_t.flags
-#define FSUSER_NATIVE       (0x0001) // readblocks[2]/writeblocks[2] contain native func
-#define FSUSER_FREE_OBJ     (0x0002) // fs_user_mount_t obj should be freed on umount
-#define FSUSER_HAVE_IOCTL   (0x0004) // new protocol with ioctl
-
-// constants for block protocol ioctl
-#define BP_IOCTL_INIT           (1)
-#define BP_IOCTL_DEINIT         (2)
-#define BP_IOCTL_SYNC           (3)
-#define BP_IOCTL_SEC_COUNT      (4)
-#define BP_IOCTL_SEC_SIZE       (5)
-
-typedef struct _fs_user_mount_t {
-    mp_obj_base_t base;
-    const char *str;
-    uint16_t len; // length of str
-    uint16_t flags;
-    mp_obj_t readblocks[4];
-    mp_obj_t writeblocks[4];
-    // new protocol uses just ioctl, old uses sync (optional) and count
-    union {
-        mp_obj_t ioctl[4];
-        struct {
-            mp_obj_t sync[2];
-            mp_obj_t count[2];
-        } old;
-    } u;
-    FATFS fatfs;
-} fs_user_mount_t;
-
-fs_user_mount_t *fatfs_mount_mkfs(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args, bool mkfs);
-mp_obj_t fatfs_umount(mp_obj_t bdev_or_path_in);
-
-MP_DECLARE_CONST_FUN_OBJ_KW(fsuser_mount_obj);
-MP_DECLARE_CONST_FUN_OBJ_1(fsuser_umount_obj);
-MP_DECLARE_CONST_FUN_OBJ_KW(fsuser_mkfs_obj);
diff --git a/extmod/vfs.c b/extmod/vfs.c
index 97c9077a2..1eb26acf1 100644
--- a/extmod/vfs.c
+++ b/extmod/vfs.c
@@ -31,10 +31,13 @@
 #include "py/objstr.h"
 #include "py/mperrno.h"
 #include "extmod/vfs.h"
-#include "extmod/vfs_fat.h"
 
 #if MICROPY_VFS
 
+#if MICROPY_VFS_FAT
+#include "extmod/vfs_fat.h"
+#endif
+
 // path is the path to lookup and *path_out holds the path within the VFS
 // object (starts with / if an absolute path).
 // Returns MP_VFS_ROOT for root dir (and then path_out is undefined) and
diff --git a/extmod/vfs.h b/extmod/vfs.h
index 92e53b305..4a1c225a0 100644
--- a/extmod/vfs.h
+++ b/extmod/vfs.h
@@ -35,6 +35,13 @@
 #define MP_VFS_NONE ((mp_vfs_mount_t*)1)
 #define MP_VFS_ROOT ((mp_vfs_mount_t*)0)
 
+// constants for block protocol ioctl
+#define BP_IOCTL_INIT           (1)
+#define BP_IOCTL_DEINIT         (2)
+#define BP_IOCTL_SYNC           (3)
+#define BP_IOCTL_SEC_COUNT      (4)
+#define BP_IOCTL_SEC_SIZE       (5)
+
 typedef struct _mp_vfs_mount_t {
     const char *str; // mount point with leading /
     size_t len;
diff --git a/extmod/vfs_fat.c b/extmod/vfs_fat.c
index ecbbdb59a..b32bf7ad9 100644
--- a/extmod/vfs_fat.c
+++ b/extmod/vfs_fat.c
@@ -38,7 +38,6 @@
 #include "py/mperrno.h"
 #include "lib/oofatfs/ff.h"
 #include "extmod/vfs_fat.h"
-#include "extmod/fsusermount.h"
 #include "timeutils.h"
 
 #if _MAX_SS == _MIN_SS
diff --git a/extmod/vfs_fat.h b/extmod/vfs_fat.h
index bc5be0c67..fefae776c 100644
--- a/extmod/vfs_fat.h
+++ b/extmod/vfs_fat.h
@@ -25,8 +25,32 @@
  */
 
 #include "py/lexer.h"
+#include "py/obj.h"
+#include "lib/oofatfs/ff.h"
+#include "extmod/vfs.h"
 
-struct _fs_user_mount_t;
+// these are the values for fs_user_mount_t.flags
+#define FSUSER_NATIVE       (0x0001) // readblocks[2]/writeblocks[2] contain native func
+#define FSUSER_FREE_OBJ     (0x0002) // fs_user_mount_t obj should be freed on umount
+#define FSUSER_HAVE_IOCTL   (0x0004) // new protocol with ioctl
+
+typedef struct _fs_user_mount_t {
+    mp_obj_base_t base;
+    const char *str;
+    uint16_t len; // length of str
+    uint16_t flags;
+    mp_obj_t readblocks[4];
+    mp_obj_t writeblocks[4];
+    // new protocol uses just ioctl, old uses sync (optional) and count
+    union {
+        mp_obj_t ioctl[4];
+        struct {
+            mp_obj_t sync[2];
+            mp_obj_t count[2];
+        } old;
+    } u;
+    FATFS fatfs;
+} fs_user_mount_t;
 
 extern const byte fresult_to_errno_table[20];
 extern const mp_obj_type_t mp_fat_vfs_type;
diff --git a/extmod/vfs_fat_diskio.c b/extmod/vfs_fat_diskio.c
index e12c4597e..7efcc22f2 100644
--- a/extmod/vfs_fat_diskio.c
+++ b/extmod/vfs_fat_diskio.c
@@ -38,7 +38,7 @@
 #include "py/runtime.h"
 #include "lib/oofatfs/ff.h"
 #include "lib/oofatfs/diskio.h"
-#include "extmod/fsusermount.h"
+#include "extmod/vfs_fat.h"
 
 #if _MAX_SS == _MIN_SS
 #define SECSIZE(fs) (_MIN_SS)
diff --git a/extmod/vfs_fat_file.c b/extmod/vfs_fat_file.c
index bb5903575..0f2a7a1aa 100644
--- a/extmod/vfs_fat_file.c
+++ b/extmod/vfs_fat_file.c
@@ -35,7 +35,6 @@
 #include "py/stream.h"
 #include "py/mperrno.h"
 #include "lib/oofatfs/ff.h"
-#include "extmod/fsusermount.h"
 #include "extmod/vfs_fat.h"
 
 #if MICROPY_VFS_FAT
diff --git a/extmod/vfs_fat_misc.c b/extmod/vfs_fat_misc.c
index ba513ef92..97d2675cd 100644
--- a/extmod/vfs_fat_misc.c
+++ b/extmod/vfs_fat_misc.c
@@ -32,7 +32,6 @@
 #include "py/runtime.h"
 #include "lib/oofatfs/ff.h"
 #include "extmod/vfs_fat.h"
-#include "extmod/fsusermount.h"
 #include "py/lexer.h"
 
 // TODO: actually, the core function should be ilistdir()
diff --git a/stmhal/main.c b/stmhal/main.c
index 9eab50061..3a0bd7a6b 100644
--- a/stmhal/main.c
+++ b/stmhal/main.c
@@ -39,7 +39,7 @@
 #include "lib/utils/pyexec.h"
 #include "lib/oofatfs/ff.h"
 #include "extmod/vfs.h"
-#include "extmod/fsusermount.h"
+#include "extmod/vfs_fat.h"
 
 #include "systick.h"
 #include "pendsv.h"
diff --git a/stmhal/modmachine.c b/stmhal/modmachine.c
index aec8e29c5..b10bca819 100644
--- a/stmhal/modmachine.c
+++ b/stmhal/modmachine.c
@@ -37,7 +37,7 @@
 #include "lib/utils/pyexec.h"
 #include "lib/oofatfs/ff.h"
 #include "extmod/vfs.h"
-#include "extmod/fsusermount.h"
+#include "extmod/vfs_fat.h"
 #include "gccollect.h"
 #include "irq.h"
 #include "rng.h"
diff --git a/stmhal/sdcard.c b/stmhal/sdcard.c
index 52ede492b..b1d67f62a 100644
--- a/stmhal/sdcard.c
+++ b/stmhal/sdcard.c
@@ -30,7 +30,6 @@
 #include "py/runtime.h"
 #include "lib/oofatfs/ff.h"
 #include "extmod/vfs_fat.h"
-#include "extmod/fsusermount.h"
 #include "mphalport.h"
 
 #include "sdcard.h"
diff --git a/stmhal/storage.c b/stmhal/storage.c
index 6130d6fb8..c1daad4c2 100644
--- a/stmhal/storage.c
+++ b/stmhal/storage.c
@@ -31,7 +31,6 @@
 #include "py/runtime.h"
 #include "lib/oofatfs/ff.h"
 #include "extmod/vfs_fat.h"
-#include "extmod/fsusermount.h"
 
 #include "systick.h"
 #include "led.h"
-- 
GitLab