summaryrefslogtreecommitdiff
path: root/extmod/vfs.c
AgeCommit message (Collapse)Author
2021-01-29extmod/vfs: Check block 0 and 1 when auto-detecting littlefs.Damien George
The superblock for littlefs is in block 0 and 1, but block 0 may be erased or partially written, so block 1 must be checked if block 0 does not have a valid littlefs superblock in it. Prior to this commit, the mount of a block device which auto-detected the filysystem type would fail for littlefs if block 0 did not contain a valid superblock. That is now fixed. Signed-off-by: Damien George <damien@micropython.org>
2020-12-17extmod/vfs: Raise OSError(ENODEV) if mounting bdev without a filesystem.Oliver Joos
This commit prevents uos.mount() from raising an AttributeError. vfs_autodetect() is supposed to return an object that has a "mount" method, so if no filesystem is found it should raise an OSError(ENODEV) and not return the bdev itself which has no "mount" method.
2020-09-23extmod/vfs: Fix lookup of entry in root dir so it fails correctly.Damien George
Prior to this commit, uos.chdir('/') followed by uos.stat('noexist') would succeed that stat even though the entry did not exist (some other functions like listdir would have similar issues). This is because, if the current directory was the root and the path was relative, mp_vfs_lookup_path would return success for bad paths. Signed-off-by: Damien George <damien@micropython.org>
2020-05-29extmod/vfs: Retain previous working directory if chdir fails.Damien George
Fixes issue #6069.
2020-03-11extmod/vfs: Factor out vfs mount-and-chdir helper from stm32.Damien George
2020-02-28all: Reformat C and Python source code with tools/codeformat.py.Damien George
This is run with uncrustify 0.70.1, and black 19.10b0.
2019-12-27py: Introduce MP_ROM_FALSE/MP_ROM_TRUE for ROM to refer to bool objects.Damien George
This helps to prevent mistakes, and allows easily changing the ROM value of False/True if needed.
2019-12-27py: Introduce MP_ROM_NONE macro for ROM to refer to None object.Damien George
This helps to prevent mistakes, and allows easily changing the ROM value of None if needed.
2019-11-06extmod/vfs: Add autodetect of littlefs filesystem when mounting.Damien George
2019-02-12extmod: Convert legacy uppercase macro names to lowercase.Damien George
2018-07-03extmod/vfs: Support opening a file descriptor (int) with VfsPosix.Damien George
Fixes issue #3865.
2018-06-06extmod/vfs: Introduce a C-level VFS protocol, with fast import_stat.Damien George
Following other C-level protocols, this VFS protocol is added to help abstract away implementation details of the underlying VFS in an efficient way. As a starting point, the import_stat function is put into this protocol so that the VFS sub-system does not need to know about every VFS implementation in order to do an efficient stat for importing files. In the future it might be worth adding other functions to this protocol.
2018-06-06extmod/vfs: Add fast path for stating VfsPosix filesystem.Damien George
2018-06-06extmod/vfs: Use u_rom_obj properly in argument structures.Damien George
2018-05-02extmod/vfs: Delegate import_stat to vfs.stat to allow generic FS import.Damien George
2018-03-12extmod/vfs_fat: Add file size as 4th element of uos.ilistdir tuple.Tom Collins
2017-11-16extmod/vfs: Use existing qstr for forward-slash string object.Damien George
2017-10-27extmod/vfs: Replace VLA in proxy func with small, static sized array.Damien George
VLAs can be expensive on stack usage due to stack alignment requirements, and also the fact that extra local variables are needed to track the dynamic size of the stack. So using fixed-size arrays when possible can help to reduce code size and stack usage. In this particular case, the maximum value of n_args in the VLA is 2 and so it's more efficient to just allocate this array with a fixed size. This reduces code size by around 30 bytes on Thumb2 and Xtensa archs. It also reduces total stack usage of the function: on Thumb2 the usage with VLA is between 40 and 48 bytes, which is reduced to 32; on Xtensa, VLA usage is between 64 and 80 bytes, reduced to 32; on x86-64 it's at least 88 bytes reduced to 80.
2017-10-04all: Remove inclusion of internal py header files.Damien George
Header files that are considered internal to the py core and should not normally be included directly are: py/nlr.h - internal nlr configuration and declarations py/bc0.h - contains bytecode macro definitions py/runtime0.h - contains basic runtime enums Instead, the top-level header files to include are one of: py/obj.h - includes runtime0.h and defines everything to use the mp_obj_t type py/runtime.h - includes mpstate.h and hence nlr.h, obj.h, runtime0.h, and defines everything to use the general runtime support functions Additional, specific headers (eg py/objlist.h) can be included if needed.
2017-06-07extmod/vfs: Allow "buffering" and "encoding" args to VFS's open().Damien George
These args are currently ignored but are parsed to make it easier to write portable scripts between CPython and MicroPython.
2017-06-07extmod/vfs: Allow to statvfs the root directory.Damien George
2017-05-10extmod/vfs: Use MP_S_IFDIR, MP_S_IFREG consts instead of magic numbers.Damien George
2017-05-10extmod/vfs: Implement mp_vfs_ilistdir().Damien George
uos.ilistdir() is the core function, returning an iterator that yields 3-tuples. uos.listdir() is implemented in terms of ilistdir().
2017-05-05extmod/vfs: Allow a VFS to be mounted at the root dir.Damien George
This patch allows mounting of VFS objects right at the root directory, eg os.mount(vfs, '/'). It still allows VFS's to be mounted at a path within the root, eg os.mount(vfs, '/flash'), and such mount points will override any paths within a VFS that is mounted at the root.
2017-03-29extmod: Update for changes to mp_obj_str_get_data.Damien George
2017-03-13extmod/vfs: Rewrite path lookup algo to support relative paths from root.Damien George
For example, if the current directory is the root dir then this patch allows one to do uos.listdir('mnt'), where 'mnt' is a valid mount point. Previous to this patch such a thing would not work, on needed to do uos.listdir('/mnt') instead.
2017-02-13extmod/vfs: Allow to stat the root directory.Damien George
os.stat('/') now works and returns a mostly-empty tuple. Really all that is useful is the mode which tells that it's a directory.
2017-02-09extmod/vfs: Raise OSError(EEXIST) on attempt to mkdir a mount point.Damien George
2017-02-09extmod/vfs: Allow to mount a block device, not just a VFS object.Damien George
If the mounted object doesn't have a "mount" method then assume it's a block device and try to detect the filesystem. Since we currently only support FAT filesystems, the behaviour is to just try and create a VfsFat object automatically, using the given block device.
2017-01-30extmod: Merge old fsusermount.h header into vfs.h and vfs_fat.h.Damien George
vfs.h is for generic VFS declarations, and vfs_fat.h is for VfsFat specific things.
2017-01-30extmod/vfs: Expose lookup_path_raw as mp_vfs_lookup_path.Damien George
It can be useful for low-level lookup of paths by ports.
2017-01-27extmod/vfs: Expose mp_vfs_mount_t type.Damien George
It should only be used for low-level things and with caution, for example putting mounted VFS data in ROM or the static data section.
2017-01-27extmod/vfs: Add ability for VFS sub-system to import using VfsFat.Damien George
2017-01-27extmod: Add generic VFS sub-system.Damien George
This provides mp_vfs_XXX functions (eg mount, open, listdir) which are agnostic to the underlying filesystem type, and just require an object with the relevant filesystem-like methods (eg .mount, .open, .listidr) which can then be mounted. These mp_vfs_XXX functions would typically be used by a port to implement the "uos" module, and mp_vfs_open would be the builtin open function. This feature is controlled by MICROPY_VFS, disabled by default.