diff options
43 files changed, 589 insertions, 588 deletions
diff --git a/src/sg_dd.c b/src/sg_dd.c index e3b20cff..54eb4d18 100644 --- a/src/sg_dd.c +++ b/src/sg_dd.c @@ -58,7 +58,7 @@ This version is designed for the linux kernel 2.4 and 2.6 series. */ -static char * version_str = "5.73 20090205"; +static char * version_str = "5.73 20090717"; #define ME "sg_dd: " @@ -400,7 +400,7 @@ scsi_read_capacity(int sg_fd, int64_t * num_sect, int * sect_sz) (rcBuff[6] << 8) | rcBuff[7]; } if (verbose) - fprintf(stderr, " number of blocks=%"PRId64" [0x%"PRIx64"], block " + fprintf(stderr, " number of blocks=%"PRId64" [%#"PRIx64"], block " "size=%d\n", *num_sect, *num_sect, *sect_sz); return 0; } @@ -426,7 +426,7 @@ read_blkdev_capacity(int sg_fd, int64_t * num_sect, int * sect_sz) } *num_sect = ((int64_t)ull / (int64_t)*sect_sz); if (verbose) - fprintf(stderr, " [bgs64] number of blocks=%"PRId64" [0x%"PRIx64"], " + fprintf(stderr, " [bgs64] number of blocks=%"PRId64" [%#"PRIx64"], " "block size=%d\n", *num_sect, *num_sect, *sect_sz); #else unsigned long ul; @@ -437,7 +437,7 @@ read_blkdev_capacity(int sg_fd, int64_t * num_sect, int * sect_sz) } *num_sect = (int64_t)ul; if (verbose) - fprintf(stderr, " [bgs] number of blocks=%"PRId64" [0x%"PRIx64"], " + fprintf(stderr, " [bgs] number of blocks=%"PRId64" [%#"PRIx64"], " " block size=%d\n", *num_sect, *num_sect, *sect_sz); #endif } @@ -611,12 +611,12 @@ sg_read_low(int sg_fd, unsigned char * buff, int blocks, int64_t from_block, info_valid = sg_get_sense_info_fld(sbp, slen, io_addrp); if (info_valid) { fprintf(stderr, " lba of last recovered error in this " - "READ=0x%"PRIx64"\n", *io_addrp); + "READ=%#"PRIx64"\n", *io_addrp); if (verbose > 1) sg_chk_n_print3("reading", &io_hdr, 1); } else { fprintf(stderr, "Recovered error: [no info] reading from " - "block=0x%"PRIx64", num=%d\n", from_block, blocks); + "block=%#"PRIx64", num=%d\n", from_block, blocks); sg_chk_n_print3("reading", &io_hdr, verbose > 1); } break; @@ -736,7 +736,7 @@ sg_read(int sg_fd, unsigned char * buff, int blocks, int64_t from_block, break; case SG_LIB_CAT_MEDIUM_HARD_WITH_INFO: if (retries_tmp > 0) { - fprintf(stderr, ">>> retrying a sgio read, lba=0x%"PRIx64"\n", + fprintf(stderr, ">>> retrying a sgio read, lba=%#"PRIx64"\n", (uint64_t)lba); --retries_tmp; ++num_retries; @@ -757,7 +757,7 @@ sg_read(int sg_fd, unsigned char * buff, int blocks, int64_t from_block, may_coe = 1; default: if (retries_tmp > 0) { - fprintf(stderr, ">>> retrying a sgio read, lba=0x%"PRIx64"\n", + fprintf(stderr, ">>> retrying a sgio read, lba=%#"PRIx64"\n", (uint64_t)lba); --retries_tmp; ++num_retries; @@ -773,8 +773,8 @@ sg_read(int sg_fd, unsigned char * buff, int blocks, int64_t from_block, continue; if ((io_addr < (uint64_t)lba) || (io_addr >= (uint64_t)(lba + blks))) { - fprintf(stderr, " Unrecovered error lba 0x%"PRIx64" not in " - "correct range:\n\t[0x%"PRIx64",0x%"PRIx64"]\n", io_addr, + fprintf(stderr, " Unrecovered error lba %#"PRIx64" not in " + "correct range:\n\t[%#"PRIx64",%#"PRIx64"]\n", io_addr, (uint64_t)lba, (uint64_t)(lba + blks - 1)); may_coe = 1; @@ -1001,12 +1001,12 @@ sg_write(int sg_fd, unsigned char * buff, int blocks, int64_t to_block, &io_addr); if (info_valid) { fprintf(stderr, " lba of last recovered error in this " - "WRITE=0x%"PRIx64"\n", io_addr); + "WRITE=%#"PRIx64"\n", io_addr); if (verbose > 1) sg_chk_n_print3("writing", &io_hdr, 1); } else { fprintf(stderr, "Recovered error: [no info] writing to " - "block=0x%"PRIx64", num=%d\n", to_block, blocks); + "block=%#"PRIx64", num=%d\n", to_block, blocks); sg_chk_n_print3("writing", &io_hdr, verbose > 1); } break; @@ -1163,7 +1163,7 @@ open_if(const char * inf, int64_t skip, int bpt, struct flags_t * ifp, } } if (verbose) - fprintf(stderr, " open input(sg_io), flags=0x%x\n", + fprintf(stderr, " open input(sg_io), flags=%#x\n", fl | flags); if (sg_simple_inquiry(infd, &sir, 0, verb)) { fprintf(stderr, "INQUIRY failed on %s\n", inf); @@ -1204,7 +1204,7 @@ open_if(const char * inf, int64_t skip, int bpt, struct flags_t * ifp, goto file_err; } else { if (verbose) - fprintf(stderr, " open input, flags=0x%x\n", + fprintf(stderr, " open input, flags=%#x\n", flags); if (skip > 0) { off64_t offset = skip; @@ -1218,7 +1218,7 @@ open_if(const char * inf, int64_t skip, int bpt, struct flags_t * ifp, } if (verbose) fprintf(stderr, " >> skip: lseek64 SEEK_SET, " - "byte offset=0x%"PRIx64"\n", + "byte offset=%#"PRIx64"\n", (uint64_t)offset); } #ifdef HAVE_POSIX_FADVISE @@ -1290,7 +1290,7 @@ open_of(const char * outf, int64_t seek, int bpt, struct flags_t * ofp, goto file_err; } if (verbose) - fprintf(stderr, " open output(sg_io), flags=0x%x\n", + fprintf(stderr, " open output(sg_io), flags=%#x\n", flags); if (sg_simple_inquiry(outfd, &sir, 0, verb)) { fprintf(stderr, "INQUIRY failed on %s\n", outf); @@ -1346,7 +1346,7 @@ open_of(const char * outf, int64_t seek, int bpt, struct flags_t * ofp, } } if (verbose) - fprintf(stderr, " %s output, flags=0x%x\n", + fprintf(stderr, " %s output, flags=%#x\n", ((O_CREAT & flags) ? "create" : "open"), flags); if (seek > 0) { off64_t offset = seek; @@ -1360,7 +1360,7 @@ open_of(const char * outf, int64_t seek, int bpt, struct flags_t * ofp, } if (verbose) fprintf(stderr, " >> seek: lseek64 SEEK_SET, " - "byte offset=0x%"PRIx64"\n", + "byte offset=%#"PRIx64"\n", (uint64_t)offset); } } @@ -1827,7 +1827,7 @@ main(int argc, char * argv[]) } if (res) { fprintf(stderr, "sg_read failed,%s at or after lba=%"PRId64" " - "[0x%"PRIx64"]\n", + "[%#"PRIx64"]\n", ((-2 == res) ? " try reducing bpt," : ""), skip, skip); ret = res; break; @@ -1973,7 +1973,7 @@ main(int argc, char * argv[]) break; else if (retries_tmp > 0) { fprintf(stderr, ">>> retrying a sgio write, " - "lba=0x%"PRIx64"\n", (uint64_t)seek); + "lba=%#"PRIx64"\n", (uint64_t)seek); --retries_tmp; ++num_retries; if (unrecovered_errs > 0) diff --git a/src/sg_format.c b/src/sg_format.c index 16617b71..433588ae 100644 --- a/src/sg_format.c +++ b/src/sg_format.c @@ -45,7 +45,7 @@ #include "sg_cmds_basic.h" #include "sg_cmds_extra.h" -static char * version_str = "1.17 20090324"; +static char * version_str = "1.17 20090717"; #define RW_ERROR_RECOVERY_PAGE 1 /* every disk should have one */ #define FORMAT_DEV_PAGE 3 /* Format Device Mode Page [now obsolete] */ @@ -521,7 +521,7 @@ main(int argc, char **argv) ret = SG_LIB_CAT_OTHER; goto out; } - printf(" %.8s %.16s %.4s peripheral_type: %s [0x%x]\n", + printf(" %.8s %.16s %.4s peripheral_type: %s [%#x]\n", inq_out.vendor, inq_out.product, inq_out.revision, sg_get_pdt_str(inq_out.peripheral_type, sizeof(pdt_name), pdt_name), @@ -634,9 +634,9 @@ main(int argc, char **argv) prob = 1; } else if (bd_len != 8) prob = 1; - printf(" Number of blocks=%" PRIu64 " [0x%" PRIx64 "]\n", + printf(" Number of blocks=%" PRIu64 " [%#" PRIx64 "]\n", ull, ull); - printf(" Block size=%d [0x%x]\n", bd_blk_len, bd_blk_len); + printf(" Block size=%d [%#x]\n", bd_blk_len, bd_blk_len); } else { printf(" No block descriptors present\n"); prob = 1; diff --git a/src/sg_get_config.c b/src/sg_get_config.c index 11f29f8e..3ee05ad1 100644 --- a/src/sg_get_config.c +++ b/src/sg_get_config.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2008 Douglas Gilbert. + * Copyright (c) 2004-2009 Douglas Gilbert. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -49,7 +49,7 @@ */ -static char * version_str = "0.36 20080714"; /* mmc6r02 */ +static char * version_str = "0.37 20090716"; /* mmc6r02 */ #define MX_ALLOC_LEN 8192 #define NAME_BUFF_SZ 64 @@ -165,7 +165,7 @@ get_profile_str(int profile_num, char * buff) return buff; } } - snprintf(buff, 64, "0x%x", profile_num); + snprintf(buff, 64, "%#x", profile_num); return buff; } @@ -245,7 +245,7 @@ get_feature_str(int feature_num, char * buff) return buff; } } - snprintf(buff, 64, "0x%x", feature_num); + snprintf(buff, 64, "%#x", feature_num); return buff; } @@ -268,7 +268,7 @@ decode_feature(int feature, unsigned char * ucp, int len) cp = ""; switch (feature) { case 0: /* Profile list */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 2), !!(ucp[2] & 1), feature); printf(" available profiles [more recent typically higher " @@ -280,7 +280,7 @@ decode_feature(int feature, unsigned char * ucp, int len) } break; case 1: /* Core */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 2), !!(ucp[2] & 1), feature); if (len < 8) { @@ -300,7 +300,7 @@ decode_feature(int feature, unsigned char * ucp, int len) case 8: cp = "USB (both 1 and 2)"; break; case 0xffff: cp = "vendor unique"; break; default: - snprintf(buff, sizeof(buff), "[0x%x]", num); + snprintf(buff, sizeof(buff), "[%#x]", num); cp = buff; break; } @@ -311,7 +311,7 @@ decode_feature(int feature, unsigned char * ucp, int len) printf("\n"); break; case 2: /* Morphing */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 2), !!(ucp[2] & 1), feature); if (len < 8) { @@ -322,7 +322,7 @@ decode_feature(int feature, unsigned char * ucp, int len) !!(ucp[4] & 1)); break; case 3: /* Removable medium */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 2), !!(ucp[2] & 1), feature); if (len < 8) { @@ -338,7 +338,7 @@ decode_feature(int feature, unsigned char * ucp, int len) break; case 5: cp = "Embedded changer using a magazine"; break; default: - snprintf(buff, sizeof(buff), "[0x%x]", num); + snprintf(buff, sizeof(buff), "[%#x]", num); cp = buff; break; } @@ -348,7 +348,7 @@ decode_feature(int feature, unsigned char * ucp, int len) !!(ucp[4] & 0x1)); break; case 4: /* Write protect */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); if (len < 8) { @@ -359,7 +359,7 @@ decode_feature(int feature, unsigned char * ucp, int len) !!(ucp[4] & 0x4), !!(ucp[4] & 0x2), !!(ucp[4] & 0x1)); break; case 0x10: /* Random readable */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); if (len < 12) { @@ -367,7 +367,7 @@ decode_feature(int feature, unsigned char * ucp, int len) break; } num = (ucp[4] << 24) + (ucp[5] << 16) + (ucp[6] << 8) + ucp[7]; - printf(" Logical block size=0x%x, blocking=0x%x, PP=%d\n", + printf(" Logical block size=%#x, blocking=%#x, PP=%d\n", num, ((ucp[8] << 8) + ucp[9]), !!(ucp[10] & 0x1)); break; case 0x1d: /* Multi-read */ @@ -381,12 +381,12 @@ decode_feature(int feature, unsigned char * ucp, int len) case 0x109: /* Media serial number */ case 0x110: /* VCPS */ case 0x113: /* SecurDisc */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); break; case 0x1e: /* CD read */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); if (len < 8) { @@ -397,7 +397,7 @@ decode_feature(int feature, unsigned char * ucp, int len) !!(ucp[4] & 0x2), !!(ucp[4] & 0x1)); break; case 0x1f: /* DVD read */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); if (len > 7) @@ -405,7 +405,7 @@ decode_feature(int feature, unsigned char * ucp, int len) !!(ucp[4] & 0x1), !!(ucp[6] & 0x2), !!(ucp[6] & 0x1)); break; case 0x20: /* Random writable */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); if (len < 16) { @@ -414,19 +414,19 @@ decode_feature(int feature, unsigned char * ucp, int len) } num = (ucp[4] << 24) + (ucp[5] << 16) + (ucp[6] << 8) + ucp[7]; n = (ucp[8] << 24) + (ucp[9] << 16) + (ucp[10] << 8) + ucp[11]; - printf(" Last lba=0x%x, Logical block size=0x%x, blocking=0x%x," + printf(" Last lba=%#x, Logical block size=%#x, blocking=%#x," " PP=%d\n", num, n, ((ucp[12] << 8) + ucp[13]), !!(ucp[14] & 0x1)); break; case 0x21: /* Incremental streaming writable */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); if (len < 8) { printf(" additional length [%d] too short\n", len - 4); break; } - printf(" Data block types supported=0x%x, TRIO=%d, ARSV=%d, " + printf(" Data block types supported=%#x, TRIO=%d, ARSV=%d, " "BUF=%d\n", ((ucp[4] << 8) + ucp[5]), !!(ucp[6] & 0x4), !!(ucp[6] & 0x2), !!(ucp[6] & 0x1)); num = ucp[7]; @@ -436,7 +436,7 @@ decode_feature(int feature, unsigned char * ucp, int len) break; /* case 0x22: Sector erasable -> see 0x1d entry */ case 0x23: /* Formattable */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); if (len > 4) @@ -447,14 +447,14 @@ decode_feature(int feature, unsigned char * ucp, int len) printf(" BD-R: RRM=%d\n", !!(ucp[8] & 0x1)); break; case 0x24: /* Hardware defect management */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); if (len > 4) printf(" SSA=%d\n", !!(ucp[4] & 0x80)); break; case 0x25: /* Write once */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); if (len < 12) { @@ -462,13 +462,13 @@ decode_feature(int feature, unsigned char * ucp, int len) break; } num = (ucp[4] << 24) + (ucp[5] << 16) + (ucp[6] << 8) + ucp[7]; - printf(" Logical block size=0x%x, blocking=0x%x, PP=%d\n", + printf(" Logical block size=%#x, blocking=%#x, PP=%d\n", num, ((ucp[8] << 8) + ucp[9]), !!(ucp[10] & 0x1)); break; /* case 0x26: Restricted overwrite -> see 0x1d entry */ /* case 0x27: CDRW CAV write -> see 0x1d entry */ case 0x28: /* MRW (Mount Rainier reWriteable) */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); if (len > 4) @@ -476,19 +476,19 @@ decode_feature(int feature, unsigned char * ucp, int len) !!(ucp[4] & 0x4), !!(ucp[4] & 0x2), !!(ucp[4] & 0x1)); break; case 0x29: /* Enhanced defect reporting */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); if (len < 8) { printf(" additional length [%d] too short\n", len - 4); break; } - printf(" DRT-DM=%d, number of DBI cache zones=0x%x, number of " - "entries=0x%x\n", !!(ucp[4] & 0x1), ucp[5], + printf(" DRT-DM=%d, number of DBI cache zones=%#x, number of " + "entries=%#x\n", !!(ucp[4] & 0x1), ucp[5], ((ucp[6] << 8) + ucp[7])); break; case 0x2a: /* DVD+RW */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); if (len < 8) { @@ -499,7 +499,7 @@ decode_feature(int feature, unsigned char * ucp, int len) !!(ucp[4] & 0x1), !!(ucp[5] & 0x2), !!(ucp[5] & 0x1)); break; case 0x2b: /* DVD+R */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); if (len < 8) { @@ -509,7 +509,7 @@ decode_feature(int feature, unsigned char * ucp, int len) printf(" Write=%d\n", !!(ucp[4] & 0x1)); break; case 0x2c: /* Rigid restricted overwrite */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); if (len < 8) { @@ -521,7 +521,7 @@ decode_feature(int feature, unsigned char * ucp, int len) !!(ucp[4] & 0x1)); break; case 0x2d: /* CD Track at once */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); if (len < 8) { @@ -535,7 +535,7 @@ decode_feature(int feature, unsigned char * ucp, int len) !!(ucp[4] & 0x2), !!(ucp[4] & 0x1), (ucp[6] << 8) + ucp[7]); break; case 0x2e: /* CD mastering (session at once) */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); if (len < 8) { @@ -547,11 +547,11 @@ decode_feature(int feature, unsigned char * ucp, int len) !!(ucp[4] & 0x8)); printf(" Test write=%d, CD-RW=%d, R-W=%d\n", !!(ucp[4] & 0x4), !!(ucp[4] & 0x2), !!(ucp[4] & 0x1)); - printf(" Maximum cue sheet length=0x%x\n", + printf(" Maximum cue sheet length=%#x\n", (ucp[5] << 16) + (ucp[6] << 8) + ucp[7]); break; case 0x2f: /* DVD-R/-RW write */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); if (len < 8) { @@ -563,7 +563,7 @@ decode_feature(int feature, unsigned char * ucp, int len) !!(ucp[4] & 0x2)); break; case 0x33: /* Layer jump recording */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); if (len < 8) { @@ -576,7 +576,7 @@ decode_feature(int feature, unsigned char * ucp, int len) printf(" %d\n", ucp[8 + k]); break; case 0x34: /* Layer jump rigid restricted overwrite */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); if (len < 8) { @@ -588,18 +588,18 @@ decode_feature(int feature, unsigned char * ucp, int len) break; /* case 0x35: Stop long operation -> see 0x1d entry */ case 0x37: /* CD-RW media write support */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); if (len < 8) { printf(" additional length [%d] too short\n", len - 4); break; } - printf(" CD-RW media sub-type support (bitmask)=0x%x\n", ucp[5]); + printf(" CD-RW media sub-type support (bitmask)=%#x\n", ucp[5]); break; /* case 0x38: BD-R pseudo-overwrite (POW) -> see 0x1d entry */ case 0x3a: /* DVD+RW dual layer */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); if (len < 8) { @@ -610,7 +610,7 @@ decode_feature(int feature, unsigned char * ucp, int len) !!(ucp[4] & 0x1), !!(ucp[5] & 0x2), !!(ucp[5] & 0x1)); break; case 0x3b: /* DVD+R dual layer */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); if (len < 8) { @@ -620,7 +620,7 @@ decode_feature(int feature, unsigned char * ucp, int len) printf(" write=%d\n", !!(ucp[4] & 0x1)); break; case 0x40: /* BD Read */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); if (len < 32) { @@ -628,26 +628,26 @@ decode_feature(int feature, unsigned char * ucp, int len) break; } printf(" Bitmaps for BD-RE read support:\n"); - printf(" Class 0=0x%x, Class 1=0x%x, Class 2=0x%x, " - "Class 3=0x%x\n", (ucp[8] << 8) + ucp[9], + printf(" Class 0=%#x, Class 1=%#x, Class 2=%#x, " + "Class 3=%#x\n", (ucp[8] << 8) + ucp[9], (ucp[10] << 8) + ucp[11], (ucp[12] << 8) + ucp[13], (ucp[14] << 8) + ucp[15]); printf(" Bitmaps for BD-R read support:\n"); - printf(" Class 0=0x%x, Class 1=0x%x, Class 2=0x%x, " - "Class 3=0x%x\n", (ucp[16] << 8) + ucp[17], + printf(" Class 0=%#x, Class 1=%#x, Class 2=%#x, " + "Class 3=%#x\n", (ucp[16] << 8) + ucp[17], (ucp[18] << 8) + ucp[19], (ucp[20] << 8) + ucp[21], (ucp[22] << 8) + ucp[23]); printf(" Bitmaps for BD-ROM read support:\n"); - printf(" Class 0=0x%x, Class 1=0x%x, Class 2=0x%x, " - "Class 3=0x%x\n", (ucp[24] << 8) + ucp[25], + printf(" Class 0=%#x, Class 1=%#x, Class 2=%#x, " + "Class 3=%#x\n", (ucp[24] << 8) + ucp[25], (ucp[26] << 8) + ucp[27], (ucp[28] << 8) + ucp[29], (ucp[30] << 8) + ucp[31]); break; case 0x41: /* BD Write */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); if (len < 32) { @@ -656,27 +656,27 @@ decode_feature(int feature, unsigned char * ucp, int len) } printf(" SVNR=%d\n", !!(ucp[4] & 0x1)); printf(" Bitmaps for BD-RE write support:\n"); - printf(" Class 0=0x%x, Class 1=0x%x, Class 2=0x%x, " - "Class 3=0x%x\n", (ucp[8] << 8) + ucp[9], + printf(" Class 0=%#x, Class 1=%#x, Class 2=%#x, " + "Class 3=%#x\n", (ucp[8] << 8) + ucp[9], (ucp[10] << 8) + ucp[11], (ucp[12] << 8) + ucp[13], (ucp[14] << 8) + ucp[15]); printf(" Bitmaps for BD-R write support:\n"); - printf(" Class 0=0x%x, Class 1=0x%x, Class 2=0x%x, " - "Class 3=0x%x\n", (ucp[16] << 8) + ucp[17], + printf(" Class 0=%#x, Class 1=%#x, Class 2=%#x, " + "Class 3=%#x\n", (ucp[16] << 8) + ucp[17], (ucp[18] << 8) + ucp[19], (ucp[20] << 8) + ucp[21], (ucp[22] << 8) + ucp[23]); printf(" Bitmaps for BD-ROM write support:\n"); - printf(" Class 0=0x%x, Class 1=0x%x, Class 2=0x%x, " - "Class 3=0x%x\n", (ucp[24] << 8) + ucp[25], + printf(" Class 0=%#x, Class 1=%#x, Class 2=%#x, " + "Class 3=%#x\n", (ucp[24] << 8) + ucp[25], (ucp[26] << 8) + ucp[27], (ucp[28] << 8) + ucp[29], (ucp[30] << 8) + ucp[31]); break; /* case 0x42: TSR (timely safe recording) -> see 0x1d entry */ case 0x50: /* HD DVD Read */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); if (len < 8) { @@ -687,7 +687,7 @@ decode_feature(int feature, unsigned char * ucp, int len) !!(ucp[6] & 0x1)); break; case 0x51: /* HD DVD Write */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); if (len < 8) { @@ -698,7 +698,7 @@ decode_feature(int feature, unsigned char * ucp, int len) !!(ucp[6] & 0x1)); break; case 0x52: /* HD DVD-RW fragment recording */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); if (len < 8) { @@ -708,7 +708,7 @@ decode_feature(int feature, unsigned char * ucp, int len) printf(" BGP=%d\n", !!(ucp[4] & 0x1)); break; case 0x80: /* Hybrid disc */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); if (len < 8) { @@ -719,7 +719,7 @@ decode_feature(int feature, unsigned char * ucp, int len) break; /* case 0x100: Power management -> see 0x1d entry */ case 0x101: /* SMART */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); if (len < 8) { @@ -729,7 +729,7 @@ decode_feature(int feature, unsigned char * ucp, int len) printf(" PP=%d\n", !!(ucp[4] & 0x1)); break; case 0x102: /* Embedded changer */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); if (len < 8) { @@ -740,7 +740,7 @@ decode_feature(int feature, unsigned char * ucp, int len) !!(ucp[4] & 0x10), !!(ucp[4] & 0x4), (ucp[7] & 0x1f)); break; case 0x103: /* CD audio external play (obsolete) */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); if (len < 8) { @@ -752,7 +752,7 @@ decode_feature(int feature, unsigned char * ucp, int len) (ucp[6] << 8) + ucp[7]); break; case 0x104: /* Firmware upgrade */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); if (len < 4) { @@ -763,7 +763,7 @@ decode_feature(int feature, unsigned char * ucp, int len) printf(" M5=%d\n", !!(ucp[4] & 0x1)); break; case 0x105: /* Timeout */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); if (len > 7) { @@ -772,7 +772,7 @@ decode_feature(int feature, unsigned char * ucp, int len) } break; case 0x106: /* DVD CSS */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); if (len < 8) { @@ -782,7 +782,7 @@ decode_feature(int feature, unsigned char * ucp, int len) printf(" CSS version=%d\n", ucp[7]); break; case 0x107: /* Real time streaming */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); if (len < 8) { @@ -794,7 +794,7 @@ decode_feature(int feature, unsigned char * ucp, int len) !!(ucp[4] & 0x2), !!(ucp[4] & 0x1)); break; case 0x108: /* Drive serial number */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); num = len - 4; @@ -806,17 +806,17 @@ decode_feature(int feature, unsigned char * ucp, int len) break; /* case 0x109: Media serial number -> see 0x1d entry */ case 0x10a: /* Disc control blocks */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); printf(" Disc control blocks:\n"); for (k = 4; k < len; k += 4) { - printf(" 0x%x\n", ((unsigned int)ucp[k] << 24) + + printf(" %#x\n", ((unsigned int)ucp[k] << 24) + (ucp[k + 1] << 16) + (ucp[k + 2] << 8) + ucp[k + 3]); } break; case 0x10b: /* DVD CPRM */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); if (len < 8) { @@ -826,7 +826,7 @@ decode_feature(int feature, unsigned char * ucp, int len) printf(" CPRM version=%d\n", ucp[7]); break; case 0x10c: /* firmware information */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); if (len < 20) { @@ -837,7 +837,7 @@ decode_feature(int feature, unsigned char * ucp, int len) ucp + 6, ucp + 8, ucp + 10, ucp + 12, ucp + 14, ucp + 16); break; case 0x10d: /* AACS */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); if (len < 8) { @@ -850,7 +850,7 @@ decode_feature(int feature, unsigned char * ucp, int len) (ucp[6] & 0xf), ucp[7]); break; case 0x10e: /* DVD CSS managed recording */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); if (len < 8) { @@ -863,7 +863,7 @@ decode_feature(int feature, unsigned char * ucp, int len) /* case 0x110: VCPS -> see 0x1d entry */ /* case 0x113: SecurDisc -> see 0x1d entry */ case 0x120: /* BD CPS */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); if (len < 8) { @@ -875,7 +875,7 @@ decode_feature(int feature, unsigned char * ucp, int len) ucp[6] & 0x3); break; case 0x142: /* OSSC (Optical Security Subsystem Class) */ - printf(" version=%d, persist=%d, current=%d [0x%x]\n", + printf(" version=%d, persist=%d, current=%d [%#x]\n", ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1), feature); if (len < 8) { @@ -892,7 +892,7 @@ decode_feature(int feature, unsigned char * ucp, int len) } break; default: - printf(" Unknown feature [0x%x], version=%d persist=%d, " + printf(" Unknown feature [%#x], version=%d persist=%d, " "current=%d\n", feature, ((ucp[2] >> 2) & 0xf), !!(ucp[2] & 0x2), !!(ucp[2] & 0x1)); dStrHex((const char *)ucp, len, 1); @@ -951,13 +951,13 @@ list_known(int brief) num = sizeof(feature_desc_arr) / sizeof(feature_desc_arr[0]); printf("Known features:\n"); for (k = 0; k < num; ++k) - printf(" %s [0x%x]\n", feature_desc_arr[k].desc, + printf(" %s [%#x]\n", feature_desc_arr[k].desc, feature_desc_arr[k].val); if (! brief) { printf("Known profiles:\n"); num = sizeof(profile_desc_arr) / sizeof(profile_desc_arr[0]); for (k = 0; k < num; ++k) - printf(" %s [0x%x]\n", profile_desc_arr[k].desc, + printf(" %s [%#x]\n", profile_desc_arr[k].desc, profile_desc_arr[k].val); } } @@ -1034,7 +1034,7 @@ main(int argc, char * argv[]) fprintf(stderr, ME "version: %s\n", version_str); return 0; default: - fprintf(stderr, "unrecognised option code 0x%x ??\n", c); + fprintf(stderr, "unrecognised option code %#x ??\n", c); usage(); return SG_LIB_SYNTAX_ERROR; } @@ -1077,7 +1077,7 @@ main(int argc, char * argv[]) if (strlen(cp) > 0) printf(" Peripheral device type: %s\n", cp); else - printf(" Peripheral device type: 0x%x\n", peri_type); + printf(" Peripheral device type: %#x\n", peri_type); } } else { fprintf(stderr, ME "%s doesn't respond to a SCSI INQUIRY\n", diff --git a/src/sg_ident.c b/src/sg_ident.c index fc7ceac9..255426a4 100644 --- a/src/sg_ident.c +++ b/src/sg_ident.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005-2008 Douglas Gilbert. + * Copyright (c) 2005-2009 Douglas Gilbert. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -49,7 +49,7 @@ * DEVICE IDENTIFIER and SET DEVICE IDENTIFIER prior to spc4r07. */ -static char * version_str = "1.08 20080510"; +static char * version_str = "1.08 20090717"; #define ME "sg_ident: " @@ -178,7 +178,7 @@ int main(int argc, char * argv[]) fprintf(stderr, ME "version: %s\n", version_str); return 0; default: - fprintf(stderr, "unrecognised option code 0x%x ??\n", c); + fprintf(stderr, "unrecognised option code %#x ??\n", c); usage(); return SG_LIB_SYNTAX_ERROR; } diff --git a/src/sg_inq.c b/src/sg_inq.c index 430c10b0..043f7eb9 100644 --- a/src/sg_inq.c +++ b/src/sg_inq.c @@ -66,7 +66,7 @@ * information [MAINTENANCE IN, service action = 0xc]; see sg_opcodes. */ -static char * version_str = "0.84 20090612"; /* SPC-4 rev 20 */ +static char * version_str = "0.84 20090717"; /* SPC-4 rev 20 */ #define VPD_SUPPORTED_VPDS 0x0 @@ -400,7 +400,7 @@ process_cl_new(struct opts_t * optsp, int argc, char * argv[]) ++optsp->do_version; break; default: - fprintf(stderr, "unrecognised option code %c [0x%x]\n", c, c); + fprintf(stderr, "unrecognised option code %c [%#x]\n", c, c); if (optsp->do_help) break; usage_for(optsp); @@ -614,7 +614,7 @@ enumerate_vpds() for (vnp = vpd_pg; vnp->acron; ++vnp) { if (vnp->name) - printf(" %-10s 0x%02x %s\n", vnp->acron, vnp->value, + printf(" %-10s %#02x %s\n", vnp->acron, vnp->value, vnp->name); } } @@ -799,9 +799,9 @@ decode_mode_policy_vpd(unsigned char * buff, int len, int do_hex) if (do_hex) dStrHex((const char *)ucp, 4, 1); else { - printf(" Policy page code: 0x%x", (ucp[0] & 0x3f)); + printf(" Policy page code: %#x", (ucp[0] & 0x3f)); if (ucp[1]) - printf(", subpage code: 0x%x\n", ucp[1]); + printf(", subpage code: %#x\n", ucp[1]); else printf("\n"); printf(" MLUS=%d, Policy: %s\n", !!(ucp[2] & 0x80), @@ -963,7 +963,7 @@ decode_dev_ids(const char * leadin, unsigned char * buff, int len, int do_hex) id_ext <<= 8; id_ext |= ip[m]; } - printf(" Identifier extension: 0x%" PRIx64 "\n", id_ext); + printf(" Identifier extension: %#" PRIx64 "\n", id_ext); } else if ((8 != i_len) && (12 != i_len)) { fprintf(stderr, " << can only decode 8, 12 and 16 " "byte ids>>\n"); @@ -972,19 +972,19 @@ decode_dev_ids(const char * leadin, unsigned char * buff, int len, int do_hex) } c_id = ((ip[ci_off] << 16) | (ip[ci_off + 1] << 8) | ip[ci_off + 2]); - printf(" IEEE Company_id: 0x%x\n", c_id); + printf(" IEEE Company_id: %#x\n", c_id); vsei = 0; for (m = 0; m < 5; ++m) { if (m > 0) vsei <<= 8; vsei |= ip[ci_off + 3 + m]; } - printf(" Vendor Specific Extension Identifier: 0x%" PRIx64 + printf(" Vendor Specific Extension Identifier: %#" PRIx64 "\n", vsei); if (12 == i_len) { d_id = ((ip[8] << 24) | (ip[9] << 16) | (ip[10] << 8) | ip[11]); - printf(" Directory ID: 0x%x\n", d_id); + printf(" Directory ID: %#x\n", d_id); } printf(" [0x"); for (m = 0; m < i_len; ++m) @@ -999,24 +999,24 @@ decode_dev_ids(const char * leadin, unsigned char * buff, int len, int do_hex) } naa = (ip[0] >> 4) & 0xff; if ((naa < 2) || (naa > 6) || (4 == naa)) { - fprintf(stderr, " << unexpected naa [0x%x]>>\n", naa); + fprintf(stderr, " << unexpected naa [%#x]>>\n", naa); dStrHex((const char *)ip, i_len, 0); break; } if (2 == naa) { /* NAA IEEE Extended */ if (8 != i_len) { fprintf(stderr, " << unexpected NAA 2 identifier " - "length: 0x%x>>\n", i_len); + "length: %#x>>\n", i_len); dStrHex((const char *)ip, i_len, 0); break; } d_id = (((ip[0] & 0xf) << 8) | ip[1]); c_id = ((ip[2] << 16) | (ip[3] << 8) | ip[4]); vsi = ((ip[5] << 16) | (ip[6] << 8) | ip[7]); - printf(" NAA 2, vendor specific identifier A: 0x%x\n", + printf(" NAA 2, vendor specific identifier A: %#x\n", d_id); - printf(" IEEE Company_id: 0x%x\n", c_id); - printf(" vendor specific identifier B: 0x%x\n", vsi); + printf(" IEEE Company_id: %#x\n", c_id); + printf(" vendor specific identifier B: %#x\n", vsi); printf(" [0x"); for (m = 0; m < 8; ++m) printf("%02x", (unsigned int)ip[m]); @@ -1024,7 +1024,7 @@ decode_dev_ids(const char * leadin, unsigned char * buff, int len, int do_hex) } else if (3 == naa) { /* NAA Locally assigned */ if (8 != i_len) { fprintf(stderr, " << unexpected NAA 3 identifier " - "length: 0x%x>>\n", i_len); + "length: %#x>>\n", i_len); dStrHex((const char *)ip, i_len, 0); break; } @@ -1036,7 +1036,7 @@ decode_dev_ids(const char * leadin, unsigned char * buff, int len, int do_hex) } else if (5 == naa) { /* NAA IEEE Registered */ if (8 != i_len) { fprintf(stderr, " << unexpected NAA 5 identifier " - "length: 0x%x>>\n", i_len); + "length: %#x>>\n", i_len); dStrHex((const char *)ip, i_len, 0); break; } @@ -1047,8 +1047,8 @@ decode_dev_ids(const char * leadin, unsigned char * buff, int len, int do_hex) vsei <<= 8; vsei |= ip[3 + m]; } - printf(" NAA 5, IEEE Company_id: 0x%x\n", c_id); - printf(" Vendor Specific Identifier: 0x%" PRIx64 + printf(" NAA 5, IEEE Company_id: %#x\n", c_id); + printf(" Vendor Specific Identifier: %#" PRIx64 "\n", vsei); printf(" [0x"); for (m = 0; m < 8; ++m) @@ -1057,7 +1057,7 @@ decode_dev_ids(const char * leadin, unsigned char * buff, int len, int do_hex) } else if (6 == naa) { /* NAA IEEE Registered extended */ if (16 != i_len) { fprintf(stderr, " << unexpected NAA 6 identifier " - "length: 0x%x>>\n", i_len); + "length: %#x>>\n", i_len); dStrHex((const char *)ip, i_len, 0); break; } @@ -1068,8 +1068,8 @@ decode_dev_ids(const char * leadin, unsigned char * buff, int len, int do_hex) vsei <<= 8; vsei |= ip[3 + m]; } - printf(" NAA 6, IEEE Company_id: 0x%x\n", c_id); - printf(" Vendor Specific Identifier: 0x%" PRIx64 "\n", + printf(" NAA 6, IEEE Company_id: %#x\n", c_id); + printf(" Vendor Specific Identifier: %#" PRIx64 "\n", vsei); vsei = 0; for (m = 0; m < 8; ++m) { @@ -1078,7 +1078,7 @@ decode_dev_ids(const char * leadin, unsigned char * buff, int len, int do_hex) vsei |= ip[8 + m]; } printf(" Vendor Specific Identifier Extension: " - "0x%" PRIx64 "\n", vsei); + "%#" PRIx64 "\n", vsei); printf(" [0x"); for (m = 0; m < 16; ++m) printf("%02x", (unsigned int)ip[m]); @@ -1093,7 +1093,7 @@ decode_dev_ids(const char * leadin, unsigned char * buff, int len, int do_hex) break; } d_id = ((ip[2] << 8) | ip[3]); - printf(" Relative target port: 0x%x\n", d_id); + printf(" Relative target port: %#x\n", d_id); break; case 5: /* (primary) Target port group */ if ((1 != c_set) || (1 != assoc) || (4 != i_len)) { @@ -1103,7 +1103,7 @@ decode_dev_ids(const char * leadin, unsigned char * buff, int len, int do_hex) break; } d_id = ((ip[2] << 8) | ip[3]); - printf(" Target port group: 0x%x\n", d_id); + printf(" Target port group: %#x\n", d_id); break; case 6: /* Logical unit group */ if ((1 != c_set) || (0 != assoc) || (4 != i_len)) { @@ -1113,7 +1113,7 @@ decode_dev_ids(const char * leadin, unsigned char * buff, int len, int do_hex) break; } d_id = ((ip[2] << 8) | ip[3]); - printf(" Logical unit group: 0x%x\n", d_id); + printf(" Logical unit group: %#x\n", d_id); break; case 7: /* MD5 logical unit identifier */ if ((1 != c_set) || (0 != assoc)) { @@ -1174,13 +1174,13 @@ decode_transport_id(const char * leadin, unsigned char * ucp, int len) bump = 24; break; case TPROTO_SPI: - printf("%s Parallel SCSI initiator SCSI address: 0x%x\n", + printf("%s Parallel SCSI initiator SCSI address: %#x\n", leadin, ((ucp[2] << 8) | ucp[3])); if (0 != format_code) printf("%s [Unexpected format code: %d]\n", leadin, format_code); printf("%s relative port number (of corresponding target): " - "0x%x\n", leadin, ((ucp[6] << 8) | ucp[7])); + "%#x\n", leadin, ((ucp[6] << 8) | ucp[7])); bump = 24; break; case TPROTO_SSA: /* SSA */ @@ -1225,7 +1225,7 @@ decode_transport_id(const char * leadin, unsigned char * ucp, int len) ull <<= 8; ull |= ucp[4 + j]; } - printf("%s SAS address: 0x%" PRIx64 "\n", leadin, ull); + printf("%s SAS address: %#" PRIx64 "\n", leadin, ull); if (0 != format_code) printf("%s [Unexpected format code: %d]\n", leadin, format_code); @@ -1245,7 +1245,7 @@ decode_transport_id(const char * leadin, unsigned char * ucp, int len) break; case TPROTO_NONE: default: - fprintf(stderr, "%s unknown protocol id=0x%x " + fprintf(stderr, "%s unknown protocol id=%#x " "format_code=%d\n", leadin, proto_id, format_code); dStrHex((const char *)ucp, ((len > 24) ? 24 : len), 0); bump = 24; @@ -1348,7 +1348,7 @@ decode_ata_info_vpd(unsigned char * buff, int len, int do_hex) printf(" firmware revision: %s\n", b); printf(" response in hex:\n"); } else - printf(" ATA command 0x%x got following response:\n", + printf(" ATA command %#x got following response:\n", (unsigned int)buff[56]); if (len < 572) return; @@ -1442,7 +1442,7 @@ decode_b0_vpd(unsigned char * buff, int len, int do_hex, int pdt) break; case PDT_OSD: default: - printf(" Unable to decode pdt=0x%x, in hex:\n", pdt); + printf(" Unable to decode pdt=%#x, in hex:\n", pdt); dStrHex((const char *)buff, len, 0); break; } @@ -1470,7 +1470,7 @@ decode_b1_vpd(unsigned char * buff, int len, int do_hex, int pdt) else if (1 == u) printf(" Non-rotating medium (e.g. solid state)\n"); else if ((u < 0x401) || (0xffff == u)) - printf(" Reserved [0x%x]\n", u); + printf(" Reserved [%#x]\n", u); else printf(" Nominal rotation rate: %d rpm\n", u); break; @@ -1479,7 +1479,7 @@ decode_b1_vpd(unsigned char * buff, int len, int do_hex, int pdt) len - 4, buff + 4); break; default: - printf(" Unable to decode pdt=0x%x, in hex:\n", pdt); + printf(" Unable to decode pdt=%#x, in hex:\n", pdt); dStrHex((const char *)buff, len, 0); break; } @@ -1790,7 +1790,7 @@ process_std_inq(int sg_fd, const struct opts_t * optsp) else if (optsp->do_hex) dStrHex((const char *)rsp_buff, act_len, 0); else { - printf(" PQual=%d Device_type=%d RMB=%d version=0x%02x ", + printf(" PQual=%d Device_type=%d RMB=%d version=%#02x ", pqual, peri_type, !!(rsp_buff[1] & 0x80), (unsigned int)rsp_buff[2]); printf(" [%s]\n", get_ansi_version_str(ansi_version, buff, @@ -1817,13 +1817,13 @@ process_std_inq(int sg_fd, const struct opts_t * optsp) !!(rsp_buff[7] & 0x08), !!(rsp_buff[7] & 0x04)); printf("CmdQue=%d\n", !!(rsp_buff[7] & 0x02)); if (act_len > 56) - printf(" [SPI: Clocking=0x%x QAS=%d IUS=%d]\n", + printf(" [SPI: Clocking=%#x QAS=%d IUS=%d]\n", (rsp_buff[56] & 0x0c) >> 2, !!(rsp_buff[56] & 0x2), !!(rsp_buff[56] & 0x1)); if (act_len >= len) - printf(" length=%d (0x%x)", len, len); + printf(" length=%d (%#x)", len, len); else - printf(" length=%d (0x%x), but only fetched %d bytes", + printf(" length=%d (%#x), but only fetched %d bytes", len, len, act_len); if ((ansi_version >= 2) && (len < SAFE_STD_INQ_RESP_LEN)) printf(" [for SCSI>=2, len>=36 is expected]"); @@ -1881,7 +1881,7 @@ process_std_inq(int sg_fd, const struct opts_t * optsp) printf(" %s\n", cp); else printf(" [unrecognised version descriptor " - "code: 0x%x]\n", vdesc_arr[k]); + "code: %#x]\n", vdesc_arr[k]); } } } @@ -1949,17 +1949,17 @@ process_cmddt(int sg_fd, const struct opts_t * optsp) op_name[sizeof(op_name) - 1] = '\0'; printf(" %s\n", op_name); } else if ((4 == support_num) || (6 == support_num)) - printf(" opcode=0x%.2x vendor specific (%d)\n", + printf(" opcode=%#.2x vendor specific (%d)\n", k, support_num); else if ((0 == support_num) && (reserved_cmddt > 0)) { - printf(" opcode=0x%.2x ignored cmddt bit, " + printf(" opcode=%#.2x ignored cmddt bit, " "given standard INQUIRY response, stop\n", k); break; } } else { fprintf(stderr, - "CmdDt INQUIRY on opcode=0x%.2x: failed\n", k); + "CmdDt INQUIRY on opcode=%#.2x: failed\n", k); break; } } @@ -1970,7 +1970,7 @@ process_cmddt(int sg_fd, const struct opts_t * optsp) if (0 == res) { peri_type = rsp_buff[0] & 0x1f; if (! optsp->do_raw) { - printf("CmdDt INQUIRY, opcode=0x%.2x: [", optsp->page_num); + printf("CmdDt INQUIRY, opcode=%#.2x: [", optsp->page_num); sg_get_opcode_name((unsigned char)optsp->page_num, peri_type, sizeof(op_name) - 1, op_name); op_name[sizeof(op_name) - 1] = '\0'; @@ -2020,13 +2020,13 @@ process_cmddt(int sg_fd, const struct opts_t * optsp) } else { if (! optsp->do_raw) { - printf("CmdDt INQUIRY, opcode=0x%.2x: [", optsp->page_num); + printf("CmdDt INQUIRY, opcode=%#.2x: [", optsp->page_num); sg_get_opcode_name((unsigned char)optsp->page_num, 0, sizeof(op_name) - 1, op_name); op_name[sizeof(op_name) - 1] = '\0'; printf("%s]\n", op_name); } - fprintf(stderr, "CmdDt INQUIRY on opcode=0x%.2x: failed\n", + fprintf(stderr, "CmdDt INQUIRY on opcode=%#.2x: failed\n", optsp->page_num); } } @@ -2043,7 +2043,7 @@ process_vpd(int sg_fd, const struct opts_t * optsp) memset(rsp_buff, 0, DEF_ALLOC_LEN); if (! optsp->do_raw) - printf("VPD INQUIRY, page code=0x%.2x:\n", optsp->page_num); + printf("VPD INQUIRY, page code=%#.2x:\n", optsp->page_num); res = sg_ll_inquiry(sg_fd, 0, 1, optsp->page_num, rsp_buff, DEF_ALLOC_LEN, 1, optsp->do_verbose); if (0 == res) { @@ -2078,9 +2078,9 @@ process_vpd(int sg_fd, const struct opts_t * optsp) vpd = rsp_buff[4 + k]; cp = get_vpd_page_str(vpd, peri_type); if (cp) - printf(" 0x%x\t%s\n", vpd, cp); + printf(" %#x\t%s\n", vpd, cp); else - printf(" 0x%x\n", vpd); + printf(" %#x\n", vpd); } } else dStrHex((const char *)rsp_buff, len, 0); @@ -2341,7 +2341,7 @@ decode_vpd(int sg_fd, const struct opts_t * optsp) printf("VPD INQUIRY: OSD information (OSD)\n"); break; default: - printf("VPD INQUIRY: page=0x%x, pdt=0x%x\n", 0xb0, pdt); + printf("VPD INQUIRY: page=%#x, pdt=%#x\n", 0xb0, pdt); break; } } @@ -2390,7 +2390,7 @@ decode_vpd(int sg_fd, const struct opts_t * optsp) "(ADC):\n"); break; default: - printf("VPD INQUIRY: page=0x%x, pdt=0x%x\n", 0xb1, pdt); + printf("VPD INQUIRY: page=%#x, pdt=%#x\n", 0xb1, pdt); break; } } diff --git a/src/sg_logs.c b/src/sg_logs.c index 6074fca5..b4cf546e 100644 --- a/src/sg_logs.c +++ b/src/sg_logs.c @@ -25,7 +25,7 @@ */ -static char * version_str = "0.87 20090608"; /* SPC-4 revision 20 */ +static char * version_str = "0.87 20090721"; /* SPC-4 revision 20 */ #define MX_ALLOC_LEN (0xfffc) #define SHORT_RESP_LEN 128 @@ -38,6 +38,7 @@ static char * version_str = "0.87 20090608"; /* SPC-4 revision 20 */ #define VERIFY_ERR_LPAGE 0x5 #define NON_MEDIUM_LPAGE 0x6 #define LAST_N_ERR_LPAGE 0x7 +#define FORMAT_STATUS_LPAGE 0x8 #define LAST_N_DEFERRED_LPAGE 0xb #define TEMPERATURE_LPAGE 0xd #define START_STOP_LPAGE 0xe @@ -350,7 +351,7 @@ process_cl_new(struct opts_t * optsp, int argc, char * argv[]) ++optsp->do_version; break; default: - fprintf(stderr, "unrecognised option code %c [0x%x]\n", c, c); + fprintf(stderr, "unrecognised option code %c [%#x]\n", c, c); if (optsp->do_help) break; usage(); @@ -633,9 +634,9 @@ show_page_name(int pg_code, int subpg_code, memset(b, 0, sizeof(b)); /* first process log pages that do not depend on peripheral type */ if (NOT_SUBPG_LOG == subpg_code) - snprintf(b, sizeof(b) - 1, " 0x%02x ", pg_code); + snprintf(b, sizeof(b) - 1, " %#02x ", pg_code); else - snprintf(b, sizeof(b) - 1, " 0x%02x,0x%02x ", pg_code, + snprintf(b, sizeof(b) - 1, " %#02x,%#02x ", pg_code, subpg_code); done = 1; if ((NOT_SUBPG_LOG == subpg_code) || (ALL_SUBPG_LOG == subpg_code)) { @@ -703,7 +704,7 @@ show_page_name(int pg_code, int subpg_code, /* disk (direct access) type devices */ { switch (pg_code) { - case 0x8: + case FORMAT_STATUS_LPAGE: printf("%sFormat status (sbc-2)\n", b); break; case 0x15: @@ -831,12 +832,12 @@ get_pcb_str(int pcb, char * outp, int maxoutlen) if (pcb & 0x10) n += sprintf(buff + n, "tmc=%d ", ((pcb & 0xc) >> 2)); #if 1 - n += sprintf(buff + n, "format+linking=%d [0x%.2x]", pcb & 3, + n += sprintf(buff + n, "format+linking=%d [%#.2x]", pcb & 3, pcb); #else if (pcb & 0x1) n += sprintf(buff + n, "lbin=%d ", ((pcb & 0x2) >> 1)); - n += sprintf(buff + n, "lp=%d [0x%.2x]", pcb & 0x1, pcb); + n += sprintf(buff + n, "lp=%d [%#.2x]", pcb & 0x1, pcb); #endif if (outp && (n < maxoutlen)) { memcpy(outp, buff, n); @@ -870,14 +871,14 @@ show_buffer_under_overrun_page(unsigned char * resp, int len, int show_pcb) case 1 : printf("per command"); break; case 2 : printf("per failed reconnect"); break; case 3 : printf("per unit of time"); break; - default: printf("reserved [0x%x]", count_basis); break; + default: printf("reserved [%#x]", count_basis); break; } printf(", Cause: "); switch (cause) { case 0 : printf("undefined"); break; case 1 : printf("bus busy"); break; case 2 : printf("transfer rate too slow"); break; - default: printf("reserved [0x%x]", cause); break; + default: printf("reserved [%#x]", cause); break; } printf(", Type: "); if (ucp[1] & 1) @@ -933,7 +934,7 @@ show_error_counter_page(unsigned char * resp, int len, int show_pcb) printf("Verify error counter page\n"); break; default: - printf("expecting error counter page, got page = 0x%x\n", resp[0]); + printf("expecting error counter page, got page = %#x\n", resp[0]); return; } num = len - 4; @@ -952,7 +953,7 @@ show_error_counter_page(unsigned char * resp, int len, int show_pcb) case 6: printf(" Total uncorrected errors"); break; case 0x8009: printf(" Track following errors [Hitachi]"); break; case 0x8015: printf(" Positioning errors [Hitachi]"); break; - default: printf(" Reserved or vendor specific [0x%x]", pc); break; + default: printf(" Reserved or vendor specific [%#x]", pc); break; } k = pl - 4; xp = ucp + 4; @@ -998,9 +999,9 @@ show_non_medium_error_page(unsigned char * resp, int len, int show_pcb) printf(" Non-medium error count"); break; default: if (pc <= 0x7fff) - printf(" Reserved [0x%x]", pc); + printf(" Reserved [%#x]", pc); else - printf(" Vendor specific [0x%x]", pc); + printf(" Vendor specific [%#x]", pc); break; } k = pl - 4; @@ -1057,7 +1058,7 @@ show_power_condition_transitions_page(unsigned char * resp, int len, case 9: printf(" Accumulated transitions to standby_y"); break; default: - printf(" Reserved [0x%x]", pc); + printf(" Reserved [%#x]", pc); } k = pl - 4; xp = ucp + 4; @@ -1182,7 +1183,7 @@ show_self_test_page(unsigned char * resp, int len, int show_pcb) num = len - 4; if (num < 0x190) { - printf("short self-test results page [length 0x%x rather than " + printf("short self-test results page [length %#x rather than " "0x190 bytes]\n", num); return; } @@ -1206,9 +1207,9 @@ show_self_test_page(unsigned char * resp, int len, int show_pcb) ull <<= 8; ull |= ucp[13]; ull <<= 8; ull |= ucp[14]; ull <<= 8; ull |= ucp[15]; if ((0xffffffffffffffffULL != ull) && (res > 0) && ( res < 0xf)) - printf(" address of first error = 0x%" PRIx64 "\n", ull); + printf(" address of first error = %#" PRIx64 "\n", ull); if (ucp[16] & 0xf) - printf(" sense key = 0x%x, asc = 0x%x, asq = 0x%x", + printf(" sense key = %#x, asc = %#x, asq = %#x", ucp[16] & 0xf, ucp[17], ucp[18]); if (show_pcb) { get_pcb_str(pcb, pcb_str, sizeof(pcb_str)); @@ -1258,7 +1259,7 @@ show_temperature_page(unsigned char * resp, int len, int show_pcb, int hdr, } } else if (show_unknown) { - printf(" unknown parameter code = 0x%x, contents in hex:\n", pc); + printf(" unknown parameter code = %#x, contents in hex:\n", pc); dStrHex((const char *)ucp, extra, 1); } else continue; @@ -1355,7 +1356,7 @@ show_start_stop_page(unsigned char * resp, int len, int show_pcb, int verbose) } break; default: - printf(" unknown parameter code = 0x%x, contents in hex:\n", pc); + printf(" unknown parameter code = %#x, contents in hex:\n", pc); dStrHex((const char *)ucp, extra, 1); break; } @@ -1394,7 +1395,7 @@ show_ie_page(unsigned char * resp, int len, int show_pcb, int full) if (0 == pc) { if (extra > 5) { if (full) { - printf(" IE asc = 0x%x, ascq = 0x%x", ucp[4], ucp[5]); + printf(" IE asc = %#x, ascq = %#x", ucp[4], ucp[5]); if (ucp[4]) { if(sg_get_asc_ascq_str(ucp[4], ucp[5], sizeof(b), b)) printf("\n [%s]", b); @@ -1416,7 +1417,7 @@ show_ie_page(unsigned char * resp, int len, int show_pcb, int full) } } } else if (full) { - printf(" parameter code = 0x%x, contents in hex:\n", pc); + printf(" parameter code = %#x, contents in hex:\n", pc); dStrHex((const char *)ucp, extra, 1); } if (show_pcb) { @@ -1607,14 +1608,14 @@ show_sas_port_param(unsigned char * ucp, int param_len, if (optsp->do_name) { t = ((0x70 & vcp[4]) >> 4); printf(" att_dev_type=%d\n", t); - printf(" att_iport_mask=0x%x\n", vcp[6]); + printf(" att_iport_mask=%#x\n", vcp[6]); printf(" att_phy_id=%d\n", vcp[24]); - printf(" att_reason=0x%x\n", (vcp[4] & 0xf)); + printf(" att_reason=%#x\n", (vcp[4] & 0xf)); for (n = 0, ull = vcp[16]; n < 8; ++n) { ull <<= 8; ull |= vcp[16 + n]; } - printf(" att_sas_addr=0x%" PRIx64 "\n", ull); - printf(" att_tport_mask=0x%x\n", vcp[7]); + printf(" att_sas_addr=%#" PRIx64 "\n", ull); + printf(" att_tport_mask=%#x\n", vcp[7]); ui = (vcp[32] << 24) | (vcp[33] << 16) | (vcp[34] << 8) | vcp[35]; printf(" inv_dwords=%u\n", ui); ui = (vcp[40] << 24) | (vcp[41] << 16) | (vcp[42] << 8) | vcp[43]; @@ -1624,11 +1625,11 @@ show_sas_port_param(unsigned char * ucp, int param_len, printf(" phy_reset_probs=%u\n", ui); ui = (vcp[36] << 24) | (vcp[37] << 16) | (vcp[38] << 8) | vcp[39]; printf(" running_disparity=%u\n", ui); - printf(" reason=0x%x\n", (vcp[5] & 0xf0) >> 4); + printf(" reason=%#x\n", (vcp[5] & 0xf0) >> 4); for (n = 0, ull = vcp[8]; n < 8; ++n) { ull <<= 8; ull |= vcp[8 + n]; } - printf(" sas_addr=0x%" PRIx64 "\n", ull); + printf(" sas_addr=%#" PRIx64 "\n", ull); } else { t = ((0x70 & vcp[4]) >> 4); switch (t) { @@ -1653,7 +1654,7 @@ show_sas_port_param(unsigned char * ucp, int param_len, case 8: snprintf(s, sz, "phy test function stopped"); break; case 9: snprintf(s, sz, "expander device reduced functionality"); break; - default: snprintf(s, sz, "reserved [0x%x]", t); break; + default: snprintf(s, sz, "reserved [%#x]", t); break; } printf(" attached reason: %s\n", s); t = (vcp[5] & 0xf0) >> 4; @@ -1670,7 +1671,7 @@ show_sas_port_param(unsigned char * ucp, int param_len, case 8: snprintf(s, sz, "phy test function stopped"); break; case 9: snprintf(s, sz, "expander device reduced functionality"); break; - default: snprintf(s, sz, "reserved [0x%x]", t); break; + default: snprintf(s, sz, "reserved [%#x]", t); break; } printf(" reason: %s\n", s); t = (0xf & vcp[5]); @@ -1701,11 +1702,11 @@ show_sas_port_param(unsigned char * ucp, int param_len, for (n = 0, ull = vcp[8]; n < 8; ++n) { ull <<= 8; ull |= vcp[8 + n]; } - printf(" SAS address = 0x%" PRIx64 "\n", ull); + printf(" SAS address = %#" PRIx64 "\n", ull); for (n = 0, ull = vcp[16]; n < 8; ++n) { ull <<= 8; ull |= vcp[16 + n]; } - printf(" attached SAS address = 0x%" PRIx64 "\n", ull); + printf(" attached SAS address = %#" PRIx64 "\n", ull); printf(" attached phy identifier = %d\n", vcp[24]); ui = (vcp[32] << 24) | (vcp[33] << 16) | (vcp[34] << 8) | vcp[35]; printf(" Invalid DWORD count = %u\n", ui); @@ -1756,7 +1757,7 @@ show_protocol_specific_page(unsigned char * resp, int len, num = len - 4; if (optsp->do_name) - printf("log_page=0x%x\n", PORT_SPECIFIC_LPAGE); + printf("log_page=%#x\n", PORT_SPECIFIC_LPAGE); for (k = 0, ucp = resp + 4; k < num; ) { param_len = ucp[3] + 4; if (6 != (0xf & ucp[4])) @@ -1788,9 +1789,9 @@ show_stats_perform_page(unsigned char * resp, int len, spf = !!(resp[0] & 0x40); subpg_code = spf ? resp[1] : 0; if (nam) { - printf("log_page=0x%x\n", STATS_LPAGE); + printf("log_page=%#x\n", STATS_LPAGE); if (subpg_code > 0) - printf("log_subpage=0x%x\n", subpg_code); + printf("log_subpage=%#x\n", subpg_code); } if (subpg_code > 31) return 0; @@ -2118,9 +2119,9 @@ show_cache_stats_page(unsigned char * resp, int len, spf = !!(resp[0] & 0x40); subpg_code = spf ? resp[1] : 0; if (nam) { - printf("log_page=0x%x\n", STATS_LPAGE); + printf("log_page=%#x\n", STATS_LPAGE); if (subpg_code > 0) - printf("log_subpage=0x%x\n", subpg_code); + printf("log_subpage=%#x\n", subpg_code); } else printf("Cache memory statistics log page\n"); @@ -2256,7 +2257,7 @@ show_format_status_page(unsigned char * resp, int len, int show_pcb) case 3: printf(" Total new blocks reassigned"); break; case 4: printf(" Power on minutes since format"); break; default: - printf(" Unknown Format status code = 0x%x\n", pc); + printf(" Unknown Format status code = %#x\n", pc); counter = 0; dStrHex((const char *)ucp, pl, 0); break; @@ -2356,7 +2357,7 @@ show_non_volatile_cache_page(unsigned char * resp, int len, int show_pcb) printf("<unexpected parameter length=%d>\n", ucp[4]); break; default: - printf(" Unknown Format status code = 0x%x\n", pc); + printf(" Unknown Format status code = %#x\n", pc); dStrHex((const char *)ucp, pl, 0); break; } @@ -2429,7 +2430,7 @@ show_background_scan_results_page(unsigned char * resp, int len, int show_pcb, if (j < (int)(sizeof(bms_status) / sizeof(bms_status[0]))) printf("%s\n", bms_status[j]); else - printf("unknown [0x%x] background scan status value\n", j); + printf("unknown [%#x] background scan status value\n", j); j = (ucp[10] << 8) + ucp[11]; printf(" Number of background scans performed: %d\n", j); j = (ucp[12] << 8) + ucp[13]; @@ -2467,8 +2468,8 @@ show_background_scan_results_page(unsigned char * resp, int len, int show_pcb, (int)(sizeof(reassign_status) / sizeof(reassign_status[0]))) printf(" %s\n", reassign_status[j]); else - printf(" Reassign status: reserved [0x%x]\n", j); - printf(" sense key: %s [sk,asc,ascq: 0x%x,0x%x,0x%x]\n", + printf(" Reassign status: reserved [%#x]\n", j); + printf(" sense key: %s [sk,asc,ascq: %#x,%#x,%#x]\n", sg_get_sense_key_str(ucp[8] & 0xf, sizeof(str), str), ucp[8] & 0xf, ucp[9], ucp[10]); printf(" %s\n", sg_get_asc_ascq_str(ucp[9], ucp[10], @@ -2476,7 +2477,7 @@ show_background_scan_results_page(unsigned char * resp, int len, int show_pcb, if (verbose) { printf(" vendor bytes [11 -> 15]: "); for (m = 0; m < 5; ++m) - printf("0x%02x ", ucp[11 + m]); + printf("%#02x ", ucp[11 + m]); printf("\n"); } printf(" LBA (associated with medium error): 0x"); @@ -2583,10 +2584,10 @@ show_sequential_access_page(unsigned char * resp, int len, int show_pcb, break; default: if (pc >= 0x8000) - printf(" Vendor specific parameter [0x%x] value: %" PRIu64 + printf(" Vendor specific parameter [%#x] value: %" PRIu64 "\n", pc, ull); else - printf(" Reserved parameter [0x%x] value: %" PRIu64 "\n", + printf(" Reserved parameter [%#x] value: %" PRIu64 "\n", pc, ull); break; } @@ -2677,7 +2678,7 @@ show_device_stats_page(unsigned char * resp, int len, int show_pcb) "eject occurred: %" PRIu64 "\n", ull); break; default: - printf(" Reserved parameter [0x%x] value: %" PRIu64 "\n", + printf(" Reserved parameter [%#x] value: %" PRIu64 "\n", pc, ull); break; } @@ -2689,7 +2690,7 @@ show_device_stats_page(unsigned char * resp, int len, int show_pcb) dStrHex((const char *)ucp, pl, 0); break; default: - printf(" Reserved parameter [0x%x], dump in hex:\n", pc); + printf(" Reserved parameter [%#x], dump in hex:\n", pc); dStrHex((const char *)ucp, pl, 0); break; } @@ -2824,7 +2825,7 @@ show_media_stats_page(unsigned char * resp, int len, int show_pcb) "recovered errors: %" PRIu64 "\n", ull); break; default: - printf(" Reserved parameter [0x%x] value: %" PRIu64 "\n", + printf(" Reserved parameter [%#x] value: %" PRIu64 "\n", pc, ull); break; } @@ -2892,11 +2893,11 @@ show_mchanger_diag_data_page(unsigned char * resp, int len, int show_pcb) pl = ucp[3] + 4; printf(" Parameter code: %d\n", pc); printf(" Repeat: %d\n", !!(ucp[5] & 0x80)); - printf(" Sense key: 0x%x\n", ucp[5] & 0xf); - printf(" Additional sense code: 0x%x\n", ucp[6]); - printf(" Additional sense code qualifier: 0x%x\n", ucp[7]); + printf(" Sense key: %#x\n", ucp[5] & 0xf); + printf(" Additional sense code: %#x\n", ucp[6]); + printf(" Additional sense code qualifier: %#x\n", ucp[7]); v = (ucp[8] << 24) + (ucp[9] << 16) + (ucp[10] << 8) + ucp[11]; - printf(" Vendor specific code qualifier: 0x%x\n", v); + printf(" Vendor specific code qualifier: %#x\n", v); v = (ucp[12] << 24) + (ucp[13] << 16) + (ucp[14] << 8) + ucp[15]; printf(" Product revision level: %u\n", v); v = (ucp[16] << 24) + (ucp[17] << 16) + (ucp[18] << 8) + ucp[19]; @@ -2913,27 +2914,27 @@ show_mchanger_diag_data_page(unsigned char * resp, int len, int show_pcb) printf(" Number of determined volume identifiers: %u\n", v); v = (ucp[40] << 24) + (ucp[41] << 16) + (ucp[42] << 8) + ucp[43]; printf(" Number of unreadable volume identifiers: %u\n", v); - printf(" Operation code: 0x%x\n", ucp[44]); - printf(" Service action: 0x%x\n", ucp[45] & 0xf); - printf(" Media changer error type: 0x%x\n", ucp[46]); + printf(" Operation code: %#x\n", ucp[44]); + printf(" Service action: %#x\n", ucp[45] & 0xf); + printf(" Media changer error type: %#x\n", ucp[46]); printf(" MTAV: %d\n", !!(ucp[47] & 0x8)); printf(" IAV: %d\n", !!(ucp[47] & 0x4)); printf(" LSAV: %d\n", !!(ucp[47] & 0x2)); printf(" DAV: %d\n", !!(ucp[47] & 0x1)); v = (ucp[48] << 8) + ucp[49]; - printf(" Medium transport address: 0x%x\n", v); + printf(" Medium transport address: %#x\n", v); v = (ucp[50] << 8) + ucp[51]; - printf(" Intial address: 0x%x\n", v); + printf(" Intial address: %#x\n", v); v = (ucp[52] << 8) + ucp[53]; - printf(" Last successful address: 0x%x\n", v); + printf(" Last successful address: %#x\n", v); v = (ucp[54] << 8) + ucp[55]; - printf(" Destination address: 0x%x\n", v); + printf(" Destination address: %#x\n", v); if (pl > 91) { printf(" Volume tag information:\n"); dStrHex((const char *)(ucp + 56), 36, 0); } if (pl > 99) { - printf(" Timestamp origin: 0x%x\n", ucp[92] & 0xf); + printf(" Timestamp origin: %#x\n", ucp[92] & 0xf); printf(" Timestamp:\n"); dStrHex((const char *)(ucp + 94), 6, 1); } @@ -3034,7 +3035,7 @@ show_tape_alert_ssc_page(unsigned char * resp, int len, int show_pcb, sizeof(tape_alert_strs[0]))) printf(" %s: %d\n", tape_alert_strs[pc], flag); else - printf(" Reserved parameter code 0x%x, flag: %d\n", pc, + printf(" Reserved parameter code %#x, flag: %d\n", pc, flag); } if (show_pcb) { @@ -3070,7 +3071,7 @@ show_seagate_cache_page(unsigned char * resp, int len, int show_pcb) "<= segment size"); break; case 4: printf(" Number of read and write commands whose size " "> segment size"); break; - default: printf(" Unknown Seagate parameter code = 0x%x", pc); break; + default: printf(" Unknown Seagate parameter code = %#x", pc); break; } k = pl - 4; xp = ucp + 4; @@ -3118,7 +3119,7 @@ show_seagate_factory_page(unsigned char * resp, int len, int show_pcb) break; default: valid = 0; - printf(" Unknown Seagate/Hitachi parameter code = 0x%x", pc); + printf(" Unknown Seagate/Hitachi parameter code = %#x", pc); break; } if (valid) { @@ -3167,7 +3168,7 @@ show_ascii_page(unsigned char * resp, int len, subpg_code = spf ? resp[1] : 0; if ((ALL_PAGE_LPAGE != pg_code ) && (ALL_SUBPG_LOG == subpg_code)) { - printf("Supported subpages for log page=0x%x\n", pg_code); + printf("Supported subpages for log page=%#x\n", pg_code); for (k = 0; k < num; k += 2) show_page_name((int)resp[4 + k], (int)resp[4 + k + 1], inq_dat); @@ -3201,7 +3202,7 @@ show_ascii_page(unsigned char * resp, int len, case LAST_N_ERR_LPAGE: show_last_n_error_page(resp, len, optsp->do_pcb); break; - case 0x8: + case FORMAT_STATUS_LPAGE: { switch (inq_dat->peripheral_type) { case PDT_DISK: case PDT_WO: case PDT_OPTICAL: case PDT_RBC: @@ -3357,7 +3358,7 @@ show_ascii_page(unsigned char * resp, int len, break; } if (! done) { - printf("No ascii information for page = 0x%x, here is hex:\n", + printf("No ascii information for page = %#x, here is hex:\n", resp[0] & 0x3f); if (len > 128) { dStrHex((const char *)resp, 64, 1); @@ -3534,11 +3535,11 @@ main(int argc, char * argv[]) else if (pg_len > 1) { if (opts.do_hex) { if (rsp_buff[0] & 0x40) - printf("Log page code=0x%x,0x%x, DS=%d, SPF=1, " - "page_len=0x%x\n", rsp_buff[0] & 0x3f, rsp_buff[1], + printf("Log page code=%#x,%#x, DS=%d, SPF=1, " + "page_len=%#x\n", rsp_buff[0] & 0x3f, rsp_buff[1], !!(rsp_buff[0] & 0x80), pg_len); else - printf("Log page code=0x%x, DS=%d, SPF=0, page_len=0x%x\n", + printf("Log page code=%#x, DS=%d, SPF=0, page_len=%#x\n", rsp_buff[0] & 0x3f, !!(rsp_buff[0] & 0x80), pg_len); dStrHex((const char *)rsp_buff, pg_len + 4, 1); } @@ -3583,25 +3584,25 @@ main(int argc, char * argv[]) dStrHex((const char *)rsp_buff, pg_len + 4, 1); else if (opts.do_hex) { if (rsp_buff[0] & 0x40) - printf("Log page code=0x%x,0x%x, DS=%d, SPF=1, page_" - "len=0x%x\n", rsp_buff[0] & 0x3f, rsp_buff[1], + printf("Log page code=%#x,%#x, DS=%d, SPF=1, page_" + "len=%#x\n", rsp_buff[0] & 0x3f, rsp_buff[1], !!(rsp_buff[0] & 0x80), pg_len); else - printf("Log page code=0x%x, DS=%d, SPF=0, page_len=" - "0x%x\n", rsp_buff[0] & 0x3f, + printf("Log page code=%#x, DS=%d, SPF=0, page_len=" + "%#x\n", rsp_buff[0] & 0x3f, !!(rsp_buff[0] & 0x80), pg_len); dStrHex((const char *)rsp_buff, pg_len + 4, 1); } else show_ascii_page(rsp_buff, pg_len + 4, &inq_out, &opts); } else if (SG_LIB_CAT_INVALID_OP == res) - fprintf(stderr, "log_sense: page=0x%x,0x%x not supported\n", + fprintf(stderr, "log_sense: page=%#x,%#x not supported\n", opts.pg_code, opts.subpg_code); else if (SG_LIB_CAT_NOT_READY == res) fprintf(stderr, "log_sense: device not ready\n"); else if (SG_LIB_CAT_ILLEGAL_REQ == res) fprintf(stderr, "log_sense: field in cdb illegal " - "[page=0x%x,0x%x]\n", opts.pg_code, opts.subpg_code); + "[page=%#x,%#x]\n", opts.pg_code, opts.subpg_code); else if (SG_LIB_CAT_UNIT_ATTENTION == res) fprintf(stderr, "log_sense: unit attention\n"); else if (SG_LIB_CAT_ABORTED_COMMAND == res) diff --git a/src/sg_luns.c b/src/sg_luns.c index 0df18a27..a8a07d93 100644 --- a/src/sg_luns.c +++ b/src/sg_luns.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2008 Douglas Gilbert. + * Copyright (c) 2004-2009 Douglas Gilbert. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -48,7 +48,7 @@ * This program issues the SCSI REPORT LUNS command to the given SCSI device. */ -static char * version_str = "1.15 20090617"; +static char * version_str = "1.15 20090717"; #define MAX_RLUNS_BUFF_LEN (1024 * 64) #define DEF_RLUNS_BUFF_LEN (1024 * 8) @@ -178,7 +178,7 @@ decode_lun(const char * leadin, unsigned char * lunp) } else if ((1 == len) && (2 == e_a_method)) { x = (lunp[1] << 16) + (lunp[2] << 8) + lunp[3]; printf("%sExtended flat space logical unit addressing: " - "value=0x%x\n", l_leadin, x); + "value=%#x\n", l_leadin, x); } else if ((3 == len) && (0xf == e_a_method)) printf("%sLogical unit _not_ specified addressing\n", l_leadin); @@ -187,7 +187,7 @@ decode_lun(const char * leadin, unsigned char * lunp) if (1 == len) x = (lunp[1] << 16) + (lunp[2] << 8) + lunp[3]; printf("%sExtended logical unit addressing: length=%d, " - "e.a. method=%d, value=0x%x\n", l_leadin, len, + "e.a. method=%d, value=%#x\n", l_leadin, len, e_a_method, x); } else { ull = 0; @@ -198,7 +198,7 @@ decode_lun(const char * leadin, unsigned char * lunp) ull |= lunp[1 + j]; } printf("%sExtended logical unit addressing: length=%d, " - "e. a. method=%d, value=0x%" PRIx64 "\n", + "e. a. method=%d, value=%#" PRIx64 "\n", l_leadin, len, e_a_method, ull); } } @@ -286,7 +286,7 @@ main(int argc, char * argv[]) fprintf(stderr, "version: %s\n", version_str); return 0; default: - fprintf(stderr, "unrecognised option code 0x%x ??\n", c); + fprintf(stderr, "unrecognised option code %#x ??\n", c); usage(); return SG_LIB_SYNTAX_ERROR; } diff --git a/src/sg_map26.c b/src/sg_map26.c index 3a6b1670..3f82f1a5 100644 --- a/src/sg_map26.c +++ b/src/sg_map26.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005-2008 Douglas Gilbert. + * Copyright (c) 2005-2009 Douglas Gilbert. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -61,7 +61,7 @@ #endif #include "sg_lib.h" -static char * version_str = "1.08 20081009"; +static char * version_str = "1.08 20090717"; #define ME "sg_map26: " @@ -1123,7 +1123,7 @@ main(int argc, char * argv[]) fprintf(stderr, ME "version: %s\n", version_str); return 0; default: - fprintf(stderr, "unrecognised option code 0x%x ??\n", + fprintf(stderr, "unrecognised option code %#x ??\n", c); usage(); return SG_LIB_SYNTAX_ERROR; diff --git a/src/sg_modes.c b/src/sg_modes.c index 0ac1820f..c53fdaae 100644 --- a/src/sg_modes.c +++ b/src/sg_modes.c @@ -26,7 +26,7 @@ */ -static char * version_str = "1.31 20090604"; +static char * version_str = "1.31 20090717"; #define DEF_ALLOC_LEN (1024 * 4) #define DEF_6_ALLOC_LEN 252 @@ -294,7 +294,7 @@ process_cl_new(struct opts_t * optsp, int argc, char * argv[]) ++optsp->do_version; break; default: - fprintf(stderr, "unrecognised option code %c [0x%x]\n", c, c); + fprintf(stderr, "unrecognised option code %c [%#x]\n", c, c); if (optsp->do_help) break; usage(); @@ -769,27 +769,27 @@ list_page_codes(int scsi_ptype, int inq_byte6, int t_proto) dp = (--num <= 0) ? NULL : (dp + 1); /* skip protocol specific */ else if (c == d) { if (pe_dp->subpage_code) - printf(" 0x%02x,0x%02x * %s\n", pe_dp->page_code, + printf(" %#02x,%#02x * %s\n", pe_dp->page_code, pe_dp->subpage_code, pe_dp->desc); else - printf(" 0x%02x * %s\n", pe_dp->page_code, + printf(" %#02x * %s\n", pe_dp->page_code, pe_dp->desc); dp = (--num <= 0) ? NULL : (dp + 1); pe_dp = (--num_ptype <= 0) ? NULL : (pe_dp + 1); } else if (c < d) { if (dp->subpage_code) - printf(" 0x%02x,0x%02x %s\n", dp->page_code, + printf(" %#02x,%#02x %s\n", dp->page_code, dp->subpage_code, dp->desc); else - printf(" 0x%02x %s\n", dp->page_code, + printf(" %#02x %s\n", dp->page_code, dp->desc); dp = (--num <= 0) ? NULL : (dp + 1); } else { if (pe_dp->subpage_code) - printf(" 0x%02x,0x%02x %s\n", pe_dp->page_code, + printf(" %#02x,%#02x %s\n", pe_dp->page_code, pe_dp->subpage_code, pe_dp->desc); else - printf(" 0x%02x %s\n", pe_dp->page_code, + printf(" %#02x %s\n", pe_dp->page_code, pe_dp->desc); pe_dp = (--num_ptype <= 0) ? NULL : (pe_dp + 1); } @@ -802,10 +802,10 @@ list_page_codes(int scsi_ptype, int inq_byte6, int t_proto) dp = mode_page_cs_table(0xd, &num); while (dp) { if (dp->subpage_code) - printf(" 0x%02x,0x%02x %s\n", dp->page_code, + printf(" %#02x,%#02x %s\n", dp->page_code, dp->subpage_code, dp->desc); else - printf(" 0x%02x %s\n", dp->page_code, + printf(" %#02x %s\n", dp->page_code, dp->desc); dp = (--num <= 0) ? NULL : (dp + 1); } @@ -816,10 +816,10 @@ list_page_codes(int scsi_ptype, int inq_byte6, int t_proto) dp = mode_page_cs_table(0x8, &num); while (dp) { if (dp->subpage_code) - printf(" 0x%02x,0x%02x %s\n", dp->page_code, + printf(" %#02x,%#02x %s\n", dp->page_code, dp->subpage_code, dp->desc); else - printf(" 0x%02x %s\n", dp->page_code, + printf(" %#02x %s\n", dp->page_code, dp->desc); dp = (--num <= 0) ? NULL : (dp + 1); } @@ -830,10 +830,10 @@ list_page_codes(int scsi_ptype, int inq_byte6, int t_proto) dp = mode_page_transp_table(t_proto, &num); while (dp) { if (dp->subpage_code) - printf(" 0x%02x,0x%02x %s\n", dp->page_code, + printf(" %#02x,%#02x %s\n", dp->page_code, dp->subpage_code, dp->desc); else - printf(" 0x%02x %s\n", dp->page_code, + printf(" %#02x %s\n", dp->page_code, dp->desc); dp = (--num <= 0) ? NULL : (dp + 1); } @@ -890,7 +890,7 @@ examine_pages(int sg_fd, int inq_pdt, int inq_byte6, if (cp) printf(" %s\n", cp); else - printf(" [0x%x]\n", k); + printf(" [%#x]\n", k); if (optsp->do_hex) dStrHex((const char *)rbuf, len, 1); } @@ -1021,7 +1021,7 @@ main(int argc, char * argv[]) inq_pdt = inq_out.peripheral_type; inq_byte6 = inq_out.byte_6; if (0 == opts.do_raw) - printf(" %.8s %.16s %.4s peripheral_type: %s [0x%x]\n", + printf(" %.8s %.16s %.4s peripheral_type: %s [%#x]\n", inq_out.vendor, inq_out.product, inq_out.revision, sg_get_pdt_str(inq_pdt, sizeof(pdt_name), pdt_name), inq_pdt); if (opts.do_list) { @@ -1083,7 +1083,7 @@ main(int argc, char * argv[]) "page control (PC) not supported)\n"); else fprintf(stderr, "invalid field in cdb (perhaps " - "page 0x%x not supported)\n", opts.pg_code); + "page %#x not supported)\n", opts.pg_code); } else if (SG_LIB_CAT_NOT_READY == res) fprintf(stderr, "device not ready\n"); else if (SG_LIB_CAT_UNIT_ATTENTION == res) @@ -1160,12 +1160,12 @@ main(int argc, char * argv[]) } else if (opts.do_hex > 1) dStrHex((const char *)rsp_buff, headerlen, 1); if (0 == inq_pdt) - printf(" Mode data length=%d, medium type=0x%.2x, WP=%d," + printf(" Mode data length=%d, medium type=%#.2x, WP=%d," " DpoFua=%d, longlba=%d\n", md_len, medium_type, !!(specific & 0x80), !!(specific & 0x10), longlba); else - printf(" Mode data length=%d, medium type=0x%.2x, specific" - " param=0x%.2x, longlba=%d\n", md_len, medium_type, + printf(" Mode data length=%d, medium type=%#.2x, specific" + " param=%#.2x, longlba=%d\n", md_len, medium_type, specific, longlba); if (md_len > rsp_buff_size) { printf("Only fetched %d bytes of response, truncate output\n", @@ -1195,7 +1195,7 @@ main(int argc, char * argv[]) ucp = rsp_buff + headerlen; while (num > 0) { - printf(" Density code=0x%x\n", + printf(" Density code=%#x\n", *(ucp + density_code_off)); dStrHex((const char *)ucp, len, 1); ucp += len; @@ -1230,10 +1230,10 @@ main(int argc, char * argv[]) } if (opts.do_hex) { if (spf) - printf(">> page_code=0x%x, subpage_code=0x%x, page_cont" + printf(">> page_code=%#x, subpage_code=%#x, page_cont" "rol=%d\n", page_num, ucp[1], opts.page_control); else - printf(">> page_code=0x%x, page_control=%d\n", page_num, + printf(">> page_code=%#x, page_control=%d\n", page_num, opts.page_control); } else { descp = NULL; @@ -1246,10 +1246,10 @@ main(int argc, char * argv[]) inq_pdt, inq_byte6, -1); if (NULL == descp) { if (spf) - snprintf(ebuff, EBUFF_SZ, "0x%x, subpage_code: 0x%x", + snprintf(ebuff, EBUFF_SZ, "%#x, subpage_code: %#x", page_num, ucp[1]); else - snprintf(ebuff, EBUFF_SZ, "0x%x", page_num); + snprintf(ebuff, EBUFF_SZ, "%#x", page_num); } if (descp) printf(">> %s, page_control: %s\n", descp, diff --git a/src/sg_opcodes.c b/src/sg_opcodes.c index b1e2a743..b68d753f 100644 --- a/src/sg_opcodes.c +++ b/src/sg_opcodes.c @@ -26,7 +26,7 @@ #include "sg_pt.h" -static char * version_str = "0.34 20090610"; /* spc4r20 */ +static char * version_str = "0.34 20090717"; /* spc4r20 */ #define SENSE_BUFF_LEN 32 /* Arbitrary, could be larger */ @@ -237,7 +237,7 @@ process_cl_new(struct opts_t * optsp, int argc, char * argv[]) ++optsp->do_version; break; default: - fprintf(stderr, "unrecognised option code %c [0x%x]\n", c, c); + fprintf(stderr, "unrecognised option code %c [%#x]\n", c, c); if (optsp->do_help) break; usage(); @@ -572,9 +572,9 @@ list_one(unsigned char * rsoc_buff, int cd_len, int rep_opts, int do_opcode, int v = 0; - printf("\n Opcode=0x%.2x", do_opcode); + printf("\n Opcode=%#.2x", do_opcode); if (rep_opts > 1) - printf(" Service_action=0x%.4x", do_servact); + printf(" Service_action=%#.4x", do_servact); printf("\n"); sg_get_opcode_sa_name(((do_opcode > 0) ? do_opcode : 0), ((do_servact > 0) ? do_servact : 0), @@ -596,7 +596,7 @@ list_one(unsigned char * rsoc_buff, int cd_len, int rep_opts, int do_opcode, v = 1; break; default: - snprintf(name_buff, NAME_BUFF_SZ, "support reserved [0x%x]", + snprintf(name_buff, NAME_BUFF_SZ, "support reserved [%#x]", rsoc_buff[1] & 7); cp = name_buff; break; @@ -691,7 +691,7 @@ main(int argc, char * argv[]) if (strlen(cp) > 0) printf(" Peripheral device type: %s\n", cp); else - printf(" Peripheral device type: 0x%x\n", peri_type); + printf(" Peripheral device type: %#x\n", peri_type); } } else { fprintf(stderr, "sg_opcodes: %s doesn't respond to a SCSI " diff --git a/src/sg_persist.c b/src/sg_persist.c index 76dad174..297fe66a 100644 --- a/src/sg_persist.c +++ b/src/sg_persist.c @@ -27,7 +27,7 @@ */ -static char * version_str = "0.36 20090402"; +static char * version_str = "0.36 20090717"; #define PRIN_RKEY_SA 0x0 @@ -223,13 +223,13 @@ decode_transport_id(const char * leadin, unsigned char * ucp, int len) bump = 24; break; case TPROTO_SPI: /* Parallel SCSI */ - printf("%s Parallel SCSI initiator SCSI address: 0x%x\n", + printf("%s Parallel SCSI initiator SCSI address: %#x\n", leadin, ((ucp[2] << 8) | ucp[3])); if (0 != format_code) printf("%s [Unexpected format code: %d]\n", leadin, format_code); printf("%s relative port number (of corresponding target): " - "0x%x\n", leadin, ((ucp[6] << 8) | ucp[7])); + "%#x\n", leadin, ((ucp[6] << 8) | ucp[7])); bump = 24; break; case TPROTO_SSA: @@ -274,7 +274,7 @@ decode_transport_id(const char * leadin, unsigned char * ucp, int len) ull <<= 8; ull |= ucp[4 + j]; } - printf("%s SAS address: 0x%" PRIx64 "\n", leadin, ull); + printf("%s SAS address: %#" PRIx64 "\n", leadin, ull); if (0 != format_code) printf("%s [Unexpected format code: %d]\n", leadin, format_code); @@ -294,7 +294,7 @@ decode_transport_id(const char * leadin, unsigned char * ucp, int len) break; case TPROTO_NONE: default: - fprintf(stderr, "%s unknown protocol id=0x%x " + fprintf(stderr, "%s unknown protocol id=%#x " "format_code=%d\n", leadin, proto_id, format_code); dStrHex((const char *)ucp, ((len > 24) ? 24 : len), 0); bump = 24; @@ -373,7 +373,7 @@ prin_work(int sg_fd, const struct opts_t * optsp) add_len = ((pr_buff[4] << 24) | (pr_buff[5] << 16) | (pr_buff[6] << 8) | pr_buff[7]); if (optsp->hex) { - printf(" PR generation=0x%x, ", pr_gen); + printf(" PR generation=%#x, ", pr_gen); if (add_len <= 0) printf("Additional length=%d\n", add_len); if (add_len > ((int)sizeof(pr_buff) - 8)) { @@ -385,7 +385,7 @@ prin_work(int sg_fd, const struct opts_t * optsp) dStrHex((const char *)(pr_buff + 8), add_len, 1); } } else if (PRIN_RKEY_SA == optsp->prin_sa) { - printf(" PR generation=0x%x, ", pr_gen); + printf(" PR generation=%#x, ", pr_gen); num = add_len / 8; if (num > 0) { if (1 == num) @@ -400,12 +400,12 @@ prin_work(int sg_fd, const struct opts_t * optsp) ull <<= 8; ull |= ucp[j]; } - printf(" 0x%" PRIx64 "\n", ull); + printf(" %#" PRIx64 "\n", ull); } } else printf("there are NO registered reservation keys\n"); } else if (PRIN_RRES_SA == optsp->prin_sa) { - printf(" PR generation=0x%x, ", pr_gen); + printf(" PR generation=%#x, ", pr_gen); num = add_len / 16; if (num > 0) { printf("Reservation follows:\n"); @@ -416,7 +416,7 @@ prin_work(int sg_fd, const struct opts_t * optsp) ull <<= 8; ull |= ucp[j]; } - printf(" Key=0x%" PRIx64 "\n", ull); + printf(" Key=%#" PRIx64 "\n", ull); j = ((ucp[13] >> 4) & 0xf); if (0 == j) printf(" scope: LU_SCOPE, "); @@ -427,7 +427,7 @@ prin_work(int sg_fd, const struct opts_t * optsp) } else printf("there is NO reservation held\n"); } else if (PRIN_RFSTAT_SA == optsp->prin_sa) { - printf(" PR generation=0x%x\n", pr_gen); + printf(" PR generation=%#x\n", pr_gen); ucp = pr_buff + 8; for (k = 0; k < add_len; k += num, ucp += num) { add_desc_len = ((ucp[20] << 24) | (ucp[21] << 16) | @@ -439,13 +439,13 @@ prin_work(int sg_fd, const struct opts_t * optsp) ull <<= 8; ull |= ucp[j]; } - printf(" Key=0x%" PRIx64 "\n", ull); + printf(" Key=%#" PRIx64 "\n", ull); if (ucp[12] & 0x2) printf(" All target ports bit set\n"); else { printf(" All target ports bit clear\n"); rel_pt_addr = ((ucp[18] << 8) | ucp[19]); - printf(" Relative port address: 0x%x\n", + printf(" Relative port address: %#x\n", rel_pt_addr); } if (ucp[12] & 0x1) { @@ -523,7 +523,7 @@ prout_work(int sg_fd, const struct opts_t * optsp) if (optsp->prout_sa < num_prout_sa_strs) strncpy(buff, prout_sa_strs[optsp->prout_sa], sizeof(buff)); else - snprintf(buff, sizeof(buff), "service action=0x%x", + snprintf(buff, sizeof(buff), "service action=%#x", optsp->prout_sa); fprintf(stderr, "PR out: command (%s) successful\n", buff); } @@ -898,7 +898,7 @@ main(int argc, char * argv[]) return 0; default: fprintf(stderr, "unrecognised switch " - "code 0x%x ??\n", c); + "code %#x ??\n", c); usage(); return SG_LIB_SYNTAX_ERROR; } @@ -999,7 +999,7 @@ main(int argc, char * argv[]) if (strlen(cp) > 0) printf(" Peripheral device type: %s\n", cp); else - printf(" Peripheral device type: 0x%x\n", peri_type); + printf(" Peripheral device type: %#x\n", peri_type); } else { printf("sg_persist: %s doesn't respond to a SCSI INQUIRY\n", device_name); diff --git a/src/sg_prevent.c b/src/sg_prevent.c index 5f23b11d..dd7aadc5 100644 --- a/src/sg_prevent.c +++ b/src/sg_prevent.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2007 Douglas Gilbert. + * Copyright (c) 2004-2009 Douglas Gilbert. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -46,7 +46,7 @@ * given SCSI device. */ -static char * version_str = "1.06 20070919"; +static char * version_str = "1.06 20090717"; #define ME "sg_prevent: " @@ -120,7 +120,7 @@ int main(int argc, char * argv[]) fprintf(stderr, ME "version: %s\n", version_str); return 0; default: - fprintf(stderr, "unrecognised option code 0x%x ??\n", c); + fprintf(stderr, "unrecognised option code %#x ??\n", c); usage(); return SG_LIB_SYNTAX_ERROR; } diff --git a/src/sg_rbuf.c b/src/sg_rbuf.c index 2148d911..de0eaf77 100644 --- a/src/sg_rbuf.c +++ b/src/sg_rbuf.c @@ -52,7 +52,7 @@ #endif -static char * version_str = "4.88 20071226"; +static char * version_str = "4.88 20090717"; static struct option long_options[] = { {"buffer", 1, 0, 'b'}, @@ -192,7 +192,7 @@ static int process_cl_new(struct opts_t * optsp, int argc, char * argv[]) ++optsp->do_version; break; default: - fprintf(stderr, "unrecognised option code %c [0x%x]\n", c, c); + fprintf(stderr, "unrecognised option code %c [%#x]\n", c, c); if (optsp->do_help) break; usage_for(optsp); diff --git a/src/sg_rdac.c b/src/sg_rdac.c index d78f3e31..fb609494 100644 --- a/src/sg_rdac.c +++ b/src/sg_rdac.c @@ -212,7 +212,7 @@ static void print_rdac_mode( unsigned char *ptr ) printf("alternate controller present; "); break; default: - printf("(Unknown controller status 0x%x); ", + printf("(Unknown controller status %#x); ", rdac_ptr->current_mode_msb); break; } @@ -227,7 +227,7 @@ static void print_rdac_mode( unsigned char *ptr ) printf("Dual active mode\n"); break; default: - printf("(Unknown mode 0x%x)\n", + printf("(Unknown mode %#x)\n", rdac_ptr->current_mode_lsb); } @@ -243,7 +243,7 @@ static void print_rdac_mode( unsigned char *ptr ) printf("active/active mode; "); break; default: - printf("(Unknown status 0x%x); ", + printf("(Unknown status %#x); ", rdac_ptr->alternate_mode_msb); break; } @@ -261,11 +261,11 @@ static void print_rdac_mode( unsigned char *ptr ) printf("held in reset\n"); break; default: - printf("(Unknown mode 0x%x)\n", + printf("(Unknown mode %#x)\n", rdac_ptr->alternate_mode_lsb); } printf(" Quiescence timeout: %d\n", rdac_ptr->quiescence); - printf(" RDAC option 0x%x\n", rdac_ptr->options); + printf(" RDAC option %#x\n", rdac_ptr->options); printf (" LUN Table:\n"); for (k = 0; k < 32; k += 8) { printf(" %x:",k / 8); diff --git a/src/sg_read.c b/src/sg_read.c index b18bfa33..0412bbc4 100644 --- a/src/sg_read.c +++ b/src/sg_read.c @@ -28,7 +28,7 @@ #include "sg_io_linux.h" /* A utility program for the Linux OS SCSI generic ("sg") device driver. -* Copyright (C) 2001 - 2007 D. Gilbert +* Copyright (C) 2001 - 2009 D. Gilbert * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) @@ -47,7 +47,7 @@ */ -static const char * version_str = "1.18 20071226"; +static const char * version_str = "1.18 20090717"; #define DEF_BLOCK_SIZE 512 #define DEF_BLOCKS_PER_TRANSFER 128 @@ -578,7 +578,7 @@ int main(int argc, char * argv[]) } } if (verbose) - fprintf(stderr, "Opened %s for SG_IO with flags=0x%x\n", inf, + fprintf(stderr, "Opened %s for SG_IO with flags=%#x\n", inf, flags); if ((dd_count > 0) && (! (FT_BLOCK & in_type))) { if (verbose > 2) { @@ -623,7 +623,7 @@ int main(int argc, char * argv[]) return SG_LIB_FILE_ERROR; } if (verbose) - fprintf(stderr, "Opened %s for Unix reads with flags=0x%x\n", + fprintf(stderr, "Opened %s for Unix reads with flags=%#x\n", inf, flags); if (skip > 0) { off64_t offset = skip; diff --git a/src/sg_read_buffer.c b/src/sg_read_buffer.c index aefc3b3a..266b605c 100644 --- a/src/sg_read_buffer.c +++ b/src/sg_read_buffer.c @@ -126,7 +126,7 @@ print_modes(void) fprintf(stderr, "The modes parameter argument can be numeric " "(hex or decimal)\nor symbolic:\n"); for (k = 0; k < NUM_MODES; k++) { - fprintf(stderr, " %2d (0x%02x) %-16s%s\n", modes[k].mode, + fprintf(stderr, " %2d (%#02x) %-16s%s\n", modes[k].mode, modes[k].mode, modes[k].mode_string, modes[k].comment); } } @@ -226,7 +226,7 @@ main(int argc, char * argv[]) fprintf(stderr, ME "version: %s\n", version_str); return 0; default: - fprintf(stderr, "unrecognised option code 0x%x ??\n", c); + fprintf(stderr, "unrecognised option code %#x ??\n", c); usage(); return SG_LIB_SYNTAX_ERROR; } @@ -320,13 +320,13 @@ main(int argc, char * argv[]) k = (resp[1] << 16) | (resp[2] << 8) | resp[3]; printf("OFFSET BOUNDARY: %d, Buffer offset alignment: %d-byte\n", resp[0], (1 << resp[0])); - printf("BUFFER CAPACITY: %d (0x%x)\n", k, k); + printf("BUFFER CAPACITY: %d (%#x)\n", k, k); break; case MODE_ECHO_BDESC: k = ((resp[2] & 0x1F) << 8) | resp[3]; printf("EBOS:%d\n", resp[0] & 1 ? 1 : 0); - printf("Echo buffer capacity: %d (0x%x)\n", k, k); + printf("Echo buffer capacity: %d (%#x)\n", k, k); break; default: dStrHex((const char *)resp, rb_len, 1); diff --git a/src/sg_read_long.c b/src/sg_read_long.c index 5359fcb4..0b2df286 100644 --- a/src/sg_read_long.c +++ b/src/sg_read_long.c @@ -16,7 +16,7 @@ #include "sg_cmds_extra.h" /* A utility program for the Linux OS SCSI subsystem. - * Copyright (C) 2004-2008 D. Gilbert + * Copyright (C) 2004-2009 D. Gilbert * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) @@ -29,7 +29,7 @@ the sector data and the ECC bytes. */ -static char * version_str = "1.16 20080510"; +static char * version_str = "1.16 20090717"; #define MAX_XFER_LEN 10000 @@ -196,7 +196,7 @@ main(int argc, char * argv[]) } break; default: - fprintf(stderr, "unrecognised option code 0x%x ??\n", c); + fprintf(stderr, "unrecognised option code %#x ??\n", c); usage(); return SG_LIB_SYNTAX_ERROR; } @@ -242,7 +242,7 @@ main(int argc, char * argv[]) memset(rawp, 0x0, MAX_XFER_LEN); fprintf(stderr, ME "issue read long (%s) to device %s\n xfer_len=%d " - "(0x%x), lba=%" PRIu64 " (0x%" PRIx64 "), correct=%d\n", + "(%#x), lba=%" PRIu64 " (%#" PRIx64 "), correct=%d\n", (do_16 ? "16" : "10"), device_name, xfer_len, xfer_len, llba, llba, correct); diff --git a/src/sg_readcap.c b/src/sg_readcap.c index f0433ede..5ad0fdc2 100644 --- a/src/sg_readcap.c +++ b/src/sg_readcap.c @@ -28,7 +28,7 @@ */ -static char * version_str = "3.84 20090422"; +static char * version_str = "3.84 20090717"; #define ME "sg_readcap: " @@ -193,7 +193,7 @@ static int process_cl_new(struct opts_t * optsp, int argc, char * argv[]) ++optsp->do_version; break; default: - fprintf(stderr, "unrecognised option code %c [0x%x]\n", c, c); + fprintf(stderr, "unrecognised option code %c [%#x]\n", c, c); if (optsp->do_help) break; usage(); @@ -404,15 +404,15 @@ int main(int argc, char * argv[]) block_size = ((resp_buff[4] << 24) | (resp_buff[5] << 16) | (resp_buff[6] << 8) | resp_buff[7]); if (opts.do_brief) { - printf("0x%x 0x%x\n", last_blk_addr + 1, block_size); + printf("%#x %#x\n", last_blk_addr + 1, block_size); goto good; } printf("Read Capacity results:\n"); if (opts.do_pmi) - printf(" PMI mode: given lba=0x%" PRIx64 ", last lba " - "before delay=0x%x\n", opts.llba, last_blk_addr); + printf(" PMI mode: given lba=%#" PRIx64 ", last lba " + "before delay=%#x\n", opts.llba, last_blk_addr); else - printf(" Last logical block address=%u (0x%x), Number " + printf(" Last logical block address=%u (%#x), Number " "of blocks=%u\n", last_blk_addr, last_blk_addr, last_blk_addr + 1); printf(" Logical block length=%u bytes\n", block_size); @@ -482,7 +482,7 @@ int main(int argc, char * argv[]) block_size = ((resp_buff[8] << 24) | (resp_buff[9] << 16) | (resp_buff[10] << 8) | resp_buff[11]); if (opts.do_brief) { - printf("0x%" PRIx64 " 0x%x\n", llast_blk_addr + 1, block_size); + printf("%#" PRIx64 " %#x\n", llast_blk_addr + 1, block_size); goto good; } printf("Read Capacity results:\n"); @@ -492,11 +492,11 @@ int main(int argc, char * argv[]) printf(" Thin provisioning: tpe=%d, tprz=%d\n", !!(resp_buff[14] & 0x80), !!(resp_buff[14] & 0x40)); if (opts.do_pmi) - printf(" PMI mode: given lba=0x%" PRIx64 ", last lba " - "before delay=0x%" PRIx64 "\n", opts.llba, + printf(" PMI mode: given lba=%#" PRIx64 ", last lba " + "before delay=%#" PRIx64 "\n", opts.llba, llast_blk_addr); else - printf(" Last logical block address=%" PRIu64 " (0x%" + printf(" Last logical block address=%" PRIu64 " (%#" PRIx64 "), Number of logical blocks=%" PRIu64 "\n", llast_blk_addr, llast_blk_addr, llast_blk_addr + 1); printf(" Logical block length=%u bytes\n", block_size); diff --git a/src/sg_reassign.c b/src/sg_reassign.c index 7d8730e7..32e77823 100644 --- a/src/sg_reassign.c +++ b/src/sg_reassign.c @@ -54,7 +54,7 @@ * vendor specific data is written. */ -static char * version_str = "1.12 20090611"; +static char * version_str = "1.12 20090717"; #define ME "sg_reassign: " @@ -339,7 +339,7 @@ main(int argc, char * argv[]) fprintf(stderr, ME "version: %s\n", version_str); return 0; default: - fprintf(stderr, "unrecognised option code 0x%x ??\n", c); + fprintf(stderr, "unrecognised option code %#x ??\n", c); usage(); return SG_LIB_SYNTAX_ERROR; } @@ -426,7 +426,7 @@ main(int argc, char * argv[]) if (verbose) { fprintf(stderr, " Would have reassigned these blocks:\n"); for (j = 0; j < addr_arr_len; ++j) - printf(" 0x%" PRIx64 "\n", addr_arr[j]); + printf(" %#" PRIx64 "\n", addr_arr[j]); } return 0; } diff --git a/src/sg_requests.c b/src/sg_requests.c index d7a118fe..2b1d3612 100644 --- a/src/sg_requests.c +++ b/src/sg_requests.c @@ -47,7 +47,7 @@ * This program issues the SCSI command REQUEST SENSE to the given SCSI device. */ -static char * version_str = "1.22 20090607"; +static char * version_str = "1.22 20090717"; #define MAX_REQS_RESP_LEN 255 #define DEF_REQS_RESP_LEN 252 @@ -197,7 +197,7 @@ main(int argc, char * argv[]) fprintf(stderr, ME "version: %s\n", version_str); return 0; default: - fprintf(stderr, "unrecognised option code 0x%x ??\n", c); + fprintf(stderr, "unrecognised option code %#x ??\n", c); usage(); return SG_LIB_SYNTAX_ERROR; } diff --git a/src/sg_rmsn.c b/src/sg_rmsn.c index 2467cdd5..73f83042 100644 --- a/src/sg_rmsn.c +++ b/src/sg_rmsn.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005-2008 Douglas Gilbert. + * Copyright (c) 2005-2009 Douglas Gilbert. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -48,7 +48,7 @@ * to the given SCSI device. */ -static char * version_str = "1.08 20080513"; +static char * version_str = "1.08 20090717"; #define ME "sg_rmsn: " @@ -110,7 +110,7 @@ int main(int argc, char * argv[]) fprintf(stderr, ME "version: %s\n", version_str); return 0; default: - fprintf(stderr, "unrecognised option code 0x%x ??\n", c); + fprintf(stderr, "unrecognised option code %#x ??\n", c); usage(); return SG_LIB_SYNTAX_ERROR; } diff --git a/src/sg_rtpg.c b/src/sg_rtpg.c index 802a9baa..466c887d 100644 --- a/src/sg_rtpg.c +++ b/src/sg_rtpg.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2008 Christophe Varoqui and Douglas Gilbert. + * Copyright (c) 2004-2009 Christophe Varoqui and Douglas Gilbert. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -48,7 +48,7 @@ * to the given SCSI device. */ -static char * version_str = "1.13 20080513"; +static char * version_str = "1.13 20090717"; #define REPORT_TGT_GRP_BUFF_LEN 1024 @@ -208,7 +208,7 @@ int main(int argc, char * argv[]) fprintf(stderr, "Version: %s\n", version_str); return 0; default: - fprintf(stderr, "unrecognised option code 0x%x ??\n", c); + fprintf(stderr, "unrecognised option code %#x ??\n", c); usage(); return SG_LIB_SYNTAX_ERROR; } @@ -284,10 +284,10 @@ int main(int argc, char * argv[]) for (k = 4, ucp = reportTgtGrpBuff + 4; k < report_len; k += off, ucp += off) { - printf(" target port group id : 0x%x , Pref=%d\n", + printf(" target port group id : %#x , Pref=%d\n", (ucp[2] << 8) + ucp[3], !!(ucp[0] & 0x80)); printf(" target port group asymmetric access state : "); - printf("0x%02x", ucp[0] & 0x0f); + printf("%#02x", ucp[0] & 0x0f); if (decode) decode_tpgs_state(ucp[0] & 0x0f); printf("\n"); @@ -300,13 +300,13 @@ int main(int argc, char * argv[]) printf("AO_SUP : %d\n", !!(ucp[1] & 0x01)); printf(" status code : "); - printf("0x%02x", ucp[5]); + printf("%#02x", ucp[5]); if (decode) decode_status(ucp[5]); printf("\n"); printf(" vendor unique status : "); - printf("0x%02x\n", ucp[6]); + printf("%#02x\n", ucp[6]); printf(" target port count : "); tgt_port_count = ucp[7]; @@ -315,7 +315,7 @@ int main(int argc, char * argv[]) for (j = 0; j < tgt_port_count * 4; j += 4) { if (0 == j) printf(" Relative target port ids:\n"); - printf(" 0x%02x\n", + printf(" %#02x\n", (ucp[8 + j + 2] << 8) + ucp[8 + j + 3]); } off = 8 + j; diff --git a/src/sg_safte.c b/src/sg_safte.c index 74241c2a..f6c933bb 100644 --- a/src/sg_safte.c +++ b/src/sg_safte.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2008 Hannes Reinecke and Douglas Gilbert. + * Copyright (c) 2004-2009 Hannes Reinecke and Douglas Gilbert. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -48,7 +48,7 @@ * to the 'SCSI Accessed Fault-Tolerant Enclosures' (SAF-TE) spec. */ -static char * version_str = "0.24 20080513"; +static char * version_str = "0.24 20090717"; #define SENSE_BUFF_LEN 32 /* Arbitrary, could be larger */ @@ -594,7 +594,7 @@ main(int argc, char * argv[]) fprintf(stderr, "Version string: %s\n", version_str); exit(0); default: - fprintf(stderr, "unrecognised option code 0x%x ??\n", c); + fprintf(stderr, "unrecognised option code %#x ??\n", c); usage(); return SG_LIB_SYNTAX_ERROR; } @@ -642,7 +642,7 @@ main(int argc, char * argv[]) if (strlen(cp) > 0) printf(" Peripheral device type: %s\n", cp); else - printf(" Peripheral device type: 0x%x\n", peri_type); + printf(" Peripheral device type: %#x\n", peri_type); } else { fprintf(stderr, "sg_safte: %s doesn't respond to a SCSI " "INQUIRY\n", device_name); diff --git a/src/sg_sat_identify.c b/src/sg_sat_identify.c index ba8bb8a6..7834db59 100644 --- a/src/sg_sat_identify.c +++ b/src/sg_sat_identify.c @@ -63,7 +63,7 @@ #define EBUFF_SZ 256 -static char * version_str = "1.06 20090303"; +static char * version_str = "1.06 20090917"; static struct option long_options[] = { {"ck_cond", no_argument, 0, 'c'}, @@ -235,11 +235,11 @@ static int do_identify_dev(int sg_fd, int do_packet, int cdb_len, } if (0x72 != (sense_buffer[0] & 0x7f)) { fprintf(stderr, "expected descriptor sense format, response " - "code=0x%x\n", sense_buffer[0]); + "code=%#x\n", sense_buffer[0]); return SG_LIB_CAT_MALFORMED; } } else if (res > 0) { - fprintf(stderr, "Unexpected SCSI status=0x%x\n", res); + fprintf(stderr, "Unexpected SCSI status=%#x\n", res); return SG_LIB_CAT_MALFORMED; } else { fprintf(stderr, "ATA pass through (%d) failed\n", cdb_len); @@ -337,7 +337,7 @@ int main(int argc, char * argv[]) fprintf(stderr, "version: %s\n", version_str); return 0; default: - fprintf(stderr, "unrecognised option code 0x%x ??\n", c); + fprintf(stderr, "unrecognised option code %#x ??\n", c); usage(); return SG_LIB_SYNTAX_ERROR; } diff --git a/src/sg_sat_phy_event.c b/src/sg_sat_phy_event.c index dd43a613..e7e5b88e 100644 --- a/src/sg_sat_phy_event.c +++ b/src/sg_sat_phy_event.c @@ -68,7 +68,7 @@ #define EBUFF_SZ 256 -static char * version_str = "1.03 20090303"; +static char * version_str = "1.03 20090717"; static struct option long_options[] = { {"ck_cond", no_argument, 0, 'c'}, @@ -294,11 +294,11 @@ do_read_log_ext(int sg_fd, int log_addr, int page_in_log, int feature, } if (0x72 != (sense_buffer[0] & 0x7f)) { fprintf(stderr, "expected descriptor sense format, response " - "code=0x%x\n", sense_buffer[0]); + "code=%#x\n", sense_buffer[0]); return SG_LIB_CAT_MALFORMED; } } else if (res > 0) { - fprintf(stderr, "Unexpected SCSI status=0x%x\n", res); + fprintf(stderr, "Unexpected SCSI status=%#x\n", res); return SG_LIB_CAT_MALFORMED; } else { fprintf(stderr, "ATA pass through (%d) failed\n", cdb_len); @@ -396,7 +396,7 @@ int main(int argc, char * argv[]) fprintf(stderr, "version: %s\n", version_str); exit(0); default: - fprintf(stderr, "unrecognised option code %c [0x%x]\n", c, c); + fprintf(stderr, "unrecognised option code %c [%#x]\n", c, c); usage(); return SG_LIB_SYNTAX_ERROR; } @@ -459,7 +459,7 @@ int main(int argc, char * argv[]) if (cp) printf(" %s: %" PRIu64 "\n", cp, ull); else - printf(" id=0x%x, vendor=%d, data_len=%d, " + printf(" id=%#x, vendor=%d, data_len=%d, " "val=%" PRIu64 "\n", id, vendor, len, ull); } } diff --git a/src/sg_sat_set_features.c b/src/sg_sat_set_features.c index d44c73d3..4ac4b172 100644 --- a/src/sg_sat_set_features.c +++ b/src/sg_sat_set_features.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2007 Douglas Gilbert. + * Copyright (c) 2006-2009 Douglas Gilbert. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -61,7 +61,7 @@ #define DEF_TIMEOUT 20 -static char * version_str = "1.04 20070918"; +static char * version_str = "1.04 20090717"; static struct option long_options[] = { {"count", required_argument, 0, 'c'}, @@ -236,11 +236,11 @@ static int do_set_features(int sg_fd, int feature, int count, int lba, } if (0x72 != (sense_buffer[0] & 0x7f)) { fprintf(stderr, "expected descriptor sense format, response " - "code=0x%x\n", sense_buffer[0]); + "code=%#x\n", sense_buffer[0]); return SG_LIB_CAT_MALFORMED; } } else if (res > 0) { - fprintf(stderr, "Unexpected SCSI status=0x%x\n", res); + fprintf(stderr, "Unexpected SCSI status=%#x\n", res); return SG_LIB_CAT_MALFORMED; } else { fprintf(stderr, "ATA pass through (%d) failed\n", cdb_len); @@ -325,7 +325,7 @@ int main(int argc, char * argv[]) fprintf(stderr, "version: %s\n", version_str); return 0; default: - fprintf(stderr, "unrecognised option code 0x%x ??\n", c); + fprintf(stderr, "unrecognised option code %#x ??\n", c); usage(); return SG_LIB_SYNTAX_ERROR; } diff --git a/src/sg_senddiag.c b/src/sg_senddiag.c index e024cfd5..9beb1f58 100644 --- a/src/sg_senddiag.c +++ b/src/sg_senddiag.c @@ -24,7 +24,7 @@ the SCSI RECEIVE DIAGNOSTIC command to list supported diagnostic pages. */ -static char * version_str = "0.36 20090617"; +static char * version_str = "0.36 20090717"; #define ME "sg_senddiag: " @@ -196,7 +196,7 @@ static int process_cl_new(struct opts_t * optsp, int argc, char * argv[]) ++optsp->do_version; break; default: - fprintf(stderr, "unrecognised option code %c [0x%x]\n", c, c); + fprintf(stderr, "unrecognised option code %c [%#x]\n", c, c); if (optsp->do_help) break; usage(); @@ -558,7 +558,7 @@ static void list_page_codes() printf("Page_Code Description\n"); for (k = 0; k < num; ++k, ++pcdp) - printf(" 0x%02x %s\n", pcdp->page_code, + printf(" %#02x %s\n", pcdp->page_code, (pcdp->desc ? pcdp->desc : "<unknown>")); } @@ -711,7 +711,7 @@ int main(int argc, char * argv[]) else { for (k = 0; k < (rsp_len - 4); ++k) { cp = find_page_code_desc(rsp_buff[k + 4]); - printf(" 0x%02x %s\n", rsp_buff[k + 4], + printf(" %#02x %s\n", rsp_buff[k + 4], (cp ? cp : "<unknown>")); } } diff --git a/src/sg_ses.c b/src/sg_ses.c index feeb91e3..4ae9ede6 100644 --- a/src/sg_ses.c +++ b/src/sg_ses.c @@ -46,7 +46,7 @@ * commands tailored for SES (enclosure) devices. */ -static char * version_str = "1.45 20090617"; /* ses2r19b */ +static char * version_str = "1.45 20090717"; /* ses2r19b */ #define MX_ALLOC_LEN 4096 #define MX_ELEM_HDR 1024 @@ -312,7 +312,7 @@ get_element_type_desc(int elem_type_code, int b_len, char * b) if (elem_desc) snprintf(b, b_len - 1, "%s", elem_desc); else - snprintf(b, b_len - 1, "unknown element type code=0x%x", elem_type_code); + snprintf(b, b_len - 1, "unknown element type code=%#x", elem_type_code); return b; } #endif @@ -355,7 +355,7 @@ ses_configuration_sdg(const unsigned char * resp, int resp_len) num_subs - 1); gen_code = (resp[4] << 24) | (resp[5] << 16) | (resp[6] << 8) | resp[7]; - printf(" generation code: 0x%x\n", gen_code); + printf(" generation code: %#x\n", gen_code); printf(" enclosure descriptor list\n"); ucp = resp + 8; for (k = 0; k < num_subs; ++k, ucp += el) { @@ -392,7 +392,7 @@ ses_configuration_sdg(const unsigned char * resp, int resp_len) printf(" Element type: %s, subenclosure id: %d\n", cp, ucp[2]); else - printf(" Element type: [0x%x], subenclosure id: %d\n", + printf(" Element type: [%#x], subenclosure id: %d\n", ucp[0], ucp[2]); printf(" number of possible elements: %d\n", ucp[1]); if (ucp[3] > 0) { @@ -435,10 +435,10 @@ populate_type_desc_hdr_arr(int fd, struct type_desc_hdr_t * tdhp, printf("Enclosure busy, try again later\n"); else if (0x8 == resp[0]) printf("Enclosure only supports Short Enclosure status: " - "0x%x\n", resp[1]); + "%#x\n", resp[1]); else - printf("Invalid response, wanted page code: 0x%x but got " - "0x%x\n", 1, resp[0]); + printf("Invalid response, wanted page code: %#x but got " + "%#x\n", 1, resp[0]); return -1; } if (resp_len < 4) @@ -530,22 +530,22 @@ find_sas_connector_type(int conn_type, char * buff, int buff_len) break; default: if (conn_type < 0x10) - snprintf(buff, buff_len, "unknown external connector type: 0x%x", + snprintf(buff, buff_len, "unknown external connector type: %#x", conn_type); else if (conn_type < 0x20) snprintf(buff, buff_len, "unknown internal wide connector type: " - "0x%x", conn_type); + "%#x", conn_type); else if (conn_type < 0x30) snprintf(buff, buff_len, "unknown internal connector to end " - "device, type: 0x%x", conn_type); + "device, type: %#x", conn_type); else if (conn_type < 0x70) - snprintf(buff, buff_len, "reserved connector type: 0x%x", + snprintf(buff, buff_len, "reserved connector type: %#x", conn_type); else if (conn_type < 0x80) - snprintf(buff, buff_len, "vendor specific connector type: 0x%x", + snprintf(buff, buff_len, "vendor specific connector type: %#x", conn_type); else /* conn_type is a 7 bit field, so this is impossible */ - snprintf(buff, buff_len, "unexpected connector type: 0x%x", + snprintf(buff, buff_len, "unexpected connector type: %#x", conn_type); break; } @@ -683,7 +683,7 @@ print_element_status(const char * pad, const unsigned char * statp, int etype, case NV_CACHE_ETC: /* Non volatile cache */ res = (statp[2] << 8) + statp[3]; printf("%sIdent=%d, Fail=%d, Size multiplier=%d, Non volatile cache " - "size=0x%x\n", pad, !!(statp[1] & 0x80), !!(statp[1] & 0x40), + "size=%#x\n", pad, !!(statp[1] & 0x80), !!(statp[1] & 0x40), (statp[1] & 0x3), res); printf("%sHence non volatile cache size: %d %s\n", pad, res, nv_cache_unit[statp[1] & 0x3]); @@ -732,7 +732,7 @@ print_element_status(const char * pad, const unsigned char * statp, int etype, case DISPLAY_ETC: /* Display (ses2r15) */ if ((! filter) || (0xc0 & statp[1])) printf("%sIdent=%d, Fail=%d, Display mode status=%d, Display " - "character status=0x%x\n", pad, !!(statp[1] & 0x80), + "character status=%#x\n", pad, !!(statp[1] & 0x80), !!(statp[1] & 0x40), (statp[1] & 0x3), ((statp[2] << 8) & statp[3])); break; @@ -818,7 +818,7 @@ print_element_status(const char * pad, const unsigned char * statp, int etype, !!(statp[2] & 0x1), !!(statp[3] & 0x1)); break; case SIMPLE_SUBENC_ETC: /* Simple subenclosure */ - printf("%sIdent=%d, Fail=%d, Short enclosure status: 0x%x\n", pad, + printf("%sIdent=%d, Fail=%d, Short enclosure status: %#x\n", pad, !!(statp[1] & 0x80), !!(statp[1] & 0x40), statp[3]); break; case ARRAY_DEV_ETC: /* Array device */ @@ -857,7 +857,7 @@ print_element_status(const char * pad, const unsigned char * statp, int etype, break; case SAS_CONNECTOR_ETC: printf("%sIdent=%d, %s, Connector physical " - "link=0x%x\n", pad, !!(statp[1] & 0x80), + "link=%#x\n", pad, !!(statp[1] & 0x80), find_sas_connector_type((statp[1] & 0x7f), buff, sizeof(buff)), statp[2]); printf("%sFail=%d\n", pad, !!(statp[3] & 0x40)); @@ -891,7 +891,7 @@ ses_enc_status_dp(const struct type_desc_hdr_t * tdhp, int num_telems, goto truncated; gen_code = (resp[4] << 24) | (resp[5] << 16) | (resp[6] << 8) | resp[7]; - printf(" generation code: 0x%x\n", gen_code); + printf(" generation code: %#x\n", gen_code); if (ref_gen_code != gen_code) { fprintf(stderr, " <<state of enclosure changed, please try " "again>>\n"); @@ -907,7 +907,7 @@ ses_enc_status_dp(const struct type_desc_hdr_t * tdhp, int num_telems, printf(" Element type: %s, subenclosure id: %d\n", cp, tdhp[k].se_id); else - printf(" Element type: [0x%x], subenclosure id: %d\n", + printf(" Element type: [%#x], subenclosure id: %d\n", tdhp[k].etype, tdhp[k].se_id); if (inner_hex) printf(" Overall status(hex): %02x %02x %02x %02x\n", ucp[0], @@ -1037,7 +1037,7 @@ ses_threshold_sdg(const struct type_desc_hdr_t * tdhp, int num_telems, goto truncated; gen_code = (resp[4] << 24) | (resp[5] << 16) | (resp[6] << 8) | resp[7]; - printf(" generation code: 0x%x\n", gen_code); + printf(" generation code: %#x\n", gen_code); if (ref_gen_code != gen_code) { fprintf(stderr, " <<state of enclosure changed, please try " "again>>\n"); @@ -1053,7 +1053,7 @@ ses_threshold_sdg(const struct type_desc_hdr_t * tdhp, int num_telems, printf(" Element type: %s, subenclosure id: %d\n", cp, tdhp[k].se_id); else - printf(" Element type: [0x%x], subenclosure id: %d\n", + printf(" Element type: [%#x], subenclosure id: %d\n", tdhp[k].etype, tdhp[k].se_id); ses_threshold_helper(" ", ucp, tdhp[k].etype, -1, inner_hex, verbose); @@ -1087,7 +1087,7 @@ ses_element_desc_sdg(const struct type_desc_hdr_t * tdhp, int num_telems, goto truncated; gen_code = (resp[4] << 24) | (resp[5] << 16) | (resp[6] << 8) | resp[7]; - printf(" generation code: 0x%x\n", gen_code); + printf(" generation code: %#x\n", gen_code); if (ref_gen_code != gen_code) { fprintf(stderr, " <<state of enclosure changed, please try " "again>>\n"); @@ -1103,7 +1103,7 @@ ses_element_desc_sdg(const struct type_desc_hdr_t * tdhp, int num_telems, printf(" Element type: %s, subenclosure id: %d\n", cp, tdhp[k].se_id); else - printf(" Element type: [0x%x], subenclosure id: %d\n", + printf(" Element type: [%#x], subenclosure id: %d\n", tdhp[k].etype, tdhp[k].se_id); desc_len = (ucp[2] << 8) + ucp[3] + 4; if (desc_len > 4) @@ -1160,7 +1160,7 @@ ses_additional_elem_each(const unsigned char * ucp, int len, int elem_num, per_ucp = ucp + 14 + eip_offset; for (j = 0; j < ports; ++j, per_ucp += 16) { printf(" port index: %d, port loop position: %d, port " - "bypass reason: 0x%x\n", j, per_ucp[0], per_ucp[1]); + "bypass reason: %#x\n", j, per_ucp[0], per_ucp[1]); printf(" requested hard address: %d, n_port " "identifier: %02x%02x%02x\n", per_ucp[4], per_ucp[5], per_ucp[6], per_ucp[7]); @@ -1204,7 +1204,7 @@ ses_additional_elem_each(const unsigned char * ucp, int len, int elem_num, printf("\n SAS address: 0x"); for (m = 0; m < 8; ++m) printf("%02x", per_ucp[12 + m]); - printf("\n phy identifier: 0x%x\n", per_ucp[20]); + printf("\n phy identifier: %#x\n", per_ucp[20]); } } else if (1 == desc_type) { phys = ucp[2 + eip_offset]; @@ -1232,7 +1232,7 @@ ses_additional_elem_each(const unsigned char * ucp, int len, int elem_num, per_ucp = ucp + 6 + eip_offset; for (j = 0; j < phys; ++j, per_ucp += 12) { printf(" phy index: %d\n", j); - printf(" phy identifier: 0x%x\n", per_ucp[0]); + printf(" phy identifier: %#x\n", per_ucp[0]); if (0xff == per_ucp[2]) printf(" no attached connector"); else @@ -1280,7 +1280,7 @@ ses_additional_elem_sdg(const struct type_desc_hdr_t * tdhp, int num_telems, last_ucp = resp + resp_len - 1; gen_code = (resp[4] << 24) | (resp[5] << 16) | (resp[6] << 8) | resp[7]; - printf(" generation code: 0x%x\n", gen_code); + printf(" generation code: %#x\n", gen_code); if (ref_gen_code != gen_code) { fprintf(stderr, " <<state of enclosure changed, please try " "again>>\n"); @@ -1304,12 +1304,12 @@ ses_additional_elem_sdg(const struct type_desc_hdr_t * tdhp, int num_telems, printf(" Element type: %s, subenclosure id: %d\n", cp, tdhp[k].se_id); else - printf(" Element type: [0x%x], subenclosure id: %d\n", + printf(" Element type: [%#x], subenclosure id: %d\n", tdhp[k].etype, tdhp[k].se_id); for (j = 0; j < tdhp[k].num_elements; ++j, ucp += desc_len) { invalid = !!(ucp[0] & 0x80); if (ucp[0] & 0x10) /* eip=1 */ - printf(" element index: %d [0x%x]\n", ucp[3], ucp[3]); + printf(" element index: %d [%#x]\n", ucp[3], ucp[3]); desc_len = ucp[1] + 2; if (inner_hex) dStrHex((const char *)ucp + 4, desc_len, 0); @@ -1342,7 +1342,7 @@ ses_subenc_help_sdg(const unsigned char * resp, int resp_len) num_subs - 1); gen_code = (resp[4] << 24) | (resp[5] << 16) | (resp[6] << 8) | resp[7]; - printf(" generation code: 0x%x\n", gen_code); + printf(" generation code: %#x\n", gen_code); ucp = resp + 8; for (k = 0; k < num_subs; ++k, ucp += el) { if ((ucp + 3) > last_ucp) @@ -1377,7 +1377,7 @@ ses_subenc_string_sdg(const unsigned char * resp, int resp_len) num_subs - 1); gen_code = (resp[4] << 24) | (resp[5] << 16) | (resp[6] << 8) | resp[7]; - printf(" generation code: 0x%x\n", gen_code); + printf(" generation code: %#x\n", gen_code); ucp = resp + 8; for (k = 0; k < num_subs; ++k, ucp += el) { if ((ucp + 3) > last_ucp) @@ -1412,15 +1412,15 @@ ses_subenc_nickname_sdg(const unsigned char * resp, int resp_len) num_subs - 1); gen_code = (resp[4] << 24) | (resp[5] << 16) | (resp[6] << 8) | resp[7]; - printf(" generation code: 0x%x\n", gen_code); + printf(" generation code: %#x\n", gen_code); ucp = resp + 8; el = 40; for (k = 0; k < num_subs; ++k, ucp += el) { if ((ucp + el - 1) > last_ucp) goto truncated; printf(" subenclosure identifier: %d\n", ucp[1]); - printf(" nickname status: 0x%x\n", ucp[2]); - printf(" nickname additional status: 0x%x\n", ucp[3]); + printf(" nickname status: %#x\n", ucp[2]); + printf(" nickname additional status: %#x\n", ucp[3]); printf(" nickname language code: %.2s\n", ucp + 6); printf(" nickname: %s\n", ucp + 8); } @@ -1443,7 +1443,7 @@ ses_supported_pages_sdg(const char * leadin, const unsigned char * resp, if (code < prev) break; /* assume to be padding at end */ cp = find_diag_page_desc(code); - printf(" %s [0x%x]\n", (cp ? cp : "<unknown>"), code); + printf(" %s [%#x]\n", (cp ? cp : "<unknown>"), code); } } @@ -1464,17 +1464,17 @@ ses_download_code_sdg(const unsigned char * resp, int resp_len) num_subs - 1); gen_code = (resp[4] << 24) | (resp[5] << 16) | (resp[6] << 8) | resp[7]; - printf(" generation code: 0x%x\n", gen_code); + printf(" generation code: %#x\n", gen_code); ucp = resp + 8; for (k = 0; k < num_subs; ++k, ucp += 16) { if ((ucp + 3) > last_ucp) goto truncated; printf(" subenclosure identifier: %d\n", ucp[1]); - printf(" download microcode status: 0x%x [additional status: " - "0x%x]\n", ucp[2], ucp[3]); + printf(" download microcode status: %#x [additional status: " + "%#x]\n", ucp[2], ucp[3]); printf(" download microcode maximum size: %d bytes\n", (ucp[4] << 24) + (ucp[5] << 16) + (ucp[6] << 8) + ucp[7]); - printf(" download microcode expected buffer id: 0x%x\n", ucp[11]); + printf(" download microcode expected buffer id: %#x\n", ucp[11]); printf(" download microcode expected buffer id offset: %d\n", (ucp[12] << 24) + (ucp[13] << 16) + (ucp[14] << 8) + ucp[15]); } @@ -1617,10 +1617,10 @@ ses_process_status(int sg_fd, int page_code, int do_raw, int do_hex, dStrHex((const char *)rsp_buff, rsp_len, 0); } else if (0x8 == rsp_buff[0]) { fprintf(stderr, "Enclosure only supports Short Enclosure " - "status: 0x%x\n", rsp_buff[1]); + "status: %#x\n", rsp_buff[1]); } else { - fprintf(stderr, "Invalid response, wanted page code: 0x%x " - "but got 0x%x\n", page_code, rsp_buff[0]); + fprintf(stderr, "Invalid response, wanted page code: %#x " + "but got %#x\n", page_code, rsp_buff[0]); dStrHex((const char *)rsp_buff, rsp_len, 0); } } else if (do_raw) { @@ -1636,7 +1636,7 @@ ses_process_status(int sg_fd, int page_code, int do_raw, int do_hex, printf("Response in hex from diagnostic page: %s\n", cp); else printf("Response in hex from unknown diagnostic page " - "[0x%x]\n", page_code); + "[%#x]\n", page_code); dStrHex((const char *)rsp_buff, rsp_len, 0); } else { switch (page_code) { @@ -1689,11 +1689,11 @@ ses_process_status(int sg_fd, int page_code, int do_raw, int do_hex, break; case DPC_SHORT_ENC_STATUS: printf("Short enclosure status diagnostic page, " - "status=0x%x\n", rsp_buff[1]); + "status=%#x\n", rsp_buff[1]); break; case DPC_ENC_BUSY: printf("Enclosure busy diagnostic page, " - "busy=%d [vendor specific=0x%x]\n", + "busy=%d [vendor specific=%#x]\n", rsp_buff[1] & 1, (rsp_buff[1] >> 1) & 0xff); break; case DPC_ADD_ELEM_STATUS: @@ -1732,7 +1732,7 @@ ses_process_status(int sg_fd, int page_code, int do_raw, int do_hex, cp); else fprintf(stderr, "Attempt to fetch status diagnostic page " - "[0x%x] failed\n", page_code); + "[%#x] failed\n", page_code); switch (res) { case SG_LIB_CAT_NOT_READY: fprintf(stderr, " device no ready\n"); @@ -1846,7 +1846,7 @@ main(int argc, char * argv[]) fprintf(stderr, "version: %s\n", version_str); return 0; default: - fprintf(stderr, "unrecognised option code 0x%x ??\n", c); + fprintf(stderr, "unrecognised option code %#x ??\n", c); usage(); return SG_LIB_SYNTAX_ERROR; } @@ -1873,12 +1873,12 @@ main(int argc, char * argv[]) printf("Known diagnostic pages (followed by page code):\n"); for (k = 0; k < num; ++k, ++pcdp) - printf(" %s [0x%x]\n", pcdp->desc, pcdp->page_code); + printf(" %s [%#x]\n", pcdp->desc, pcdp->page_code); printf("\nKnown SES element type names (followed by element type " "code):\n"); num = sizeof(element_type_arr) / sizeof(element_type_arr[0]); for (k = 0; k < num; ++k, ++etp) - printf(" %s [0x%x]\n", etp->desc, etp->elem_type_code); + printf(" %s [%#x]\n", etp->desc, etp->elem_type_code); return 0; } if (do_control && do_status) { @@ -1935,7 +1935,7 @@ main(int argc, char * argv[]) data_arr[3] = arr_len & 0xff; switch (page_code) { case 0x2: /* Enclosure control diagnostic page */ - printf("Sending Enclosure control [0x%x] page, with page " + printf("Sending Enclosure control [%#x] page, with page " "length=%d bytes\n", page_code, arr_len); ret = do_senddiag(sg_fd, 1, data_arr, arr_len + 4, 1, verbose); if (ret) { @@ -1944,7 +1944,7 @@ main(int argc, char * argv[]) } break; case 0x4: /* String Out diagnostic page */ - printf("Sending String Out [0x%x] page, with page length=%d " + printf("Sending String Out [%#x] page, with page length=%d " "bytes\n", page_code, arr_len); ret = do_senddiag(sg_fd, 1, data_arr, arr_len + 4, 1, verbose); if (ret) { @@ -1953,7 +1953,7 @@ main(int argc, char * argv[]) } break; case 0x5: /* Threshold Out diagnostic page */ - printf("Sending Threshold Out [0x%x] page, with page length=%d " + printf("Sending Threshold Out [%#x] page, with page length=%d " "bytes\n", page_code, arr_len); ret = do_senddiag(sg_fd, 1, data_arr, arr_len + 4, 1, verbose); if (ret) { @@ -1962,7 +1962,7 @@ main(int argc, char * argv[]) } break; case 0x6: /* Array control diagnostic page (obsolete) */ - printf("Sending Array control [0x%x] page, with page " + printf("Sending Array control [%#x] page, with page " "length=%d bytes\n", page_code, arr_len); ret = do_senddiag(sg_fd, 1, data_arr, arr_len + 4, 1, verbose); if (ret) { @@ -1971,7 +1971,7 @@ main(int argc, char * argv[]) } break; case 0xc: /* Subenclosure String Out diagnostic page */ - printf("Sending Subenclosure String Out [0x%x] page, with page " + printf("Sending Subenclosure String Out [%#x] page, with page " "length=%d bytes\n", page_code, arr_len); ret = do_senddiag(sg_fd, 1, data_arr, arr_len + 4, 1, verbose); if (ret) { @@ -1981,7 +1981,7 @@ main(int argc, char * argv[]) } break; default: - fprintf(stderr, "Setting SES control page 0x%x not supported " + fprintf(stderr, "Setting SES control page %#x not supported " "by this utility\n", page_code); fprintf(stderr, "That can be done with the sg_senddiag utility " "with its '--raw=' option\n"); diff --git a/src/sg_start.c b/src/sg_start.c index bec9e555..a6c8ab9f 100644 --- a/src/sg_start.c +++ b/src/sg_start.c @@ -12,7 +12,7 @@ #include "sg_cmds_basic.h" /* - * Copyright (C) 1999-2008 D. Gilbert + * Copyright (C) 1999-2009 D. Gilbert * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) @@ -30,7 +30,7 @@ */ -static char * version_str = "0.57 20080325"; /* sbc3r14; mmc6r01a */ +static char * version_str = "0.57 20090717"; /* sbc3r14; mmc6r01a */ static struct option long_options[] = { {"eject", 0, 0, 'e'}, @@ -238,7 +238,7 @@ process_cl_new(struct opts_t * optsp, int argc, char * argv[]) ++optsp->do_version; break; default: - fprintf(stderr, "unrecognised option code %c [0x%x]\n", c, c); + fprintf(stderr, "unrecognised option code %c [%#x]\n", c, c); if (optsp->do_help) break; usage(); diff --git a/src/sg_stpg.c b/src/sg_stpg.c index 72fc35ac..a12254d9 100644 --- a/src/sg_stpg.c +++ b/src/sg_stpg.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2007 Hannes Reinecke, Christophe Varoqui and Douglas Gilbert. + * Copyright (c) 2004-2009 Hannes Reinecke, Christophe Varoqui and Douglas Gilbert. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -46,7 +46,7 @@ * to the given SCSI device. */ -static char * version_str = "1.2 20070926"; +static char * version_str = "1.2 20090717"; #define TGT_GRP_BUFF_LEN 1024 #define MX_ALLOC_LEN (0xc000 + 0x80) @@ -209,7 +209,7 @@ decode_tpgs_state(const int st) printf(" (transitioning between states)"); break; default: - printf(" (unknown: 0x%x)", st); + printf(" (unknown: %#x)", st); break; } } @@ -225,12 +225,12 @@ transition_tpgs_states(struct tgtgrp *tgtState, int numgrp, int portgroup, break; } if (i == numgrp) { - printf("Portgroup 0x%02x does not exist\n", portgroup); + printf("Portgroup %#02x does not exist\n", portgroup); return 1; } if (!( (1 << newstate) & tgtState[i].valid )) { - printf("Portgroup 0x%02x: Invalid state 0x%x\n", + printf("Portgroup %#02x: Invalid state %#x\n", portgroup, newstate); return 1; } @@ -257,10 +257,10 @@ transition_tpgs_states(struct tgtgrp *tgtState, int numgrp, int portgroup, } printf("New target port groups:\n"); for (i = 0; i < numgrp; i++) { - printf(" target port group id : 0x%x\n", + printf(" target port group id : %#x\n", tgtState[i].id); printf(" target port group asymmetric access state : "); - printf("0x%02x\n", tgtState[i].current); + printf("%#02x\n", tgtState[i].current); } return 0; } @@ -478,7 +478,7 @@ main(int argc, char * argv[]) fprintf(stderr, "Version: %s\n", version_str); return 0; default: - fprintf(stderr, "unrecognised option code 0x%x ??\n", c); + fprintf(stderr, "unrecognised option code %#x ??\n", c); usage(); return SG_LIB_SYNTAX_ERROR; } @@ -586,7 +586,7 @@ main(int argc, char * argv[]) return SG_LIB_CAT_OTHER; } decode_target_port(rsp_buff + 4, report_len - 4, &relport, &portgroup); - printf("Device is at port Group 0x%02x, relative port 0x%02x\n", + printf("Device is at port Group %#02x, relative port %#02x\n", portgroup, relport); } @@ -625,10 +625,10 @@ main(int argc, char * argv[]) for (k = 4, ucp = reportTgtGrpBuff + 4, numgrp = 0; k < report_len; k += off, ucp += off, numgrp ++) { - printf(" target port group id : 0x%x , Pref=%d\n", + printf(" target port group id : %#x , Pref=%d\n", (ucp[2] << 8) + ucp[3], !!(ucp[0] & 0x80)); printf(" target port group asymmetric access state : "); - printf("0x%02x", ucp[0] & 0x0f); + printf("%#02x", ucp[0] & 0x0f); printf("\n"); tgtStatePtr->id = (ucp[2] << 8) + ucp[3]; tgtStatePtr->current = ucp[0] & 0x0f; @@ -656,7 +656,7 @@ main(int argc, char * argv[]) if (0 != res) goto err_out; - printf("Port group 0x%02x: Set asymmetric access state to", portgroup); + printf("Port group %#02x: Set asymmetric access state to", portgroup); decode_tpgs_state(state); printf("\n"); diff --git a/src/sg_sync.c b/src/sg_sync.c index b821b572..b3d5c681 100644 --- a/src/sg_sync.c +++ b/src/sg_sync.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2007 Douglas Gilbert. + * Copyright (c) 2004-2009 Douglas Gilbert. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -45,7 +45,7 @@ * (e.g. disks). */ -static char * version_str = "1.08 20070919"; +static char * version_str = "1.08 20090717"; #define ME "sg_sync: " @@ -150,7 +150,7 @@ int main(int argc, char * argv[]) fprintf(stderr, ME "version: %s\n", version_str); return 0; default: - fprintf(stderr, "unrecognised option code 0x%x ??\n", c); + fprintf(stderr, "unrecognised option code %#x ??\n", c); usage(); return SG_LIB_SYNTAX_ERROR; } diff --git a/src/sg_test_rwbuf.c b/src/sg_test_rwbuf.c index 031d579f..4d9bda9d 100644 --- a/src/sg_test_rwbuf.c +++ b/src/sg_test_rwbuf.c @@ -172,7 +172,7 @@ int do_checksum (int *buf, int len, int quiet) } else { if (verbose > 1) - printf("Checksum value: 0x%x\n", sum); + printf("Checksum value: %#x\n", sum); return 0; } } diff --git a/src/sg_turs.c b/src/sg_turs.c index 933fb66f..2c67d77b 100644 --- a/src/sg_turs.c +++ b/src/sg_turs.c @@ -29,7 +29,7 @@ */ -static char * version_str = "3.27 20090422"; +static char * version_str = "3.27 20090717"; #if defined(MSC_VER) || defined(__MINGW32__) #define HAVE_MS_SLEEP @@ -152,7 +152,7 @@ static int process_cl_new(struct opts_t * optsp, int argc, char * argv[]) ++optsp->do_version; break; default: - fprintf(stderr, "unrecognised option code %c [0x%x]\n", c, c); + fprintf(stderr, "unrecognised option code %c [%#x]\n", c, c); if (optsp->do_help) break; usage(); diff --git a/src/sg_unmap.c b/src/sg_unmap.c index 7d9b079c..651a181d 100644 --- a/src/sg_unmap.c +++ b/src/sg_unmap.c @@ -51,7 +51,7 @@ * logical blocks. */ -static char * version_str = "1.00 20090611"; +static char * version_str = "1.00 20090717"; #define ME "sg_unmap: " @@ -410,7 +410,7 @@ main(int argc, char * argv[]) fprintf(stderr, ME "version: %s\n", version_str); return 0; default: - fprintf(stderr, "unrecognised option code 0x%x ??\n", c); + fprintf(stderr, "unrecognised option code %#x ??\n", c); usage(); return SG_LIB_SYNTAX_ERROR; } diff --git a/src/sg_verify.c b/src/sg_verify.c index cde03a92..9d5cd7e7 100644 --- a/src/sg_verify.c +++ b/src/sg_verify.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2008 Douglas Gilbert. + * Copyright (c) 2004-2009 Douglas Gilbert. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -48,7 +48,7 @@ * This program issues the SCSI VERIFY command to the given SCSI block device. */ -static char * version_str = "1.12 20080327"; +static char * version_str = "1.12 20090717"; #define ME "sg_verify: " @@ -166,7 +166,7 @@ main(int argc, char * argv[]) fprintf(stderr, ME "version: %s\n", version_str); return 0; default: - fprintf(stderr, "unrecognised option code 0x%x ??\n", c); + fprintf(stderr, "unrecognised option code %#x ??\n", c); usage(); return SG_LIB_SYNTAX_ERROR; } @@ -231,11 +231,11 @@ main(int argc, char * argv[]) break; case SG_LIB_CAT_ILLEGAL_REQ: fprintf(stderr, "bad field in Verify(10) cdb, near " - "lba=0x%" PRIx64 "\n", lba); + "lba=%#" PRIx64 "\n", lba); break; case SG_LIB_CAT_MEDIUM_HARD: fprintf(stderr, "medium or hardware error near " - "lba=0x%" PRIx64 "\n", lba); + "lba=%#" PRIx64 "\n", lba); break; case SG_LIB_CAT_MEDIUM_HARD_WITH_INFO: fprintf(stderr, "medium or hardware error, reported " @@ -243,7 +243,7 @@ main(int argc, char * argv[]) break; default: fprintf(stderr, "Verify(10) failed near lba=%" PRIu64 - " [0x%" PRIx64 "]\n", lba, lba); + " [%#" PRIx64 "]\n", lba, lba); break; } break; @@ -251,8 +251,8 @@ main(int argc, char * argv[]) } if (verbose && (0 == ret) && (orig_count > 1)) - fprintf(stderr, "Verified %" PRId64 " [0x%" PRIx64 "] blocks from " - "lba %" PRIu64 " [0x%" PRIx64 "]\n without error\n", + fprintf(stderr, "Verified %" PRId64 " [%#" PRIx64 "] blocks from " + "lba %" PRIu64 " [%#" PRIx64 "]\n without error\n", orig_count, (uint64_t)orig_count, orig_lba, orig_lba); res = sg_cmds_close_device(sg_fd); diff --git a/src/sg_vpd.c b/src/sg_vpd.c index c707de2d..183035bc 100644 --- a/src/sg_vpd.c +++ b/src/sg_vpd.c @@ -52,7 +52,7 @@ */ -static char * version_str = "0.33 20090530"; /* spc4r20 + sbc3r19 */ +static char * version_str = "0.33 20090717"; /* spc4r20 + sbc3r19 */ extern void svpd_enumerate_vendor(void); extern int svpd_decode_vendor(int sg_fd, int num_vpd, int subvalue, @@ -257,7 +257,7 @@ enumerate_vpds(int standard, int vendor) if (standard) { for (vnp = standard_vpd_pg; vnp->acron; ++vnp) { if (vnp->name && (0 == vnp->vendor)) - printf(" %-10s 0x%02x %s\n", vnp->acron, vnp->value, + printf(" %-10s %#02x %s\n", vnp->acron, vnp->value, vnp->name); } } @@ -409,9 +409,9 @@ decode_mode_policy_vpd(unsigned char * buff, int len, int do_hex) if (do_hex > 1) dStrHex((const char *)ucp, 4, 1); else { - printf(" Policy page code: 0x%x", (ucp[0] & 0x3f)); + printf(" Policy page code: %#x", (ucp[0] & 0x3f)); if (ucp[1]) - printf(", subpage code: 0x%x\n", ucp[1]); + printf(", subpage code: %#x\n", ucp[1]); else printf("\n"); printf(" MLUS=%d, Policy: %s\n", !!(ucp[2] & 0x80), @@ -556,14 +556,14 @@ decode_dev_ids_quiet(unsigned char * buff, int len, int m_assoc, } naa = (ip[0] >> 4) & 0xff; if ((naa < 2) || (naa > 6) || (4 == naa)) { - fprintf(stderr, " << unexpected NAA [0x%x]>>\n", naa); + fprintf(stderr, " << unexpected NAA [%#x]>>\n", naa); dStrHex((const char *)ip, i_len, 0); break; } if (2 == naa) { /* NAA IEEE extended */ if (8 != i_len) { fprintf(stderr, " << unexpected NAA 2 identifier " - "length: 0x%x>>\n", i_len); + "length: %#x>>\n", i_len); dStrHex((const char *)ip, i_len, 0); break; } @@ -575,7 +575,7 @@ decode_dev_ids_quiet(unsigned char * buff, int len, int m_assoc, /* NAA=3 Locally assigned; NAA=5 IEEE Registered */ if (8 != i_len) { fprintf(stderr, " << unexpected NAA 3 or 5 " - "identifier length: 0x%x>>\n", i_len); + "identifier length: %#x>>\n", i_len); dStrHex((const char *)ip, i_len, 0); break; } @@ -588,7 +588,7 @@ decode_dev_ids_quiet(unsigned char * buff, int len, int m_assoc, printf("0x"); for (m = 0; m < 8; ++m) printf("%02x", (unsigned int)ip[m]); - printf(",0x%x\n", rtp); + printf(",%#x\n", rtp); rtp = 0; } else { if (sas_tport_addr[0]) { @@ -602,7 +602,7 @@ decode_dev_ids_quiet(unsigned char * buff, int len, int m_assoc, } else if (6 == naa) { /* NAA IEEE registered extended */ if (16 != i_len) { fprintf(stderr, " << unexpected NAA 6 identifier " - "length: 0x%x>>\n", i_len); + "length: %#x>>\n", i_len); dStrHex((const char *)ip, i_len, 0); break; } @@ -620,7 +620,7 @@ decode_dev_ids_quiet(unsigned char * buff, int len, int m_assoc, printf("0x"); for (m = 0; m < 8; ++m) printf("%02x", (unsigned int)sas_tport_addr[m]); - printf(",0x%x\n", rtp); + printf(",%#x\n", rtp); memset(sas_tport_addr, 0, sizeof(sas_tport_addr)); rtp = 0; } @@ -756,7 +756,7 @@ decode_dev_ids(const char * print_if_found, unsigned char * buff, int len, id_ext <<= 8; id_ext |= ip[m]; } - printf(" Identifier extension: 0x%" PRIx64 "\n", id_ext); + printf(" Identifier extension: %#" PRIx64 "\n", id_ext); } else if ((8 != i_len) && (12 != i_len)) { fprintf(stderr, " << can only decode 8, 12 and 16 " "byte ids>>\n"); @@ -765,19 +765,19 @@ decode_dev_ids(const char * print_if_found, unsigned char * buff, int len, } c_id = ((ip[ci_off] << 16) | (ip[ci_off + 1] << 8) | ip[ci_off + 2]); - printf(" IEEE Company_id: 0x%x\n", c_id); + printf(" IEEE Company_id: %#x\n", c_id); vsei = 0; for (m = 0; m < 5; ++m) { if (m > 0) vsei <<= 8; vsei |= ip[ci_off + 3 + m]; } - printf(" Vendor Specific Extension Identifier: 0x%" PRIx64 + printf(" Vendor Specific Extension Identifier: %#" PRIx64 "\n", vsei); if (12 == i_len) { d_id = ((ip[8] << 24) | (ip[9] << 16) | (ip[10] << 8) | ip[11]); - printf(" Directory ID: 0x%x\n", d_id); + printf(" Directory ID: %#x\n", d_id); } break; case 3: /* NAA */ @@ -789,14 +789,14 @@ decode_dev_ids(const char * print_if_found, unsigned char * buff, int len, } naa = (ip[0] >> 4) & 0xff; if (! ((2 == naa) || (5 == naa) || (6 == naa))) { - fprintf(stderr, " << unexpected NAA [0x%x]>>\n", naa); + fprintf(stderr, " << unexpected NAA [%#x]>>\n", naa); dStrHex((const char *)ip, i_len, 0); break; } if (2 == naa) { if (8 != i_len) { fprintf(stderr, " << unexpected NAA 2 identifier " - "length: 0x%x>>\n", i_len); + "length: %#x>>\n", i_len); dStrHex((const char *)ip, i_len, 0); break; } @@ -805,9 +805,9 @@ decode_dev_ids(const char * print_if_found, unsigned char * buff, int len, vsi = ((ip[5] << 16) | (ip[6] << 8) | ip[7]); if (long_out) { printf(" NAA 2, vendor specific identifier A: " - "0x%x\n", d_id); - printf(" IEEE Company_id: 0x%x\n", c_id); - printf(" vendor specific identifier B: 0x%x\n", vsi); + "%#x\n", d_id); + printf(" IEEE Company_id: %#x\n", c_id); + printf(" vendor specific identifier B: %#x\n", vsi); printf(" [0x"); for (m = 0; m < 8; ++m) printf("%02x", (unsigned int)ip[m]); @@ -820,7 +820,7 @@ decode_dev_ids(const char * print_if_found, unsigned char * buff, int len, } else if (5 == naa) { if (8 != i_len) { fprintf(stderr, " << unexpected NAA 5 identifier " - "length: 0x%x>>\n", i_len); + "length: %#x>>\n", i_len); dStrHex((const char *)ip, i_len, 0); break; } @@ -832,8 +832,8 @@ decode_dev_ids(const char * print_if_found, unsigned char * buff, int len, vsei |= ip[3 + m]; } if (long_out) { - printf(" NAA 5, IEEE Company_id: 0x%x\n", c_id); - printf(" Vendor Specific Identifier: 0x%" PRIx64 + printf(" NAA 5, IEEE Company_id: %#x\n", c_id); + printf(" Vendor Specific Identifier: %#" PRIx64 "\n", vsei); printf(" [0x"); for (m = 0; m < 8; ++m) @@ -848,7 +848,7 @@ decode_dev_ids(const char * print_if_found, unsigned char * buff, int len, } else if (6 == naa) { if (16 != i_len) { fprintf(stderr, " << unexpected NAA 6 identifier " - "length: 0x%x>>\n", i_len); + "length: %#x>>\n", i_len); dStrHex((const char *)ip, i_len, 0); break; } @@ -860,8 +860,8 @@ decode_dev_ids(const char * print_if_found, unsigned char * buff, int len, vsei |= ip[3 + m]; } if (long_out) { - printf(" NAA 6, IEEE Company_id: 0x%x\n", c_id); - printf(" Vendor Specific Identifier: 0x%" PRIx64 + printf(" NAA 6, IEEE Company_id: %#x\n", c_id); + printf(" Vendor Specific Identifier: %#" PRIx64 "\n", vsei); vsei = 0; for (m = 0; m < 8; ++m) { @@ -870,7 +870,7 @@ decode_dev_ids(const char * print_if_found, unsigned char * buff, int len, vsei |= ip[8 + m]; } printf(" Vendor Specific Identifier Extension: " - "0x%" PRIx64 "\n", vsei); + "%#" PRIx64 "\n", vsei); printf(" [0x"); for (m = 0; m < 16; ++m) printf("%02x", (unsigned int)ip[m]); @@ -891,7 +891,7 @@ decode_dev_ids(const char * print_if_found, unsigned char * buff, int len, break; } d_id = ((ip[2] << 8) | ip[3]); - printf(" Relative target port: 0x%x\n", d_id); + printf(" Relative target port: %#x\n", d_id); break; case 5: /* (primary) Target port group */ if ((1 != c_set) || (1 != assoc) || (4 != i_len)) { @@ -901,7 +901,7 @@ decode_dev_ids(const char * print_if_found, unsigned char * buff, int len, break; } d_id = ((ip[2] << 8) | ip[3]); - printf(" Target port group: 0x%x\n", d_id); + printf(" Target port group: %#x\n", d_id); break; case 6: /* Logical unit group */ if ((1 != c_set) || (0 != assoc) || (4 != i_len)) { @@ -911,7 +911,7 @@ decode_dev_ids(const char * print_if_found, unsigned char * buff, int len, break; } d_id = ((ip[2] << 8) | ip[3]); - printf(" Logical unit group: 0x%x\n", d_id); + printf(" Logical unit group: %#x\n", d_id); break; case 7: /* MD5 logical unit identifier */ if ((1 != c_set) || (0 != assoc)) { @@ -976,13 +976,13 @@ decode_transport_id(const char * leadin, unsigned char * ucp, int len) bump = 24; break; case TPROTO_SPI: /* Scsi Parallel Interface */ - printf("%s Parallel SCSI initiator SCSI address: 0x%x\n", + printf("%s Parallel SCSI initiator SCSI address: %#x\n", leadin, ((ucp[2] << 8) | ucp[3])); if (0 != format_code) printf("%s [Unexpected format code: %d]\n", leadin, format_code); printf("%s relative port number (of corresponding target): " - "0x%x\n", leadin, ((ucp[6] << 8) | ucp[7])); + "%#x\n", leadin, ((ucp[6] << 8) | ucp[7])); bump = 24; break; case TPROTO_SSA: @@ -1027,7 +1027,7 @@ decode_transport_id(const char * leadin, unsigned char * ucp, int len) ull <<= 8; ull |= ucp[4 + j]; } - printf("%s SAS address: 0x%" PRIx64 "\n", leadin, ull); + printf("%s SAS address: %#" PRIx64 "\n", leadin, ull); if (0 != format_code) printf("%s [Unexpected format code: %d]\n", leadin, format_code); @@ -1047,7 +1047,7 @@ decode_transport_id(const char * leadin, unsigned char * ucp, int len) break; case TPROTO_NONE: default: - fprintf(stderr, "%s unknown protocol id=0x%x " + fprintf(stderr, "%s unknown protocol id=%#x " "format_code=%d\n", leadin, proto_id, format_code); dStrHex((const char *)ucp, ((len > 24) ? 24 : len), 0); bump = 24; @@ -1154,7 +1154,7 @@ decode_ata_info_vpd(unsigned char * buff, int len, int do_long, int do_hex) if (do_long) printf(" ATA command IDENTIFY %sDEVICE response in hex:\n", cp); } else if (do_long) - printf(" ATA command 0x%x got following response:\n", + printf(" ATA command %#x got following response:\n", (unsigned int)buff[56]); if (len < 572) return; @@ -1343,7 +1343,7 @@ decode_b0_vpd(unsigned char * buff, int len, int do_hex, int pdt) break; case 0x11: default: - printf(" Unable to decode pdt=0x%x, in hex:\n", pdt); + printf(" Unable to decode pdt=%#x, in hex:\n", pdt); dStrHex((const char *)buff, len, 0); break; } @@ -1371,7 +1371,7 @@ decode_b1_vpd(unsigned char * buff, int len, int do_hex, int pdt) else if (1 == u) printf(" Non-rotating medium (e.g. solid state)\n"); else if ((u < 0x401) || (0xffff == u)) - printf(" Reserved [0x%x]\n", u); + printf(" Reserved [%#x]\n", u); else printf(" Nominal rotation rate: %d rpm\n", u); u = buff[7] & 0xf; @@ -1406,7 +1406,7 @@ decode_b1_vpd(unsigned char * buff, int len, int do_hex, int pdt) len - 4, buff + 4); break; default: - printf(" Unable to decode pdt=0x%x, in hex:\n", pdt); + printf(" Unable to decode pdt=%#x, in hex:\n", pdt); dStrHex((const char *)buff, len, 0); break; } @@ -1426,10 +1426,10 @@ svpd_unable_to_decode(int sg_fd, int num_vpd, int subvalue, int maxlen, printf("Only hex output supported\n"); if (!do_raw) { if (subvalue) - printf("VPD page code=0x%.2x, subvalue=0x%.2x:\n", num_vpd, + printf("VPD page code=%#.2x, subvalue=%#.2x:\n", num_vpd, subvalue); else - printf("VPD page code=0x%.2x:\n", num_vpd); + printf("VPD page code=%#.2x:\n", num_vpd); } if (0 == alloc_len) alloc_len = DEF_ALLOC_LEN; @@ -1451,7 +1451,7 @@ svpd_unable_to_decode(int sg_fd, int num_vpd, int subvalue, int maxlen, res = sg_ll_inquiry(sg_fd, 0, 1, num_vpd, rsp_buff, len, 1, verbose); if (res) { - fprintf(stderr, "fetching VPD page (2) code=0x%.2x " + fprintf(stderr, "fetching VPD page (2) code=%#.2x " " (alloc_len=%d) failed\n", num_vpd, len); return res; } @@ -1468,7 +1468,7 @@ svpd_unable_to_decode(int sg_fd, int num_vpd, int subvalue, int maxlen, return 0; } else { fprintf(stderr, - "fetching VPD page code=0x%.2x: failed\n", num_vpd); + "fetching VPD page code=%#.2x: failed\n", num_vpd); return res; } } @@ -1538,7 +1538,7 @@ svpd_decode_standard(int sg_fd, int num_vpd, int subvalue, int maxlen, if (vnp) printf(" %s [%s]\n", vnp->name, vnp->acron); else - printf(" 0x%x\n", rsp_buff[4 + k]); + printf(" %#x\n", rsp_buff[4 + k]); } } return 0; @@ -2055,7 +2055,7 @@ svpd_decode_standard(int sg_fd, int num_vpd, int subvalue, int maxlen, printf("OSD information VPD page (OSD):\n"); break; default: - printf("VPD page=0x%x, pdt=0x%x:\n", 0xb0, pdt); + printf("VPD page=%#x, pdt=%#x:\n", 0xb0, pdt); break; } } @@ -2120,7 +2120,7 @@ svpd_decode_standard(int sg_fd, int num_vpd, int subvalue, int maxlen, "(ADC):\n"); break; default: - printf("VPD page=0x%x, pdt=0x%x:\n", 0xb1, pdt); + printf("VPD page=%#x, pdt=%#x:\n", 0xb1, pdt); break; } } @@ -2245,7 +2245,7 @@ main(int argc, char * argv[]) fprintf(stderr, "version: %s\n", version_str); return 0; default: - fprintf(stderr, "unrecognised option code 0x%x ??\n", c); + fprintf(stderr, "unrecognised option code %#x ??\n", c); usage(); return SG_LIB_SYNTAX_ERROR; } diff --git a/src/sg_vpd_vendor.c b/src/sg_vpd_vendor.c index 7b58cf90..1d7bd206 100644 --- a/src/sg_vpd_vendor.c +++ b/src/sg_vpd_vendor.c @@ -156,7 +156,7 @@ svpd_enumerate_vendor() printf("\nVendor specific VPD pages:\n"); seen = 1; } - printf(" %-10s 0x%02x,%d %s\n", vnp->acron, + printf(" %-10s %#02x,%d %s\n", vnp->acron, vnp->value, vnp->subvalue, vnp->name); } } @@ -577,7 +577,7 @@ svpd_decode_vendor(int sg_fd, int num_vpd, int subvalue, int maxlen, if (vnp && vnp->name) strcpy(name, vnp->name); else - snprintf(name, sizeof(name) - 1, "Vendor VPD page=0x%x", num_vpd); + snprintf(name, sizeof(name) - 1, "Vendor VPD page=%#x", num_vpd); if (0 == alloc_len) alloc_len = DEF_ALLOC_LEN; switch(num_vpd) { diff --git a/src/sg_wr_mode.c b/src/sg_wr_mode.c index 55dd64af..48cd8f6c 100644 --- a/src/sg_wr_mode.c +++ b/src/sg_wr_mode.c @@ -46,7 +46,7 @@ * mode page on the given device. */ -static char * version_str = "1.10 20090401"; +static char * version_str = "1.10 20090717"; #define ME "sg_wr_mode: " @@ -396,7 +396,7 @@ int main(int argc, char * argv[]) fprintf(stderr, ME "version: %s\n", version_str); return 0; default: - fprintf(stderr, "unrecognised option code 0x%x ??\n", c); + fprintf(stderr, "unrecognised option code %#x ??\n", c); usage(); return SG_LIB_SYNTAX_ERROR; } @@ -529,8 +529,8 @@ int main(int argc, char * argv[]) goto err_out; } if (pg_code != (read_in[0] & 0x3f)) { - fprintf(stderr, "contents page_code=0x%x but reference " - "page_code=0x%x\n", (read_in[0] & 0x3f), pg_code); + fprintf(stderr, "contents page_code=%#x but reference " + "page_code=%#x\n", (read_in[0] & 0x3f), pg_code); goto err_out; } if ((read_in[0] & 0x40) != (ref_md[off] & 0x40)) { @@ -539,8 +539,8 @@ int main(int argc, char * argv[]) goto err_out; } if ((read_in[0] & 0x40) && (read_in[1] != sub_pg_code)) { - fprintf(stderr, "contents subpage_code=0x%x but reference " - "sub_page_code=0x%x\n", read_in[1], sub_pg_code); + fprintf(stderr, "contents subpage_code=%#x but reference " + "sub_page_code=%#x\n", read_in[1], sub_pg_code); goto err_out; } } else diff --git a/src/sg_write_buffer.c b/src/sg_write_buffer.c index b63a600c..730977ea 100644 --- a/src/sg_write_buffer.c +++ b/src/sg_write_buffer.c @@ -46,7 +46,7 @@ * This utility issues the SCSI WRITE BUFFER command to the given device. */ -static char * version_str = "1.06 20090420"; /* spc4r08 */ +static char * version_str = "1.06 20090917"; /* spc4r08 */ #define ME "sg_write_buffer: " #define DEF_XFER_LEN (8 * 1024 * 1024) @@ -150,7 +150,7 @@ static void print_modes(void) fprintf(stderr, "The modes parameter argument can be numeric " "(hex or decimal)\nor symbolic:\n"); for (k = 0; k < NUM_MODES; k++) { - fprintf(stderr, " %2d (0x%02x) %-16s%s\n", modes[k].mode, + fprintf(stderr, " %2d (%#02x) %-16s%s\n", modes[k].mode, modes[k].mode, modes[k].mode_string, modes[k].comment); } } @@ -251,7 +251,7 @@ int main(int argc, char * argv[]) fprintf(stderr, ME "version: %s\n", version_str); return 0; default: - fprintf(stderr, "unrecognised option code 0x%x ??\n", c); + fprintf(stderr, "unrecognised option code %#x ??\n", c); usage(); return SG_LIB_SYNTAX_ERROR; } diff --git a/src/sg_write_long.c b/src/sg_write_long.c index 501e1d54..6a96809d 100644 --- a/src/sg_write_long.c +++ b/src/sg_write_long.c @@ -31,7 +31,7 @@ This code was contributed by Saeed Bishara */ -static char * version_str = "1.17 20090420"; +static char * version_str = "1.17 20090717"; #define MAX_XFER_LEN 10000 @@ -161,7 +161,7 @@ main(int argc, char * argv[]) } break; default: - fprintf(stderr, "unrecognised option code 0x%x ??\n", c); + fprintf(stderr, "unrecognised option code %#x ??\n", c); usage(); return SG_LIB_SYNTAX_ERROR; } @@ -247,7 +247,7 @@ main(int argc, char * argv[]) } if (verbose) fprintf(stderr, ME "issue write long to device %s\n\t\txfer_len= %d " - "(0x%x), lba=%" PRIu64 " (0x%" PRIx64 ")\n cor_dis=%d, " + "(%#x), lba=%" PRIu64 " (%#" PRIx64 ")\n cor_dis=%d, " "wr_uncor=%d, pblock=%d\n", device_name, xfer_len, xfer_len, llba, llba, cor_dis, wr_uncor, pblock); diff --git a/src/sg_write_same.c b/src/sg_write_same.c index 2d1912af..71be77c8 100644 --- a/src/sg_write_same.c +++ b/src/sg_write_same.c @@ -48,7 +48,7 @@ #include "sg_cmds_basic.h" #include "sg_cmds_extra.h" -static char * version_str = "0.93 20090610"; +static char * version_str = "0.93 20090717"; #define ME "sg_write_same: " @@ -285,7 +285,7 @@ do_write_same(int sg_fd, const struct opts_t * optsp, const void * dataoutp, valid = sg_get_sense_info_fld(sense_b, slen, &ull); if (valid) fprintf(stderr, "Medium or hardware error starting at " - "lba=%"PRIu64" [0x%"PRIx64"]\n", ull, ull); + "lba=%"PRIu64" [%#"PRIx64"]\n", ull, ull); } ret = sense_cat; break; @@ -408,7 +408,7 @@ main(int argc, char * argv[]) } break; default: - fprintf(stderr, "unrecognised option code 0x%x ??\n", c); + fprintf(stderr, "unrecognised option code %#x ??\n", c); usage(); return SG_LIB_SYNTAX_ERROR; } diff --git a/src/sginfo.c b/src/sginfo.c index d7750d82..d31dd0ad 100644 --- a/src/sginfo.c +++ b/src/sginfo.c @@ -122,7 +122,7 @@ #define _GNU_SOURCE #endif -static const char * version_str = "2.29 [20090329]"; +static const char * version_str = "2.29 [20090717]"; #include <stdio.h> #include <string.h> @@ -433,7 +433,7 @@ static int do_scsi_io(struct scsi_cmnd_io * sio) if (trace_cmd) { char ebuff[EBUFF_SZ]; - snprintf(ebuff, EBUFF_SZ, "do_scsi_io: opcode=0x%x", sio->cmnd[0]); + snprintf(ebuff, EBUFF_SZ, "do_scsi_io: opcode=%#x", sio->cmnd[0]); sg_chk_n_print3(ebuff, &io_hdr, 1); } if (sg_normalize_sense(&io_hdr, &ssh)) { @@ -555,11 +555,11 @@ static char * get_page_name(struct mpage_info * mpi) if ((NULL == mpf) || (NULL == mpf->name)) { if (mpi->subpage) snprintf(unkn_page_str, sizeof(unkn_page_str), - "page number=0x%x, subpage number=0x%x", + "page number=%#x, subpage number=%#x", mpi->page, mpi->subpage); else snprintf(unkn_page_str, sizeof(unkn_page_str), - "page number=0x%x", mpi->page); + "page number=%#x", mpi->page); return unkn_page_str; } return mpf->name; @@ -694,7 +694,7 @@ static void hexfield(unsigned char * pageaddr, int nbytes, char * text) } else if (x_interface) printf("%d ", getnbyte(pageaddr, nbytes)); else - printf("%-35s0x%x\n", text, getnbyte(pageaddr, nbytes)); + printf("%-35s%#x\n", text, getnbyte(pageaddr, nbytes)); } static void hexdatafield(unsigned char * pageaddr, int nbytes, char * text) @@ -806,11 +806,11 @@ static int get_mode_page6(struct mpage_info * mpi, int dbd, status = do_scsi_io(&sci); if (status) { if (mpi->subpage) - fprintf(stdout, ">>> Unable to read %s mode page 0x%x, subpage " - "0x%x [mode_sense_6]\n", get_page_name(mpi), mpi->page, + fprintf(stdout, ">>> Unable to read %s mode page %#x, subpage " + "%#x [mode_sense_6]\n", get_page_name(mpi), mpi->page, mpi->subpage); else - fprintf(stdout, ">>> Unable to read %s mode page (0x%x) " + fprintf(stdout, ">>> Unable to read %s mode page (%#x) " "[mode_sense_6]\n", get_page_name(mpi), mpi->page); return status; } @@ -835,11 +835,11 @@ static int get_mode_page6(struct mpage_info * mpi, int dbd, status = do_scsi_io(&sci); if (status) { if (mpi->subpage) - fprintf(stdout, ">>> Unable to read %s mode page 0x%x, subpage " - "0x%x [mode_sense_6]\n", get_page_name(mpi), mpi->page, + fprintf(stdout, ">>> Unable to read %s mode page %#x, subpage " + "%#x [mode_sense_6]\n", get_page_name(mpi), mpi->page, mpi->subpage); else - fprintf(stdout, ">>> Unable to read %s mode page (0x%x) " + fprintf(stdout, ">>> Unable to read %s mode page (%#x) " "[mode_sense_6]\n", get_page_name(mpi), mpi->page); } else if (trace_cmd > 1) { off = modePageOffset(resp, mpi->resp_len, 1); @@ -880,11 +880,11 @@ static int get_mode_page10(struct mpage_info * mpi, int llbaa, int dbd, status = do_scsi_io(&sci); if (status) { if (mpi->subpage) - fprintf(stdout, ">>> Unable to read %s mode page 0x%x, subpage " - "0x%x [mode_sense_10]\n", get_page_name(mpi), mpi->page, + fprintf(stdout, ">>> Unable to read %s mode page %#x, subpage " + "%#x [mode_sense_10]\n", get_page_name(mpi), mpi->page, mpi->subpage); else - fprintf(stdout, ">>> Unable to read %s mode page (0x%x) " + fprintf(stdout, ">>> Unable to read %s mode page (%#x) " "[mode_sense_10]\n", get_page_name(mpi), mpi->page); return status; } @@ -910,11 +910,11 @@ static int get_mode_page10(struct mpage_info * mpi, int llbaa, int dbd, status = do_scsi_io(&sci); if (status) { if (mpi->subpage) - fprintf(stdout, ">>> Unable to read %s mode page 0x%x, subpage " - "0x%x [mode_sense_10]\n", get_page_name(mpi), mpi->page, + fprintf(stdout, ">>> Unable to read %s mode page %#x, subpage " + "%#x [mode_sense_10]\n", get_page_name(mpi), mpi->page, mpi->subpage); else - fprintf(stdout, ">>> Unable to read %s mode page (0x%x) " + fprintf(stdout, ">>> Unable to read %s mode page (%#x) " "[mode_sense_10]\n", get_page_name(mpi), mpi->page); } else if (trace_cmd > 1) { off = modePageOffset(resp, mpi->resp_len, 0); @@ -994,11 +994,11 @@ static int put_mode_page6(struct mpage_info * mpi, status = do_scsi_io(&sci); if (status) { if (mpi->subpage) - fprintf(stdout, ">>> Unable to store %s mode page 0x%x," - " subpage 0x%x [msel_6]\n", get_page_name(mpi), + fprintf(stdout, ">>> Unable to store %s mode page %#x," + " subpage %#x [msel_6]\n", get_page_name(mpi), mpi->page, mpi->subpage); else - fprintf(stdout, ">>> Unable to store %s mode page 0x%x [msel_6]\n", + fprintf(stdout, ">>> Unable to store %s mode page %#x [msel_6]\n", get_page_name(mpi), mpi->page); } return status; @@ -1052,11 +1052,11 @@ static int put_mode_page10(struct mpage_info * mpi, status = do_scsi_io(&sci); if (status) { if (mpi->subpage) - fprintf(stdout, ">>> Unable to store %s mode page 0x%x," - " subpage 0x%x [msel_10]\n", get_page_name(mpi), + fprintf(stdout, ">>> Unable to store %s mode page %#x," + " subpage %#x [msel_10]\n", get_page_name(mpi), mpi->page, mpi->subpage); else - fprintf(stdout, ">>> Unable to store %s mode page 0x%x " + fprintf(stdout, ">>> Unable to store %s mode page %#x " "[msel_10]\n", get_page_name(mpi), mpi->page); } return status; @@ -1084,7 +1084,7 @@ int setup_mode_page(struct mpage_info * mpi, int nparam, } offset = modePageOffset(buff, mpi->resp_len, mode6byte); if (offset < 0) { - fprintf(stdout, "mode page=0x%x has bad page format\n", mpi->page); + fprintf(stdout, "mode page=%#x has bad page format\n", mpi->page); fprintf(stdout, " perhaps '-z' switch may help\n"); return -1; } @@ -1145,7 +1145,7 @@ static int disk_geometry(struct mpage_info * mpi, const char * prefix) if (prefix[0]) printf("%s", prefix); if (!x_interface && !replace) { - printf("%s mode page (0x%x)\n", get_page_name(mpi), mpi->page); + printf("%s mode page (%#x)\n", get_page_name(mpi), mpi->page); printf("-----------------------------------\n"); }; intfield(pagestart + 2, 3, "Number of cylinders"); @@ -1177,7 +1177,7 @@ static int common_disconnect_reconnect(struct mpage_info * mpi, if (prefix[0]) printf("%s", prefix); if (!x_interface && !replace) { - printf("%s mode page (0x%x)\n", get_page_name(mpi), mpi->page); + printf("%s mode page (%#x)\n", get_page_name(mpi), mpi->page); printf("------------------------------------\n"); }; intfield(pagestart + 2, 1, "Buffer full ratio"); @@ -1211,7 +1211,7 @@ static int common_control(struct mpage_info * mpi, const char * prefix) if (prefix[0]) printf("%s", prefix); if (!x_interface && !replace) { - printf("%s mode page (0x%x)\n", get_page_name(mpi), mpi->page); + printf("%s mode page (%#x)\n", get_page_name(mpi), mpi->page); printf("-----------------------\n"); } bitfield(pagestart + 2, "TST", 0x7, 5); @@ -1254,7 +1254,7 @@ static int common_control_extension(struct mpage_info * mpi, const char * prefix if (prefix[0]) printf("%s", prefix); if (!x_interface && !replace) { - printf("%s mode subpage (0x%x,0x%x)\n", get_page_name(mpi), mpi->page, + printf("%s mode subpage (%#x,%#x)\n", get_page_name(mpi), mpi->page, mpi->subpage); printf("--------------------------------------------\n"); } @@ -1282,7 +1282,7 @@ static int common_informational(struct mpage_info * mpi, const char * prefix) if (prefix[0]) printf("%s", prefix); if (!x_interface && !replace) { - printf("%s mode page (0x%x)\n", get_page_name(mpi), mpi->page); + printf("%s mode page (%#x)\n", get_page_name(mpi), mpi->page); printf("-----------------------------------------\n"); } bitfield(pagestart + 2, "PERF", 1, 7); @@ -1314,7 +1314,7 @@ static int disk_error_recovery(struct mpage_info * mpi, const char * prefix) if (prefix[0]) printf("%s", prefix); if (!x_interface && !replace) { - printf("%s mode page (0x%x)\n", get_page_name(mpi), mpi->page); + printf("%s mode page (%#x)\n", get_page_name(mpi), mpi->page); printf("-----------------------------------------\n"); } bitfield(pagestart + 2, "AWRE", 1, 7); @@ -1350,7 +1350,7 @@ static int cdvd_error_recovery(struct mpage_info * mpi, const char * prefix) if (prefix[0]) printf("%s", prefix); if (!x_interface && !replace) { - printf("%s mode page (0x%x)\n", get_page_name(mpi), mpi->page); + printf("%s mode page (%#x)\n", get_page_name(mpi), mpi->page); printf("------------------------------------------------\n"); } bitfield(pagestart + 2, "AWRE", 1, 7); @@ -1382,7 +1382,7 @@ static int cdvd_mrw(struct mpage_info * mpi, const char * prefix) if (prefix[0]) printf("%s", prefix); if (!x_interface && !replace) { - printf("%s mode page (0x%x)\n", get_page_name(mpi), mpi->page); + printf("%s mode page (%#x)\n", get_page_name(mpi), mpi->page); printf("------------------------------------------------\n"); } bitfield(pagestart + 3, "LBA space", 1, 0); @@ -1408,7 +1408,7 @@ static int disk_notch_parameters(struct mpage_info * mpi, const char * prefix) if (prefix[0]) printf("%s", prefix); if (!x_interface && !replace) { - printf("%s mode page (0x%x)\n", get_page_name(mpi), mpi->page); + printf("%s mode page (%#x)\n", get_page_name(mpi), mpi->page); printf("-----------------------------------\n"); }; bitfield(pagestart + 2, "Notched Drive", 1, 7); @@ -1430,7 +1430,7 @@ static int disk_notch_parameters(struct mpage_info * mpi, const char * prefix) if (1 == mpi->page_control) /* modifiable */ printf("0"); else - printf("0x%8.8x%8.8x", getnbyte(pagestart + 16, 4), + printf("%#8.8x%8.8x", getnbyte(pagestart + 16, 4), getnbyte(pagestart + 20, 4)); #endif }; @@ -1799,7 +1799,7 @@ static int disk_cache(struct mpage_info * mpi, const char * prefix) if (prefix[0]) printf("%s", prefix); if (!x_interface && !replace) { - printf("%s mode page (0x%x)\n", get_page_name(mpi), mpi->page); + printf("%s mode page (%#x)\n", get_page_name(mpi), mpi->page); printf("-----------------------\n"); }; bitfield(pagestart + 2, "Initiator Control", 1, 7); @@ -1842,7 +1842,7 @@ static int disk_format(struct mpage_info * mpi, const char * prefix) if (prefix[0]) printf("%s", prefix); if (!x_interface && !replace) { - printf("%s mode page (0x%x)\n", get_page_name(mpi), mpi->page); + printf("%s mode page (%#x)\n", get_page_name(mpi), mpi->page); printf("-----------------------------\n"); }; intfield(pagestart + 2, 2, "Tracks per Zone"); @@ -1879,7 +1879,7 @@ static int disk_verify_error_recovery(struct mpage_info * mpi, if (prefix[0]) printf("%s", prefix); if (!x_interface && !replace) { - printf("%s mode page (0x%x)\n", get_page_name(mpi), mpi->page); + printf("%s mode page (%#x)\n", get_page_name(mpi), mpi->page); printf("-------------------------------------\n"); } bitfield(pagestart + 2, "EER", 1, 3); @@ -1921,7 +1921,7 @@ static int peripheral_device_page(struct mpage_info * mpi, if (prefix[0]) printf("%s", prefix); if (!x_interface && !replace) { - printf("%s mode page (0x%x)\n", get_page_name(mpi), mpi->page); + printf("%s mode page (%#x)\n", get_page_name(mpi), mpi->page); printf("---------------------------------\n"); }; @@ -1981,7 +1981,7 @@ static int common_power_condition(struct mpage_info * mpi, const char * prefix) if (prefix[0]) printf("%s", prefix); if (!x_interface && !replace) { - printf("%s mode page (0x%x)\n", get_page_name(mpi), mpi->page); + printf("%s mode page (%#x)\n", get_page_name(mpi), mpi->page); printf("--------------------------------\n"); } bitfield(pagestart + 3, "Idle", 1, 1); @@ -2008,7 +2008,7 @@ static int disk_xor_control(struct mpage_info * mpi, const char * prefix) if (prefix[0]) printf("%s", prefix); if (!x_interface && !replace) { - printf("%s mode page (0x%x)\n", get_page_name(mpi), mpi->page); + printf("%s mode page (%#x)\n", get_page_name(mpi), mpi->page); printf("--------------------------------\n"); } bitfield(pagestart + 2, "XORDS", 1, 1); @@ -2036,7 +2036,7 @@ static int disk_background(struct mpage_info * mpi, const char * prefix) if (prefix[0]) printf("%s", prefix); if (!x_interface && !replace) { - printf("%s mode subpage (0x%x,0x%x)\n", get_page_name(mpi), mpi->page, + printf("%s mode subpage (%#x,%#x)\n", get_page_name(mpi), mpi->page, mpi->subpage); printf("--------------------------------------------\n"); } @@ -2064,7 +2064,7 @@ static int optical_memory(struct mpage_info * mpi, const char * prefix) if (prefix[0]) printf("%s", prefix); if (!x_interface && !replace) { - printf("%s mode page (0x%x)\n", get_page_name(mpi), mpi->page); + printf("%s mode page (%#x)\n", get_page_name(mpi), mpi->page); printf("--------------------------------\n"); } bitfield(pagestart + 2, "RUBR", 1, 0); @@ -2088,7 +2088,7 @@ static int cdvd_write_param(struct mpage_info * mpi, const char * prefix) if (prefix[0]) printf("%s", prefix); if (!x_interface && !replace) { - printf("%s mode page (0x%x)\n", get_page_name(mpi), mpi->page); + printf("%s mode page (%#x)\n", get_page_name(mpi), mpi->page); printf("--------------------------------\n"); } bitfield(pagestart + 2, "BUFE", 1, 6); @@ -2131,7 +2131,7 @@ static int cdvd_audio_control(struct mpage_info * mpi, const char * prefix) if (prefix[0]) printf("%s", prefix); if (!x_interface && !replace) { - printf("%s mode page (0x%x)\n", get_page_name(mpi), mpi->page); + printf("%s mode page (%#x)\n", get_page_name(mpi), mpi->page); printf("--------------------------------\n"); } bitfield(pagestart + 2, "IMMED", 1, 2); @@ -2164,7 +2164,7 @@ static int cdvd_timeout(struct mpage_info * mpi, const char * prefix) if (prefix[0]) printf("%s", prefix); if (!x_interface && !replace) { - printf("%s mode page (0x%x)\n", get_page_name(mpi), mpi->page); + printf("%s mode page (%#x)\n", get_page_name(mpi), mpi->page); printf("-----------------------------------\n"); } bitfield(pagestart + 4, "G3Enable", 1, 3); @@ -2193,7 +2193,7 @@ static int cdvd_device_param(struct mpage_info * mpi, const char * prefix) if (prefix[0]) printf("%s", prefix); if (!x_interface && !replace) { - printf("%s mode page (0x%x)\n", get_page_name(mpi), mpi->page); + printf("%s mode page (%#x)\n", get_page_name(mpi), mpi->page); printf("------------------------------------\n"); } bitfield(pagestart + 3, "Inactivity timer multiplier", 0xf, 0); @@ -2222,7 +2222,7 @@ static int cdvd_feature(struct mpage_info * mpi, const char * prefix) if (prefix[0]) printf("%s", prefix); if (!x_interface && !replace) { - printf("%s mode page (0x%x)\n", get_page_name(mpi), mpi->page); + printf("%s mode page (%#x)\n", get_page_name(mpi), mpi->page); printf("----------------------------------------------\n"); } intfield(pagestart + 2, 2, "DVD feature set"); @@ -2257,7 +2257,7 @@ static int cdvd_mm_capab(struct mpage_info * mpi, const char * prefix) if (prefix[0]) printf("%s", prefix); if (!x_interface && !replace) { - printf("%s mode page (0x%x)\n", get_page_name(mpi), mpi->page); + printf("%s mode page (%#x)\n", get_page_name(mpi), mpi->page); printf("----------------------------------------------------\n"); } bitfield(pagestart + 2, "DVD-RAM read", 1, 5); @@ -2329,7 +2329,7 @@ static int cdvd_cache(struct mpage_info * mpi, const char * prefix) if (prefix[0]) printf("%s", prefix); if (!x_interface && !replace) { - printf("%s mode page (0x%x)\n", get_page_name(mpi), mpi->page); + printf("%s mode page (%#x)\n", get_page_name(mpi), mpi->page); printf("-----------------------\n"); }; bitfield(pagestart + 2, "Write Cache Enabled", 1, 2); @@ -2353,7 +2353,7 @@ static int tape_data_compression(struct mpage_info * mpi, const char * prefix) if (prefix[0]) printf("%s", prefix); if (!x_interface && !replace) { - printf("%s mode page (0x%x)\n", get_page_name(mpi), mpi->page); + printf("%s mode page (%#x)\n", get_page_name(mpi), mpi->page); printf("----------------------------------------------------\n"); } bitfield(pagestart + 2, "DCE", 1, 7); @@ -2382,7 +2382,7 @@ static int tape_dev_config(struct mpage_info * mpi, const char * prefix) if (prefix[0]) printf("%s", prefix); if (!x_interface && !replace) { - printf("%s mode page (0x%x)\n", get_page_name(mpi), mpi->page); + printf("%s mode page (%#x)\n", get_page_name(mpi), mpi->page); printf("----------------------------------------------------\n"); } bitfield(pagestart + 2, "CAF", 1, 5); @@ -2439,7 +2439,7 @@ static int tape_medium_part1(struct mpage_info * mpi, const char * prefix) if (prefix[0]) printf("%s", prefix); if (!x_interface && !replace) { - printf("%s mode page (0x%x)\n", get_page_name(mpi), mpi->page); + printf("%s mode page (%#x)\n", get_page_name(mpi), mpi->page); printf("----------------------------------------------------\n"); } intfield(pagestart + 2, 1, "Maximum additional partitions"); @@ -2486,7 +2486,7 @@ static int tape_medium_part2_4(struct mpage_info * mpi, const char * prefix) if (prefix[0]) printf("%s", prefix); if (!x_interface && !replace) { - printf("%s mode page (0x%x)\n", get_page_name(mpi), mpi->page); + printf("%s mode page (%#x)\n", get_page_name(mpi), mpi->page); printf("----------------------------------------------------\n"); } intfield(pagestart + 2, 2, "Partition size"); @@ -2513,7 +2513,7 @@ static int ses_services_manag(struct mpage_info * mpi, const char * prefix) if (prefix[0]) printf("%s", prefix); if (!x_interface && !replace) { - printf("%s mode page (0x%x)\n", get_page_name(mpi), mpi->page); + printf("%s mode page (%#x)\n", get_page_name(mpi), mpi->page); printf("----------------------------------------------------\n"); } bitfield(pagestart + 5, "ENBLTC", 1, 0); @@ -2538,7 +2538,7 @@ static int fcp_proto_spec_lu(struct mpage_info * mpi, const char * prefix) if (prefix[0]) printf("%s", prefix); if (!x_interface && !replace) { - printf("%s mode page (0x%x)\n", "Fibre Channel logical unit", + printf("%s mode page (%#x)\n", "Fibre Channel logical unit", mpi->page); printf("----------------------------------------------------\n"); } @@ -2563,7 +2563,7 @@ static int sas_proto_spec_lu(struct mpage_info * mpi, const char * prefix) if (prefix[0]) printf("%s", prefix); if (!x_interface && !replace) { - printf("%s mode page (0x%x)\n", "SAS logical unit", mpi->page); + printf("%s mode page (%#x)\n", "SAS logical unit", mpi->page); printf("----------------------------------------------------\n"); } bitfield(pagestart + 2, "Transport Layer Retries", 1, 4); @@ -2602,7 +2602,7 @@ static int fcp_proto_spec_port(struct mpage_info * mpi, const char * prefix) if (prefix[0]) printf("%s", prefix); if (!x_interface && !replace) { - printf("%s mode page (0x%x)\n", "Fibre Channel port control", + printf("%s mode page (%#x)\n", "Fibre Channel port control", mpi->page); printf("----------------------------------------------------\n"); } @@ -2636,7 +2636,7 @@ static int spi4_proto_spec_port(struct mpage_info * mpi, const char * prefix) if (prefix[0]) printf("%s", prefix); if (!x_interface && !replace) { - printf("%s mode page (0x%x)\n", "SPI-4 port control", mpi->page); + printf("%s mode page (%#x)\n", "SPI-4 port control", mpi->page); printf("-----------------------------------\n"); } intfield(pagestart + 4, 2, "Synchronous transfer time-out"); @@ -2661,7 +2661,7 @@ static int sas_proto_spec_port(struct mpage_info * mpi, const char * prefix) if (prefix[0]) printf("%s", prefix); if (!x_interface && !replace) { - printf("%s mode page (0x%x)\n", "SAS SSP port control", mpi->page); + printf("%s mode page (%#x)\n", "SAS SSP port control", mpi->page); printf("-------------------------------------\n"); } bitfield(pagestart + 2, "Ready LED meaning", 0x1, 4); @@ -2704,7 +2704,7 @@ static int spi4_margin_control(struct mpage_info * mpi, const char * prefix) if (prefix[0]) printf("%s", prefix); if (!x_interface && !replace) { - printf("%s mode subpage (0x%x,0x%x)\n", "SPI-4 Margin control", + printf("%s mode subpage (%#x,%#x)\n", "SPI-4 Margin control", mpi->page, mpi->subpage); printf("--------------------------------------------\n"); } @@ -2745,7 +2745,7 @@ static int sas_phy_control_discover(struct mpage_info * mpi, if (prefix[0]) printf("%s", prefix); if (!x_interface && !replace) { - printf("%s mode subpage (0x%x,0x%x)\n", "SAS Phy Control and " + printf("%s mode subpage (%#x,%#x)\n", "SAS Phy Control and " "Discover", mpi->page, mpi->subpage); printf("--------------------------------------------\n"); } @@ -2804,7 +2804,7 @@ static int spi4_training_config(struct mpage_info * mpi, const char * prefix) if (prefix[0]) printf("%s", prefix); if (!x_interface && !replace) { - printf("%s mode subpage (0x%x,0x%x)\n", "training configuration", + printf("%s mode subpage (%#x,%#x)\n", "training configuration", mpi->page, mpi->subpage); printf("----------------------------------------------------------\n"); } @@ -2856,7 +2856,7 @@ static int sas_shared_spec_port(struct mpage_info * mpi, const char * prefix) if (prefix[0]) printf("%s", prefix); if (!x_interface && !replace) { - printf("%s mode subpage (0x%x,0x%x)\n", "SAS SSP shared protocol " + printf("%s mode subpage (%#x,%#x)\n", "SAS SSP shared protocol " "specific port", mpi->page, mpi->subpage); printf("-----------------------------------------------------\n"); } @@ -2897,7 +2897,7 @@ static int spi4_negotiated(struct mpage_info * mpi, const char * prefix) if (prefix[0]) printf("%s", prefix); if (!x_interface && !replace) { - printf("%s mode subpage (0x%x,0x%x)\n", get_page_name(mpi), mpi->page, + printf("%s mode subpage (%#x,%#x)\n", get_page_name(mpi), mpi->page, mpi->subpage); printf("--------------------------------------------\n"); } @@ -2928,7 +2928,7 @@ static int spi4_report_xfer(struct mpage_info * mpi, const char * prefix) if (prefix[0]) printf("%s", prefix); if (!x_interface && !replace) { - printf("%s mode subpage (0x%x,0x%x)\n", get_page_name(mpi), mpi->page, + printf("%s mode subpage (%#x,%#x)\n", get_page_name(mpi), mpi->page, mpi->subpage); printf("--------------------------------------------\n"); } @@ -2956,18 +2956,18 @@ static void print_hex_page(struct mpage_info * mpi, const char * prefix, pg_name = get_page_name(mpi); if (mpi->subpage) { if (pg_name && (unkn_page_str != pg_name)) - printf("mode page: 0x%02x subpage: 0x%02x [%s]\n", + printf("mode page: %#02x subpage: %#02x [%s]\n", mpi->page, mpi->subpage, pg_name); else - printf("mode page: 0x%02x subpage: 0x%02x\n", mpi->page, + printf("mode page: %#02x subpage: %#02x\n", mpi->page, mpi->subpage); printf("------------------------------\n"); } else { if (pg_name && (unkn_page_str != pg_name)) - printf("mode page: 0x%02x [%s]\n", mpi->page, + printf("mode page: %#02x [%s]\n", mpi->page, pg_name); else - printf("mode page: 0x%02x\n", mpi->page); + printf("mode page: %#02x\n", mpi->page); printf("---------------\n"); } } @@ -2975,7 +2975,7 @@ static void print_hex_page(struct mpage_info * mpi, const char * prefix, { char nm[8]; - snprintf(nm, sizeof(nm), "0x%02x", k); + snprintf(nm, sizeof(nm), "%#02x", k); hexdatafield(pagestart + k, 1, nm); } printf("\n"); @@ -3004,7 +3004,7 @@ static int do_user_page(struct mpage_info * mpi, int decode_in_hex) } else { offset = modePageOffset(cbuffer2, mpi->resp_len, mode6byte); if (offset < 0) { - fprintf(stdout, "mode page=0x%x has bad page format\n", + fprintf(stdout, "mode page=%#x has bad page format\n", mpi->page); fprintf(stdout, " perhaps '-z' switch may help\n"); return -1; @@ -3038,11 +3038,11 @@ static int do_user_page(struct mpage_info * mpi, int decode_in_hex) mpf->func) { if (multiple && x_interface && !replace) { if (local_mp_i.subpage) - snprintf(prefix, sizeof(prefix), "sginfo -t 0x%x,0x%x" + snprintf(prefix, sizeof(prefix), "sginfo -t %#x,%#x" " -XR %s ", local_mp_i.page, local_mp_i.subpage, device_name); else - snprintf(prefix, sizeof(prefix), "sginfo -t 0x%x -XR %s ", + snprintf(prefix, sizeof(prefix), "sginfo -t %#x -XR %s ", local_mp_i.page, device_name); } res = mpf->func(&local_mp_i, prefix); @@ -3057,11 +3057,11 @@ static int do_user_page(struct mpage_info * mpi, int decode_in_hex) else { if (multiple && x_interface && !replace) { if (local_mp_i.subpage) - snprintf(prefix, sizeof(prefix), "sginfo -u 0x%x,0x%x" + snprintf(prefix, sizeof(prefix), "sginfo -u %#x,%#x" " -XR %s ", local_mp_i.page, local_mp_i.subpage, device_name); else - snprintf(prefix, sizeof(prefix), "sginfo -u 0x%x -XR " + snprintf(prefix, sizeof(prefix), "sginfo -u %#x -XR " "%s ", local_mp_i.page, device_name); } print_hex_page(&local_mp_i, prefix, pagestart, off, len); @@ -3785,7 +3785,7 @@ int main(int argc, char *argv[]) usage("Unknown option"); break; default: - fprintf(stdout, "Unknown option '-%c' (ascii 0x%02x)\n", c, c); + fprintf(stdout, "Unknown option '-%c' (ascii %#02x)\n", c, c); usage("bad option"); } } diff --git a/src/sgm_dd.c b/src/sgm_dd.c index 1e9ad780..3e93e5af 100644 --- a/src/sgm_dd.c +++ b/src/sgm_dd.c @@ -33,7 +33,7 @@ /* A utility program for copying files. Specialised for "files" that * represent devices that understand the SCSI command set. * -* Copyright (C) 1999 - 2007 D. Gilbert and P. Allworth +* Copyright (C) 1999 - 2009 D. Gilbert and P. Allworth * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) @@ -64,9 +64,9 @@ /* #define SG_WANT_SHARED_MMAP_IO 1 */ #ifdef SG_WANT_SHARED_MMAP_IO -static char * version_str = "1.35 20080205 shared_mmap"; +static char * version_str = "1.35 20090717 shared_mmap"; #else -static char * version_str = "1.35 20080205"; +static char * version_str = "1.35 20090717"; #endif #define DEF_BLOCK_SIZE 512 @@ -372,7 +372,7 @@ scsi_read_capacity(int sg_fd, int64_t * num_sect, int * sect_sz) (rcBuff[6] << 8) | rcBuff[7]; } if (verbose) - fprintf(stderr, " number of blocks=%"PRId64" [0x%"PRIx64"], block " + fprintf(stderr, " number of blocks=%"PRId64" [%#"PRIx64"], block " "size=%d\n", *num_sect, *num_sect, *sect_sz); return 0; } @@ -397,7 +397,7 @@ read_blkdev_capacity(int sg_fd, int64_t * num_sect, int * sect_sz) } *num_sect = ((int64_t)ull / (int64_t)*sect_sz); if (verbose) - fprintf(stderr, " [bgs64] number of blocks=%"PRId64" [0x%"PRIx64"], " + fprintf(stderr, " [bgs64] number of blocks=%"PRId64" [%#"PRIx64"], " "block size=%d\n", *num_sect, *num_sect, *sect_sz); #else unsigned long ul; @@ -408,7 +408,7 @@ read_blkdev_capacity(int sg_fd, int64_t * num_sect, int * sect_sz) } *num_sect = (int64_t)ul; if (verbose) - fprintf(stderr, " [bgs] number of blocks=%"PRId64" [0x%"PRIx64"], " + fprintf(stderr, " [bgs] number of blocks=%"PRId64" [%#"PRIx64"], " " block size=%d\n", *num_sect, *num_sect, *sect_sz); #endif } @@ -1050,7 +1050,7 @@ main(int argc, char * argv[]) } if (verbose) fprintf(stderr, " >> skip: lseek64 SEEK_SET, " - "byte offset=0x%"PRIx64"\n", + "byte offset=%#"PRIx64"\n", (uint64_t)offset); } } @@ -1149,7 +1149,7 @@ main(int argc, char * argv[]) } if (verbose) fprintf(stderr, " >> seek: lseek64 SEEK_SET, " - "byte offset=0x%"PRIx64"\n", + "byte offset=%#"PRIx64"\n", (uint64_t)offset); } } |