sg_pt_osf1.c (sdparm-1.11.tgz) | : | sg_pt_osf1.c (sdparm-1.12.tgz) | ||
---|---|---|---|---|
/* | /* | |||
* Copyright (c) 2005-2019 Douglas Gilbert. | * Copyright (c) 2005-2020 Douglas Gilbert. | |||
* All rights reserved. | * All rights reserved. | |||
* Use of this source code is governed by a BSD-style | * Use of this source code is governed by a BSD-style | |||
* license that can be found in the BSD_LICENSE file. | * license that can be found in the BSD_LICENSE file. | |||
* | * | |||
* SPDX-License-Identifier: BSD-2-Clause | * SPDX-License-Identifier: BSD-2-Clause | |||
*/ | */ | |||
#include <fcntl.h> | #include <fcntl.h> | |||
#include <sys/stat.h> | #include <sys/stat.h> | |||
#include <sys/types.h> | #include <sys/types.h> | |||
skipping to change at line 33 | skipping to change at line 33 | |||
#include <stdlib.h> | #include <stdlib.h> | |||
#include <stdarg.h> | #include <stdarg.h> | |||
#include <stdbool.h> | #include <stdbool.h> | |||
#include <string.h> | #include <string.h> | |||
#include <errno.h> | #include <errno.h> | |||
#include "sg_pt.h" | #include "sg_pt.h" | |||
#include "sg_lib.h" | #include "sg_lib.h" | |||
#include "sg_pr2serr.h" | #include "sg_pr2serr.h" | |||
/* Version 2.00 20190113 */ | /* Version 2.03 20200722 */ | |||
#define OSF1_MAXDEV 64 | #define OSF1_MAXDEV 64 | |||
#ifndef CAM_DIR_BOTH | ||||
#define CAM_DIR_BOTH 0x0 /* copy value from FreeBSD */ | ||||
#endif | ||||
struct osf1_dev_channel { | struct osf1_dev_channel { | |||
int bus; | int bus; | |||
int tgt; | int tgt; | |||
int lun; | int lun; | |||
}; | }; | |||
// Private table of open devices: guaranteed zero on startup since | // Private table of open devices: guaranteed zero on startup since | |||
// part of static data. | // part of static data. | |||
static struct osf1_dev_channel *devicetable[OSF1_MAXDEV] = {0}; | static struct osf1_dev_channel *devicetable[OSF1_MAXDEV] = {0}; | |||
static char *cam_dev = "/dev/cam"; | static char *cam_dev = "/dev/cam"; | |||
skipping to change at line 202 | skipping to change at line 206 | |||
{ | { | |||
struct sg_pt_osf1_scsi * ptp = &vp->impl; | struct sg_pt_osf1_scsi * ptp = &vp->impl; | |||
if (ptp) | if (ptp) | |||
free(ptp); | free(ptp); | |||
} | } | |||
void | void | |||
clear_scsi_pt_obj(struct sg_pt_base * vp) | clear_scsi_pt_obj(struct sg_pt_base * vp) | |||
{ | { | |||
bool is_nvme; | ||||
int dev_fd; | ||||
struct sg_pt_osf1_scsi * ptp = &vp->impl; | struct sg_pt_osf1_scsi * ptp = &vp->impl; | |||
if (ptp) { | if (ptp) { | |||
is_nvme = ptp->is_nvme; | ||||
dev_fd = ptp->dev_fd; | ||||
bzero(ptp, sizeof(struct sg_pt_osf1_scsi)); | bzero(ptp, sizeof(struct sg_pt_osf1_scsi)); | |||
ptp->dev_fd = dev_fd; | ||||
ptp->is_nvme = is_nvme; | ||||
ptp->dxfer_dir = CAM_DIR_NONE; | ptp->dxfer_dir = CAM_DIR_NONE; | |||
} | } | |||
} | } | |||
void | void | |||
partial_clear_scsi_pt_obj(struct sg_pt_base * vp) | ||||
{ | ||||
struct sg_pt_osf1_scsi * ptp = &vp->impl; | ||||
if (NULL == ptp) | ||||
return; | ||||
ptp->in_err = 0; | ||||
ptp->os_err = 0; | ||||
ptp->transport_err = 0; | ||||
ptp->scsi_status = 0; | ||||
ptp->dxfer_dir = CAM_DIR_NONE; | ||||
ptp->dxferp = NULL; | ||||
ptp->dxfer_len = 0; | ||||
} | ||||
void | ||||
set_scsi_pt_cdb(struct sg_pt_base * vp, const uint8_t * cdb, | set_scsi_pt_cdb(struct sg_pt_base * vp, const uint8_t * cdb, | |||
int cdb_len) | int cdb_len) | |||
{ | { | |||
struct sg_pt_osf1_scsi * ptp = &vp->impl; | struct sg_pt_osf1_scsi * ptp = &vp->impl; | |||
if (ptp->cdb) | ||||
++ptp->in_err; | ||||
ptp->cdb = (uint8_t *)cdb; | ptp->cdb = (uint8_t *)cdb; | |||
ptp->cdb_len = cdb_len; | ptp->cdb_len = cdb_len; | |||
} | } | |||
int | ||||
get_scsi_pt_cdb_len(const struct sg_pt_base * vp) | ||||
{ | ||||
const struct sg_pt_osf1_scsi * ptp = &vp->impl; | ||||
return ptp->cdb_len; | ||||
} | ||||
uint8_t * | ||||
get_scsi_pt_cdb_buf(const struct sg_pt_base * vp) | ||||
{ | ||||
const struct sg_pt_osf1_scsi * ptp = &vp->impl; | ||||
return ptp->cdb; | ||||
} | ||||
void | void | |||
set_scsi_pt_sense(struct sg_pt_base * vp, uint8_t * sense, | set_scsi_pt_sense(struct sg_pt_base * vp, uint8_t * sense, | |||
int max_sense_len) | int max_sense_len) | |||
{ | { | |||
struct sg_pt_osf1_scsi * ptp = &vp->impl; | struct sg_pt_osf1_scsi * ptp = &vp->impl; | |||
if (ptp->sense) | if (sense) { | |||
++ptp->in_err; | if (max_sense_len > 0) | |||
bzero(sense, max_sense_len); | bzero(sense, max_sense_len); | |||
} | ||||
ptp->sense = sense; | ptp->sense = sense; | |||
ptp->sense_len = max_sense_len; | ptp->sense_len = max_sense_len; | |||
} | } | |||
/* from device */ | /* from device */ | |||
void | void | |||
set_scsi_pt_data_in(struct sg_pt_base * vp, uint8_t * dxferp, | set_scsi_pt_data_in(struct sg_pt_base * vp, uint8_t * dxferp, | |||
int dxfer_len) | int dxfer_len) | |||
{ | { | |||
struct sg_pt_osf1_scsi * ptp = &vp->impl; | struct sg_pt_osf1_scsi * ptp = &vp->impl; | |||
skipping to change at line 599 | skipping to change at line 640 | |||
{ | { | |||
const struct sg_pt_osf1_scsi * ptp = &vp->impl; | const struct sg_pt_osf1_scsi * ptp = &vp->impl; | |||
const char * cp; | const char * cp; | |||
cp = safe_strerror(ptp->os_err); | cp = safe_strerror(ptp->os_err); | |||
strncpy(b, cp, max_b_len); | strncpy(b, cp, max_b_len); | |||
if ((int)strlen(cp) >= max_b_len) | if ((int)strlen(cp) >= max_b_len) | |||
b[max_b_len - 1] = '\0'; | b[max_b_len - 1] = '\0'; | |||
return b; | return b; | |||
} | } | |||
int | ||||
do_nvm_pt(struct sg_pt_base * vp, int submq, int timeout_secs, int verbose) | ||||
{ | ||||
if (vp) { } | ||||
if (submq) { } | ||||
if (timeout_secs) { } | ||||
if (verbose) { } | ||||
return SCSI_PT_DO_NOT_SUPPORTED; | ||||
} | ||||
End of changes. 11 change blocks. | ||||
7 lines changed or deleted | 48 lines changed or added |