[clue-tech] Detecting media change
David L. Willson
DLWillson at TheGeek.NU
Thu May 1 12:50:59 MDT 2008
Overkill for what I need.
I just need to "look" at a given filesystem from a script, and determine whether I own
it, and whether it's the one I used yesterday. If I own it AND it's the one I used
yesterday, I'll just do my normal thing. If I don't own it, I'll scream and holler. If
I own it AND it's NOT the one I used yesterday, I'll blank it and then do my normal thing.
I think I just wrote the script I need, minus translation into bash-ese.
On Thu, 01 May 2008 18:28:37 +0000, dennisjperkins wrote
> 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
>
> _______________________________________________
> clue-tech mailing list
> clue-tech at cluedenver.org
> http://www.cluedenver.org/mailman/listinfo/clue-tech
David L. Willson
Trainer/Engineer/Consultant
MCT, MCSE, Linux+
(720) 333-LANS
More information about the clue-tech
mailing list