Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 27 Sep 1998 22:29:35 +0200 (CEST)
From:      Sascha Schumann <sas@schell.de>
To:        freebsd-hackers@FreeBSD.ORG
Subject:   CDIOREADTOCENTRY
Message-ID:  <Pine.BSF.4.01.9809272214210.2364-100000@guerilla.foo.bar>

next in thread | raw e-mail | index | archive | help
Hi peers,

I've got a problem getting CDIOREADTOCENTRY to work properly with a
Toshiba on -current (last cvsup two days ago).

The attached program outputs for every CDIOREADTOCENTRY a EINVAL meaning
that a) address_format is incorrect (!CD_MSF_FORMAT && !CD_LBA_FORMAT) or
b) track is illegal, if it is set from the caller.

There doesn't seem to be an obvious error in my program nor in wcd.c. Has
anyone already encountered such a behaviour?


    Sascha
   

-----------------------------
#include <sys/ioctl.h>
#include <sys/cdio.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

main()
{
	int fd;
	int i;
	char *drive = "/dev/wcd0a";
	struct ioc_read_toc_single_entry tec;
	struct ioc_read_toc_entry tex;
	struct ioc_toc_header th;
	
	fd = open(drive, O_RDWR);
	if(fd == -1) {
		perror("open");
		exit(1);
	}

	if(ioctl(fd, CDIOREADTOCHEADER, &th)) {
		perror("cdioreadtocheader");
		exit(1);
	}
	
	tex.data_len = (th.ending_track - th.starting_track + 1) * 
			sizeof(struct cd_toc_entry);
	tex.data = malloc(tex.data_len);
	tex.starting_track = 1;
	tex.address_format = CD_LBA_FORMAT;
	
	if(ioctl(fd, CDIOREADTOCENTRYS, &tex) < 0) {
		perror("cdioreadtocentrys");
	}
	
	for(i = th.starting_track; i <= th.ending_track; i++) {
		memset(&tec, 0, sizeof(tec));
		tec.track = i; /* also doesn't work, if track = 0 */
		tec.address_format = CD_LBA_FORMAT;
		if(ioctl(fd, CDIOREADTOCENTRY, &tec) < 0)
			perror("cdioreadtocentry");
		else
			printf("addr: %d \n", ntohl(tec.entry.addr.lba));
		printf("%d\n", ntohl(tex.data[i].addr.lba));
	}
	close(fd);
}


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.01.9809272214210.2364-100000>