Tweaked lfs_fsinfo block_size/block_count fields
Mainly to match superblock ordering and emphasize these are logical blocks.
This commit is contained in:
@@ -46,7 +46,8 @@ static int lfs_bd_read(lfs_t *lfs,
|
|||||||
lfs_block_t block, lfs_off_t off,
|
lfs_block_t block, lfs_off_t off,
|
||||||
void *buffer, lfs_size_t size) {
|
void *buffer, lfs_size_t size) {
|
||||||
uint8_t *data = buffer;
|
uint8_t *data = buffer;
|
||||||
if (off+size > lfs->cfg->block_size || (lfs->block_count && block >= lfs->block_count)) {
|
if (off+size > lfs->cfg->block_size
|
||||||
|
|| (lfs->block_count && block >= lfs->block_count)) {
|
||||||
return LFS_ERR_CORRUPT;
|
return LFS_ERR_CORRUPT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4509,14 +4510,15 @@ static int lfs_fs_rawstat(lfs_t *lfs, struct lfs_fsinfo *fsinfo) {
|
|||||||
fsinfo->disk_version = superblock.version;
|
fsinfo->disk_version = superblock.version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// filesystem geometry
|
||||||
|
fsinfo->block_size = lfs->cfg->block_size;
|
||||||
|
fsinfo->block_count = lfs->block_count;
|
||||||
|
|
||||||
// other on-disk configuration, we cache all of these for internal use
|
// other on-disk configuration, we cache all of these for internal use
|
||||||
fsinfo->name_max = lfs->name_max;
|
fsinfo->name_max = lfs->name_max;
|
||||||
fsinfo->file_max = lfs->file_max;
|
fsinfo->file_max = lfs->file_max;
|
||||||
fsinfo->attr_max = lfs->attr_max;
|
fsinfo->attr_max = lfs->attr_max;
|
||||||
|
|
||||||
fsinfo->block_count = lfs->block_count;
|
|
||||||
fsinfo->block_size = lfs->cfg->block_size;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -293,6 +293,12 @@ struct lfs_fsinfo {
|
|||||||
// On-disk version.
|
// On-disk version.
|
||||||
uint32_t disk_version;
|
uint32_t disk_version;
|
||||||
|
|
||||||
|
// Size of a logical block in bytes.
|
||||||
|
lfs_size_t block_size;
|
||||||
|
|
||||||
|
// Number of logical blocks in filesystem.
|
||||||
|
lfs_size_t block_count;
|
||||||
|
|
||||||
// Upper limit on the length of file names in bytes.
|
// Upper limit on the length of file names in bytes.
|
||||||
lfs_size_t name_max;
|
lfs_size_t name_max;
|
||||||
|
|
||||||
@@ -301,13 +307,6 @@ struct lfs_fsinfo {
|
|||||||
|
|
||||||
// Upper limit on the size of custom attributes in bytes.
|
// Upper limit on the size of custom attributes in bytes.
|
||||||
lfs_size_t attr_max;
|
lfs_size_t attr_max;
|
||||||
|
|
||||||
// Number of blocks in filesystem.
|
|
||||||
// May differ from cfg->block_count if autodetected from filesystem.
|
|
||||||
lfs_size_t block_count;
|
|
||||||
|
|
||||||
// Size of block in bytes.
|
|
||||||
lfs_size_t block_size;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Custom attribute structure, used to describe custom attributes
|
// Custom attribute structure, used to describe custom attributes
|
||||||
@@ -440,12 +439,11 @@ typedef struct lfs {
|
|||||||
} free;
|
} free;
|
||||||
|
|
||||||
const struct lfs_config *cfg;
|
const struct lfs_config *cfg;
|
||||||
|
lfs_size_t block_count;
|
||||||
lfs_size_t name_max;
|
lfs_size_t name_max;
|
||||||
lfs_size_t file_max;
|
lfs_size_t file_max;
|
||||||
lfs_size_t attr_max;
|
lfs_size_t attr_max;
|
||||||
|
|
||||||
lfs_size_t block_count;
|
|
||||||
|
|
||||||
#ifdef LFS_MIGRATE
|
#ifdef LFS_MIGRATE
|
||||||
struct lfs1 *lfs1;
|
struct lfs1 *lfs1;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user