Skip to content

Commit f448139

Browse files
committed
Swapped BLKGETSIZE for BLKGETSIZE64
BLKGETSIZE64 seems to report the size in bytes, which is what we actually want. BLKGETSIZE reported the size in "512-byte blocks", which just complicates our final block_count calculation.
1 parent e06caf4 commit f448139

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lfs_fuse_bd.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ int lfs_fuse_bd_create(struct lfs_config *cfg, const char *path) {
4141

4242
// get size in sectors
4343
if (!cfg->block_count) {
44-
long size;
45-
int err = ioctl(fd, BLKGETSIZE, &size);
44+
uint64_t size;
45+
int err = ioctl(fd, BLKGETSIZE64, &size);
4646
if (err) {
4747
return -errno;
4848
}
49-
cfg->block_count = size * 512 / cfg->block_size;
49+
cfg->block_count = size / cfg->block_size;
5050
}
5151

5252
// setup function pointers

0 commit comments

Comments
 (0)