[clue-tech] Detecting media change

dennisjperkins at comcast.net dennisjperkins at comcast.net
Thu May 1 12:28:37 MDT 2008


I'm not sure how to do it, but I might be able to point you towards what you need.

If you are using udev, and most distros do nowadays, you might be able to monitor the device in /sysfs.  You might be able to use /proc instead, but /proc is deprecated for most hardware info.

If you are using HAL and dbus, you might be able to register a request with the dbus server to be informed whenever the media is changed.  I'm assuming that HAL can trigger such a message.

I don't know if you could monitor /dev for the existence of the driver  This does require udev.  Does the driver disappear when the media is removed?

 -------------- Original message ----------------------
From: "David L. Willson" <DLWillson at TheGeek.NU>
> Anyone have a "best" way to detect the successful swap of a USB disc (or new 
> blank
> optical media)?
> 
> I want my backup program to automatically detect the attachment of new media, 
> validate a
> few things, and then blank that media.  Hmmm...  I was thinking of doing 
> something fancy
> like reading the UUID off the filesystem and keeping track of that locally, but 
> I guess
> I could do something simpler, like recording a "last-used" bookmark on the 
> currently
> attached disc, and deciding what to do with the currently attached media based 
> on
> whether that bookmark is present and what it's mod-date is.
> 
> Hmmm...  Thoughts?
> 
> David L. Willson
> Trainer/Engineer/Consultant
> MCT, MCSE, Linux+
> (720) 333-LANS
> 
> _______________________________________________
> clue-tech mailing list
> clue-tech at cluedenver.org
> http://www.cluedenver.org/mailman/listinfo/clue-tech



More information about the clue-tech mailing list