Kudos for your persistance. I hope this makes it in soon.
I see two remaining problems:
+ /* + * This case should never occur, we've already checked permissions earlier + * and we are holding the file handle open. + */ + ERR("Replacement file may not be deleted!\n");
You need to handle this case better; it happens in real life sometimes that the filesystem lies when it tells you you can write. It should be a WARN, and you need to return the proper error code.
Are you quite sure you need to do any file copying? Wouldn't a series of renames be more efficient? - Dan