Changeset 21567 for trunk/src/kernel32/disk.cpp
- Timestamp:
- Jan 28, 2011, 5:50:41 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/disk.cpp
r10560 r21567 90 90 TVFSTOHPFS = 1 91 91 */ 92 if(lpSectorsPerCluster!=NULL) 92 if(lpSectorsPerCluster!=NULL) 93 93 { 94 if(*lpSectorsPerCluster==1024 && PROFILE_GetOdinIniBool("DRIVESPACE","CLUSTERTO32",0)) 94 if(*lpSectorsPerCluster==1024 && PROFILE_GetOdinIniBool("DRIVESPACE","CLUSTERTO32",0)) 95 95 {/* TVFS returns 1024 sectors per cluster */ 96 96 dprintf(("KERNEL32: GetDiskFreeSpaceA, TVFS-Drive detected. Faking clustersize to 32.\n")); … … 231 231 else { 232 232 //Volume functions only available in Windows 2000 and up 233 if(VERSION_IS_WIN2000_OR_HIGHER() && !strncmp(lpszDrive, VOLUME_NAME_PREFIX, sizeof(VOLUME_NAME_PREFIX)-1)) 233 if(VERSION_IS_WIN2000_OR_HIGHER() && !strncmp(lpszDrive, VOLUME_NAME_PREFIX, sizeof(VOLUME_NAME_PREFIX)-1)) 234 234 { 235 235 char *pszVolume; … … 240 240 pszVolume = (char *)alloca(length); 241 241 242 if(OSLibLVMStripVolumeName(lpszDrive, pszVolume, length)) 242 if(OSLibLVMStripVolumeName(lpszDrive, pszVolume, length)) 243 243 { 244 244 rc = OSLibLVMGetDriveType(pszVolume); … … 311 311 else { 312 312 //Volume functions only available in Windows 2000 and up 313 if(LOBYTE(GetVersion()) >= 5 && !strncmp(lpRootPathName, VOLUME_NAME_PREFIX, sizeof(VOLUME_NAME_PREFIX)-1)) 313 if(LOBYTE(GetVersion()) >= 5 && !strncmp(lpRootPathName, VOLUME_NAME_PREFIX, sizeof(VOLUME_NAME_PREFIX)-1)) 314 314 { 315 315 int length; … … 319 319 pszVolume = (char *)alloca(length); 320 320 321 if(OSLibLVMStripVolumeName(lpRootPathName, pszVolume, length)) 321 if(OSLibLVMStripVolumeName(lpRootPathName, pszVolume, length)) 322 322 { 323 323 pszVolume[length-2] = 0; … … 343 343 } 344 344 } 345 if(lpFileSystemNameBuffer || lpMaximumComponentLength || lpFileSystemFlags) 345 if(lpFileSystemNameBuffer || lpMaximumComponentLength || lpFileSystemFlags) 346 346 { 347 347 if(!lpFileSystemNameBuffer || (nFileSystemNameSize == 0)) { … … 357 357 if(rc == ERROR_SUCCESS) strcpy(szOrgFileSystemName, lpFileSystemNameBuffer); 358 358 359 if(lpFileSystemNameBuffer) 359 if(lpFileSystemNameBuffer) 360 360 { 361 361 dprintf2(("File system name: %s", lpFileSystemNameBuffer)); 362 if(!strcmp(lpFileSystemNameBuffer, "JFS")) 362 if(!strcmp(lpFileSystemNameBuffer, "JFS")) 363 363 { 364 364 strncpy(lpFileSystemNameBuffer, "NTFS", nFileSystemNameSize); … … 372 372 //do nothing 373 373 } 374 else 374 else 375 375 {//pretend everything else is FAT16 (HPFS and FAT have the same file size limit) 376 376 // @@VP:20040323 - nFileSystemNameSize may be 0!!! … … 379 379 if(fForce2GBFileSize) { 380 380 if(strcmp(lpFileSystemNameBuffer, "CDFS") && 381 strcmp(lpFileSystemNameBuffer, "UDF")) 381 strcmp(lpFileSystemNameBuffer, "UDF")) 382 382 {//everything is FAT -> 2 GB file size limit 383 383 strncpy(lpFileSystemNameBuffer, "FAT16", nFileSystemNameSize); … … 565 565 //****************************************************************************** 566 566 //****************************************************************************** 567 BOOL WIN32API FindNextVolumeA(HANDLE hFindVolume, LPTSTR lpszVolumeName, 567 BOOL WIN32API FindNextVolumeA(HANDLE hFindVolume, LPTSTR lpszVolumeName, 568 568 DWORD cchBufferLength) 569 569 { … … 583 583 return FALSE; 584 584 } 585 if(OSLibLVMQueryVolumeName(pVolInfo->hLVMVolumeControlData, &pVolInfo->lastvol, 585 if(OSLibLVMQueryVolumeName(pVolInfo->hLVMVolumeControlData, &pVolInfo->lastvol, 586 586 szVolume, sizeof(szVolume)) == FALSE) { 587 587 SetLastError(ERROR_NO_MORE_FILES); … … 603 603 //****************************************************************************** 604 604 //****************************************************************************** 605 BOOL WIN32API FindNextVolumeW(HANDLE hFindVolume, LPWSTR lpszVolumeName, 605 BOOL WIN32API FindNextVolumeW(HANDLE hFindVolume, LPWSTR lpszVolumeName, 606 606 DWORD cchBufferLength) 607 607 { … … 646 646 //****************************************************************************** 647 647 //****************************************************************************** 648 HANDLE WIN32API FindFirstVolumeMountPointA(LPTSTR lpszRootPathName, 648 HANDLE WIN32API FindFirstVolumeMountPointA(LPTSTR lpszRootPathName, 649 649 LPTSTR lpszVolumeMountPoint, 650 650 DWORD cchBufferLength) … … 654 654 return INVALID_HANDLE_VALUE; 655 655 } 656 656 657 657 SetLastError(ERROR_NO_MORE_FILES); 658 658 return INVALID_HANDLE_VALUE; … … 660 660 //****************************************************************************** 661 661 //****************************************************************************** 662 HANDLE WIN32API FindFirstVolumeMountPointW(LPWSTR lpszRootPathName, 662 HANDLE WIN32API FindFirstVolumeMountPointW(LPWSTR lpszRootPathName, 663 663 LPWSTR lpszVolumeMountPoint, 664 664 DWORD cchBufferLength) … … 761 761 } 762 762 763 if(OSLibLVMGetVolumeNameForVolumeMountPoint(lpszVolumeMountPoint, pszvol, 764 cchBufferLength) == TRUE) 763 if(OSLibLVMGetVolumeNameForVolumeMountPoint(lpszVolumeMountPoint, pszvol, 764 cchBufferLength) == TRUE) 765 765 { 766 766 int length = strlen(pszvol); … … 771 771 sprintf(lpszVolumeName, VOLUME_NAME_PREFIX"{%s}\\", pszvol); 772 772 773 dprintf((" GetVolumeNameForVolumeMountPointA %s returned %s", lpszVolumeMountPoint, lpszVolumeName));773 dprintf(("KERNEL32: GetVolumeNameForVolumeMountPointA %s returned %s", lpszVolumeMountPoint, lpszVolumeName)); 774 774 SetLastError(ERROR_SUCCESS); 775 775 return TRUE; 776 776 } 777 dprintf((" GetVolumeNameForVolumeMountPointA: %s not found!!", lpszVolumeMountPoint));777 dprintf(("KERNEL32: GetVolumeNameForVolumeMountPointA: %s not found!!", lpszVolumeMountPoint)); 778 778 SetLastError(ERROR_FILE_NOT_FOUND); 779 779 return FALSE; … … 810 810 //****************************************************************************** 811 811 //****************************************************************************** 812 BOOL WIN32API GetVolumePathNameA(LPCSTR lpszFileName, 813 LPSTR lpszVolumePathName, 814 DWORD cchBufferLength) 815 { 816 if(!VERSION_IS_WIN2000_OR_HIGHER()) { 817 SetLastError(ERROR_NOT_SUPPORTED); 818 return FALSE; 819 } 820 821 if(!*lpszFileName) { 822 // According to MSDN: 823 SetLastError(ERROR_SUCCESS); 824 return FALSE; 825 } 826 827 // We only support drive letters as volume names 828 if(cchBufferLength < 3) { 829 SetLastError(ERROR_INSUFFICIENT_BUFFER); 830 return FALSE; 831 } 832 833 CHAR fullName[MAX_PATH]; 834 DWORD rc = GetFullPathNameA(lpszFileName, sizeof(fullName), fullName, NULL); 835 if (rc == 0 || rc > sizeof(fullName)) 836 return FALSE; 837 838 if(fullName[0] == '\\' && fullName[1] == '\\') { 839 // UNC path, search for the 2nd single slash: we should return "\\foo\bar\" 840 LPSTR slash1 = strchr(&fullName[2], '\\'); 841 if(!slash1 || slash1 - fullName == 2) { 842 SetLastError(ERROR_INVALID_NAME); 843 return FALSE; 844 } 845 LPSTR slash2 = strchr(slash1 + 1, '\\'); 846 if(!slash2 || slash2 - slash1 == 1) { 847 SetLastError(ERROR_INVALID_NAME); 848 return FALSE; 849 } 850 DWORD len = slash2 - fullName + 1; // with trailing slash 851 if(cchBufferLength < len + 1) { 852 SetLastError(ERROR_INSUFFICIENT_BUFFER); 853 return FALSE; 854 } 855 memcpy(lpszVolumePathName, fullName, len); 856 lpszVolumePathName[len] = '\0'; 857 } else { 858 lpszVolumePathName[0] = fullName[0]; 859 lpszVolumePathName[1] = ':'; 860 if(cchBufferLength == 3) { 861 lpszVolumePathName[2] = '\0'; 862 } else { 863 lpszVolumePathName[2] = '\\'; 864 lpszVolumePathName[3] = '\0'; 865 } 866 } 867 868 dprintf(("KERNEL32: GetVolumePathNameA %s returned %s", lpszFileName, lpszVolumePathName)); 869 SetLastError(ERROR_SUCCESS); 870 return TRUE; 871 } 872 //****************************************************************************** 873 //****************************************************************************** 874 BOOL WIN32API GetVolumePathNameW(LPCWSTR lpszFileName, 875 LPWSTR lpszVolumePathName, 876 DWORD cchBufferLength) 877 { 878 LPSTR lpszFileNameA = NULL; 879 LPSTR lpszVolumePathNameA = NULL; 880 BOOL ret; 881 int len; 882 883 if(!VERSION_IS_WIN2000_OR_HIGHER()) { 884 SetLastError(ERROR_NOT_SUPPORTED); 885 return FALSE; 886 } 887 len = WideCharToMultiByte( CP_ACP, 0, lpszFileName, -1, NULL, 0, 0, NULL); 888 lpszFileNameA = (char *)alloca(len+1); 889 WideCharToMultiByte(CP_ACP, 0, lpszFileName, -1, lpszFileNameA, len, 0, NULL); 890 891 if(cchBufferLength && lpszVolumePathName) { 892 lpszVolumePathNameA = (char *)alloca(cchBufferLength); 893 } 894 ret = GetVolumePathNameA(lpszFileNameA, lpszVolumePathNameA, cchBufferLength); 895 if(ret) { 896 int len = MultiByteToWideChar( CP_ACP, 0, lpszVolumePathNameA, -1, NULL, 0); 897 MultiByteToWideChar(CP_ACP, 0, lpszVolumePathNameA, -1, lpszVolumePathName, len); 898 } 899 return ret; 900 } 901 //****************************************************************************** 902 //******************************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.