site  contact  subhomenews

mount/umount uevents

May 09, 2008 — BarryK
I was testing 'hotplug2stdout' on the 2.6.25 kernel, and it works for inserting and removing drives, but there are no kernel uevents when a partition is mounted or unmounted.

I looked around and found this in a 2.6.22 changelog:
-What: mount/umount uevents
-When: February 2007
-Why: These events are not correct, and do not properly let userspace know
- when a file system has been mounted or unmounted. Userspace should
- poll the /proc/mounts file instead to detect this properly.


inotifywait does not work

Another option
Username: Everitt
"IIRC aren't 'mount' and 'umount' scripts in puppy? Wouldn't it be possible to add something to send a signal whenever something is mounted and unmounted, and only look at the /proc/mounts when something has changed? I'm not sure how easy that'd be to build into the existing uevents code though.

Futher to 'Another option'
Username: Everitt
"Hmm, I've been looking into it all day. As far as I can tell it is possible to write a userspace application to send events via netmessage (ie a 'mount' or 'umount' notification), which hotplug2stdout will recieve. Unfortunately the interface doesn't seem to have any userfriendly documentation. My knowledge of C is very limited, I work with numbers, not text, so all I'm able to send at the moment is a single char. Interestingly the udevadm monitor --kernel reports (null) (null) (null) when I do this, sujesting that there is some precise format the message should be sent in. I can't for the life of me work it out though. If Puppy is only going to use a custom system (no udev) then I doubt that's an issue, assuming that a full string can be sent. It seems rather complicated when polling still works though... If you're interested I can post the code I have to the forum, but I'm going to give up on it myself; I have exams to revise for. :(

Sorry for posting so much!
Username: Everitt
"Sorry, I keep missnig obvious idea! Why not just add a line to the (u)mount scripts to write something to a file in /tmp or /var, and use inotifywait to detect this? There is of course still the problem of monitoring uevents and mounting at the same time.

Tags: puppy