Re: ide cdrom sg like access / rpcmgr ?

Jens Axboe
2003-11-12T14:31:31Z

On Wed, Nov 12 2003, Andreas Jellinghaus wrote:
> On Wed, 2003-11-12 at 12:36, Jens Axboe wrote:
> > Post the code and I'll show you how to do it. Generally, you should just
> > use SG_IO or CDROM_SEND_PACKET for this.
>
> thanks, the code is at
> http://www.ilovedvd.co.nz/downloads/unix-linux/rpcmgr11.c

How overly complex :-). I wrote a similar tool, dunno if it still works.
Googling shows:

http://www.au.linuxvideo.org/lists/livid-dev/2000-June/msg00649.html

To make the below work, all you probably need to do is change sgio() to
use CDROM_SEND_PACKET for instance. That'll work in 2.4 and 2.6. You
just need to fill a cdrom_generic_command and send it to the cdrom fd.
Ala

struct cdrom_generic_command cgc;

memset(&cgc, 0, sizeof(cgc));
memcpy(cgc.cmd, cdb, sizeof(cdb));
cgc.buffer = the_buffer_to_write_to;
cgc.buflen = sizeof(the_buffer_to_write_to);
cgc.data_direction = CGC_DATA_READ;
cgc.quiet = 1;

if (ioctl(cdrom_fd, CDROM_SEND_PACKET, cdrom_fd) < 0) {
perror("CDROM_SEND_PACKET");
return 1;
}

/* success */
return 0;

--
Jens Axboe