filebuf: handle write error in `lock_file`
filebuf: handle write error in `lock_file`

When writing to a file with locking not check if writing the
locked file actually succeeds. Fix the issue by returning error
code and message when writing fails.

joshtriplett/libgit2,joshtriplett/libgit2,stewid/libgit2,leoyanggit/libgit2,jeffhostetler/public_libgit2,Corillian/libgit2,saurabhsuniljain/libgit2,Corillian/libgit2,leoyanggit/libgit2,Corillian/libgit2,jeffhostetler/public_libgit2,leoyanggit/libgit2,saurabhsuniljain/libgit2,stewid/libgit2,joshtriplett/libgit2,jeffhostetler/public_libgit2,leoyanggit/libgit2,Corillian/libgit2,stewid/libgit2,Corillian/libgit2,saurabhsuniljain/libgit2,joshtriplett/libgit2,jeffhostetler/public_libgit2,jeffhostetler/public_libgit2,stewid/libgit2,Corillian/libgit2,saurabhsuniljain/libgit2,saurabhsuniljain/libgit2,joshtriplett/libgit2,joshtriplett/libgit2,saurabhsuniljain/libgit2,leoyanggit/libgit2,stewid/libgit2,jeffhostetler/public_libgit2,leoyanggit/libgit2,stewid/libgit2