Bug#607267: /usr/bin/scp: fails to notice close() errors
severity 607267 important
On Thu, Dec 08, 2011 at 02:33:00PM +0100, Michal Suchanek wrote:
> FWIW this is unreproducible as of kernel 3.2 rc2 so I guess this is
> squeeze only for cifs shares (as can be verified by running the test on
> a squeeze live CD).
Thanks for reporting. Given the small amount of systems being able to
reproduce this issue I am downgrading the severity. You need an old (or
stable) kernel and a filesystem like cifs. This doesn't seem to be a
frequently encountered combination.
> However, the close() man page clearly states that only doing fsync() you
> can be sure your file was closed successfully.
This is slightly incorrect. If close() returns 0, the file is closed
successfully, so unfortunately your immediate conclusion is wrong again.
The truth is that close() does not ensure that any data has reached a
disk. Also note that using fsync() would not be enough either. It would
just force the file to disk, but not necessarily its entry in a
directory. After a power failure your file would be on the disk, but
there would be no visible reference from your directory tree. You'd have
to call fsync on the directory as well. After all it doesn't seem that
obvious given that you got it wrong. ;-)
I still wonder where it says that cp would guarantee that data would
reach a disk. Can you find a reference? Same question for scp.