From zgabor@zahemszky.hu  Thu Nov 25 16:23:21 2004
Return-Path: <zgabor@zahemszky.hu>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id E8CF816A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 25 Nov 2004 16:23:21 +0000 (GMT)
Received: from zahemszky.hu (103.204-182-adsl-pool.axelero.hu [81.182.204.103])
	by mx1.FreeBSD.org (Postfix) with ESMTP id B8A6143D1F
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 25 Nov 2004 16:23:20 +0000 (GMT)
	(envelope-from zgabor@zahemszky.hu)
Received: from zahemszky.hu (localhost [127.0.0.1])
	by Picasso.Zahemszky.HU (8.13.1/8.13.1) with ESMTP id iAPGOFc1091972
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 25 Nov 2004 17:24:16 +0100 (CET)
	(envelope-from zgabor@zahemszky.hu)
Received: (from zgabor@localhost)
	by zahemszky.hu (8.13.1/8.13.1/Submit) id iAPGOEpW091971;
	Thu, 25 Nov 2004 17:24:14 +0100 (CET)
	(envelope-from zgabor)
Message-Id: <200411251624.iAPGOEpW091971@zahemszky.hu>
Date: Thu, 25 Nov 2004 17:24:14 +0100 (CET)
From: Zahemszky Gabor <gabor@zahemszky.hu>
Reply-To: Zahemszky Gabor <gabor@zahemszky.hu>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] sysutils/dvdbackup cannot get DVD-title
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         74375
>Category:       ports
>Synopsis:       [PATCH] sysutils/dvdbackup cannot get DVD-title
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    ahze
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Nov 25 16:30:28 GMT 2004
>Closed-Date:    Sat Dec 11 22:19:00 GMT 2004
>Last-Modified:  Sat Dec 11 22:19:00 GMT 2004
>Originator:     Zahemszky Gabor
>Release:        FreeBSD 5.3-STABLE i386
>Organization:
>Environment:
System: FreeBSD zahemszky.hu 5.3-STABLE FreeBSD 5.3-STABLE #0: Tue Nov 23 23:53:24 CET 2004 root@Picasso.Zahemszky.HU:/usr/obj/usr/src/sys/PICASSO i386


	
>Description:

With sysutils/dvdbackup, I cannot read the DVD-title.  Neither with a SCSI
DVD-ROM (Pioneer DVD 305S), nor an ATAPI DVD-ROM (Samsung/Toshiba TS-H552B
- I tried both with /dev/acd0 device, and with ATAPICAM as /dev/cd1). As
libdvdcss can read the DVD-title (as we can found in the ~/.dvdcss
"cache directory"), the problem is with dvdbackup.
>How-To-Repeat:
Try running:
dvdbackup -i /dev/dvd -I
and looking the output.  (Or try to make a backup with
dvdbackup -i /dev/dvd -M -o savedir
and read the error message.)
>Fix:

By reading libdvdcss source, and dvdbackup source, the only difference is
that libdvdcss reads one 2048 bytes sector at a time.  But dvdbackup
tries to read eg. 32 bytes in one read.  So the obvious fix is to change
dvdbackup's title-reading to read the whole sector in a temporary buffer,
and after it, copy the DVD-title from this temporary buffer to the correct
location.  This is in the DVDGetTitleName routine

By the way, this patch makes two another corrections:

a) add the missing -n option into the help (it's in the README file, and in
the source, but dvdrecord doesn't write it) - in the "usage" routine

b) corrects some typos. - in the same "usage", and in DVDDisplayInfo

