Skip to contentSkip to conversation

program inquiry is using a deprecated scsi_ioctl , please convert it to SG_IO

DISCUSSION Masthan 3 participants 5 messages Feb 8, 2007 – Feb 22, 2007 2 messages not in the archive SCSI

lore
Share & tools
lore

Masthan

author
#0 lore raw

Hi All,

I am not getting why i am getting the following DIAG message

Program inquiry is using deprecated scsi ioctl, please convert it to SG_IO.

The following snippet of linux source code clearly saying that, the above message is a kind of cosmetic warning message.

Do you know how to use SG_IO to overcome this problem.

The following function sayign that only 6 scsi ioctls are deprecated, out of 6 inquiry program is using only 2 scsi ioctls(i.e.SCSI_IOCTL_SEND_COMMAND and SCSI_IOCTL_TEST_UNIT_READY ) . What are their equivalents SG_IO ioctls ?

181  /* the scsi_ioctl() function differs from most ioctls in that it does
182  * not take a major/minor number as the dev field.  Rather, it takes
183  * a pointer to a scsi_devices[] element, a structure. 
184  */

185 int scsi_ioctl(struct scsi_device *sdev, int cmd, void __user *arg) 186 {
187 char scsi_cmd[MAX_COMMAND_SIZE];
188
189 /* No idea how this happens.... */
190 if (!sdev)
191 return -ENXIO;
192
193 /*
194 * If we are in the middle of error recovery, don't let anyone
195 * else try and use this device. Also, if error recovery fails,
it
196 * may try and take the device offline, in which case all
further
197 * access to the device is prohibited.
198 */
199 if (!scsi_block_when_processing_errors(sdev))
200 return -ENODEV;
201
202 /* Check for deprecated ioctls ... all the ioctls which don't
203 * follow the new unique numbering scheme are deprecated */

204         switch (cmd) {
205         case SCSI_IOCTL_SEND_COMMAND:
206         case SCSI_IOCTL_TEST_UNIT_READY:
207         case SCSI_IOCTL_BENCHMARK_COMMAND:
208         case SCSI_IOCTL_SYNC:
209         case SCSI_IOCTL_START_UNIT:
210         case SCSI_IOCTL_STOP_UNIT:

211 printk(KERN_WARNING "program %s is using a deprecated
SCSI "
212 "ioctl, please convert it to SG_IO\n",
current->comm);
213 break;
214 default:
215 break;
216 }
217
218 switch (cmd) {
219 case SCSI_IOCTL_GET_IDLUN:
220 if (!access_ok(VERIFY_WRITE, arg, sizeof(struct
scsi_idlun)))
221 return -EFAULT;
222
223 __put_user((sdev->id & 0xff)

224                          + ((sdev->lun & 0xff) << 8)
225                          + ((sdev->channel & 0xff) << 16)
226                          + ((sdev->host->host_no & 0xff) << 24),
227                          &((struct scsi_idlun __user *)arg)->dev_id);

228 __put_user(sdev->host->unique_id,
229 &((struct scsi_idlun __user
*)arg)->host_unique_id);
230 return 0;
231 case SCSI_IOCTL_GET_BUS_NUMBER:
232 return put_user(sdev->host->host_no, (int __user *)arg);
233 case SCSI_IOCTL_PROBE_HOST:
234 return ioctl_probe(sdev->host, arg);
235 case SCSI_IOCTL_SEND_COMMAND:
236 if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO))
237 return -EACCES;
238 return sg_scsi_ioctl(NULL, sdev->request_queue, NULL,
arg);
239 case SCSI_IOCTL_DOORLOCK:
240 return scsi_set_medium_removal(sdev,
SCSI_REMOVAL_PREVENT);
241 case SCSI_IOCTL_DOORUNLOCK:
242 return scsi_set_medium_removal(sdev,
SCSI_REMOVAL_ALLOW);
243 case SCSI_IOCTL_TEST_UNIT_READY:
244 return scsi_test_unit_ready(sdev, IOCTL_NORMAL_TIMEOUT,
245 NORMAL_RETRIES);
246 case SCSI_IOCTL_START_UNIT:

247                 scsi_cmd[0] = START_STOP;
248                 scsi_cmd[1] = 0;
249                 scsi_cmd[2] = scsi_cmd[3] = scsi_cmd[5] = 0;
250                 scsi_cmd[4] = 1;
251                 return ioctl_internal_command(sdev, scsi_cmd,
252                                      START_STOP_TIMEOUT,
NORMAL_RETRIES);
253         case SCSI_IOCTL_STOP_UNIT:
254                 scsi_cmd[0] = START_STOP;
255                 scsi_cmd[1] = 0;
256                 scsi_cmd[2] = scsi_cmd[3] = scsi_cmd[5] = 0;
257                 scsi_cmd[4] = 0;
258                 return ioctl_internal_command(sdev, scsi_cmd,

259 START_STOP_TIMEOUT,
NORMAL_RETRIES);
260 case SCSI_IOCTL_GET_PCI:
261 return scsi_ioctl_get_pci(sdev, arg);
262 default:
263 if (sdev->host->hostt->ioctl)
264 return sdev->host->hostt->ioctl(sdev, cmd, arg);
265 }
266 return -EINVAL;
267 }
268 EXPORT_SYMBOL(scsi_ioctl);

