mirror of
https://github.com/bootandy/dust.git
synced 2026-06-08 11:29:05 +03:00
[GH-ISSUE #295] Quirky output of Windows NTFS mount inside WSL #128
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @danie-dejager on GitHub (Jan 15, 2023).
Original GitHub issue: https://github.com/bootandy/dust/issues/295
Hi,
I see that most Linux apps struggle to get the actual file size of a NTFS drive mounted in WSL.
Using
Dust 0.8.3From my Linux instance I go to
/mnt/d/and see the following resultsNormal output
with apparent-size things are looking better
Is there something wrong with how WSL is presenting the drive as other tools like Dust is also not printing sizes correctly. gdu also needs to use
apparent sizeto display correctly.https://github.com/dundee/gdu/issues/162
@bootandy commented on GitHub (Jan 18, 2023):
I've no idea how WSL works, but if it is fixed in gdu then I should be able to replicate that here
apparent size uses file length instead of counting the blocks that the file uses. It is possible that the block size in WSL is strange:
https://doc.rust-lang.org/std/os/linux/fs/trait.MetadataExt.html#tymethod.st_blocks
@bootandy commented on GitHub (Apr 2, 2025):
can we close this @danie-dejager ? It's been 2 years and I don't have a windows box to replicate this
@frendsick commented on GitHub (Apr 19, 2025):
I have the same issue. I'm taking some time to debug the issue and will let you know if I find a solution. The
--apparent-sizeflag works for me, too.@frendsick commented on GitHub (Apr 20, 2025):
I successfully reproduced the problem using the
statfunction with_FILE_OFFSET_BITSset to 64; see the C program below. It should be the same asstat64, what Rust's std::fs::metadata uses internally.This script shows that the problem cannot be fixed from Rust's side as long as we are using
std::fs::metadata. The bug is in the GNU C library'sstatfunction, specifically in how it handles NTFS files, at least when using WSL on Windows. Luckily, this happens very rarely, and the output is usually correct.PR #487 does not completely fix the issue, but it makes it less prevalent for
dustwhen it does occur. The expected allocated_size should be close, if not the actual size.@frendsick commented on GitHub (Apr 20, 2025):
The rabbit hole deepens. The problem seems not to be in GLIBC, but rather probably in the WSL's DrvFs driver. Unfortunately, DrvFs is not open source, so I cannot dig deeper.
Side note: I copied the SubmissionPayload.json file from the previous comment's test script to the same folder, renaming it to SubmissionPayload_new.json. After copying, both files show correct block counts on WSL's side. Somehow, touching the original file fixed it for the
statcommand in WSL.