I have a program which writes some files to a directory. My problem is that if the directory isn't mounted for some reason, the program writes to the directory anyway, but the files end up in the system's filesystem, not on the normally mounted filesystem. I would like writes to the directory to fail if that directory isn't mounted. How do I do this in Linux?
How to only allow a program to write to a directory if it is mounted
linuxmount
Best Answer
Make the underlying mount point read-only.
When the additional filesystem is mounted, it's permissions take precedence IIRC.