revision 777:60431d09605c
summary |
tree |
shortlog |
changelog |
graph |
changeset |
raw | bz2 | zip | gz changeset | 777:60431d09605c |
parent | 776:b12d8be15387 |
child | 778:a34b180d92f7 |
author | nkeynes |
date | Mon Jul 28 06:29:46 2008 +0000 (15 years ago) |
Display the CD-Rom drive names for consistency with the OS X implementation
1.1 --- a/src/drivers/cd_linux.c Mon Jul 28 06:03:05 2008 +00001.2 +++ b/src/drivers/cd_linux.c Mon Jul 28 06:29:46 2008 +00001.3 @@ -50,6 +50,7 @@1.4 static gboolean linux_image_is_valid( FILE *f );1.5 static gdrom_disc_t linux_open_device( const gchar *filename, FILE *f );1.6 static gdrom_error_t linux_read_disc_toc( gdrom_image_t disc );1.7 +static gdrom_error_t linux_identify_drive( int fd, unsigned char *buf, int buflen );1.8 static gdrom_error_t linux_read_sector( gdrom_disc_t disc, uint32_t sector,1.9 int mode, unsigned char *buf, uint32_t *length );1.10 static gdrom_error_t linux_send_command( int fd, char *cmd, unsigned char *buffer, size_t *buflen,1.11 @@ -74,7 +75,9 @@1.12 int caps = ioctl(fd, CDROM_GET_CAPABILITY);1.13 if( caps != -1 ) {1.14 /* Appears to support CDROM functions */1.15 - list = g_list_append( list, gdrom_device_new(ent->fs_spec, ent->fs_spec));1.16 + char buf[32];1.17 + linux_identify_drive( fd, buf, sizeof(buf) );1.18 + list = g_list_append( list, gdrom_device_new(ent->fs_spec, buf));1.19 }1.20 close(fd);1.21 }1.22 @@ -201,6 +204,36 @@1.23 return linux_send_command( fd, cmd, NULL, &buflen, CGC_DATA_NONE );1.24 }1.26 +static unsigned char *trim( unsigned char *src )1.27 +{1.28 + char *p = src + strlen(src)-1;1.29 + while( isspace(*src) )1.30 + src++;1.31 + while( p >= src && isspace(*p) )1.32 + *p-- = '\0';1.33 + return src;1.34 +}1.35 +static gdrom_error_t linux_identify_drive( int fd, unsigned char *buf, int buflen )1.36 +{1.37 + unsigned char ident[256];1.38 + uint32_t identlen = 256;1.39 + char cmd[12] = {0x12,0,0,0, 0xFF,0,0,0, 0,0,0,0};1.40 + gdrom_error_t status =1.41 + linux_send_command( fd, cmd, ident, &identlen, CGC_DATA_READ );1.42 + if( status == 0 ) {1.43 + char vendorid[9];1.44 + char productid[17];1.45 + char productrev[5];1.46 + memcpy( vendorid, ident+8, 8 ); vendorid[8] = 0;1.47 + memcpy( productid, ident+16, 16 ); productid[16] = 0;1.48 + memcpy( productrev, ident+32, 4 ); productrev[4] = 0;1.49 +1.50 + snprintf( buf, buflen, "%.8s %.16s %.4s", trim(vendorid),1.51 + trim(productid), trim(productrev) );1.52 + }1.53 + return status;1.54 +}1.55 +1.56 static gdrom_error_t linux_read_sector( gdrom_disc_t disc, uint32_t sector,1.57 int mode, unsigned char *buf, uint32_t *length )1.58 {
.