mirror of
				https://github.com/eledio-devices/thirdparty-littlefs.git
				synced 2025-10-31 00:32:38 +01:00 
			
		
		
		
	Added v1->v2 migration into CI
Also fixed issue where migration would not handle large dirs due to v1 iteration changing the pair of the directory.
This commit is contained in:
		
							
								
								
									
										53
									
								
								.travis.yml
									
									
									
									
									
								
							
							
						
						
									
										53
									
								
								.travis.yml
									
									
									
									
									
								
							| @@ -130,7 +130,58 @@ jobs: | ||||
|         - ls -flh | ||||
|         - make -B test_dirs test_files QUIET=1 | ||||
|  | ||||
|       # Automatically update releases | ||||
|     # self-host with littlefs-fuse for fuzz test | ||||
|     - stage: test | ||||
|       env: | ||||
|         - STAGE=test | ||||
|         - NAME=littlefs-migration | ||||
|       install: | ||||
|         - sudo apt-get install libfuse-dev | ||||
|         - git clone --depth 1 https://github.com/geky/littlefs-fuse -b v2-alpha v2 | ||||
|         - git clone --depth 1 https://github.com/geky/littlefs-fuse v1 | ||||
|         - fusermount -V | ||||
|         - gcc --version | ||||
|       before_script: | ||||
|         # setup disk for littlefs-fuse | ||||
|         - rm -rf v2/littlefs/* | ||||
|         - cp -r $(git ls-tree --name-only HEAD) v2/littlefs | ||||
|  | ||||
|         - mkdir mount | ||||
|         - sudo chmod a+rw /dev/loop0 | ||||
|         - dd if=/dev/zero bs=512 count=4096 of=disk | ||||
|         - losetup /dev/loop0 disk | ||||
|       script: | ||||
|         # compile v1 and v2 | ||||
|         - make -C v1 | ||||
|         - make -C v2 | ||||
|  | ||||
|         # run self-host test with v1 | ||||
|         - v1/lfs --format /dev/loop0 | ||||
|         - v1/lfs /dev/loop0 mount | ||||
|  | ||||
|         - ls mount | ||||
|         - mkdir mount/littlefs | ||||
|         - cp -r $(git ls-tree --name-only HEAD) mount/littlefs | ||||
|         - cd mount/littlefs | ||||
|         - stat . | ||||
|         - ls -flh | ||||
|         - make -B test_dirs test_files QUIET=1 | ||||
|  | ||||
|         # attempt to migrate | ||||
|         - cd ../.. | ||||
|         - fusermount -u mount | ||||
|  | ||||
|         - v2/lfs --migrate /dev/loop0 | ||||
|         - v2/lfs /dev/loop0 mount | ||||
|  | ||||
|         # run self-host test with v2 right where we left off | ||||
|         - ls mount | ||||
|         - cd mount/littlefs | ||||
|         - stat . | ||||
|         - ls -flh | ||||
|         - make -B test_dirs test_files QUIET=1 | ||||
|  | ||||
|     # Automatically create releases | ||||
|     - stage: deploy | ||||
|       env: | ||||
|         - STAGE=deploy | ||||
|   | ||||
							
								
								
									
										9
									
								
								lfs.c
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								lfs.c
									
									
									
									
									
								
							| @@ -4268,6 +4268,8 @@ int lfs_migrate(lfs_t *lfs, const struct lfs_config *cfg) { | ||||
|             } | ||||
|  | ||||
|             dir2.rev = dir1.d.rev; | ||||
|             dir1.head[0] = dir1.pair[0]; | ||||
|             dir1.head[1] = dir1.pair[1]; | ||||
|             lfs->root[0] = dir2.pair[0]; | ||||
|             lfs->root[1] = dir2.pair[1]; | ||||
|  | ||||
| @@ -4368,7 +4370,10 @@ int lfs_migrate(lfs_t *lfs, const struct lfs_config *cfg) { | ||||
|  | ||||
|             // Copy over first block to thread into fs. Unfortunately | ||||
|             // if this fails there is not much we can do. | ||||
|             err = lfs_bd_erase(lfs, dir1.pair[1]); | ||||
|             LFS_DEBUG("Migrating %"PRIu32" %"PRIu32" -> %"PRIu32" %"PRIu32, | ||||
|                     lfs->root[0], lfs->root[1], dir1.head[0], dir1.head[1]); | ||||
|  | ||||
|             err = lfs_bd_erase(lfs, dir1.head[1]); | ||||
|             if (err) { | ||||
|                 goto cleanup; | ||||
|             } | ||||
| @@ -4389,7 +4394,7 @@ int lfs_migrate(lfs_t *lfs, const struct lfs_config *cfg) { | ||||
|  | ||||
|                 err = lfs_bd_prog(lfs, | ||||
|                         &lfs->pcache, &lfs->rcache, true, | ||||
|                         dir1.pair[1], i, &dat, 1); | ||||
|                         dir1.head[1], i, &dat, 1); | ||||
|                 if (err) { | ||||
|                     goto cleanup; | ||||
|                 } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user