Skip to content
Snippets Groups Projects
Select Git revision
  • 84dfdfd97f291f5df95fda25bf9fca7ff32ee7a4
  • master default protected
  • color-definitions
  • battery-symbol
  • framebuffer-overlay
  • batt-capacity
  • menu-disp
  • clock-fix
  • personal-state-colors
  • power
  • charge_voltage
  • pybattery
  • koalo/bhi160
  • ch3/splashscreen
  • genofire/ble-rewrite
  • rahix/simple_menu
  • koalo/bhi160-works-but-dirty
  • ios-workarounds
  • koalo/wip/i2c-for-python
  • renze/safe_mode
  • renze/hatchery_apps
  • v1.2
  • v1.1
  • v1.0
  • release-1
  • bootloader-v1
  • v0.0
27 results

init.gdb

Blame
  • Forked from card10 / firmware
    Source project has a limited visibility.
    fsusermount.c 8.65 KiB
    /*
     * 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.
     */
    
    #include "py/mpconfig.h"
    #if MICROPY_FSUSERMOUNT
    #include <string.h>
    #include <errno.h>
    
    #include "py/nlr.h"
    #include "py/runtime.h"
    #include "py/mperrno.h"
    #if MICROPY_FATFS_OO
    #include "lib/oofatfs/ff.h"
    #else
    #include "lib/fatfs/ff.h"
    #endif
    #include "extmod/fsusermount.h"
    
    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) {
        static const mp_arg_t allowed_args[] = {
            { MP_QSTR_readonly, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} },
            { MP_QSTR_mkfs, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} },
        };
    
        // parse args
        mp_obj_t device = pos_args[0];
        mp_obj_t mount_point = pos_args[1];
        mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
        mp_arg_parse_all(n_args - 2, pos_args + 2, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
    
        // get the mount point
        mp_uint_t mnt_len;
        const char *mnt_str = mp_obj_str_get_data(mount_point, &mnt_len);
    
        if (device == mp_const_none) {
            // umount
            FRESULT res = FR_NO_FILESYSTEM;
            for (size_t i = 0; i < MP_ARRAY_SIZE(MP_STATE_PORT(fs_user_mount)); ++i) {
                fs_user_mount_t *vfs = MP_STATE_PORT(fs_user_mount)[i];
                if (vfs != NULL && !memcmp(mnt_str, vfs->str, mnt_len + 1)) {
                    #if MICROPY_FATFS_OO
                    res = f_umount(&vfs->fatfs);
                    #else
                    res = f_mount(NULL, vfs->str, 0);
                    #endif
                    if (vfs->flags & FSUSER_FREE_OBJ) {
                        m_del_obj(fs_user_mount_t, vfs);