Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Size reported by fileAllocatedSizeKey incorrect on linux #4885

Open
patrick-zippenfenig opened this issue Feb 27, 2024 · 0 comments
Open

Size reported by fileAllocatedSizeKey incorrect on linux #4885

patrick-zippenfenig opened this issue Feb 27, 2024 · 0 comments

Comments

@patrick-zippenfenig
Copy link

Hi,

The allocated file size using fileAllocatedSizeKey is wrongly calculated for linux.

Current implementation:

let stat = try urlStat()
result[key] = Int(stat.st_blocks) * Int(stat.st_blksize)

Proposed implementation:

let stat = try urlStat()
result[key] = Int(stat.st_blocks) * 512

st_blocks appears to be always defined as 512 on Linux. st_blksize is the prefered IO size, but unrelated to the underlaying storage size. As the preferred IO size may be reported as 4096, this results in 8 times larger file size. This is exactly what I am seeing right now, while using fileAllocatedSizeKey.

I am unsure if other platforms may use st_blksize to report a different storage block size.

Let me know if I should submit a PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant