A short, sad story:
I spent most of the day writing coding in a single source file. As I
have done thousands of times, I save-exit JOE, then run make. The
linker returns an error about "main" not being found. That's strange,
maybe I accidentally deleted it? Open the file, it's empty. What,
did I open a new file by mistake? Running an "ls -l" shows the file
as zero bytes. Huh? In the next minutes, I find out that someone
filled up the NFS mount, causing JOE to unlink and recreate the file,
but without being able to write any data. Source code, say good-bye.
The correct fix is to add an option for reliable saves as the default:
- open a temporary file in the same directory as the save target (i.e.
on the same device)
- write to the temp file
- close the temp file (check the return status, as NFS can error here)
- fsync the temp file
- rename the temp file to the target name
Those more familiar with the JOE source feel free to volunteer (saver
confused me a bit), otherwise I can add this.