littlefs-project / littlefs

A little fail-safe filesystem designed for microcontrollers
BSD 3-Clause "New" or "Revised" License
5.25k stars 803 forks source link

lfs:Added lfs_file_getattr interface #1047

Open crafcat7 opened 4 days ago

crafcat7 commented 4 days ago

This change comes from https://github.com/littlefs-project/littlefs/pull/1045, which splits lfs_file_getattr and lfs_file_setattr. At the same time, the logic of lfs_file_getattr is optimized.

  1. Added a new interface lfs_file_getattr to get the corresponding file attributes through lfs_file. This interface is similar to lfs_getattr, but lfs_file_getattr replaces path with lfs_file.
  2. Implemented the corresponding test case in test_attrs.toml.

The main logic of the test:

  1. Create a file and get its attributes (it should return LFS_ERR_NOATTR at this time)
  2. Set its attributes and then get the attributes and compare the attributes

After passing make test, the results are all passed

running test_alloc: 12/12 cases, 207/207 perms
running test_attrs: 5/5 cases, 25/25 perms
running test_badblocks: 4/4 cases, 300/300 perms
running test_bd: 5/5 cases, 85/85 perms
running test_compat: 17/17 cases, 205/205 perms
running test_dirs: 14/14 cases, 445/445 perms, 1756pls!
running test_entries: 8/8 cases, 32/32 perms
running test_evil: 8/8 cases, 105/105 perms
running test_exhaustion: 5/5 cases, 85/85 perms
running test_files: 10/10 cases, 7155/7155 perms, 9410pls!
running test_interspersed: 4/4 cases, 190/190 perms, 2835pls!
running test_move: 17/17 cases, 161/161 perms, 157pls!
running test_orphans: 6/6 cases, 50/50 perms, 846pls!
running test_paths: 13/13 cases, 65/65 perms
running test_powerloss: 2/2 cases, 21/21 perms
running test_relocations: 4/4 cases, 68/68 perms, 1612pls!
running test_seek: 6/6 cases, 175/175 perms, 1050pls!
running test_superblocks: 16/16 cases, 285/285 perms, 1437pls!
running test_truncate: 7/7 cases, 1270/1270 perms, 9691pls!

done: 10929/10929 passed, 0/10929 failed, 28794pls!, in 216.85s