diff options
author | Douglas Gilbert <dgilbert@interlog.com> | 2019-01-14 02:42:05 +0000 |
---|---|---|
committer | Douglas Gilbert <dgilbert@interlog.com> | 2019-01-14 02:42:05 +0000 |
commit | 0b07dc9a41e495604add3b006c040b36e4ea50c7 (patch) | |
tree | 0cb11adaa2f3f93c3be95cf28de486d7dbe716d9 /lib/sg_pt_osf1.c | |
parent | 2433a22138f1b508c2765aa8499456cd6138a200 (diff) | |
download | sg3_utils-0b07dc9a41e495604add3b006c040b36e4ea50c7.tar.gz |
sg_lib: tweak sg_pt interface to better handle bidi; sg_cmds_process_resp(): two arguments removed
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@805 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'lib/sg_pt_osf1.c')
-rw-r--r-- | lib/sg_pt_osf1.c | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/lib/sg_pt_osf1.c b/lib/sg_pt_osf1.c index f041ec00..6a003022 100644 --- a/lib/sg_pt_osf1.c +++ b/lib/sg_pt_osf1.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005-2018 Douglas Gilbert. + * Copyright (c) 2005-2019 Douglas Gilbert. * All rights reserved. * Use of this source code is governed by a BSD-style * license that can be found in the BSD_LICENSE file. @@ -30,6 +30,7 @@ #include "sg_lib.h" #include "sg_pr2serr.h" +/* Version 2.00 20190113 */ #define OSF1_MAXDEV 64 @@ -69,7 +70,6 @@ struct sg_pt_base { }; - /* Returns >= 0 if successful. If error in Unix returns negated errno. */ int scsi_pt_open_device(const char * device_name, bool read_only, int verbose) @@ -462,6 +462,49 @@ get_scsi_pt_resid(const struct sg_pt_base * vp) return ptp->resid; } +void +get_pt_req_lengths(const struct sg_pt_base * vp, int * req_dinp, + int * req_doutp) +{ + const struct sg_pt_osf1_scsi * ptp = &vp->impl; + bool bidi = (ptp->dxfer_dir == CAM_DIR_BOTH); + + if (req_dinp) { + if (ptp->dxfer_len > 0) + *req_dinp = ptp->dxfer_len; + else + *req_dinp = 0; + } + if (req_doutp) { + if ((!bidi) && (ptp->dxfer_len > 0)) + *req_doutp = ptp->dxfer_len; + else + *req_doutp = 0; + } +} + +void +get_pt_actual_lengths(const struct sg_pt_base * vp, int * act_dinp, + int * act_doutp) +{ + const struct sg_pt_osf1_scsi * ptp = &vp->impl; + bool bidi = (ptp->dxfer_dir == CAM_DIR_BOTH); + + if (act_dinp) { + if (ptp->dxfer_len > 0) + *act_dinp = ptp->dxfer_len - ptp->resid; + else + *act_dinp = 0; + } + if (act_doutp) { + if ((!bidi) && (ptp->dxfer_len > 0)) + *act_doutp = ptp->dxfer_len - ptp->resid; + else + *act_doutp = 0; + } +} + + int get_scsi_pt_status_response(const struct sg_pt_base * vp) { |