From e0d9f4b42a7a94d3a9a824a5f1a13a4734b09191 Mon Sep 17 00:00:00 2001 From: xiphmont Date: Thu, 14 Aug 2008 13:56:20 +0000 Subject: [PATCH] Add updated functionality equivalent to several patches RedHat deployed in previous cdparanoia versions. git-svn-id: http://svn.xiph.org/trunk@15181 0101bb08-14d6-0310-b084-bc0e0c8e3800 --- cdparanoia/cdparanoia.1 | 20 ++++++++++++++++++-- cdparanoia/interface/scsi_interface.c | 10 ++-------- cdparanoia/interface/utils.h | 12 ++++-------- cdparanoia/main.c | 34 +++++++++++++++++++++++++++++----- cdparanoia/paranoia/gap.c | 1 + 5 files changed, 54 insertions(+), 23 deletions(-) diff --git a/cdparanoia/cdparanoia.1 b/cdparanoia/cdparanoia.1 index a68bc116e..bfe77379a 100644 --- a/cdparanoia/cdparanoia.1 +++ b/cdparanoia/cdparanoia.1 @@ -125,15 +125,31 @@ to specify devices of any valid interface type (ATAPI, SCSI or proprietary). .TP +.BI "\-k --force-cooked-device " device +This option forces use of the old 'cooked ioctl' kernel +interface with the specified cdrom device. The cooked ioctl interface +is obsolete in Linux 2.6 if it is present at all. +.B \-k +cannot be used +with +.B \-d +or +.BR \-g . + + +.TP .BI "\-g --force-generic-device " device This option forces use of the old 'generic scsi' (sg) kernel -interface with the specified generic scsi device. +interface with the specified generic scsi device. +.B \-g +cannot be used with +.BR \-k . .B \-g may be used with .B \-d to explicitly set both the SCSI cdrom and generic (sg) devices seperately. This option is only useful on -non-standard SCSI setups and when using the generic scsi (sg) driver. +obsolete SCSI setups and when using the generic scsi (sg) driver. .TP .BI "\-S --force-read-speed " number diff --git a/cdparanoia/interface/scsi_interface.c b/cdparanoia/interface/scsi_interface.c index 3b5ea98d4..04ca569cb 100644 --- a/cdparanoia/interface/scsi_interface.c +++ b/cdparanoia/interface/scsi_interface.c @@ -14,12 +14,6 @@ /* hook */ static int Dummy (cdrom_drive *d,int s){ - if(d->opened){ - fprintf(stderr,"Disabling cache\n"); - set_read_ahead(d, - cdda_track_firstsector(d,1), - cdda_track_lastsector(d,d->tracks)); - } return(0); } @@ -58,7 +52,7 @@ static void tweak_SG_buffer(cdrom_drive *d) { /* so since we never go above q->max_sectors, we should never get -EIO. * we might still get -ENOMEM, but we back off for that later. Monty * had an old comment: "not too much; new kernels have trouble with DMA - * "allocation, so be more conservative: 32kB max until I test more + * allocation, so be more conservative: 32kB max until I test more * thoroughly". We're not currently honoring that, because we should * always get -ENOMEM. * @@ -617,7 +611,7 @@ int scsi_enable_cdda (cdrom_drive *d, int fAudioMode){ return(0); } -int set_read_ahead (cdrom_drive *d, int start, int end){ +static int set_read_ahead (cdrom_drive *d, int start, int end){ int err; unsigned char sense[SG_MAX_SENSE]; unsigned char cmd[12]={0xA7, /* SET READ AHEAD */ diff --git a/cdparanoia/interface/utils.h b/cdparanoia/interface/utils.h index 7f28fdf9e..c9647dad3 100644 --- a/cdparanoia/interface/utils.h +++ b/cdparanoia/interface/utils.h @@ -111,9 +111,8 @@ static void cderror(cdrom_drive *d,const char *s){ d->errorbuf=catstring(d->errorbuf,s); break; case CDDA_MESSAGE_FORGETIT: - ; default: - ; + break; } } } @@ -128,9 +127,8 @@ static void cdmessage(cdrom_drive *d,const char *s){ d->messagebuf=catstring(d->messagebuf,s); break; case CDDA_MESSAGE_FORGETIT: - ; default: - ; + break; } } } @@ -172,9 +170,8 @@ static void idperror(int messagedest,char **messages,const char *f, } break; case CDDA_MESSAGE_FORGETIT: - ; default: - ; + break; } } if(malloced)free(buffer); @@ -210,9 +207,8 @@ static void idmessage(int messagedest,char **messages,const char *f, } break; case CDDA_MESSAGE_FORGETIT: - ; default: - ; + break; } } if(malloced)free(buffer); diff --git a/cdparanoia/main.c b/cdparanoia/main.c index cd5c8680a..677d25fd4 100644 --- a/cdparanoia/main.c +++ b/cdparanoia/main.c @@ -242,7 +242,13 @@ VERSION"\n" " verification to n sectors\n" " -d --force-cdrom-device : use specified device; disallow \n" " autosense\n" -" -g --force-generic-device : use specified generic scsi device\n" +" -k --force-cooked-device : use specified cdrom device and force\n" +" use of the old 'cooked ioctl' kernel\n" +" interface. -k cannot be used with -d\n" +" or -g.\n" +" -g --force-generic-device : use specified generic scsi device and\n" +" force use of the old SG kernel\n" +" interface. -g cannot be used with -k.\n" " -S --force-read-speed : read from device at specified speed\n" " -t --toc-offset : Add sectors to the values reported\n" " when addressing tracks. May be negative\n" @@ -576,7 +582,7 @@ static void callback(long inpos, int function){ memset(dispcache,' ',graph); } -const char *optstring = "escCn:o:O:d:g:S:prRwafvqVQhZz::YXWBi:Tt:l:"; +const char *optstring = "escCn:o:O:d:g:k:S:prRwafvqVQhZz::YXWBi:Tt:l:"; struct option options [] = { {"stderr-progress",no_argument,NULL,'e'}, @@ -586,6 +592,7 @@ struct option options [] = { {"force-default-sectors",required_argument,NULL,'n'}, {"force-search-overlap",required_argument,NULL,'o'}, {"force-cdrom-device",required_argument,NULL,'d'}, + {"force-cooked-device",required_argument,NULL,'k'}, {"force-generic-device",required_argument,NULL,'g'}, {"force-read-speed",required_argument,NULL,'S'}, {"sample-offset",required_argument,NULL,'O'}, @@ -646,6 +653,7 @@ int main(int argc,char *argv[]){ int force_cdrom_overlap=-1; char *force_cdrom_device=NULL; char *force_generic_device=NULL; + char *force_cooked_device=NULL; int force_cdrom_speed=-1; int max_retries=20; char *span=NULL; @@ -687,9 +695,22 @@ int main(int argc,char *argv[]){ force_cdrom_device=copystring(optarg); break; case 'g': + if(force_cooked_device){ + report3("-g option incompatable with -k\n"); + exit(1); + } + force_cooked_device=NULL; if(force_generic_device)free(force_generic_device); force_generic_device=copystring(optarg); break; + case 'k': + if(force_generic_device || force_cdrom_device){ + report3("-k option incompatable with -d and -g\n"); + exit(1); + } + if(force_cooked_device)free(force_cooked_device); + force_cooked_device=copystring(optarg); + break; case 'S': force_cdrom_speed=atoi(optarg); break; @@ -730,7 +751,7 @@ int main(int argc,char *argv[]){ break; case 'e': callscript=1; - fprintf(stderr,"Sending all callcaks to stderr for wrapper script\n"); + fprintf(stderr,"Sending all callbacks to stderr for wrapper script\n"); break; case 'V': fprintf(stderr,VERSION); @@ -829,7 +850,9 @@ int main(int argc,char *argv[]){ /* Query the cdrom/disc; we may need to override some settings */ - if(force_generic_device) + if(force_cooked_device){ + d=cdda_identify_cooked(force_cooked_device,verbose,NULL); + }else if(force_generic_device) d=cdda_identify_scsi(force_generic_device,force_cdrom_device,verbose,NULL); else if(force_cdrom_device) @@ -928,7 +951,8 @@ int main(int argc,char *argv[]){ exit(1); } - cdda_cache_sectors(d); + /* Determine drive caching behavior for cache-busting purposes */ + /* cdda_cache_sectors(d); */ /* Dump the TOC */ if(query_only || verbose)display_toc(d); diff --git a/cdparanoia/paranoia/gap.c b/cdparanoia/paranoia/gap.c index 4ac957e07..94113a40a 100644 --- a/cdparanoia/paranoia/gap.c +++ b/cdparanoia/paranoia/gap.c @@ -9,6 +9,7 @@ #include "p_block.h" #include "cdda_paranoia.h" #include "gap.h" +#include /**** Gap analysis code ***************************************************/ -- 2.11.4.GIT