https://bugs.winehq.org/show_bug.cgi?id=43947
Bug ID: 43947 Summary: Disk size in Wine is not correct Product: Wine Version: 2.0 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: -unknown Assignee: wine-bugs@winehq.org Reporter: christoph.heilmann@gmx.de Distribution: ---
Created attachment 59586 --> https://bugs.winehq.org/attachment.cgi?id=59586 disk size windows
Dual Xeon E5-2630v4 (!!) Ubuntu 17.04 Server Kernel 4.10.0-37 Wine 2.0.3
WINEARCH=win64 WINEPREFIX=/home/christoph/.wine64
christoph@:/$ df -h Filesystem Size Used Avail Use% Mounted on udev 126G 0 126G 0% /dev tmpfs 26G 11M 26G 1% /run /dev/sda2 450G 166G 262G 39% / tmpfs 126G 0 126G 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 126G 0 126G 0% /sys/fs/cgroup /dev/sda1 226M 58M 153M 28% /boot
The disk size in Wine is not correct (see attachment).
https://bugs.winehq.org/show_bug.cgi?id=43947
--- Comment #1 from Christoph Heilmann christoph.heilmann@gmx.de --- The disk drive is a Samsung ssd:
Oct 29 13:49:09 kernel: [ 7.576322] scsi host0: ahci Oct 29 13:49:09 kernel: [ 7.576424] scsi host1: ahci Oct 29 13:49:09 kernel: [ 7.576532] scsi host2: ahci Oct 29 13:49:09 kernel: [ 7.576627] scsi host3: ahci Oct 29 13:49:09 kernel: [ 7.576729] scsi host4: ahci Oct 29 13:49:09 kernel: [ 7.576817] scsi host5: ahci Oct 29 13:49:09 kernel: [ 7.576854] ata1: SATA max UDMA/133 abar m2048@0xc7332000 port 0xc7332100 irq 32 Oct 29 13:49:09 kernel: [ 7.576859] ata2: SATA max UDMA/133 abar m2048@0xc7332000 port 0xc7332180 irq 32 Oct 29 13:49:09 kernel: [ 7.576863] ata3: SATA max UDMA/133 abar m2048@0xc7332000 port 0xc7332200 irq 32 Oct 29 13:49:09 kernel: [ 7.576868] ata4: SATA max UDMA/133 abar m2048@0xc7332000 port 0xc7332280 irq 32 Oct 29 13:49:09 kernel: [ 7.576872] ata5: SATA max UDMA/133 abar m2048@0xc7332000 port 0xc7332300 irq 32 Oct 29 13:49:09 kernel: [ 7.576877] ata6: SATA max UDMA/133 abar m2048@0xc7332000 port 0xc7332380 irq 32 Oct 29 13:49:09 kernel: [ 7.890224] ata6: SATA link down (SStatus 0 SControl 300) Oct 29 13:49:09 kernel: [ 7.890523] ata1: SATA link up 6.0 Gbps (SStatus 133 SControl 300) Oct 29 13:49:09 kernel: [ 7.890862] ata5: SATA link down (SStatus 0 SControl 300) Oct 29 13:49:09 kernel: [ 7.891002] ata4: SATA link down (SStatus 0 SControl 300) Oct 29 13:49:09 kernel: [ 7.891095] ata3: SATA link down (SStatus 0 SControl 300) Oct 29 13:49:09 kernel: [ 7.891167] ata2: SATA link down (SStatus 0 SControl 300) Oct 29 13:49:09 kernel: [ 7.892453] ata1.00: supports DRM functions and may not be fully accessible Oct 29 13:49:09 kernel: [ 7.892858] ata1.00: NCQ Send/Recv Log not supported Oct 29 13:49:09 kernel: [ 7.892859] ata1.00: ATA-9: Samsung SSD 840 EVO 500GB, EXT0CB6Q, max UDMA/133 Oct 29 13:49:09 kernel: [ 7.892860] ata1.00: 976773168 sectors, multi 1: LBA48 NCQ (depth 31/32), AA Oct 29 13:49:09 kernel: [ 7.893052] ata1.00: supports DRM functions and may not be fully accessible Oct 29 13:49:09 kernel: [ 7.893427] ata1.00: NCQ Send/Recv Log not supported Oct 29 13:49:09 kernel: [ 7.893428] ata1.00: configured for UDMA/133 Oct 29 13:49:09 kernel: [ 7.893766] scsi 0:0:0:0: Direct-Access ATA Samsung SSD 840 CB6Q PQ: 0 ANSI: 5 Oct 29 13:49:09 m4348 kernel: [ 7.908432] dca service started, version 1.12.1
https://bugs.winehq.org/show_bug.cgi?id=43947
--- Comment #2 from Christoph Heilmann christoph.heilmann@gmx.de --- root@~# fdisk -u -l Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0xa6126827
Device Boot Start End Sectors Size Id Type /dev/sda1 * 2048 487423 485376 237M 83 Linux /dev/sda2 487424 961144831 960657408 458.1G 83 Linux /dev/sda3 961144832 976771071 15626240 7.5G 82 Linux swap / Solaris
https://bugs.winehq.org/show_bug.cgi?id=43947
--- Comment #3 from Christoph Heilmann christoph.heilmann@gmx.de --- Created attachment 59595 --> https://bugs.winehq.org/attachment.cgi?id=59595 Registry Hardware Profiles
https://bugs.winehq.org/show_bug.cgi?id=43947
--- Comment #4 from Christoph Heilmann christoph.heilmann@gmx.de --- Created attachment 59596 --> https://bugs.winehq.org/attachment.cgi?id=59596 Regitry MountedDevices
https://bugs.winehq.org/show_bug.cgi?id=43947
Christoph Heilmann christoph.heilmann@gmx.de changed:
What |Removed |Added ---------------------------------------------------------------------------- Attachment #59596|Registry MountedDevices.png |Registry Hardware filename| |Profiles.png Attachment #59596|Regitry MountedDevices |Registry Hardware Profiles description| |
https://bugs.winehq.org/show_bug.cgi?id=43947
Christoph Heilmann christoph.heilmann@gmx.de changed:
What |Removed |Added ---------------------------------------------------------------------------- Attachment #59595|Registry Hardware Profiles |Registry MountedDevices description| | Attachment #59595|registry Hardware |registry MountedDevices.png filename|Profiles.png |
https://bugs.winehq.org/show_bug.cgi?id=43947
--- Comment #5 from Christoph Heilmann christoph.heilmann@gmx.de --- I suppose the issue belongs to following code in wine-2.0-rc3/dlls/kernel32/volume.c but I'm not sure whats going wrong here:
1664 /*********************************************************************** d1051870 Alexan*1665 * GetDiskFreeSpaceExW (KERNEL32.@) 1666 * 1667 * This function is used to acquire the size of the available and 1668 * total space on a logical volume. 1669 * 1670 * RETURNS 1671 * 1672 * Zero on failure, nonzero upon success. Use GetLastError to obtain 1673 * detailed error information. 1674 * 1675 */ 1676 BOOL WINAPI GetDiskFreeSpaceExW( LPCWSTR root, PULARGE_INTEGER avail, 1677 PULARGE_INTEGER total, PULARGE_INTEGER totalfree ) 1678 { 1679 FILE_FS_SIZE_INFORMATION info; 1680 IO_STATUS_BLOCK io; 1681 NTSTATUS status; 1682 HANDLE handle; 1683 UINT units; 1684 1685 TRACE( "%s,%p,%p,%p\n", debugstr_w(root), avail, total, totalfree ); 1686 1687 if (!open_device_root( root, &handle )) return FALSE; 1688 1689 status = NtQueryVolumeInformationFile( handle, &io, &info, sizeof(info), FileFsSizeInformation ); 1690 NtClose( handle ); 1691 if (status != STATUS_SUCCESS) 1692 { 1693 SetLastError( RtlNtStatusToDosError(status) ); 1694 return FALSE; 1695 } 1696 1697 units = info.SectorsPerAllocationUnit * info.BytesPerSector; 1698 if (total) total->QuadPart = info.TotalAllocationUnits.QuadPart * units; 1699 if (totalfree) totalfree->QuadPart = info.AvailableAllocationUnits.QuadPart * units; 1700 /* FIXME: this one should take quotas into account */ 1701 if (avail) avail->QuadPart = info.AvailableAllocationUnits.QuadPart * units; 1702 return TRUE; 1703 } 1704 1705 1706 /*********************************************************************** 1707 * GetDiskFreeSpaceExA (KERNEL32.@) b8d9b619 Markus*1708 * 1709 * See GetDiskFreeSpaceExW. d1051870 Alexan*1710 */ 1711 BOOL WINAPI GetDiskFreeSpaceExA( LPCSTR root, PULARGE_INTEGER avail, 1712 PULARGE_INTEGER total, PULARGE_INTEGER totalfree ) 1713 { 0d33e5e3 Alexan*1714 WCHAR *rootW = NULL; d1051870 Alexan*1715 0d33e5e3 Alexan*1716 if (root && !(rootW = FILE_name_AtoW( root, FALSE ))) return FALSE; 1717 return GetDiskFreeSpaceExW( rootW, avail, total, totalfree ); d1051870 Alexan*1718 } 1719 1720 1721 /*********************************************************************** 1722 * GetDiskFreeSpaceW (KERNEL32.@) 1723 */ 1724 BOOL WINAPI GetDiskFreeSpaceW( LPCWSTR root, LPDWORD cluster_sectors, 1725 LPDWORD sector_bytes, LPDWORD free_clusters, 1726 LPDWORD total_clusters ) 1727 { 1728 FILE_FS_SIZE_INFORMATION info; 1729 IO_STATUS_BLOCK io; 1730 NTSTATUS status; 1731 HANDLE handle; 1732 UINT units; 1733 1734 TRACE( "%s,%p,%p,%p,%p\n", debugstr_w(root), 1735 cluster_sectors, sector_bytes, free_clusters, total_clusters ); 1736 1737 if (!open_device_root( root, &handle )) return FALSE; 1738 1739 status = NtQueryVolumeInformationFile( handle, &io, &info, sizeof(info), FileFsSizeInformation ); 1740 NtClose( handle ); 1741 if (status != STATUS_SUCCESS) 1742 { 1743 SetLastError( RtlNtStatusToDosError(status) ); 1744 return FALSE; 1745 } 1746 1747 units = info.SectorsPerAllocationUnit * info.BytesPerSector; 1748 551ef365 Rein K*1749 if( GetVersion() & 0x80000000) { /* win3.x, 9x, ME */ 1750 /* cap the size and available at 2GB as per specs */ 1751 if (info.TotalAllocationUnits.QuadPart * units > 0x7fffffff) { 1752 info.TotalAllocationUnits.QuadPart = 0x7fffffff / units; 1753 if (info.AvailableAllocationUnits.QuadPart * units > 0x7fffffff) 1754 info.AvailableAllocationUnits.QuadPart = 0x7fffffff / units; 1755 } 1756 /* nr. of clusters is always <= 65335 */ 1757 while( info.TotalAllocationUnits.QuadPart > 65535 ) { 1758 info.TotalAllocationUnits.QuadPart /= 2; 1759 info.AvailableAllocationUnits.QuadPart /= 2; 1760 info.SectorsPerAllocationUnit *= 2; 1761 } 1762 } d1051870 Alexan*1763 1764 if (cluster_sectors) *cluster_sectors = info.SectorsPerAllocationUnit; 1765 if (sector_bytes) *sector_bytes = info.BytesPerSector; 1766 if (free_clusters) *free_clusters = info.AvailableAllocationUnits.u.LowPart; 1767 if (total_clusters) *total_clusters = info.TotalAllocationUnits.u.LowPart; 729afb18 Austin*1768 TRACE("%#08x, %#08x, %#08x, %#08x\n", info.SectorsPerAllocationUnit, info.BytesPerSector, 1769 info.AvailableAllocationUnits.u.LowPart, info.TotalAllocationUnits.u.LowPart); d1051870 Alexan*1770 return TRUE; 1771 } 1772 1773 1774 /*********************************************************************** 1775 * GetDiskFreeSpaceA (KERNEL32.@) 1776 */ 1777 BOOL WINAPI GetDiskFreeSpaceA( LPCSTR root, LPDWORD cluster_sectors, 1778 LPDWORD sector_bytes, LPDWORD free_clusters, 1779 LPDWORD total_clusters ) 1780 { 0d33e5e3 Alexan*1781 WCHAR *rootW = NULL; d1051870 Alexan*1782 0d33e5e3 Alexan*1783 if (root && !(rootW = FILE_name_AtoW( root, FALSE ))) return FALSE; 1784 return GetDiskFreeSpaceW( rootW, cluster_sectors, sector_bytes, free_clusters, total_clusters ); d1051870 Alexan*1785 } 590aaaf4 Marcus*1786 1787 /*********************************************************************** 1788 * GetVolumePathNameA (KERNEL32.@) 1789 */ 1790 BOOL WINAPI GetVolumePathNameA(LPCSTR filename, LPSTR volumepathname, DWORD buflen) 1791 { 9b9d8dc3 Hans L*1792 BOOL ret; 3465646d Bruno *1793 WCHAR *filenameW = NULL, *volumeW = NULL; 9b9d8dc3 Hans L*1794 f6c7e247 Erich *1795 TRACE("(%s, %p, %d)\n", debugstr_a(filename), volumepathname, buflen); 9b9d8dc3 Hans L*1796 3465646d Bruno *1797 if (filename && !(filenameW = FILE_name_AtoW( filename, FALSE ))) 1798 return FALSE; 1799 if (volumepathname && !(volumeW = HeapAlloc( GetProcessHeap(), 0, buflen * sizeof(WCHAR) ))) 1800 return FALSE; 9b9d8dc3 Hans L*1801 1802 if ((ret = GetVolumePathNameW( filenameW, volumeW, buflen ))) 1803 FILE_name_WtoA( volumeW, -1, volumepathname, buflen ); 1804 1805 HeapFree( GetProcessHeap(), 0, volumeW ); 1806 return ret; 590aaaf4 Marcus*1807 } 1808
https://bugs.winehq.org/show_bug.cgi?id=43947
--- Comment #6 from Christoph Heilmann christoph.heilmann@gmx.de --- This seems to be the corresponding Linux statfs() call for NtQueryVolumeInformationFile():
3197 #if !defined(linux) || !defined(HAVE_FSTATFS) 3198 struct statvfs stfs; 3199 3200 if (fstatvfs( fd, &stfs ) < 0) 3201 { 3202 io->u.Status = FILE_GetNtStatus(); 3203 break; 3204 } b0192cfed Alexa*3205 bsize = stfs.f_frsize; 3058548eb Rein *3206 #else 3207 struct statfs stfs; 3208 if (fstatfs( fd, &stfs ) < 0) 3209 { 3210 io->u.Status = FILE_GetNtStatus(); 3211 break; 3212 } b0192cfed Alexa*3213 bsize = stfs.f_bsize; 3058548eb Rein *3214 #endif 4d958a1cb Alexa*3215 if (bsize == 2048) /* assume CD-ROM */ 3216 { 3217 info->BytesPerSector = 2048; 3218 info->SectorsPerAllocationUnit = 1; 3219 } 3220 else 3221 { 3222 info->BytesPerSector = 512; 3223 info->SectorsPerAllocationUnit = 8; 3224 } 3225 info->TotalAllocationUnits.QuadPart = bsize * stfs.f_blocks / (info->BytesPerSector * info->SectorsPerAllocationUnit); 3226 info->AvailableAllocationUnits.QuadPart = bsize * stfs.f_bavail / (info->BytesPerSector * info->SectorsPerAllocationUnit); 01c5ef37c Alexa*3227 io->Information = sizeof(*info); 3228 io->u.Status = STATUS_SUCCESS; 3229 } 3230 }
https://bugs.winehq.org/show_bug.cgi?id=43947
--- Comment #7 from Christoph Heilmann christoph.heilmann@gmx.de --- Statfs seems to be ok:
root@:/opt/sources# ./statfs mounted on /: f_bsize: 4096 f_blocks: 117935160 f_bfree: 74453650 f_bavail: 68445446 f_files: 30023680 f_ffree: 29941883
It's a mystery. Maybe a developer could look at it?
https://bugs.winehq.org/show_bug.cgi?id=43947
--- Comment #8 from Ken Sharp imwellcushtymelike@gmail.com --- What file system are you using?
https://bugs.winehq.org/show_bug.cgi?id=43947
Alan A. grsfdhj@tiscali.it changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |grsfdhj@tiscali.it
--- Comment #9 from Alan A. grsfdhj@tiscali.it --- I think I see this too with multiple recent wine versions, although with different "free space" numbers between versions (see screenshots).
These are the drive mappings, as in ~/.wine/dosdevices:
c: -> ../drive_c com1 -> /dev/ttyS0 com2 -> /dev/ttyS1 com3 -> /dev/ttyS2 com4 -> /dev/ttyS3 d:: -> /dev/sr0 e:: -> /dev/sdc f:: -> /dev/sde g: -> /run/media/alan/Cruzer g:: -> /dev/sdd1 h: -> /home/alan i:: -> /dev/sdd3 j:: -> /dev/sdd2 k:: -> /dev/sdd6 l:: -> /dev/sdd8 m:: -> /dev/sdd7 n: -> /run/media/alan/DATA n:: -> /dev/sdd5 o: -> /mnt/tmp o:: -> /dev/loop0 p:: -> /dev/sdd q:: -> /dev/sdb z: -> /
This is what "df -Th" reports for the relevant paths:
File system Type Dim. Used Avail. Use% Mounted on /dev/sda4 ext4 121G 111G 3,8G 97% /home /dev/sdb1 ext4 917G 851G 20G 98% /mnt/storage tmpfs tmpfs 16G 42M 16G 1% /tmp /dev/sda3 ext4 50G 42G 4,9G 90% / devtmpfs devtmpfs 16G 0 16G 0% /dev
https://bugs.winehq.org/show_bug.cgi?id=43947
--- Comment #10 from Alan A. grsfdhj@tiscali.it --- Created attachment 68332 --> https://bugs.winehq.org/attachment.cgi?id=68332 free disk space with wine-3.1
https://bugs.winehq.org/show_bug.cgi?id=43947
--- Comment #11 from Alan A. grsfdhj@tiscali.it --- Created attachment 68333 --> https://bugs.winehq.org/attachment.cgi?id=68333 free disk space with wine-5.10
https://bugs.winehq.org/show_bug.cgi?id=43947
--- Comment #12 from Alan A. grsfdhj@tiscali.it --- Created attachment 68334 --> https://bugs.winehq.org/attachment.cgi?id=68334 free disk space with wine-staging-5.18
https://bugs.winehq.org/show_bug.cgi?id=43947
--- Comment #13 from Alan A. grsfdhj@tiscali.it --- I think I found something while trying to debug the issue at hand: the "dir" command used in wineconsole reports the correct free disk space for the given path, while the explorer command does not.
Could be a wine explorer bug.
https://bugs.winehq.org/show_bug.cgi?id=43947
--- Comment #14 from Alan A. grsfdhj@tiscali.it --- Looked into it a bit more. I think the culprit is the "ISF_MyComputer_fnGetDetailsOf" function, where there's also a FIXME note above that says "FIXME: drive size >4GB is rolling over". I'm still not able to properly debug that code with gdb to better understand what it does, but I guess that the "4GB capping" could be due to calling "StrFormatByteSizeA" on "ulBytes.u.LowPart", which should be only a part of the result from "GetDiskFreeSpaceExA". This seems different to what the "dir" command does in wineconsole, as it just calls "WCMD_filesize64 (freebytes.QuadPart)", considering all the bytes inside the union instead of only a part of them.
https://bugs.winehq.org/show_bug.cgi?id=43947
--- Comment #15 from Alan A. grsfdhj@tiscali.it --- Created attachment 68362 --> https://bugs.winehq.org/attachment.cgi?id=68362 first fix for wrong disk sizes
This patch fixes the problem on my system by assuming that what `GetDiskFreeSpaceExA` returns could be a ULONGLONG and then invoking `StrFormatByteSize64A` instead of `StrFormatByteSizeA`. Turns out that the "4Gib capping" seems due to only passing to the `StrFormatByteSizeA` function the `LowPart` (which is a single DWORD/int32) part of the `ulBytes` variable.
This is just a first try at solving the problem, though. I don't know if a proper check should be put in place to prefer the `StrFormatByteSizeA` function if the size argument is not > 4GiB.