On Thu, Jun 15, 2006 at 12:15:06AM +0200, Sjoerd Simons wrote:
> On Tue, Jun 13, 2006 at 09:05:38PM -0400, Daniel Schepler wrote:
> > On Tuesday 13 June 2006 17:23 pm, you wrote:
> > > On Mon, Jun 05, 2006 at 12:29:55PM -0400, Daniel Schepler wrote:
> > > > I can confirm that this happens on my laptop as well; when a CD is in 
> > > > the
> > > > drive, I can hear the drive spinning all the time, although at a lower
> > > > speed than when the disc is being read.  After I stop hald manually, the
> > > > drive spins down after about a minute.
> > >
> > > What hal does is poll the cddrive for status every two seconds.. This
> > > shouldn't spin up the drive though.. Could you try to kill/stop the
> > > /usr/lib/hal/hald-addon-storage processes that hal spawns (These poll your
> > > drive) and check if that solves it ?
> > 
> > Yes, that solves it.
> 
> Ok, well in the ioctl's/commands that the addon uses shouldn't spin up the
> drive.. But well, hardware can do odd things :) 
> 
> It would be interested to know what actually triggers the spin of the
> drive.. I've attached a little test program which does two of the three things
> the addon usually does. To compile just run gcc test.c -o test..  After that
> run it as root and pass the device name of your cd drive it 
> (e.g. ./test /dev/hdc).. Please let me know when the drive spins up (if at 
> all) 

And ofcourse i forgot the attachment.. Should be there this time :)

  Sjoerd
-- 
Time is nature's way of making sure that everything doesn't happen at once.

Space is nature's way of making sure that everything doesn't happen to you.
#include <stdio.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <assert.h>
#include <errno.h>

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

#include <linux/cdrom.h>

int
main(int argc, char **argv) {
  unsigned int drive;
  int fd;

  fd = open(argv[1], O_RDONLY | O_NONBLOCK | O_EXCL);
  if (fd < 0 && errno == EBUSY) {
    fd = open(argv[1], O_RDONLY | O_NONBLOCK);
  }
  assert(fd >= 0);

  printf("Doing CDROM_DRIVE_STATUS\n");
  drive = ioctl (fd, CDROM_DRIVE_STATUS, CDSL_CURRENT);

  printf("Got: %x\n", drive);
  sleep(5);
  printf("Doing CDROM_MEDIA_CHANGEDs\n");
  ioctl (fd, CDROM_MEDIA_CHANGED, CDSL_CURRENT);
  ioctl (fd, CDROM_MEDIA_CHANGED, CDSL_CURRENT);

  return 0;
}

Reply via email to