/*
ide-atapi
Copyright (c) 2007 Carlo Marcelo Arenas Belon
ide-atapi is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
#include
#include
#include
#include
#include
#include
#include
#include
int main (int argc, char *argv[])
{
struct cdrom_generic_command cgc;
struct request_sense sense;
unsigned char buf[250];
int i;
if (argc < 2) {
printf("Usage: %s \n", argv[0]);
printf("\n");
printf(" device: where the commands are send\n");
printf("\n");
return 1;
}
memset (&cgc, 0, sizeof(struct cdrom_generic_command));
memset (&sense, 0, sizeof(struct request_sense));
memset (&buf, 0, sizeof(buf));
int fd = open (argv[1], O_RDONLY | O_NONBLOCK);
if (fd < 0) {
printf("couldn't open device %s\n", argv[1]);
return 1;
}
cgc.cmd[0] = GPCMD_GET_CONFIGURATION;
cgc.cmd[1] = 0x00;
cgc.cmd[8] = sizeof(buf);
cgc.timeout = 100;
cgc.buffer = buf;
cgc.buflen = sizeof(buf);
cgc.data_direction = CGC_DATA_READ;
cgc.sense = &sense;
cgc.quiet = 0;
i = ioctl (fd, CDROM_SEND_PACKET, &cgc);
if (i < 0) {
printf("command failed\n");
close (fd);
return 1;
}
printf("Response raw dump:\n");
for (i = 0; i