mirror of
				https://github.com/eledio-devices/thirdparty-littlefs.git
				synced 2025-10-31 00:32:38 +01:00 
			
		
		
		
	Generated v2 prefixes
This commit is contained in:
		
							
								
								
									
										17
									
								
								.travis.yml
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								.travis.yml
									
									
									
									
									
								
							| @@ -66,7 +66,10 @@ jobs: | ||||
|         - CC="arm-linux-gnueabi-gcc --static -mthumb" | ||||
|         - EXEC="qemu-arm" | ||||
|       install: | ||||
|         - sudo apt-get install gcc-arm-linux-gnueabi qemu-user | ||||
|         - sudo apt-get install | ||||
|               gcc-arm-linux-gnueabi | ||||
|               libc6-dev-armel-cross | ||||
|               qemu-user | ||||
|         - arm-linux-gnueabi-gcc --version | ||||
|         - qemu-arm -version | ||||
|  | ||||
| @@ -78,7 +81,10 @@ jobs: | ||||
|         - CC="powerpc-linux-gnu-gcc --static" | ||||
|         - EXEC="qemu-ppc" | ||||
|       install: | ||||
|         - sudo apt-get install gcc-powerpc-linux-gnu qemu-user | ||||
|         - sudo apt-get install | ||||
|               gcc-powerpc-linux-gnu | ||||
|               libc6-dev-powerpc-cross | ||||
|               qemu-user | ||||
|         - powerpc-linux-gnu-gcc --version | ||||
|         - qemu-ppc -version | ||||
|  | ||||
| @@ -90,9 +96,10 @@ jobs: | ||||
|         - CC="mips-linux-gnu-gcc --static" | ||||
|         - EXEC="qemu-mips" | ||||
|       install: | ||||
|         - sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu/ xenial main universe" | ||||
|         - sudo apt-get -qq update | ||||
|         - sudo apt-get install gcc-mips-linux-gnu qemu-user | ||||
|         - sudo apt-get install | ||||
|               gcc-mips-linux-gnu | ||||
|               libc6-dev-mips-cross | ||||
|               qemu-user | ||||
|         - mips-linux-gnu-gcc --version | ||||
|         - qemu-mips -version | ||||
|  | ||||
|   | ||||
							
								
								
									
										26
									
								
								lfs2.c
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								lfs2.c
									
									
									
									
									
								
							| @@ -194,7 +194,7 @@ static int lfs2_bd_prog(lfs2_t *lfs2, | ||||
|             off += diff; | ||||
|             size -= diff; | ||||
|  | ||||
|             pcache->size = off - pcache->off; | ||||
|             pcache->size = lfs2_max(pcache->size, off - pcache->off); | ||||
|             if (pcache->size == lfs2->cfg->cache_size) { | ||||
|                 // eagerly flush out pcache if we fill up | ||||
|                 int err = lfs2_bd_flush(lfs2, pcache, rcache, validate); | ||||
| @@ -617,7 +617,7 @@ static int lfs2_dir_getread(lfs2_t *lfs2, const lfs2_mdir_t *dir, | ||||
|                 lfs2->cfg->cache_size); | ||||
|         int err = lfs2_dir_getslice(lfs2, dir, gmask, gtag, | ||||
|                 rcache->off, rcache->buffer, rcache->size); | ||||
|         if (err) { | ||||
|         if (err < 0) { | ||||
|             return err; | ||||
|         } | ||||
|     } | ||||
| @@ -2548,7 +2548,7 @@ relocate: | ||||
|                 } | ||||
|             } | ||||
|         } else { | ||||
|             file->ctz.size = lfs2_max(file->pos, file->ctz.size); | ||||
|             file->pos = lfs2_max(file->pos, file->ctz.size); | ||||
|         } | ||||
|  | ||||
|         // actual file updates | ||||
| @@ -3338,6 +3338,14 @@ int lfs2_format(lfs2_t *lfs2, const struct lfs2_config *cfg) { | ||||
|         if (err) { | ||||
|             goto cleanup; | ||||
|         } | ||||
|  | ||||
|         // force compaction to prevent accidentally mounting any | ||||
|         // older version of littlefs that may live on disk | ||||
|         root.erased = false; | ||||
|         err = lfs2_dir_commit(lfs2, &root, NULL, 0); | ||||
|         if (err) { | ||||
|             goto cleanup; | ||||
|         } | ||||
|     } | ||||
|  | ||||
| cleanup: | ||||
| @@ -4399,6 +4407,11 @@ int lfs2_migrate(lfs2_t *lfs2, const struct lfs2_config *cfg) { | ||||
|                     goto cleanup; | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             err = lfs2_bd_flush(lfs2, &lfs2->pcache, &lfs2->rcache, true); | ||||
|             if (err) { | ||||
|                 goto cleanup; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         // Create new superblock. This marks a successful migration! | ||||
| @@ -4442,6 +4455,13 @@ int lfs2_migrate(lfs2_t *lfs2, const struct lfs2_config *cfg) { | ||||
|         if (err) { | ||||
|             goto cleanup; | ||||
|         } | ||||
|  | ||||
|         // force compaction to prevent accidentally mounting v1 | ||||
|         dir2.erased = false; | ||||
|         err = lfs2_dir_commit(lfs2, &dir2, NULL, 0); | ||||
|         if (err) { | ||||
|             goto cleanup; | ||||
|         } | ||||
|     } | ||||
|  | ||||
| cleanup: | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #!/usr/bin/env python | ||||
| #!/usr/bin/env python2 | ||||
|  | ||||
| # This script replaces prefixes of files, and symbols in that file. | ||||
| # Useful for creating different versions of the codebase that don't | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #!/usr/bin/env python | ||||
| #!/usr/bin/env python2 | ||||
|  | ||||
| import struct | ||||
| import sys | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #!/usr/bin/env python | ||||
| #!/usr/bin/env python2 | ||||
|  | ||||
| import struct | ||||
| import sys | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| #!/usr/bin/env python | ||||
| #!/usr/bin/env python2 | ||||
|  | ||||
| import re | ||||
| import sys | ||||
|   | ||||
| @@ -357,5 +357,73 @@ tests/test.py << TEST | ||||
|     lfs2_unmount(&lfs2) => 0; | ||||
| TEST | ||||
|  | ||||
| echo "--- Inline write and seek ---" | ||||
| for SIZE in $SMALLSIZE $MEDIUMSIZE $LARGESIZE | ||||
| do | ||||
| tests/test.py << TEST | ||||
|     lfs2_mount(&lfs2, &cfg) => 0; | ||||
|     lfs2_file_open(&lfs2, &file[0], "hello/tinykitty$SIZE", | ||||
|             LFS2_O_RDWR | LFS2_O_CREAT) => 0; | ||||
|     int j = 0; | ||||
|     int k = 0; | ||||
|  | ||||
|     memcpy(buffer, "abcdefghijklmnopqrstuvwxyz", 26); | ||||
|     for (unsigned i = 0; i < $SIZE; i++) { | ||||
|         lfs2_file_write(&lfs2, &file[0], &buffer[j++ % 26], 1) => 1; | ||||
|         lfs2_file_tell(&lfs2, &file[0]) => i+1; | ||||
|         lfs2_file_size(&lfs2, &file[0]) => i+1; | ||||
|     } | ||||
|  | ||||
|     lfs2_file_seek(&lfs2, &file[0], 0, LFS2_SEEK_SET) => 0; | ||||
|     lfs2_file_tell(&lfs2, &file[0]) => 0; | ||||
|     lfs2_file_size(&lfs2, &file[0]) => $SIZE; | ||||
|     for (unsigned i = 0; i < $SIZE; i++) { | ||||
|         uint8_t c; | ||||
|         lfs2_file_read(&lfs2, &file[0], &c, 1) => 1; | ||||
|         c => buffer[k++ % 26]; | ||||
|     } | ||||
|  | ||||
|     lfs2_file_sync(&lfs2, &file[0]) => 0; | ||||
|     lfs2_file_tell(&lfs2, &file[0]) => $SIZE; | ||||
|     lfs2_file_size(&lfs2, &file[0]) => $SIZE; | ||||
|  | ||||
|     lfs2_file_seek(&lfs2, &file[0], 0, LFS2_SEEK_SET) => 0; | ||||
|     for (unsigned i = 0; i < $SIZE; i++) { | ||||
|         lfs2_file_write(&lfs2, &file[0], &buffer[j++ % 26], 1) => 1; | ||||
|         lfs2_file_tell(&lfs2, &file[0]) => i+1; | ||||
|         lfs2_file_size(&lfs2, &file[0]) => $SIZE; | ||||
|         lfs2_file_sync(&lfs2, &file[0]) => 0; | ||||
|         lfs2_file_tell(&lfs2, &file[0]) => i+1; | ||||
|         lfs2_file_size(&lfs2, &file[0]) => $SIZE; | ||||
|         if (i < $SIZE-2) { | ||||
|             uint8_t c[3]; | ||||
|             lfs2_file_seek(&lfs2, &file[0], -1, LFS2_SEEK_CUR) => i; | ||||
|             lfs2_file_read(&lfs2, &file[0], &c, 3) => 3; | ||||
|             lfs2_file_tell(&lfs2, &file[0]) => i+3; | ||||
|             lfs2_file_size(&lfs2, &file[0]) => $SIZE; | ||||
|             lfs2_file_seek(&lfs2, &file[0], i+1, LFS2_SEEK_SET) => i+1; | ||||
|             lfs2_file_tell(&lfs2, &file[0]) => i+1; | ||||
|             lfs2_file_size(&lfs2, &file[0]) => $SIZE; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     lfs2_file_seek(&lfs2, &file[0], 0, LFS2_SEEK_SET) => 0; | ||||
|     lfs2_file_tell(&lfs2, &file[0]) => 0; | ||||
|     lfs2_file_size(&lfs2, &file[0]) => $SIZE; | ||||
|     for (unsigned i = 0; i < $SIZE; i++) { | ||||
|         uint8_t c; | ||||
|         lfs2_file_read(&lfs2, &file[0], &c, 1) => 1; | ||||
|         c => buffer[k++ % 26]; | ||||
|     } | ||||
|  | ||||
|     lfs2_file_sync(&lfs2, &file[0]) => 0; | ||||
|     lfs2_file_tell(&lfs2, &file[0]) => $SIZE; | ||||
|     lfs2_file_size(&lfs2, &file[0]) => $SIZE; | ||||
|  | ||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; | ||||
|     lfs2_unmount(&lfs2) => 0; | ||||
| TEST | ||||
| done | ||||
|  | ||||
| echo "--- Results ---" | ||||
| tests/stats.py | ||||
|   | ||||
		Reference in New Issue
	
	Block a user