diff options
| author | christos <christos@NetBSD.org> | 2012-04-06 22:41:47 +0000 |
|---|---|---|
| committer | christos <christos@NetBSD.org> | 2012-04-06 22:41:47 +0000 |
| commit | 1015e4d57211cb0f118fad378b40dc629a30d648 (patch) | |
| tree | cd543129b0508ba55ec9be67f6d65c7508712f92 /dist | |
| parent | 6a7de2be4ddfd1304937f4827e0efba3eb19d40d (diff) | |
make this work on 64 bit machines; use stdint/inttypes.
Diffstat (limited to 'dist')
31 files changed, 554 insertions, 544 deletions
diff --git a/dist/pdisk/ATA_media.c b/dist/pdisk/ATA_media.c index dbb3b30ea72..b9c266e5c0e 100644 --- a/dist/pdisk/ATA_media.c +++ b/dist/pdisk/ATA_media.c @@ -87,69 +87,69 @@ struct ATA_media_iterator { }; struct ATA_identify_drive_info { /* word */ - unsigned short config_bits; /* 0 */ - unsigned short num_cylinders; /* 1 */ - unsigned short reserved2; /* 2 */ - unsigned short num_heads; /* 3 */ - unsigned short bytes_per_track; /* 4 */ - unsigned short bytes_per_sector; /* 5 */ - unsigned short sectors_per_track; /* 6 */ - unsigned short vendor7[3]; /* 7-9 */ + uint16_t config_bits; /* 0 */ + uint16_t num_cylinders; /* 1 */ + uint16_t reserved2; /* 2 */ + uint16_t num_heads; /* 3 */ + uint16_t bytes_per_track; /* 4 */ + uint16_t bytes_per_sector; /* 5 */ + uint16_t sectors_per_track; /* 6 */ + uint16_t vendor7[3]; /* 7-9 */ char serial_number[20]; /* 10-19 */ - unsigned short buffer_type; /* 20 */ - unsigned short buffer_size; /* 21 */ - unsigned short num_of_ecc_bytes; /* 22 */ + uint16_t buffer_type; /* 20 */ + uint16_t buffer_size; /* 21 */ + uint16_t num_of_ecc_bytes; /* 22 */ char firmware_rev[8]; /* 23-26 */ char model_number[40]; /* 27-46 */ - unsigned short word47; /* 47 */ - unsigned short double_word_io; /* 48 */ - unsigned short capabilities; /* 49 */ - unsigned short reserved50; /* 50 */ - unsigned short pio_timing; /* 51 */ - unsigned short dma_timing; /* 52 */ - unsigned short current_is_valid; /* 53 */ - unsigned short cur_cylinders; /* 54 */ - unsigned short cur_heads; /* 55 */ - unsigned short cur_sec_per_track; /* 56 */ - unsigned long total_sectors; /* 57-58 */ - unsigned short multiple_sectors; /* 59 */ - unsigned long lba_sectors; /* 60-61 */ - unsigned short singleword_dma; /* 62 */ - unsigned short multiword_dma; /* 63 */ - unsigned short reserved64[64]; /* 64-127 */ - unsigned short vendor128[32]; /* 128-159 */ - unsigned short reserved160[96]; /* 160-255 */ + uint16_t word47; /* 47 */ + uint16_t double_word_io; /* 48 */ + uint16_t capabilities; /* 49 */ + uint16_t reserved50; /* 50 */ + uint16_t pio_timing; /* 51 */ + uint16_t dma_timing; /* 52 */ + uint16_t current_is_valid; /* 53 */ + uint16_t cur_cylinders; /* 54 */ + uint16_t cur_heads; /* 55 */ + uint16_t cur_sec_per_track; /* 56 */ + uint32_t total_sectors; /* 57-58 */ + uint16_t multiple_sectors; /* 59 */ + uint32_t lba_sectors; /* 60-61 */ + uint16_t singleword_dma; /* 62 */ + uint16_t multiword_dma; /* 63 */ + uint16_t reserved64[64]; /* 64-127 */ + uint16_t vendor128[32]; /* 128-159 */ + uint16_t reserved160[96]; /* 160-255 */ }; struct ATAPI_identify_drive_info { /* word */ - unsigned short config_bits; /* 0 */ - unsigned short retired1[9]; /* 1-9 */ + uint16_t config_bits; /* 0 */ + uint16_t retired1[9]; /* 1-9 */ char serial_number[20]; /* 10-19 */ - unsigned short retired20[3]; /* 20-22 */ + uint16_t retired20[3]; /* 20-22 */ char firmware_rev[8]; /* 23-26 */ char model_number[40]; /* 27-46 */ - unsigned short retired47[2]; /* 47-48 */ - unsigned short capabilities; /* 49 */ - unsigned short reserved50; /* 50 */ - unsigned short pio_timing; /* 51 */ - unsigned short dma_timing; /* 52 */ - unsigned short current_is_valid; /* 53 */ - unsigned short retired54[8]; /* 54-61 */ - unsigned short singleword_dma; /* 62 */ - unsigned short multiword_dma; /* 63 */ - unsigned short pio_transfer; /* 64 */ - unsigned short min_cycle_time; /* 65 */ - unsigned short rec_cycle_time; /* 66 */ - unsigned short min_wo_flow; /* 67 */ - unsigned short min_with_flow; /* 68 */ - unsigned short reserved69[2]; /* 69-70 */ - unsigned short release_over; /* 71 */ - unsigned short release_service; /* 72 */ - unsigned short major_rev; /* 73 */ - unsigned short minor_rev; /* 74 */ - unsigned short reserved75[53]; /* 75-127 */ - unsigned short vendor128[32]; /* 128-159 */ - unsigned short reserved160[96]; /* 160-255 */ + uint16_t retired47[2]; /* 47-48 */ + uint16_t capabilities; /* 49 */ + uint16_t reserved50; /* 50 */ + uint16_t pio_timing; /* 51 */ + uint16_t dma_timing; /* 52 */ + uint16_t current_is_valid; /* 53 */ + uint16_t retired54[8]; /* 54-61 */ + uint16_t singleword_dma; /* 62 */ + uint16_t multiword_dma; /* 63 */ + uint16_t pio_transfer; /* 64 */ + uint16_t min_cycle_time; /* 65 */ + uint16_t rec_cycle_time; /* 66 */ + uint16_t min_wo_flow; /* 67 */ + uint16_t min_with_flow; /* 68 */ + uint16_t reserved69[2]; /* 69-70 */ + uint16_t release_over; /* 71 */ + uint16_t release_service; /* 72 */ + uint16_t major_rev; /* 73 */ + uint16_t minor_rev; /* 74 */ + uint16_t reserved75[53]; /* 75-127 */ + uint16_t vendor128[32]; /* 128-159 */ + uint16_t reserved160[96]; /* 160-255 */ }; /* Identifies the bus protocol type. */ @@ -185,8 +185,8 @@ int ATAHardwarePresent(void); pascal SInt16 ataManager(ataPB *pb); void ata_init(void); ATA_MEDIA new_ata_media(void); -long read_ata_media(MEDIA m, long long offset, unsigned long count, void *address); -long write_ata_media(MEDIA m, long long offset, unsigned long count, void *address); +long read_ata_media(MEDIA m, long long offset, uint32_t count, void *address); +long write_ata_media(MEDIA m, long long offset, uint32_t count, void *address); long close_ata_media(MEDIA m); long os_reload_ata_media(MEDIA m); long compute_id(long bus, long device); @@ -196,11 +196,11 @@ int ATA_WriteBlock(UInt32 deviceID, ATA_INFO info, UInt32 block_size, UInt32 blo long get_info(long id, struct ATA_identify_drive_info *ip); long get_pi_info(long id, struct ATAPI_identify_drive_info *ip); long is_atapi(long id); -long read_atapi_media(MEDIA m, long long offset, unsigned long count, void *address); -long write_atapi_media(MEDIA m, long long offset, unsigned long count, void *address); +long read_atapi_media(MEDIA m, long long offset, uint32_t count, void *address); +long write_atapi_media(MEDIA m, long long offset, uint32_t count, void *address); int ATAPI_ReadBlock(UInt32 deviceID, UInt32 block_size, UInt32 block, UInt8 *address); int ATAPI_TestUnitReady(UInt32 deviceID); -int ATAPI_ReadCapacity(UInt32 deviceID, unsigned long *block_size, unsigned long *blocks); +int ATAPI_ReadCapacity(UInt32 deviceID, uint32_t *block_size, uint32_t *blocks); ATA_MEDIA_ITERATOR new_ata_iterator(void); void reset_ata_iterator(MEDIA_ITERATOR m); char *step_ata_iterator(MEDIA_ITERATOR m); @@ -439,8 +439,8 @@ open_ata_as_media(long bus, long device) ATA_MEDIA a; long id; struct ATA_identify_drive_info info; - unsigned char *buf; - unsigned long total; + uint8_t *buf; + uint32_t total; if (ata_inited == 0) { ata_init(); @@ -510,7 +510,7 @@ open_ata_as_media(long bus, long device) long -read_ata_media(MEDIA m, long long offset, unsigned long count, void *address) +read_ata_media(MEDIA m, long long offset, uint32_t count, void *address) { ATA_MEDIA a; ataIOPB pb; @@ -519,7 +519,7 @@ read_ata_media(MEDIA m, long long offset, unsigned long count, void *address) long block; long block_count; long block_size; - unsigned char *buffer; + uint8_t *buffer; int i; a = (ATA_MEDIA) m; @@ -555,14 +555,14 @@ read_ata_media(MEDIA m, long long offset, unsigned long count, void *address) long -write_ata_media(MEDIA m, long long offset, unsigned long count, void *address) +write_ata_media(MEDIA m, long long offset, uint32_t count, void *address) { ATA_MEDIA a; long rtn_value; long block; long block_count; long block_size; - unsigned char *buffer; + uint8_t *buffer; int i; a = (ATA_MEDIA) m; @@ -772,9 +772,9 @@ open_atapi_as_media(long bus, long device) ATA_MEDIA a; long id; struct ATAPI_identify_drive_info info; - unsigned char *buf; - unsigned long block_size; - unsigned long blocks; + uint8_t *buf; + uint32_t block_size; + uint32_t blocks; if (ata_inited == 0) { ata_init(); @@ -821,7 +821,7 @@ open_atapi_as_media(long bus, long device) long -read_atapi_media(MEDIA m, long long offset, unsigned long count, void *address) +read_atapi_media(MEDIA m, long long offset, uint32_t count, void *address) { ATA_MEDIA a; ataIOPB pb; @@ -830,7 +830,7 @@ read_atapi_media(MEDIA m, long long offset, unsigned long count, void *address) long block; long block_count; long block_size; - unsigned char *buffer; + uint8_t *buffer; int i; a = (ATA_MEDIA) m; @@ -866,7 +866,7 @@ read_atapi_media(MEDIA m, long long offset, unsigned long count, void *address) long -write_atapi_media(MEDIA m, long long offset, unsigned long count, void *address) +write_atapi_media(MEDIA m, long long offset, uint32_t count, void *address) { return 0; } @@ -974,7 +974,7 @@ ATAPI_TestUnitReady(UInt32 deviceID) int -ATAPI_ReadCapacity(UInt32 deviceID, unsigned long *block_size, unsigned long *blocks) +ATAPI_ReadCapacity(UInt32 deviceID, uint32_t *block_size, uint32_t *blocks) { ataIOPB pb; OSErr status; @@ -993,7 +993,7 @@ ATAPI_ReadCapacity(UInt32 deviceID, unsigned long *block_size, unsigned long *bl pb.ataPBFlags = mATAFlagTFRead | mATAFlagIORead | mATAFlagProtocol1; pb.ataPBTimeOut = kATAtimeout; - pb.ataPBBuffer = (unsigned char *)&rcd; + pb.ataPBBuffer = (uint8_t *)&rcd; pb.ataPBByteCount = 8; pb.ataPBTaskFile.ataTFCylinder = 8; if (deviceID & 0x0FF00) { diff --git a/dist/pdisk/DoSCSICommand.c b/dist/pdisk/DoSCSICommand.c index ea9cd49a373..04ac06568f6 100644 --- a/dist/pdisk/DoSCSICommand.c +++ b/dist/pdisk/DoSCSICommand.c @@ -93,7 +93,7 @@ OSErr OriginalSCSI( OSErr DoOriginalSCSICommand( DeviceIdent scsiDevice, const SCSI_CommandPtr theSCSICommand, - unsigned short cmdBlockLength, + uint16_t cmdBlockLength, Ptr dataBuffer, ByteCount dataLength, UInt32 scsiFlags, @@ -193,7 +193,7 @@ DoSCSICommand( { OSErr status; SCSI_Command theSCSICommand; - unsigned short cmdBlockLength; + uint16_t cmdBlockLength; // SpinSpinner(&gCurrentInfoPtr->spinnerRecord); // ShowProgressAction(currentAction); @@ -280,7 +280,7 @@ OSErr DoOriginalSCSICommand( DeviceIdent scsiDevice, const SCSI_CommandPtr theSCSICommand, - unsigned short cmdBlockLength, + uint16_t cmdBlockLength, Ptr dataBuffer, ByteCount dataLength, UInt32 scsiFlags, @@ -360,8 +360,8 @@ OriginalSCSI( short totalTries; /* Get/Select retries */ short getTries; /* Get retries */ short iCount; /* Bus free counter */ - unsigned long watchdog; /* Timeout after this */ - unsigned long myTransferCount; /* Gets TIB loop counter */ + uint32_t watchdog; /* Timeout after this */ + uint32_t myTransferCount; /* Gets TIB loop counter */ short scsiStatusByte; /* Gets SCSIComplete result */ short scsiMsgByte; /* Gets SCSIComplete result */ Boolean bufferHoldFlag; @@ -388,10 +388,10 @@ OriginalSCSI( */ if (dataBuffer != NULL) { tib[0].scOpcode = scInc; - tib[0].scParam1 = (unsigned long) dataBuffer; + tib[0].scParam1 = (uint32_t) dataBuffer; tib[0].scParam2 = 1; tib[1].scOpcode = scAdd; - tib[1].scParam1 = (unsigned long) &myTransferCount; + tib[1].scParam1 = (uint32_t) &myTransferCount; tib[1].scParam2 = 1; tib[2].scOpcode = scLoop; tib[2].scParam1 = (-2 * sizeof (SCSIInstr)); @@ -589,7 +589,7 @@ GetCommandLength( const SCSI_CommandPtr cmdPtr ) { - unsigned short result; + uint16_t result; /* * Look at the "group code" in the command operation. Return zero * error for the reserved (3, 4) and vendor-specific command (6, 7) diff --git a/dist/pdisk/DoSCSICommand.h b/dist/pdisk/DoSCSICommand.h index 337ddbee695..ce4a0ba8860 100644 --- a/dist/pdisk/DoSCSICommand.h +++ b/dist/pdisk/DoSCSICommand.h @@ -64,14 +64,14 @@ */ #if !defined(__NewTypesDefined__) #define __NewTypesDefined__ -typedef signed char SInt8; -typedef signed short SInt16; -typedef signed long SInt32; -typedef unsigned char UInt8; -typedef unsigned short UInt16; -typedef unsigned long UInt32; -typedef unsigned long ItemCount; -typedef unsigned long ByteCount; +typedef int8_t SInt8; +typedef int16_t SInt16; +typedef int32_t SInt32; +typedef uint8_t UInt8; +typedef uint16_t UInt16; +typedef uint32_t UInt32; +typedef uint32_t ItemCount; +typedef uint32_t ByteCount; #endif diff --git a/dist/pdisk/MacSCSICommand.h b/dist/pdisk/MacSCSICommand.h index b02b66f90ae..0c4d8fb4f32 100644 --- a/dist/pdisk/MacSCSICommand.h +++ b/dist/pdisk/MacSCSICommand.h @@ -39,42 +39,42 @@ * I/O requests. */ struct SCSI_6_Byte_Command { /* Six-byte command */ - unsigned char opcode; /* 0 */ - unsigned char lbn3; /* 1 lbn in low 5 */ - unsigned char lbn2; /* 2 */ - unsigned char lbn1; /* 3 */ - unsigned char len; /* 4 */ - unsigned char ctrl; /* 5 */ + uint8_t opcode; /* 0 */ + uint8_t lbn3; /* 1 lbn in low 5 */ + uint8_t lbn2; /* 2 */ + uint8_t lbn1; /* 3 */ + uint8_t len; /* 4 */ + uint8_t ctrl; /* 5 */ }; typedef struct SCSI_6_Byte_Command SCSI_6_Byte_Command; struct SCSI_10_Byte_Command { /* Ten-byte command */ - unsigned char opcode; /* 0 */ - unsigned char lun; /* 1 */ - unsigned char lbn4; /* 2 */ - unsigned char lbn3; /* 3 */ - unsigned char lbn2; /* 4 */ - unsigned char lbn1; /* 5 */ - unsigned char pad; /* 6 */ - unsigned char len2; /* 7 */ - unsigned char len1; /* 8 */ - unsigned char ctrl; /* 9 */ + uint8_t opcode; /* 0 */ + uint8_t lun; /* 1 */ + uint8_t lbn4; /* 2 */ + uint8_t lbn3; /* 3 */ + uint8_t lbn2; /* 4 */ + uint8_t lbn1; /* 5 */ + uint8_t pad; /* 6 */ + uint8_t len2; /* 7 */ + uint8_t len1; /* 8 */ + uint8_t ctrl; /* 9 */ }; typedef struct SCSI_10_Byte_Command SCSI_10_Byte_Command; struct SCSI_12_Byte_Command { /* Twelve-byte command */ - unsigned char opcode; /* 0 */ - unsigned char lun; /* 1 */ - unsigned char lbn4; /* 2 */ - unsigned char lbn3; /* 3 */ - unsigned char lbn2; /* 4 */ - unsigned char lbn1; /* 5 */ - unsigned char len4; /* 6 */ - unsigned char len3; /* 7 */ - unsigned char len2; /* 8 */ - unsigned char len1; /* 9 */ - unsigned char pad; /* 10 */ - unsigned char ctrl; /* 11 */ + uint8_t opcode; /* 0 */ + uint8_t lun; /* 1 */ + uint8_t lbn4; /* 2 */ + uint8_t lbn3; /* 3 */ + uint8_t lbn2; /* 4 */ + uint8_t lbn1; /* 5 */ + uint8_t len4; /* 6 */ + uint8_t len3; /* 7 */ + uint8_t len2; /* 8 */ + uint8_t len1; /* 9 */ + uint8_t pad; /* 10 */ + uint8_t ctrl; /* 11 */ }; typedef struct SCSI_12_Byte_Command SCSI_12_Byte_Command; @@ -85,7 +85,7 @@ union SCSI_Command { SCSI_6_Byte_Command scsi6; SCSI_10_Byte_Command scsi10; SCSI_12_Byte_Command scsi12; - unsigned char scsi[12]; + uint8_t scsi[12]; }; typedef union SCSI_Command SCSI_Command, *SCSI_CommandPtr; @@ -93,31 +93,31 @@ typedef union SCSI_Command SCSI_Command, *SCSI_CommandPtr; * Returned by a read-capacity command. */ struct SCSI_Capacity_Data { - unsigned char lbn4; /* Number */ - unsigned char lbn3; /* of */ - unsigned char lbn2; /* logical */ - unsigned char lbn1; /* blocks */ - unsigned char len4; /* Length */ - unsigned char len3; /* of each */ - unsigned char len2; /* logical block */ - unsigned char len1; /* in bytes */ + uint8_t lbn4; /* Number */ + uint8_t lbn3; /* of */ + uint8_t lbn2; /* logical */ + uint8_t lbn1; /* blocks */ + uint8_t len4; /* Length */ + uint8_t len3; /* of each */ + uint8_t len2; /* logical block */ + uint8_t len1; /* in bytes */ }; typedef struct SCSI_Capacity_Data SCSI_Capacity_Data; struct SCSI_Inquiry_Data { /* Inquiry returns this */ - unsigned char devType; /* 0 Device type, */ - unsigned char devTypeMod; /* 1 Device type modifier */ - unsigned char version; /* 2 ISO/ECMA/ANSI version */ - unsigned char format; /* 3 Response data format */ - unsigned char length; /* 4 Additional Length */ - unsigned char reserved5; /* 5 Reserved */ - unsigned char reserved6; /* 6 Reserved */ - unsigned char flags; /* 7 Capability flags */ - unsigned char vendor[8]; /* 8-15 Vendor-specific */ - unsigned char product[16]; /* 16-31 Product id */ - unsigned char revision[4]; /* 32-35 Product revision */ - unsigned char vendorSpecific[20]; /* 36-55 Vendor stuff */ - unsigned char moreReserved[40]; /* 56-95 Reserved */ + uint8_t devType; /* 0 Device type, */ + uint8_t devTypeMod; /* 1 Device type modifier */ + uint8_t version; /* 2 ISO/ECMA/ANSI version */ + uint8_t format; /* 3 Response data format */ + uint8_t length; /* 4 Additional Length */ + uint8_t reserved5; /* 5 Reserved */ + uint8_t reserved6; /* 6 Reserved */ + uint8_t flags; /* 7 Capability flags */ + uint8_t vendor[8]; /* 8-15 Vendor-specific */ + uint8_t product[16]; /* 16-31 Product id */ + uint8_t revision[4]; /* 32-35 Product revision */ + uint8_t vendorSpecific[20]; /* 36-55 Vendor stuff */ + uint8_t moreReserved[40]; /* 56-95 Reserved */ }; typedef struct SCSI_Inquiry_Data SCSI_Inquiry_Data; @@ -186,17 +186,17 @@ enum { * logical block number (most-significant byte first). */ struct SCSI_Sense_Data { /* Request Sense result */ - unsigned char errorCode; /* 0 Class code, valid lbn */ - unsigned char segmentNumber; /* 1 Segment number */ - unsigned char senseKey; /* 2 Sense key and flags */ - unsigned char info[4]; - unsigned char additionalSenseLength; - unsigned char reservedForCopy[4]; - unsigned char additionalSenseCode; - unsigned char additionalSenseQualifier; - unsigned char fruCode; /* Field replacable unit code */ - unsigned char senseKeySpecific[2]; - unsigned char additional[101]; + uint8_t errorCode; /* 0 Class code, valid lbn */ + uint8_t segmentNumber; /* 1 Segment number */ + uint8_t senseKey; /* 2 Sense key and flags */ + uint8_t info[4]; + uint8_t additionalSenseLength; + uint8_t reservedForCopy[4]; + uint8_t additionalSenseCode; + uint8_t additionalSenseQualifier; + uint8_t fruCode; /* Field replacable unit code */ + uint8_t senseKeySpecific[2]; + uint8_t additional[101]; }; typedef struct SCSI_Sense_Data SCSI_Sense_Data; /* @@ -239,26 +239,26 @@ typedef struct SCSI_Sense_Data SCSI_Sense_Data; * Mode sense parameter header */ struct SCSI_ModeParamHeader { - unsigned char modeDataLength; - unsigned char mediumType; - unsigned char deviceSpecific; - unsigned char blockDescriptorLength; + uint8_t modeDataLength; + uint8_t mediumType; + uint8_t deviceSpecific; + uint8_t blockDescriptorLength; }; typedef struct SCSI_ModeParamHeader SCSI_ModeParamHeader; struct SCSI_ModeParamBlockDescriptor { - unsigned char densityCode; - unsigned char numberOfBlocks[3]; - unsigned char reserved; - unsigned char blockLength[3]; + uint8_t densityCode; + uint8_t numberOfBlocks[3]; + uint8_t reserved; + uint8_t blockLength[3]; }; typedef struct SCSI_ModeParamBlockDescriptor SCSI_ModeParamBlockDescriptor; union SCSI_ModeParamPage { - unsigned char data[1]; + uint8_t data[1]; struct { - unsigned char code; - unsigned char length; + uint8_t code; + uint8_t length; } page; }; typedef union SCSI_ModeParamPage SCSI_ModeParamPage; @@ -267,9 +267,9 @@ typedef union SCSI_ModeParamPage SCSI_ModeParamPage; * LogSense parameter header */ struct SCSI_LogSenseParamHeader { - unsigned char pageCode; - unsigned char reserved; - unsigned char pageLength[2]; + uint8_t pageCode; + uint8_t reserved; + uint8_t pageLength[2]; }; typedef struct SCSI_LogSenseParamHeader SCSI_LogSenseParamHeader; @@ -277,11 +277,11 @@ typedef struct SCSI_LogSenseParamHeader SCSI_LogSenseParamHeader; * Log parameter pages are variable-length with a fixed length header. */ union SCSI_LogSenseParamPage { - unsigned char data[1]; + uint8_t data[1]; struct { - unsigned char parameterCode[2]; - unsigned char flags; - unsigned char parameterLength; + uint8_t parameterCode[2]; + uint8_t flags; + uint8_t parameterLength; } page; }; typedef union SCSI_LogSenseParamPage SCSI_LogSenseParamPage; diff --git a/dist/pdisk/SCSI_media.c b/dist/pdisk/SCSI_media.c index 9502b24a041..d45db41ce86 100644 --- a/dist/pdisk/SCSI_media.c +++ b/dist/pdisk/SCSI_media.c @@ -38,7 +38,7 @@ /* * Defines */ -#define DriverRefNumToSCSI(x) ((signed short) (~(x) - 32)) +#define DriverRefNumToSCSI(x) ((int16_t) (~(x) - 32)) /* @@ -119,8 +119,8 @@ static struct linux_order_cache linux_order; int AsyncSCSIPresent(void); void scsi_init(void); SCSI_MEDIA new_scsi_media(void); -long read_scsi_media(MEDIA m, long long offset, unsigned long count, void *address); -long write_scsi_media(MEDIA m, long long offset, unsigned long count, void *address); +long read_scsi_media(MEDIA m, long long offset, uint32_t count, void *address); +long write_scsi_media(MEDIA m, long long offset, uint32_t count, void *address); long close_scsi_media(MEDIA m); long os_reload_scsi_media(MEDIA m); long compute_id(long bus, long device); @@ -320,14 +320,14 @@ open_scsi_as_media(long bus, long device) long -read_scsi_media(MEDIA m, long long offset, unsigned long count, void *address) +read_scsi_media(MEDIA m, long long offset, uint32_t count, void *address) { SCSI_MEDIA a; long rtn_value; long block; long block_count; long block_size; - unsigned char *buffer; + uint8_t *buffer; int i; block = (long) offset; @@ -365,14 +365,14 @@ read_scsi_media(MEDIA m, long long offset, unsigned long count, void *address) long -write_scsi_media(MEDIA m, long long offset, unsigned long count, void *address) +write_scsi_media(MEDIA m, long long offset, uint32_t count, void *address) { SCSI_MEDIA a; long rtn_value; long block; long block_count; long block_size; - unsigned char *buffer; + uint8_t *buffer; int i; a = (SCSI_MEDIA) m; diff --git a/dist/pdisk/bitfield.c b/dist/pdisk/bitfield.c index 31f1ff2ceb4..c52b6c6bc82 100644 --- a/dist/pdisk/bitfield.c +++ b/dist/pdisk/bitfield.c @@ -27,6 +27,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include <stdint.h> #include "bitfield.h" @@ -43,7 +44,7 @@ // // Global Constants // -const unsigned long masks[] = { +const uint32_t masks[] = { 0x00000000, 0x00000001, 0x00000003, 0x00000007, 0x0000000F, 0x0000001F, 0x0000003F, 0x0000007F, 0x000000FF, @@ -69,11 +70,11 @@ const unsigned long masks[] = { // // Routines // -unsigned long -bitfield_set(unsigned long *bf, int base, int length, unsigned long value) +uint32_t +bitfield_set(uint32_t *bf, int base, int length, uint32_t value) { - unsigned long t; - unsigned long m; + uint32_t t; + uint32_t m; int s; // compute shift & mask, coerce value to correct number of bits, @@ -87,10 +88,10 @@ bitfield_set(unsigned long *bf, int base, int length, unsigned long value) } -unsigned long -bitfield_get(unsigned long bf, int base, int length) +uint32_t +bitfield_get(uint32_t bf, int base, int length) { - unsigned long m; + uint32_t m; int s; // compute shift & mask diff --git a/dist/pdisk/bitfield.h b/dist/pdisk/bitfield.h index 5086f6b7906..12a78e5052d 100644 --- a/dist/pdisk/bitfield.h +++ b/dist/pdisk/bitfield.h @@ -66,7 +66,8 @@ // // Forward declarations // -unsigned long bitfield_set(unsigned long *bf, int base, int length, unsigned long value); -unsigned long bitfield_get(unsigned long bf, int base, int length); +uint32_t bitfield_set(uint32_t *bf, int base, int length, uint32_t value); + +uint32_t bitfield_get(uint32_t bf, int base, int length); #endif /* __bitfield__ */ diff --git a/dist/pdisk/convert.c b/dist/pdisk/convert.c index 2533156c9ba..d3e68a89b66 100644 --- a/dist/pdisk/convert.c +++ b/dist/pdisk/convert.c @@ -64,8 +64,8 @@ // // Forward declarations // -void reverse2(u8 *bytes); -void reverse4(u8 *bytes); +void reverse2(uint8_t *bytes); +void reverse4(uint8_t *bytes); // @@ -77,21 +77,21 @@ convert_dpme(DPME *data, int to_cpu_form) #if BYTE_ORDER == LITTLE_ENDIAN // Since we will toss the block if the signature doesn't match // we don't need to check the signature down here. - reverse2((u8 *)&data->dpme_signature); - reverse2((u8 *)&data->dpme_reserved_1); - reverse4((u8 *)&data->dpme_map_entries); - reverse4((u8 *)&data->dpme_pblock_start); - reverse4((u8 *)&data->dpme_pblocks); - reverse4((u8 *)&data->dpme_lblock_start); - reverse4((u8 *)&data->dpme_lblocks); - reverse4((u8 *)&data->dpme_flags); - reverse4((u8 *)&data->dpme_boot_block); - reverse4((u8 *)&data->dpme_boot_bytes); - reverse4((u8 *)&data->dpme_load_addr); - reverse4((u8 *)&data->dpme_load_addr_2); - reverse4((u8 *)&data->dpme_goto_addr); - reverse4((u8 *)&data->dpme_goto_addr_2); - reverse4((u8 *)&data->dpme_checksum); + reverse2((uint8_t *)&data->dpme_signature); + reverse2((uint8_t *)&data->dpme_reserved_1); + reverse4((uint8_t *)&data->dpme_map_entries); + reverse4((uint8_t *)&data->dpme_pblock_start); + reverse4((uint8_t *)&data->dpme_pblocks); + reverse4((uint8_t *)&data->dpme_lblock_start); + reverse4((uint8_t *)&data->dpme_lblocks); + reverse4((uint8_t *)&data->dpme_flags); + reverse4((uint8_t *)&data->dpme_boot_block); + reverse4((uint8_t *)&data->dpme_boot_bytes); + reverse4((uint8_t *)&data->dpme_load_addr); + reverse4((uint8_t *)&data->dpme_load_addr_2); + reverse4((uint8_t *)&data->dpme_goto_addr); + reverse4((uint8_t *)&data->dpme_goto_addr_2); + reverse4((uint8_t *)&data->dpme_checksum); convert_bzb((BZB *)data->dpme_bzb, to_cpu_form); #endif return 0; @@ -106,9 +106,9 @@ convert_bzb(BZB *data, int to_cpu_form) // do not want to convert willy-nilly. We use the flag to determine // whether to check for the signature before or after we flip the bytes. if (to_cpu_form) { - reverse4((u8 *)&data->bzb_magic); + reverse4((uint8_t *)&data->bzb_magic); if (data->bzb_magic != BZBMAGIC) { - reverse4((u8 *)&data->bzb_magic); + reverse4((uint8_t *)&data->bzb_magic); if (data->bzb_magic != BZBMAGIC) { return 0; } @@ -117,13 +117,13 @@ convert_bzb(BZB *data, int to_cpu_form) if (data->bzb_magic != BZBMAGIC) { return 0; } - reverse4((u8 *)&data->bzb_magic); + reverse4((uint8_t *)&data->bzb_magic); } - reverse2((u8 *)&data->bzb_inode); - reverse4((u8 *)&data->bzb_flags); - reverse4((u8 *)&data->bzb_tmade); - reverse4((u8 *)&data->bzb_tmount); - reverse4((u8 *)&data->bzb_tumount); + reverse2((uint8_t *)&data->bzb_inode); + reverse4((uint8_t *)&data->bzb_flags); + reverse4((uint8_t *)&data->bzb_tmade); + reverse4((uint8_t *)&data->bzb_tmount); + reverse4((uint8_t *)&data->bzb_tumount); return 0; } #endif @@ -134,7 +134,7 @@ convert_block0(Block0 *data, int to_cpu_form) { #if BYTE_ORDER == LITTLE_ENDIAN DDMap *m; - u16 count; + uint16_t count; int i; // Since this data is optional we do not want to convert willy-nilly. @@ -142,9 +142,9 @@ convert_block0(Block0 *data, int to_cpu_form) // before or after we flip the bytes and to determine which form of // the count to use. if (to_cpu_form) { - reverse2((u8 *)&data->sbSig); + reverse2((uint8_t *)&data->sbSig); if (data->sbSig != BLOCK0_SIGNATURE) { - reverse2((u8 *)&data->sbSig); + reverse2((uint8_t *)&data->sbSig); if (data->sbSig != BLOCK0_SIGNATURE) { return 0; } @@ -153,27 +153,27 @@ convert_block0(Block0 *data, int to_cpu_form) if (data->sbSig != BLOCK0_SIGNATURE) { return 0; } - reverse2((u8 *)&data->sbSig); + reverse2((uint8_t *)&data->sbSig); } - reverse2((u8 *)&data->sbBlkSize); - reverse4((u8 *)&data->sbBlkCount); - reverse2((u8 *)&data->sbDevType); - reverse2((u8 *)&data->sbDevId); - reverse4((u8 *)&data->sbData); + reverse2((uint8_t *)&data->sbBlkSize); + reverse4((uint8_t *)&data->sbBlkCount); + reverse2((uint8_t *)&data->sbDevType); + reverse2((uint8_t *)&data->sbDevId); + reverse4((uint8_t *)&data->sbData); if (to_cpu_form) { - reverse2((u8 *)&data->sbDrvrCount); + reverse2((uint8_t *)&data->sbDrvrCount); count = data->sbDrvrCount; } else { count = data->sbDrvrCount; - reverse2((u8 *)&data->sbDrvrCount); + reverse2((uint8_t *)&data->sbDrvrCount); } if (count > 0) { m = (DDMap *) data->sbMap; for (i = 0; i < count; i++) { - reverse4((u8 *)&m[i].ddBlock); - reverse2((u8 *)&m[i].ddSize); - reverse2((u8 *)&m[i].ddType); + reverse4((uint8_t *)&m[i].ddBlock); + reverse2((uint8_t *)&m[i].ddSize); + reverse2((uint8_t *)&m[i].ddType); } } #endif @@ -182,9 +182,9 @@ convert_block0(Block0 *data, int to_cpu_form) void -reverse2(u8 *bytes) +reverse2(uint8_t *bytes) { - u8 t; + uint8_t t; t = *bytes; *bytes = bytes[1]; @@ -193,9 +193,9 @@ reverse2(u8 *bytes) void -reverse4(u8 *bytes) +reverse4(uint8_t *bytes) { - u8 t; + uint8_t t; t = *bytes; *bytes = bytes[3]; diff --git a/dist/pdisk/cvt_pt.c b/dist/pdisk/cvt_pt.c index 7e142e12b12..148aef478cf 100644 --- a/dist/pdisk/cvt_pt.c +++ b/dist/pdisk/cvt_pt.c @@ -1,7 +1,7 @@ /* * cvt_pt.c * - * Covert partition type. $Revision: 1.5 $ + * Covert partition type. $Revision: 1.6 $ * * Copyright (c) 1999, Eryk Vershen * @@ -135,7 +135,7 @@ trim_num(char *s) } for (t--; t >= s; t--) { - if (!isdigit((unsigned char)*t)) { + if (!isdigit((uint8_t)*t)) { t++; if (*t) { n = atoi(t); diff --git a/dist/pdisk/deblock_media.c b/dist/pdisk/deblock_media.c index f8c691c78cc..b3c46890f4a 100644 --- a/dist/pdisk/deblock_media.c +++ b/dist/pdisk/deblock_media.c @@ -26,6 +26,7 @@ */ +#include <stdio.h> // for malloc() & free() #include <stdlib.h> // for memcpy() @@ -48,8 +49,8 @@ struct deblock_media { struct media m; long need_filtering; MEDIA next_media; - unsigned long next_block_size; - unsigned char *buffer; + uint32_t next_block_size; + uint8_t *buffer; }; struct deblock_globals { @@ -74,8 +75,8 @@ static struct deblock_globals deblock_info; */ void deblock_init(void); DEBLOCK_MEDIA new_deblock_media(void); -long read_deblock_media(MEDIA m, long long offset, unsigned long count, void *address); -long write_deblock_media(MEDIA m, long long offset, unsigned long count, void *address); +long read_deblock_media(MEDIA m, long long offset, uint32_t count, void *address); +long write_deblock_media(MEDIA m, long long offset, uint32_t count, void *address); long close_deblock_media(MEDIA m); long os_reload_deblock_media(MEDIA m); @@ -103,10 +104,10 @@ new_deblock_media(void) MEDIA -open_deblock_media(unsigned long new_block_size, MEDIA m) +open_deblock_media(uint32_t new_block_size, MEDIA m) { DEBLOCK_MEDIA a; - unsigned long block_size; + uint32_t block_size; if (deblock_inited == 0) { deblock_init(); @@ -160,16 +161,16 @@ open_deblock_media(unsigned long new_block_size, MEDIA m) long -read_deblock_media(MEDIA m, long long offset, unsigned long count, void *address) +read_deblock_media(MEDIA m, long long offset, uint32_t count, void *address) { DEBLOCK_MEDIA a; long rtn_value; - unsigned long next_size; - unsigned long partial_offset; - unsigned long partial_count; + uint32_t next_size; + uint32_t partial_offset; + uint32_t partial_count; long long cur_offset; - unsigned long remainder; - unsigned char *addr; + uint32_t remainder; + uint8_t *addr; a = (DEBLOCK_MEDIA) m; rtn_value = 0; @@ -227,16 +228,16 @@ read_deblock_media(MEDIA m, long long offset, unsigned long count, void *address long -write_deblock_media(MEDIA m, long long offset, unsigned long count, void *address) +write_deblock_media(MEDIA m, long long offset, uint32_t count, void *address) { DEBLOCK_MEDIA a; long rtn_value; - unsigned long next_size; - unsigned long partial_offset; - unsigned long partial_count; + uint32_t next_size; + uint32_t partial_offset; + uint32_t partial_count; long long cur_offset; - unsigned long remainder; - unsigned char *addr; + uint32_t remainder; + uint8_t *addr; a = (DEBLOCK_MEDIA) m; rtn_value = 0; diff --git a/dist/pdisk/deblock_media.h b/dist/pdisk/deblock_media.h index acc2ad9d0e5..ab8548831f6 100644 --- a/dist/pdisk/deblock_media.h +++ b/dist/pdisk/deblock_media.h @@ -54,6 +54,6 @@ /* * Forward declarations */ -MEDIA open_deblock_media(unsigned long new_block_size, MEDIA m); +MEDIA open_deblock_media(uint32_t new_block_size, MEDIA m); #endif /* __deblock_media__ */ diff --git a/dist/pdisk/dpme.h b/dist/pdisk/dpme.h index 6d43e82b946..c836982dbd7 100644 --- a/dist/pdisk/dpme.h +++ b/dist/pdisk/dpme.h @@ -53,76 +53,72 @@ // A/UX only stuff (tradition!) #define dpme_bzb dpme_boot_args #define BZBMAGIC 0xABADBABE /* BZB magic number */ -#define FST ((u8) 0x1) /* standard UNIX FS */ -#define FSTEFS ((u8) 0x2) /* Autorecovery FS */ -#define FSTSFS ((u8) 0x3) /* Swap FS */ +#define FST ((uint8_t) 0x1) /* standard UNIX FS */ +#define FSTEFS ((uint8_t) 0x2) /* Autorecovery FS */ +#define FSTSFS ((uint8_t) 0x3) /* Swap FS */ // // Types // -typedef unsigned char u8; -typedef unsigned short u16; -typedef unsigned long u32; - // Physical block zero of the disk has this format struct Block0 { - u16 sbSig; /* unique value for SCSI block 0 */ - u16 sbBlkSize; /* block size of device */ - u32 sbBlkCount; /* number of blocks on device */ - u16 sbDevType; /* device type */ - u16 sbDevId; /* device id */ - u32 sbData; /* not used */ - u16 sbDrvrCount; /* driver descriptor count */ - u16 sbMap[247]; /* descriptor map */ + uint16_t sbSig; /* unique value for SCSI block 0 */ + uint16_t sbBlkSize; /* block size of device */ + uint32_t sbBlkCount; /* number of blocks on device */ + uint16_t sbDevType; /* device type */ + uint16_t sbDevId; /* device id */ + uint32_t sbData; /* not used */ + uint16_t sbDrvrCount; /* driver descriptor count */ + uint16_t sbMap[247]; /* descriptor map */ }; typedef struct Block0 Block0; // Where &sbMap[0] is actually an array DDMap[sbDrvrCount] // kludge to get around alignment junk struct DDMap { - u32 ddBlock; /* 1st driver's starting block (in sbBlkSize blocks!) */ - u16 ddSize; /* size of 1st driver (512-byte blks) */ - u16 ddType; /* system type (1 for Mac+) */ + uint32_t ddBlock; /* 1st driver's starting block (in sbBlkSize blocks!) */ + uint16_t ddSize; /* size of 1st driver (512-byte blks) */ + uint16_t ddType; /* system type (1 for Mac+) */ }; typedef struct DDMap DDMap; // Each partition map entry (blocks 1 through n) has this format struct dpme { - u16 dpme_signature ; - u16 dpme_reserved_1 ; - u32 dpme_map_entries ; - u32 dpme_pblock_start ; - u32 dpme_pblocks ; + uint16_t dpme_signature ; + uint16_t dpme_reserved_1 ; + uint32_t dpme_map_entries ; + uint32_t dpme_pblock_start ; + uint32_t dpme_pblocks ; char dpme_name[DPISTRLEN] ; /* name of partition */ char dpme_type[DPISTRLEN] ; /* type of partition */ - u32 dpme_lblock_start ; - u32 dpme_lblocks ; - u32 dpme_flags; + uint32_t dpme_lblock_start ; + uint32_t dpme_lblocks ; + uint32_t dpme_flags; #if 0 - u32 dpme_reserved_2 : 23 ; /* Bit 9 through 31. */ - u32 dpme_os_specific_1 : 1 ; /* Bit 8. */ - u32 dpme_os_specific_2 : 1 ; /* Bit 7. */ - u32 dpme_os_pic_code : 1 ; /* Bit 6. */ - u32 dpme_writable : 1 ; /* Bit 5. */ - u32 dpme_readable : 1 ; /* Bit 4. */ - u32 dpme_bootable : 1 ; /* Bit 3. */ - u32 dpme_in_use : 1 ; /* Bit 2. */ - u32 dpme_allocated : 1 ; /* Bit 1. */ - u32 dpme_valid : 1 ; /* Bit 0. */ + uint32_t dpme_reserved_2 : 23 ; /* Bit 9 through 31. */ + uint32_t dpme_os_specific_1 : 1 ; /* Bit 8. */ + uint32_t dpme_os_specific_2 : 1 ; /* Bit 7. */ + uint32_t dpme_os_pic_code : 1 ; /* Bit 6. */ + uint32_t dpme_writable : 1 ; /* Bit 5. */ + uint32_t dpme_readable : 1 ; /* Bit 4. */ + uint32_t dpme_bootable : 1 ; /* Bit 3. */ + uint32_t dpme_in_use : 1 ; /* Bit 2. */ + uint32_t dpme_allocated : 1 ; /* Bit 1. */ + uint32_t dpme_valid : 1 ; /* Bit 0. */ #endif - u32 dpme_boot_block ; - u32 dpme_boot_bytes ; - u8 *dpme_load_addr ; - u8 *dpme_load_addr_2 ; - u8 *dpme_goto_addr ; - u8 *dpme_goto_addr_2 ; - u32 dpme_checksum ; + uint32_t dpme_boot_block ; + uint32_t dpme_boot_bytes ; + uint32_t dpme_load_addr ; + uint32_t dpme_load_addr_2 ; + uint32_t dpme_goto_addr ; + uint32_t dpme_goto_addr_2 ; + uint32_t dpme_checksum ; char dpme_process_id[16] ; - u32 dpme_boot_args[32] ; - u32 dpme_reserved_3[62] ; + uint32_t dpme_boot_args[32] ; + uint32_t dpme_reserved_3[62] ; }; typedef struct dpme DPME; @@ -158,9 +154,9 @@ typedef struct dpme DPME; // Alternate block map (aka bad block remaping) [Never really used] struct abm /* altblk map info stored in bzb */ { - u32 abm_size; /* size of map in bytes */ - u32 abm_ents; /* number of used entries */ - u32 abm_start; /* start of altblk map */ + uint32_t abm_size; /* size of map in bytes */ + uint32_t abm_ents; /* number of used entries */ + uint32_t abm_start; /* start of altblk map */ }; typedef struct abm ABM; @@ -169,25 +165,25 @@ typedef struct abm ABM; // kludge to get around alignment junk struct bzb /* block zero block format */ { - u32 bzb_magic; /* magic number */ - u8 bzb_cluster; /* Autorecovery cluster grouping */ - u8 bzb_type; /* FS type */ - u16 bzb_inode; /* bad block inode number */ - u32 bzb_flags; + uint32_t bzb_magic; /* magic number */ + uint8_t bzb_cluster; /* Autorecovery cluster grouping */ + uint8_t bzb_type; /* FS type */ + uint16_t bzb_inode; /* bad block inode number */ + uint32_t bzb_flags; #if 0 - u16 bzb_root:1, /* FS is a root FS */ + uint16_t bzb_root:1, /* FS is a root FS */ bzb_usr:1, /* FS is a usr FS */ bzb_crit:1, /* FS is a critical FS */ bzb_rsrvd:8, /* reserved for later use */ bzb_slice:5; /* slice number to associate with plus one */ - u16 bzb_filler; /* pad bitfield to 32 bits */ + uint16_t bzb_filler; /* pad bitfield to 32 bits */ #endif - u32 bzb_tmade; /* time of FS creation */ - u32 bzb_tmount; /* time of last mount */ - u32 bzb_tumount; /* time of last umount */ + uint32_t bzb_tmade; /* time of FS creation */ + uint32_t bzb_tmount; /* time of last mount */ + uint32_t bzb_tumount; /* time of last umount */ ABM bzb_abm; /* altblk map info */ - u32 bzb_fill2[7]; /* for expansion of ABM (ha!ha!) */ - u8 bzb_mount_point[64]; /* default mount point name */ + uint32_t bzb_fill2[7]; /* for expansion of ABM (ha!ha!) */ + uint8_t bzb_mount_point[64]; /* default mount point name */ }; typedef struct bzb BZB; diff --git a/dist/pdisk/dump.c b/dist/pdisk/dump.c index 1714b61c0d7..fd505132e63 100644 --- a/dist/pdisk/dump.c +++ b/dist/pdisk/dump.c @@ -42,6 +42,7 @@ #include <fcntl.h> // for errno #include <errno.h> +#include <inttypes.h> #include "dump.h" #include "pathname.h" @@ -68,26 +69,26 @@ typedef struct names { } NAMES; #ifdef __unix__ -typedef unsigned long OSType; +typedef uint32_t OSType; #endif typedef struct PatchDescriptor { - OSType patchSig; - unsigned short majorVers; - unsigned short minorVers; - unsigned long flags; - unsigned long patchOffset; - unsigned long patchSize; - unsigned long patchCRC; - unsigned long patchDescriptorLen; - unsigned char patchName[33]; - unsigned char patchVendor[1]; + OSType patchSig; + uint16_t majorVers; + uint16_t minorVers; + uint32_t flags; + uint32_t patchOffset; + uint32_t patchSize; + uint32_t patchCRC; + uint32_t patchDescriptorLen; + uint8_t patchName[33]; + uint8_t patchVendor[1]; } PatchDescriptor; typedef PatchDescriptor * PatchDescriptorPtr; typedef struct PatchList { - unsigned short numPatchBlocks; // number of disk blocks to hold the patch list - unsigned short numPatches; // number of patches in list + uint16_t numPatchBlocks; // number of disk blocks to hold the patch list + uint16_t numPatches; // number of patches in list PatchDescriptor thePatch[1]; } PatchList; typedef PatchList *PatchListPtr; @@ -164,7 +165,7 @@ dump_block_zero(partition_map_header *map) int i; double value; int prefix; - long t; + int32_t t; p = map->misc; if (p->sbSig != BLOCK0_SIGNATURE) { @@ -173,7 +174,7 @@ dump_block_zero(partition_map_header *map) value = ((double)p->sbBlkCount) * p->sbBlkSize; adjust_value_and_compute_prefix(&value, &prefix); - printf("\nDevice block size=%u, Number of Blocks=%lu (%1.1f%c)\n", + printf("\nDevice block size=%u, Number of Blocks=%"PRIu32" (%1.1f%c)\n", p->sbBlkSize, p->sbBlkCount, value, prefix); printf("DeviceType=0x%x, DeviceId=0x%x\n", @@ -182,14 +183,14 @@ dump_block_zero(partition_map_header *map) printf("Drivers-\n"); m = (DDMap *) p->sbMap; for (i = 0; i < p->sbDrvrCount; i++) { - printf("%u: %3u @ %lu, ", i+1, + printf("%u: %3u @ %"PRIu32", ", i+1, m[i].ddSize, get_align_long(&m[i].ddBlock)); if (map->logical_block != p->sbBlkSize) { t = (m[i].ddSize * p->sbBlkSize) / map->logical_block; - printf("(%lu@", t); + printf("(%"PRIu32"@", t); t = (get_align_long(&m[i].ddBlock) * p->sbBlkSize) / map->logical_block; - printf("%lu) ", t); + printf("%"PRIu32") ", t); } printf("type=0x%x\n", m[i].ddType); } @@ -266,7 +267,7 @@ dump_partition_entry(partition_map *entry, int type_length, int name_length, int int j; DPME *p; const char *s; - u32 size; + uint32_t size; double bytes; int driver; // int kind; @@ -286,9 +287,9 @@ dump_partition_entry(partition_map *entry, int type_length, int name_length, int break; } } - printf("%2ld: %.4s", entry->disk_address, s); + printf("%2"PRIu32": %.4s", entry->disk_address, s); } else { - printf("%2ld: %*.32s", entry->disk_address, type_length, p->dpme_type); + printf("%2"PRIu32": %*.32s", entry->disk_address, type_length, p->dpme_type); } buf = (char *) malloc(name_length+1); @@ -312,22 +313,22 @@ dump_partition_entry(partition_map *entry, int type_length, int name_length, int */ if (pflag) { - printf("%*lu ", digits, p->dpme_pblocks); + printf("%*"PRIu32" ", digits, p->dpme_pblocks); size = p->dpme_pblocks; } else if (p->dpme_lblocks + p->dpme_lblock_start != p->dpme_pblocks) { - printf("%*lu+", digits, p->dpme_lblocks); + printf("%*"PRIu32"+", digits, p->dpme_lblocks); size = p->dpme_lblocks; } else if (p->dpme_lblock_start != 0) { - printf("%*lu ", digits, p->dpme_lblocks); + printf("%*"PRIu32" ", digits, p->dpme_lblocks); size = p->dpme_lblocks; } else { - printf("%*lu ", digits, p->dpme_pblocks); + printf("%*"PRIu32" ", digits, p->dpme_pblocks); size = p->dpme_pblocks; } if (pflag || p->dpme_lblock_start == 0) { - printf("@ %-*lu", digits, p->dpme_pblock_start); + printf("@ %-*"PRIu32"", digits, p->dpme_pblock_start); } else { - printf("@~%-*lu", digits, p->dpme_pblock_start + p->dpme_lblock_start); + printf("@~%-*"PRIu32"", digits, p->dpme_pblock_start + p->dpme_lblock_start); } bytes = ((double)size) * map->logical_block; @@ -367,7 +368,7 @@ dump_partition_entry(partition_map *entry, int type_length, int name_length, int break; } if (bzb_slice_get(bp) != 0) { - printf(" s%1ld %4s", bzb_slice_get(bp)-1, s); + printf(" s%1"PRId32" %4s", bzb_slice_get(bp)-1, s); } else if (j >= 0) { printf(" S%1d %4s", j, s); } else { @@ -444,7 +445,7 @@ show_data_structures(partition_map_header *map) return; } printf("Header:\n"); - printf("map %d blocks out of %d, media %lu blocks (%d byte blocks)\n", + printf("map %d blocks out of %d, media %"PRIu32" blocks (%d byte blocks)\n", map->blocks_in_map, map->maximum_in_map, map->media_size, map->logical_block); printf("Map is%s writable", (map->writable)?kStringEmpty:kStringNot); @@ -464,9 +465,9 @@ show_data_structures(partition_map_header *map) } else { printf(" should be 0x%x\n", BLOCK0_SIGNATURE); } - printf("Block size=%u, Number of Blocks=%lu\n", + printf("Block size=%u, Number of Blocks=%"PRIu32"\n", zp->sbBlkSize, zp->sbBlkCount); - printf("DeviceType=0x%x, DeviceId=0x%x, sbData=0x%lx\n", + printf("DeviceType=0x%x, DeviceId=0x%x, sbData=0x%"PRIx32"\n", zp->sbDevType, zp->sbDevId, zp->sbData); if (zp->sbDrvrCount == 0) { printf("No drivers\n"); @@ -475,7 +476,7 @@ show_data_structures(partition_map_header *map) (zp->sbDrvrCount>1)?"s":kStringEmpty); m = (DDMap *) zp->sbMap; for (i = 0; i < zp->sbDrvrCount; i++) { - printf("%u: @ %lu for %u, type=0x%x\n", i+1, + printf("%u: @ %"PRIu32" for %u, type=0x%x\n", i+1, get_align_long(&m[i].ddBlock), m[i].ddSize, m[i].ddType); } @@ -484,16 +485,16 @@ show_data_structures(partition_map_header *map) printf("\n"); /* -u32 dpme_boot_args[32] ; -u32 dpme_reserved_3[62] ; +uint32_t dpme_boot_args[32] ; +uint32_t dpme_reserved_3[62] ; */ printf(" #: type length base " "flags (logical)\n"); for (entry = map->disk_order; entry != NULL; entry = entry->next_on_disk) { p = entry->data; - printf("%2ld: %20.32s ", + printf("%2"PRIu32": %20.32s ", entry->disk_address, p->dpme_type); - printf("%7lu @ %-7lu ", p->dpme_pblocks, p->dpme_pblock_start); + printf("%7"PRIu32" @ %-7"PRIu32" ", p->dpme_pblocks, p->dpme_pblock_start); printf("%c%c%c%c%c%c%c%c%c%c%c%c ", (dpme_valid_get(p))?'V':'.', (dpme_allocated_get(p))?'A':'.', @@ -508,7 +509,7 @@ u32 dpme_reserved_3[62] ; (bitfield_get(p->dpme_flags, 30, 1))?'M':'.', (bitfield_get(p->dpme_flags, 31, 1))?'X':'.'); if (p->dpme_lblock_start != 0 || p->dpme_pblocks != p->dpme_lblocks) { - printf("(%lu @ %lu)", p->dpme_lblocks, p->dpme_lblock_start); + printf("(%"PRIu32" @ %"PRIu32")", p->dpme_lblocks, p->dpme_lblock_start); } printf("\n"); } @@ -517,14 +518,14 @@ u32 dpme_reserved_3[62] ; "goto_address checksum processor\n"); for (entry = map->disk_order; entry != NULL; entry = entry->next_on_disk) { p = entry->data; - printf("%2ld: ", entry->disk_address); - printf("%7lu ", p->dpme_boot_block); - printf("%7lu ", p->dpme_boot_bytes); - printf("%8lx ", (u32)p->dpme_load_addr); - printf("%8lx ", (u32)p->dpme_load_addr_2); - printf("%8lx ", (u32)p->dpme_goto_addr); - printf("%8lx ", (u32)p->dpme_goto_addr_2); - printf("%8lx ", p->dpme_checksum); + printf("%2"PRIu32": ", entry->disk_address); + printf("%7"PRIu32" ", p->dpme_boot_block); + printf("%7"PRIu32" ", p->dpme_boot_bytes); + printf("%8"PRIx32" ", (uint32_t)p->dpme_load_addr); + printf("%8"PRIx32" ", (uint32_t)p->dpme_load_addr_2); + printf("%8"PRIx32" ", (uint32_t)p->dpme_goto_addr); + printf("%8"PRIx32" ", (uint32_t)p->dpme_goto_addr_2); + printf("%8"PRIx32" ", p->dpme_checksum); printf("%.32s", p->dpme_process_id); printf("\n"); } @@ -535,7 +536,7 @@ xx: cccc RU *dd s... printf(" #: type RU *slice mount_point (A/UX only fields)\n"); for (entry = map->disk_order; entry != NULL; entry = entry->next_on_disk) { p = entry->data; - printf("%2ld: ", entry->disk_address); + printf("%2"PRIu32": ", entry->disk_address); bp = (BZB *) (p->dpme_bzb); j = -1; @@ -563,7 +564,7 @@ xx: cccc RU *dd s... (bzb_root_get(bp))?'R':' ', (bzb_usr_get(bp))?'U':' '); if (bzb_slice_get(bp) != 0) { - printf(" %2ld", bzb_slice_get(bp)-1); + printf(" %2"PRIu32"", bzb_slice_get(bp)-1); } else if (j >= 0) { printf(" *%2d", j); } else { @@ -584,7 +585,7 @@ full_dump_partition_entry(partition_map_header *map, int ix) partition_map * cur; DPME *p; int i; - u32 t; + uint32_t t; cur = find_entry_by_disk_address(ix, map); if (cur == NULL) { @@ -595,11 +596,11 @@ full_dump_partition_entry(partition_map_header *map, int ix) p = cur->data; printf(" signature: 0x%x\n", p->dpme_signature); printf(" reserved1: 0x%x\n", p->dpme_reserved_1); - printf(" number of map entries: %ld\n", p->dpme_map_entries); - printf(" physical start: %10lu length: %10lu\n", p->dpme_pblock_start, p->dpme_pblocks); - printf(" logical start: %10lu length: %10lu\n", p->dpme_lblock_start, p->dpme_lblocks); + printf(" number of map entries: %"PRId32"\n", p->dpme_map_entries); + printf(" physical start: %10"PRIu32" length: %10"PRIu32"\n", p->dpme_pblock_start, p->dpme_pblocks); + printf(" logical start: %10"PRIu32" length: %10"PRIu32"\n", p->dpme_lblock_start, p->dpme_lblocks); - printf(" flags: 0x%lx\n", (u32)p->dpme_flags); + printf(" flags: 0x%"PRIx32"\n", (uint32_t)p->dpme_flags); printf(" "); if (dpme_valid_get(p)) printf("valid "); if (dpme_allocated_get(p)) printf("alloc "); @@ -620,23 +621,23 @@ full_dump_partition_entry(partition_map_header *map, int ix) printf(" name: '%.32s'\n", p->dpme_name); printf(" type: '%.32s'\n", p->dpme_type); - printf(" boot start block: %10lu\n", p->dpme_boot_block); - printf("boot length (in bytes): %10lu\n", p->dpme_boot_bytes); - printf(" load address: 0x%08lx 0x%08lx\n", - (u32)p->dpme_load_addr, (u32)p->dpme_load_addr_2); - printf(" start address: 0x%08lx 0x%08lx\n", - (u32)p->dpme_goto_addr, (u32)p->dpme_goto_addr_2); - printf(" checksum: 0x%08lx\n", p->dpme_checksum); + printf(" boot start block: %10"PRIu32"\n", p->dpme_boot_block); + printf("boot length (in bytes): %10"PRIu32"\n", p->dpme_boot_bytes); + printf(" load address: 0x%08"PRIx32" 0x%08"PRIx32"\n", + (uint32_t)p->dpme_load_addr, (uint32_t)p->dpme_load_addr_2); + printf(" start address: 0x%08"PRIx32" 0x%08"PRIx32"\n", + (uint32_t)p->dpme_goto_addr, (uint32_t)p->dpme_goto_addr_2); + printf(" checksum: 0x%08"PRIx32"\n", p->dpme_checksum); printf(" processor: '%.32s'\n", p->dpme_process_id); printf("boot args field -"); - dump_block((unsigned char *)p->dpme_boot_args, 32*4); + dump_block((uint8_t *)p->dpme_boot_args, 32*4); printf("dpme_reserved_3 -"); - dump_block((unsigned char *)p->dpme_reserved_3, 62*4); + dump_block((uint8_t *)p->dpme_reserved_3, 62*4); } void -dump_block(unsigned char *addr, int len) +dump_block(uint8_t *addr, int len) { int i; int j; @@ -699,22 +700,22 @@ full_dump_block_zero(partition_map_header *map) printf(" signature: 0x%x\n", zp->sbSig); printf(" size of a block: %d\n", zp->sbBlkSize); - printf(" number of blocks: %ld\n", zp->sbBlkCount); + printf(" number of blocks: %"PRId32"\n", zp->sbBlkCount); printf(" device type: 0x%x\n", zp->sbDevType); printf(" device id: 0x%x\n", zp->sbDevId); - printf(" data: 0x%lx\n", zp->sbData); + printf(" data: 0x%"PRIx32"\n", zp->sbData); printf(" driver count: %d\n", zp->sbDrvrCount); m = (DDMap *) zp->sbMap; for (i = 0; &m[i].ddType < &zp->sbMap[247]; i++) { if (m[i].ddBlock == 0 && m[i].ddSize == 0 && m[i].ddType == 0) { break; } - printf(" driver %3u block: %ld\n", i+1, m[i].ddBlock); + printf(" driver %3u block: %"PRId32"\n", i+1, m[i].ddBlock); printf(" size in blocks: %d\n", m[i].ddSize); printf(" driver type: 0x%x\n", m[i].ddType); } printf("remainder of block -"); - dump_block((unsigned char *)(void *)&m[i].ddBlock, (&zp->sbMap[247]-((unsigned short *)(void *)&m[i].ddBlock))*2); + dump_block((uint8_t *)(void *)&m[i].ddBlock, (&zp->sbMap[247]-((uint16_t *)(void *)&m[i].ddBlock))*2); } @@ -723,18 +724,18 @@ display_patches(partition_map *entry) { long long offset; MEDIA m; - static unsigned char *patch_block; + static uint8_t *patch_block; PatchListPtr p; PatchDescriptorPtr q; - unsigned char *next; - unsigned char *s; + uint8_t *next; + uint8_t *s; int i; offset = entry->data->dpme_pblock_start; m = entry->the_map->m; offset = ((long long) entry->data->dpme_pblock_start) * entry->the_map->logical_block; if (patch_block == NULL) { - patch_block = (unsigned char *) malloc(PBLOCK_SIZE); + patch_block = (uint8_t *) malloc(PBLOCK_SIZE); if (patch_block == NULL) { error(errno, "can't allocate memory for patch block buffer"); return; @@ -748,7 +749,7 @@ display_patches(partition_map *entry) if (p->numPatchBlocks != 1) { i = p->numPatchBlocks; free(patch_block); - patch_block = (unsigned char *) malloc(PBLOCK_SIZE*i); + patch_block = (uint8_t *) malloc(PBLOCK_SIZE*i); if (patch_block == NULL) { error(errno, "can't allocate memory for patch blocks buffer"); return; @@ -769,13 +770,13 @@ display_patches(partition_map *entry) for (i = 0; i < p->numPatches; i++) { printf("%2d signature: '%.4s'\n", i+1, (char *)&q->patchSig); printf(" version: %d.%d\n", q->majorVers, q->minorVers); - printf(" flags: 0x%lx\n", q->flags); - printf(" offset: %ld\n", q->patchOffset); - printf(" size: %ld\n", q->patchSize); - printf(" CRC: 0x%lx\n", q->patchCRC); + printf(" flags: 0x%"PRIx32"\n", q->flags); + printf(" offset: %"PRId32"\n", q->patchOffset); + printf(" size: %"PRId32"\n", q->patchSize); + printf(" CRC: 0x%"PRIx32"\n", q->patchCRC); printf(" name: '%.*s'\n", q->patchName[0], &q->patchName[1]); printf(" vendor: '%.*s'\n", q->patchVendor[0], &q->patchVendor[1]); - next = ((unsigned char *)q) + q->patchDescriptorLen; + next = ((uint8_t *)q) + q->patchDescriptorLen; s = &q->patchVendor[q->patchVendor[0]+1]; if (next > s) { printf("remainder of entry -"); @@ -846,7 +847,7 @@ int get_max_base_or_length(partition_map_header *map) { partition_map * entry; - unsigned int max; + uint32_t max; if (map == NULL) { return 0; diff --git a/dist/pdisk/dump.h b/dist/pdisk/dump.h index 86147503fb5..7ec582f24cf 100644 --- a/dist/pdisk/dump.h +++ b/dist/pdisk/dump.h @@ -62,7 +62,7 @@ extern int fflag; // void display_patches(partition_map *entry); int dump(char *name); -void dump_block(unsigned char *addr, int len); +void dump_block(uint8_t *addr, int len); void dump_partition_map(partition_map_header *map, int disk_order); void full_dump_partition_entry(partition_map_header *, int); void full_dump_block_zero(partition_map_header *map); diff --git a/dist/pdisk/file_media.c b/dist/pdisk/file_media.c index 542124a3795..1b8fc544193 100644 --- a/dist/pdisk/file_media.c +++ b/dist/pdisk/file_media.c @@ -100,7 +100,7 @@ struct file_media_iterator { * Global Constants */ int potential_block_sizes[] = { - 1, 512, 1024, 2048, + 1, 512, 1024, 2048, 4096, 8192, 16834, 0 }; @@ -124,8 +124,8 @@ static struct file_media_globals file_info; int compute_block_size(int fd); void file_init(void); FILE_MEDIA new_file_media(void); -long read_file_media(MEDIA m, long long offset, unsigned long count, void *address); -long write_file_media(MEDIA m, long long offset, unsigned long count, void *address); +long read_file_media(MEDIA m, long long offset, uint32_t count, void *address); +long write_file_media(MEDIA m, long long offset, uint32_t count, void *address); long close_file_media(MEDIA m); long os_reload_file_media(MEDIA m); FILE_MEDIA_ITERATOR new_file_iterator(void); @@ -249,7 +249,7 @@ open_file_as_media(char *file, int oflag) long -read_file_media(MEDIA m, long long offset, unsigned long count, void *address) +read_file_media(MEDIA m, long long offset, uint32_t count, void *address) { FILE_MEDIA a; long rtn_value; @@ -294,7 +294,7 @@ read_file_media(MEDIA m, long long offset, unsigned long count, void *address) long -write_file_media(MEDIA m, long long offset, unsigned long count, void *address) +write_file_media(MEDIA m, long long offset, uint32_t count, void *address) { FILE_MEDIA a; long rtn_value; diff --git a/dist/pdisk/hfs_misc.c b/dist/pdisk/hfs_misc.c index 3189f367564..c2382a51778 100644 --- a/dist/pdisk/hfs_misc.c +++ b/dist/pdisk/hfs_misc.c @@ -25,6 +25,8 @@ // for errno #include <errno.h> +#include <inttypes.h> + #include "hfs_misc.h" #include "partition_map.h" #include "convert.h" @@ -38,7 +40,7 @@ #define HFS_SIG 0x4244 /* i.e 'BD' */ #define HFS_PLUS_SIG 0x482B /* i.e 'H+' */ -#define get_align_long(x) (*(u32*)(x)) +#define get_align_long(x) (*(uint32_t*)(x)) // @@ -47,8 +49,8 @@ typedef long long u64; typedef struct ExtDescriptor { // extent descriptor - u16 xdrStABN; // first allocation block - u16 xdrNumABlks; // number of allocation blocks + uint16_t xdrStABN; // first allocation block + uint16_t xdrNumABlks; // number of allocation blocks } ext_descriptor; typedef struct ExtDataRec { @@ -56,87 +58,87 @@ typedef struct ExtDataRec { } ext_data_rec; /* - * The crazy "u16 x[2]" stuff here is to get around the fact + * The crazy "uint16_t x[2]" stuff here is to get around the fact * that I can't convince the Mac compiler to align on 32 bit * quantities on 16 bit boundaries... */ struct mdb_record { // master directory block - u16 drSigWord; // volume signature - u16 drCrDate[2]; // date and time of volume creation - u16 drLsMod[2]; // date and time of last modification - u16 drAtrb; // volume attributes - u16 drNmFls; // number of files in root directory - u16 drVBMSt; // first block of volume bitmap - u16 drAllocPtr; // start of next allocation search - u16 drNmAlBlks; // number of allocation blocks in volume - u32 drAlBlkSiz; // size (in bytes) of allocation blocks - u32 drClpSiz; // default clump size - u16 drAlBlSt; // first allocation block in volume - u16 drNxtCNID[2]; // next unused catalog node ID - u16 drFreeBks; // number of unused allocation blocks + uint16_t drSigWord; // volume signature + uint16_t drCrDate[2]; // date and time of volume creation + uint16_t drLsMod[2]; // date and time of last modification + uint16_t drAtrb; // volume attributes + uint16_t drNmFls; // number of files in root directory + uint16_t drVBMSt; // first block of volume bitmap + uint16_t drAllocPtr; // start of next allocation search + uint16_t drNmAlBlks; // number of allocation blocks in volume + uint32_t drAlBlkSiz; // size (in bytes) of allocation blocks + uint32_t drClpSiz; // default clump size + uint16_t drAlBlSt; // first allocation block in volume + uint16_t drNxtCNID[2]; // next unused catalog node ID + uint16_t drFreeBks; // number of unused allocation blocks char drVN[28]; // volume name - u16 drVolBkUp[2]; // date and time of last backup - u16 drVSeqNum; // volume backup sequence number - u16 drWrCnt[2]; // volume write count - u16 drXTClpSiz[2]; // clump size for extents overflow file - u16 drCTClpSiz[2]; // clump size for catalog file - u16 drNmRtDirs; // number of directories in root directory - u32 drFilCnt; // number of files in volume - u32 drDirCnt; // number of directories in volume - u32 drFndrInfo[8]; // information used by the Finder + uint16_t drVolBkUp[2]; // date and time of last backup + uint16_t drVSeqNum; // volume backup sequence number + uint16_t drWrCnt[2]; // volume write count + uint16_t drXTClpSiz[2]; // clump size for extents overflow file + uint16_t drCTClpSiz[2]; // clump size for catalog file + uint16_t drNmRtDirs; // number of directories in root directory + uint32_t drFilCnt; // number of files in volume + uint32_t drDirCnt; // number of directories in volume + uint32_t drFndrInfo[8]; // information used by the Finder #ifdef notdef - u16 drVCSize; // size (in blocks) of volume cache - u16 drVBMCSize; // size (in blocks) of volume bitmap cache - u16 drCtlCSize; // size (in blocks) of common volume cache + uint16_t drVCSize; // size (in blocks) of volume cache + uint16_t drVBMCSize; // size (in blocks) of volume bitmap cache + uint16_t drCtlCSize; // size (in blocks) of common volume cache #else - u16 drEmbedSigWord; // type of embedded volume + uint16_t drEmbedSigWord; // type of embedded volume ext_descriptor drEmbedExtent; // embedded volume extent #endif - u16 drXTFlSize[2]; // size of extents overflow file + uint16_t drXTFlSize[2]; // size of extents overflow file ext_data_rec drXTExtRec; // extent record for extents overflow file - u16 drCTFlSize[2]; // size of catalog file + uint16_t drCTFlSize[2]; // size of catalog file ext_data_rec drCTExtRec; // extent record for catalog file }; -typedef u32 HFSCatalogNodeID; +typedef uint32_t HFSCatalogNodeID; typedef struct HFSPlusExtentDescriptor { - u32 startBlock; - u32 blockCount; + uint32_t startBlock; + uint32_t blockCount; } HFSPlusExtentDescriptor; typedef HFSPlusExtentDescriptor HFSPlusExtentRecord[ 8]; typedef struct HFSPlusForkData { u64 logicalSize; - u32 clumpSize; - u32 totalBlocks; + uint32_t clumpSize; + uint32_t totalBlocks; HFSPlusExtentRecord extents; } HFSPlusForkData; struct HFSPlusVolumeHeader { - u16 signature; - u16 version; - u32 attributes; - u32 lastMountedVersion; - u32 reserved; - u32 createDate; - u32 modifyDate; - u32 backupDate; - u32 checkedDate; - u32 fileCount; - u32 folderCount; - u32 blockSize; - u32 totalBlocks; - u32 freeBlocks; - u32 nextAllocation; - u32 rsrcClumpSize; - u32 dataClumpSize; + uint16_t signature; + uint16_t version; + uint32_t attributes; + uint32_t lastMountedVersion; + uint32_t reserved; + uint32_t createDate; + uint32_t modifyDate; + uint32_t backupDate; + uint32_t checkedDate; + uint32_t fileCount; + uint32_t folderCount; + uint32_t blockSize; + uint32_t totalBlocks; + uint32_t freeBlocks; + uint32_t nextAllocation; + uint32_t rsrcClumpSize; + uint32_t dataClumpSize; HFSCatalogNodeID nextCatalogID; - u32 writeCount; + uint32_t writeCount; u64 encodingsBitmap; - u8 finderInfo[ 32]; + uint8_t finderInfo[ 32]; HFSPlusForkData allocationFile; HFSPlusForkData extentsFile; HFSPlusForkData catalogFile; @@ -158,17 +160,17 @@ struct HFSPlusVolumeHeader { // // Forward declarations // -u32 embeded_offset(struct mdb_record *mdb, u32 sector); -int read_partition_block(partition_map *entry, unsigned long num, char *buf); +uint32_t embeded_offset(struct mdb_record *mdb, uint32_t sector); +int read_partition_block(partition_map *entry, uint32_t num, char *buf); // // Routines // -u32 -embeded_offset(struct mdb_record *mdb, u32 sector) +uint32_t +embeded_offset(struct mdb_record *mdb, uint32_t sector) { - u32 e_offset; + uint32_t e_offset; e_offset = mdb->drAlBlSt + mdb->drEmbedExtent.xdrStABN * (mdb->drAlBlkSiz / 512); @@ -205,7 +207,7 @@ get_HFS_name(partition_map *entry, int *kind) *kind = kHFS_plus; } else if (mdb->drSigWord != HFS_SIG) { // not HFS !!! - printf("%lu not HFS\n", entry->disk_address); + // printf("%"PRIu32" not HFS\n", entry->disk_address); *kind = kHFS_not; } else if (mdb->drEmbedSigWord != HFS_PLUS_SIG) { // HFS @@ -233,11 +235,11 @@ not_hfs: // really need a function to read block n from partition m int -read_partition_block(partition_map *entry, unsigned long num, char *buf) +read_partition_block(partition_map *entry, uint32_t num, char *buf) { DPME *data; partition_map_header * map; - u32 base; + uint32_t base; u64 offset; map = entry->the_map; diff --git a/dist/pdisk/io.c b/dist/pdisk/io.c index 63179c1b81b..f11885d7a19 100644 --- a/dist/pdisk/io.c +++ b/dist/pdisk/io.c @@ -369,12 +369,12 @@ get_string(int eos) } -unsigned long +uint32_t get_multiplier(long divisor) { int c; - unsigned long result; - unsigned long extra; + uint32_t result; + uint32_t extra; c = my_getch(); @@ -433,7 +433,7 @@ get_partition_modifier(void) int -number_of_digits(unsigned long value) +number_of_digits(uint32_t value) { int j; diff --git a/dist/pdisk/io.h b/dist/pdisk/io.h index 4194e196882..8cb326700e2 100644 --- a/dist/pdisk/io.h +++ b/dist/pdisk/io.h @@ -57,11 +57,11 @@ extern const long kDefault; void bad_input(const char *fmt, ...); void flush_to_newline(int keep_newline); int get_command(const char *prompt, int promptBeforeGet, int *command); -unsigned long get_multiplier(long divisor); +uint32_t get_multiplier(long divisor); int get_number_argument(const char *prompt, long *number, long default_value); int get_okay(const char *prompt, int default_value); int get_partition_modifier(void); int get_string_argument(const char *prompt, char **string, int reprompt); -int number_of_digits(unsigned long value); +int number_of_digits(uint32_t value); #endif /* __io__ */ diff --git a/dist/pdisk/layout_dump.c b/dist/pdisk/layout_dump.c index 23519f75452..dd1e24f8b47 100644 --- a/dist/pdisk/layout_dump.c +++ b/dist/pdisk/layout_dump.c @@ -29,6 +29,7 @@ #include <stdio.h> // for strlen() #include <string.h> +#include <inttypes.h> #include "layout_dump.h" @@ -45,7 +46,7 @@ /* * Global Constants */ -unsigned char bitmasks[] = { +uint8_t bitmasks[] = { 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0xFF }; @@ -97,7 +98,7 @@ dump_using_layout(void *buffer, layout *desc) value = 0; for (i = entry->byte_offset; byte_length > 0;i++) { value = value << 8; - value |= ((unsigned char *)buffer)[i]; + value |= ((uint8_t *)buffer)[i]; byte_length--; } } else { @@ -110,29 +111,29 @@ dump_using_layout(void *buffer, layout *desc) entry->bit_offset, entry->bit_length); continue; } - value = (((unsigned char *)buffer)[entry->byte_offset] + value = (((uint8_t *)buffer)[entry->byte_offset] & bitmasks[entry->bit_offset]) >> ((entry->bit_offset + 1) - entry->bit_length); } switch (entry->format) { case kHex: - printf("0x%x\n", (unsigned int) value); + printf("0x%x\n", (uint32_t) value); break; case kDec: byte_length = entry->bit_length / 8; switch (byte_length) { - case 4: printf("%ld\n", (signed long)value); break; - case 2: printf("%d\n", (signed short)value); break; - case 1: printf("%d\n", (signed char)value); break; + case 4: printf("%"PRId32"\n", (int32_t)value); break; + case 2: printf("%"PRId16"\n", (int16_t)value); break; + case 1: printf("%"PRId8"\n", (int8_t)value); break; } break; case kUns: byte_length = entry->bit_length / 8; switch (byte_length) { - case 4: printf("%lu\n", (unsigned long)value); break; - case 2: printf("%u\n", (unsigned short)value); break; - case 1: printf("%u\n", (unsigned char)value); break; + case 4: printf("%"PRIu32"\n", (uint32_t)value); break; + case 2: printf("%"PRIu16"\n", (uint16_t)value); break; + case 1: printf("%"PRIu8"\n", (uint8_t)value); break; } break; case kBit: @@ -149,7 +150,7 @@ dump_using_layout(void *buffer, layout *desc) void -DumpRawBuffer(unsigned char *bufferPtr, int length ) +DumpRawBuffer(uint8_t *bufferPtr, int length ) { register int i; int lineStart; diff --git a/dist/pdisk/layout_dump.h b/dist/pdisk/layout_dump.h index e47821b3f3c..239ac9cfa41 100644 --- a/dist/pdisk/layout_dump.h +++ b/dist/pdisk/layout_dump.h @@ -73,6 +73,6 @@ typedef struct { * Routines */ void dump_using_layout(void *buffer, layout *desc); -void DumpRawBuffer(unsigned char *bufferPtr, int length); +void DumpRawBuffer(uint8_t *bufferPtr, int length); #endif /* __layout_dump__ */ diff --git a/dist/pdisk/makefile b/dist/pdisk/makefile index 179aeda19a5..04c66a45383 100644 --- a/dist/pdisk/makefile +++ b/dist/pdisk/makefile @@ -129,7 +129,7 @@ MAC_68KBINARY= \ pdisk_68k.hqx -CFLAGS = -Wall -D__unix__ +CFLAGS = -Wall -D__unix__ -g DIST_TAR_FLAGS = cvf diff --git a/dist/pdisk/media.c b/dist/pdisk/media.c index 2fb3fc96448..cb4c7b7a2a1 100644 --- a/dist/pdisk/media.c +++ b/dist/pdisk/media.c @@ -87,7 +87,7 @@ delete_media(MEDIA m) } -unsigned long +uint32_t media_granularity(MEDIA m) { if (m == 0) { @@ -110,7 +110,7 @@ media_total_size(MEDIA m) long -read_media(MEDIA m, long long offset, unsigned long count, void *address) +read_media(MEDIA m, long long offset, uint32_t count, void *address) { long result; @@ -126,7 +126,7 @@ read_media(MEDIA m, long long offset, unsigned long count, void *address) long -write_media(MEDIA m, long long offset, unsigned long count, void *address) +write_media(MEDIA m, long long offset, uint32_t count, void *address) { long result; diff --git a/dist/pdisk/media.h b/dist/pdisk/media.h index fcc237fe95b..f3c34a66167 100644 --- a/dist/pdisk/media.h +++ b/dist/pdisk/media.h @@ -60,14 +60,14 @@ typedef struct media *MEDIA; /* those who define media objects need the struct and internal routine types */ -typedef long (*media_read)(MEDIA m, long long offset, unsigned long count, void *address); -typedef long (*media_write)(MEDIA m, long long offset, unsigned long count, void *address); +typedef long (*media_read)(MEDIA m, long long offset, uint32_t count, void *address); +typedef long (*media_write)(MEDIA m, long long offset, uint32_t count, void *address); typedef long (*media_close)(MEDIA m); typedef long (*media_os_reload)(MEDIA m); struct media { long kind; /* kind of media - SCSI, IDE, etc. */ - unsigned long grain; /* granularity (offset & size) */ + uint32_t grain; /* granularity (offset & size) */ long long size_in_bytes; /* offset granularity */ media_read do_read; /* device specific routines */ media_write do_write; @@ -115,10 +115,10 @@ struct media_iterator { * Forward declarations */ /* those whose use media objects need these routines */ -unsigned long media_granularity(MEDIA m); +uint32_t media_granularity(MEDIA m); long long media_total_size(MEDIA m); -long read_media(MEDIA m, long long offset, unsigned long count, void *address); -long write_media(MEDIA m, long long offset, unsigned long count, void *address); +long read_media(MEDIA m, long long offset, uint32_t count, void *address); +long write_media(MEDIA m, long long offset, uint32_t count, void *address); void close_media(MEDIA m); void os_reload_media(MEDIA m); diff --git a/dist/pdisk/partition_map.c b/dist/pdisk/partition_map.c index 00c9ed670d0..6ee62c3eaa6 100644 --- a/dist/pdisk/partition_map.c +++ b/dist/pdisk/partition_map.c @@ -42,6 +42,8 @@ // for errno #include <errno.h> +#include <inttypes.h> + #include "partition_map.h" #include "pathname.h" #include "hfs_misc.h" @@ -97,18 +99,18 @@ int coerce_block0(partition_map_header *map); int contains_driver(partition_map *entry); void combine_entry(partition_map *entry); long compute_device_size(partition_map_header *map, partition_map_header *oldmap); -DPME* create_data(const char *name, const char *dptype, u32 base, u32 length); +DPME* create_data(const char *name, const char *dptype, uint32_t base, uint32_t length); void delete_entry(partition_map *entry); char *get_HFS_name(partition_map *entry, int *kind); void insert_in_base_order(partition_map *entry); void insert_in_disk_order(partition_map *entry); -int read_block(partition_map_header *map, unsigned long num, char *buf); +int read_block(partition_map_header *map, uint32_t num, char *buf); int read_partition_map(partition_map_header *map); void remove_driver(partition_map *entry); void remove_from_disk_order(partition_map *entry); void renumber_disk_addresses(partition_map_header *map); void sync_device_size(partition_map_header *map); -int write_block(partition_map_header *map, unsigned long num, char *buf); +int write_block(partition_map_header *map, uint32_t num, char *buf); // @@ -234,8 +236,8 @@ int read_partition_map(partition_map_header *map) { DPME *data; - u32 limit; - unsigned int ix; + uint32_t limit; + uint32_t ix; int old_logical; double d; @@ -433,10 +435,10 @@ create_partition_map(char *name, partition_map_header *oldmap) MEDIA m; partition_map_header * map; DPME *data; - unsigned long default_number; - unsigned long number; + uint32_t default_number; + uint32_t number; long size; - unsigned long multiple; + uint32_t multiple; m = open_pathname_as_media(name, (rflag)?O_RDONLY:O_RDWR); if (m == 0) { @@ -507,7 +509,7 @@ create_partition_map(char *name, partition_map_header *oldmap) number = compute_device_size(map, oldmap); if (interactive) { - printf("size of 'device' is %lu blocks (%d byte blocks): ", + printf("size of 'device' is %"PRIu32" blocks (%d byte blocks): ", number, map->logical_block); default_number = number; flush_to_newline(0); @@ -537,7 +539,7 @@ create_partition_map(char *name, partition_map_header *oldmap) if (number < 4) { number = 4; } - printf("new size of 'device' is %lu blocks (%d byte blocks)\n", + printf("new size of 'device' is %"PRIu32" blocks (%d byte blocks)\n", number, map->logical_block); } map->media_size = number; @@ -609,17 +611,17 @@ coerce_block0(partition_map_header *map) int -add_partition_to_map(const char *name, const char *dptype, u32 base, u32 length, +add_partition_to_map(const char *name, const char *dptype, uint32_t base, uint32_t length, partition_map_header *map) { partition_map * cur; DPME *data; enum add_action act; int limit; - u32 adjusted_base = 0; - u32 adjusted_length = 0; - u32 new_base = 0; - u32 new_length = 0; + uint32_t adjusted_base = 0; + uint32_t adjusted_length = 0; + uint32_t new_base = 0; + uint32_t new_length = 0; // find a block that starts includes base and length cur = map->base_order; @@ -740,7 +742,7 @@ add_partition_to_map(const char *name, const char *dptype, u32 base, u32 length, DPME * -create_data(const char *name, const char *dptype, u32 base, u32 length) +create_data(const char *name, const char *dptype, uint32_t base, uint32_t length) { DPME *data; @@ -843,13 +845,13 @@ long compute_device_size(partition_map_header *map, partition_map_header *oldmap) { #ifdef TEST_COMPUTE - unsigned long length; + uint32_t length; struct hd_geometry geometry; struct stat info; loff_t pos; #endif char* data; - unsigned long l, r, x = 0; + uint32_t l, r, x = 0; long long size; int valid = 0; #ifdef TEST_COMPUTE @@ -951,7 +953,7 @@ void sync_device_size(partition_map_header *map) { Block0 *p; - unsigned long size; + uint32_t size; double d; p = map->misc; @@ -1024,7 +1026,7 @@ contains_driver(partition_map *entry) DDMap *m; int i; int f; - u32 start; + uint32_t start; map = entry->the_map; p = map->misc; @@ -1059,7 +1061,7 @@ void combine_entry(partition_map *entry) { partition_map *p; - u32 end; + uint32_t end; if (entry == NULL || istrncmp(entry->data->dpme_type, kFreeType, DPISTRLEN) != 0) { @@ -1145,7 +1147,7 @@ delete_entry(partition_map *entry) partition_map * -find_entry_by_disk_address(long ix, partition_map_header *map) +find_entry_by_disk_address(int32_t ix, partition_map_header *map) { partition_map * cur; @@ -1176,7 +1178,7 @@ find_entry_by_type(const char *type_name, partition_map_header *map) } partition_map * -find_entry_by_base(u32 base, partition_map_header *map) +find_entry_by_base(uint32_t base, partition_map_header *map) { partition_map * cur; @@ -1192,7 +1194,7 @@ find_entry_by_base(u32 base, partition_map_header *map) void -move_entry_in_map(long old_index, long ix, partition_map_header *map) +move_entry_in_map(int32_t old_index, int32_t ix, partition_map_header *map) { partition_map * cur; @@ -1302,11 +1304,11 @@ insert_in_base_order(partition_map *entry) void -resize_map(unsigned long new_size, partition_map_header *map) +resize_map(uint32_t new_size, partition_map_header *map) { partition_map * entry; partition_map * next; - unsigned int incr; + uint32_t incr; // find map entry entry = find_entry_by_type(kMapType, map); @@ -1370,7 +1372,7 @@ remove_driver(partition_map *entry) int i; int j; int f; - u32 start; + uint32_t start; map = entry->the_map; p = map->misc; @@ -1418,7 +1420,7 @@ remove_driver(partition_map *entry) } int -read_block(partition_map_header *map, unsigned long num, char *buf) +read_block(partition_map_header *map, uint32_t num, char *buf) { //printf("read block %d\n", num); return read_media(map->m, ((long long) num) * map->logical_block, @@ -1427,7 +1429,7 @@ read_block(partition_map_header *map, unsigned long num, char *buf) int -write_block(partition_map_header *map, unsigned long num, char *buf) +write_block(partition_map_header *map, uint32_t num, char *buf) { return write_media(map->m, ((long long) num) * map->logical_block, PBLOCK_SIZE, (void *)buf); diff --git a/dist/pdisk/partition_map.h b/dist/pdisk/partition_map.h index b9c96a9c5e4..5a9165b71c9 100644 --- a/dist/pdisk/partition_map.h +++ b/dist/pdisk/partition_map.h @@ -55,7 +55,7 @@ struct partition_map_header { int logical_block; // must be <= physical_block int blocks_in_map; int maximum_in_map; - unsigned long media_size; // in logical_blocks + uint32_t media_size; // in logical_blocks }; typedef struct partition_map_header partition_map_header; @@ -64,7 +64,7 @@ struct partition_map { struct partition_map * prev_on_disk; struct partition_map * next_by_base; struct partition_map * prev_by_base; - long disk_address; + int32_t disk_address; struct partition_map_header * the_map; int contains_driver; DPME *data; @@ -104,17 +104,17 @@ extern int dflag; // // Forward declarations // -int add_partition_to_map(const char *name, const char *dptype, u32 base, u32 length, partition_map_header *map); +int add_partition_to_map(const char *name, const char *dptype, uint32_t base, uint32_t length, partition_map_header *map); void close_partition_map(partition_map_header *map); partition_map_header* create_partition_map(char *name, partition_map_header *oldmap); void delete_partition_from_map(partition_map *entry); -partition_map* find_entry_by_disk_address(long, partition_map_header *); +partition_map* find_entry_by_disk_address(int32_t, partition_map_header *); partition_map* find_entry_by_type(const char *type_name, partition_map_header *map); -partition_map* find_entry_by_base(u32 base, partition_map_header *map); +partition_map* find_entry_by_base(uint32_t base, partition_map_header *map); partition_map_header* init_partition_map(char *name, partition_map_header* oldmap); -void move_entry_in_map(long, long, partition_map_header *); +void move_entry_in_map(int32_t, int32_t, partition_map_header *); partition_map_header* open_partition_map(char *name, int *valid_file, int ask_logical_size); -void resize_map(unsigned long new_size, partition_map_header *map); +void resize_map(uint32_t new_size, partition_map_header *map); void write_partition_map(partition_map_header *map); void bzb_init_slice(BZB *bp, int slice); void dpme_init_flags(DPME *data); diff --git a/dist/pdisk/pathname.c b/dist/pdisk/pathname.c index 75acd51a1b7..77d7ad850fe 100644 --- a/dist/pdisk/pathname.c +++ b/dist/pdisk/pathname.c @@ -28,6 +28,7 @@ // for strncmp() #include <string.h> +#include <stdint.h> #include "pathname.h" #include "file_media.h" diff --git a/dist/pdisk/pdisk.c b/dist/pdisk/pdisk.c index 4c2cd3dd374..ce8dc02c333 100644 --- a/dist/pdisk/pdisk.c +++ b/dist/pdisk/pdisk.c @@ -61,6 +61,8 @@ #include <linux/hdreg.h> #endif +#include <stdint.h> + #include "pdisk.h" #include "io.h" #include "partition_map.h" @@ -761,7 +763,7 @@ get_size_argument(long *number, partition_map_header *map) { partition_map * entry; int result = 0; - unsigned long multiple; + uint32_t multiple; if (get_number_argument("Length in blocks: ", number, kDefault) == 0) { bad_input("Bad length"); @@ -1068,7 +1070,7 @@ do_display_block(partition_map_header *map, char *alt_name) MEDIA m; long number; char *name; - static unsigned char *display_block; + static uint8_t *display_block; static int display_g; int g; static long next_number = -1; @@ -1106,7 +1108,7 @@ do_display_block(partition_map_header *map, char *alt_name) free(display_block); display_g = 0; } - display_block = (unsigned char *) malloc(g); + display_block = (uint8_t *) malloc(g); if (display_block == NULL) { error(errno, "can't allocate memory for display block buffer"); goto xit; @@ -1115,7 +1117,7 @@ do_display_block(partition_map_header *map, char *alt_name) } if (read_media(m, ((long long)number) * g, g, (char *)display_block) != 0) { printf("block %ld -", number); - dump_block((unsigned char*) display_block, g); + dump_block((uint8_t*) display_block, g); next_number = number + 1; } diff --git a/dist/pdisk/util.c b/dist/pdisk/util.c index e29232d054d..50a7754a4c8 100644 --- a/dist/pdisk/util.c +++ b/dist/pdisk/util.c @@ -30,6 +30,7 @@ #include <stdio.h> // for tolower() #include <ctype.h> +#include <stdint.h> #include "version.h" #include "util.h" @@ -72,7 +73,7 @@ static char dynamic_version[10]; * Routines */ void -clear_memory(void *dataPtr, unsigned long size) +clear_memory(void *dataPtr, uint32_t size) { char *ptr; @@ -111,8 +112,8 @@ TrapAvailable(short theTrap) int istrncmp(const char *x, const char *y, long len) { - const unsigned char *p = (const unsigned char *)x; - const unsigned char *q = (const unsigned char *)y; + const uint8_t *p = (const uint8_t *)x; + const uint8_t *q = (const uint8_t *)y; while (len > 0) { if (tolower(*p) != tolower(*q)) { diff --git a/dist/pdisk/util.h b/dist/pdisk/util.h index 5fc34c512c9..16cd0b33373 100644 --- a/dist/pdisk/util.h +++ b/dist/pdisk/util.h @@ -52,7 +52,7 @@ /* * Forward declarations */ -void clear_memory(void *dataPtr, unsigned long size); +void clear_memory(void *dataPtr, uint32_t size); #if !defined(__linux__) && !defined(__unix__) int TrapAvailable(short theTrap); #endif diff --git a/dist/pdisk/validate.c b/dist/pdisk/validate.c index 44ffcde5ec5..b94fe7d7237 100644 --- a/dist/pdisk/validate.c +++ b/dist/pdisk/validate.c @@ -38,6 +38,7 @@ #include <fcntl.h> // for errno #include <errno.h> +#include <inttypes.h> #include "validate.h" #include "deblock_media.h" @@ -66,8 +67,8 @@ struct range_list { struct range_list *prev; enum range_state state; int valid; - u32 start; - u32 end; + uint32_t start; + uint32_t end; }; typedef struct range_list range_list; @@ -93,9 +94,9 @@ static int g; // int get_block_zero(void); int get_block_n(int n); -range_list *new_range_list_item(enum range_state state, int valid, u32 low, u32 high); +range_list *new_range_list_item(enum range_state state, int valid, uint32_t low, uint32_t high); void initialize_list(range_list **list); -void add_range(range_list **list, u32 base, u32 len, int allocate); +void add_range(range_list **list, uint32_t base, uint32_t len, int allocate); void print_range_list(range_list *list); void delete_list(range_list *list); void coalesce_list(range_list *list); @@ -153,7 +154,7 @@ get_block_n(int n) range_list * -new_range_list_item(enum range_state state, int valid, u32 low, u32 high) +new_range_list_item(enum range_state state, int valid, uint32_t low, uint32_t high) { range_list *item; @@ -193,12 +194,12 @@ delete_list(range_list *list) void -add_range(range_list **list, u32 base, u32 len, int allocate) +add_range(range_list **list, uint32_t base, uint32_t len, int allocate) { range_list *item; range_list *cur; - u32 low; - u32 high; + uint32_t low; + uint32_t high; if (list == 0 || *list == 0) { /* XXX initialized list will always have one element */ @@ -325,7 +326,7 @@ print_range_list(range_list *list) break; } printed = 1; - printf("\t%lu:%lu %s\n", cur->start, cur->end, s); + printf("\t%"PRIu32":%"PRIu32" %s\n", cur->start, cur->end, s); } else { switch (cur->state) { case kUnallocated: @@ -340,7 +341,7 @@ print_range_list(range_list *list) break; } printed = 1; - printf("\t%lu:%lu out of range, but %s\n", cur->start, cur->end, s); + printf("\t%"PRIu32":%"PRIu32" out of range, but %s\n", cur->start, cur->end, s); } } if (printed == 0) { @@ -354,8 +355,8 @@ validate_map(partition_map_header *map) { range_list *list; char *name; - unsigned int i; - u32 limit; + uint32_t i; + uint32_t limit; int printed; //printf("Validation not implemented yet.\n"); @@ -458,18 +459,18 @@ check_map: #if 0 if (limit < 0) { printed = 1; - printf("\tentry count is 0x%lx, real value unknown\n", mb->dpme_map_entries); + printf("\tentry count is 0x%"PRIx32", real value unknown\n", mb->dpme_map_entries); } else #endif if (mb->dpme_map_entries != limit) { printed = 1; - printf("\tentry count is 0x%lx, should be %ld\n", mb->dpme_map_entries, limit); + printf("\tentry count is 0x%"PRIx32", should be %"PRId32"\n", mb->dpme_map_entries, limit); } // lblocks contained within physical if (mb->dpme_lblock_start >= mb->dpme_pblocks || mb->dpme_lblocks > mb->dpme_pblocks - mb->dpme_lblock_start) { printed = 1; - printf("\tlogical blocks (%ld for %ld) not within physical size (%ld)\n", + printf("\tlogical blocks (%"PRId32" for %"PRId32") not within physical size (%"PRId32")\n", mb->dpme_lblock_start, mb->dpme_lblocks, mb->dpme_pblocks); } // remember stuff for post processing diff --git a/dist/pdisk/version.h b/dist/pdisk/version.h index a9509b61957..0ee4a6930d5 100644 --- a/dist/pdisk/version.h +++ b/dist/pdisk/version.h @@ -43,7 +43,7 @@ * Z is two digits indicating the delta within the stage * * Note that within the 'vers' resource all these fields end up - * comprising a four byte unsigned integer with the property that any later + * comprising a four byte uint32_teger with the property that any later * version will be be represented by a larger number. */ |