=== patch-dvdbackup.c
*** src/dvdbackup.c.orig	Mon Aug  5 08:08:39 2002
--- src/dvdbackup.c	Thu Nov 25 16:43:19 2004
*************** void usage(){
*** 210,215 ****
--- 210,216 ----
  	fprintf(stderr,"\t-v X\t\twhere X is the amount of verbosity\n");
  	fprintf(stderr,"\t-I\t\tfor information about the DVD\n");
  	fprintf(stderr,"\t-o directory\twhere directory is your backup target\n");
+ 	fprintf(stderr,"\t-n\t\tuse this as DVD name (if we can't get it)\n");
  	fprintf(stderr,"\t-M\t\tbackup the whole DVD\n");
  	fprintf(stderr,"\t-F\t\tbackup the main feature of the DVD\n");
  	fprintf(stderr,"\t-T X\t\tbackup title set X\n");
*************** void usage(){
*** 219,226 ****
  	fprintf(stderr,"\t-a 0\t\tto get aspect ratio 4:3 instead of 16:9 if both are present\n");
  	fprintf(stderr,"\t-h\t\tprint a brief usage message\n");
  	fprintf(stderr,"\t-?\t\tprint a brief usage message\n\n");
! 	fprintf(stderr,"\t-i is manditory\n");
! 	fprintf(stderr,"\t-o is manditory except if you use -I\n");
  	fprintf(stderr,"\t-a is option to the -F switch and has no effect on other options\n");
  	fprintf(stderr,"\t-s and -e should prefereibly be used together with -t \n\n");
  	exit(1);
--- 220,227 ----
  	fprintf(stderr,"\t-a 0\t\tto get aspect ratio 4:3 instead of 16:9 if both are present\n");
  	fprintf(stderr,"\t-h\t\tprint a brief usage message\n");
  	fprintf(stderr,"\t-?\t\tprint a brief usage message\n\n");
! 	fprintf(stderr,"\t-i is mandatory\n");
! 	fprintf(stderr,"\t-o is mandatory except if you use -I\n");
  	fprintf(stderr,"\t-a is option to the -F switch and has no effect on other options\n");
  	fprintf(stderr,"\t-s and -e should prefereibly be used together with -t \n\n");
  	exit(1);
*************** int DVDGetTitleName(const char *device, 
*** 1530,1536 ****
  
  	/* Seek to title of first track, which is at (track_no * 32768) + 40 */
  
! 	if ( 32808 != lseek(filehandle, 32808, SEEK_SET) ) {
  		close(filehandle);
  		fprintf(stderr, "Can't seek DVD device %s - check your DVD device\n", device);
  		return(1);
--- 1531,1537 ----
  
  	/* Seek to title of first track, which is at (track_no * 32768) + 40 */
  
! 	if ( 32768 != lseek(filehandle, 32768, SEEK_SET) ) {
  		close(filehandle);
  		fprintf(stderr, "Can't seek DVD device %s - check your DVD device\n", device);
  		return(1);
*************** int DVDGetTitleName(const char *device, 
*** 1538,1549 ****
  
  	/* Read the DVD-Video title */
  
! 	if ( 32 != read(filehandle, title, 32)) {
  		close(filehandle);
  		fprintf(stderr, "Can't read title from DVD device %s\n", device);
  		return(1);
  	}
  
  	/* Terminate the title string */
  
  	title[32] = '\0';
--- 1539,1556 ----
  
  	/* Read the DVD-Video title */
  
! #define	DVD_SEC_SIZ	2048
! 	{
! 	 char tempBuf[ DVD_SEC_SIZ ];
! 
! 	if ( DVD_SEC_SIZ != read(filehandle, tempBuf, DVD_SEC_SIZ)) {
  		close(filehandle);
  		fprintf(stderr, "Can't read title from DVD device %s\n", device);
  		return(1);
  	}
  
+ 	snprintf( title, 32, "%s", tempBuf + 40 );
+ 	}
  	/* Terminate the title string */
  
  	title[32] = '\0';
*************** int DVDDisplayInfo(dvd_reader_t * _dvd, 
*** 2164,2170 ****
  	DVDGetTitleName(dvd,title_name);
  
  
! 	fprintf(stdout,"\n\n\nDVD-Video information of the DVD with tile %s\n\n", title_name);
  
  	/* Print file structure */
  
--- 2171,2177 ----
  	DVDGetTitleName(dvd,title_name);
  
  
! 	fprintf(stdout,"\n\n\nDVD-Video information of the DVD with title %s\n\n", title_name);
  
  	/* Print file structure */
===
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->ahze 
Responsible-Changed-By: pav 
Responsible-Changed-When: Fri Nov 26 15:12:59 GMT 2004 
Responsible-Changed-Why:  
Letter for you, Michael. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=74375 
State-Changed-From-To: open->feedback  
State-Changed-By: ahze 
State-Changed-When: Thu Dec 9 22:34:06 GMT 2004 
State-Changed-Why:  
Can you please send me a unified diff? 


http://www.freebsd.org/cgi/query-pr.cgi?pr=74375 
State-Changed-From-To: feedback->closed  
State-Changed-By: ahze 
State-Changed-When: Sat Dec 11 22:18:40 GMT 2004 
State-Changed-Why:  
Committed, Thanks 

http://www.freebsd.org/cgi/query-pr.cgi?pr=74375 
>Unformatted:
