From owner-freebsd-ports@FreeBSD.ORG Thu Oct 30 19:24:16 2003 Return-Path: Delivered-To: freebsd-ports@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CB94816A4CE for ; Thu, 30 Oct 2003 19:24:16 -0800 (PST) Received: from cod.melbpc.org.au (cod.melbpc.org.au [203.12.152.54]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3BF0543FDD for ; Thu, 30 Oct 2003 19:24:14 -0800 (PST) (envelope-from kpeter@melbpc.org.au) Received: from 127.0.0.1 (localhost.melbpc.org.au [127.0.0.1]) by av.domain.name (Postfix) with SMTP id 4691725E11 for ; Fri, 31 Oct 2003 14:24:16 +1100 (EST) Received: by cod.melbpc.org.au (Postfix, from userid 1006) id 29AB325E0B; Fri, 31 Oct 2003 14:24:16 +1100 (EST) Received: from melbpc.org.au (emel025.melbpc.org.au [203.221.42.25]) by cod.melbpc.org.au (Postfix) with ESMTP id 7C33325E3E for ; Fri, 31 Oct 2003 14:23:43 +1100 (EST) Message-ID: <3FA1D5B6.3040605@melbpc.org.au> Date: Fri, 31 Oct 2003 14:23:34 +1100 From: Peter Kostouros Organization: Melbourne PC User Group User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.6a) Gecko/20031027 X-Accept-Language: en-us, en MIME-Version: 1.0 To: ports@FreeBSD.ORG Content-Type: multipart/mixed; boundary="------------040005040005070008030001" X-Spam-Status: No, hits=0.8 required=8.0 tests=AWL,BAYES_30,PATCH_UNIFIED_DIFF,USER_AGENT_MOZILLA_UA version=2.55 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.55 (1.174.2.19-2003-05-19-exp) Subject: [patch] dagrab post new ATA code X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: kpeter@melbpc.org.au List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 Oct 2003 03:24:16 -0000 This is a multi-part message in MIME format. --------------040005040005070008030001 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Hi I have attached a patch that got dagrab working for me again after the new ATA code was imported into CURRENT. The patch may need further work, but for those interested ... -- Regards Peter As always the organisation disavows knowledge of this email --------------040005040005070008030001 Content-Type: text/plain; name="patch-cd_read_audio" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="patch-cd_read_audio" --- dagrab.c.after.patch Fri Oct 31 12:02:06 2003 +++ dagrab.c Fri Oct 31 14:00:45 2003 @@ -106,6 +106,7 @@ #include #include #include +#include #define CDDEVICE "/dev/cdrom" #define N_BUF 12 #define OVERLAP 2 @@ -203,7 +204,8 @@ {"@DIS",KW_DISK,"Disk name (guessed)"} }; - +int block_size = CD_FRAMESIZE_RAW; + struct Wavefile cd_newave(unsigned size) { struct Wavefile dummy={{'R','I','F','F'}, /* Rid */ @@ -242,27 +244,33 @@ return ioctl(cdrom_fd,CDIOREADTOCENTRY,Te); } -void cd_read_audio(int lba,int num,char *buf) - /* reads num CD_FRAMESIZE_RAW sized - sectors in buf, starting from lba*/ - /*NOTE: if num>CDROM_NBLOCKS_BUFFER as defined in ide_cd.c (8 in linux 2.0.32) - jitter correction may be required inside the block. */ -{ - struct ioc_read_audio ra; - - ra.address.lba=lba; - ra.address_format=CD_LBA_FORMAT; - ra.nframes=num; - ra.buffer=buf; - if(ioctl(cdrom_fd,CDIOCREADAUDIO,&ra)){ - /*fprintf(stderr,"%s: read raw ioctl failed \n",progname);*/ - fprintf(stderr,"\n%s: read raw ioctl failed at lba %d length %d: %s\n", - progname,lba,num,strerror(errno)); - exit(1); - } +/* Original documentation for cd_read_audio: + * + * reads num CD_FRAMESIZE_RAW sized sectors in buf, starting from lba + * + * NOTE: if num > CDROM_NBLOCKS_BUFFER as defined in ide_cd.c (8 in linux 2.0.32) + * jitter correction may be required inside the block. + */ +void cd_read_audio(int lba, int num, char *buf) +{ + if (lba >= 0) + { + if (lseek(cdrom_fd, lba * block_size, SEEK_SET) == -1) + { + fprintf(stderr, "\n%s: read failed at lba %d: %s\n", + progname, lba * block_size, strerror(errno)); + exit (errno); + } + } + + if (read(cdrom_fd, buf, num * block_size) == -1) + { + fprintf(stderr, "\n%s: read failed at lba %d length %d: %s\n", + progname, lba, num, strerror(errno)); + exit (errno); + } } - // CDDB section static int cddb_sock; @@ -655,7 +663,7 @@ if ((cdrom_fd=open(cd_dev,O_RDONLY))==-1){ fprintf(stderr,"%s: error opening device %s\n",progname,cd_dev); exit(1); - } + } if(cd_get_tochdr(&Th)){ fprintf(stderr,"%s: read TOC ioctl failed: %s\n",progname,strerror(errno)); exit(1); @@ -987,6 +995,7 @@ char path[500]; FILE *f; progname=av[0]; + while((c=getopt(ac,av,"pshaivCSNd:f:n:o:k:r:t:m:e:H:P:D:"))!=-1){ switch(c){ case 'h':usage();break; @@ -1064,9 +1073,7 @@ opt_chmod=0660; if(opt_verbose) fprintf(stderr, "strange chmod value, setting to 0660\n"); } - opt_bufsize=CD_FRAMESIZE_RAW * opt_blocks; - opt_ibufsize=opt_bufsize/sizeof(int); - opt_bufstep=opt_blocks-opt_overlap; + if((optind==ac)&&!all_tracks&&!opt_save) { if(disp_TOC){ if(cd_getinfo(cd_dev,&tl)) @@ -1075,11 +1082,24 @@ exit(0); } else usage(); - }; + } if(cd_getinfo(cd_dev,&tl)){ exit(1); } + + /* Initialise global variable block_size */ + if (ioctl(cdrom_fd, CDRIOCGETBLOCKSIZE, &block_size) == -1) + { + fprintf(stderr, "\nioctl error: %s\n", strerror(errno)); + exit (errno); + } + + /* Set opt_* variables now that block_size is found. */ + opt_bufsize = block_size * opt_blocks; + opt_ibufsize = opt_bufsize / sizeof(int); + opt_bufstep = opt_blocks - opt_overlap; + if(disp_TOC)cd_disp_TOC(&tl); if(opt_save && (tl.cddb!=NULL)){ if(tl.gnr==NULL) --------------040005040005070008030001--