Lines Matching defs:cmd
125 static void info_scsi_cmd_err(struct udev *udev, const char *cmd, int err)
128 log_debug("%s failed", cmd);
131 log_debug("%s failed with SK=%Xh/ASC=%02Xh/ACQ=%02Xh", cmd, SK(err), ASC(err), ASCQ(err));
143 static void scsi_cmd_init(struct udev *udev, struct scsi_cmd *cmd)
145 memzero(cmd, sizeof(struct scsi_cmd));
146 cmd->cgc.quiet = 1;
147 cmd->cgc.sense = &cmd->_sense.s;
148 cmd->sg_io.interface_id = 'S';
149 cmd->sg_io.mx_sb_len = sizeof(cmd->_sense);
150 cmd->sg_io.cmdp = cmd->cgc.cmd;
151 cmd->sg_io.sbp = cmd->_sense.u;
152 cmd->sg_io.flags = SG_FLAG_LUN_INHIBIT | SG_FLAG_DIRECT_IO;
155 static void scsi_cmd_set(struct udev *udev, struct scsi_cmd *cmd, size_t i, unsigned char arg)
157 cmd->sg_io.cmd_len = i + 1;
158 cmd->cgc.cmd[i] = arg;
163 static int scsi_cmd_run(struct udev *udev, struct scsi_cmd *cmd, int fd, unsigned char *buf, size_t bufsize)
168 cmd->sg_io.dxferp = buf;
169 cmd->sg_io.dxfer_len = bufsize;
170 cmd->sg_io.dxfer_direction = SG_DXFER_FROM_DEV;
172 cmd->sg_io.dxfer_direction = SG_DXFER_NONE;
174 if (ioctl(fd, SG_IO, &cmd->sg_io))
177 if ((cmd->sg_io.info & SG_INFO_OK_MASK) != SG_INFO_OK) {
180 if (cmd->sg_io.masked_status & CHECK_CONDITION) {
181 ret = ERRCODE(cmd->_sense.u);