0

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:

  1. Create a.txt at 12:35 pm
  2. Create a.txt at 12:40 pm
  3. 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.

4
  • Your only evidence is that the file hasn't been overridden is that O_TRUNC on 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? Commented May 29, 2024 at 0:58
  • (Regardless, do you have a question about writing code? If this is about filesystem semantics, it might be better suited to Unix & Linux than here). Commented May 29, 2024 at 1:08
  • Yes, I could tell that the file wasn't overwritten from the mtime. The hash value, inode, and filesystem block did not change. My main question is why the mtime changes when performing the same action locally but not on NFS. As you suggested, I will find a suitable forum to ask this question. Thank you. Commented May 29, 2024 at 1:18
  • nod. Depending on how it's "overwritten", the inode not changing may be completely normal -- that's the case for >file in shell, or open('file', 'w') in Python, or anything else that's an open("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. Commented May 29, 2024 at 1:29

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.