On Sun, Mar 19, 2006 at 10:01:14PM +0100, sjoerd wrote:
> On Sun, Mar 19, 2006 at 05:31:22PM +0100, Christian von Kietzell wrote:
> > Hi,
> >
> > whenever I pop a video DVD into my DVD drive (Plextor PX-716A), hal reports
> > it as an empty DVD-ROM medium. If I run "totem dvd:///dev/hdc" it can play
> > the DVD though, so no problem there. I've attached the appropriate
> > hal-device
> > output.
>
> Could you compile the attached program and run it as root with your dvd device
> as first argument (eg gcc probe-volume.c -o probe ; ./probe /dev/hdc) and mail
> the output. Obviously when a video cd is inserted :)
This time with the attachement...
--
Well, you know, no matter where you go, there you are.
-- Buckaroo Banzai
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
***************************************************************************
* CVSID: $Id: probe-volume.c,v 1.26 2006/02/22 21:27:52 david Exp $
*
* probe-volume.c : Probe for volume type (filesystems etc.)
*
* Copyright (C) 2004 David Zeuthen, <[EMAIL PROTECTED]>
*
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
**************************************************************************/
#define TRUE 1
#define FALSE 1
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <stdint.h>
#include <sys/stat.h>
#include <stdint.h>
#include <fcntl.h>
#include <unistd.h>
#include <ctype.h>
#include <linux/kdev_t.h>
#include <linux/cdrom.h>
#include <linux/fs.h>
#include <time.h>
#include <sys/time.h>
int
main (int argc, char *argv[])
{
int fd;
int ret;
char *udi;
char *device_file;
char *parent_udi;
char *sysfs_path;
struct volume_id *vid;
char *stordev_dev_file;
char *partition_number_str;
char *is_disc_str;
int is_disc;
unsigned int partition_number;
unsigned int block_size;
long long vol_size;
int should_probe_for_fs;
long long vol_probe_offset = 0;
fd = -1;
device_file = argv[1];
/* assume failure */
ret = 1;
fd = open (device_file, O_RDONLY);
if (fd < 0)
goto out;
/* block size and total size */
if (ioctl (fd, BLKSSZGET, &block_size) == 0) {
printf("volume.block_size = %d\n", block_size);
}
if (ioctl (fd, BLKGETSIZE64, &vol_size) == 0) {
printf ("volume.size = %llu\n", vol_size);
} else
vol_size = 0;
should_probe_for_fs = TRUE;
if (1) {
int type;
long long capacity;
struct cdrom_tochdr; /* toc_hdr; */
/* Suggested by Alex Larsson to get rid of log spewage
* on Alan's cd changer (RH bug 130649) */
if (ioctl (fd, CDROM_DRIVE_STATUS, CDSL_CURRENT) != CDS_DISC_OK) {
goto out;
}
/* check for audio/data/blank */
type = ioctl (fd, CDROM_DISC_STATUS, CDSL_CURRENT);
printf("Type: 0x%x\n\n", type);
switch (type) {
case CDS_AUDIO: /* audio CD */
printf ("Disc in %s has audio\n\n", device_file);
should_probe_for_fs = FALSE;
break;
case CDS_MIXED: /* mixed mode CD */
printf ("Disc in %s has audio+data\n", device_file);
break;
case CDS_DATA_1: /* data CD */
case CDS_DATA_2:
case CDS_XA_2_1:
case CDS_XA_2_2:
printf ("Disc in %s has data\n", device_file);
//advanced_disc_detect (ctx, udi, fd, device_file);
break;
case CDS_NO_INFO: /* blank or invalid CD */
printf ("Disc in %s is blank\n", device_file);
should_probe_for_fs = FALSE;
break;
default: /* should never see this */
printf ("Disc in %s returned unknown CDROM_DISC_STATUS\n", device_file);
should_probe_for_fs = FALSE;
break;
}
/* see table 87 - Profile List in MMC-5 for details on disc type
* http://www.t10.org/drafts.htm#mmc5
*/
//type = get_disc_type (fd);
//printf ("get_disc_type returned 0x%02x\n", type);
//if (get_disc_capacity_for_type (fd, type, &capacity) == 0) {
// printf ("volume.disc.capacity = %llu\n", capacity);
// }
/* try again, to get last session that way */
if (vol_probe_offset == 0) {
struct cdrom_multisession ms_info;
memset(&ms_info, 0x00, sizeof(ms_info));
ms_info.addr_format = CDROM_LBA;
if (ioctl(fd, CDROMMULTISESSION, &ms_info) == 0)
if (!ms_info.xa_flag)
vol_probe_offset = ms_info.addr.lba * block_size;
}
}
/* good so far */
ret = 0;
out:
if (fd >= 0)
close (fd);
return ret;
}