mirror of
				https://github.com/eledio-devices/thirdparty-littlefs.git
				synced 2025-10-31 16:14:16 +01:00 
			
		
		
		
	After quite a bit of prototyping, settled on the following functions: - lfs_dir_alloc - create a new dir - lfs_dir_fetch - load and check a dir pair from disk - lfs_dir_commit - save a dir pair to disk - lfs_dir_shift - shrink a dir pair to disk - lfs_dir_append - add a dir entry, creating dirs if needed - lfs_dir_remove - remove a dir entry, dropping dirs if needed Additionally, followed through with a few other tweaks
		
			
				
	
	
		
			50 lines
		
	
	
		
			971 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			50 lines
		
	
	
		
			971 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
| #!/bin/bash
 | |
| set -eu
 | |
| 
 | |
| echo "=== Formatting tests ==="
 | |
| rm -rf blocks
 | |
| 
 | |
| echo "--- Basic formatting ---"
 | |
| tests/test.py << TEST
 | |
|     lfs_format(&lfs, &config) => 0;
 | |
| TEST
 | |
| 
 | |
| echo "--- Invalid superblocks ---"
 | |
| ln -f -s /dev/null blocks/0
 | |
| ln -f -s /dev/null blocks/1
 | |
| tests/test.py << TEST
 | |
|     lfs_format(&lfs, &config) => LFS_ERROR_CORRUPT;
 | |
| TEST
 | |
| rm blocks/0 blocks/1
 | |
| 
 | |
| echo "--- Basic mounting ---"
 | |
| tests/test.py << TEST
 | |
|     lfs_format(&lfs, &config) => 0;
 | |
| TEST
 | |
| tests/test.py << TEST
 | |
|     lfs_mount(&lfs, &config) => 0;
 | |
|     lfs_unmount(&lfs) => 0;
 | |
| TEST
 | |
| 
 | |
| echo "--- Invalid mount ---"
 | |
| tests/test.py << TEST
 | |
|     lfs_format(&lfs, &config) => 0;
 | |
| TEST
 | |
| rm blocks/0 blocks/1
 | |
| tests/test.py << TEST
 | |
|     lfs_mount(&lfs, &config) => LFS_ERROR_CORRUPT;
 | |
| TEST
 | |
| 
 | |
| echo "--- Valid corrupt mount ---"
 | |
| tests/test.py << TEST
 | |
|     lfs_format(&lfs, &config) => 0;
 | |
| TEST
 | |
| rm blocks/0
 | |
| tests/test.py << TEST
 | |
|     lfs_mount(&lfs, &config) => 0;
 | |
|     lfs_unmount(&lfs) => 0;
 | |
| TEST
 | |
| 
 | |
| echo "--- Results ---"
 | |
| tests/stats.py
 |