Let's say I have file X with string ABCD. I then edit the file using open X, seek to 0, truncate, write 1234. Will ABCD remain anywhere on the harddrive? Assuming it would be large file over number of sectors / inodes.
Let's say I have file X with string ABCD. I then edit the file using open X, seek to 0, truncate, write 1234. Will ABCD remain anywhere on the harddrive? Assuming it would be large file over number of sectors / inodes.
To my knowledge, there is no guarantee that if you truncate the file, you would get allocated the same block for the next write operation. In that case, you would indeed end up with a copy of the data in an old block.
If you are on an SSD, this is guaranteed to happen even if you overwrite the data byte-wise and regardless of the file system, as SSDs are always copy-on-write for performance reasons.
No, it does not. Also, file locking is used to prevent this, but that is up to the program’s developer.