Skip to content

Commit 2c222af

Browse files
committed
Tweaked lfs_fsinfo block_size/block_count fields
Mainly to match superblock ordering and emphasize these are logical blocks.
1 parent 127d84b commit 2c222af

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

lfs.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ static int lfs_bd_read(lfs_t *lfs,
4646
lfs_block_t block, lfs_off_t off,
4747
void *buffer, lfs_size_t size) {
4848
uint8_t *data = buffer;
49-
if (off+size > lfs->cfg->block_size || (lfs->block_count && block >= lfs->block_count)) {
49+
if (off+size > lfs->cfg->block_size
50+
|| (lfs->block_count && block >= lfs->block_count)) {
5051
return LFS_ERR_CORRUPT;
5152
}
5253

@@ -4509,14 +4510,15 @@ static int lfs_fs_rawstat(lfs_t *lfs, struct lfs_fsinfo *fsinfo) {
45094510
fsinfo->disk_version = superblock.version;
45104511
}
45114512

4513+
// filesystem geometry
4514+
fsinfo->block_size = lfs->cfg->block_size;
4515+
fsinfo->block_count = lfs->block_count;
4516+
45124517
// other on-disk configuration, we cache all of these for internal use
45134518
fsinfo->name_max = lfs->name_max;
45144519
fsinfo->file_max = lfs->file_max;
45154520
fsinfo->attr_max = lfs->attr_max;
45164521

4517-
fsinfo->block_count = lfs->block_count;
4518-
fsinfo->block_size = lfs->cfg->block_size;
4519-
45204522
return 0;
45214523
}
45224524

lfs.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,12 @@ struct lfs_fsinfo {
293293
// On-disk version.
294294
uint32_t disk_version;
295295

296+
// Size of a logical block in bytes.
297+
lfs_size_t block_size;
298+
299+
// Number of logical blocks in filesystem.
300+
lfs_size_t block_count;
301+
296302
// Upper limit on the length of file names in bytes.
297303
lfs_size_t name_max;
298304

@@ -301,13 +307,6 @@ struct lfs_fsinfo {
301307

302308
// Upper limit on the size of custom attributes in bytes.
303309
lfs_size_t attr_max;
304-
305-
// Number of blocks in filesystem.
306-
// May differ from cfg->block_count if autodetected from filesystem.
307-
lfs_size_t block_count;
308-
309-
// Size of block in bytes.
310-
lfs_size_t block_size;
311310
};
312311

313312
// Custom attribute structure, used to describe custom attributes
@@ -440,12 +439,11 @@ typedef struct lfs {
440439
} free;
441440

442441
const struct lfs_config *cfg;
442+
lfs_size_t block_count;
443443
lfs_size_t name_max;
444444
lfs_size_t file_max;
445445
lfs_size_t attr_max;
446446

447-
lfs_size_t block_count;
448-
449447
#ifdef LFS_MIGRATE
450448
struct lfs1 *lfs1;
451449
#endif

0 commit comments

Comments
 (0)