Comment 0 for bug 1895619

Revision history for this message
Paul Collins (pjdc) wrote :

The fstab module does this:

```
class Fstab(io.FileIO):
    # [...]
    def remove_entry(self, entry):
        # [...]
        self.seek(0)
        self.write(''.join(lines).encode('us-ascii'))
        self.truncate()
```

If the machine crashes between seek and write, or if write is large enough to be split into multiple operations, /etc/fstab will be empty or incomplete.

Instead the file should be always updated using the write-new-file/fsync/rename/fsync pattern.

(Depending on which filesystem developer you're talking to, the weather, and the condition of the Sun's corona, you may be recommended different recipes. But the current methodology is certainly flawed.)