All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* Can not send SCSI command to the cdrom device.
@ 2009-01-17  9:02 fangxiaozhi 00110321
  2009-01-17 16:40 ` Douglas Gilbert
  0 siblings, 1 reply; 2+ messages in thread
From: fangxiaozhi 00110321 @ 2009-01-17  9:02 UTC (permalink / raw
  To: linux-scsi

Dear all:
 
  I have a CDROM device, and after I plug it into the Linux system, the Linux system will generate three device files in the directory of /dev/, such as:
  scd1: block special (11/0)
  sr1:  link to scd1
  sg1: character special(21/1)
 
  And I write a c program to send the SCSI command of SPACE to my CDROM device. Such as :
 
   fd = open("/dev/sg1", 0_RDWR);
   ioctl(fd, SCSI_IOCTL_SEND_COMMAND, cmdbuff);
 
  And I found that I can send the SPACE command to my CDROM device, if I open the file of /dev/sg1.
  But if I open the file of /dev/scd1, then I can not send the SPACE command to my CDROM device.
 
   Why I can not send SCSI command through /dev/scd1 ?
 
   What difference between /dev/sg1 and /dev/scd1 ?
 
   And how can I send send the command through /dev/scd1?
 
   Wait for the help, thanks.
 
Best Regards,
 
Franko Fang
2009-1-17


******************************************************************************************
 This email and its attachments contain confidential information from HUAWEI, which is intended only for the person or entity whose address is listed above. Any use of the information contained here in any way (including, but not limited to, total or partial disclosure, reproduction, or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this email in error, please notify the sender by phone or email
 immediately and delete it!
 *****************************************************************************************

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Can not send SCSI command to the cdrom device.
  2009-01-17  9:02 Can not send SCSI command to the cdrom device fangxiaozhi 00110321
@ 2009-01-17 16:40 ` Douglas Gilbert
  0 siblings, 0 replies; 2+ messages in thread
From: Douglas Gilbert @ 2009-01-17 16:40 UTC (permalink / raw
  To: fangxiaozhi 00110321; +Cc: linux-scsi

fangxiaozhi 00110321 wrote:
> Dear all:
>  
>   I have a CDROM device, and after I plug it into the Linux system, the Linux system will generate three device files in the directory of /dev/, such as:
>   scd1: block special (11/0)
>   sr1:  link to scd1
>   sg1: character special(21/1)
>  
>   And I write a c program to send the SCSI command of SPACE to my CDROM device. Such as :
>  
>    fd = open("/dev/sg1", 0_RDWR);
>    ioctl(fd, SCSI_IOCTL_SEND_COMMAND, cmdbuff);
>  
>   And I found that I can send the SPACE command to my CDROM device, if I open the file of /dev/sg1.
>   But if I open the file of /dev/scd1, then I can not send the SPACE command to my CDROM device.
>  
>    Why I can not send SCSI command through /dev/scd1 ?

Probably because you don't have media in the drive in which case
open("/dev/scd1", ...) will block. You might try or-ing in
O_NONBLOCK as in open("/dev/scd1", 0_RDWR | O_NONBLOCK).

If you are using any Linux system made in the last 5 years then
you should _not_ be using the SCSI_IOCTL_SEND_COMMAND ioctl. Try
the SG_IO ioctl instead.

>    What difference between /dev/sg1 and /dev/scd1 ?

The sg driver makes a lot less assumptions about the SCSI
device and is designed for lower-level, pass-through access at
the SCSI command level. The bsg driver in recent kernels plays
a similar role to the older sg driver which dates from 1992.

>    And how can I send send the command through /dev/scd1?

Answered above. BTW In the lk 2.6 series the SG_IO ioctl will
work on both "sg" and "scd/sr" drivers.

For examples on the use of SG_IO have a look at my sg3_utils
package, specifically the examples directory. You may find the
sg_get_config utility interesting to use on a CD/DVD/BD drive.

Doug Gilbert

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-01-17 16:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-17  9:02 Can not send SCSI command to the cdrom device fangxiaozhi 00110321
2009-01-17 16:40 ` 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.