On Thu, Jun 09, 2005 at 10:12:28PM +0200, Nicolas DEGAND wrote:
> Le Jeudi 9 Juin 2005 19:15, vous avez écrit :
> > On Thu, Jun 09, 2005 at 04:41:46PM +0200, Nicolas DEGAND wrote:
> > > Le Jeudi 9 Juin 2005 13:47, vous avez écrit :
> > > > The strace shows that you didn't have dbus running at that time, which
> > > > hal needs thus giving you no usefull output :)
> > >
> > > Oops. Stupid me. Thought that as hald was already running, and as I
> > > cannot stop it (and as I thought there was confusion between the two hald
> > > after seeing the output of the strace below), the best way to test it was
> > > not to start it at boot by deactivating dbus-1. Bad idea.
> > >
> > > Here are (I hope) correct outputs
> >
> > Hal is already running (and now in state D). So it can't startup.. You need
> > to disable the hal startup at boot and run it manually. For example by
> > placing exit at the top of /etc/dbus-1/event.d/20hal
> >
> >   Sjoerd
> 
> I hope this time, everything is ok. Here is the end of strace output (hald is 
> locked in D+ status, strace is in S+)
> 
> lstat64("/sys/bus/pci/devices/serial8250", 0xbfffe6ec) = -1 ENOENT (No such 
> file or directory)
> lstat64("/sys/bus/platform/devices/serial8250", {st_mode=S_IFLNK|0777, 
> st_size=0, ...}) = 0
> readlink("/sys/bus/platform/devices/serial8250", 
  ....
> gettimeofday({1118346467, 267435}, NULL) = 0
> poll([{fd=3, events=POLLIN}, {fd=6, events=POLLIN}, {fd=5, events=POLLIN}, 
> {fd=10, events=POLLIN|POLLPRI}, {fd=7, events=POLLIN}], 5, 1991) = 0
> gettimeofday({1118346469, 259799}, NULL) = 0
> open("/dev/hdc", O_RDONLY|O_NONBLOCK|O_EXCL|O_LARGEFILE) = 0
> ioctl(0, CDROM_DRIVE_STATUS, 0x7fffffff) = 1
> close(0)                                = 0
> open("/dev/hdd", O_RDONLY|O_NONBLOCK|O_EXCL|O_LARGEFILE) = 0
> ioctl(0, CDROM_DRIVE_STATUS, 0x7fffffff) = 1
> close(0)                                = 0
> time(NULL)                              = 1118346469
> gettimeofday({1118346469, 271622}, NULL) = 0
> poll([{fd=3, events=POLLIN}, {fd=6, events=POLLIN}, {fd=5, events=POLLIN}, 
> {fd=10, events=POLLIN|POLLPRI}, {fd=7, events=POLLIN}], 5, 1989) = 0
> gettimeofday({1118346471, 262122}, NULL) = 0
> open("/dev/hdc", O_RDONLY|O_NONBLOCK|O_EXCL|O_LARGEFILE) = 0
> ioctl(0, CDROM_DRIVE_STATUS, 0x7fffffff) = 1
> close(0)                                = 0
> open("/dev/hdd", O_RDONLY|O_NONBLOCK|O_EXCL|O_LARGEFILE
> 
> Here is the hald output (stuck in D+) :

Here hal tries to detect if there is a disc in your cd drive..  Odd that it
hangs there.

Could you compile and run the folowing test program?
Compile with:  gcc -Wall -D_FILE_OFFSET_BITS=64 test.c -o test

And then run like this: ./test /dev/hdc /dev/hdd
Where i'm assuming that /dev/hdc and /dev/hdd are your cdrom drives, judging
from hal's strace output.

That basically does the same as hal does for polling your drive. So it's
interested to see if it gets stuck in D too.. For best effect, run when hald is
disabled..

  Sjoerd
-- 
For fast-acting relief, try slowing down.
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <linux/cdrom.h>

static void
detect_disc (const char *device_file)
{
	int fd;
	int type;
  printf("detect disc on %s\n", device_file);

	/* Check handling */
	fd = open (device_file, O_RDONLY | O_NONBLOCK | O_EXCL);
	if (fd < 0)
		return;

	/* 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) {
		close (fd);
		return;
	}

	/* check for audio/data/blank */
	type = ioctl (fd, CDROM_DISC_STATUS, CDSL_CURRENT);
	switch (type) {
	case CDS_AUDIO:		/* audio CD */
		printf("Disc in %s has audio\n", device_file);
		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);
		break;
	case CDS_NO_INFO:	/* blank or invalid CD */
		printf ("Disc in %s is blank\n", device_file);
		break;
		
	default:		/* should never see this */
		printf ("Disc in %s returned unknown CDROM_DISC_STATUS\n", device_file);
		break;
	}

	close (fd);
	return;
}

int
main(int argc, char **argv) {
  for (;;) {
    int x;
    for (x = 1; x < argc; x++) {
      detect_disc(argv[x]);
    }
    sleep(1);
  }
}

Reply via email to