Your help is appreciated.

Thanks & Regards
Masthan

Signature · 2 lines
View this message in context: http://www.nabble.com/program-inquiry-is-using-a-deprecated-scsi_ioctl-%2C-please-convert-it-to-SG_IO-tf3192438.html#a8862659
Sent from the linux-scsi mailing list archive at Nabble.com.
#1 lore raw
Quoted 4 lines · Masthan

I am not getting why i am getting the following DIAG message

Program inquiry is using deprecated scsi ioctl, please convert it to SG_IO.

Quoted 8 lines

The following snippet of linux source code clearly saying that, the above message is a kind of cosmetic warning message.

Do you know how to use SG_IO to overcome this problem.

The following function sayign that only 6 scsi ioctls are deprecated, out of 6 inquiry program is using only 2 scsi ioctls(i.e.SCSI_IOCTL_SEND_COMMAND and SCSI_IOCTL_TEST_UNIT_READY ) . What are their equivalents SG_IO ioctls ?

Yes, see, e.g.

http://www.linux.org/docs/ldp/howto/SCSI-Generic-HOWTO/sg_io.html

although SG_IO can be sent to any SCSI device, not just sg.

James

#3 lore raw
In reply to a message not in the archive

If you want help, please don't drop linux-scsi.

Quoted 8 lines · MASTHAN DUDEKULA

Thanks for your reply.

I have one question to you.
Can you please answetr this one ?
What is SG_IO equivalent of SCSI_IOCTL_SCSI_COMMAND on sd devices ?

In otherwords How can we send SCSI_IOCTL_SCSI_COMMAND through SG_IO ioctls.

SG_IO is an ioctl which is capable of sending a SCSI command similar to the SCSI_IOCTL_SCSI_COMMAND ioctl.

James

#5 lore raw
In reply to a message not in the archive
Quoted 21 lines · MASTHAN DUDEKULA

Hi JAMES,

The following code is SG_IO equivalent of scsi ioctls SCSI_TEST_UNIT_READY

   unsigned char sense_b[32];
    unsigned char turCmbBlk[] = {0x00, 0, 0, 0, 0, 0};
    struct sg_io_hdr io_hdr; 
    memset(&io_hdr, 0, sizeof(struct sg_io_hdr));
    io_hdr.interface_id = 'S';
    io_hdr.cmd_len = sizeof(turCmbBlk);
    io_hdr.mx_sb_len = sizeof(sense_b);
    io_hdr.dxfer_direction = SG_DXFER_NONE;
    io_hdr.cmdp = turCmbBlk;
    io_hdr.sbp = sense_b;
    io_hdr.timeout = DEF_TIMEOUT;

    if (ioctl(fd, SG_IO, &io_hdr) < 0) {
Quoted 1 line

Like this What is the SG_IO equivalent for SCSI_IOCTL_SCSI_COMMAND ?

I don't understand your question ... SCSI_IOCTL_SEND_COMMAND sends a SCSI command to the device. Your example of test unit ready above does just that ... it sends a Test Unit Ready command to the device using SG_IO ... exactly what do you not understand about using SG_IO to send commands to the device?

James

#6 lore raw
Quoted 20 lines · James Bottomley
Quoted 19 lines · MASTHAN DUDEKULA

Hi JAMES,

The following code is SG_IO equivalent of scsi ioctls SCSI_TEST_UNIT_READY

   unsigned char sense_b[32];
    unsigned char turCmbBlk[] = {0x00, 0, 0, 0, 0, 0};
    struct sg_io_hdr io_hdr; 
    memset(&io_hdr, 0, sizeof(struct sg_io_hdr));
    io_hdr.interface_id = 'S';
    io_hdr.cmd_len = sizeof(turCmbBlk);
    io_hdr.mx_sb_len = sizeof(sense_b);
    io_hdr.dxfer_direction = SG_DXFER_NONE;
    io_hdr.cmdp = turCmbBlk;
    io_hdr.sbp = sense_b;
    io_hdr.timeout = DEF_TIMEOUT;
Quoted 3 lines
Quoted 3 lines
    if (ioctl(fd, SG_IO, &io_hdr) < 0) {

Like this What is the SG_IO equivalent for SCSI_IOCTL_SCSI_COMMAND ?

Judging from the above you have found some sg3_utils code. In a recent version, if you go to the "examples" subdirectory, you will find the scsi_inquiry.c and sg_simple1.c files.
The former shows the usage of the older, deprecated SCSI_IOCTL_SCSI_COMMAND ioctl while the latter does something very similar but uses the SG_IO ioctl interface.

The equivalence is that they both programs send a SCSI INQUIRY cdb to a device and print out the response.

Doug Gilbert

Quoted 7 lines

I don't understand your question ... SCSI_IOCTL_SEND_COMMAND sends a SCSI command to the device. Your example of test unit ready above does just that ... it sends a Test Unit Ready command to the device using SG_IO ... exactly what do you not understand about using SG_IO to send commands to the device?

James