Re: accessing media_changed() for CDROMs

Jens Axboe (axboe@image.dk)
Thu, 04 Feb 1999 22:46:11 +0100


"D.A. Harris" wrote:
>
> Hi,
>
> I would have sent this to the linux-c-programming list, but it appears to
> be down.
>
> I'm pretty new to programming on Linux, especially when it involves trying
> to interface with the kernel. I have a test program attached that basically
> just trying to get status of media_changed(), so I can tell if a CDROM has
> changed. The grand plan is to set up a daemon that can monitor media
> changed events for various types of media, and do operations like automatic
> mounting, kind of like mediad on IRIX. But right now I don't have much
> clue. So can anyone point me in the right direction? Am I even doing the
> ioctl() call right? One thing for sure is that the call to media_changed()
> generates a segmetation violation.

The correct way to use the ioctl, would be something like this :

changed = ioctl(drive, CDROM_MEDIA_CHANGED, CDSL_CURRENT);

And that is the only way you can do it. There's no way you can retrieve
the info by trying to call media_changed() - userspace programs can't
access kernelspace functions like that. Hey, that's one of the reasons
for ioctl!

-- 
*  Jens Axboe <axboe@image.dk>
*  Linux CD-ROM Maintainer
* "The only thing that interferes with my
*  learning is my education." -- A. Einstein

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/