Skip to contentSkip to conversation

mount notification question

DISCUSSION Daniel Lezcano 3 participants 5 messages Aug 2, 2010 – Aug 6, 2010

lore
Share & tools
lore
#0 lore raw

Hi all,

is there a way to be notified when a mount occurs on the system ?

Thanks
-- Daniel

#1 lore raw
Quoted 4 lines · Daniel Lezcano

Hi all,

is there a way to be notified when a mount occurs on the system ?

Have you looked on google? The link is a bit misleading but they do give a way to do it (not using inotify).

http://stackoverflow.com/questions/1113176/how-could-i-detect-when-a-directory-is-mounted-with-inotify

Chris

Signature · 7 lines
The author works for GENBAND Corporation (GENBAND) who is solely
responsible for this email and its contents. All enquiries regarding
this email should be addressed to GENBAND. Nortel has provided the use
of the nortel.com domain to GENBAND in connection with this email solely
for the purpose of connectivity and Nortel Networks Inc. has no
liability for the email or its contents. GENBAND's web site is
http://www.genband.com
#2 lore raw
Quoted 11 lines · Chris Friesen
Quoted 4 lines · Daniel Lezcano

Hi all,

is there a way to be notified when a mount occurs on the system ?

Have you looked on google? The link is a bit misleading but they do give a way to do it (not using inotify).

http://stackoverflow.com/questions/1113176/how-could-i-detect-when-a-directory-is-mounted-with-inotify

Thanks a lot for the pointer. I am not sure this solution will work, because it is inadequate for watching a specific location in a container context separated by the mount and the network namespaces. We have multiple mount points at the same place (eg. the mount point inheritance, the container configuration and the init scripts may mount /dev or /var/run several time) and the network namespace separation will make impossible to watch udev event via a netlink socket. I didn't look at the inotify implementation but IMHO, it should be worth to add IN_MOUNT and IN_UNMOUNT events for inotify no ?

Thanks
-- Daniel

#3 lore raw
Quoted 9 lines · Daniel Lezcano
Quoted 7 lines · Chris Friesen
Quoted 1 line · Daniel Lezcano

is there a way to be notified when a mount occurs on the system ?

Have you looked on google?  The link is a bit misleading but they do give a way to do it (not using inotify).

http://stackoverflow.com/questions/1113176/how-could-i-detect-when-a-directory-is-mounted-with-inotify

Quoted 9 lines

Thanks a lot for the pointer. I am not sure this solution will work, because it is inadequate for watching a specific location in a container context separated by the mount and the network namespaces. We have multiple mount points at the same place (eg. the mount point inheritance, the container configuration and the init scripts may mount /dev or /var/run several time) and the network namespace separation will make impossible to watch udev event via a netlink socket. I didn't look at the inotify implementation but IMHO, it should be worth to add IN_MOUNT and IN_UNMOUNT events for inotify no ?

These events wouldn't work, and they are long removed from the kernel and don't exist.

You need to poll() /proc/mounts, and any changes in it will wake you up with POLL_ERR. /proc/mounts should be namespace aware.

Kay

#4 lore raw
Quoted 23 lines · Kay Sievers
Quoted 11 lines · Daniel Lezcano
Quoted 9 lines · Chris Friesen
Quoted 2 lines · Daniel Lezcano

is there a way to be notified when a mount occurs on the system ?

Have you looked on google? The link is a bit misleading but they do give a way to do it (not using inotify).

http://stackoverflow.com/questions/1113176/how-could-i-detect-when-a-directory-is-mounted-with-inotify

Quoted 10 lines

Thanks a lot for the pointer. I am not sure this solution will work, because it is inadequate for watching a specific location in a container context separated by the mount and the network namespaces. We have multiple mount points at the same place (eg. the mount point inheritance, the container configuration and the init scripts may mount /dev or /var/run several time) and the network namespace separation will make impossible to watch udev event via a netlink socket. I didn't look at the inotify implementation but IMHO, it should be worth to add IN_MOUNT and IN_UNMOUNT events for inotify no ?

Quoted 6 lines

These events wouldn't work, and they are long removed from the kernel and don't exist.

You need to poll() /proc/mounts, and any changes in it will wake you up with POLL_ERR. /proc/mounts should be namespace aware.

Ah, great ! I will look for this solution (I suppose I will probably have to diff /proc/mounts but anyway ...)

Thanks Kay and Chris for your help.

-- Daniel