diff options
author | Douglas Gilbert <dgilbert@interlog.com> | 2007-12-27 04:41:53 +0000 |
---|---|---|
committer | Douglas Gilbert <dgilbert@interlog.com> | 2007-12-27 04:41:53 +0000 |
commit | 83b6e5355fb25dc0452e77ddbbe8d206342e5e8b (patch) | |
tree | e113604b55c64d2a98bb9c8f3dd948cfc4f13739 /src | |
parent | 543c2b8a8987ca2b75d589fde1d235433ff74719 (diff) | |
download | sg3_utils-83b6e5355fb25dc0452e77ddbbe8d206342e5e8b.tar.gz |
replace %lld and friends with PRI macros, remove archive/pre_configure
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@134 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'src')
-rw-r--r-- | src/sg_dd.c | 80 | ||||
-rw-r--r-- | src/sg_rbuf.c | 6 | ||||
-rw-r--r-- | src/sg_read.c | 14 | ||||
-rw-r--r-- | src/sginfo.c | 10 | ||||
-rw-r--r-- | src/sgm_dd.c | 40 | ||||
-rw-r--r-- | src/sgp_dd.c | 36 |
6 files changed, 99 insertions, 87 deletions
diff --git a/src/sg_dd.c b/src/sg_dd.c index f1bd9f4d..cdc3ff0a 100644 --- a/src/sg_dd.c +++ b/src/sg_dd.c @@ -12,6 +12,8 @@ #include <ctype.h> #include <errno.h> #include <limits.h> +#define __STDC_FORMAT_MACROS 1 +#include <inttypes.h> #include <sys/ioctl.h> #include <sys/types.h> #include <sys/stat.h> @@ -55,7 +57,7 @@ This version is designed for the linux kernel 2.4 and 2.6 series. */ -static char * version_str = "5.63 20070714"; +static char * version_str = "5.64 20071226"; #define ME "sg_dd: " @@ -177,13 +179,13 @@ static void install_handler(int sig_num, void (*sig_handler) (int sig)) static void print_stats(const char * str) { if (0 != dd_count) - fprintf(stderr, " remaining block count=%lld\n", dd_count); - fprintf(stderr, "%s%lld+%d records in\n", str, in_full - in_partial, + fprintf(stderr, " remaining block count=%"PRId64"\n", dd_count); + fprintf(stderr, "%s%"PRId64"+%d records in\n", str, in_full - in_partial, in_partial); - fprintf(stderr, "%s%lld+%d records out\n", str, out_full - out_partial, + fprintf(stderr, "%s%"PRId64"+%d records out\n", str, out_full - out_partial, out_partial); if (oflag.sparse) - fprintf(stderr, "%s%lld bypassed records out\n", str, out_sparse); + fprintf(stderr, "%s%"PRId64" bypassed records out\n", str, out_sparse); if (recovered_errs > 0) fprintf(stderr, "%s%d recovered errors\n", str, recovered_errs); if (num_retries > 0) @@ -367,7 +369,7 @@ static int 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=%lld [0x%llx], block " + fprintf(stderr, " number of blocks=%"PRId64" [0x%"PRIx64"], block " "size=%d\n", *num_sect, *num_sect, *sect_sz); return 0; } @@ -392,7 +394,7 @@ static int read_blkdev_capacity(int sg_fd, int64_t * num_sect, } *num_sect = ((int64_t)ull / (int64_t)*sect_sz); if (verbose) - fprintf(stderr, " [bgs64] number of blocks=%lld [0x%llx], " + fprintf(stderr, " [bgs64] number of blocks=%"PRId64" [0x%"PRIx64"], " "block size=%d\n", *num_sect, *num_sect, *sect_sz); #else unsigned long ul; @@ -403,7 +405,7 @@ static int read_blkdev_capacity(int sg_fd, int64_t * num_sect, } *num_sect = (int64_t)ul; if (verbose) - fprintf(stderr, " [bgs] number of blocks=%lld [0x%llx], " + fprintf(stderr, " [bgs] number of blocks=%"PRId64" [0x%"PRIx64"], " " block size=%d\n", *num_sect, *num_sect, *sect_sz); #endif } @@ -528,7 +530,7 @@ static int sg_read_low(int sg_fd, unsigned char * buff, int blocks, if (sg_build_scsi_cdb(rdCmd, ifp->cdbsz, blocks, from_block, 0, ifp->fua, ifp->dpo)) { - fprintf(stderr, ME "bad rd cdb build, from_block=%lld, blocks=%d\n", + fprintf(stderr, ME "bad rd cdb build, from_block=%"PRId64", blocks=%d\n", from_block, blocks); return SG_LIB_SYNTAX_ERROR; } @@ -573,12 +575,12 @@ static int sg_read_low(int sg_fd, unsigned char * buff, int blocks, io_addrp); if (info_valid) { fprintf(stderr, " lba of last recovered error in this " - "READ=0x%llx\n", *io_addrp); + "READ=0x%"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%llx, num=%d\n", from_block, blocks); + "block=0x%"PRIx64", num=%d\n", from_block, blocks); sg_chk_n_print3("reading", &io_hdr, verbose > 1); } break; @@ -671,7 +673,7 @@ static int sg_read(int sg_fd, unsigned char * buff, int blocks, break; case SG_LIB_CAT_MEDIUM_HARD_WITH_INFO: if (retries_tmp > 0) { - fprintf(stderr, ">>> retrying a sgio read, lba=0x%llx\n", + fprintf(stderr, ">>> retrying a sgio read, lba=0x%"PRIx64"\n", (uint64_t)lba); --retries_tmp; ++num_retries; @@ -691,7 +693,7 @@ static int sg_read(int sg_fd, unsigned char * buff, int blocks, case SG_LIB_CAT_MEDIUM_HARD: default: if (retries_tmp > 0) { - fprintf(stderr, ">>> retrying a sgio read, lba=0x%llx\n", + fprintf(stderr, ">>> retrying a sgio read, lba=0x%"PRIx64"\n", (uint64_t)lba); --retries_tmp; ++num_retries; @@ -707,8 +709,8 @@ static int sg_read(int sg_fd, unsigned char * buff, int blocks, continue; if ((io_addr < (uint64_t)lba) || (io_addr >= (uint64_t)(lba + blks))) { - fprintf(stderr, " Unrecovered error lba 0x%llx not in " - "correct range:\n\t[0x%llx,0x%llx]\n", io_addr, + fprintf(stderr, " Unrecovered error lba 0x%"PRIx64" not in " + "correct range:\n\t[0x%"PRIx64",0x%"PRIx64"]\n", io_addr, (uint64_t)lba, (uint64_t)(lba + blks - 1)); goto err_out; @@ -764,7 +766,7 @@ static int sg_read(int sg_fd, unsigned char * buff, int blocks, bp += (blks * bs); lba += blks; if ((0 != ifp->pdt) || (ifp->coe < 2)) { - fprintf(stderr, ">> unrecovered read error at blk=%lld, " + fprintf(stderr, ">> unrecovered read error at blk=%"PRId64", " "pdt=%d, use zeros\n", lba, ifp->pdt); memset(bp, 0, bs); } else if (io_addr < UINT_MAX) { @@ -833,7 +835,7 @@ static int sg_read(int sg_fd, unsigned char * buff, int blocks, memset(bp, 0, bs); free(buffp); } else { - fprintf(stderr, ">> read_long(10) cannot handle blk=%lld, " + fprintf(stderr, ">> read_long(10) cannot handle blk=%"PRId64", " "use zeros\n", lba); memset(bp, 0, bs); } @@ -854,7 +856,7 @@ static int sg_read(int sg_fd, unsigned char * buff, int blocks, err_out: if (ifp->coe) { memset(bp, 0, bs * blks); - fprintf(stderr, ">> unable to read at blk=%lld for " + fprintf(stderr, ">> unable to read at blk=%"PRId64" for " "%d bytes, use zeros\n", lba, bs * blks); /* fudge success */ if (blks_readp) @@ -880,7 +882,7 @@ static int sg_write(int sg_fd, unsigned char * buff, int blocks, if (sg_build_scsi_cdb(wrCmd, ofp->cdbsz, blocks, to_block, 1, ofp->fua, ofp->dpo)) { - fprintf(stderr, ME "bad wr cdb build, to_block=%lld, blocks=%d\n", + fprintf(stderr, ME "bad wr cdb build, to_block=%"PRId64", blocks=%d\n", to_block, blocks); return SG_LIB_SYNTAX_ERROR; } @@ -926,12 +928,12 @@ static int sg_write(int sg_fd, unsigned char * buff, int blocks, &io_addr); if (info_valid) { fprintf(stderr, " lba of last recovered error in this " - "WRITE=0x%llx\n", io_addr); + "WRITE=0x%"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%llx, num=%d\n", to_block, blocks); + "block=0x%"PRIx64", num=%d\n", to_block, blocks); sg_chk_n_print3("writing", &io_hdr, verbose > 1); } break; @@ -948,7 +950,7 @@ static int sg_write(int sg_fd, unsigned char * buff, int blocks, sg_chk_n_print3("writing", &io_hdr, verbose > 1); ++unrecovered_errs; if (ofp->coe) { - fprintf(stderr, ">> ignored errors for out blk=%lld for " + fprintf(stderr, ">> ignored errors for out blk=%"PRId64" for " "%d bytes\n", to_block, bs * blocks); return 0; /* fudge success */ } else @@ -1237,7 +1239,7 @@ int main(int argc, char * argv[]) if ((blk_sz >= 2048) && (0 == bpt_given)) bpt = DEF_BLOCKS_PER_2048TRANSFER; #ifdef SG_DEBUG - fprintf(stderr, ME "if=%s skip=%lld of=%s seek=%lld count=%lld\n", + fprintf(stderr, ME "if=%s skip=%"PRId64" of=%s seek=%"PRId64" count=%"PRId64"\n", inf, skip, outf, seek, dd_count); #endif install_handler(SIGINT, interrupt_handler); @@ -1337,7 +1339,7 @@ int main(int argc, char * argv[]) } if (verbose) fprintf(stderr, " >> skip: lseek64 SEEK_SET, " - "byte offset=0x%llx\n", + "byte offset=0x%"PRIx64"\n", (uint64_t)offset); } } @@ -1440,7 +1442,7 @@ int main(int argc, char * argv[]) } if (verbose) fprintf(stderr, " >> seek: lseek64 SEEK_SET, " - "byte offset=0x%llx\n", + "byte offset=0x%"PRIx64"\n", (uint64_t)offset); } } @@ -1538,7 +1540,7 @@ int main(int argc, char * argv[]) out_num_sect -= seek; #ifdef SG_DEBUG fprintf(stderr, - "Start of loop, count=%lld, in_num_sect=%lld, out_num_sect=%lld\n", + "Start of loop, count=%"PRId64", in_num_sect=%"PRId64", out_num_sect=%"PRId64"\n", dd_count, in_num_sect, out_num_sect); #endif if (dd_count < 0) { @@ -1593,7 +1595,7 @@ int main(int argc, char * argv[]) blocks_per = bpt; #ifdef SG_DEBUG - fprintf(stderr, "Start of loop, count=%lld, blocks_per=%d\n", + fprintf(stderr, "Start of loop, count=%"PRId64", blocks_per=%d\n", dd_count, blocks_per); #endif if (do_time) { @@ -1632,8 +1634,8 @@ int main(int argc, char * argv[]) } } if (res) { - fprintf(stderr, "sg_read failed,%s at or after lba=%lld " - "[0x%llx]\n", + fprintf(stderr, "sg_read failed,%s at or after lba=%"PRId64" " + "[0x%"PRIx64"]\n", ((-2 == res) ? " try reducing bpt," : ""), skip, skip); ret = res; break; @@ -1654,7 +1656,7 @@ int main(int argc, char * argv[]) fprintf(stderr, "read(unix): count=%d, res=%d\n", blocks * blk_sz, res); if (res < 0) { - snprintf(ebuff, EBUFF_SZ, ME "reading, skip=%lld ", skip); + snprintf(ebuff, EBUFF_SZ, ME "reading, skip=%"PRId64" ", skip); perror(ebuff); ret = -1; break; @@ -1691,7 +1693,7 @@ int main(int argc, char * argv[]) out_sparse += blocks; if (verbose > 2) fprintf(stderr, "sparse bypassing sg_write: seek " - "blk=%lld, offset blks=%d\n", seek, blocks); + "blk=%"PRId64", offset blks=%d\n", seek, blocks); } else if (FT_DEV_NULL & out_type) ; else { @@ -1700,18 +1702,18 @@ int main(int argc, char * argv[]) if (verbose > 2) fprintf(stderr, "sparse bypassing write: " - "seek=%lld, rel offset=%lld\n", (seek * blk_sz), + "seek=%"PRId64", rel offset=%"PRId64"\n", (seek * blk_sz), (int64_t)offset); off_res = lseek64(outfd, offset, SEEK_CUR); if (off_res < 0) { fprintf(stderr, "sparse tried to bypass write: " - "seek=%lld, rel offset=%lld but ...\n", + "seek=%"PRId64", rel offset=%"PRId64" but ...\n", (seek * blk_sz), (int64_t)offset); perror("lseek64 on output"); ret = SG_LIB_FILE_ERROR; break; } else if (verbose > 4) - fprintf(stderr, "oflag=sparse lseek64 result=%lld\n", + fprintf(stderr, "oflag=sparse lseek64 result=%"PRId64"\n", (int64_t)off_res); out_sparse += blocks; } @@ -1760,7 +1762,7 @@ int main(int argc, char * argv[]) break; else if (retries_tmp > 0) { fprintf(stderr, ">>> retrying a sgio write, " - "lba=0x%llx\n", (uint64_t)seek); + "lba=0x%"PRIx64"\n", (uint64_t)seek); --retries_tmp; ++num_retries; if (unrecovered_errs > 0) @@ -1770,7 +1772,7 @@ int main(int argc, char * argv[]) first = 0; } if (0 != ret) { - fprintf(stderr, "sg_write failed,%s seek=%lld\n", + fprintf(stderr, "sg_write failed,%s seek=%"PRId64"\n", ((-2 == ret) ? " try reducing bpt," : ""), seek); break; } else { @@ -1788,12 +1790,12 @@ int main(int argc, char * argv[]) fprintf(stderr, "write(unix): count=%d, res=%d\n", blocks * blk_sz, res); if (res < 0) { - snprintf(ebuff, EBUFF_SZ, ME "writing, seek=%lld ", seek); + snprintf(ebuff, EBUFF_SZ, ME "writing, seek=%"PRId64" ", seek); perror(ebuff); ret = -1; break; } else if (res < blocks * blk_sz) { - fprintf(stderr, "output file probably full, seek=%lld ", seek); + fprintf(stderr, "output file probably full, seek=%"PRId64" ", seek); blocks = res / blk_sz; out_full += blocks; if ((res % blk_sz) > 0) @@ -1822,7 +1824,7 @@ int main(int argc, char * argv[]) "res=%d\n", penult_blocks * blk_sz, res); if (res < 0) { snprintf(ebuff, EBUFF_SZ, ME "writing(sparse after error), " - "seek=%lld ", seek); + "seek=%"PRId64" ", seek); perror(ebuff); } } diff --git a/src/sg_rbuf.c b/src/sg_rbuf.c index 07aab0ea..6d3f56be 100644 --- a/src/sg_rbuf.c +++ b/src/sg_rbuf.c @@ -11,6 +11,8 @@ #include <string.h> #include <errno.h> #include <getopt.h> +#define __STDC_FORMAT_MACROS 1 +#include <inttypes.h> #include <sys/ioctl.h> #include <sys/types.h> #include <sys/stat.h> @@ -51,7 +53,7 @@ #endif -static char * version_str = "4.87 20070714"; +static char * version_str = "4.88 20071226"; static struct option long_options[] = { {"buffer", 1, 0, 'b'}, @@ -600,7 +602,7 @@ int main(int argc, char * argv[]) } if (dio_incomplete) printf(">> direct IO requested but not done\n"); - printf("Read %lld MiB (actual: %lld bytes), buffer size=%d KiB " + printf("Read %"PRId64" MiB (actual: %"PRId64" bytes), buffer size=%d KiB " "(%d bytes)\n", (total_size / (1024 * 1024)), (int64_t)num * buf_size, buf_size / 1024, buf_size); diff --git a/src/sg_read.c b/src/sg_read.c index 2da4a102..9e191344 100644 --- a/src/sg_read.c +++ b/src/sg_read.c @@ -11,6 +11,8 @@ #include <signal.h> #include <ctype.h> #include <errno.h> +#define __STDC_FORMAT_MACROS 1 +#include <inttypes.h> #include <sys/ioctl.h> #include <sys/types.h> #include <sys/stat.h> @@ -45,7 +47,7 @@ */ -static const char * version_str = "1.17 20070714"; +static const char * version_str = "1.18 20071226"; #define DEF_BLOCK_SIZE 512 #define DEF_BLOCKS_PER_TRANSFER 128 @@ -102,8 +104,8 @@ static void print_stats(int iters, const char * str) { if (orig_count > 0) { if (0 != dd_count) - fprintf(stderr, " remaining block count=%lld\n", dd_count); - fprintf(stderr, "%lld+%d records in", in_full - in_partial, + fprintf(stderr, " remaining block count=%"PRId64"\n", dd_count); + fprintf(stderr, "%"PRId64"+%d records in", in_full - in_partial, in_partial); if (iters > 0) fprintf(stderr, ", %s commands issued: %d\n", (str ? str : ""), @@ -303,7 +305,7 @@ static int sg_bread(int sg_fd, unsigned char * buff, int blocks, struct sg_io_hdr io_hdr; if (sg_build_scsi_cdb(rdCmd, cdbsz, blocks, from_block, 0, fua, dpo)) { - fprintf(stderr, ME "bad cdb build, from_block=%lld, blocks=%d\n", + fprintf(stderr, ME "bad cdb build, from_block=%"PRId64", blocks=%d\n", from_block, blocks); return -1; } @@ -672,7 +674,7 @@ int main(int argc, char * argv[]) start_tm.tv_usec = 0; if (verbose && (dd_count < 0)) - fprintf(stderr, "About to issue %lld zero block SCSI READs\n", + fprintf(stderr, "About to issue %"PRId64" zero block SCSI READs\n", 0 - dd_count); /* main loop */ @@ -749,7 +751,7 @@ int main(int argc, char * argv[]) (EINTR == errno)) ; if (res < 0) { - snprintf(ebuff, EBUFF_SZ, ME "reading, skip=%lld ", skip); + snprintf(ebuff, EBUFF_SZ, ME "reading, skip=%"PRId64" ", skip); perror(ebuff); break; } else if (res < blocks * bs) { diff --git a/src/sginfo.c b/src/sginfo.c index 634f90c4..0b7d8e19 100644 --- a/src/sginfo.c +++ b/src/sginfo.c @@ -115,7 +115,7 @@ #define _GNU_SOURCE #endif -static const char * version_str = "2.25 [20070714]"; +static const char * version_str = "2.26 [20071226]"; #include <stdio.h> #include <string.h> @@ -126,6 +126,8 @@ static const char * version_str = "2.25 [20070714]"; #include <errno.h> #include <stdlib.h> #include <ctype.h> +#define __STDC_FORMAT_MACROS 1 +#include <inttypes.h> #include <sys/ioctl.h> #include <sys/types.h> #include <sys/stat.h> @@ -638,13 +640,13 @@ static void check_parm_type(int i) if (i == 1 && is_hex[next_parameter] != 1) { snprintf(reason, REASON_SZ, - "simple number (pos %i) instead of @ hexdatafield: %llu", + "simple number (pos %i) instead of @ hexdatafield: %"PRIu64, next_parameter, replacement_values[next_parameter]); usage (reason); } if (i != 1 && is_hex[next_parameter]) { snprintf(reason, REASON_SZ, - "@ hexdatafield (pos %i) instead of a simple number: %llu", + "@ hexdatafield (pos %i) instead of a simple number: %"PRIu64, next_parameter, replacement_values[next_parameter]); usage (reason); } @@ -1754,7 +1756,7 @@ trytenbyte: } case 3: /* lba (64 bit) */ while (len > 0) { - printf("%15lld", getnbyte_ll(df, 8)); + printf("%15"PRId64, getnbyte_ll(df, 8)); len -= 8; df += 8; i++; diff --git a/src/sgm_dd.c b/src/sgm_dd.c index 9a296821..b3afc7f4 100644 --- a/src/sgm_dd.c +++ b/src/sgm_dd.c @@ -12,6 +12,8 @@ #include <ctype.h> #include <errno.h> #include <limits.h> +#define __STDC_FORMAT_MACROS 1 +#include <inttypes.h> #include <sys/ioctl.h> #include <sys/types.h> #include <sys/stat.h> @@ -59,7 +61,7 @@ This version is designed for the linux kernel 2.4 and 2.6 series. */ -static char * version_str = "1.33 20070728 shared_mmap"; +static char * version_str = "1.34 20071226 shared_mmap"; #define DEF_BLOCK_SIZE 512 #define DEF_BLOCKS_PER_TRANSFER 128 @@ -159,9 +161,9 @@ static void install_handler (int sig_num, void (*sig_handler) (int sig)) static void print_stats() { if (0 != dd_count) - fprintf(stderr, " remaining block count=%lld\n", dd_count); - fprintf(stderr, "%lld+%d records in\n", in_full - in_partial, in_partial); - fprintf(stderr, "%lld+%d records out\n", out_full - out_partial, + fprintf(stderr, " remaining block count=%"PRId64"\n", dd_count); + fprintf(stderr, "%"PRId64"+%d records in\n", in_full - in_partial, in_partial); + fprintf(stderr, "%"PRId64"+%d records out\n", out_full - out_partial, out_partial); } @@ -345,7 +347,7 @@ int 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=%lld [0x%llx], block " + fprintf(stderr, " number of blocks=%"PRId64" [0x%"PRIx64"], block " "size=%d\n", *num_sect, *num_sect, *sect_sz); return 0; } @@ -369,7 +371,7 @@ int 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=%lld [0x%llx], " + fprintf(stderr, " [bgs64] number of blocks=%"PRId64" [0x%"PRIx64"], " "block size=%d\n", *num_sect, *num_sect, *sect_sz); #else unsigned long ul; @@ -380,7 +382,7 @@ int 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=%lld [0x%llx], " + fprintf(stderr, " [bgs] number of blocks=%"PRId64" [0x%"PRIx64"], " " block size=%d\n", *num_sect, *num_sect, *sect_sz); #endif } @@ -499,7 +501,7 @@ int sg_read(int sg_fd, unsigned char * buff, int blocks, int64_t from_block, int k, res; if (sg_build_scsi_cdb(rdCmd, cdbsz, blocks, from_block, 0, fua, dpo)) { - fprintf(stderr, ME "bad rd cdb build, from_block=%lld, blocks=%d\n", + fprintf(stderr, ME "bad rd cdb build, from_block=%"PRId64", blocks=%d\n", from_block, blocks); return SG_LIB_SYNTAX_ERROR; } @@ -590,7 +592,7 @@ int sg_write(int sg_fd, unsigned char * buff, int blocks, int64_t to_block, int k, res; if (sg_build_scsi_cdb(wrCmd, cdbsz, blocks, to_block, 1, fua, dpo)) { - fprintf(stderr, ME "bad wr cdb build, to_block=%lld, blocks=%d\n", + fprintf(stderr, ME "bad wr cdb build, to_block=%"PRId64", blocks=%d\n", to_block, blocks); return SG_LIB_SYNTAX_ERROR; } @@ -905,7 +907,7 @@ int main(int argc, char * argv[]) bpt = DEF_BLOCKS_PER_2048TRANSFER; #ifdef SG_DEBUG - fprintf(stderr, ME "if=%s skip=%lld of=%s seek=%lld count=%lld\n", + fprintf(stderr, ME "if=%s skip=%"PRId64" of=%s seek=%"PRId64" count=%"PRId64"\n", inf, skip, outf, seek, dd_count); #endif install_handler (SIGINT, interrupt_handler); @@ -997,7 +999,7 @@ int main(int argc, char * argv[]) } if (verbose) fprintf(stderr, " >> skip: lseek64 SEEK_SET, " - "byte offset=0x%llx\n", + "byte offset=0x%"PRIx64"\n", (uint64_t)offset); } } @@ -1096,7 +1098,7 @@ int main(int argc, char * argv[]) } if (verbose) fprintf(stderr, " >> seek: lseek64 SEEK_SET, " - "byte offset=0x%llx\n", + "byte offset=0x%"PRIx64"\n", (uint64_t)offset); } } @@ -1181,7 +1183,7 @@ int main(int argc, char * argv[]) out_num_sect -= seek; #ifdef SG_DEBUG fprintf(stderr, - "Start of loop, count=%lld, in_num_sect=%lld, out_num_sect=%lld\n", + "Start of loop, count=%"PRId64", in_num_sect=%"PRId64", out_num_sect=%"PRId64"\n", dd_count, in_num_sect, out_num_sect); #endif if (in_num_sect > 0) { @@ -1259,7 +1261,7 @@ int main(int argc, char * argv[]) blocks_per = bpt; #ifdef SG_DEBUG - fprintf(stderr, "Start of loop, count=%lld, blocks_per=%d\n", + fprintf(stderr, "Start of loop, count=%"PRId64", blocks_per=%d\n", dd_count, blocks_per); #endif if (do_time) { @@ -1288,7 +1290,7 @@ int main(int argc, char * argv[]) scsi_cdbsz_in, in_flags.fua, in_flags.dpo, 1); } if (0 != ret) { - fprintf(stderr, "sg_read failed, skip=%lld\n", skip); + fprintf(stderr, "sg_read failed, skip=%"PRId64"\n", skip); break; } else @@ -1302,7 +1304,7 @@ int main(int argc, char * argv[]) fprintf(stderr, "read(unix): count=%d, res=%d\n", blocks * blk_sz, res); if (ret < 0) { - snprintf(ebuff, EBUFF_SZ, ME "reading, skip=%lld ", skip); + snprintf(ebuff, EBUFF_SZ, ME "reading, skip=%"PRId64" ", skip); perror(ebuff); ret = -1; break; @@ -1338,7 +1340,7 @@ int main(int argc, char * argv[]) do_mmap, mmap_shareable, &dio_res); } if (0 != ret) { - fprintf(stderr, "sg_write failed, seek=%lld\n", seek); + fprintf(stderr, "sg_write failed, seek=%"PRId64"\n", seek); break; } else { @@ -1357,12 +1359,12 @@ int main(int argc, char * argv[]) fprintf(stderr, "write(unix): count=%d, res=%d\n", blocks * blk_sz, res); if (res < 0) { - snprintf(ebuff, EBUFF_SZ, ME "writing, seek=%lld ", seek); + snprintf(ebuff, EBUFF_SZ, ME "writing, seek=%"PRId64" ", seek); perror(ebuff); break; } else if (res < blocks * blk_sz) { - fprintf(stderr, "output file probably full, seek=%lld ", seek); + fprintf(stderr, "output file probably full, seek=%"PRId64" ", seek); blocks = res / blk_sz; out_full += blocks; if ((res % blk_sz) > 0) diff --git a/src/sgp_dd.c b/src/sgp_dd.c index 4d7f9a7e..a20d692e 100644 --- a/src/sgp_dd.c +++ b/src/sgp_dd.c @@ -13,6 +13,8 @@ #include <limits.h> #include <pthread.h> #include <signal.h> +#define __STDC_FORMAT_MACROS 1 +#include <inttypes.h> #include <sys/ioctl.h> #include <sys/types.h> #include <sys/stat.h> @@ -54,7 +56,7 @@ */ -static char * version_str = "5.38 20070728"; +static char * version_str = "5.39 20071226"; #define DEF_BLOCK_SIZE 512 #define DEF_BLOCKS_PER_TRANSFER 128 @@ -220,14 +222,14 @@ static void print_stats(const char * str) int64_t infull, outfull; if (0 != rcoll.out_rem_count) - fprintf(stderr, " remaining block count=%lld\n", + fprintf(stderr, " remaining block count=%"PRId64"\n", rcoll.out_rem_count); infull = dd_count - rcoll.in_rem_count; - fprintf(stderr, "%s%lld+%d records in\n", str, infull - rcoll.in_partial, + fprintf(stderr, "%s%"PRId64"+%d records in\n", str, infull - rcoll.in_partial, rcoll.in_partial); outfull = dd_count - rcoll.out_rem_count; - fprintf(stderr, "%s%lld+%d records out\n", str, + fprintf(stderr, "%s%"PRId64"+%d records out\n", str, outfull - rcoll.out_partial, rcoll.out_partial); } @@ -629,7 +631,7 @@ static int normal_in_operation(Rq_coll * clp, Rq_elem * rep, int blocks) if (res < 0) { if (clp->in_flags.coe) { memset(rep->buffp, 0, rep->num_blks * rep->bs); - fprintf(stderr, ">> substituted zeros for in blk=%lld for " + fprintf(stderr, ">> substituted zeros for in blk=%"PRId64" for " "%d bytes, %s\n", rep->blk, rep->num_blks * rep->bs, tsafe_strerror(errno, strerr_buff)); @@ -673,7 +675,7 @@ static void normal_out_operation(Rq_coll * clp, Rq_elem * rep, int blocks) ; if (res < 0) { if (clp->out_flags.coe) { - fprintf(stderr, ">> ignored error for out blk=%lld for " + fprintf(stderr, ">> ignored error for out blk=%"PRId64" for " "%d bytes, %s\n", rep->blk, rep->num_blks * rep->bs, tsafe_strerror(errno, strerr_buff)); @@ -801,7 +803,7 @@ static void sg_in_operation(Rq_coll * clp, Rq_elem * rep) if (1 == res) err_exit(ENOMEM, "sg starting in command"); else if (res < 0) { - fprintf(stderr, ME "inputting to sg failed, blk=%lld\n", + fprintf(stderr, ME "inputting to sg failed, blk=%"PRId64"\n", rep->blk); status = pthread_mutex_unlock(&clp->in_mutex); if (0 != status) err_exit(status, "unlock in_mutex"); @@ -831,7 +833,7 @@ static void sg_in_operation(Rq_coll * clp, Rq_elem * rep) return; } else { memset(rep->buffp, 0, rep->num_blks * rep->bs); - fprintf(stderr, ">> substituted zeros for in blk=%lld for " + fprintf(stderr, ">> substituted zeros for in blk=%"PRId64" for " "%d bytes\n", rep->blk, rep->num_blks * rep->bs); } /* fall through */ @@ -871,7 +873,7 @@ static void sg_out_operation(Rq_coll * clp, Rq_elem * rep) if (1 == res) err_exit(ENOMEM, "sg starting out command"); else if (res < 0) { - fprintf(stderr, ME "outputting from sg failed, blk=%lld\n", + fprintf(stderr, ME "outputting from sg failed, blk=%"PRId64"\n", rep->blk); status = pthread_mutex_unlock(&clp->out_mutex); if (0 != status) err_exit(status, "unlock out_mutex"); @@ -900,7 +902,7 @@ static void sg_out_operation(Rq_coll * clp, Rq_elem * rep) guarded_stop_both(clp); return; } else - fprintf(stderr, ">> ignored error for out blk=%lld for " + fprintf(stderr, ">> ignored error for out blk=%"PRId64" for " "%d bytes\n", rep->blk, rep->num_blks * rep->bs); /* fall through */ case 0: @@ -939,7 +941,7 @@ static int sg_start_io(Rq_elem * rep) if (sg_build_scsi_cdb(rep->cmd, cdbsz, rep->num_blks, rep->blk, rep->wr, fua, dpo)) { - fprintf(stderr, ME "bad cdb build, start_blk=%lld, blocks=%d\n", + fprintf(stderr, ME "bad cdb build, start_blk=%"PRId64", blocks=%d\n", rep->blk, rep->num_blks); return -1; } @@ -958,7 +960,7 @@ static int sg_start_io(Rq_elem * rep) if (dio) hp->flags |= SG_FLAG_DIRECT_IO; if (rep->debug > 8) { - fprintf(stderr, "sg_start_io: SCSI %s, blk=%lld num_blks=%d\n", + fprintf(stderr, "sg_start_io: SCSI %s, blk=%"PRId64" num_blks=%d\n", rep->wr ? "WRITE" : "READ", rep->blk, rep->num_blks); sg_print_command(hp->cmdp); } @@ -1023,7 +1025,7 @@ static int sg_finish_io(int wr, Rq_elem * rep, pthread_mutex_t * a_mutp) { char ebuff[EBUFF_SZ]; - snprintf(ebuff, EBUFF_SZ, "%s blk=%lld", + snprintf(ebuff, EBUFF_SZ, "%s blk=%"PRId64, wr ? "writing": "reading", rep->blk); status = pthread_mutex_lock(a_mutp); if (0 != status) err_exit(status, "lock aux_mutex"); @@ -1296,7 +1298,7 @@ int main(int argc, char * argv[]) return SG_LIB_SYNTAX_ERROR; } if (rcoll.debug) - fprintf(stderr, ME "if=%s skip=%lld of=%s seek=%lld count=%lld\n", + fprintf(stderr, ME "if=%s skip=%"PRId64" of=%s seek=%"PRId64" count=%"PRId64"\n", inf, skip, outf, seek, dd_count); install_handler(SIGINT, interrupt_handler); @@ -1518,8 +1520,8 @@ int main(int argc, char * argv[]) dd_count = out_num_sect; } if (rcoll.debug > 1) - fprintf(stderr, "Start of loop, count=%lld, in_num_sect=%lld, " - "out_num_sect=%lld\n", dd_count, in_num_sect, out_num_sect); + fprintf(stderr, "Start of loop, count=%"PRId64", in_num_sect=%"PRId64", " + "out_num_sect=%"PRId64"\n", dd_count, in_num_sect, out_num_sect); if (dd_count < 0) { fprintf(stderr, "Couldn't calculate count, please give one\n"); return SG_LIB_CAT_OTHER; @@ -1632,7 +1634,7 @@ int main(int argc, char * argv[]) close(rcoll.outfd); res = exit_status; if (0 != rcoll.out_count) { - fprintf(stderr, ">>>> Some error occurred, remaining blocks=%lld\n", + fprintf(stderr, ">>>> Some error occurred, remaining blocks=%"PRId64"\n", rcoll.out_count); if (0 == res) res = SG_LIB_CAT_OTHER; |