diff options
author | Douglas Gilbert <dgilbert@interlog.com> | 2007-12-19 16:35:49 +0000 |
---|---|---|
committer | Douglas Gilbert <dgilbert@interlog.com> | 2007-12-19 16:35:49 +0000 |
commit | b4530ba23ca6fb39e2bbf56afa4fdc892bf16910 (patch) | |
tree | 6a1ad36741c45c218f6ba11001c8260b18e4a09a /src | |
parent | 2fdbef700da5c71ab2eaf80547704d03e7a93f91 (diff) | |
download | sg3_utils-b4530ba23ca6fb39e2bbf56afa4fdc892bf16910.tar.gz |
change 'long long' to int64_t to stress only need 64 bit integers (similar change to uint64_t)
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@128 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'src')
-rw-r--r-- | src/sg_dd.c | 76 | ||||
-rw-r--r-- | src/sg_format.c | 6 | ||||
-rw-r--r-- | src/sg_inq.c | 6 | ||||
-rw-r--r-- | src/sg_logs.c | 28 | ||||
-rw-r--r-- | src/sg_luns.c | 2 | ||||
-rw-r--r-- | src/sg_persist.c | 21 | ||||
-rw-r--r-- | src/sg_rbuf.c | 10 | ||||
-rw-r--r-- | src/sg_read.c | 12 | ||||
-rw-r--r-- | src/sg_read_long.c | 8 | ||||
-rw-r--r-- | src/sg_readcap.c | 12 | ||||
-rw-r--r-- | src/sg_reassign.c | 16 | ||||
-rw-r--r-- | src/sg_sat_phy_event.c | 2 | ||||
-rw-r--r-- | src/sg_sync.c | 4 | ||||
-rw-r--r-- | src/sg_verify.c | 17 | ||||
-rw-r--r-- | src/sg_vpd.c | 6 | ||||
-rw-r--r-- | src/sg_write_long.c | 6 | ||||
-rw-r--r-- | src/sginfo.c | 6 | ||||
-rw-r--r-- | src/sgm_dd.c | 40 | ||||
-rw-r--r-- | src/sgp_dd.c | 48 |
19 files changed, 162 insertions, 164 deletions
diff --git a/src/sg_dd.c b/src/sg_dd.c index 81a89078..f1bd9f4d 100644 --- a/src/sg_dd.c +++ b/src/sg_dd.c @@ -113,13 +113,13 @@ static char * version_str = "5.63 20070714"; static int sum_of_resids = 0; -static long long dd_count = -1; -static long long req_count = 0; -static long long in_full = 0; +static int64_t dd_count = -1; +static int64_t req_count = 0; +static int64_t in_full = 0; static int in_partial = 0; -static long long out_full = 0; +static int64_t out_full = 0; static int out_partial = 0; -static long long out_sparse = 0; +static int64_t out_sparse = 0; static int recovered_errs = 0; static int unrecovered_errs = 0; static int read_longs = 0; @@ -331,7 +331,7 @@ static void usage() } /* Return of 0 -> success, see sg_ll_read_capacity*() otherwise */ -static int scsi_read_capacity(int sg_fd, long long * num_sect, int * sect_sz) +static int scsi_read_capacity(int sg_fd, int64_t * num_sect, int * sect_sz) { int k, res; unsigned int ui; @@ -345,7 +345,7 @@ static int scsi_read_capacity(int sg_fd, long long * num_sect, int * sect_sz) if ((0xff == rcBuff[0]) && (0xff == rcBuff[1]) && (0xff == rcBuff[2]) && (0xff == rcBuff[3])) { - long long ls; + int64_t ls; res = sg_ll_readcap_16(sg_fd, 0, 0, rcBuff, RCAP16_REPLY_LEN, 0, verb); @@ -362,7 +362,7 @@ static int scsi_read_capacity(int sg_fd, long long * num_sect, int * sect_sz) ui = ((rcBuff[0] << 24) | (rcBuff[1] << 16) | (rcBuff[2] << 8) | rcBuff[3]); /* take care not to sign extend values > 0x7fffffff */ - *num_sect = (long long)ui + 1; + *num_sect = (int64_t)ui + 1; *sect_sz = (rcBuff[4] << 24) | (rcBuff[5] << 16) | (rcBuff[6] << 8) | rcBuff[7]; } @@ -374,7 +374,7 @@ static int scsi_read_capacity(int sg_fd, long long * num_sect, int * sect_sz) /* Return of 0 -> success, -1 -> failure. BLKGETSIZE64, BLKGETSIZE and */ /* BLKSSZGET macros problematic (from <linux/fs.h> or <sys/mount.h>). */ -static int read_blkdev_capacity(int sg_fd, long long * num_sect, +static int read_blkdev_capacity(int sg_fd, int64_t * num_sect, int * sect_sz) { #ifdef BLKSSZGET @@ -383,14 +383,14 @@ static int read_blkdev_capacity(int sg_fd, long long * num_sect, return -1; } else { #ifdef BLKGETSIZE64 - unsigned long long ull; + uint64_t ull; if (ioctl(sg_fd, BLKGETSIZE64, &ull) < 0) { perror("BLKGETSIZE64 ioctl error"); return -1; } - *num_sect = ((long long)ull / (long long)*sect_sz); + *num_sect = ((int64_t)ull / (int64_t)*sect_sz); if (verbose) fprintf(stderr, " [bgs64] number of blocks=%lld [0x%llx], " "block size=%d\n", *num_sect, *num_sect, *sect_sz); @@ -401,7 +401,7 @@ static int read_blkdev_capacity(int sg_fd, long long * num_sect, perror("BLKGETSIZE ioctl error"); return -1; } - *num_sect = (long long)ul; + *num_sect = (int64_t)ul; if (verbose) fprintf(stderr, " [bgs] number of blocks=%lld [0x%llx], " " block size=%d\n", *num_sect, *num_sect, *sect_sz); @@ -418,7 +418,7 @@ static int read_blkdev_capacity(int sg_fd, long long * num_sect, } static int sg_build_scsi_cdb(unsigned char * cdbp, int cdb_sz, - unsigned int blocks, long long start_block, + unsigned int blocks, int64_t start_block, int write_true, int fua, int dpo) { int rd_opcode[] = {0x8, 0x28, 0xa8, 0x88}; @@ -517,9 +517,9 @@ static int sg_build_scsi_cdb(unsigned char * cdbp, int cdb_sz, -2 -> ENOMEM -1 other errors */ static int sg_read_low(int sg_fd, unsigned char * buff, int blocks, - long long from_block, int bs, + int64_t from_block, int bs, const struct flags_t * ifp, int * diop, - unsigned long long * io_addrp) + uint64_t * io_addrp) { unsigned char rdCmd[MAX_SCSI_CDBSZ]; unsigned char senseBuff[SENSE_BUFF_LEN]; @@ -623,11 +623,11 @@ static int sg_read_low(int sg_fd, unsigned char * buff, int blocks, SG_LIB_CAT_MEDIUM_HARD, SG_LIB_CAT_ABORTED_COMMAND, -2 -> ENOMEM, -1 other errors */ static int sg_read(int sg_fd, unsigned char * buff, int blocks, - long long from_block, int bs, struct flags_t * ifp, + int64_t from_block, int bs, struct flags_t * ifp, int * diop, int * blks_readp) { - unsigned long long io_addr; - long long lba; + uint64_t io_addr; + int64_t lba; int res, blks, repeat, xferred; unsigned char * bp; int retries_tmp; @@ -672,7 +672,7 @@ static int sg_read(int sg_fd, unsigned char * buff, int blocks, case SG_LIB_CAT_MEDIUM_HARD_WITH_INFO: if (retries_tmp > 0) { fprintf(stderr, ">>> retrying a sgio read, lba=0x%llx\n", - (unsigned long long)lba); + (uint64_t)lba); --retries_tmp; ++num_retries; if (unrecovered_errs > 0) @@ -692,7 +692,7 @@ static int sg_read(int sg_fd, unsigned char * buff, int blocks, default: if (retries_tmp > 0) { fprintf(stderr, ">>> retrying a sgio read, lba=0x%llx\n", - (unsigned long long)lba); + (uint64_t)lba); --retries_tmp; ++num_retries; if (unrecovered_errs > 0) @@ -705,15 +705,15 @@ static int sg_read(int sg_fd, unsigned char * buff, int blocks, } if (repeat) continue; - if ((io_addr < (unsigned long long)lba) || - (io_addr >= (unsigned long long)(lba + blks))) { + 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, - (unsigned long long)lba, - (unsigned long long)(lba + blks - 1)); + (uint64_t)lba, + (uint64_t)(lba + blks - 1)); goto err_out; } - blks = (int)(io_addr - (unsigned long long)lba); + blks = (int)(io_addr - (uint64_t)lba); if (blks > 0) { if (verbose) fprintf(stderr, " partial read of %d blocks prior to " @@ -869,14 +869,14 @@ err_out: SG_LIB_CAT_ABORTED_COMMAND, -2 -> recoverable (ENOMEM), -1 -> unrecoverable error + others */ static int sg_write(int sg_fd, unsigned char * buff, int blocks, - long long to_block, int bs, const struct flags_t * ofp, + int64_t to_block, int bs, const struct flags_t * ofp, int * diop) { unsigned char wrCmd[MAX_SCSI_CDBSZ]; unsigned char senseBuff[SENSE_BUFF_LEN]; struct sg_io_hdr io_hdr; int res, k, info_valid; - unsigned long long io_addr = 0; + uint64_t io_addr = 0; if (sg_build_scsi_cdb(wrCmd, ofp->cdbsz, blocks, to_block, 1, ofp->fua, ofp->dpo)) { @@ -964,7 +964,7 @@ static void calc_duration_throughput(int contin) { struct timeval end_tm, res_tm; double a, b; - long long blks; + int64_t blks; if (start_tm_valid && (start_tm.tv_sec || start_tm.tv_usec)) { blks = (in_full > out_full) ? in_full : out_full; @@ -1039,8 +1039,8 @@ static int process_flags(const char * arg, struct flags_t * fp) int main(int argc, char * argv[]) { - long long skip = 0; - long long seek = 0; + int64_t skip = 0; + int64_t seek = 0; int ibs = 0; int obs = 0; int bpt = DEF_BLOCKS_PER_TRANSFER; @@ -1061,8 +1061,8 @@ int main(int argc, char * argv[]) int infd, outfd, retries_tmp, blks_read; unsigned char * wrkBuff; unsigned char * wrkPos; - long long in_num_sect = -1; - long long out_num_sect = -1; + int64_t in_num_sect = -1; + int64_t out_num_sect = -1; int in_sect_sz, out_sect_sz; char ebuff[EBUFF_SZ]; int blocks_per; @@ -1338,7 +1338,7 @@ int main(int argc, char * argv[]) if (verbose) fprintf(stderr, " >> skip: lseek64 SEEK_SET, " "byte offset=0x%llx\n", - (unsigned long long)offset); + (uint64_t)offset); } } } @@ -1441,7 +1441,7 @@ int main(int argc, char * argv[]) if (verbose) fprintf(stderr, " >> seek: lseek64 SEEK_SET, " "byte offset=0x%llx\n", - (unsigned long long)offset); + (uint64_t)offset); } } } @@ -1701,18 +1701,18 @@ int main(int argc, char * argv[]) if (verbose > 2) fprintf(stderr, "sparse bypassing write: " "seek=%lld, rel offset=%lld\n", (seek * blk_sz), - (long long)offset); + (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 * blk_sz), (long long)offset); + (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", - (long long)off_res); + (int64_t)off_res); out_sparse += blocks; } } else if (FT_SG & out_type) { @@ -1760,7 +1760,7 @@ int main(int argc, char * argv[]) break; else if (retries_tmp > 0) { fprintf(stderr, ">>> retrying a sgio write, " - "lba=0x%llx\n", (unsigned long long)seek); + "lba=0x%llx\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 bdfb1a25..6064ae69 100644 --- a/src/sg_format.c +++ b/src/sg_format.c @@ -189,7 +189,7 @@ print_read_cap(int fd, int do_16, int verbose) int res, k; unsigned char resp_buff[RCAP_REPLY_LEN]; unsigned int last_blk_addr, block_size; - unsigned long long llast_blk_addr; + uint64_t llast_blk_addr; if (do_16) { res = sg_ll_readcap_16(fd, 0 /* pmi */, 0 /* llba */, @@ -309,8 +309,8 @@ int main(int argc, char **argv) const int mode_page = THIS_MPAGE_EXISTS; /* hopefully */ int fd, res, calc_len, bd_len, dev_specific_param; int offset, j, bd_blk_len, prob, len; - unsigned long long ull; - long long blk_count = 0; /* -c value */ + uint64_t ull; + int64_t blk_count = 0; /* -c value */ int blk_size = 0; /* -s value */ int format = 0; /* -F */ int resize = 0; /* -r */ diff --git a/src/sg_inq.c b/src/sg_inq.c index a04718ce..2df3a9a0 100644 --- a/src/sg_inq.c +++ b/src/sg_inq.c @@ -885,8 +885,8 @@ static void decode_dev_ids(const char * leadin, unsigned char * buff, { int u, j, m, id_len, p_id, c_set, piv, assoc, id_type, i_len; int off, ci_off, c_id, d_id, naa, vsi; - unsigned long long vsei; - unsigned long long id_ext; + uint64_t vsei; + uint64_t id_ext; const unsigned char * ucp; const unsigned char * ip; @@ -1125,7 +1125,7 @@ static void decode_transport_id(const char * leadin, unsigned char * ucp, int len) { int format_code, proto_id, num, j, k; - unsigned long long ull; + uint64_t ull; int bump; for (k = 0, bump = 24; k < len; k += bump, ucp += bump) { diff --git a/src/sg_logs.c b/src/sg_logs.c index a3a710d2..b984ea7a 100644 --- a/src/sg_logs.c +++ b/src/sg_logs.c @@ -25,7 +25,7 @@ */ -static char * version_str = "0.78 20071217"; /* SPC-4 revision 11 */ +static char * version_str = "0.77 20070923"; /* SPC-4 revision 11 */ #define MX_ALLOC_LEN (0xfffc) #define SHORT_RESP_LEN 128 @@ -816,7 +816,7 @@ show_buffer_under_overrun_page(unsigned char * resp, int len, int show_pcb) int k, j, num, pl, count_basis, cause, pcb; unsigned char * ucp; unsigned char * xp; - unsigned long long ull; + uint64_t ull; char pcb_str[PCB_STR_LEN]; printf("Buffer over-run/under-run page\n"); @@ -881,7 +881,7 @@ show_error_counter_page(unsigned char * resp, int len, int show_pcb) int k, j, num, pl, pc, pcb; unsigned char * ucp; unsigned char * xp; - unsigned long long ull; + uint64_t ull; char pcb_str[PCB_STR_LEN]; switch(resp[0] & 0x3f) { @@ -948,7 +948,7 @@ show_non_medium_error_page(unsigned char * resp, int len, int show_pcb) int k, j, num, pl, pc, pcb; unsigned char * ucp; unsigned char * xp; - unsigned long long ull; + uint64_t ull; char pcb_str[PCB_STR_LEN]; printf("Non-medium error page\n"); @@ -1086,7 +1086,7 @@ show_self_test_page(unsigned char * resp, int len, int show_pcb) { int k, num, n, res, pcb; unsigned char * ucp; - unsigned long long ull; + uint64_t ull; char pcb_str[PCB_STR_LEN]; num = len - 4; @@ -1441,7 +1441,7 @@ show_sas_rel_target_port(unsigned char * ucp, int param_len, { int j, m, n, nphys, pcb, t, sz, spld_len; unsigned char * vcp; - unsigned long long ull; + uint64_t ull; unsigned long ul; char pcb_str[PCB_STR_LEN]; char s[64]; @@ -1456,7 +1456,7 @@ show_sas_rel_target_port(unsigned char * ucp, int param_len, if (optsp->do_name) printf(" gen_code=%d\n", ucp[6]); else - printf(" generation code = %d\n", ucp[6]); + printf(" generation code = %d\n", ucp[6]); nphys = ucp[7]; if (optsp->do_name) printf(" num_phys=%d\n", nphys); @@ -1652,7 +1652,7 @@ show_stats_perform_page(unsigned char * resp, int len, int pcb, nam; unsigned char * ucp; const char * ccp; - unsigned long long ull; + uint64_t ull; char pcb_str[PCB_STR_LEN]; nam = optsp->do_name; @@ -1958,7 +1958,7 @@ show_format_status_page(unsigned char * resp, int len, int show_pcb) int k, j, num, pl, pc, pcb, all_ff, counter; unsigned char * ucp; unsigned char * xp; - unsigned long long ull; + uint64_t ull; char pcb_str[PCB_STR_LEN]; printf("Format status page (sbc-2) [0x8]\n"); @@ -2223,7 +2223,7 @@ show_sequential_access_page(unsigned char * resp, int len, int show_pcb, int k, j, num, pl, pc, pcb; unsigned char * ucp; unsigned char * xp; - unsigned long long ull, gbytes; + uint64_t ull, gbytes; char pcb_str[PCB_STR_LEN]; printf("Sequential access device page (ssc-3)\n"); @@ -2328,7 +2328,7 @@ show_device_stats_page(unsigned char * resp, int len, int show_pcb) int k, j, num, pl, pc, pcb; unsigned char * ucp; unsigned char * xp; - unsigned long long ull; + uint64_t ull; char pcb_str[PCB_STR_LEN]; printf("Device statistics page (ssc-3 and adc)\n"); @@ -2432,7 +2432,7 @@ show_media_stats_page(unsigned char * resp, int len, int show_pcb) int k, j, num, pl, pc, pcb; unsigned char * ucp; unsigned char * xp; - unsigned long long ull; + uint64_t ull; char pcb_str[PCB_STR_LEN]; printf("Media statistics page (smc-3)\n"); @@ -2774,7 +2774,7 @@ show_seagate_cache_page(unsigned char * resp, int len, int show_pcb) int k, j, num, pl, pc, pcb; unsigned char * ucp; unsigned char * xp; - unsigned long long ull; + uint64_t ull; char pcb_str[PCB_STR_LEN]; printf("Seagate cache page [0x37]\n"); @@ -2823,7 +2823,7 @@ show_seagate_factory_page(unsigned char * resp, int len, int show_pcb) int k, j, num, pl, pc, pcb, valid; unsigned char * ucp; unsigned char * xp; - unsigned long long ull; + uint64_t ull; char pcb_str[PCB_STR_LEN]; printf("Seagate/Hitachi factory page [0x3e]\n"); diff --git a/src/sg_luns.c b/src/sg_luns.c index 109eb53e..9a5b07fb 100644 --- a/src/sg_luns.c +++ b/src/sg_luns.c @@ -101,7 +101,7 @@ static void decode_lun(const char * leadin, unsigned char * lunp) unsigned char not_spec[8] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; char l_leadin[128]; - unsigned long long ull; + uint64_t ull; if (0 == memcmp(lunp, not_spec, sizeof(not_spec))) { printf("%sLogical unit not specified\n", leadin); diff --git a/src/sg_persist.c b/src/sg_persist.c index 920b37b4..e5e52698 100644 --- a/src/sg_persist.c +++ b/src/sg_persist.c @@ -27,7 +27,7 @@ */ -static char * version_str = "0.33 20070919"; +static char * version_str = "0.33 20071219"; #define PRIN_RKEY_SA 0x0 @@ -175,7 +175,7 @@ static void decode_transport_id(const char * leadin, unsigned char * ucp, int len) { int format_code, proto_id, num, j, k; - unsigned long long ull; + uint64_t ull; int bump; for (k = 0, bump = 24; k < len; k += bump, ucp += bump) { @@ -280,7 +280,7 @@ static int prin_work(int sg_fd, int prin_sa, int do_verbose, int do_hex) { int k, j, num, res, add_len, add_desc_len, rel_pt_addr; unsigned int pr_gen; - unsigned long long ull; + uint64_t ull; unsigned char * ucp; unsigned char pr_buff[MX_ALLOC_LEN]; @@ -440,10 +440,10 @@ static int prin_work(int sg_fd, int prin_sa, int do_verbose, int do_hex) } static int prout_work(int sg_fd, int prout_sa, unsigned int prout_type, - unsigned long long param_rk, - unsigned long long param_sark, int param_alltgpt, - int param_aptpl, unsigned char * transportidp, - int transportid_len, int do_verbose) + uint64_t param_rk, uint64_t param_sark, + int param_alltgpt, int param_aptpl, + unsigned char * transportidp, int transportid_len, + int do_verbose) { int j, len, res; unsigned char pr_buff[MX_ALLOC_LEN]; @@ -499,8 +499,7 @@ static int prout_work(int sg_fd, int prout_sa, unsigned int prout_type, } static int prout_rmove_work(int sg_fd, unsigned int prout_type, - unsigned long long param_rk, - unsigned long long param_sark, int param_unreg, + uint64_t param_rk, uint64_t param_sark, int param_unreg, int param_aptpl, unsigned int rel_target_port, unsigned char * transportidp, int transportid_len, int do_verbose) @@ -690,8 +689,8 @@ int main(int argc, char * argv[]) { int sg_fd, c, res; unsigned int prout_type; - unsigned long long param_rk = 0; - unsigned long long param_sark = 0; + uint64_t param_rk = 0; + uint64_t param_sark = 0; unsigned int param_rtp = 0; const char * device_name = NULL; char buff[48]; diff --git a/src/sg_rbuf.c b/src/sg_rbuf.c index 7e7a0397..07aab0ea 100644 --- a/src/sg_rbuf.c +++ b/src/sg_rbuf.c @@ -74,7 +74,7 @@ struct opts_t { int do_help; int do_mmap; int do_quick; - long long do_size; + int64_t do_size; int do_time; int do_verbose; int do_version; @@ -134,7 +134,7 @@ static void usage_for(const struct opts_t * optsp) static int process_cl_new(struct opts_t * optsp, int argc, char * argv[]) { int c, n; - long long nn; + int64_t nn; while (1) { int option_index = 0; @@ -217,7 +217,7 @@ static int process_cl_new(struct opts_t * optsp, int argc, char * argv[]) static int process_cl_old(struct opts_t * optsp, int argc, char * argv[]) { int k, jmp_out, plen, num; - long long nn; + int64_t nn; const char * cp; for (k = 1; k < argc; ++k) { @@ -332,7 +332,7 @@ int main(int argc, char * argv[]) unsigned char sense_buffer[32]; int buf_capacity = 0; int buf_size = 0; - long long total_size = RB_DEF_SIZE; + int64_t total_size = RB_DEF_SIZE; size_t psz = getpagesize(); int dio_incomplete = 0; struct sg_io_hdr io_hdr; @@ -602,7 +602,7 @@ int main(int argc, char * argv[]) printf(">> direct IO requested but not done\n"); printf("Read %lld MiB (actual: %lld bytes), buffer size=%d KiB " "(%d bytes)\n", (total_size / (1024 * 1024)), - (long long)num * buf_size, buf_size / 1024, buf_size); + (int64_t)num * buf_size, buf_size / 1024, buf_size); if (rawp) free(rawp); res = close(sg_fd); diff --git a/src/sg_read.c b/src/sg_read.c index c8accc4b..2da4a102 100644 --- a/src/sg_read.c +++ b/src/sg_read.c @@ -75,9 +75,9 @@ static const char * version_str = "1.17 20070714"; static int sum_of_resids = 0; -static long long dd_count = -1; -static long long orig_count = 0; -static long long in_full = 0; +static int64_t dd_count = -1; +static int64_t orig_count = 0; +static int64_t in_full = 0; static int in_partial = 0; static int pack_id_count = 0; @@ -198,7 +198,7 @@ static void usage() } static int sg_build_scsi_cdb(unsigned char * cdbp, int cdb_sz, - unsigned int blocks, long long start_block, + unsigned int blocks, int64_t start_block, int write_true, int fua, int dpo) { int rd_opcode[] = {0x8, 0x28, 0xa8, 0x88}; @@ -293,7 +293,7 @@ static int sg_build_scsi_cdb(unsigned char * cdbp, int cdb_sz, 1 -> recoverable (ENOMEM), 2 -> try again (e.g. unit attention), 3 -> try again (e.g. aborted command), -1 -> other unrecoverable error */ static int sg_bread(int sg_fd, unsigned char * buff, int blocks, - long long from_block, int bs, int cdbsz, + int64_t from_block, int bs, int cdbsz, int fua, int dpo, int * diop, int do_mmap, int no_dxfer) { @@ -387,7 +387,7 @@ static int sg_bread(int sg_fd, unsigned char * buff, int blocks, int main(int argc, char * argv[]) { - long long skip = 0; + int64_t skip = 0; int bs = 0; int bpt = DEF_BLOCKS_PER_TRANSFER; char str[STR_SZ]; diff --git a/src/sg_read_long.c b/src/sg_read_long.c index fef37cc8..7dc4dd2d 100644 --- a/src/sg_read_long.c +++ b/src/sg_read_long.c @@ -80,7 +80,7 @@ static void usage() /* Returns 0 if successful */ static int process_read_long(int sg_fd, int do_16, int pblock, int correct, - unsigned long long llba, void * data_out, + uint64_t llba, void * data_out, int xfer_len, int verbose) { int offset, res; @@ -137,9 +137,9 @@ int main(int argc, char * argv[]) int xfer_len = 520; int do_16 = 0; int pblock = 0; - unsigned long long llba = 0; + uint64_t llba = 0; int verbose = 0; - long long ll; + int64_t ll; int got_stdout; const char * device_name = NULL; char out_fname[256]; @@ -169,7 +169,7 @@ int main(int argc, char * argv[]) fprintf(stderr, "bad argument to '--lba'\n"); return SG_LIB_SYNTAX_ERROR; } - llba = (unsigned long long)ll; + llba = (uint64_t)ll; break; case 'o': strncpy(out_fname, optarg, sizeof(out_fname) - 1); diff --git a/src/sg_readcap.c b/src/sg_readcap.c index 3a9bb6a2..39dfba8f 100644 --- a/src/sg_readcap.c +++ b/src/sg_readcap.c @@ -60,7 +60,7 @@ struct opts_t { int do_raw; int do_verbose; int do_version; - unsigned long long llba; + uint64_t llba; const char * device_name; int opt_new; }; @@ -128,7 +128,7 @@ static int process_cl_new(struct opts_t * optsp, int argc, char * argv[]) { int c; int a_one = 0; - long long nn; + int64_t nn; while (1) { int option_index = 0; @@ -217,7 +217,7 @@ static int process_cl_old(struct opts_t * optsp, int argc, char * argv[]) { int k, jmp_out, plen, num; const char * cp; - unsigned long long uu; + uint64_t uu; for (k = 1; k < argc; ++k) { cp = argv[k]; @@ -338,7 +338,7 @@ static void dStrRaw(const char* str, int len) int main(int argc, char * argv[]) { int sg_fd, k, res; - unsigned long long llast_blk_addr; + uint64_t llast_blk_addr; int ret = 0; unsigned int last_blk_addr, block_size; unsigned char resp_buff[RCAP16_REPLY_LEN]; @@ -408,7 +408,7 @@ int main(int argc, char * argv[]) last_blk_addr + 1); printf(" Logical block length=%u bytes\n", block_size); if (! opts.do_pmi) { - unsigned long long total_sz = last_blk_addr + 1; + uint64_t total_sz = last_blk_addr + 1; double sz_mb, sz_gb; total_sz *= block_size; @@ -494,7 +494,7 @@ int main(int argc, char * argv[]) printf(" Lowest aligned logical block address=%d\n", ((resp_buff[14] & 0x3f) << 8) + resp_buff[15]); if (! opts.do_pmi) { - unsigned long long total_sz = llast_blk_addr + 1; + uint64_t total_sz = llast_blk_addr + 1; double sz_mb, sz_gb; total_sz *= block_size; diff --git a/src/sg_reassign.c b/src/sg_reassign.c index fd0b6ba8..c77ad1a7 100644 --- a/src/sg_reassign.c +++ b/src/sg_reassign.c @@ -119,12 +119,12 @@ usage() /* Trying to decode multipliers as sg_get_llnum() [in sg_libs does] would * only confuse things here, so use this local trimmed version */ -long long +int64_t get_llnum(const char * buf) { int res, len; - long long num; - unsigned long long unum; + int64_t num; + uint64_t unum; const char * commap; if ((NULL == buf) || ('\0' == buf[0])) @@ -154,12 +154,12 @@ get_llnum(const char * buf) /* or contains trailing 'h' or 'H' (which indicate hex). */ /* Returns 0 if ok, or 1 if error. */ static int -build_lba_arr(const char * inp, unsigned long long * lba_arr, +build_lba_arr(const char * inp, uint64_t * lba_arr, int * lba_arr_len, int max_arr_len) { int in_len, k, j, m; const char * lcp; - long long ll; + int64_t ll; char * cp; if ((NULL == inp) || (NULL == lba_arr) || @@ -207,7 +207,7 @@ build_lba_arr(const char * inp, unsigned long long * lba_arr, "exceeded\n"); return 1; } - lba_arr[off + k] = (unsigned long long)ll; + lba_arr[off + k] = (uint64_t)ll; lcp = strpbrk(lcp, " ,\t"); if (NULL == lcp) break; @@ -237,7 +237,7 @@ build_lba_arr(const char * inp, unsigned long long * lba_arr, for (k = 0; k < max_arr_len; ++k) { ll = get_llnum(lcp); if (-1 != ll) { - lba_arr[k] = (unsigned long long)ll; + lba_arr[k] = (uint64_t)ll; cp = strchr(lcp, ','); if (NULL == cp) break; @@ -272,7 +272,7 @@ main(int argc, char * argv[]) int primary = 0; int verbose = 0; const char * device_name = NULL; - unsigned long long addr_arr[MAX_NUM_ADDR]; + uint64_t addr_arr[MAX_NUM_ADDR]; unsigned char param_arr[4 + (MAX_NUM_ADDR * 8)]; int param_len = 4; int ret = 0; diff --git a/src/sg_sat_phy_event.c b/src/sg_sat_phy_event.c index 1f895ff1..fcd85542 100644 --- a/src/sg_sat_phy_event.c +++ b/src/sg_sat_phy_event.c @@ -348,7 +348,7 @@ int main(int argc, char * argv[]) int ck_cond = 0; /* set to 1 to read register(s) back */ int extend = 0; int ret = 0; - unsigned long long ull; + uint64_t ull; const char * cp; memset(inBuff, 0, sizeof(inBuff)); diff --git a/src/sg_sync.c b/src/sg_sync.c index 31eb2d8d..b821b572 100644 --- a/src/sg_sync.c +++ b/src/sg_sync.c @@ -94,9 +94,9 @@ static void usage() int main(int argc, char * argv[]) { int sg_fd, res, c; - long long count = 0; + int64_t count = 0; int group = 0; - long long lba = 0; + int64_t lba = 0; int immed = 0; int sync_nv = 0; int verbose = 0; diff --git a/src/sg_verify.c b/src/sg_verify.c index 75afa1fd..4d4da21c 100644 --- a/src/sg_verify.c +++ b/src/sg_verify.c @@ -48,7 +48,7 @@ * This program issues the SCSI VERIFY command to the given SCSI block device. */ -static char * version_str = "1.11 20071102"; +static char * version_str = "1.11 20071219"; #define ME "sg_verify: " @@ -95,15 +95,15 @@ int main(int argc, char * argv[]) { int sg_fd, res, c, num; - long long ll; + int64_t ll; int dpo = 0; int bytechk = 0; int vrprotect = 0; - long long count = 1; - long long orig_count; + int64_t count = 1; + int64_t orig_count; int bpc = 128; - unsigned long long lba = 0; - unsigned long long orig_lba; + uint64_t lba = 0; + uint64_t orig_lba; int verbose = 0; const char * device_name = NULL; int ret = 0; @@ -145,7 +145,7 @@ main(int argc, char * argv[]) fprintf(stderr, "bad argument to '--lba'\n"); return SG_LIB_SYNTAX_ERROR; } - lba = (unsigned long long)ll; + lba = (uint64_t)ll; break; case 'P': vrprotect = sg_get_num(optarg); @@ -253,8 +253,7 @@ 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", - orig_count, (unsigned long long)orig_count, orig_lba, - orig_lba); + orig_count, (uint64_t)orig_count, orig_lba, orig_lba); res = sg_cmds_close_device(sg_fd); if (res < 0) { diff --git a/src/sg_vpd.c b/src/sg_vpd.c index 33c68d34..58dbcea6 100644 --- a/src/sg_vpd.c +++ b/src/sg_vpd.c @@ -677,8 +677,8 @@ decode_dev_ids(const char * print_if_found, unsigned char * buff, int len, { int m, p_id, c_set, piv, assoc, desig_type, i_len; int ci_off, c_id, d_id, naa, vsi, printed, off, u; - unsigned long long vsei; - unsigned long long id_ext; + uint64_t vsei; + uint64_t id_ext; const unsigned char * ucp; const unsigned char * ip; @@ -950,7 +950,7 @@ static void decode_transport_id(const char * leadin, unsigned char * ucp, int len) { int format_code, proto_id, num, j, k; - unsigned long long ull; + uint64_t ull; int bump; for (k = 0, bump= 24; k < len; k += bump, ucp += bump) { diff --git a/src/sg_write_long.c b/src/sg_write_long.c index 4e6112fc..e32df43a 100644 --- a/src/sg_write_long.c +++ b/src/sg_write_long.c @@ -96,9 +96,9 @@ int main(int argc, char * argv[]) int pblock = 0; int wr_uncor = 0; int do_16 = 0; - unsigned long long llba = 0; + uint64_t llba = 0; int verbose = 0; - long long ll; + int64_t ll; int got_stdin; const char * device_name = NULL; char file_name[256]; @@ -132,7 +132,7 @@ int main(int argc, char * argv[]) fprintf(stderr, "bad argument to '--lba'\n"); return SG_LIB_SYNTAX_ERROR; } - llba = (unsigned long long)ll; + llba = (uint64_t)ll; break; case 'p': pblock = 1; diff --git a/src/sginfo.c b/src/sginfo.c index c4ee5fca..634f90c4 100644 --- a/src/sginfo.c +++ b/src/sginfo.c @@ -346,7 +346,7 @@ static char * transport_proto_arr[] = static int next_parameter; static int n_replacement_values; -static unsigned long long replacement_values[MAXPARM]; +static uint64_t replacement_values[MAXPARM]; static char is_hex[MAXPARM]; #define SMODE_SENSE 0x1a @@ -604,9 +604,9 @@ static int getnbyte(const unsigned char *pnt, int nbyte) return result; } -static long long getnbyte_ll(const unsigned char *pnt, int nbyte) +static int64_t getnbyte_ll(const unsigned char *pnt, int nbyte) { - long long result; + int64_t result; int i; if (nbyte > 8) diff --git a/src/sgm_dd.c b/src/sgm_dd.c index 3639a150..9a296821 100644 --- a/src/sgm_dd.c +++ b/src/sgm_dd.c @@ -113,11 +113,11 @@ static char * version_str = "1.33 20070728 shared_mmap"; static int sum_of_resids = 0; -static long long dd_count = -1; -static long long req_count = 0; -static long long in_full = 0; +static int64_t dd_count = -1; +static int64_t req_count = 0; +static int64_t in_full = 0; static int in_partial = 0; -static long long out_full = 0; +static int64_t out_full = 0; static int out_partial = 0; static int verbose = 0; @@ -308,7 +308,7 @@ void usage() } /* Return of 0 -> success, see sg_ll_read_capacity*() otherwise */ -int scsi_read_capacity(int sg_fd, long long * num_sect, int * sect_sz) +int scsi_read_capacity(int sg_fd, int64_t * num_sect, int * sect_sz) { int k, res; unsigned int ui; @@ -323,7 +323,7 @@ int scsi_read_capacity(int sg_fd, long long * num_sect, int * sect_sz) if ((0xff == rcBuff[0]) && (0xff == rcBuff[1]) && (0xff == rcBuff[2]) && (0xff == rcBuff[3])) { - long long ls; + int64_t ls; res = sg_ll_readcap_16(sg_fd, 0, 0, rcBuff, RCAP16_REPLY_LEN, 0, verb); @@ -340,7 +340,7 @@ int scsi_read_capacity(int sg_fd, long long * num_sect, int * sect_sz) ui = ((rcBuff[0] << 24) | (rcBuff[1] << 16) | (rcBuff[2] << 8) | rcBuff[3]); /* take care not to sign extend values > 0x7fffffff */ - *num_sect = (long long)ui + 1; + *num_sect = (int64_t)ui + 1; *sect_sz = (rcBuff[4] << 24) | (rcBuff[5] << 16) | (rcBuff[6] << 8) | rcBuff[7]; } @@ -352,7 +352,7 @@ int scsi_read_capacity(int sg_fd, long long * num_sect, int * sect_sz) /* Return of 0 -> success, -1 -> failure. BLKGETSIZE64, BLKGETSIZE and */ /* BLKSSZGET macros problematic (from <linux/fs.h> or <sys/mount.h>). */ -int read_blkdev_capacity(int sg_fd, long long * num_sect, int * sect_sz) +int read_blkdev_capacity(int sg_fd, int64_t * num_sect, int * sect_sz) { #ifdef BLKSSZGET if ((ioctl(sg_fd, BLKSSZGET, sect_sz) < 0) && (*sect_sz > 0)) { @@ -360,14 +360,14 @@ int read_blkdev_capacity(int sg_fd, long long * num_sect, int * sect_sz) return -1; } else { #ifdef BLKGETSIZE64 - unsigned long long ull; + uint64_t ull; if (ioctl(sg_fd, BLKGETSIZE64, &ull) < 0) { perror("BLKGETSIZE64 ioctl error"); return -1; } - *num_sect = ((long long)ull / (long long)*sect_sz); + *num_sect = ((int64_t)ull / (int64_t)*sect_sz); if (verbose) fprintf(stderr, " [bgs64] number of blocks=%lld [0x%llx], " "block size=%d\n", *num_sect, *num_sect, *sect_sz); @@ -378,7 +378,7 @@ int read_blkdev_capacity(int sg_fd, long long * num_sect, int * sect_sz) perror("BLKGETSIZE ioctl error"); return -1; } - *num_sect = (long long)ul; + *num_sect = (int64_t)ul; if (verbose) fprintf(stderr, " [bgs] number of blocks=%lld [0x%llx], " " block size=%d\n", *num_sect, *num_sect, *sect_sz); @@ -395,7 +395,7 @@ int read_blkdev_capacity(int sg_fd, long long * num_sect, int * sect_sz) } int sg_build_scsi_cdb(unsigned char * cdbp, int cdb_sz, unsigned int blocks, - long long start_block, int write_true, int fua, + int64_t start_block, int write_true, int fua, int dpo) { int rd_opcode[] = {0x8, 0x28, 0xa8, 0x88}; @@ -490,7 +490,7 @@ int sg_build_scsi_cdb(unsigned char * cdbp, int cdb_sz, unsigned int blocks, * SG_LIB_CAT_NOT_READY, SG_LIB_CAT_MEDIUM_HARD, SG_LIB_CAT_ILLEGAL_REQ, * SG_LIB_CAT_ABORTED_COMMAND, -2 -> recoverable (ENOMEM), * -1 -> unrecoverable error */ -int sg_read(int sg_fd, unsigned char * buff, int blocks, long long from_block, +int sg_read(int sg_fd, unsigned char * buff, int blocks, int64_t from_block, int bs, int cdbsz, int fua, int dpo, int do_mmap) { unsigned char rdCmd[MAX_SCSI_CDBSZ]; @@ -580,7 +580,7 @@ int sg_read(int sg_fd, unsigned char * buff, int blocks, long long from_block, * SG_LIB_CAT_NOT_READY, SG_LIB_CAT_MEDIUM_HARD, SG_LIB_CAT_ILLEGAL_REQ, * SG_LIB_CAT_ABORTED_COMMAND, -2 -> recoverable (ENOMEM), * -1 -> unrecoverable error */ -int sg_write(int sg_fd, unsigned char * buff, int blocks, long long to_block, +int sg_write(int sg_fd, unsigned char * buff, int blocks, int64_t to_block, int bs, int cdbsz, int fua, int dpo, int do_mmap, int mmap_shareable, int * diop) { @@ -726,8 +726,8 @@ static int process_flags(const char * arg, struct flags_t * fp) int main(int argc, char * argv[]) { - long long skip = 0; - long long seek = 0; + int64_t skip = 0; + int64_t seek = 0; int ibs = 0; int obs = 0; int bpt = DEF_BLOCKS_PER_TRANSFER; @@ -744,9 +744,9 @@ int main(int argc, char * argv[]) unsigned char * wrkPos; unsigned char * wrkBuff = NULL; unsigned char * wrkMmap = NULL; - long long in_num_sect = -1; + int64_t in_num_sect = -1; int in_res_sz = 0; - long long out_num_sect = -1; + int64_t out_num_sect = -1; int out_res_sz = 0; int scsi_cdbsz_in = DEF_SCSI_CDBSZ; int scsi_cdbsz_out = DEF_SCSI_CDBSZ; @@ -998,7 +998,7 @@ int main(int argc, char * argv[]) if (verbose) fprintf(stderr, " >> skip: lseek64 SEEK_SET, " "byte offset=0x%llx\n", - (unsigned long long)offset); + (uint64_t)offset); } } } @@ -1097,7 +1097,7 @@ int main(int argc, char * argv[]) if (verbose) fprintf(stderr, " >> seek: lseek64 SEEK_SET, " "byte offset=0x%llx\n", - (unsigned long long)offset); + (uint64_t)offset); } } } diff --git a/src/sgp_dd.c b/src/sgp_dd.c index bb3300df..4d7f9a7e 100644 --- a/src/sgp_dd.c +++ b/src/sgp_dd.c @@ -114,24 +114,24 @@ struct flags_t { typedef struct request_collection { /* one instance visible to all threads */ int infd; - long long skip; + int64_t skip; int in_type; int cdbsz_in; struct flags_t in_flags; - long long in_blk; /* -\ next block address to read */ - long long in_count; /* | blocks remaining for next read */ - long long in_rem_count; /* | count of remaining in blocks */ + int64_t in_blk; /* -\ next block address to read */ + int64_t in_count; /* | blocks remaining for next read */ + int64_t in_rem_count; /* | count of remaining in blocks */ int in_partial; /* | */ int in_stop; /* | */ pthread_mutex_t in_mutex; /* -/ */ int outfd; - long long seek; + int64_t seek; int out_type; int cdbsz_out; struct flags_t out_flags; - long long out_blk; /* -\ next block address to write */ - long long out_count; /* | blocks remaining for next write */ - long long out_rem_count; /* | count of remaining out blocks */ + int64_t out_blk; /* -\ next block address to write */ + int64_t out_count; /* | blocks remaining for next write */ + int64_t out_rem_count; /* | count of remaining out blocks */ int out_partial; /* | */ int out_stop; /* | */ pthread_mutex_t out_mutex; /* | */ @@ -149,7 +149,7 @@ typedef struct request_element int infd; int outfd; int wr; - long long blk; + int64_t blk; int num_blks; unsigned char * buffp; unsigned char * alloc_bp; @@ -185,7 +185,7 @@ static pthread_mutex_t strerr_mut = PTHREAD_MUTEX_INITIALIZER; static int do_time = 0; static Rq_coll rcoll; static struct timeval start_tm; -static long long dd_count = -1; +static int64_t dd_count = -1; static int num_threads = DEF_NUM_THREADS; static int do_sync = 0; static int exit_status = 0; @@ -217,7 +217,7 @@ static void calc_duration_throughput(int contin) static void print_stats(const char * str) { - long long infull, outfull; + int64_t infull, outfull; if (0 != rcoll.out_rem_count) fprintf(stderr, " remaining block count=%lld\n", @@ -388,7 +388,7 @@ static void guarded_stop_both(Rq_coll * clp) } /* Return of 0 -> success, see sg_ll_read_capacity*() otherwise */ -static int scsi_read_capacity(int sg_fd, long long * num_sect, int * sect_sz) +static int scsi_read_capacity(int sg_fd, int64_t * num_sect, int * sect_sz) { int k, res; unsigned int ui; @@ -400,7 +400,7 @@ static int scsi_read_capacity(int sg_fd, long long * num_sect, int * sect_sz) if ((0xff == rcBuff[0]) && (0xff == rcBuff[1]) && (0xff == rcBuff[2]) && (0xff == rcBuff[3])) { - long long ls; + int64_t ls; res = sg_ll_readcap_16(sg_fd, 0, 0, rcBuff, RCAP16_REPLY_LEN, 0, 0); if (0 != res) @@ -416,7 +416,7 @@ static int scsi_read_capacity(int sg_fd, long long * num_sect, int * sect_sz) ui = ((rcBuff[0] << 24) | (rcBuff[1] << 16) | (rcBuff[2] << 8) | rcBuff[3]); /* take care not to sign extend values > 0x7fffffff */ - *num_sect = (long long)ui + 1; + *num_sect = (int64_t)ui + 1; *sect_sz = (rcBuff[4] << 24) | (rcBuff[5] << 16) | (rcBuff[6] << 8) | rcBuff[7]; } @@ -425,7 +425,7 @@ static int scsi_read_capacity(int sg_fd, long long * num_sect, int * sect_sz) /* Return of 0 -> success, -1 -> failure. BLKGETSIZE64, BLKGETSIZE and */ /* BLKSSZGET macros problematic (from <linux/fs.h> or <sys/mount.h>). */ -static int read_blkdev_capacity(int sg_fd, long long * num_sect, int * sect_sz) +static int read_blkdev_capacity(int sg_fd, int64_t * num_sect, int * sect_sz) { #ifdef BLKSSZGET if ((ioctl(sg_fd, BLKSSZGET, sect_sz) < 0) && (*sect_sz > 0)) { @@ -433,14 +433,14 @@ static int read_blkdev_capacity(int sg_fd, long long * num_sect, int * sect_sz) return -1; } else { #ifdef BLKGETSIZE64 - unsigned long long ull; + uint64_t ull; if (ioctl(sg_fd, BLKGETSIZE64, &ull) < 0) { perror("BLKGETSIZE64 ioctl error"); return -1; } - *num_sect = ((long long)ull / (long long)*sect_sz); + *num_sect = ((int64_t)ull / (int64_t)*sect_sz); #else unsigned long ul; @@ -448,7 +448,7 @@ static int read_blkdev_capacity(int sg_fd, long long * num_sect, int * sect_sz) perror("BLKGETSIZE ioctl error"); return -1; } - *num_sect = (long long)ul; + *num_sect = (int64_t)ul; #endif } return 0; @@ -505,7 +505,7 @@ static void * read_write_thread(void * v_clp) size_t psz = 0; int sz = clp->bpt * clp->bs; int stop_after_write = 0; - long long seek_skip = clp->seek - clp->skip; + int64_t seek_skip = clp->seek - clp->skip; int blocks, status; memset(rep, 0, sizeof(Rq_elem)); @@ -699,7 +699,7 @@ static void normal_out_operation(Rq_coll * clp, Rq_elem * rep, int blocks) } static int sg_build_scsi_cdb(unsigned char * cdbp, int cdb_sz, - unsigned int blocks, long long start_block, + unsigned int blocks, int64_t start_block, int write_true, int fua, int dpo) { int rd_opcode[] = {0x8, 0x28, 0xa8, 0x88}; @@ -1119,8 +1119,8 @@ static int process_flags(const char * arg, struct flags_t * fp) int main(int argc, char * argv[]) { - long long skip = 0; - long long seek = 0; + int64_t skip = 0; + int64_t seek = 0; int ibs = 0; int obs = 0; int bpt_given = 0; @@ -1131,8 +1131,8 @@ int main(int argc, char * argv[]) char inf[INOUTF_SZ]; char outf[INOUTF_SZ]; int res, k; - long long in_num_sect = 0; - long long out_num_sect = 0; + int64_t in_num_sect = 0; + int64_t out_num_sect = 0; pthread_t threads[MAX_NUM_THREADS]; int in_sect_sz, out_sect_sz, status, n, flags; void * vp; |