mirror of
https://github.com/aaru-dps/libaaruformat.git
synced 2025-12-16 19:24:40 +00:00
Implement media tag types.
This commit is contained in:
@@ -5,6 +5,6 @@ set(CMAKE_C_STANDARD 99)
|
|||||||
add_compile_definitions(__STDC_FORMAT_MACROS=1)
|
add_compile_definitions(__STDC_FORMAT_MACROS=1)
|
||||||
|
|
||||||
add_library(dicformat SHARED include/dicformat/consts.h include/dicformat/enums.h include/dic.h include/dicformat.h
|
add_library(dicformat SHARED include/dicformat/consts.h include/dicformat/enums.h include/dic.h include/dicformat.h
|
||||||
include/dicformat/decls.h include/dicformat/structs.h src/identify.c src/open.c include/dicformat/context.h src/close.c include/dicformat/errors.h src/read.c src/crc64.c src/cst.c src/ecc_cd.c)
|
include/dicformat/decls.h include/dicformat/structs.h src/identify.c src/open.c include/dicformat/context.h src/close.c include/dicformat/errors.h src/read.c src/crc64.c src/cst.c src/ecc_cd.c src/helpers.c)
|
||||||
|
|
||||||
include_directories(include include/dicformat)
|
include_directories(include include/dicformat)
|
||||||
@@ -1081,8 +1081,8 @@ typedef struct ImageInfo
|
|||||||
} ImageInfo;
|
} ImageInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
/// Metadata present for each sector (aka, "tag").
|
* Metadata present for each sector (aka, "tag").
|
||||||
/// */
|
*/
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
AppleSectorTag = 0,/** Apple's GCR sector tags, 12 bytes */
|
AppleSectorTag = 0,/** Apple's GCR sector tags, 12 bytes */
|
||||||
@@ -1102,6 +1102,86 @@ typedef enum
|
|||||||
MaxSectorTag = FloppyAddressMark
|
MaxSectorTag = FloppyAddressMark
|
||||||
} SectorTagType;
|
} SectorTagType;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Metadata present for each media.
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
/* CD table of contents */
|
||||||
|
CD_TOC = 0, /* CD session information */
|
||||||
|
CD_SessionInfo = 1, /* CD full table of contents */
|
||||||
|
CD_FullTOC = 2, /* CD PMA */
|
||||||
|
CD_PMA = 3, /* CD Adress-Time-In-Pregroove */
|
||||||
|
CD_ATIP = 4, /* CD-Text */
|
||||||
|
CD_TEXT = 5, /* CD Media Catalogue Number */
|
||||||
|
CD_MCN = 6, /* DVD/HD DVD Physical Format Information */
|
||||||
|
DVD_PFI = 7, /* DVD Lead-in Copyright Management Information */
|
||||||
|
DVD_CMI = 8, /* DVD disc key */
|
||||||
|
DVD_DiscKey = 9, /* DVD/HD DVD Burst Cutting Area */
|
||||||
|
DVD_BCA = 10, /* DVD/HD DVD Lead-in Disc Manufacturer Information */
|
||||||
|
DVD_DMI = 11, /* Media identifier */
|
||||||
|
DVD_MediaIdentifier = 12, /* Media key block */
|
||||||
|
DVD_MKB = 13, /* DVD-RAM/HD DVD-RAM DDS information */
|
||||||
|
DVDRAM_DDS = 14, /* DVD-RAM/HD DVD-RAM Medium status */
|
||||||
|
DVDRAM_MediumStatus = 15, /* DVD-RAM/HD DVD-RAM Spare area information */
|
||||||
|
DVDRAM_SpareArea = 16, /* DVD-R/-RW/HD DVD-R RMD in last border-out */
|
||||||
|
DVDR_RMD = 17, /* Pre-recorded information from DVD-R/-RW lead-in */
|
||||||
|
DVDR_PreRecordedInfo = 18, /* DVD-R/-RW/HD DVD-R media identifier */
|
||||||
|
DVDR_MediaIdentifier = 19, /* DVD-R/-RW/HD DVD-R physical format information */
|
||||||
|
DVDR_PFI = 20, /* ADIP information */
|
||||||
|
DVD_ADIP = 21, /* HD DVD Lead-in copyright protection information */
|
||||||
|
HDDVD_CPI = 22, /* HD DVD-R Medium Status */
|
||||||
|
HDDVD_MediumStatus = 23, /* DVD+/-R DL Layer capacity */
|
||||||
|
DVDDL_LayerCapacity = 24, /* DVD-R DL Middle Zone start address */
|
||||||
|
DVDDL_MiddleZoneAddress = 25, /* DVD-R DL Jump Interval Size */
|
||||||
|
DVDDL_JumpIntervalSize = 26, /* DVD-R DL Start LBA of the manual layer jump */
|
||||||
|
DVDDL_ManualLayerJumpLBA = 27, /* Blu-ray Disc Information */
|
||||||
|
BD_DI = 28, /* Blu-ray Burst Cutting Area */
|
||||||
|
BD_BCA = 29, /* Blu-ray Disc Definition Structure */
|
||||||
|
BD_DDS = 30, /* Blu-ray Cartridge Status */
|
||||||
|
BD_CartridgeStatus = 31, /* Blu-ray Status of Spare Area */
|
||||||
|
BD_SpareArea = 32, /* AACS volume identifier */
|
||||||
|
AACS_VolumeIdentifier = 33, /* AACS pre-recorded media serial number */
|
||||||
|
AACS_SerialNumber = 34, /* AACS media identifier */
|
||||||
|
AACS_MediaIdentifier = 35, /* Lead-in AACS media key block */
|
||||||
|
AACS_MKB = 36, /* AACS data keys */
|
||||||
|
AACS_DataKeys = 37, /* LBA extents flagged for bus encryption by AACS */
|
||||||
|
AACS_LBAExtents = 38, /* CPRM media key block in Lead-in */
|
||||||
|
AACS_CPRM_MKB = 39, /* Recognized layer formats in hybrid discs */
|
||||||
|
Hybrid_RecognizedLayers = 40, /* Disc write protection status */
|
||||||
|
MMC_WriteProtection = 41, /* Disc standard information */
|
||||||
|
MMC_DiscInformation = 42, /* Disc track resources information */
|
||||||
|
MMC_TrackResourcesInformation = 43, /* BD-R Pseudo-overwrite information */
|
||||||
|
MMC_POWResourcesInformation = 44, /* SCSI INQUIRY response */
|
||||||
|
SCSI_INQUIRY = 45, /* SCSI MODE PAGE 2Ah */
|
||||||
|
SCSI_MODEPAGE_2A = 46, /* ATA IDENTIFY DEVICE response */
|
||||||
|
ATA_IDENTIFY = 47, /* ATA IDENTIFY PACKET DEVICE response */
|
||||||
|
ATAPI_IDENTIFY = 48, /* PCMCIA/CardBus Card Information Structure */
|
||||||
|
PCMCIA_CIS = 49, /* SecureDigital CID */
|
||||||
|
SD_CID = 50, /* SecureDigital CSD */
|
||||||
|
SD_CSD = 51, /* SecureDigital SCR */
|
||||||
|
SD_SCR = 52, /* SecureDigital OCR */
|
||||||
|
SD_OCR = 53, /* MultiMediaCard CID */
|
||||||
|
MMC_CID = 54, /* MultiMediaCard CSD */
|
||||||
|
MMC_CSD = 55, /* MultiMediaCard OCR */
|
||||||
|
MMC_OCR = 56, /* MultiMediaCard Extended CSD */
|
||||||
|
MMC_ExtendedCSD = 57, /* Xbox Security Sector */
|
||||||
|
Xbox_SecuritySector = 58, /*
|
||||||
|
* On floppy disks, data in last cylinder usually in a different format that contains duplication or
|
||||||
|
* manufacturing information
|
||||||
|
*/
|
||||||
|
Floppy_LeadOut = 59, /* DVD Disc Control Blocks */
|
||||||
|
DCB = 60, /* Compact Disc First Track Pregap */
|
||||||
|
CD_FirstTrackPregap = 61, /* Compact Disc Lead-out */
|
||||||
|
CD_LeadOut = 62, /* SCSI MODE SENSE (6) */
|
||||||
|
SCSI_MODESENSE_6 = 63, /* SCSI MODE SENSE (10) */
|
||||||
|
SCSI_MODESENSE_10 = 64, /* USB descriptors */
|
||||||
|
USB_Descriptors = 65, /* XGD unlocked DMI */
|
||||||
|
Xbox_DMI = 66, /* XDG unlocked PFI */
|
||||||
|
Xbox_PFI = 67, /* Compact Disc Lead-in */
|
||||||
|
CD_LeadIn = 68
|
||||||
|
} MediaTagType;
|
||||||
|
|
||||||
|
|
||||||
#endif //LIBDICFORMAT_DIC_H
|
#endif //LIBDICFORMAT_DIC_H
|
||||||
|
|
||||||
|
|||||||
@@ -113,4 +113,6 @@ uint32_t edc_cd_compute(void *context, uint32_t edc, const uint8_t *src, int siz
|
|||||||
|
|
||||||
int32_t read_track_sector(void *context, uint8_t *data, uint64_t sectorAddress, uint32_t *length, uint8_t track);
|
int32_t read_track_sector(void *context, uint8_t *data, uint64_t sectorAddress, uint32_t *length, uint8_t track);
|
||||||
|
|
||||||
|
static int32_t GetMediaTagTypeForDataType(int32_t type);
|
||||||
|
|
||||||
#endif //LIBDICFORMAT_DECLS_H
|
#endif //LIBDICFORMAT_DECLS_H
|
||||||
|
|||||||
112
src/helpers.c
Normal file
112
src/helpers.c
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
// /***************************************************************************
|
||||||
|
// The Disc Image Chef
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Filename : helpers.c
|
||||||
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||||
|
//
|
||||||
|
// Component : Disk image plugins.
|
||||||
|
//
|
||||||
|
// --[ Description ] ----------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Contains helpers for DiscImageChef format disk images.
|
||||||
|
//
|
||||||
|
// --[ License ] --------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation; either version 2.1 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful, but
|
||||||
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public
|
||||||
|
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// Copyright © 2011-2019 Natalia Portillo
|
||||||
|
// ****************************************************************************/
|
||||||
|
|
||||||
|
#include <dic.h>
|
||||||
|
#include <dicformat.h>
|
||||||
|
|
||||||
|
// Converts between image data type and dic media tag type
|
||||||
|
static int32_t GetMediaTagTypeForDataType(int32_t type)
|
||||||
|
{
|
||||||
|
switch(type)
|
||||||
|
{
|
||||||
|
case CompactDiscPartialToc: return CD_TOC;
|
||||||
|
case CompactDiscSessionInfo: return CD_SessionInfo;
|
||||||
|
case CompactDiscToc: return CD_FullTOC;
|
||||||
|
case CompactDiscPma: return CD_PMA;
|
||||||
|
case CompactDiscAtip: return CD_ATIP;
|
||||||
|
case CompactDiscLeadInCdText: return CD_TEXT;
|
||||||
|
case DvdPfi: return DVD_PFI;
|
||||||
|
case DvdLeadInCmi: return DVD_CMI;
|
||||||
|
case DvdDiscKey: return DVD_DiscKey;
|
||||||
|
case DvdBca: return DVD_BCA;
|
||||||
|
case DvdDmi: return DVD_DMI;
|
||||||
|
case DvdMediaIdentifier: return DVD_MediaIdentifier;
|
||||||
|
case DvdMediaKeyBlock: return DVD_MKB;
|
||||||
|
case DvdRamDds: return DVDRAM_DDS;
|
||||||
|
case DvdRamMediumStatus: return DVDRAM_MediumStatus;
|
||||||
|
case DvdRamSpareArea: return DVDRAM_SpareArea;
|
||||||
|
case DvdRRmd: return DVDR_RMD;
|
||||||
|
case DvdRPrerecordedInfo: return DVDR_PreRecordedInfo;
|
||||||
|
case DvdRMediaIdentifier: return DVDR_MediaIdentifier;
|
||||||
|
case DvdRPfi: return DVDR_PFI;
|
||||||
|
case DvdAdip: return DVD_ADIP;
|
||||||
|
case HdDvdCpi: return HDDVD_CPI;
|
||||||
|
case HdDvdMediumStatus: return HDDVD_MediumStatus;
|
||||||
|
case DvdDlLayerCapacity: return DVDDL_LayerCapacity;
|
||||||
|
case DvdDlMiddleZoneAddress: return DVDDL_MiddleZoneAddress;
|
||||||
|
case DvdDlJumpIntervalSize: return DVDDL_JumpIntervalSize;
|
||||||
|
case DvdDlManualLayerJumpLba: return DVDDL_ManualLayerJumpLBA;
|
||||||
|
case BlurayDi: return BD_DI;
|
||||||
|
case BlurayBca: return BD_BCA;
|
||||||
|
case BlurayDds: return BD_DDS;
|
||||||
|
case BlurayCartridgeStatus: return BD_CartridgeStatus;
|
||||||
|
case BluraySpareArea: return BD_SpareArea;
|
||||||
|
case AacsVolumeIdentifier: return AACS_VolumeIdentifier;
|
||||||
|
case AacsSerialNumber: return AACS_SerialNumber;
|
||||||
|
case AacsMediaIdentifier: return AACS_MediaIdentifier;
|
||||||
|
case AacsMediaKeyBlock: return AACS_MKB;
|
||||||
|
case AacsDataKeys: return AACS_DataKeys;
|
||||||
|
case AacsLbaExtents: return AACS_LBAExtents;
|
||||||
|
case CprmMediaKeyBlock: return AACS_CPRM_MKB;
|
||||||
|
case HybridRecognizedLayers: return Hybrid_RecognizedLayers;
|
||||||
|
case ScsiMmcWriteProtection: return MMC_WriteProtection;
|
||||||
|
case ScsiMmcDiscInformation: return MMC_DiscInformation;
|
||||||
|
case ScsiMmcTrackResourcesInformation: return MMC_TrackResourcesInformation;
|
||||||
|
case ScsiMmcPowResourcesInformation: return MMC_POWResourcesInformation;
|
||||||
|
case ScsiInquiry: return SCSI_INQUIRY;
|
||||||
|
case ScsiModePage2A: return SCSI_MODEPAGE_2A;
|
||||||
|
case AtaIdentify: return ATA_IDENTIFY;
|
||||||
|
case AtapiIdentify: return ATAPI_IDENTIFY;
|
||||||
|
case PcmciaCis: return PCMCIA_CIS;
|
||||||
|
case SecureDigitalCid: return SD_CID;
|
||||||
|
case SecureDigitalCsd: return SD_CSD;
|
||||||
|
case SecureDigitalScr: return SD_SCR;
|
||||||
|
case SecureDigitalOcr: return SD_OCR;
|
||||||
|
case MultiMediaCardCid: return MMC_CID;
|
||||||
|
case MultiMediaCardCsd: return MMC_CSD;
|
||||||
|
case MultiMediaCardOcr: return MMC_OCR;
|
||||||
|
case MultiMediaCardExtendedCsd: return MMC_ExtendedCSD;
|
||||||
|
case XboxSecuritySector: return Xbox_SecuritySector;
|
||||||
|
case FloppyLeadOut: return Floppy_LeadOut;
|
||||||
|
case DvdDiscControlBlock: return DCB;
|
||||||
|
case CompactDiscFirstTrackPregap: return CD_FirstTrackPregap;
|
||||||
|
case CompactDiscLeadOut: return CD_LeadOut;
|
||||||
|
case ScsiModeSense6: return SCSI_MODESENSE_6;
|
||||||
|
case ScsiModeSense10: return SCSI_MODESENSE_10;
|
||||||
|
case UsbDescriptors: return USB_Descriptors;
|
||||||
|
case XboxDmi: return Xbox_DMI;
|
||||||
|
case XboxPfi: return Xbox_PFI;
|
||||||
|
case CompactDiscMediaCatalogueNumber: return CD_MCN;
|
||||||
|
case CompactDiscLeadIn: return CD_LeadIn;
|
||||||
|
default: return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -371,10 +371,7 @@ void *open(const char *filepath)
|
|||||||
}
|
}
|
||||||
memset(mediaTag, 0, sizeof(dataLinkedList));
|
memset(mediaTag, 0, sizeof(dataLinkedList));
|
||||||
|
|
||||||
// TODO: MediaTagType
|
mediaTag->type = GetMediaTagTypeForDataType(blockHeader.type);
|
||||||
// MediaTagType mediaTagType = GetMediaTagTypeForDataType(blockHeader.type);
|
|
||||||
|
|
||||||
mediaTag->type = blockHeader.type;
|
|
||||||
mediaTag->data = data;
|
mediaTag->data = data;
|
||||||
mediaTag->length = blockHeader.length;
|
mediaTag->length = blockHeader.length;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user