I'm developing a encrypte&decrypt filesystem on Mac. I use MacFuse to realize this filesystem and mount it under a folder.
By doing this I can hook the open file method when user are trying to open the encrypted file(such as A.rtf) under the mounted folder. Then I will decrypt A.rtf and generate a new decrypted file, let's call it as B.rtf. In the hooked open file method, I will return B.rtf file descriptor so that the user can open the decrypted file.
All works fine, until I opend the encrypted file once and copy it. It seems Mac system directly using the decrypted cache data when doing copy, so the decrypted content will be copied.
I tried add fcntl(fd, F_NOCACHE, 1); fcntl(fd, F_NODIRECT, 1)
after int fd = open([p UTF8String], mode);
, but it not work.
So is there a way to clearly tell the Mac system, do not cache my data when open files?