Mounting remote fs - post mount and pre unmount scripts (linux) -


i'm trying figure out way run script when specific remote fs cifs or nfs mounted , when it's unmounted. have entries in fstab mounting icons automatically created on desktop. need mount overlay fs when specific remote fs mounted , unmount before remote fs gets unmounted. udev monitor see add/remove notifications attributes pretty useless:

~$ udevadm monitor monitor print received events for: udev - event udev sends out after rule processing kernel - kernel uevent  kernel[41113.912505] add      /devices/virtual/bdi/cifs-2 (bdi) udev  [41113.913868] add      /devices/virtual/bdi/cifs-2 (bdi) ^  ~$ udevadm info -a -p /devices/virtual/bdi/cifs-2  udevadm info starts device specified devpath , walks chain of parent devices. prints every device found, possible attributes in udev rules key format. rule match, can composed attributes of device , attributes 1 single parent device.    looking @ device '/devices/virtual/bdi/cifs-2':     kernel=="cifs-2"     subsystem=="bdi"     driver==""     attr{min_ratio}=="0"     attr{stable_pages_required}=="0"     attr{read_ahead_kb}=="1024"     attr{max_ratio}=="100" 

is there can use instead then? thanks

you did not mention programming language, going go ahead pyudev, wrapper udev.

it provides easy way monitor events emitted udev , react them. here example documentation:

the linux kernel emits events whenever devices added, removed (e.g. usb stick plugged or unplugged) or have attributes changed (e.g. charge level of battery changed). pyudev.monitor can react on such events, example react on added or removed mountable filesystems:

>>> monitor = pyudev.monitor.from_netlink(context) >>> monitor.filter_by('block') >>> device in iter(monitor.poll, none): ...     if 'id_fs_type' in device: ...         print('{0} partition {1}'.format(action, device.get('id_fs_label'))) ... add partition multiboot remove partition multiboot 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -