circuitpython/tests/extmod/vfs_lfs.py.exp
Damien George 2acc087880 extmod/vfs_lfs: Add mtime support to littlefs files.
This commit adds support for modification time of files on littlefs v2
filesystems, using file attributes.  For some background see issue #6114.

Features/properties of this implementation:
- Only supported on littlefs2 (not littlefs1).
- Uses littlefs2's general file attributes to store the timestamp.
- The timestamp is 64-bits and stores nanoseconds since 1970/1/1 (if the
  range to the year 2554 is not enough then additional bits can be added to
  this timestamp by adding another file attribute).
- mtime is enabled by default but can be disabled in the constructor, eg:
  uos.mount(uos.VfsLfs2(bdev, mtime=False), '/flash')
- It's fully backwards compatible, existing littlefs2 filesystems will work
  without reformatting and timestamps will be added transparently to
  existing files (once they are opened for writing).
- Files without timestamps will open correctly, and stat will just return 0
  for their timestamp.
- mtime can be disabled or enabled each mount time and timestamps will only
  be updated if mtime is enabled (otherwise they will be untouched).

Signed-off-by: Damien George <damien@micropython.org>
2020-08-25 17:35:19 +10:00

75 lines
1.9 KiB
Plaintext

test <class 'VfsLfs1'>
(1024, 1024, 30, 26, 26, 0, 0, 0, 0, 255)
(1024, 1024, 30, 25, 25, 0, 0, 0, 0, 255)
[('test', 32768, 0, 8)]
[('test', 32768, 0, 8)]
[(b'test', 32768, 0, 8)]
[('test', 32768, 0, 8), ('testdir', 16384, 0, 0)]
[]
[('test', 32768, 0, 8)]
(32768, 0, 0, 0, 0, 0) 8 <class 'int'> <class 'int'> <class 'int'>
(16384, 0, 0, 0, 0, 0) -1 <class 'int'> <class 'int'> <class 'int'>
littlefs
data length: 4096
write 0
write 1
write 2
write 3
(1024, 1024, 30, 6, 6, 0, 0, 0, 0, 255)
[('test', 32768, 0, 8), ('testbig2', 32768, 0, 16384), ('testdir', 16384, 0, 0)]
[('testbig2', 32768, 0, 16384)]
[('test', 32768, 0, 8), ('testbig2', 32768, 0, 16384), ('testdir', 16384, 0, 0)]
[('test', 32768, 0, 8), ('testdir', 16384, 0, 0)]
/
/testdir
(32768, 0, 0, 0, 0, 0) 0 <class 'int'> <class 'int'> <class 'int'>
(32768, 0, 0, 0, 0, 0) 0 <class 'int'> <class 'int'> <class 'int'>
/
/testdir
/
/testdir/subdir
/
/testdir2
/testdir
/
/testdir
/testdir/subdir
/
test <class 'VfsLfs2'>
(1024, 1024, 30, 28, 28, 0, 0, 0, 0, 255)
(1024, 1024, 30, 28, 28, 0, 0, 0, 0, 255)
[('test', 32768, 0, 8)]
[('test', 32768, 0, 8)]
[(b'test', 32768, 0, 8)]
[('testdir', 16384, 0, 0), ('test', 32768, 0, 8)]
[]
[('test', 32768, 0, 8)]
(32768, 0, 0, 0, 0, 0) 8 <class 'int'> <class 'int'> <class 'int'>
(16384, 0, 0, 0, 0, 0) -1 <class 'int'> <class 'int'> <class 'int'>
littlefs
data length: 4096
write 0
write 1
write 2
write 3
(1024, 1024, 30, 7, 7, 0, 0, 0, 0, 255)
[('test', 32768, 0, 8), ('testbig2', 32768, 0, 16384), ('testdir', 16384, 0, 0)]
[('testbig2', 32768, 0, 16384)]
[('test', 32768, 0, 8), ('testbig2', 32768, 0, 16384), ('testdir', 16384, 0, 0)]
[('test', 32768, 0, 8), ('testdir', 16384, 0, 0)]
/
/testdir
(32768, 0, 0, 0, 0, 0) 0 <class 'int'> <class 'int'> <class 'int'>
(32768, 0, 0, 0, 0, 0) 0 <class 'int'> <class 'int'> <class 'int'>
/
/testdir
/
/testdir/subdir
/
/testdir2
/testdir
/
/testdir
/testdir/subdir
/