On Thu, Jun 23, 2005 at 04:32:11PM +0300, Petri T. Koistinen wrote:
> Hi!
> 
> On Thu, 23 Jun 2005, Sjoerd Simons wrote:
> 
> > Are you sure it's hal that's doing this?
> 
> $ sudo apt-get install hal
> ...
> Setting up hal (0.4.8-2) ...
> ...
> Starting system message bus: dbus-1.
> Starting Hardware abstraction layer: hald.
> 
> and all drives open. I close manually, they keep opening again.
> 
> $ sudo killall hald
> I close drives again and they keep being closed.
> 
> $ sudo /usr/sbin/hald
> And drives open their disk bays instantly.
> 
> So I am pretty sure that hald has atleast something to do with this.

Ok, just making sure it's indeed hal that triggers this, because quite odd..
The floppy ticking problem also goes away when your restart hal like that ?

> > It polls the cdrom's status on  a
> > regular basis, but they shouldn't open when doing this. Also hal doesn't 
> > access
> > the floppy drive, so it's kinda weird that it would cause floppydrive 
> > ticks..
> >
> > Are you sure you don't have magicdev installed, which does actually poll the
> > floppy drive iirc ?
> 
> $ dpkg -L magicdev
> Package `magicdev' is not installed.

Ok.

> And I am running latest vanilla kernel from kernel.org fetch via
> cogito/git, but does it really matter here?
> 
> $ uname -a
> Linux dsl-hkigw8g28.dial.inet.fi 2.6.12-git #1 Sun Jun 19 17:37:01 EEST 2005 
> i686 GNU/Linux

We'll see if that matters.. Hopefully not. Could you run the attached test
program, it poll you cdroms for media status just like hal does.

The way to use it is to turn off hal, and run it with your cdrom device names
as arguments. For example ./test /dev/hdc /dev/hdd

  Sjoerd
-- 
A sine curve goes off to infinity, or at least the end of the blackboard.
                -- Prof. Steiner
#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