NetBSD Problem Report #6093

Received: (qmail 26398 invoked from network); 3 Sep 1998 12:41:49 -0000
Message-Id: <199809031240.FAA03610@ldc-gw-cs.cs.wwu.EDU>
Date: Thu, 3 Sep 1998 05:40:19 -0700 (PDT)
From: duwe@caldera.de
To: gnats-bugs@gnats.netbsd.org
Subject: -current cannot mount multisession CDs properly (+fix)
X-Send-Pr-Version: www-1.0

>Number:         6093
>Category:       kern
>Synopsis:       -current cannot mount multisession CDs properly (+fix)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    is
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Sep 03 05:50:01 +0000 1998
>Closed-Date:    Mon May 31 09:11:58 +0000 1999
>Last-Modified:  Mon May 31 09:15:19 +0000 1999
>Originator:     Torsten Duwe
>Release:        1998-08-22 tarballs compile
>Organization:
Caldera, Germany
>Environment:
NetBSD friedwart 1.3G NetBSD 1.3G (FRIEDWART) #5: Thu Sep  3 12:54:47 MEST 1998     torsten@friedwart:/usr/src/sys/arch/i386/compile/FRIEDWART i386

using egcs, UVM, new_pmap (but all of that should't matter... ;-)

>Description:
While most other OSes can read multisession CD-Rs at no sweat (e.g. Linux
since 1995 !) NetBSD presents only the first session written. Given
this time factor and how bad it makes us look I've classified this
"serious".

>How-To-Repeat:
Quite obvious:

1. write a CD-R with an ISO-FS on it, using Rockridge Extensions.
   use the multisession option e. g. in cdrecord and leave room for a 
   second session on the CD-R.
2. add a second session (currend mkisofs and cdrecord will let you do this)

   alternatively get hold of an already-written multisession CD-R

3. mount it on a NetBSD system.

4. try to read files from the second session.
>Fix:

I have a patch ready, but I'm afraid cut-and-pasteing it here will ruin
the tab stops. I'll send it as reply mail to the PR confirmation...
>Release-Note:
>Audit-Trail:

From: Torsten Duwe <duwe@ns.lst.de>
To: gnats-bugs@netbsd.org
Cc:  Subject: kern/6093
Date: Tue, 8 Sep 1998 06:20:12 +0200 (MEST)

 [Hmm, didn't get a confirmation mail. Maybe I've filtered it. anyway...]

 --- /sys/sys/cdio.h.orig	Tue Aug 18 13:13:23 1998
 +++ /sys/sys/cdio.h	Wed Sep  2 17:51:57 1998
 @@ -184,6 +184,9 @@
  #define CDIOREADTOCENTRIES _IOWR('c', 5, struct ioc_read_toc_entry)
  #define CDIOREADTOCENTRYS _IOWR('c', 5, struct ioc_read_toc_entry)

 +/* read LBA start of a given session; 0=last, others not yet supported */
 +#define CDIOREADMSADDR _IOWR('c', 6, int)
 +
  struct	ioc_patch {
  	u_char	patch[4];	/* one for each channel */
  };
 --- /sys/dev/scsipi/cd.c.orig	Mon Aug 17 13:16:31 1998
 +++ /sys/dev/scsipi/cd.c	Thu Sep  3 02:02:07 1998
 @@ -120,7 +120,7 @@
  int	cd_reset __P((struct cd_softc *));
  int	cd_read_subchannel __P((struct cd_softc *, int, int, int,
  	    struct cd_sub_channel_info *, int));
 -int	cd_read_toc __P((struct cd_softc *, int, int, void *, int));
 +int	cd_read_toc __P((struct cd_softc *, int, int, void *, int, int));
  int	cd_get_parms __P((struct cd_softc *, int));
  int	cd_load_toc __P((struct cd_softc *, struct cd_toc *));

 @@ -773,7 +773,7 @@
  	case CDIOREADTOCHEADER: {
  		struct ioc_toc_header th;

 -		if ((error = cd_read_toc(cd, 0, 0, &th, sizeof(th))) != 0)
 +		if ((error = cd_read_toc(cd, 0, 0, &th, sizeof(th), 0)) != 0)
  			return (error);
  		if (cd->sc_link->quirks & ADEV_LITTLETOC) {
  #if BYTE_ORDER == BIG_ENDIAN
 @@ -799,7 +799,7 @@
  		    len < sizeof(struct cd_toc_entry))
  			return (EINVAL);
  		error = cd_read_toc(cd, te->address_format, te->starting_track,
 -		    &toc, len + sizeof(struct ioc_toc_header));
 +		    &toc, len + sizeof(struct ioc_toc_header), 0);
  		if (error)
  			return (error);
  		if (te->address_format == CD_LBA_FORMAT)
 @@ -826,6 +826,39 @@
  		    sizeof(th->ending_track)));
  		return (copyout(toc.entries, te->data, len));
  	}
 +	case CDIOREADMSADDR: {
 +		struct cd_toc toc;
 +		int sessno = *(int*)addr;
 +		struct cd_toc_entry *cte;
 +
 +		if (sessno != 0)
 +			return (EINVAL);
 +
 +		error = cd_read_toc(cd, 0, 0, &toc,
 +		  sizeof(struct ioc_toc_header) + sizeof(struct cd_toc_entry),
 +		  0x40 /* control word for "get MS info" */);
 +
 +		if (error)
 +			return (error);
 +
 +		cte = &toc.entries[0];
 +		if (cd->sc_link->quirks & ADEV_LITTLETOC) {
 +#if BYTE_ORDER == BIG_ENDIAN
 +			bswap((u_int8_t*)&cte->addr, sizeof(cte->addr));
 +#endif
 +		} else
 +			cte->addr.lba = ntohl(cte->addr.lba);
 +		if (cd->sc_link->quirks & ADEV_LITTLETOC) {
 +#if BYTE_ORDER == BIG_ENDIAN
 +			bswap((u_int8_t*)&toc.header.len, sizeof(toc.header.len));
 +#endif
 +		} else
 +			toc.header.len = ntohs(toc.header.len);
 +
 +		*(int*)addr = (toc.header.len >= 10 && cte->track > 1) ?
 +			cte->addr.lba : 0;
 +		return 0;
 +	}
  	case CDIOCSETPATCH: {
  		struct ioc_patch *arg = (struct ioc_patch *)addr;

 @@ -1165,9 +1198,9 @@
   * Read table of contents
   */
  int
 -cd_read_toc(cd, mode, start, data, len)
 +cd_read_toc(cd, mode, start, data, len, control)
  	struct cd_softc *cd;
 -	int mode, start, len;
 +	int mode, start, len, control;
  	void *data;
  {
  	struct scsipi_read_toc scsipi_cmd;
 @@ -1186,6 +1219,7 @@
  		scsipi_cmd.byte2 |= CD_MSF;
  	scsipi_cmd.from_track = start;
  	_lto2b(ntoc, scsipi_cmd.data_len);
 +	scsipi_cmd.control = control;
  	return (scsipi_command(cd->sc_link,
  	    (struct scsipi_generic *)&scsipi_cmd,
  	    sizeof(struct scsipi_read_toc), (u_char *)data, len, CDRETRIES,
 @@ -1199,13 +1233,13 @@
  {
  	int ntracks, len, error;

 -	if ((error = cd_read_toc(cd, 0, 0, toc, sizeof(toc->header))) != 0)
 +	if ((error = cd_read_toc(cd, 0, 0, toc, sizeof(toc->header), 0)) != 0)
  		return (error);

  	ntracks = toc->header.ending_track - toc->header.starting_track + 1;
  	len = (ntracks + 1) * sizeof(struct cd_toc_entry) +
  	    sizeof(toc->header);
 -	if ((error = cd_read_toc(cd, CD_MSF_FORMAT, 0, toc, len)) != 0)
 +	if ((error = cd_read_toc(cd, CD_MSF_FORMAT, 0, toc, len, 0)) != 0)
  		return (error);
  	return (0);
  }
 --- /sys/isofs/cd9660/cd9660_vfsops.c.orig	Mon Aug 10 13:11:27 1998
 +++ /sys/isofs/cd9660/cd9660_vfsops.c	Thu Sep  3 01:53:43 1998
 @@ -57,6 +57,7 @@
  #include <sys/disklabel.h>
  #include <sys/device.h>
  #include <sys/ioctl.h>
 +#include <sys/cdio.h>
  #include <sys/errno.h>
  #include <sys/malloc.h>
  #include <sys/stat.h>
 @@ -238,6 +239,7 @@
  	struct iso_primary_descriptor *pri;
  	struct iso_directory_record *rootp;
  	int logical_block_size;
 +	int sess = 0;

  	if (!ronly)
  		return EROFS;
 @@ -265,9 +267,17 @@
  	 * whichever is greater.  For now, we'll just use a constant.
  	 */
  	iso_bsize = ISO_DEFAULT_BLOCK_SIZE;
 +
 +	error = VOP_IOCTL(devvp, CDIOREADMSADDR, (caddr_t)&sess, 0, FSCRED, p);
 +	if (error)
 +		sess = 0;	/* never mind */
 +#if 0
 +	else
 +		printf("cdfs: detected multi-session at offset %d\n", sess);
 +#endif

  	for (iso_blknum = 16; iso_blknum < 100; iso_blknum++) {
 -		if ((error = bread(devvp, iso_blknum * btodb(iso_bsize),
 +		if ((error = bread(devvp, (iso_blknum+sess) * btodb(iso_bsize),
  				   iso_bsize, NOCRED, &bp)) != 0)
  			goto out;

State-Changed-From-To: open->analyzed 
State-Changed-By: is 
State-Changed-When: Mon Jan 4 05:59:48 PST 1999 
State-Changed-Why:  
I'm testing this. 
. 


Responsible-Changed-From-To: kern-bug-people->is 
Responsible-Changed-By: is 
Responsible-Changed-When: Mon Jan 4 05:59:48 PST 1999 
Responsible-Changed-Why:  
I'm testing this. 
State-Changed-From-To: analyzed->feedback 
State-Changed-By: is 
State-Changed-When: Mon Jan 4 12:00:15 PST 1999 
State-Changed-Why:  
Patch applied. Please report whether it works for you, too (NetBSD-current). 

From: Ignatios Souvatzis <is@netbsd.org>
To: gnats-bugs@netbsd.org
Cc:  Subject: kern/6093
Date: Tue, 4 May 1999 14:42:27 +0200

 Please report whether 1.4_BETA or 1.4 work for you.
 	-is

From: Torsten Duwe <duwe@ns.lst.de>
To: gnats-bugs@netbsd.org,
    is@netbsd.org
Cc: current-users@netbsd.org
Subject: kern/6093
Date: Thu,  6 May 1999 12:27:08 +0200 (CEST)

 [this is about the multisession CD fix I submitted]

     Ignatios> Please report whether 1.4_BETA or 1.4 work for you.  -is

 Sorry, it took a while because I wanted to reply with fairly well-founded
 test results rather than a rushed quick answer.

 Tested hardware:
 ================

 AMD K6/200 PC with an internal Ultraplex (Plextor PX-32TS, rev 1.03) at
 an NCR810

 AMD K6-2/350 with an internal Toshiba XM-6402B rev.1008 as secondary IDE
 master

 SparcStation LX

 external CD-R Yamaha CDR400t rev. 1.0j

 another external Ultraplex (identical to the internal above)

 Tested Software:
 ================

 The PCs have fairly late betas of Caldera OpenLinux-2.2 (kernel 2.2.3 or
 above) installed; I used these for reference.

 The SparcStation runs NetBSD-"current" of 1999-04-06 or so (about 1.4_ALPHA)

 Since I haven't gotten at installing the PCs yet, I downloaded the 1.4_BETA
 install floppies from ftp.netbsd.org and booted those.

 Test Results:
 =============

 SparcStation LX with ext. Ultraplex: "invalid argument" (Yikes !)

 K6/200 w/ internal Ultraplex and Linux: "invalid argument" (Whew!)

 K6-2/350 w/ internal ATAPI CD and Linux:			OK.
 K6-2/350 w/ internal ATAPI CD and NetBSD-1.4_BETA floppy:	OK.

 K6/200 w/ external CD-R; NetBSD-1.4_BETA & Linux:	   both OK.

 SparcStation LX with external CD-R, NetBSD-1.4_ALPHA:		OK.

 Conclusion:
 ===========

 The Ultraplex drive, at least with the tested firmware revision, seems to
 require a different SCSI command to read the MS-TOC. This is neither present
 in Linux(-current) nor in NetBSD-current. Maybe for Linux setting
 CONFIG_BLK_DEV_SR_VENDOR will help, but I haven't tested this yet.

 All other drive/SW combinations work fine.

 	Torsten
State-Changed-From-To: feedback->closed 
State-Changed-By: is 
State-Changed-When: Mon May 31 02:11:58 PDT 1999 
State-Changed-Why:  
Works for the submitter and for myself. 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.