mirror of
				https://github.com/eledio-devices/thirdparty-littlefs.git
				synced 2025-10-31 08:42:40 +01:00 
			
		
		
		
	Merge pull request #16 from geky/versioning
Add version info for software library and on-disk structures
This commit is contained in:
		
							
								
								
									
										28
									
								
								.travis.yml
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								.travis.yml
									
									
									
									
									
								
							| @@ -45,3 +45,31 @@ before_script: | |||||||
|     - sudo chmod a+rw /dev/loop0 |     - sudo chmod a+rw /dev/loop0 | ||||||
|     - dd if=/dev/zero bs=512 count=2048 of=disk |     - dd if=/dev/zero bs=512 count=2048 of=disk | ||||||
|     - losetup /dev/loop0 disk |     - losetup /dev/loop0 disk | ||||||
|  |  | ||||||
|  | deploy: | ||||||
|  |     # Let before_deploy take over | ||||||
|  |     provider: script | ||||||
|  |     script: 'true' | ||||||
|  |     on: | ||||||
|  |         branch: master | ||||||
|  |  | ||||||
|  | before_deploy: | ||||||
|  |     - cd $TRAVIS_BUILD_DIR | ||||||
|  |     # Update tag for version defined in lfs.h | ||||||
|  |     - LFS_VERSION=$(grep -ox '#define LFS_VERSION .*' lfs.h | cut -d ' ' -f3) | ||||||
|  |     - LFS_VERSION_MAJOR=$((0xffff & ($LFS_VERSION >> 16))) | ||||||
|  |     - LFS_VERSION_MINOR=$((0xffff & ($LFS_VERSION >>  0))) | ||||||
|  |     - LFS_VERSION="v$LFS_VERSION_MAJOR.$LFS_VERSION_MINOR" | ||||||
|  |     - | | ||||||
|  |       curl -u $GEKY_BOT -X POST \ | ||||||
|  |         https://api.github.com/repos/$TRAVIS_REPO_SLUG/git/refs \ | ||||||
|  |         -d @- <<< "{ | ||||||
|  |           \"ref\": \"refs/tags/$LFS_VERSION\", | ||||||
|  |           \"sha\": \"$TRAVIS_COMMIT\" | ||||||
|  |         }" | ||||||
|  |     - | | ||||||
|  |       curl -f -u $GEKY_BOT -X PATCH \ | ||||||
|  |         https://api.github.com/repos/$TRAVIS_REPO_SLUG/git/refs/tags/$LFS_VERSION \ | ||||||
|  |         -d @- <<< "{ | ||||||
|  |           \"sha\": \"$TRAVIS_COMMIT\" | ||||||
|  |         }" | ||||||
|   | |||||||
							
								
								
									
										11
									
								
								lfs.c
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								lfs.c
									
									
									
									
									
								
							| @@ -2067,7 +2067,7 @@ int lfs_format(lfs_t *lfs, const struct lfs_config *cfg) { | |||||||
|         .d.type = LFS_TYPE_SUPERBLOCK, |         .d.type = LFS_TYPE_SUPERBLOCK, | ||||||
|         .d.elen = sizeof(superblock.d) - sizeof(superblock.d.magic) - 4, |         .d.elen = sizeof(superblock.d) - sizeof(superblock.d.magic) - 4, | ||||||
|         .d.nlen = sizeof(superblock.d.magic), |         .d.nlen = sizeof(superblock.d.magic), | ||||||
|         .d.version = 0x00010001, |         .d.version = LFS_DISK_VERSION, | ||||||
|         .d.magic = {"littlefs"}, |         .d.magic = {"littlefs"}, | ||||||
|         .d.block_size  = lfs->cfg->block_size, |         .d.block_size  = lfs->cfg->block_size, | ||||||
|         .d.block_count = lfs->cfg->block_count, |         .d.block_count = lfs->cfg->block_count, | ||||||
| @@ -2140,10 +2140,11 @@ int lfs_mount(lfs_t *lfs, const struct lfs_config *cfg) { | |||||||
|         return LFS_ERR_CORRUPT; |         return LFS_ERR_CORRUPT; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (superblock.d.version > (0x00010001 | 0x0000ffff)) { |     uint16_t major_version = (0xffff & (superblock.d.version >> 16)); | ||||||
|         LFS_ERROR("Invalid version %d.%d", |     uint16_t minor_version = (0xffff & (superblock.d.version >>  0)); | ||||||
|                 0xffff & (superblock.d.version >> 16), |     if ((major_version != LFS_DISK_VERSION_MAJOR || | ||||||
|                 0xffff & (superblock.d.version >> 0)); |          minor_version > LFS_DISK_VERSION_MINOR)) { | ||||||
|  |         LFS_ERROR("Invalid version %d.%d", major_version, minor_version); | ||||||
|         return LFS_ERR_INVAL; |         return LFS_ERR_INVAL; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										17
									
								
								lfs.h
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								lfs.h
									
									
									
									
									
								
							| @@ -22,6 +22,23 @@ | |||||||
| #include <stdbool.h> | #include <stdbool.h> | ||||||
|  |  | ||||||
|  |  | ||||||
|  | /// Version info /// | ||||||
|  |  | ||||||
|  | // Software library version | ||||||
|  | // Major (top-nibble), incremented on backwards incompatible changes | ||||||
|  | // Minor (bottom-nibble), incremented on feature additions | ||||||
|  | #define LFS_VERSION 0x00010002 | ||||||
|  | #define LFS_VERSION_MAJOR (0xffff & (LFS_VERSION >> 16)) | ||||||
|  | #define LFS_VERSION_MINOR (0xffff & (LFS_VERSION >>  0)) | ||||||
|  |  | ||||||
|  | // Version of On-disk data structures | ||||||
|  | // Major (top-nibble), incremented on backwards incompatible changes | ||||||
|  | // Minor (bottom-nibble), incremented on feature additions | ||||||
|  | #define LFS_DISK_VERSION 0x00010001 | ||||||
|  | #define LFS_DISK_VERSION_MAJOR (0xffff & (LFS_DISK_VERSION >> 16)) | ||||||
|  | #define LFS_DISK_VERSION_MINOR (0xffff & (LFS_DISK_VERSION >>  0)) | ||||||
|  |  | ||||||
|  |  | ||||||
| /// Definitions /// | /// Definitions /// | ||||||
|  |  | ||||||
| // Type definitions | // Type definitions | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user