mirror of
				https://github.com/eledio-devices/thirdparty-littlefs.git
				synced 2025-10-31 00:32:38 +01:00 
			
		
		
		
	Changed attr_max to be specific to custom attributes
While technically, both system and user attributes share the same disk limitations, that's not what attr_max represents when considered from the user's perspective. To the user, attr_max applies only to custom attributes. This means attr_max should not impact other configurable limitations, such as inline files, and the ordering should be reconsidered with what the user finds most important.
This commit is contained in:
		
							
								
								
									
										41
									
								
								lfs.c
									
									
									
									
									
								
							
							
						
						
									
										41
									
								
								lfs.c
									
									
									
									
									
								
							| @@ -388,18 +388,18 @@ static inline void lfs_superblock_fromle32(lfs_superblock_t *superblock) { | ||||
|     superblock->version     = lfs_fromle32(superblock->version); | ||||
|     superblock->block_size  = lfs_fromle32(superblock->block_size); | ||||
|     superblock->block_count = lfs_fromle32(superblock->block_count); | ||||
|     superblock->name_max    = lfs_fromle32(superblock->name_max); | ||||
|     superblock->inline_max  = lfs_fromle32(superblock->inline_max); | ||||
|     superblock->attr_max    = lfs_fromle32(superblock->attr_max); | ||||
|     superblock->name_max    = lfs_fromle32(superblock->name_max); | ||||
| } | ||||
|  | ||||
| static inline void lfs_superblock_tole32(lfs_superblock_t *superblock) { | ||||
|     superblock->version     = lfs_tole32(superblock->version); | ||||
|     superblock->block_size  = lfs_tole32(superblock->block_size); | ||||
|     superblock->block_count = lfs_tole32(superblock->block_count); | ||||
|     superblock->name_max    = lfs_tole32(superblock->name_max); | ||||
|     superblock->inline_max  = lfs_tole32(superblock->inline_max); | ||||
|     superblock->attr_max    = lfs_tole32(superblock->attr_max); | ||||
|     superblock->name_max    = lfs_tole32(superblock->name_max); | ||||
| } | ||||
|  | ||||
|  | ||||
| @@ -3054,6 +3054,12 @@ static int lfs_init(lfs_t *lfs, const struct lfs_config *cfg) { | ||||
|     } | ||||
|  | ||||
|     // check that the size limits are sane | ||||
|     LFS_ASSERT(lfs->cfg->name_max <= LFS_NAME_MAX); | ||||
|     lfs->name_max = lfs->cfg->name_max; | ||||
|     if (!lfs->name_max) { | ||||
|         lfs->name_max = LFS_NAME_MAX; | ||||
|     } | ||||
|  | ||||
|     LFS_ASSERT(lfs->cfg->inline_max <= LFS_INLINE_MAX); | ||||
|     LFS_ASSERT(lfs->cfg->inline_max <= lfs->cfg->cache_size); | ||||
|     lfs->inline_max = lfs->cfg->inline_max; | ||||
| @@ -3067,12 +3073,6 @@ static int lfs_init(lfs_t *lfs, const struct lfs_config *cfg) { | ||||
|         lfs->attr_max = LFS_ATTR_MAX; | ||||
|     } | ||||
|  | ||||
|     LFS_ASSERT(lfs->cfg->name_max <= LFS_NAME_MAX); | ||||
|     lfs->name_max = lfs->cfg->name_max; | ||||
|     if (!lfs->name_max) { | ||||
|         lfs->name_max = LFS_NAME_MAX; | ||||
|     } | ||||
|  | ||||
|     // setup default state | ||||
|     lfs->root[0] = 0xffffffff; | ||||
|     lfs->root[1] = 0xffffffff; | ||||
| @@ -3132,9 +3132,9 @@ int lfs_format(lfs_t *lfs, const struct lfs_config *cfg) { | ||||
|  | ||||
|         .block_size  = lfs->cfg->block_size, | ||||
|         .block_count = lfs->cfg->block_count, | ||||
|         .attr_max    = lfs->attr_max, | ||||
|         .name_max    = lfs->name_max, | ||||
|         .inline_max  = lfs->inline_max, | ||||
|         .attr_max    = lfs->attr_max, | ||||
|     }; | ||||
|  | ||||
|     lfs_superblock_tole32(&superblock); | ||||
| @@ -3204,17 +3204,6 @@ int lfs_mount(lfs_t *lfs, const struct lfs_config *cfg) { | ||||
|             } | ||||
|  | ||||
|             // check superblock configuration | ||||
|             if (superblock.attr_max) { | ||||
|                 if (superblock.attr_max > lfs->attr_max) { | ||||
|                     LFS_ERROR("Unsupported attr_max (%"PRIu32" > %"PRIu32")", | ||||
|                             superblock.attr_max, lfs->attr_max); | ||||
|                     err = LFS_ERR_INVAL; | ||||
|                     goto cleanup; | ||||
|                 } | ||||
|  | ||||
|                 lfs->attr_max = superblock.attr_max; | ||||
|             } | ||||
|  | ||||
|             if (superblock.name_max) { | ||||
|                 if (superblock.name_max > lfs->name_max) { | ||||
|                     LFS_ERROR("Unsupported name_max (%"PRIu32" > %"PRIu32")", | ||||
| @@ -3236,6 +3225,18 @@ int lfs_mount(lfs_t *lfs, const struct lfs_config *cfg) { | ||||
|  | ||||
|                 lfs->inline_max = superblock.inline_max; | ||||
|             } | ||||
|  | ||||
|             if (superblock.attr_max) { | ||||
|                 if (superblock.attr_max > lfs->attr_max) { | ||||
|                     LFS_ERROR("Unsupported attr_max (%"PRIu32" > %"PRIu32")", | ||||
|                             superblock.attr_max, lfs->attr_max); | ||||
|                     err = LFS_ERR_INVAL; | ||||
|                     goto cleanup; | ||||
|                 } | ||||
|  | ||||
|                 lfs->attr_max = superblock.attr_max; | ||||
|             } | ||||
|  | ||||
|         } | ||||
|  | ||||
|         // has globals? | ||||
|   | ||||
		Reference in New Issue
	
	Block a user