I'd like to have a program executed before a mount attempt is made for a particular device/share/mount. For example, I'd like for autofs/amd to control /data/{1..10}, and when a process opens /data/4 (and /data/4 is not currently mounted), a script is invoked, such as '/usr/local/bin/preparedata 4' (4 being the mount point name within the autofs controlled directory), prior to the attempt to mount. For example, I could dynamically attach an iSCSI LUN (which would be referenced in the autofs map), or startup a remote system/VM which has an NFS export (which is specified in the map).
I'd be glad to add details if missing.
Update: I've noticed that systemd appears to be intercepting open() calls, is there some way to do this particularly in systemd?