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

du -h reports wrong file size on DrvFs #1894

Closed
marcogroppo opened this issue Apr 12, 2017 · 4 comments
Closed

du -h reports wrong file size on DrvFs #1894

marcogroppo opened this issue Apr 12, 2017 · 4 comments
Labels

Comments

@marcogroppo
Copy link

  • A brief description

du -h (du --block-size=human-readable) does not work correctly on DrvFs volumes (i.e., /mnt/c).

  • Expected results

If the file size is ~10M du -h should output 10M.

  • Actual results (with terminal output if applicable)

Totally wrong file size (for example 5 GB for a 10 MB file!)

  • Your Windows build number

Windows 10 Creators Update
Windows 10 Pro Version 1703 Build 15063.138

  • Steps / All commands required to reproduce the error from a brand new installation
$ dd if=/dev/zero of=test.bin bs=1M count=10
10+0 records in
10+0 records out
10485760 bytes (10 MB, 10 MiB) copied, 0.049809 s, 211 MB/s
$ ls -l test.bin
-rwxrwxrwx 1 root root 10485760 Apr 12 18:06 test.bin
$ du -h test.bin
5.1G    test.bin

The command works fine on VolFs:

$ mv test.bin ~/
$ cd
$ du -h test.bin
10M     test.bin
  • Strace of the failing command
execve("/usr/bin/du", ["du", "-h", "test.bin"], [/* 16 vars */]) = 0
brk(NULL)                               = 0x7f0000
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f2c3f740000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=20599, ...}) = 0
mmap(NULL, 20599, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f2c3f745000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P\t\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1864888, ...}) = 0
mmap(NULL, 3967392, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f2c3f030000
mprotect(0x7f2c3f1ef000, 2097152, PROT_NONE) = 0
mmap(0x7f2c3f3ef000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1bf000) = 0x7f2c3f3ef000
mmap(0x7f2c3f3f5000, 14752, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f2c3f3f5000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f2c3f730000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f2c3f720000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f2c3f710000
arch_prctl(ARCH_SET_FS, 0x7f2c3f720700) = 0
mprotect(0x7f2c3f3ef000, 16384, PROT_READ) = 0
mprotect(0x61c000, 4096, PROT_READ)     = 0
mprotect(0x7f2c3f625000, 4096, PROT_READ) = 0
munmap(0x7f2c3f745000, 20599)           = 0
brk(NULL)                               = 0x7f0000
brk(0x811000)                           = 0x811000
open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=1668976, ...}) = 0
mmap(NULL, 1668976, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f2c3f48d000
close(3)                                = 0
newfstatat(AT_FDCWD, "test.bin", {st_mode=S_IFREG|0777, st_size=10485760, ...}, AT_SYMLINK_NOFOLLOW) = 0
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(4, 3), ...}) = 0
ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0
write(1, "5.1G\ttest.bin\n", 145.1G     test.bin
)        = 14
close(1)                                = 0
close(2)                                = 0
exit_group(0)                           = ?
+++ exited with 0 +++
@marcogroppo marcogroppo changed the title du -h reports wrong file size on DrvFs du -h reports wrong file size on DrvFs Apr 12, 2017
@marcogroppo
Copy link
Author

On DrvFs the stat system call returns a bogus number of blocks (maybe file size + 1?):

$ stat ~/test.bin
  File: '/home/marco/test.bin'
  Size: 10485760        Blocks: 20480      IO Block: 4096   regular file
Device: 10h/16d Inode: 17451448556193666  Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/   marco)   Gid: ( 1000/   marco)
...

$ stat /mnt/c/Users/Marco/test.bin
  File: '/mnt/c/Users/Marco/test.bin'
  Size: 10485760        Blocks: 10485761   IO Block: 4096   regular file
Device: eh/14d  Inode: 7318349394488527  Links: 1
Access: (0777/-rwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/    root)

@jonmclean
Copy link

@marcogroppo
Copy link
Author

The bug fix should be on its way: #2211 (comment)

@benhillis
Copy link
Member

Fixed in 16237.

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

No branches or pull requests

5 participants