littlefs-project / littlefs

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

Try to understand the littleFS implementation principle #601

Open litiansong opened 3 years ago

litiansong commented 3 years ago

Dear seniors, I have been studying the realization principle of LittleFS recently。 I'm new to LittleFS, and I'm comparing my learning with other file systems and asking designers the following questions:

  1. What is the layout of LittleFS? When I learned FATFS, FATFS file system consists of MBR DBR and its reserved sectors, FAT1, FAT2 and DATA. What about litlefs?
  2. In the process of transplantation, I found that mount failed all the time. I read the source code, but I did not understand what was done in the whole process of mount. Could you please explain the process of lfs_mounting to me in detail? Thanks a million.
  3. When the format // sanity check that fetch works err = lfs_dir_fetch(lfs, &root, (const lfs_block_t[2]){0, 1}); So what does this code do? I read the notes and I didn't really understand them. Could you please explain the principle of lfs_format to me in detail? After understanding format, I believe I can better understand the layout of littleFS. I hope you can reply to my small questions in your busy schedule, so that I can have a deeper understanding of LittleFS, thank you! Very eager to receive your answers!
blomnik commented 3 years ago

Did you read DESIGN.md and SPEC.md?