[Bug 43947] Disk size in Wine is not correct
wine-bugs at winehq.org
wine-bugs at winehq.org
Thu Nov 2 13:25:06 CDT 2017
https://bugs.winehq.org/show_bug.cgi?id=43947
--- Comment #5 from Christoph Heilmann <christoph.heilmann at 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
--
Do not reply to this email, post in Bugzilla using the
above URL to reply.
You are receiving this mail because:
You are watching all bug changes.
More information about the wine-bugs
mailing list