The problem statement is this: I have a directory which is configured as a mountpoint for a SAN partition. Now this SAN partition gets mounted several minutes after boot due to some reasons which I cannot avoid. In the meantime, some processes start writing to the directory (which is still not on SAN and just a local directory), thereby causing trouble.
My goal is to ensure that I do not allow any process to write in the directory while it is local. As soon as SAN gets mounted on it, the processes are free to write.
Make the mount point immutable:
# chattr +i /mnt/foo
Verify that you cannot write there:
# touch /mnt/foo/hello
touch: cannot touch ‘/srv/test/foo’: Permission denied
And now perform the mount:
# mount /dev/foo /mnt/foo