Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: trunk/xbmc/Application.cpp
- ===================================================================
- --- trunk/xbmc/Application.cpp (revision 30397)
- +++ trunk/xbmc/Application.cpp (working copy)
- @@ -894,15 +894,35 @@
- if (CIoSupport::HasPartitionTable())
- {
- // Mount up to Partition15 (drive O:) if they are available.
- - for (int i=EXTEND_PARTITION_BEGIN; i <= EXTEND_PARTITION_END; i++)
- + PARTITION_SIZES psizes;
- + memcpy (&psizes,CIoSupport::GetPartitionSizes(),sizeof(PARTITION_SIZES));
- +
- + for (int i=EXTEND_PARTITION_BEGIN; i <= (EXTEND_PARTITION_BEGIN+EXTEND_PARTITIONS_LIMIT-1); i++)
- {
- char szDevice[32];
- if (CIoSupport::PartitionExists(i))
- {
- - char cDriveLetter = 'A' + i - 1;
- - sprintf(szDevice, "Harddisk0\\Partition%u", i);
- + if (CIoSupport::GetPartitionClusterSize(i-1)>0 && (psizes[i-1]>=LBASIZE_512GB && CIoSupport::GetPartitionClusterSize(i)<64)||
- + (psizes[i-1]>=LBASIZE_256GB && CIoSupport::GetPartitionClusterSize(i)<32))
- + {
- + char cDriveLetter = 'A' + i - 1;
- +
- + char extendDriveLetter = CIoSupport::GetExtendedPartitionDriveLetter(cDriveLetter-EXTEND_DRIVE_BEGIN);
- + CLog::Log(LOGWARNING, " extended drive %c has wrong cluster size ", extendDriveLetter);
- +
- + }
- + else
- + {
- + char cDriveLetter = 'A' + i - 1;
- +
- + char extendDriveLetter = CIoSupport::GetExtendedPartitionDriveLetter(cDriveLetter-EXTEND_DRIVE_BEGIN);
- + CLog::Log(LOGNOTICE, " map extended drive %c:", extendDriveLetter);
- +
- + sprintf(szDevice, "Harddisk0\\Partition%u", i);
- - CIoSupport::RemapDriveLetter(cDriveLetter, szDevice);
- + CIoSupport::RemapDriveLetter(extendDriveLetter, szDevice);
- + // CIoSupport::RemapDriveLetter(cDriveLetter, szDevice);
- + }
- }
- }
- }
- Index: trunk/xbmc/MediaManager.cpp
- ===================================================================
- --- trunk/xbmc/MediaManager.cpp (revision 30397)
- +++ trunk/xbmc/MediaManager.cpp (working copy)
- @@ -111,16 +111,35 @@
- share.m_iDriveType = CMediaSource::SOURCE_TYPE_LOCAL;
- share.strName.Format(g_localizeStrings.Get(21438),'E');
- localDrives.push_back(share);
- - for (char driveletter=EXTEND_DRIVE_BEGIN; driveletter<=EXTEND_DRIVE_END; driveletter++)
- + //for (char driveletter=EXTEND_DRIVE_BEGIN; driveletter<=EXTEND_DRIVE_BEGIN+EXTEND_PARTITIONS_LIMIT; driveletter++)
- + for (int driveCount=EXTEND_PARTITION_BEGIN;driveCount<=(EXTEND_PARTITION_BEGIN+EXTEND_PARTITIONS_LIMIT-1);driveCount++)
- {
- - if (CIoSupport::DriveExists(driveletter))
- + if (CIoSupport::DriveExists(CIoSupport::GetExtendedPartitionDriveLetter(driveCount-EXTEND_PARTITION_BEGIN)))
- {
- CMediaSource share;
- - share.strPath.Format("%c:\\", driveletter);
- - share.strName.Format(g_localizeStrings.Get(21438),driveletter);
- - share.m_ignore = true;
- - localDrives.push_back(share);
- - }
- + PARTITION_SIZES psizes;
- + memcpy (&psizes,CIoSupport::GetPartitionSizes(),sizeof(PARTITION_SIZES));
- + if (CIoSupport::GetPartitionClusterSize(driveCount)!=0 && (psizes[driveCount-1]>=LBASIZE_512GB && CIoSupport::GetPartitionClusterSize(driveCount)<64)||
- + (psizes[driveCount-1]>=LBASIZE_256GB && CIoSupport::GetPartitionClusterSize(driveCount)<32))
- + {
- + share.m_iDriveType = CMediaSource::SOURCE_TYPE_UNKNOWN;
- + share.m_ignore = true;
- + share.strName.Format(g_localizeStrings.Get(21438),CIoSupport::GetExtendedPartitionDriveLetter(driveCount-EXTEND_PARTITION_BEGIN));
- + share.strPath.Format("%c:\\", CIoSupport::GetExtendedPartitionDriveLetter(driveCount-EXTEND_PARTITION_BEGIN));
- + CLog::Log(LOGWARNING, " Local Source Drive %c: wrong cluster size", CIoSupport::GetExtendedPartitionDriveLetter(driveCount-EXTEND_PARTITION_BEGIN));
- + localDrives.push_back(share);
- +
- + }
- + else
- + {
- + share.strPath.Format("%c:\\", CIoSupport::GetExtendedPartitionDriveLetter(driveCount-EXTEND_PARTITION_BEGIN));
- + CLog::Log(LOGNOTICE, " Local Source Drive %c:", CIoSupport::GetExtendedPartitionDriveLetter(driveCount-EXTEND_PARTITION_BEGIN));
- + share.strName.Format(g_localizeStrings.Get(21438),CIoSupport::GetExtendedPartitionDriveLetter(driveCount-EXTEND_PARTITION_BEGIN));
- + share.m_ignore = true;
- + localDrives.push_back(share);
- +
- + }
- + }
- }
- if (includeQ)
- {
- Index: trunk/xbmc/xbox/IoSupport.cpp
- ===================================================================
- --- trunk/xbmc/xbox/IoSupport.cpp (revision 30397)
- +++ trunk/xbmc/xbox/IoSupport.cpp (working copy)
- @@ -55,6 +55,11 @@
- { 'Y', "Harddisk0\\Partition4", 4},
- { 'Z', "Harddisk0\\Partition5", 5},
- };
- +char extendPartitionMapping[] =
- +{
- + 'F','G','R','S','V','W','A','B' // Bomb Bloke Partitioning scheme
- +};
- +
- #else
- stDriveMapping driveMapping[] =
- {
- @@ -169,11 +174,17 @@
- void CIoSupport::GetPartition(char cDriveLetter, char* szPartition)
- {
- char upperLetter = toupper(cDriveLetter);
- - if (upperLetter >= 'F' && upperLetter <= 'O')
- + if (ExtendedPartitionMappingExists(upperLetter))
- {
- - sprintf(szPartition, "Harddisk0\\Partition%u", upperLetter - 'A' + 1);
- - return;
- + sprintf(szPartition, "Harddisk0\\Partition%u", EXTEND_PARTITION_BEGIN+GetExtendedPartitionPosition(upperLetter));
- + CLog::Log(LOGNOTICE, "Partition %s", szPartition);
- + return;
- }
- + //if (upperLetter >= 'F' && upperLetter <= 'O')// to change
- + //{
- + // sprintf(szPartition, "Harddisk0\\Partition%u", upperLetter - 'A' + 1);
- + // return;
- + //}
- for (unsigned int i=0; i < NUM_OF_DRIVES; i++)
- if (driveMapping[i].cDriveLetter == upperLetter)
- {
- @@ -196,10 +207,11 @@
- part_num = atoi(szPartition + 19);
- - if (part_num >= 6)
- + if (part_num >= EXTEND_PARTITION_BEGIN) // EP changed
- {
- - *cDriveLetter = part_num + 'A' - 1;
- - return;
- + *cDriveLetter = extendPartitionMapping[part_num-EXTEND_PARTITION_BEGIN];
- + CLog::Log(LOGNOTICE, "Drive %c", *cDriveLetter);
- + return;
- }
- for (unsigned int i=0; i < NUM_OF_DRIVES; i++)
- if (strnicmp(driveMapping[i].szDevice, szPartition, strlen(driveMapping[i].szDevice)) == 0)
- @@ -537,7 +549,48 @@
- return (drivelist >> bitposition) & 1;
- #endif
- }
- +unsigned int CIoSupport::GetPartitionClusterSize(int nPartition)
- +{
- +#ifdef _XBOX
- + char szPartition[32];
- + ANSI_STRING part_string;
- + NTSTATUS status;
- + HANDLE hDisk;
- + OBJECT_ATTRIBUTES oa;
- + IO_STATUS_BLOCK iosb;
- + sprintf(szPartition, "\\Device\\Harddisk0\\Partition%u", nPartition);
- + RtlInitAnsiString(&part_string, szPartition);
- +
- + oa.Attributes = OBJ_CASE_INSENSITIVE;
- + oa.ObjectName = &part_string;
- + oa.RootDirectory = 0;
- +
- + status = NtOpenFile(&hDisk, GENERIC_READ | GENERIC_WRITE, &oa, &iosb, FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_SYNCHRONOUS_IO_ALERT);
- +
- + if (NT_SUCCESS(status))
- + {
- + BYTE PartSector[4096];
- + LARGE_INTEGER RWOffset;
- + FATX_SUPERBLOCK fsb;
- +
- + RWOffset.QuadPart = 0;
- + memset(PartSector, 0, sizeof(PartSector));
- +
- + status = NtReadFile(hDisk, NULL, NULL, NULL, &iosb, (PVOID) PartSector, sizeof(PartSector), &RWOffset);
- + if (!NT_SUCCESS(status))
- + return 0;
- + NtClose(hDisk);
- + memcpy (&fsb,PartSector,sizeof(PartSector));
- + return fsb.ClusterSize/2;
- +
- + }
- +#else
- + return 0;
- +#endif
- +
- +}
- +
- bool CIoSupport::PartitionExists(int nPartition)
- {
- #ifdef _XBOX
- @@ -632,6 +685,41 @@
- #endif
- }
- +PARTITION_SIZES * CIoSupport::GetPartitionSizes()
- +{
- + PARTITION_SIZES table;
- + for (int i=0;i<MAX_PARTITIONS;i++)
- + {
- + table[i] = m_partitionTable.pt_entries[i].pe_lba_size;
- + }
- + return &table;
- +}
- +bool CIoSupport::ExtendedPartitionMappingExists(char mapLetter)
- +{
- + int i;
- + for (i=0;i<EXTEND_PARTITIONS_LIMIT;i++)
- + {
- + if (mapLetter == extendPartitionMapping[i])
- + return true;
- + }
- + return false;
- +}
- +
- +INT CIoSupport::GetExtendedPartitionPosition(char mapLetter)
- +{
- + int i;
- + for (i=0;i<EXTEND_PARTITIONS_LIMIT;i++)
- + {
- + if (mapLetter == extendPartitionMapping[i])
- + return i;
- + }
- + return 0;
- +}
- +char CIoSupport::GetExtendedPartitionDriveLetter(int pos)
- +{
- + return extendPartitionMapping[pos];
- +}
- +
- bool CIoSupport::HasPartitionTable()
- {
- return m_fPartitionTableIsValid;
- @@ -644,16 +732,20 @@
- return;
- char szDevice[32] = "\\Harddisk0\\Partition0";
- char driveletter;
- + char extenddriveletter;
- +
- // we start at 5 - the first 5 partitions are the mandatory standard Xbox partitions
- // we don't deal with those here.
- - for (int i = EXTEND_PARTITION_BEGIN; i <= EXTEND_PARTITION_END; i++)
- + for (int i = EXTEND_PARTITION_BEGIN; i <= (EXTEND_PARTITION_BEGIN+EXTEND_PARTITIONS_LIMIT); i++)
- {
- if (m_partitionTable.pt_entries[i - 1].pe_flags & PE_PARTFLAGS_IN_USE)
- {
- driveletter = 'A' + i - 1;
- + extenddriveletter = extendPartitionMapping[driveletter-EXTEND_DRIVE_BEGIN];
- CLog::Log(LOGINFO, " map drive %c:", driveletter);
- + CLog::Log(LOGINFO, " map extended drive %c:", extenddriveletter);
- szDevice[20] = '1' + i - 1;
- - MapDriveLetter(driveletter, szDevice);
- + MapDriveLetter(extenddriveletter, szDevice);
- }
- }
- #endif
- Index: trunk/xbmc/xbox/IoSupport.h
- ===================================================================
- --- trunk/xbmc/xbox/IoSupport.h (revision 30397)
- +++ trunk/xbmc/xbox/IoSupport.h (working copy)
- @@ -51,6 +51,9 @@
- #define EXTEND_PARTITION_END 7
- #define EXTEND_DRIVE_BEGIN 'F'
- #define EXTEND_DRIVE_END 'G'
- +#define EXTEND_PARTITIONS_LIMIT 8
- +#define LBASIZE_512GB 1073741824
- +#define LBASIZE_256GB 536870912
- // This flag (part of PARTITION_ENTRY.pe_flags) tells you whether/not a
- // partition is being used (whether/not drive G is active, for example)
- @@ -87,6 +90,18 @@
- PARTITION_ENTRY pt_entries[MAX_PARTITIONS];
- } PARTITION_TABLE;
- +typedef unsigned long PARTITION_SIZES[MAX_PARTITIONS];
- +
- +typedef struct _FATX_SUPERBLOCK
- +{
- + char Tag[4];
- + unsigned int VolumeID;
- + unsigned int ClusterSize;
- + unsigned short FatCopies;
- + int Resvd;
- + char Unused[4078];
- +} FATX_SUPERBLOCK;
- +
- class CIoSupport
- {
- public:
- @@ -106,8 +121,14 @@
- static bool ReadPartitionTable();
- static bool HasPartitionTable();
- + static bool ExtendedPartitionMappingExists(char mapLetter);
- + static INT GetExtendedPartitionPosition(char mapLetter);
- + static char GetExtendedPartitionDriveLetter(int pos);
- + static unsigned int GetPartitionClusterSize(int nPartition);
- static void MapExtendedPartitions();
- + static PARTITION_SIZES * CIoSupport::GetPartitionSizes();
- +
- static LARGE_INTEGER GetDriveSize();
- static DWORD GetTrayState();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement