aboutsummaryrefslogtreecommitdiff
path: root/extmod/vfs_fat.c
AgeCommit message (Collapse)Author
2022-05-03all: Use mp_obj_malloc everywhere it's applicable.Jim Mussared
This replaces occurences of foo_t *foo = m_new_obj(foo_t); foo->base.type = &foo_type; with foo_t *foo = mp_obj_malloc(foo_t, &foo_type); Excludes any places where base is a sub-field or when new0/memset is used. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-07-12all: Update to point to files in new shared/ directory.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2021-05-06extmod: Remove old comments used for auto-doc generation.Damien George
They are no longer used, and the text in the docs is more up to date. Signed-off-by: Damien George <damien@micropython.org>
2020-09-18all: Rename absolute time-based functions to include "epoch".Damien George
For time-based functions that work with absolute time there is the need for an Epoch, to set the zero-point at which the absolute time starts counting. Such functions include time.time() and filesystem stat return values. And different ports may use a different Epoch. To make it clearer what functions use the Epoch (whatever it may be), and make the ports more consistent with their use of the Epoch, this commit renames all Epoch related functions to include the word "epoch" in their name (and remove references to "2000"). Along with this rename, the following things have changed: - mp_hal_time_ns() is now specified to return the number of nanoseconds since the Epoch, rather than since 1970 (but since this is an internal function it doesn't change anything for the user). - littlefs timestamps on the esp8266 have been fixed (they were previously off by 30 years in nanoseconds). Otherwise, there is no functional change made by this commit. Signed-off-by: Damien George <damien@micropython.org>
2020-09-01extmod/vfs: Add option to use 1970 as Epoch.Damien George
By setting MICROPY_EPOCH_IS_1970 a port can opt to use 1970/1/1 as the Epoch for timestamps returned by stat(). And this setting is enabled on the unix and windows ports because that's what they use. Signed-off-by: Damien George <damien@micropython.org>
2020-09-01extmod/vfs: Support larger integer range in VFS stat time fields.Damien George
On ports like unix where the Epoch is 1970/1/1 and atime/mtime/ctime are in seconds since the Epoch, this value will overflow a small-int on 32-bit systems. So far this is only an issue on 32-bit unix builds that use the VFS layer (eg dev and coverage unix variants) but the fix (using mp_obj_new_int_from_uint instead of MP_OBJ_NEW_SMALL_INT) is there for all ports so as to not complicate the code, and because they will need the range one day. Also apply a similar fix to other fields in VfsPosix.stat because they may also be large. Signed-off-by: Damien George <damien@micropython.org>
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-10-29extmod/vfs: Rename BP_IOCTL_xxx constants to MP_BLOCKDEV_IOCTL_xxx.Damien George
Also rename SEC_COUNT to BLOCK_COUNT and SEC_SIZE to BLOCK_SIZE.
2019-10-29extmod/vfs_blockdev: Factor out block device interface code.Damien George
2019-10-29extmod: Factor out block-device struct to make independent of fatfs.Damien George
2019-03-26extmod/vfs_fat: Fallback to FAT32 if standard FAT16/SFD format fails.Andrew Leech
This allows formatting SD cards, larger flash etc which do not support the default FAT16/SFD format mode.
2019-03-05extmod/vfs_fat: Update for new oofatfs version.Damien George
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-03-12extmod/vfs_fat: Add file size as 4th element of uos.ilistdir tuple.Tom Collins
2018-02-23extmod/vfs_fat: Make fat_vfs_open_obj wrapper public, not its function.Damien George
This patch just moves the definition of the wrapper object fat_vfs_open_obj to the location of the definition of its function, which matches how it's done in most other places in the code base.
2018-02-23extmod/vfs_fat: Merge remaining vfs_fat_misc.c code into vfs_fat.c.Damien George
The only function left in vfs_fat_misc.c is fat_vfs_import_stat() which can logically go into vfs_fat.c, allowing to remove vfs_fat_misc.c.
2018-02-23extmod/vfs_fat: Move ilistdir implementation from misc to main file.Damien George
The fat_vfs_ilistdir2() function was only used by fat_vfs_ilistdir_func() so moving the former into the same file as the latter allows it to be placed directly into the latter function, thus saving code size.
2017-11-20extmod/vfs_fat: Mount FatFS on creation so VFS methods can be used.Damien George
It's possible to use the methods (eg ilistdir) of a VFS FatFS object without it being mounted in the VFS itself. This previously worked but only because FatFS was "mounting" the filesystem automatically when any function (eg f_opendir) was called. But it didn't work for ports that used synchronisation objects (_FS_REENTRANT) because they are only initialised via a call to f_mount. So, call f_mount explicitly when creating a new FatFS object so that everything is set up correctly. Then also provide a finaliser to do the f_umount call, but only if synchronisation objects are enabled (since otherwise the f_umount call does nothing).
2017-11-16py/objstr: Remove "make_qstr_if_not_already" arg from mp_obj_new_str.Damien George
This patch simplifies the str creation API to favour the common case of creating a str object that is not forced to be interned. To force interning of a new str the new mp_obj_new_str_via_qstr function is added, and should only be used if warranted. Apart from simplifying the mp_obj_new_str function (and making it have the same signature as mp_obj_new_bytes), this patch also reduces code size by a bit (-16 bytes for bare-arm and roughly -40 bytes on the bare-metal archs).
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-08-21extmod,unix: For uos.stat interpret st_size member as an unsigned int.Damien George
This prevents large files (eg larger than 2gb on a 32-bit arch) from showing up as having a negative size. Fixes issue #3227.
2017-05-10extmod/vfs: Use MP_S_IFDIR, MP_S_IFREG consts instead of magic numbers.Damien George
2017-05-10extmod/vfs_fat: Replace listdir() with implementation of ilistdir().Damien George
VfsFat no longer has the listdir() method. Rather, if listdir() functionality is needed then one should use uos.listdir() which will call VfsFat.ilistdir().
2017-03-29extmod/vfs_fat: Fix calculation of total blocks in statvfs.Damien George
2017-03-10extmod/vfs_fat: Remove obsolete and unused str/len members.Damien George
2017-01-30extmod/vfs_fat.c: Use explicit include path for timeutils.h.Andrew Gatt
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_fat: Remove MICROPY_FATFS_OO config option.Damien George
Everyone should now be using the new ooFatFs library. The old one is no longer supported and will be removed.
2017-01-27extmod/vfs_fat: Use SECSIZE macro to determine FatFs sector size.Damien George
2017-01-27extmod/vfs_fat: Rework to support new generic VFS sub-system.Damien George
The VfsFat object can now be mounted by the generic VFS sub-system.
2017-01-27extmod: Rename vfs_fat_file.h to vfs_fat.h.Damien George
And move declaration of mp_fat_vfs_type to this file.
2017-01-27extmod/vfs_fat: Rework so it can optionally use OO version of FatFS.Damien George
If MICROPY_VFS_FAT is enabled by a port then the port must switch to using MICROPY_FATFS_OO. Otherwise a port can continue to use the FatFs code without any changes.
2016-12-02extmod/vfs_fat: Implement POSIX behaviour of rename, allow to overwrite.Damien George
If the destination of os.rename() exists then it will be overwritten if it is a file. This is the POSIX behaviour, which is also the CPython behaviour, and so we follow suit. See issue #2598 for discussion.
2016-10-11extmod/vfs_fat: Add file and directory checks for remove and rmdir.Alex March
2016-10-07extmod/vfs_fat: Use mp_raise_OSError helper function.Damien George
2016-09-27extmod/vfs_fat: Add fat_vfs_statvfs(), reused from stmhal.Alex March
2016-08-26esp8266/modous: Add os.umount method to unmount a filesystem.Radomir Dopieralski
This is an object-oriented approach, where uos is only a proxy for the methods on the vfs object. Some internals had to be exposed (the STATIC keyword removed) for this to work. Fixes #2338.
2016-07-16extmod/vfs_fat: Implement rmdir() method.Paul Sokolovsky
Shares the code with remove() method due to the same underlying f_unlink() FatFs operation.
2016-06-16esp8266: Use RTC to set date & time stamps for files.Robert HH
The time stamp is taken from the RTC for all newly generated or changed files. RTC must be maintained separately. The dummy time stamp of Jan 1, 2000 is set in vfs.stat() for the root directory, avoiding invalid time values.
2016-05-31extmod/vfs_fat: Mark anused "self" arg for fat_vfs_stat().Paul Sokolovsky
2016-05-31extmod/vfs_fat.c: Add vfs.stat().Robert HH
The call to stat() returns a 10 element tuple consistent to the os.stat() call. At the moment, the only relevant information returned are file type and file size.
2016-05-29extmod/vfs_fat: getcwd(): Use mp_obj_new_exception_arg1().Paul Sokolovsky
Copy-paste issue, with the original mistake in stmhal.
2016-05-29extmod/vfs_fat: chdir(), getcwd() methods should accept VFS object (self).Paul Sokolovsky
2016-05-29extmod/vfs_fat: Add getcwd() method.Paul Sokolovsky
Ported from stmhal.
2016-05-29extmod/vfs_fat: Add chdir() method.Paul Sokolovsky
Ported from stmhal.
2016-05-27extmod/vfs_fat*: Replace text error messages by POSIX error numbers.Robert HH
These changes are in line with similar changes in other modules, and with standard Python interface.
2016-05-20extmod: When including extmod headers, prefix path with extmod/.Damien George
2016-02-29extmod/vfs_fat: Add .rename() method.Paul Sokolovsky
2016-02-29extmod/vfs_fat: Add .mkdir() method.Paul Sokolovsky
2016-02-28extmod/vfs_fat: Fix unused param warning/error.Paul Sokolovsky