* program inquiry is using a deprecated scsi_ioctl , please convert it to SG_IO
@ 2007-02-08 10:14 Masthan
2007-02-08 14:50 ` James Bottomley
0 siblings, 1 reply; 5+ messages in thread
From: Masthan @ 2007-02-08 10:14 UTC (permalink / raw)
To: linux-scsi
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
--
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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: program inquiry is using a deprecated scsi_ioctl , please convert it to SG_IO
2007-02-08 10:14 program inquiry is using a deprecated scsi_ioctl , please convert it to SG_IO Masthan
@ 2007-02-08 14:50 ` James Bottomley
[not found] ` <868c9d9d0702202233pa206222jb9beb85d60089003@mail.gmail.com>
0 siblings, 1 reply; 5+ messages in thread
From: James Bottomley @ 2007-02-08 14:50 UTC (permalink / raw)
To: Masthan; +Cc: linux-scsi
On Thu, 2007-02-08 at 02:14 -0800, Masthan wrote:
> 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 ?
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: program inquiry is using a deprecated scsi_ioctl , please convert it to SG_IO
[not found] ` <868c9d9d0702202233pa206222jb9beb85d60089003@mail.gmail.com>
@ 2007-02-21 17:17 ` James Bottomley
[not found] ` <868c9d9d0702212229p2e1a39ek9b73813899f18645@mail.gmail.com>
0 siblings, 1 reply; 5+ messages in thread
From: James Bottomley @ 2007-02-21 17:17 UTC (permalink / raw)
To: MASTHAN DUDEKULA; +Cc: linux-scsi
If you want help, please don't drop linux-scsi.
On Wed, 2007-02-21 at 12:03 +0530, MASTHAN DUDEKULA wrote:
> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: program inquiry is using a deprecated scsi_ioctl , please convert it to SG_IO
[not found] ` <868c9d9d0702212229p2e1a39ek9b73813899f18645@mail.gmail.com>
@ 2007-02-22 22:15 ` James Bottomley
2007-02-22 23:59 ` Douglas Gilbert
0 siblings, 1 reply; 5+ messages in thread
From: James Bottomley @ 2007-02-22 22:15 UTC (permalink / raw)
To: MASTHAN DUDEKULA; +Cc: linux-scsi
On Thu, 2007-02-22 at 11:59 +0530, MASTHAN DUDEKULA wrote:
> 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) {
>
> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: program inquiry is using a deprecated scsi_ioctl , please convert it to SG_IO
2007-02-22 22:15 ` James Bottomley
@ 2007-02-22 23:59 ` Douglas Gilbert
0 siblings, 0 replies; 5+ messages in thread
From: Douglas Gilbert @ 2007-02-22 23:59 UTC (permalink / raw)
To: MASTHAN DUDEKULA; +Cc: linux-scsi
James Bottomley wrote:
> On Thu, 2007-02-22 at 11:59 +0530, MASTHAN DUDEKULA wrote:
>> 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) {
>>
>> 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
> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-02-22 23:59 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-08 10:14 program inquiry is using a deprecated scsi_ioctl , please convert it to SG_IO Masthan
2007-02-08 14:50 ` James Bottomley
[not found] ` <868c9d9d0702202233pa206222jb9beb85d60089003@mail.gmail.com>
2007-02-21 17:17 ` James Bottomley
[not found] ` <868c9d9d0702212229p2e1a39ek9b73813899f18645@mail.gmail.com>
2007-02-22 22:15 ` James Bottomley
2007-02-22 23:59 ` Douglas Gilbert
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.