aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2007-12-19 16:35:49 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2007-12-19 16:35:49 +0000
commitb4530ba23ca6fb39e2bbf56afa4fdc892bf16910 (patch)
tree6a1ad36741c45c218f6ba11001c8260b18e4a09a
parent2fdbef700da5c71ab2eaf80547704d03e7a93f91 (diff)
downloadsg3_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
-rw-r--r--CREDITS5
-rw-r--r--ChangeLog4
-rw-r--r--README2
-rw-r--r--archive/llseek.c6
-rw-r--r--archive/llseek.h2
-rw-r--r--debian/changelog2
-rw-r--r--examples/sg__sat_phy_event.c2
-rw-r--r--include/sg_cmds_basic.h5
-rw-r--r--include/sg_cmds_extra.h10
-rw-r--r--include/sg_lib.h7
-rw-r--r--include/sg_pt.h4
-rw-r--r--lib/sg_cmds_basic.c2
-rw-r--r--lib/sg_cmds_extra.c22
-rw-r--r--lib/sg_lib.c10
-rw-r--r--lib/sg_pt_freebsd.c2
-rw-r--r--lib/sg_pt_linux.c2
-rw-r--r--lib/sg_pt_osf1.c2
-rw-r--r--lib/sg_pt_solaris.c2
-rw-r--r--lib/sg_pt_win32.c2
-rw-r--r--sg3_utils.spec2
-rw-r--r--src/sg_dd.c76
-rw-r--r--src/sg_format.c6
-rw-r--r--src/sg_inq.c6
-rw-r--r--src/sg_logs.c28
-rw-r--r--src/sg_luns.c2
-rw-r--r--src/sg_persist.c21
-rw-r--r--src/sg_rbuf.c10
-rw-r--r--src/sg_read.c12
-rw-r--r--src/sg_read_long.c8
-rw-r--r--src/sg_readcap.c12
-rw-r--r--src/sg_reassign.c16
-rw-r--r--src/sg_sat_phy_event.c2
-rw-r--r--src/sg_sync.c4
-rw-r--r--src/sg_verify.c17
-rw-r--r--src/sg_vpd.c6
-rw-r--r--src/sg_write_long.c6
-rw-r--r--src/sginfo.c6
-rw-r--r--src/sgm_dd.c40
-rw-r--r--src/sgp_dd.c48
-rw-r--r--utils/Makefile2
-rw-r--r--utils/sg_lib.h2
41 files changed, 214 insertions, 211 deletions
diff --git a/CREDITS b/CREDITS
index 874901ac..cc5f5d0b 100644
--- a/CREDITS
+++ b/CREDITS
@@ -45,6 +45,9 @@ Ingo van Lil <inguin at gmx dot de>
James Bottomley <jejb at parisc-linux dot org> co-author of blk512-linux
that has become sg_format [20050201]
+Joe Krahn <krahn at niehs dot nih dot gov> help with int64_t cleanup
+ [20071219]
+
Kurt Garloff <garloff at suse dot de> original sg_start and sg_test_rwbuf.
Additions to sginfo and sg_map.
@@ -86,4 +89,4 @@ Trent Piepho <xyzzy at speakeasy dot org> print out some "sense key specific"
Doug Gilbert
-13th October 2007
+19th December 2007
diff --git a/ChangeLog b/ChangeLog
index 5f6d35e6..8b3466cf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,7 +2,7 @@ Each utility has its own version number, date of last change and
some description at the top of its ".c" file. All utilities in the main
directory have their own "man" pages. There is also a sg3_utils man page.
-Changelog for sg3_utils-1.26 [20071216]
+Changelog for sg3_utils-1.26 [20071219]
- sg_ses: sync with ses2r19
- sg_get_config: sync with mmc6r01
- allow Firmware upgrade feature descriptor to be 4 bytes long
@@ -13,6 +13,8 @@ Changelog for sg3_utils-1.26 [20071216]
- sg_write_long: add examples section to man page
- sg_sat_phy_event: copied from examples directory and enhanced,
rename original to sg__sat_phy_event
+ - change 'long long' to int64_t and 'unsigned long long' to
+ uint64_t to stress that 64 bit integer wanted, not larger
Changelog for sg3_utils-1.25 [20071016]
- sg_stpg: new utility to Set Target Port Groups
diff --git a/README b/README
index df1a28ef..25b1e296 100644
--- a/README
+++ b/README
@@ -327,4 +327,4 @@ See http://www.torque.net/sg/tools.html
Doug Gilbert
-16th December 2007
+19th December 2007
diff --git a/archive/llseek.c b/archive/llseek.c
index d07c1807..fbb0a5cc 100644
--- a/archive/llseek.c
+++ b/archive/llseek.c
@@ -17,7 +17,7 @@
#include <unistd.h>
#if defined(__GNUC__) || defined(HAS_LONG_LONG)
-typedef long long llse_loff_t;
+typedef int64_t llse_loff_t;
#else
typedef long llse_loff_t;
#endif
@@ -65,8 +65,8 @@ static llse_loff_t my_llseek (unsigned int fd, llse_loff_t offset,
llse_loff_t result;
int retval;
- retval = _llseek (fd, ((unsigned long long) offset) >> 32,
- ((unsigned long long) offset) & 0xffffffff,
+ retval = _llseek (fd, ((uint64_t) offset) >> 32,
+ ((uint64_t) offset) & 0xffffffff,
&result, origin);
return (retval == -1 ? (llse_loff_t) retval : result);
}
diff --git a/archive/llseek.h b/archive/llseek.h
index 2f6aef0f..61c12e43 100644
--- a/archive/llseek.h
+++ b/archive/llseek.h
@@ -2,7 +2,7 @@
#define LLSEEK_H
#if defined(__GNUC__) || defined(HAS_LONG_LONG)
-typedef long long llse_loff_t;
+typedef int64_t llse_loff_t;
#else
typedef long llse_loff_t;
#endif
diff --git a/debian/changelog b/debian/changelog
index 93b2de05..a6172bac 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,7 +2,7 @@ sg3-utils (1.26-0.1) unstable; urgency=low
* New upstream version
- -- Doug Gilbert <dgilbert@interlog.com> Sun, 16 Dec 2007 22:00:00 -0500
+ -- Doug Gilbert <dgilbert@interlog.com> Wed, 19 Dec 2007 11:00:00 -0500
sg3-utils (1.25-0.1) unstable; urgency=low
diff --git a/examples/sg__sat_phy_event.c b/examples/sg__sat_phy_event.c
index a2922857..b4609433 100644
--- a/examples/sg__sat_phy_event.c
+++ b/examples/sg__sat_phy_event.c
@@ -167,7 +167,7 @@ int main(int argc, char * argv[])
int t_length = 2; /* 0 -> no data transferred, 2 -> sector count */
const unsigned char * cucp;
int ret = 0;
- unsigned long long ull;
+ uint64_t ull;
const char * cp;
memset(inBuff, 0, sizeof(inBuff));
diff --git a/include/sg_cmds_basic.h b/include/sg_cmds_basic.h
index 24274bb3..40ecaa7b 100644
--- a/include/sg_cmds_basic.h
+++ b/include/sg_cmds_basic.h
@@ -120,9 +120,8 @@ extern int sg_ll_readcap_10(int sg_fd, int pmi, unsigned int lba,
* -> cdb not supported, SG_LIB_CAT_IlLEGAL_REQ -> bad field in cdb
* SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND,
* -1 -> other failure */
-extern int sg_ll_readcap_16(int sg_fd, int pmi, unsigned long long llba,
- void * resp, int mx_resp_len, int noisy,
- int verbose);
+extern int sg_ll_readcap_16(int sg_fd, int pmi, uint64_t llba, void * resp,
+ int mx_resp_len, int noisy, int verbose);
/* Invokes a SCSI REPORT LUNS command. Return of 0 -> success,
* SG_LIB_CAT_INVALID_OP -> Report Luns not supported,
diff --git a/include/sg_cmds_extra.h b/include/sg_cmds_extra.h
index ef4b5afe..195195b5 100644
--- a/include/sg_cmds_extra.h
+++ b/include/sg_cmds_extra.h
@@ -141,9 +141,8 @@ extern int sg_ll_read_long10(int sg_fd, int pblock, int correct,
* SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND,
* -1 -> other failure */
extern int sg_ll_read_long16(int sg_fd, int pblock, int correct,
- unsigned long long llba, void * resp,
- int xfer_len, int * offsetp, int noisy,
- int verbose);
+ uint64_t llba, void * resp, int xfer_len,
+ int * offsetp, int noisy, int verbose);
/* Invokes a SCSI READ MEDIA SERIAL NUMBER command. Return of 0 -> success,
* SG_LIB_CAT_INVALID_OP -> Read media serial number not supported,
@@ -266,9 +265,8 @@ extern int sg_ll_write_long10(int sg_fd, int cor_dis, int wr_uncor, int pblock,
* SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND,
* -1 -> other failure */
extern int sg_ll_write_long16(int sg_fd, int cor_dis, int wr_uncor, int pblock,
- unsigned long long llba, void * data_out,
- int xfer_len, int * offsetp, int noisy,
- int verbose);
+ uint64_t llba, void * data_out, int xfer_len,
+ int * offsetp, int noisy, int verbose);
#ifdef __cplusplus
}
diff --git a/include/sg_lib.h b/include/sg_lib.h
index 22182b78..8d0067b5 100644
--- a/include/sg_lib.h
+++ b/include/sg_lib.h
@@ -51,7 +51,8 @@
* parallel ATA disk in a USB enclosure).
*/
-#include <stdio.h>
+// #include <stdio.h>
+#include <stdint.h>
#ifdef __cplusplus
extern "C" {
@@ -169,7 +170,7 @@ extern char * sg_get_asc_ascq_str(int asc, int ascq, int buff_len,
information field is written out via 'info_outp' (except when it is
NULL). Handles both fixed and descriptor sense formats. */
extern int sg_get_sense_info_fld(const unsigned char * sensep, int sb_len,
- unsigned long long * info_outp);
+ uint64_t * info_outp);
/* Returns 1 if sense key is NO_SENSE or NOT_READY and SKSV is set. Places
progress field from sense data where progress_outp points. If progress
@@ -327,7 +328,7 @@ extern int sg_get_num_nomult(const char * buf);
suffix. Otherwise a decimal multiplier suffix may be given. In addition
to supporting the multipliers of sg_get_num(), this function supports:
t T TiB *(2**40); TB *(10**12); p P PiB *(2**50); PB *(10**15) . */
-extern long long sg_get_llnum(const char * buf);
+extern int64_t sg_get_llnum(const char * buf);
extern const char * sg_lib_version();
diff --git a/include/sg_pt.h b/include/sg_pt.h
index 672c1131..458aff17 100644
--- a/include/sg_pt.h
+++ b/include/sg_pt.h
@@ -30,6 +30,8 @@
*
*/
+#include <stdint.h>
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -68,7 +70,7 @@ extern void set_scsi_pt_data_out(struct sg_pt_base * objp, /* to device */
const unsigned char * dxferp, int dxfer_len);
/* The following "set_"s implementations may be dummies */
extern void set_scsi_pt_packet_id(struct sg_pt_base * objp, int pack_id);
-extern void set_scsi_pt_tag(struct sg_pt_base * objp, unsigned long long tag);
+extern void set_scsi_pt_tag(struct sg_pt_base * objp, uint64_t tag);
extern void set_scsi_pt_task_management(struct sg_pt_base * objp,
int tmf_code);
extern void set_scsi_pt_task_attr(struct sg_pt_base * objp, int attribute,
diff --git a/lib/sg_cmds_basic.c b/lib/sg_cmds_basic.c
index 5478a4d2..b460ed3d 100644
--- a/lib/sg_cmds_basic.c
+++ b/lib/sg_cmds_basic.c
@@ -536,7 +536,7 @@ sg_ll_sync_cache_10(int sg_fd, int sync_nv, int immed, int group,
* SG_LIB_CAT_ABORTED_COMMAND, SG_LIB_CAT_NOT_READY -> device not ready,
* -1 -> other failure */
int
-sg_ll_readcap_16(int sg_fd, int pmi, unsigned long long llba, void * resp,
+sg_ll_readcap_16(int sg_fd, int pmi, uint64_t llba, void * resp,
int mx_resp_len, int noisy, int verbose)
{
int k, ret, res, sense_cat;
diff --git a/lib/sg_cmds_extra.c b/lib/sg_cmds_extra.c
index 253e2c39..bfb98da2 100644
--- a/lib/sg_cmds_extra.c
+++ b/lib/sg_cmds_extra.c
@@ -1295,14 +1295,14 @@ sg_ll_read_long10(int sg_fd, int pblock, int correct, unsigned long lba,
case SG_LIB_CAT_ILLEGAL_REQ:
{
int valid, slen, ili;
- unsigned long long ull = 0;
+ uint64_t ull = 0;
slen = get_scsi_pt_sense_len(ptvp);
valid = sg_get_sense_info_fld(sense_b, slen, &ull);
ili = has_blk_ili(sense_b, slen);
if (valid && ili) {
if (offsetp)
- *offsetp = (int)(long long)ull;
+ *offsetp = (int)(int64_t)ull;
ret = SG_LIB_CAT_ILLEGAL_REQ_WITH_INFO;
} else {
if (verbose > 1)
@@ -1330,7 +1330,7 @@ sg_ll_read_long10(int sg_fd, int pblock, int correct, unsigned long lba,
* field written to 'offsetp', SG_LIB_CAT_ABORTED_COMMAND,
* SG_LIB_CAT_NOT_READY -> device not ready, -1 -> other failure */
int
-sg_ll_read_long16(int sg_fd, int pblock, int correct, unsigned long long llba,
+sg_ll_read_long16(int sg_fd, int pblock, int correct, uint64_t llba,
void * resp, int xfer_len, int * offsetp, int noisy,
int verbose)
{
@@ -1394,14 +1394,14 @@ sg_ll_read_long16(int sg_fd, int pblock, int correct, unsigned long long llba,
case SG_LIB_CAT_ILLEGAL_REQ:
{
int valid, slen, ili;
- unsigned long long ull = 0;
+ uint64_t ull = 0;
slen = get_scsi_pt_sense_len(ptvp);
valid = sg_get_sense_info_fld(sense_b, slen, &ull);
ili = has_blk_ili(sense_b, slen);
if (valid && ili) {
if (offsetp)
- *offsetp = (int)(long long)ull;
+ *offsetp = (int)(int64_t)ull;
ret = SG_LIB_CAT_ILLEGAL_REQ_WITH_INFO;
} else {
if (verbose > 1)
@@ -1491,14 +1491,14 @@ sg_ll_write_long10(int sg_fd, int cor_dis, int wr_uncor, int pblock,
case SG_LIB_CAT_ILLEGAL_REQ:
{
int valid, slen, ili;
- unsigned long long ull = 0;
+ uint64_t ull = 0;
slen = get_scsi_pt_sense_len(ptvp);
valid = sg_get_sense_info_fld(sense_b, slen, &ull);
ili = has_blk_ili(sense_b, slen);
if (valid && ili) {
if (offsetp)
- *offsetp = (int)(long long)ull;
+ *offsetp = (int)(int64_t)ull;
ret = SG_LIB_CAT_ILLEGAL_REQ_WITH_INFO;
} else {
if (verbose > 1)
@@ -1529,7 +1529,7 @@ sg_ll_write_long10(int sg_fd, int cor_dis, int wr_uncor, int pblock,
* SG_LIB_CAT_ABORTED_COMMAND, -1 -> other failure */
int
sg_ll_write_long16(int sg_fd, int cor_dis, int wr_uncor, int pblock,
- unsigned long long llba, void * data_out, int xfer_len,
+ uint64_t llba, void * data_out, int xfer_len,
int * offsetp, int noisy, int verbose)
{
int k, res, sense_cat, ret;
@@ -1594,14 +1594,14 @@ sg_ll_write_long16(int sg_fd, int cor_dis, int wr_uncor, int pblock,
case SG_LIB_CAT_ILLEGAL_REQ:
{
int valid, slen, ili;
- unsigned long long ull = 0;
+ uint64_t ull = 0;
slen = get_scsi_pt_sense_len(ptvp);
valid = sg_get_sense_info_fld(sense_b, slen, &ull);
ili = has_blk_ili(sense_b, slen);
if (valid && ili) {
if (offsetp)
- *offsetp = (int)(long long)ull;
+ *offsetp = (int)(int64_t)ull;
ret = SG_LIB_CAT_ILLEGAL_REQ_WITH_INFO;
} else {
if (verbose > 1)
@@ -1689,7 +1689,7 @@ sg_ll_verify10(int sg_fd, int vrprotect, int dpo, int bytechk,
case SG_LIB_CAT_MEDIUM_HARD:
{
int valid, slen;
- unsigned long long ull = 0;
+ uint64_t ull = 0;
slen = get_scsi_pt_sense_len(ptvp);
valid = sg_get_sense_info_fld(sense_b, slen, &ull);
diff --git a/lib/sg_lib.c b/lib/sg_lib.c
index 192d9bff..9addda4d 100644
--- a/lib/sg_lib.c
+++ b/lib/sg_lib.c
@@ -1208,11 +1208,11 @@ sg_scsi_sense_desc_find(const unsigned char * sensep, int sense_len,
int
sg_get_sense_info_fld(const unsigned char * sensep, int sb_len,
- unsigned long long * info_outp)
+ uint64_t * info_outp)
{
int j;
const unsigned char * ucp;
- unsigned long long ull;
+ uint64_t ull;
if (info_outp)
*info_outp = 0;
@@ -2362,12 +2362,12 @@ sg_get_num_nomult(const char * buf)
then -1LL is returned. Accepts a hex prefix (0x or 0X) or a decimal
multiplier suffix (as per GNU's dd (since 2002: SI and IEC 60027-2)).
Main (SI) multipliers supported: K, M, G, T, P. */
-long long
+int64_t
sg_get_llnum(const char * buf)
{
int res, len;
- long long num, ll;
- unsigned long long unum;
+ int64_t num, ll;
+ uint64_t unum;
char * cp;
char c = 'c';
char c2, c3;
diff --git a/lib/sg_pt_freebsd.c b/lib/sg_pt_freebsd.c
index 4ed7c69b..47ac8e2c 100644
--- a/lib/sg_pt_freebsd.c
+++ b/lib/sg_pt_freebsd.c
@@ -253,7 +253,7 @@ void set_scsi_pt_packet_id(struct sg_pt_base * vp __attribute__ ((unused)),
}
void set_scsi_pt_tag(struct sg_pt_base * vp,
- unsigned long long tag __attribute__ ((unused)))
+ uint64_t tag __attribute__ ((unused)))
{
struct sg_pt_freebsd_scsi * ptp = &vp->impl;
diff --git a/lib/sg_pt_linux.c b/lib/sg_pt_linux.c
index b57b016b..390d1eb3 100644
--- a/lib/sg_pt_linux.c
+++ b/lib/sg_pt_linux.c
@@ -171,7 +171,7 @@ void set_scsi_pt_packet_id(struct sg_pt_base * vp, int pack_id)
ptp->io_hdr.pack_id = pack_id;
}
-void set_scsi_pt_tag(struct sg_pt_base * vp, unsigned long long tag)
+void set_scsi_pt_tag(struct sg_pt_base * vp, uint64_t tag)
{
struct sg_pt_linux_scsi * ptp = &vp->impl;
diff --git a/lib/sg_pt_osf1.c b/lib/sg_pt_osf1.c
index 419c8cf7..7814a6a0 100644
--- a/lib/sg_pt_osf1.c
+++ b/lib/sg_pt_osf1.c
@@ -249,7 +249,7 @@ void set_scsi_pt_packet_id(struct sg_pt_base * vp, int pack_id)
{
}
-void set_scsi_pt_tag(struct sg_pt_base * vp, unsigned long long tag)
+void set_scsi_pt_tag(struct sg_pt_base * vp, uint64_t tag)
{
struct sg_pt_osf1_scsi * ptp = &vp->impl;
diff --git a/lib/sg_pt_solaris.c b/lib/sg_pt_solaris.c
index 3a829a77..76c9caf3 100644
--- a/lib/sg_pt_solaris.c
+++ b/lib/sg_pt_solaris.c
@@ -175,7 +175,7 @@ void set_scsi_pt_packet_id(struct sg_pt_base * vp, int pack_id)
pack_id = pack_id; /* ignore and suppress warning */
}
-void set_scsi_pt_tag(struct sg_pt_base * vp, unsigned long long tag)
+void set_scsi_pt_tag(struct sg_pt_base * vp, uint64_t tag)
{
// struct sg_pt_solaris_scsi * ptp = &vp->impl;
diff --git a/lib/sg_pt_win32.c b/lib/sg_pt_win32.c
index 213292d6..623557e6 100644
--- a/lib/sg_pt_win32.c
+++ b/lib/sg_pt_win32.c
@@ -292,7 +292,7 @@ void set_scsi_pt_packet_id(struct sg_pt_base * vp __attribute__ ((unused)),
}
void set_scsi_pt_tag(struct sg_pt_base * vp,
- unsigned long long tag __attribute__ ((unused)))
+ uint64_t tag __attribute__ ((unused)))
{
struct sg_pt_win32_scsi * psp = &vp->impl;
diff --git a/sg3_utils.spec b/sg3_utils.spec
index 37925d12..d3b483f5 100644
--- a/sg3_utils.spec
+++ b/sg3_utils.spec
@@ -79,7 +79,7 @@ fi
%{_libdir}/*.la
%changelog
-* Sun Dec 16 2007 - dgilbert at interlog dot com
+* Wed Dec 19 2007 - dgilbert at interlog dot com
- sg_get_config sync with mmc6r01, add sg_sat_phy_event
* sg3_utils-1.26
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;
diff --git a/utils/Makefile b/utils/Makefile
index a0da149b..c1bf677c 100644
--- a/utils/Makefile
+++ b/utils/Makefile
@@ -29,7 +29,7 @@ clean:
hxascdmp: hxascdmp.o
$(LD) -o $@ $(LDFLAGS) $^
-sg_chk_asc: sg_chk_asc.o ../sg_lib.o
+sg_chk_asc: sg_chk_asc.o ../lib/sg_lib.o
$(LD) -o $@ $(LDFLAGS) $^
diff --git a/utils/sg_lib.h b/utils/sg_lib.h
index e2f826a1..609c2584 100644
--- a/utils/sg_lib.h
+++ b/utils/sg_lib.h
@@ -1 +1 @@
-#include "../sg_lib.h"
+#include "../include/sg_lib.h"