I have set up NFS using AWS Storage Gateway and File Share on a Mac environment. When using a specific program to create 0byte files on this NFS, if a file with the same name already exists, the program does not overwrite it but instead retains the existing file.
For example:
- Create a.txt at 12:35 pm
- Create a.txt at 12:40 pm
- The system information for a.txt shows the last modification time as 12:35 pm.
Is it impossible to overwrite 0byte files on NFS? Locally, the files are overwritten correctly. NFS mount options are rw, hard, nolock, and sync; other options have been tried without success.
I tried changing various NFS mount options and also made adjustments to the S3 settings, but I was not able to achieve the desired result.
O_TRUNCon something that was already 0 bytes didn't change the mtime? Honestly, that strikes me as a perfectly reasonable optimization: the file is already empty, so opening it in O_TRUNC mode didn't change anything at all; why update the mtime after an operation that's known to be a noop?>filein shell, oropen('file', 'w')in Python, or anything else that's anopen("file", O_TRUNC). And even if that's not the case at the POSIX layer, since S3 doesn't provide an inode abstraction there's necessarily a translation layer beneath; that layer can reasonably apply its own abstractions changing behavior from what one might otherwise expect.