You cannot open the directory for recording, so this means that you cannot get a write lock.
Even if you could, please keep in mind that flock and fcntl and other types of POSIX locks are advisory, therefore they do not actually interfere with software that does not take into account blocking from actions.
Perhaps you want to see something like xfs_freeze , which locks the entire file system. This is probably not useful for your use case.
source share