iso9660 fs driver bugfix + code refactoring
Signed-off-by: Matt Madia <[email protected]>
This commit is contained in:
committed by
Matt Madia
parent
21406bd896
commit
723f4b6a43
@@ -144,7 +144,7 @@ sanitize_iso_name(iso9660_inode* node, bool removeTrailingPoints)
|
||||
static int
|
||||
init_volume_date(ISOVolDate *date, char *buffer)
|
||||
{
|
||||
memcpy(date, buffer, 17);
|
||||
memcpy(date, buffer, ISO_VOL_DATE_SIZE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ init_volume_date(ISOVolDate *date, char *buffer)
|
||||
static int
|
||||
init_node_date(ISORecDate *date, char *buffer)
|
||||
{
|
||||
memcpy(date, buffer, 7);
|
||||
memcpy(date, buffer, sizeof(struct ISORecDate));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -162,121 +162,138 @@ InitVolDesc(iso9660_volume *volume, char *buffer)
|
||||
{
|
||||
TRACE(("InitVolDesc - ENTER\n"));
|
||||
|
||||
volume->volDescType = *(uint8 *)buffer++;
|
||||
|
||||
volume->stdIDString[5] = '\0';
|
||||
strncpy(volume->stdIDString, buffer, 5);
|
||||
buffer += 5;
|
||||
volume->volDescType = *(uint8 *)buffer;
|
||||
buffer += sizeof(volume->volDescType);
|
||||
|
||||
const size_t kStdIDStringLen = sizeof(volume->stdIDString) - 1;
|
||||
volume->stdIDString[kStdIDStringLen] = '\0';
|
||||
strncpy(volume->stdIDString, buffer, kStdIDStringLen);
|
||||
buffer += kStdIDStringLen;
|
||||
|
||||
volume->volDescVersion = *(uint8 *)buffer;
|
||||
buffer += 2; // 8th byte unused
|
||||
buffer += sizeof(volume->volDescVersion);
|
||||
|
||||
buffer += sizeof(volume->unused1); // skip unused 8th byte
|
||||
|
||||
volume->systemIDString[32] = '\0';
|
||||
strncpy(volume->systemIDString, buffer, 32);
|
||||
buffer += 32;
|
||||
const size_t kSystemIDStringLen = sizeof(volume->systemIDString) - 1;
|
||||
volume->systemIDString[kSystemIDStringLen] = '\0';
|
||||
strncpy(volume->systemIDString, buffer, kSystemIDStringLen);
|
||||
buffer += kSystemIDStringLen;
|
||||
TRACE(("InitVolDesc - system id string is %s\n", volume->systemIDString));
|
||||
|
||||
volume->volIDString[32] = '\0';
|
||||
strncpy(volume->volIDString, buffer, 32);
|
||||
buffer += (32 + 80-73 + 1); // bytes 80-73 unused
|
||||
|
||||
const size_t kVolIDStringLen = sizeof(volume->volIDString) - 1;
|
||||
volume->volIDString[kVolIDStringLen] = '\0';
|
||||
strncpy(volume->volIDString, buffer, kVolIDStringLen);
|
||||
buffer += kVolIDStringLen;
|
||||
TRACE(("InitVolDesc - volume id string is %s\n", volume->volIDString));
|
||||
|
||||
volume->volSpaceSize[LSB_DATA] = *(uint32 *)buffer;
|
||||
buffer += 4;
|
||||
volume->volSpaceSize[MSB_DATA] = *(uint32 *)buffer;
|
||||
buffer+= (4 + 120-89 + 1); // bytes 120-89 unused
|
||||
buffer += sizeof(volume->unused2) - 1; // skip unused 73-80 bytes
|
||||
|
||||
volume->volSpaceSize[LSB_DATA] = *(uint32 *)buffer;
|
||||
buffer += sizeof(volume->volSpaceSize[LSB_DATA]);
|
||||
volume->volSpaceSize[MSB_DATA] = *(uint32 *)buffer;
|
||||
buffer += sizeof(volume->volSpaceSize[MSB_DATA]);
|
||||
|
||||
buffer += sizeof(volume->unused3) - 1; // skip unused 89-120 bytes
|
||||
|
||||
volume->volSetSize[LSB_DATA] = *(uint16*)buffer;
|
||||
buffer += 2;
|
||||
buffer += sizeof(volume->volSetSize[LSB_DATA]);
|
||||
volume->volSetSize[MSB_DATA] = *(uint16*)buffer;
|
||||
buffer += 2;
|
||||
buffer += sizeof(volume->volSetSize[MSB_DATA]);
|
||||
|
||||
volume->volSeqNum[LSB_DATA] = *(uint16*)buffer;
|
||||
buffer += 2;
|
||||
buffer += sizeof(volume->volSeqNum[LSB_DATA]);
|
||||
volume->volSeqNum[MSB_DATA] = *(uint16*)buffer;
|
||||
buffer += 2;
|
||||
buffer += sizeof(volume->volSeqNum[MSB_DATA]);
|
||||
|
||||
volume->logicalBlkSize[LSB_DATA] = *(uint16*)buffer;
|
||||
buffer += 2;
|
||||
buffer += sizeof(volume->logicalBlkSize[LSB_DATA]);
|
||||
volume->logicalBlkSize[MSB_DATA] = *(uint16*)buffer;
|
||||
buffer += 2;
|
||||
buffer += sizeof(volume->logicalBlkSize[MSB_DATA]);
|
||||
|
||||
volume->pathTblSize[LSB_DATA] = *(uint32*)buffer;
|
||||
buffer += 4;
|
||||
buffer += sizeof(volume->pathTblSize[LSB_DATA]);
|
||||
volume->pathTblSize[MSB_DATA] = *(uint32*)buffer;
|
||||
buffer += 4;
|
||||
buffer += sizeof(volume->pathTblSize[MSB_DATA]);
|
||||
|
||||
volume->lPathTblLoc[LSB_DATA] = *(uint16*)buffer;
|
||||
buffer += 2;
|
||||
buffer += sizeof(volume->lPathTblLoc[LSB_DATA]);
|
||||
volume->lPathTblLoc[MSB_DATA] = *(uint16*)buffer;
|
||||
buffer += 2;
|
||||
buffer += sizeof(volume->lPathTblLoc[MSB_DATA]);
|
||||
|
||||
volume->optLPathTblLoc[LSB_DATA] = *(uint16*)buffer;
|
||||
buffer += 2;
|
||||
buffer += sizeof(volume->optLPathTblLoc[LSB_DATA]);
|
||||
volume->optLPathTblLoc[MSB_DATA] = *(uint16*)buffer;
|
||||
buffer += 2;
|
||||
buffer += sizeof(volume->optLPathTblLoc[MSB_DATA]);
|
||||
|
||||
volume->mPathTblLoc[LSB_DATA] = *(uint16*)buffer;
|
||||
buffer += 2;
|
||||
buffer += sizeof(volume->mPathTblLoc[LSB_DATA]);
|
||||
volume->mPathTblLoc[MSB_DATA] = *(uint16*)buffer;
|
||||
buffer += 2;
|
||||
buffer += sizeof(volume->mPathTblLoc[MSB_DATA]);
|
||||
|
||||
volume->optMPathTblLoc[LSB_DATA] = *(uint16*)buffer;
|
||||
buffer += 2;
|
||||
buffer += sizeof(volume->optMPathTblLoc[LSB_DATA]);
|
||||
volume->optMPathTblLoc[MSB_DATA] = *(uint16*)buffer;
|
||||
buffer += 2;
|
||||
buffer += sizeof(volume->optMPathTblLoc[MSB_DATA]);
|
||||
|
||||
// Fill in directory record.
|
||||
volume->joliet_level = 0;
|
||||
InitNode(volume, &volume->rootDirRec, buffer, NULL);
|
||||
|
||||
volume->rootDirRec.id = ISO_ROOTNODE_ID;
|
||||
buffer += 34;
|
||||
|
||||
volume->volSetIDString[128] = '\0';
|
||||
strncpy(volume->volSetIDString, buffer, 128);
|
||||
buffer += 128;
|
||||
buffer += ISO_ROOT_DIR_REC_SIZE;
|
||||
|
||||
const size_t kVolSetIDStringLen = sizeof(volume->volSetIDString) - 1;
|
||||
volume->volSetIDString[kVolSetIDStringLen] = '\0';
|
||||
strncpy(volume->volSetIDString, buffer, kVolSetIDStringLen);
|
||||
buffer += kVolSetIDStringLen;
|
||||
TRACE(("InitVolDesc - volume set id string is %s\n", volume->volSetIDString));
|
||||
|
||||
volume->pubIDString[128] = '\0';
|
||||
strncpy(volume->pubIDString, buffer, 128);
|
||||
buffer += 128;
|
||||
const size_t kPubIDStringLen = sizeof(volume->pubIDString) - 1;
|
||||
volume->pubIDString[kPubIDStringLen] = '\0';
|
||||
strncpy(volume->pubIDString, buffer, kPubIDStringLen);
|
||||
buffer += kPubIDStringLen;
|
||||
TRACE(("InitVolDesc - volume pub id string is %s\n", volume->pubIDString));
|
||||
|
||||
volume->dataPreparer[128] = '\0';
|
||||
strncpy(volume->dataPreparer, buffer, 128);
|
||||
buffer += 128;
|
||||
const size_t kDataPreparerLen = sizeof(volume->dataPreparer) - 1;
|
||||
volume->dataPreparer[kDataPreparerLen] = '\0';
|
||||
strncpy(volume->dataPreparer, buffer, kDataPreparerLen);
|
||||
buffer += kDataPreparerLen;
|
||||
TRACE(("InitVolDesc - volume dataPreparer string is %s\n", volume->dataPreparer));
|
||||
|
||||
volume->appIDString[128] = '\0';
|
||||
strncpy(volume->appIDString, buffer, 128);
|
||||
buffer += 128;
|
||||
const size_t kAppIDStringLen = sizeof(volume->appIDString) - 1;
|
||||
volume->appIDString[kAppIDStringLen] = '\0';
|
||||
strncpy(volume->appIDString, buffer, kAppIDStringLen);
|
||||
buffer += kAppIDStringLen;
|
||||
TRACE(("InitVolDesc - volume app id string is %s\n", volume->appIDString));
|
||||
|
||||
volume->copyright[38] = '\0';
|
||||
strncpy(volume->copyright, buffer, 38);
|
||||
buffer += 38;
|
||||
const size_t kCopyrightLen = sizeof(volume->copyright) - 1;
|
||||
volume->copyright[kCopyrightLen] = '\0';
|
||||
strncpy(volume->copyright, buffer, kCopyrightLen);
|
||||
buffer += kCopyrightLen;
|
||||
TRACE(("InitVolDesc - copyright is %s\n", volume->copyright));
|
||||
|
||||
volume->abstractFName[38] = '\0';
|
||||
strncpy(volume->abstractFName, buffer, 38);
|
||||
buffer += 38;
|
||||
const size_t kAbstractFNameLen = sizeof(volume->abstractFName) - 1;
|
||||
volume->abstractFName[kAbstractFNameLen] = '\0';
|
||||
strncpy(volume->abstractFName, buffer, kAbstractFNameLen);
|
||||
buffer += kAbstractFNameLen;
|
||||
|
||||
volume->biblioFName[38] = '\0';
|
||||
strncpy(volume->biblioFName, buffer, 38);
|
||||
buffer += 38;
|
||||
const size_t kBiblioFNameLen = sizeof(volume->biblioFName) - 1;
|
||||
volume->biblioFName[kBiblioFNameLen] = '\0';
|
||||
strncpy(volume->biblioFName, buffer, kBiblioFNameLen);
|
||||
buffer += kBiblioFNameLen;
|
||||
|
||||
init_volume_date(&volume->createDate, buffer);
|
||||
buffer += 17;
|
||||
buffer += ISO_VOL_DATE_SIZE;
|
||||
|
||||
init_volume_date(&volume->modDate, buffer);
|
||||
buffer += 17;
|
||||
buffer += ISO_VOL_DATE_SIZE;
|
||||
|
||||
init_volume_date(&volume->expireDate, buffer);
|
||||
buffer += 17;
|
||||
buffer += ISO_VOL_DATE_SIZE;
|
||||
|
||||
init_volume_date(&volume->effectiveDate, buffer);
|
||||
buffer += 17;
|
||||
buffer += ISO_VOL_DATE_SIZE;
|
||||
|
||||
volume->fileStructVers = *(uint8*)buffer;
|
||||
return B_OK;
|
||||
|
||||
@@ -56,6 +56,9 @@ typedef struct ISOVolDate {
|
||||
int8 offsetGMT;
|
||||
} ISOVolDate;
|
||||
|
||||
// Size of volume date and time data
|
||||
#define ISO_VOL_DATE_SIZE 17
|
||||
|
||||
typedef struct ISORecDate {
|
||||
uint8 year; // Year - 1900
|
||||
uint8 month;
|
||||
@@ -183,28 +186,28 @@ struct iso9660_volume {
|
||||
uint8 volDescType; // Volume Descriptor type byte1
|
||||
char stdIDString[6]; // Standard ID, 1 extra for null byte2-6
|
||||
uint8 volDescVersion; // Volume Descriptor version byte7
|
||||
// 8th byte unused
|
||||
uint8 unused1; // Unused Field byte8
|
||||
char systemIDString[33]; // System ID, 1 extra for null byte9-40
|
||||
char volIDString[33]; // Volume ID, 1 extra for null byte41-72
|
||||
// bytes 73-80 unused
|
||||
uint32 volSpaceSize[2]; // #logical blocks, lsb and msb byte81-88
|
||||
// bytes 89-120 unused
|
||||
char unused2[9]; // Unused Field byte73-80
|
||||
uint32 volSpaceSize[2]; // #logical blocks, lsb and msb byte81-88
|
||||
char unused3[33]; // Unused Field byte89-120
|
||||
uint16 volSetSize[2]; // Assigned Volume Set Size of Vol byte121-124
|
||||
uint16 volSeqNum[2]; // Ordinal number of volume in Set byte125-128
|
||||
uint16 logicalBlkSize[2]; // Logical blocksize, usually 2048 byte129-132
|
||||
uint32 pathTblSize[2]; // Path table size byte133-149
|
||||
uint16 lPathTblLoc[2]; // Loc (Logical block #) of "Type L" path table byte141-144
|
||||
uint16 optLPathTblLoc[2]; // Loc (Logical block #) of optional Type L path tbl byte145-148
|
||||
uint16 mPathTblLoc[2]; // Loc (Logical block #) of "Type M" path table byte149-152
|
||||
uint16 optMPathTblLoc[2]; // Loc (Logical block #) of optional Type M path tbl byte153-156
|
||||
iso9660_inode rootDirRec; // Directory record for root directory byte157-190
|
||||
uint16 lPathTblLoc[2]; // Loc (Logical block #) of "Type L" path table byte141-144
|
||||
uint16 optLPathTblLoc[2]; // Loc (Logical block #) of optional Type L path tbl byte145-148
|
||||
uint16 mPathTblLoc[2]; // Loc (Logical block #) of "Type M" path table byte149-152
|
||||
uint16 optMPathTblLoc[2]; // Loc (Logical block #) of optional Type M path tbl byte153-156
|
||||
iso9660_inode rootDirRec; // Directory record for root directory byte157-190
|
||||
char volSetIDString[129]; // Name of multi-volume set where vol is member byte191-318
|
||||
char pubIDString[129]; // Name of publisher byte319-446
|
||||
char dataPreparer[129]; // Name of data preparer byte447-574
|
||||
char appIDString[129]; // Identifies data fomrat byte575-702
|
||||
char copyright[38]; // Copyright string byte703-739
|
||||
char abstractFName[38]; // Name of file in root that has abstract byte740-776
|
||||
char biblioFName[38]; // Name of file in root that has biblio byte777-813
|
||||
char biblioFName[38]; // Name of file in root that has biblio byte777-813
|
||||
|
||||
ISOVolDate createDate; // Creation date byte
|
||||
ISOVolDate modDate; // Modification date
|
||||
@@ -214,6 +217,8 @@ struct iso9660_volume {
|
||||
uint8 fileStructVers; // File structure version byte882
|
||||
};
|
||||
|
||||
// Size of root directory record
|
||||
#define ISO_ROOT_DIR_REC_SIZE 34
|
||||
|
||||
status_t ISOMount(const char *path, uint32 flags, iso9660_volume** _newVolume,
|
||||
bool allowJoliet);
|
||||
|
||||
Reference in New Issue
Block a user