#include "ddf1.h" #include #include #include #include #include void dump16x(const uint8_t *p, size_t len) { size_t i; for( i = 0; i < len; i++ ) { printf(" %02x", p[i]); } printf("\n"); } int main(void) { int i, fd; off_t cnt; struct ddf1_ddf_header ddf1head; struct ddf1_controller_data ddf1cdata; struct ddf1_phsical_disk_records ddf1pdr; struct ddf1_physical_disk_entries ddf1pde; struct ddf1_virtual_disk_records ddf1vdr; struct ddf1_virtual_disk_entries ddf1vde; struct ddf1_virtual_disk_configuration_record ddf1vdcr; struct ddf1_physical_disk_data ddf1pdd; if( (fd = open("ad4.img", O_RDONLY)) < 0 ) { perror("cannot open: ad4.img"); exit(1); } /* NOT REACHABLE */ /* ==================================================================================== */ lseek(fd, -512L, SEEK_END); read(fd, &ddf1head, 512); printf("------------------------------------\n"); printf("sizeof struct ddf1_ddf_header = %u\n", sizeof(struct ddf1_ddf_header)); printf("------------------------------------\n"); printf("Signature = 0x%08x\n", ddf1head.Signature); printf("CRC = 0x%04x\n", ddf1head.CRC); printf("DDF_Header_GUID ="); dump16x(ddf1head.DDF_Header_GUID, 24); printf("DDF_rev ="); dump16x(ddf1head.DDF_rev, 8); printf("Sequence_Number = %d\n", ddf1head.Sequence_Number); printf("Timestamp = %d\n", ddf1head.Timestamp); printf("Open_Flag = 0x%x\n", ddf1head.Open_Flag); printf("Foreign_Flag = 0x%x\n", ddf1head.Foreign_Flag); printf("Disk_Grouping = %d\n", ddf1head.Disk_Grouping); printf("Primary_Header_LBA = 0x%016llx (%llu)\n", ddf1head.Primary_Header_LBA, ddf1head.Primary_Header_LBA); printf("Secondary_Header_LBA = 0x%016llx (%llu)\n", ddf1head.Secondary_Header_LBA, ddf1head.Secondary_Header_LBA); printf("Header_Type = 0x%x\n", ddf1head.Header_Type); printf("Workspace_Length = %u\n", ddf1head.Workspace_Length); printf("Workspace_LBA = 0x%016llx (%llu)\n", ddf1head.Workspace_LBA, ddf1head.Workspace_LBA); printf("Max_PD_Entries = %d\n", ddf1head.Max_PD_Entries); printf("Max_VD_Entries = %d\n", ddf1head.Max_VD_Entries); printf("Max_Partitions = %d\n", ddf1head.Max_Partitions); printf("Configuration_Record_Length = %d\n", ddf1head.Configuration_Record_Length); printf("Max_Primary_Element_Entries = %d\n", ddf1head.Max_Primary_Element_Entries); printf("Controller_Data_Section = %d\n", ddf1head.Controller_Data_Section); printf("Controller_Data_Length = %d\n", ddf1head.Controller_Data_Length); printf("Physical_Disk_Records_Section = %d\n", ddf1head.Physical_Disk_Records_Section); printf("Physical_Disk_Records_Length = %d\n", ddf1head.Physical_Disk_Records_Length); printf("Virtual_Disk_Records_Section = %d\n", ddf1head.Virtual_Disk_Records_Section); printf("Virtual_Disk_Records_Length = %d\n", ddf1head.Virtual_Disk_Records_Length); printf("Configuration_Records_Section = %d\n", ddf1head.Configuration_Records_Section); printf("Configuration_Records_Length = %d\n", ddf1head.Configuration_Records_Length); printf("Physical_Disk_Data_Section = %d\n", ddf1head.Physical_Disk_Data_Section); printf("Physical_Disk_Data_Length = %d\n", ddf1head.Physical_Disk_Data_Length); printf("BBM_Log_Section = %d\n", ddf1head.BBM_Log_Section); printf("BBM_Log_Length = %d\n", ddf1head.BBM_Log_Length); printf("Diagnostic_Space = %d\n", ddf1head.Diagnostic_Space); printf("Diagnostic_Space_Length = %d\n", ddf1head.Diagnostic_Space_Length); printf("Vendor_Specific_Logs_Section = %d\n", ddf1head.Vendor_Specific_Logs_Section); printf("Vendor_Specific_Logs_Section_Length = %d\n", ddf1head.Vendor_Specific_Logs_Section_Length); /* ==================================================================================== */ lseek(fd, (ddf1head.Primary_Header_LBA + ddf1head.Controller_Data_Section) * 512, SEEK_SET); read(fd, &ddf1cdata, sizeof(struct ddf1_controller_data)); printf("------------------------------------\n"); printf("sizeof struct ddf1_controller_data = %u\n", sizeof(struct ddf1_controller_data)); printf("------------------------------------\n"); printf("Signature = 0x%08x\n", ddf1cdata.Signature); printf("CRC = 0x%04x\n", ddf1cdata.CRC); printf("Controller_GUID ="); dump16x(ddf1cdata.Controller_GUID, 24); printf("Controller_Type_Vendor_ID = 0x%04x\n", ddf1cdata.Controller_Type_Vendor_ID); printf("Controller_Type_Device_ID = 0x%04x\n", ddf1cdata.Controller_Type_Device_ID); printf("Controller_Type_Sub_Vendor_ID = 0x%04x\n", ddf1cdata.Controller_Type_Sub_Vendor_ID); printf("Controller_Type_Sub_Device_ID = 0x%04x\n", ddf1cdata.Controller_Type_Sub_Device_ID); /* ==================================================================================== */ lseek(fd, (ddf1head.Primary_Header_LBA + ddf1head.Physical_Disk_Records_Section) * 512, SEEK_SET); read(fd, &ddf1pdr, sizeof(struct ddf1_phsical_disk_records)); printf("------------------------------------\n"); printf("sizeof struct ddf1_phsical_disk_records = %u\n", sizeof(struct ddf1_phsical_disk_records)); printf("------------------------------------\n"); printf("Signature = 0x%08x\n", ddf1pdr.Signature); printf("CRC = 0x%04x\n", ddf1pdr.CRC); printf("Populated_PDEs = %d\n", ddf1pdr.Populated_PDEs); printf("Max_PDE_Supported = %d\n", ddf1pdr.Max_PDE_Supported); /* ==================================================================================== */ for( i = 0; i < ddf1pdr.Populated_PDEs; i++ ) { read(fd, &ddf1pde, sizeof(struct ddf1_physical_disk_entries)); printf("------------------------------------\n"); printf("*sizeof struct ddf1_physical_disk_entries = %u\n", sizeof(struct ddf1_physical_disk_entries)); printf("------------------------------------\n"); printf("PD_GUID ="); dump16x(ddf1pde.PD_GUID, 24); printf("PD_Reference = %d\n", ddf1pde.PD_Reference); printf("PD_Type = 0x%x\n", ddf1pde.PD_Type); printf("PD_State = 0x%x\n", ddf1pde.PD_State); printf("Configured_Size = %llu\n", ddf1pde.Configured_Size); printf("Path_Information ="); dump16x(ddf1pde.Path_Information, 18); } /* ==================================================================================== */ lseek(fd, (ddf1head.Primary_Header_LBA + ddf1head.Virtual_Disk_Records_Section) * 512, SEEK_SET); read(fd, &ddf1vdr, sizeof(struct ddf1_virtual_disk_records)); printf("------------------------------------\n"); printf("sizeof struct ddf1_virtual_disk_records = %u\n", sizeof(struct ddf1_virtual_disk_records)); printf("------------------------------------\n"); printf("Signature = 0x%08x\n", ddf1vdr.Signature); printf("CRC = 0x%04x\n", ddf1vdr.CRC); printf("Populated_VDEs = %d\n", ddf1vdr.Populated_VDEs); printf("Max_VDE_Supported = %d\n", ddf1vdr.Max_VDE_Supported); /* ==================================================================================== */ for( i = 0; i < ddf1vdr.Populated_VDEs; i++ ) { read(fd, &ddf1vde, sizeof(struct ddf1_virtual_disk_entries)); printf("------------------------------------\n"); printf("*sizeof struct ddf1_virtual_disk_entries = %u\n", sizeof(struct ddf1_virtual_disk_entries)); printf("------------------------------------\n"); printf("VD_GUID ="); dump16x(ddf1vde.VD_GUID, 24); printf("VD_Number = %d\n", ddf1vde.VD_Number); printf("VD_Type = 0x%x\n", ddf1vde.VD_Type); printf("VD_State = 0x%x\n", ddf1vde.VD_State); printf("Init_State = 0x%x\n", ddf1vde.Init_State); printf("VD_Name = %.16s\n", ddf1vde.VD_Name); } /* ==================================================================================== */ lseek(fd, ( ddf1head.Primary_Header_LBA + ddf1head.Configuration_Records_Section ) * 512, SEEK_SET); read(fd, &ddf1vdcr, sizeof(struct ddf1_virtual_disk_configuration_record)); printf("------------------------------------\n"); printf("sizeof struct ddf1_virtual_disk_configuration_record = %u\n", sizeof(struct ddf1_virtual_disk_configuration_record)); printf("------------------------------------\n"); printf("Signature = 0x%08x\n", ddf1vdcr.Signature); printf("CRC = 0x%04x\n", ddf1vdcr.CRC); printf("VD_GUID ="); dump16x(ddf1vdcr.VD_GUID, 24); printf("Timestamp = %d\n", ddf1vdcr.Timestamp); printf("Sequence_Number = %d\n", ddf1vdcr.Sequence_Number); printf("Primary_Element_Count = %d\n", ddf1vdcr.Primary_Element_Count); printf("Strip_Size(Stripe_Size) = %d\n", ddf1vdcr.Strip_Size); printf("Primary_RAID_Level = %d\n", ddf1vdcr.Primary_RAID_Level); printf("RAID_Level_Qualifier = %d\n", ddf1vdcr.RAID_Level_Qualifier); printf("Secondary_Element_Count = %d\n", ddf1vdcr.Secondary_Element_Count); printf("Secondary_Element_Seq = %d\n", ddf1vdcr.Secondary_Element_Seq); printf("Secondary_RAID_Level = %d\n", ddf1vdcr.Secondary_RAID_Level); printf("Block_Count = %lld\n", ddf1vdcr.Block_Count); printf("Size = %lld\n", ddf1vdcr.Size); printf("Cache_Policies_And_Parameters = 0x%016llx\n", ddf1vdcr.Cache_Policies_And_Parameters); printf("BG_Rate = %d\n", ddf1vdcr.BG_Rate); /* ==================================================================================== */ lseek(fd, ( ddf1head.Primary_Header_LBA + ddf1head.Physical_Disk_Data_Section ) * 512, SEEK_SET); read(fd, &ddf1pdd, sizeof(struct ddf1_physical_disk_data)); printf("------------------------------------\n"); printf("sizeof struct ddf1_physical_disk_data = %u\n", sizeof(struct ddf1_physical_disk_data)); printf("------------------------------------\n"); printf("Signature = 0x%08x\n", ddf1pdd.Signature); printf("CRC = 0x%04x\n", ddf1pdd.CRC); printf("PD_GUID ="); dump16x(ddf1pdd.PD_GUID, 24); printf("PD_Reference = %d\n", ddf1pdd.PD_Reference); printf("Forced_Ref_Flag = 0x%02x\n", ddf1pdd.Forced_Ref_Flag); printf("Forced_PD_GUID_Flag = 0x%02x\n", ddf1pdd.Forced_PD_GUID_Flag); close(fd); return 0; }